create-payload-app
Advanced tools
Comparing version 3.0.0-alpha.59 to 3.0.0-alpha.60
#!/usr/bin/env node | ||
require('../dist/index.js') | ||
import { main } from '../dist/index.js' | ||
main() |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
export declare function main(): Promise<void>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,12 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _main = require("./main.js"); | ||
const _log = require("./utils/log.js"); | ||
async function main() { | ||
await new _main.Main().init(); | ||
import { Main } from './main.js'; | ||
import { error } from './utils/log.js'; | ||
export async function main() { | ||
try { | ||
await new Main().init(); | ||
} catch (e) { | ||
if (e instanceof Error) { | ||
error(e.message); | ||
} | ||
} | ||
} | ||
main().catch((e)=>(0, _log.error)(`An error has occurred: ${e instanceof Error ? e.message : e}`)); | ||
//# sourceMappingURL=index.js.map |
@@ -1,21 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "configurePayloadConfig", { | ||
enumerable: true, | ||
get: function() { | ||
return configurePayloadConfig; | ||
} | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _globby = /*#__PURE__*/ _interop_require_default(require("globby")); | ||
const _log = require("../utils/log.js"); | ||
const _packages = require("./packages.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
async function configurePayloadConfig(args) { | ||
import fse from 'fs-extra'; | ||
import globby from 'globby'; | ||
import { warning } from '../utils/log.js'; | ||
import { dbReplacements } from './packages.js'; | ||
/** Update payload config with necessary imports and adapters */ export async function configurePayloadConfig(args) { | ||
if (!args.dbDetails) { | ||
@@ -27,3 +12,3 @@ return; | ||
if (!('payloadConfigPath' in args.projectDirOrConfigPath)) { | ||
payloadConfigPath = (await (0, _globby.default)('**/payload.config.ts', { | ||
payloadConfigPath = (await globby('**/payload.config.ts', { | ||
absolute: true, | ||
@@ -36,8 +21,8 @@ cwd: args.projectDirOrConfigPath.projectDir | ||
if (!payloadConfigPath) { | ||
(0, _log.warning)('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.'); | ||
warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.'); | ||
return; | ||
} | ||
const configContent = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8'); | ||
const configContent = fse.readFileSync(payloadConfigPath, 'utf-8'); | ||
const configLines = configContent.split('\n'); | ||
const dbReplacement = _packages.dbReplacements[args.dbDetails.type]; | ||
const dbReplacement = dbReplacements[args.dbDetails.type]; | ||
let dbConfigStartLineIndex; | ||
@@ -57,3 +42,3 @@ let dbConfigEndLineIndex; | ||
if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) { | ||
(0, _log.warning)('Unable to update payload.config.ts with database adapter import'); | ||
warning('Unable to update payload.config.ts with database adapter import'); | ||
} else { | ||
@@ -63,5 +48,5 @@ // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end` | ||
} | ||
_fsextra.default.writeFileSync(payloadConfigPath, configLines.join('\n')); | ||
fse.writeFileSync(payloadConfigPath, configLines.join('\n')); | ||
} catch (err) { | ||
(0, _log.warning)(`Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`); | ||
warning(`Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`); | ||
} | ||
@@ -68,0 +53,0 @@ } |
@@ -1,80 +0,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
createProject: function() { | ||
return createProject; | ||
}, | ||
updatePackageJSON: function() { | ||
return updatePackageJSON; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _degit = /*#__PURE__*/ _interop_require_default(require("degit")); | ||
const _execa = /*#__PURE__*/ _interop_require_default(require("execa")); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _nodeurl = require("node:url"); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _log = require("../utils/log.js"); | ||
const _configurepayloadconfig = require("./configure-payload-config.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()); | ||
const dirname = _path.default.dirname(filename); | ||
import * as p from '@clack/prompts'; | ||
import chalk from 'chalk'; | ||
import degit from 'degit'; | ||
import execa from 'execa'; | ||
import fse from 'fs-extra'; | ||
import { fileURLToPath } from 'node:url'; | ||
import path from 'path'; | ||
import { debug, error, warning } from '../utils/log.js'; | ||
import { configurePayloadConfig } from './configure-payload-config.js'; | ||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
async function createOrFindProjectDir(projectDir) { | ||
const pathExists = await _fsextra.default.pathExists(projectDir); | ||
const pathExists = await fse.pathExists(projectDir); | ||
if (!pathExists) { | ||
await _fsextra.default.mkdir(projectDir); | ||
await fse.mkdir(projectDir); | ||
} | ||
@@ -94,15 +30,15 @@ } | ||
try { | ||
await _execa.default.command(installCmd, { | ||
cwd: _path.default.resolve(projectDir) | ||
await execa.command(installCmd, { | ||
cwd: path.resolve(projectDir) | ||
}); | ||
return true; | ||
} catch (err) { | ||
(0, _log.error)(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`); | ||
error(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`); | ||
return false; | ||
} | ||
} | ||
async function createProject(args) { | ||
export async function createProject(args) { | ||
const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args; | ||
if (cliArgs['--dry-run']) { | ||
(0, _log.debug)(`Dry run: Creating project in ${_chalk.default.green(projectDir)}`); | ||
debug(`Dry run: Creating project in ${chalk.green(projectDir)}`); | ||
return; | ||
@@ -113,4 +49,4 @@ } | ||
// Copy template from local path. For development purposes. | ||
const localTemplate = _path.default.resolve(dirname, '../../../../templates/', cliArgs['--local-template']); | ||
await _fsextra.default.copy(localTemplate, projectDir); | ||
const localTemplate = path.resolve(dirname, '../../../../templates/', cliArgs['--local-template']); | ||
await fse.copy(localTemplate, projectDir); | ||
} else if ('url' in template) { | ||
@@ -120,8 +56,8 @@ let templateUrl = template.url; | ||
templateUrl = `${template.url}#${cliArgs['--template-branch']}`; | ||
(0, _log.debug)(`Using template url: ${templateUrl}`); | ||
debug(`Using template url: ${templateUrl}`); | ||
} | ||
const emitter = (0, _degit.default)(templateUrl); | ||
const emitter = degit(templateUrl); | ||
await emitter.clone(projectDir); | ||
} | ||
const spinner = _prompts.spinner(); | ||
const spinner = p.spinner(); | ||
spinner.start('Checking latest Payload version...'); | ||
@@ -133,3 +69,3 @@ await updatePackageJSON({ | ||
spinner.message('Configuring Payload...'); | ||
await (0, _configurepayloadconfig.configurePayloadConfig)({ | ||
await configurePayloadConfig({ | ||
dbDetails, | ||
@@ -141,5 +77,5 @@ projectDirOrConfigPath: { | ||
// Remove yarn.lock file. This is only desired in Payload Cloud. | ||
const lockPath = _path.default.resolve(projectDir, 'yarn.lock'); | ||
if (_fsextra.default.existsSync(lockPath)) { | ||
await _fsextra.default.remove(lockPath); | ||
const lockPath = path.resolve(projectDir, 'yarn.lock'); | ||
if (fse.existsSync(lockPath)) { | ||
await fse.remove(lockPath); | ||
} | ||
@@ -162,13 +98,13 @@ if (!cliArgs['--no-deps']) { | ||
} | ||
async function updatePackageJSON(args) { | ||
export async function updatePackageJSON(args) { | ||
const { projectDir, projectName } = args; | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJsonPath = path.resolve(projectDir, 'package.json'); | ||
try { | ||
const packageObj = await _fsextra.default.readJson(packageJsonPath); | ||
const packageObj = await fse.readJson(packageJsonPath); | ||
packageObj.name = projectName; | ||
await _fsextra.default.writeJson(packageJsonPath, packageObj, { | ||
await fse.writeJson(packageJsonPath, packageObj, { | ||
spaces: 2 | ||
}); | ||
} catch (err) { | ||
(0, _log.warning)(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`); | ||
warning(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`); | ||
} | ||
@@ -175,0 +111,0 @@ } |
@@ -1,20 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _createproject = require("./create-project.js"); | ||
const _nodeurl = require("node:url"); | ||
const _packages = require("./packages.js"); | ||
const _templates = require("./templates.js"); | ||
const _globby = /*#__PURE__*/ _interop_require_default(require("globby")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()); | ||
const dirname = _path.default.dirname(filename); | ||
const projectDir = _path.default.resolve(dirname, './tmp'); | ||
import fse from 'fs-extra'; | ||
import path from 'path'; | ||
import { createProject } from './create-project.js'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dbReplacements } from './packages.js'; | ||
import { getValidTemplates } from './templates.js'; | ||
import globby from 'globby'; | ||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
const projectDir = path.resolve(dirname, './tmp'); | ||
describe('createProject', ()=>{ | ||
@@ -25,4 +16,4 @@ beforeAll(()=>{ | ||
beforeEach(()=>{ | ||
if (_fsextra.default.existsSync(projectDir)) { | ||
_fsextra.default.rmdirSync(projectDir, { | ||
if (fse.existsSync(projectDir)) { | ||
fse.rmdirSync(projectDir, { | ||
recursive: true | ||
@@ -33,4 +24,4 @@ }); | ||
afterEach(()=>{ | ||
if (_fsextra.default.existsSync(projectDir)) { | ||
_fsextra.default.rmSync(projectDir, { | ||
if (fse.existsSync(projectDir)) { | ||
fse.rmSync(projectDir, { | ||
recursive: true | ||
@@ -59,3 +50,3 @@ }); | ||
}; | ||
await (0, _createproject.createProject)({ | ||
await createProject({ | ||
cliArgs: args, | ||
@@ -67,4 +58,4 @@ projectName, | ||
}); | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJson = _fsextra.default.readJsonSync(packageJsonPath); | ||
const packageJsonPath = path.resolve(projectDir, 'package.json'); | ||
const packageJson = fse.readJsonSync(packageJsonPath); | ||
// Check package name and description | ||
@@ -74,3 +65,3 @@ expect(packageJson.name).toEqual(projectName); | ||
describe('creates project from template', ()=>{ | ||
const templates = (0, _templates.getValidTemplates)(); | ||
const templates = getValidTemplates(); | ||
it.each([ | ||
@@ -93,3 +84,3 @@ [ | ||
}; | ||
await (0, _createproject.createProject)({ | ||
await createProject({ | ||
cliArgs, | ||
@@ -105,8 +96,8 @@ projectName, | ||
}); | ||
const dbReplacement = _packages.dbReplacements[db]; | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJson = _fsextra.default.readJsonSync(packageJsonPath); | ||
const dbReplacement = dbReplacements[db]; | ||
const packageJsonPath = path.resolve(projectDir, 'package.json'); | ||
const packageJson = fse.readJsonSync(packageJsonPath); | ||
// Should only have one db adapter | ||
expect(Object.keys(packageJson.dependencies).filter((n)=>n.startsWith('@payloadcms/db-'))).toHaveLength(1); | ||
const payloadConfigPath = (await (0, _globby.default)('**/payload.config.ts', { | ||
const payloadConfigPath = (await globby('**/payload.config.ts', { | ||
absolute: true, | ||
@@ -118,3 +109,3 @@ cwd: projectDir | ||
} | ||
const content = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8'); | ||
const content = fse.readFileSync(payloadConfigPath, 'utf-8'); | ||
// Check payload.config.ts | ||
@@ -121,0 +112,0 @@ expect(content).not.toContain('// database-adapter-import'); |
@@ -1,16 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "generateSecret", { | ||
enumerable: true, | ||
get: function() { | ||
return generateSecret; | ||
} | ||
}); | ||
const _crypto = require("crypto"); | ||
function generateSecret() { | ||
return (0, _crypto.randomBytes)(32).toString('hex').slice(0, 24); | ||
import { randomBytes } from 'crypto'; | ||
export function generateSecret() { | ||
return randomBytes(32).toString('hex').slice(0, 24); | ||
} | ||
//# sourceMappingURL=generate-secret.js.map |
@@ -1,82 +0,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
getNextAppDetails: function() { | ||
return getNextAppDetails; | ||
}, | ||
initNext: function() { | ||
return initNext; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _commentjson = require("comment-json"); | ||
const _execa = /*#__PURE__*/ _interop_require_default(require("execa")); | ||
const _fs = /*#__PURE__*/ _interop_require_default(require("fs")); | ||
const _globby = /*#__PURE__*/ _interop_require_default(require("globby")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _util = require("util"); | ||
const _nodeurl = require("node:url"); | ||
const _copyrecursivesync = require("../utils/copy-recursive-sync.js"); | ||
const _log = require("../utils/log.js"); | ||
const _messages = require("../utils/messages.js"); | ||
const _wrapnextconfig = require("./wrap-next-config.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
const readFile = (0, _util.promisify)(_fs.default.readFile); | ||
const writeFile = (0, _util.promisify)(_fs.default.writeFile); | ||
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()); | ||
const dirname = _path.default.dirname(filename); | ||
async function initNext(args) { | ||
import * as p from '@clack/prompts'; | ||
import { parse, stringify } from 'comment-json'; | ||
import execa from 'execa'; | ||
import fs from 'fs'; | ||
import globby from 'globby'; | ||
import path from 'path'; | ||
import { promisify } from 'util'; | ||
const readFile = promisify(fs.readFile); | ||
const writeFile = promisify(fs.writeFile); | ||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
import { fileURLToPath } from 'node:url'; | ||
import { copyRecursiveSync } from '../utils/copy-recursive-sync.js'; | ||
import { debug as origDebug, warning } from '../utils/log.js'; | ||
import { moveMessage } from '../utils/messages.js'; | ||
import { wrapNextConfig } from './wrap-next-config.js'; | ||
export async function initNext(args) { | ||
const { dbType: dbType, packageManager, projectDir } = args; | ||
@@ -94,3 +30,3 @@ const nextAppDetails = args.nextAppDetails || await getNextAppDetails(projectDir); | ||
// Output directions for user to move all files from app to top-level directory named `(app)` | ||
_prompts.log.warn((0, _messages.moveMessage)({ | ||
p.log.warn(moveMessage({ | ||
nextAppDir, | ||
@@ -106,3 +42,3 @@ projectDir | ||
} | ||
const installSpinner = _prompts.spinner(); | ||
const installSpinner = p.spinner(); | ||
installSpinner.start('Installing Payload and dependencies...'); | ||
@@ -143,7 +79,7 @@ const configurationResult = installAndConfigurePayload({ | ||
async function addPayloadConfigToTsConfig(projectDir, isSrcDir) { | ||
const tsConfigPath = _path.default.resolve(projectDir, 'tsconfig.json'); | ||
const tsConfigPath = path.resolve(projectDir, 'tsconfig.json'); | ||
const userTsConfigContent = await readFile(tsConfigPath, { | ||
encoding: 'utf8' | ||
}); | ||
const userTsConfig = (0, _commentjson.parse)(userTsConfigContent); | ||
const userTsConfig = parse(userTsConfigContent); | ||
if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) { | ||
@@ -159,3 +95,3 @@ userTsConfig.compilerOptions = {}; | ||
}; | ||
await writeFile(tsConfigPath, (0, _commentjson.stringify)(userTsConfig, null, 2), { | ||
await writeFile(tsConfigPath, stringify(userTsConfig, null, 2), { | ||
encoding: 'utf8' | ||
@@ -174,5 +110,5 @@ }); | ||
const logDebug = (message)=>{ | ||
if (debug) (0, _log.debug)(message); | ||
if (debug) origDebug(message); | ||
}; | ||
if (!_fs.default.existsSync(projectDir)) { | ||
if (!fs.existsSync(projectDir)) { | ||
return { | ||
@@ -183,5 +119,5 @@ reason: `Could not find specified project directory at ${projectDir}`, | ||
} | ||
const templateFilesPath = dirname.endsWith('dist') || useDistFiles ? _path.default.resolve(dirname, '../..', 'dist/template') : _path.default.resolve(dirname, '../../../../templates/blank-3.0'); | ||
const templateFilesPath = dirname.endsWith('dist') || useDistFiles ? path.resolve(dirname, '../..', 'dist/template') : path.resolve(dirname, '../../../../templates/blank-3.0'); | ||
logDebug(`Using template files from: ${templateFilesPath}`); | ||
if (!_fs.default.existsSync(templateFilesPath)) { | ||
if (!fs.existsSync(templateFilesPath)) { | ||
return { | ||
@@ -195,3 +131,3 @@ reason: `Could not find template source files from ${templateFilesPath}`, | ||
logDebug(`Copying template files from ${templateFilesPath} to ${nextAppDir}`); | ||
const templateSrcDir = _path.default.resolve(templateFilesPath, isSrcDir ? '' : 'src'); | ||
const templateSrcDir = path.resolve(templateFilesPath, isSrcDir ? '' : 'src'); | ||
logDebug(`templateSrcDir: ${templateSrcDir}`); | ||
@@ -201,11 +137,11 @@ logDebug(`nextAppDir: ${nextAppDir}`); | ||
logDebug(`nextConfigPath: ${nextConfigPath}`); | ||
logDebug(`isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${_path.default.dirname(nextConfigPath)}`); | ||
logDebug(`isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`); | ||
// This is a little clunky and needs to account for isSrcDir | ||
(0, _copyrecursivesync.copyRecursiveSync)(templateSrcDir, _path.default.dirname(nextConfigPath), debug); | ||
copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath), debug); | ||
// Wrap next.config.js with withPayload | ||
(0, _wrapnextconfig.wrapNextConfig)({ | ||
wrapNextConfig({ | ||
nextConfigPath | ||
}); | ||
return { | ||
payloadConfigPath: _path.default.resolve(nextAppDir, '../payload.config.ts'), | ||
payloadConfigPath: path.resolve(nextAppDir, '../payload.config.ts'), | ||
success: true | ||
@@ -225,3 +161,3 @@ }; | ||
{ | ||
({ exitCode } = await (0, _execa.default)('npm', [ | ||
({ exitCode } = await execa('npm', [ | ||
'install', | ||
@@ -238,3 +174,3 @@ '--save', | ||
{ | ||
({ exitCode } = await (0, _execa.default)(packageManager, [ | ||
({ exitCode } = await execa(packageManager, [ | ||
'add', | ||
@@ -249,4 +185,4 @@ ...packagesToInstall | ||
{ | ||
(0, _log.warning)('Bun support is untested.'); | ||
({ exitCode } = await (0, _execa.default)('bun', [ | ||
warning('Bun support is untested.'); | ||
({ exitCode } = await execa('bun', [ | ||
'add', | ||
@@ -264,5 +200,5 @@ ...packagesToInstall | ||
} | ||
async function getNextAppDetails(projectDir) { | ||
const isSrcDir = _fs.default.existsSync(_path.default.resolve(projectDir, 'src')); | ||
const nextConfigPath = (await (0, _globby.default)('next.config.*js', { | ||
export async function getNextAppDetails(projectDir) { | ||
const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src')); | ||
const nextConfigPath = (await globby('next.config.*js', { | ||
absolute: true, | ||
@@ -278,3 +214,3 @@ cwd: projectDir | ||
} | ||
let nextAppDir = (await (0, _globby.default)([ | ||
let nextAppDir = (await globby([ | ||
'**/app' | ||
@@ -289,3 +225,3 @@ ], { | ||
} | ||
const hasTopLevelLayout = nextAppDir ? _fs.default.existsSync(_path.default.resolve(nextAppDir, 'layout.tsx')) : false; | ||
const hasTopLevelLayout = nextAppDir ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx')) : false; | ||
return { | ||
@@ -292,0 +228,0 @@ hasTopLevelLayout, |
@@ -1,11 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "dbReplacements", { | ||
enumerable: true, | ||
get: function() { | ||
return dbReplacements; | ||
} | ||
}); | ||
const mongodbReplacement = { | ||
@@ -32,3 +22,3 @@ importReplacement: "import { mongooseAdapter } from '@payloadcms/db-mongodb'", | ||
}; | ||
const dbReplacements = { | ||
export const dbReplacements = { | ||
mongodb: mongodbReplacement, | ||
@@ -35,0 +25,0 @@ postgres: postgresReplacement |
@@ -1,63 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "parseProjectName", { | ||
enumerable: true, | ||
get: function() { | ||
return parseProjectName; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
async function parseProjectName(args) { | ||
if (args['--name']) return (0, _slugify.default)(args['--name']); | ||
if (args._[0]) return (0, _slugify.default)(args._[0]); | ||
const projectName = await _prompts.text({ | ||
import * as p from '@clack/prompts'; | ||
import slugify from '@sindresorhus/slugify'; | ||
export async function parseProjectName(args) { | ||
if (args['--name']) return slugify(args['--name']); | ||
if (args._[0]) return slugify(args._[0]); | ||
const projectName = await p.text({ | ||
message: 'Project name?', | ||
@@ -68,8 +12,8 @@ validate: (value)=>{ | ||
}); | ||
if (_prompts.isCancel(projectName)) { | ||
if (p.isCancel(projectName)) { | ||
process.exit(0); | ||
} | ||
return (0, _slugify.default)(projectName); | ||
return slugify(projectName); | ||
} | ||
//# sourceMappingURL=parse-project-name.js.map |
@@ -1,54 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "parseTemplate", { | ||
enumerable: true, | ||
get: function() { | ||
return parseTemplate; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
async function parseTemplate(args, validTemplates) { | ||
import * as p from '@clack/prompts'; | ||
export async function parseTemplate(args, validTemplates) { | ||
if (args['--template']) { | ||
@@ -60,3 +9,3 @@ const templateName = args['--template']; | ||
} | ||
const response = await _prompts.select({ | ||
const response = await p.select({ | ||
message: 'Choose project template', | ||
@@ -70,3 +19,3 @@ options: validTemplates.map((p)=>{ | ||
}); | ||
if (_prompts.isCancel(response)) { | ||
if (p.isCancel(response)) { | ||
process.exit(0); | ||
@@ -73,0 +22,0 @@ } |
@@ -1,59 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "selectDb", { | ||
enumerable: true, | ||
get: function() { | ||
return selectDb; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
import * as p from '@clack/prompts'; | ||
import slugify from '@sindresorhus/slugify'; | ||
const dbChoiceRecord = { | ||
@@ -71,3 +15,3 @@ mongodb: { | ||
}; | ||
async function selectDb(args, projectName) { | ||
export async function selectDb(args, projectName) { | ||
let dbType = undefined; | ||
@@ -80,3 +24,3 @@ if (args['--db']) { | ||
} else { | ||
dbType = await _prompts.select({ | ||
dbType = await p.select({ | ||
initialValue: 'mongodb', | ||
@@ -95,7 +39,7 @@ message: `Select a database`, | ||
}); | ||
if (_prompts.isCancel(dbType)) process.exit(0); | ||
if (p.isCancel(dbType)) process.exit(0); | ||
} | ||
const dbChoice = dbChoiceRecord[dbType]; | ||
let dbUri = undefined; | ||
const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : (0, _slugify.default)(projectName)}`; | ||
const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)}`; | ||
if (args['--db-accept-recommended']) { | ||
@@ -106,7 +50,7 @@ dbUri = initialDbUri; | ||
} else { | ||
dbUri = await _prompts.text({ | ||
dbUri = await p.text({ | ||
initialValue: initialDbUri, | ||
message: `Enter ${dbChoice.title.split(' ')[0]} connection string` | ||
}); | ||
if (_prompts.isCancel(dbUri)) process.exit(0); | ||
if (p.isCancel(dbUri)) process.exit(0); | ||
} | ||
@@ -113,0 +57,0 @@ return { |
@@ -1,25 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
getValidTemplates: function() { | ||
return getValidTemplates; | ||
}, | ||
validateTemplate: function() { | ||
return validateTemplate; | ||
} | ||
}); | ||
const _log = require("../utils/log.js"); | ||
function validateTemplate(templateName) { | ||
import { error, info } from '../utils/log.js'; | ||
export function validateTemplate(templateName) { | ||
const validTemplates = getValidTemplates(); | ||
if (!validTemplates.map((t)=>t.name).includes(templateName)) { | ||
(0, _log.error)(`'${templateName}' is not a valid template.`); | ||
(0, _log.info)(`Valid templates: ${validTemplates.map((t)=>t.name).join(', ')}`); | ||
error(`'${templateName}' is not a valid template.`); | ||
info(`Valid templates: ${validTemplates.map((t)=>t.name).join(', ')}`); | ||
return false; | ||
@@ -29,3 +11,3 @@ } | ||
} | ||
function getValidTemplates() { | ||
export function getValidTemplates() { | ||
return [ | ||
@@ -32,0 +14,0 @@ { |
@@ -1,35 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
parseAndModifyConfigContent: function() { | ||
return parseAndModifyConfigContent; | ||
}, | ||
withPayloadImportStatement: function() { | ||
return withPayloadImportStatement; | ||
}, | ||
wrapNextConfig: function() { | ||
return wrapNextConfig; | ||
} | ||
}); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _esprima = require("esprima"); | ||
const _fs = /*#__PURE__*/ _interop_require_default(require("fs")); | ||
const _log = require("../utils/log.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const withPayloadImportStatement = `import { withPayload } from '@payloadcms/next'\n`; | ||
const wrapNextConfig = (args)=>{ | ||
import chalk from 'chalk'; | ||
import { parseModule } from 'esprima'; | ||
import fs from 'fs'; | ||
import { warning } from '../utils/log.js'; | ||
import { log } from '../utils/log.js'; | ||
export const withPayloadImportStatement = `import { withPayload } from '@payloadcms/next'\n`; | ||
export const wrapNextConfig = (args)=>{ | ||
const { nextConfigPath } = args; | ||
const configContent = _fs.default.readFileSync(nextConfigPath, 'utf8'); | ||
const configContent = fs.readFileSync(nextConfigPath, 'utf8'); | ||
const { modifiedConfigContent: newConfig, success } = parseAndModifyConfigContent(configContent); | ||
@@ -39,7 +14,9 @@ if (!success) { | ||
} | ||
_fs.default.writeFileSync(nextConfigPath, newConfig); | ||
fs.writeFileSync(nextConfigPath, newConfig); | ||
}; | ||
function parseAndModifyConfigContent(content) { | ||
/** | ||
* Parses config content with AST and wraps it with withPayload function | ||
*/ export function parseAndModifyConfigContent(content) { | ||
content = withPayloadImportStatement + content; | ||
const ast = (0, _esprima.parseModule)(content, { | ||
const ast = parseModule(content, { | ||
loc: true | ||
@@ -61,4 +38,4 @@ }); | ||
if (exportSpecifier) { | ||
(0, _log.warning)('Could not automatically wrap next.config.js with withPayload.'); | ||
(0, _log.warning)('Automatic wrapping of named exports as default not supported yet.'); | ||
warning('Could not automatically wrap next.config.js with withPayload.'); | ||
warning('Automatic wrapping of named exports as default not supported yet.'); | ||
warnUserWrapNotSuccessful(); | ||
@@ -71,3 +48,3 @@ return { | ||
} | ||
(0, _log.warning)('Could not automatically wrap next.config.js with withPayload.'); | ||
warning('Could not automatically wrap next.config.js with withPayload.'); | ||
warnUserWrapNotSuccessful(); | ||
@@ -83,3 +60,3 @@ return { | ||
${_chalk.default.bold(`Please manually wrap your existing next.config.js with the withPayload function. Here is an example:`)} | ||
${chalk.bold(`Please manually wrap your existing next.config.js with the withPayload function. Here is an example:`)} | ||
@@ -95,3 +72,3 @@ import withPayload from '@payloadcms/next/withPayload' | ||
`; | ||
(0, _log.log)(withPayloadMessage); | ||
log(withPayloadMessage); | ||
} | ||
@@ -98,0 +75,0 @@ function insertBeforeAndAfter(content, loc) { |
@@ -1,48 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _wrapnextconfig = require("./wrap-next-config.js"); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
import { parseAndModifyConfigContent, withPayloadImportStatement } from './wrap-next-config.js'; | ||
import * as p from '@clack/prompts'; | ||
const defaultNextConfig = `/** @type {import('next').NextConfig} */ | ||
@@ -75,13 +30,13 @@ const nextConfig = {}; | ||
it('should parse the default next config', ()=>{ | ||
const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(defaultNextConfig); | ||
expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement); | ||
const { modifiedConfigContent } = parseAndModifyConfigContent(defaultNextConfig); | ||
expect(modifiedConfigContent).toContain(withPayloadImportStatement); | ||
expect(modifiedConfigContent).toContain('withPayload(nextConfig)'); | ||
}); | ||
it('should parse the config with a function', ()=>{ | ||
const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigWithFunc); | ||
const { modifiedConfigContent } = parseAndModifyConfigContent(nextConfigWithFunc); | ||
expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))'); | ||
}); | ||
it('should parse the config with a function on a new line', ()=>{ | ||
const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigWithFuncMultiline); | ||
expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement); | ||
const { modifiedConfigContent } = parseAndModifyConfigContent(nextConfigWithFuncMultiline); | ||
expect(modifiedConfigContent).toContain(withPayloadImportStatement); | ||
expect(modifiedConfigContent).toMatch(/withPayload\(someFunc\(\n nextConfig\n\)\)/); | ||
@@ -91,5 +46,5 @@ }); | ||
it('should give warning with a named export as default', ()=>{ | ||
const warnLogSpy = jest.spyOn(_prompts.log, 'warn').mockImplementation(()=>{}); | ||
const { modifiedConfigContent, success } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigExportNamedDefault); | ||
expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement); | ||
const warnLogSpy = jest.spyOn(p.log, 'warn').mockImplementation(()=>{}); | ||
const { modifiedConfigContent, success } = parseAndModifyConfigContent(nextConfigExportNamedDefault); | ||
expect(modifiedConfigContent).toContain(withPayloadImportStatement); | ||
expect(success).toBe(false); | ||
@@ -96,0 +51,0 @@ expect(warnLogSpy).toHaveBeenCalledWith(expect.stringContaining('Could not automatically wrap')); |
@@ -1,29 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "writeEnvFile", { | ||
enumerable: true, | ||
get: function() { | ||
return writeEnvFile; | ||
} | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _log = require("../utils/log.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
async function writeEnvFile(args) { | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { debug, error } from '../utils/log.js'; | ||
/** Parse and swap .env.example values and write .env */ export async function writeEnvFile(args) { | ||
const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args; | ||
if (cliArgs['--dry-run']) { | ||
(0, _log.debug)(`DRY RUN: .env file created`); | ||
debug(`DRY RUN: .env file created`); | ||
return; | ||
} | ||
try { | ||
if (template?.type === 'starter' && _fsextra.default.existsSync(_path.default.join(projectDir, '.env.example'))) { | ||
if (template?.type === 'starter' && fs.existsSync(path.join(projectDir, '.env.example'))) { | ||
// Parse .env file into key/value pairs | ||
const envFile = await _fsextra.default.readFile(_path.default.join(projectDir, '.env.example'), 'utf8'); | ||
const envFile = await fs.readFile(path.join(projectDir, '.env.example'), 'utf8'); | ||
const envWithValues = envFile.split('\n').filter((e)=>e).map((line)=>{ | ||
@@ -43,11 +28,11 @@ if (line.startsWith('#') || !line.includes('=')) return line; | ||
// Write new .env file | ||
await _fsextra.default.writeFile(_path.default.join(projectDir, '.env'), envWithValues.join('\n')); | ||
await fs.writeFile(path.join(projectDir, '.env'), envWithValues.join('\n')); | ||
} else { | ||
const content = `DATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`; | ||
await _fsextra.default.outputFile(`${projectDir}/.env`, content); | ||
await fs.outputFile(`${projectDir}/.env`, content); | ||
} | ||
} catch (err) { | ||
(0, _log.error)('Unable to write .env file'); | ||
error('Unable to write .env file'); | ||
if (err instanceof Error) { | ||
(0, _log.error)(err.message); | ||
error(err.message); | ||
} | ||
@@ -54,0 +39,0 @@ process.exit(1); |
175
dist/main.js
@@ -1,80 +0,25 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "Main", { | ||
enumerable: true, | ||
get: function() { | ||
return Main; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify")); | ||
const _arg = /*#__PURE__*/ _interop_require_default(require("arg")); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _detectpackagemanager = require("detect-package-manager"); | ||
const _figures = /*#__PURE__*/ _interop_require_default(require("figures")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _configurepayloadconfig = require("./lib/configure-payload-config.js"); | ||
const _createproject = require("./lib/create-project.js"); | ||
const _generatesecret = require("./lib/generate-secret.js"); | ||
const _initnext = require("./lib/init-next.js"); | ||
const _parseprojectname = require("./lib/parse-project-name.js"); | ||
const _parsetemplate = require("./lib/parse-template.js"); | ||
const _selectdb = require("./lib/select-db.js"); | ||
const _templates = require("./lib/templates.js"); | ||
const _writeenvfile = require("./lib/write-env-file.js"); | ||
const _log = require("./utils/log.js"); | ||
const _messages = require("./utils/messages.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
class Main { | ||
import * as p from '@clack/prompts'; | ||
import slugify from '@sindresorhus/slugify'; | ||
import arg from 'arg'; | ||
import chalk from 'chalk'; | ||
// @ts-expect-error no types | ||
import { detect } from 'detect-package-manager'; | ||
import figures from 'figures'; | ||
import path from 'path'; | ||
import { configurePayloadConfig } from './lib/configure-payload-config.js'; | ||
import { createProject } from './lib/create-project.js'; | ||
import { generateSecret } from './lib/generate-secret.js'; | ||
import { getNextAppDetails, initNext } from './lib/init-next.js'; | ||
import { parseProjectName } from './lib/parse-project-name.js'; | ||
import { parseTemplate } from './lib/parse-template.js'; | ||
import { selectDb } from './lib/select-db.js'; | ||
import { getValidTemplates, validateTemplate } from './lib/templates.js'; | ||
import { writeEnvFile } from './lib/write-env-file.js'; | ||
import { error, info } from './utils/log.js'; | ||
import { feedbackOutro, helpMessage, moveMessage, successMessage, successfulNextInit } from './utils/messages.js'; | ||
export class Main { | ||
args; | ||
constructor(){ | ||
// @ts-expect-error bad typings | ||
this.args = (0, _arg.default)({ | ||
this.args = arg({ | ||
'--db': String, | ||
@@ -112,3 +57,3 @@ '--db-accept-recommended': Boolean, | ||
if (this.args['--help']) { | ||
(0, _messages.helpMessage)(); | ||
helpMessage(); | ||
process.exit(0); | ||
@@ -118,21 +63,21 @@ } | ||
console.log('\n'); | ||
_prompts.intro(_chalk.default.bgCyan(_chalk.default.black(' create-payload-app '))); | ||
_prompts.note("Welcome to Payload. Let's create a project!"); | ||
p.intro(chalk.bgCyan(chalk.black(' create-payload-app '))); | ||
p.note("Welcome to Payload. Let's create a project!"); | ||
// Detect if inside Next.js project | ||
const nextAppDetails = await (0, _initnext.getNextAppDetails)(process.cwd()); | ||
const nextAppDetails = await getNextAppDetails(process.cwd()); | ||
const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails; | ||
if (nextConfigPath) { | ||
this.args['--name'] = (0, _slugify.default)(_path.default.basename(_path.default.dirname(nextConfigPath))); | ||
this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath))); | ||
} | ||
const projectName = await (0, _parseprojectname.parseProjectName)(this.args); | ||
const projectDir = nextConfigPath ? _path.default.dirname(nextConfigPath) : _path.default.resolve(process.cwd(), (0, _slugify.default)(projectName)); | ||
const projectName = await parseProjectName(this.args); | ||
const projectDir = nextConfigPath ? path.dirname(nextConfigPath) : path.resolve(process.cwd(), slugify(projectName)); | ||
const packageManager = await getPackageManager(this.args, projectDir); | ||
if (nextConfigPath) { | ||
_prompts.log.step(_chalk.default.bold(`${_chalk.default.bgBlack(` ${_figures.default.triangleUp} Next.js `)} project detected!`)); | ||
const proceed = await _prompts.confirm({ | ||
p.log.step(chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`)); | ||
const proceed = await p.confirm({ | ||
initialValue: true, | ||
message: _chalk.default.bold(`Install ${_chalk.default.green('Payload')} in this project?`) | ||
message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`) | ||
}); | ||
if (_prompts.isCancel(proceed) || !proceed) { | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
if (p.isCancel(proceed) || !proceed) { | ||
p.outro(feedbackOutro()); | ||
process.exit(0); | ||
@@ -142,11 +87,11 @@ } | ||
if (nextAppDir && hasTopLevelLayout) { | ||
_prompts.log.warn((0, _messages.moveMessage)({ | ||
p.log.warn(moveMessage({ | ||
nextAppDir, | ||
projectDir | ||
})); | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
p.outro(feedbackOutro()); | ||
process.exit(0); | ||
} | ||
const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName); | ||
const result = await (0, _initnext.initNext)({ | ||
const dbDetails = await selectDb(this.args, projectName); | ||
const result = await initNext({ | ||
...this.args, | ||
@@ -159,6 +104,6 @@ dbType: dbDetails.type, | ||
if (result.success === false) { | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
p.outro(feedbackOutro()); | ||
process.exit(1); | ||
} | ||
await (0, _configurepayloadconfig.configurePayloadConfig)({ | ||
await configurePayloadConfig({ | ||
dbDetails, | ||
@@ -169,11 +114,11 @@ projectDirOrConfigPath: { | ||
}); | ||
await (0, _writeenvfile.writeEnvFile)({ | ||
await writeEnvFile({ | ||
cliArgs: this.args, | ||
databaseUri: dbDetails.dbUri, | ||
payloadSecret: (0, _generatesecret.generateSecret)(), | ||
payloadSecret: generateSecret(), | ||
projectDir | ||
}); | ||
(0, _log.info)('Payload project successfully initialized!'); | ||
_prompts.note((0, _messages.successfulNextInit)(), _chalk.default.bgGreen(_chalk.default.black(' Documentation '))); | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
info('Payload project successfully initialized!'); | ||
p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation '))); | ||
p.outro(feedbackOutro()); | ||
return; | ||
@@ -183,13 +128,13 @@ } | ||
if (templateArg) { | ||
const valid = (0, _templates.validateTemplate)(templateArg); | ||
const valid = validateTemplate(templateArg); | ||
if (!valid) { | ||
(0, _messages.helpMessage)(); | ||
helpMessage(); | ||
process.exit(1); | ||
} | ||
} | ||
const validTemplates = (0, _templates.getValidTemplates)(); | ||
const template = await (0, _parsetemplate.parseTemplate)(this.args, validTemplates); | ||
const validTemplates = getValidTemplates(); | ||
const template = await parseTemplate(this.args, validTemplates); | ||
if (!template) { | ||
_prompts.log.error('Invalid template given'); | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
p.log.error('Invalid template given'); | ||
p.outro(feedbackOutro()); | ||
process.exit(1); | ||
@@ -200,5 +145,5 @@ } | ||
{ | ||
const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName); | ||
const payloadSecret = (0, _generatesecret.generateSecret)(); | ||
await (0, _createproject.createProject)({ | ||
const dbDetails = await selectDb(this.args, projectName); | ||
const payloadSecret = generateSecret(); | ||
await createProject({ | ||
cliArgs: this.args, | ||
@@ -211,3 +156,3 @@ dbDetails, | ||
}); | ||
await (0, _writeenvfile.writeEnvFile)({ | ||
await writeEnvFile({ | ||
cliArgs: this.args, | ||
@@ -223,3 +168,3 @@ databaseUri: dbDetails.dbUri, | ||
{ | ||
await (0, _createproject.createProject)({ | ||
await createProject({ | ||
cliArgs: this.args, | ||
@@ -234,7 +179,7 @@ packageManager, | ||
} | ||
(0, _log.info)('Payload project successfully created!'); | ||
_prompts.note((0, _messages.successMessage)(projectDir, packageManager), _chalk.default.bgGreen(_chalk.default.black(' Next Steps '))); | ||
_prompts.outro((0, _messages.feedbackOutro)()); | ||
info('Payload project successfully created!'); | ||
p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps '))); | ||
p.outro(feedbackOutro()); | ||
} catch (err) { | ||
(0, _log.error)(err instanceof Error ? err.message : 'An error occurred'); | ||
error(err instanceof Error ? err.message : 'An error occurred'); | ||
} | ||
@@ -252,3 +197,3 @@ } | ||
} else { | ||
const detected = await (0, _detectpackagemanager.detect)({ | ||
const detected = await detect({ | ||
cwd: projectDir | ||
@@ -255,0 +200,0 @@ }); |
@@ -1,16 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _fs = /*#__PURE__*/ _interop_require_default(require("fs")); | ||
const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises")); | ||
const _nodeurl = require("node:url"); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()); | ||
const dirname = _path.default.dirname(filename); | ||
import fs from 'fs'; | ||
import fsp from 'fs/promises'; | ||
import { fileURLToPath } from 'node:url'; | ||
import path from 'path'; | ||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
@@ -23,10 +14,10 @@ main(); | ||
*/ async function main() { | ||
const root = _path.default.resolve(dirname, '../../../../'); | ||
const outputPath = _path.default.resolve(dirname, '../../dist/template'); | ||
const sourceTemplatePath = _path.default.resolve(root, 'templates/blank-3.0'); | ||
if (!_fs.default.existsSync(sourceTemplatePath)) { | ||
const root = path.resolve(dirname, '../../../../'); | ||
const outputPath = path.resolve(dirname, '../../dist/template'); | ||
const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0'); | ||
if (!fs.existsSync(sourceTemplatePath)) { | ||
throw new Error(`Source path does not exist: ${sourceTemplatePath}`); | ||
} | ||
if (!_fs.default.existsSync(outputPath)) { | ||
_fs.default.mkdirSync(outputPath, { | ||
if (!fs.existsSync(outputPath)) { | ||
fs.mkdirSync(outputPath, { | ||
recursive: true | ||
@@ -36,6 +27,6 @@ }); | ||
// Copy the src directory from `templates/blank-3.0` to `dist` | ||
const srcPath = _path.default.resolve(sourceTemplatePath, 'src'); | ||
const distSrcPath = _path.default.resolve(outputPath, 'src'); | ||
const srcPath = path.resolve(sourceTemplatePath, 'src'); | ||
const distSrcPath = path.resolve(outputPath, 'src'); | ||
// Copy entire file structure from src to dist | ||
await _promises.default.cp(srcPath, distSrcPath, { | ||
await fsp.cp(srcPath, distSrcPath, { | ||
recursive: true | ||
@@ -42,0 +33,0 @@ }); |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
export { }; | ||
//# sourceMappingURL=types.js.map |
@@ -1,31 +0,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "copyRecursiveSync", { | ||
enumerable: true, | ||
get: function() { | ||
return copyRecursiveSync; | ||
} | ||
}); | ||
const _fs = /*#__PURE__*/ _interop_require_default(require("fs")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function copyRecursiveSync(src, dest, debug) { | ||
const exists = _fs.default.existsSync(src); | ||
const stats = exists && _fs.default.statSync(src); | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
/** | ||
* Recursively copy files from src to dest | ||
*/ export function copyRecursiveSync(src, dest, debug) { | ||
const exists = fs.existsSync(src); | ||
const stats = exists && fs.statSync(src); | ||
const isDirectory = exists && stats !== false && stats.isDirectory(); | ||
if (isDirectory) { | ||
_fs.default.mkdirSync(dest, { | ||
fs.mkdirSync(dest, { | ||
recursive: true | ||
}); | ||
_fs.default.readdirSync(src).forEach((childItemName)=>{ | ||
copyRecursiveSync(_path.default.join(src, childItemName), _path.default.join(dest, childItemName)); | ||
fs.readdirSync(src).forEach((childItemName)=>{ | ||
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName)); | ||
}); | ||
} else { | ||
_fs.default.copyFileSync(src, dest); | ||
fs.copyFileSync(src, dest); | ||
} | ||
@@ -32,0 +19,0 @@ } |
@@ -1,92 +0,19 @@ | ||
/* eslint-disable no-console */ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
debug: function() { | ||
return debug; | ||
}, | ||
error: function() { | ||
return error; | ||
}, | ||
info: function() { | ||
return info; | ||
}, | ||
log: function() { | ||
return log; | ||
}, | ||
warning: function() { | ||
return warning; | ||
} | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts")); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
const warning = (message)=>{ | ||
_prompts.log.warn(_chalk.default.yellow('? ') + _chalk.default.bold(message)); | ||
/* eslint-disable no-console */ import * as p from '@clack/prompts'; | ||
import chalk from 'chalk'; | ||
export const warning = (message)=>{ | ||
p.log.warn(chalk.yellow('? ') + chalk.bold(message)); | ||
}; | ||
const info = (message)=>{ | ||
_prompts.log.step(_chalk.default.bold(message)); | ||
export const info = (message)=>{ | ||
p.log.step(chalk.bold(message)); | ||
}; | ||
const error = (message)=>{ | ||
_prompts.log.error(_chalk.default.bold(message)); | ||
export const error = (message)=>{ | ||
p.log.error(chalk.bold(message)); | ||
}; | ||
const debug = (message)=>{ | ||
_prompts.log.step(`${_chalk.default.bgGray('[DEBUG]')} ${_chalk.default.gray(message)}`); | ||
export const debug = (message)=>{ | ||
p.log.step(`${chalk.bgGray('[DEBUG]')} ${chalk.gray(message)}`); | ||
}; | ||
const log = (message)=>{ | ||
_prompts.log.message(message); | ||
export const log = (message)=>{ | ||
p.log.message(message); | ||
}; | ||
//# sourceMappingURL=log.js.map |
@@ -1,48 +0,13 @@ | ||
/* eslint-disable no-console */ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
feedbackOutro: function() { | ||
return feedbackOutro; | ||
}, | ||
helpMessage: function() { | ||
return helpMessage; | ||
}, | ||
moveMessage: function() { | ||
return moveMessage; | ||
}, | ||
successMessage: function() { | ||
return successMessage; | ||
}, | ||
successfulNextInit: function() { | ||
return successfulNextInit; | ||
}, | ||
welcomeMessage: function() { | ||
return welcomeMessage; | ||
} | ||
}); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _terminallink = /*#__PURE__*/ _interop_require_default(require("terminal-link")); | ||
const _templates = require("../lib/templates.js"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const header = (message)=>_chalk.default.bold(message); | ||
const welcomeMessage = (0, _chalk.default)` | ||
/* eslint-disable no-console */ import chalk from 'chalk'; | ||
import path from 'path'; | ||
import terminalLink from 'terminal-link'; | ||
import { getValidTemplates } from '../lib/templates.js'; | ||
const header = (message)=>chalk.bold(message); | ||
export const welcomeMessage = chalk` | ||
{green Welcome to Payload. Let's create a project! } | ||
`; | ||
const spacer = ' '.repeat(8); | ||
function helpMessage() { | ||
const validTemplates = (0, _templates.getValidTemplates)(); | ||
console.log((0, _chalk.default)` | ||
export function helpMessage() { | ||
const validTemplates = getValidTemplates(); | ||
console.log(chalk` | ||
{bold USAGE} | ||
@@ -71,4 +36,4 @@ | ||
} | ||
function successMessage(projectDir, packageManager) { | ||
const relativePath = _path.default.relative(process.cwd(), projectDir); | ||
export function successMessage(projectDir, packageManager) { | ||
const relativePath = path.relative(process.cwd(), projectDir); | ||
return ` | ||
@@ -78,3 +43,3 @@ ${header('Launch Application:')} | ||
- cd ./${relativePath} | ||
- ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in ${createTerminalLink('README.md', `file://${_path.default.resolve(projectDir, 'README.md')}`)} | ||
- ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in ${createTerminalLink('README.md', `file://${path.resolve(projectDir, 'README.md')}`)} | ||
@@ -88,3 +53,3 @@ ${header('Documentation:')} | ||
} | ||
function successfulNextInit() { | ||
export function successfulNextInit() { | ||
return `- ${createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload')} | ||
@@ -94,4 +59,4 @@ - ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')} | ||
} | ||
function moveMessage(args) { | ||
const relativePath = _path.default.relative(process.cwd(), args.nextAppDir); | ||
export function moveMessage(args) { | ||
const relativePath = path.relative(process.cwd(), args.nextAppDir); | ||
return ` | ||
@@ -102,5 +67,5 @@ ${header('Next Steps:')} | ||
${_chalk.default.bold('To continue:')} | ||
${chalk.bold('To continue:')} | ||
Move all files from ./${relativePath} to a named directory such as ./${relativePath}/${_chalk.default.bold('(app)')} | ||
Move all files from ./${relativePath} to a named directory such as ./${relativePath}/${chalk.bold('(app)')} | ||
@@ -110,8 +75,8 @@ Once moved, rerun the create-payload-app command again. | ||
} | ||
function feedbackOutro() { | ||
return `${_chalk.default.bgCyan(_chalk.default.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`; | ||
export function feedbackOutro() { | ||
return `${chalk.bgCyan(chalk.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`; | ||
} | ||
// Create terminalLink with fallback for unsupported terminals | ||
function createTerminalLink(text, url) { | ||
return (0, _terminallink.default)(text, url, { | ||
return terminalLink(text, url, { | ||
fallback: (text, url)=>`${text}: ${url}` | ||
@@ -118,0 +83,0 @@ }); |
{ | ||
"name": "create-payload-app", | ||
"version": "3.0.0-alpha.59", | ||
"version": "3.0.0-alpha.60", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
148410
1450