create-payload-app 3.0.0-canary.ac498e7 → 3.0.0-canary.b6520aa

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"init-next.d.ts","sourceRoot":"","sources":["../../src/lib/init-next.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAkB,cAAc,EAAE,MAAM,aAAa,CAAA;AAclG,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAE5B,KAAK,cAAc,GACf;IACE,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,IAAI,CAAA;CACd,GACD;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAA;AAE9E,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAiE1E;AAmID,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA6CnF"}
1
+ {"version":3,"file":"init-next.d.ts","sourceRoot":"","sources":["../../src/lib/init-next.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAkB,cAAc,EAAE,MAAM,aAAa,CAAA;AAclG,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAE5B,KAAK,cAAc,GACf;IACE,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,IAAI,CAAA;CACd,GACD;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAA;AAE9E,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAiE1E;AAmID,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA2FnF"}
@@ -177,7 +177,8 @@ async function installDeps(projectDir, packageManager, dbType) {
177
177
  }
178
178
  export async function getNextAppDetails(projectDir) {
179
179
  const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'));
180
- const nextConfigPath = (await globby('next.config.*(t|j)s', {
180
+ // Match next.config.js, next.config.ts, next.config.mjs, next.config.cjs
181
+ const nextConfigPath = (await globby('next.config.(\\w)?(t|j)s', {
181
182
  absolute: true,
182
183
  cwd: projectDir
183
184
  }))?.[0];
@@ -185,16 +186,50 @@ export async function getNextAppDetails(projectDir) {
185
186
  return {
186
187
  hasTopLevelLayout: false,
187
188
  isSrcDir,
188
- nextConfigPath: undefined
189
+ isSupportedNextVersion: false,
190
+ nextConfigPath: undefined,
191
+ nextVersion: null
189
192
  };
190
193
  }
191
194
  const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'));
195
+ // Check if Next.js version is new enough
196
+ let nextVersion = null;
197
+ if (packageObj.dependencies?.next) {
198
+ nextVersion = packageObj.dependencies.next;
199
+ // Match versions using regex matching groups
200
+ const versionMatch = /(?<major>\d+)/.exec(nextVersion);
201
+ if (!versionMatch) {
202
+ p.log.warn(`Could not determine Next.js version from ${nextVersion}`);
203
+ return {
204
+ hasTopLevelLayout: false,
205
+ isSrcDir,
206
+ isSupportedNextVersion: false,
207
+ nextConfigPath,
208
+ nextVersion
209
+ };
210
+ }
211
+ const { major } = versionMatch.groups;
212
+ const majorVersion = parseInt(major);
213
+ if (majorVersion < 15) {
214
+ return {
215
+ hasTopLevelLayout: false,
216
+ isSrcDir,
217
+ isSupportedNextVersion: false,
218
+ nextConfigPath,
219
+ nextVersion
220
+ };
221
+ }
222
+ }
223
+ const isSupportedNextVersion = true;
224
+ // Check if Payload already installed
192
225
  if (packageObj.dependencies?.payload) {
193
226
  return {
194
227
  hasTopLevelLayout: false,
195
228
  isPayloadInstalled: true,
196
229
  isSrcDir,
197
- nextConfigPath
230
+ isSupportedNextVersion,
231
+ nextConfigPath,
232
+ nextVersion
198
233
  };
199
234
  }
200
235
  let nextAppDir = (await globby([
@@ -218,9 +253,11 @@ export async function getNextAppDetails(projectDir) {
218
253
  return {
219
254
  hasTopLevelLayout,
220
255
  isSrcDir,
256
+ isSupportedNextVersion,
221
257
  nextAppDir,
222
258
  nextConfigPath,
223
- nextConfigType: configType
259
+ nextConfigType: configType,
260
+ nextVersion
224
261
  };
225
262
  }
226
263
  function getProjectType(args) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/init-next.ts"],"sourcesContent":["import type { CompilerOptions } from 'typescript'\n\nimport * as p from '@clack/prompts'\nimport { parse, stringify } from 'comment-json'\nimport execa from 'execa'\nimport fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nimport { promisify } from 'util'\n\nimport type { CliArgs, DbType, NextAppDetails, NextConfigType, PackageManager } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { debug as origDebug, warning } from '../utils/log.js'\nimport { moveMessage } from '../utils/messages.js'\nimport { installPackages } from './install-packages.js'\nimport { wrapNextConfig } from './wrap-next-config.js'\n\nconst readFile = promisify(fs.readFile)\nconst writeFile = promisify(fs.writeFile)\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ntype InitNextArgs = {\n dbType: DbType\n nextAppDetails?: NextAppDetails\n packageManager: PackageManager\n projectDir: string\n useDistFiles?: boolean\n} & Pick<CliArgs, '--debug'>\n\ntype InitNextResult =\n | {\n isSrcDir: boolean\n nextAppDir: string\n payloadConfigPath: string\n success: true\n }\n | { isSrcDir: boolean; nextAppDir?: string; reason: string; success: false }\n\nexport async function initNext(args: InitNextArgs): Promise<InitNextResult> {\n const { dbType: dbType, packageManager, projectDir } = args\n\n const nextAppDetails = args.nextAppDetails || (await getNextAppDetails(projectDir))\n\n if (!nextAppDetails.nextAppDir) {\n warning(`Could not find app directory in ${projectDir}, creating...`)\n const createdAppDir = path.resolve(projectDir, nextAppDetails.isSrcDir ? 'src/app' : 'app')\n fse.mkdirSync(createdAppDir, { recursive: true })\n nextAppDetails.nextAppDir = createdAppDir\n }\n\n const { hasTopLevelLayout, isPayloadInstalled, isSrcDir, nextAppDir, nextConfigType } =\n nextAppDetails\n\n if (!nextConfigType) {\n return {\n isSrcDir,\n nextAppDir,\n reason: `Could not determine Next Config type in ${projectDir}. Possibly try renaming next.config.js to next.config.cjs or next.config.mjs.`,\n success: false,\n }\n }\n\n if (hasTopLevelLayout) {\n // Output directions for user to move all files from app to top-level directory named `(app)`\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n return {\n isSrcDir,\n nextAppDir,\n reason: 'Found existing layout.tsx in app directory',\n success: false,\n }\n }\n\n const installSpinner = p.spinner()\n installSpinner.start('Installing Payload and dependencies...')\n\n const configurationResult = await installAndConfigurePayload({\n ...args,\n nextAppDetails,\n nextConfigType,\n useDistFiles: true, // Requires running 'pnpm pack-template-files' in cpa\n })\n\n if (configurationResult.success === false) {\n installSpinner.stop(configurationResult.reason, 1)\n return { ...configurationResult, isSrcDir, success: false }\n }\n\n const { success: installSuccess } = await installDeps(projectDir, packageManager, dbType)\n if (!installSuccess) {\n installSpinner.stop('Failed to install dependencies', 1)\n return {\n ...configurationResult,\n isSrcDir,\n reason: 'Failed to install dependencies',\n success: false,\n }\n }\n\n // Add `@payload-config` to tsconfig.json `paths`\n await addPayloadConfigToTsConfig(projectDir, isSrcDir)\n installSpinner.stop('Successfully installed Payload and dependencies')\n return { ...configurationResult, isSrcDir, nextAppDir, success: true }\n}\n\nasync function addPayloadConfigToTsConfig(projectDir: string, isSrcDir: boolean) {\n const tsConfigPath = path.resolve(projectDir, 'tsconfig.json')\n\n // Check if tsconfig.json exists\n if (!fs.existsSync(tsConfigPath)) {\n warning(`Could not find tsconfig.json to add @payload-config path.`)\n return\n }\n const userTsConfigContent = await readFile(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = parse(userTsConfigContent) as {\n compilerOptions?: CompilerOptions\n }\n\n const hasBaseUrl =\n userTsConfig?.compilerOptions?.baseUrl && userTsConfig?.compilerOptions?.baseUrl !== '.'\n const baseUrl = hasBaseUrl ? userTsConfig?.compilerOptions?.baseUrl : './'\n\n if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) {\n userTsConfig.compilerOptions = {}\n }\n\n if (\n !userTsConfig.compilerOptions?.paths?.['@payload-config'] &&\n userTsConfig.compilerOptions?.paths\n ) {\n userTsConfig.compilerOptions.paths = {\n ...(userTsConfig.compilerOptions.paths || {}),\n '@payload-config': [`${baseUrl}${isSrcDir ? 'src/' : ''}payload.config.ts`],\n }\n await writeFile(tsConfigPath, stringify(userTsConfig, null, 2), { encoding: 'utf8' })\n }\n}\n\nasync function installAndConfigurePayload(\n args: {\n nextAppDetails: NextAppDetails\n nextConfigType: NextConfigType\n useDistFiles?: boolean\n } & InitNextArgs,\n): Promise<\n | { payloadConfigPath: string; success: true }\n | { payloadConfigPath?: string; reason: string; success: false }\n> {\n const {\n '--debug': debug,\n nextAppDetails: { isSrcDir, nextAppDir, nextConfigPath } = {},\n nextConfigType,\n projectDir,\n useDistFiles,\n } = args\n\n if (!nextAppDir || !nextConfigPath) {\n return {\n reason: 'Could not find app directory or next.config.js',\n success: false,\n }\n }\n\n const logDebug = (message: string) => {\n if (debug) origDebug(message)\n }\n\n if (!fs.existsSync(projectDir)) {\n return {\n reason: `Could not find specified project directory at ${projectDir}`,\n success: false,\n }\n }\n\n const templateFilesPath =\n dirname.endsWith('dist') || useDistFiles\n ? path.resolve(dirname, '../..', 'dist/template')\n : path.resolve(dirname, '../../../../templates/blank-3.0')\n\n logDebug(`Using template files from: ${templateFilesPath}`)\n\n if (!fs.existsSync(templateFilesPath)) {\n return {\n reason: `Could not find template source files from ${templateFilesPath}`,\n success: false,\n }\n } else {\n logDebug('Found template source files')\n }\n\n logDebug(`Copying template files from ${templateFilesPath} to ${nextAppDir}`)\n\n const templateSrcDir = path.resolve(templateFilesPath, isSrcDir ? '' : 'src')\n\n logDebug(`templateSrcDir: ${templateSrcDir}`)\n logDebug(`nextAppDir: ${nextAppDir}`)\n logDebug(`projectDir: ${projectDir}`)\n logDebug(`nextConfigPath: ${nextConfigPath}`)\n logDebug(`payloadConfigPath: ${path.resolve(projectDir, 'payload.config.ts')}`)\n\n logDebug(\n `isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`,\n )\n\n // This is a little clunky and needs to account for isSrcDir\n copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath), debug)\n\n // Wrap next.config.js with withPayload\n await wrapNextConfig({ nextConfigPath, nextConfigType })\n\n return {\n payloadConfigPath: path.resolve(nextAppDir, '../payload.config.ts'),\n success: true,\n }\n}\n\nasync function installDeps(projectDir: string, packageManager: PackageManager, dbType: DbType) {\n const packagesToInstall = [\n 'payload',\n '@payloadcms/next',\n '@payloadcms/richtext-lexical',\n '@payloadcms/plugin-cloud',\n ].map((pkg) => `${pkg}@beta`)\n\n packagesToInstall.push(`@payloadcms/db-${dbType}@beta`)\n\n // Match graphql version of @payloadcms/next\n packagesToInstall.push('graphql@^16.8.1')\n\n return await installPackages({ packageManager, packagesToInstall, projectDir })\n}\n\nexport async function getNextAppDetails(projectDir: string): Promise<NextAppDetails> {\n const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'))\n\n const nextConfigPath: string | undefined = (\n await globby('next.config.*(t|j)s', { absolute: true, cwd: projectDir })\n )?.[0]\n\n if (!nextConfigPath || nextConfigPath.length === 0) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n nextConfigPath: undefined,\n }\n }\n\n const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'))\n if (packageObj.dependencies?.payload) {\n return {\n hasTopLevelLayout: false,\n isPayloadInstalled: true,\n isSrcDir,\n nextConfigPath,\n }\n }\n\n let nextAppDir: string | undefined = (\n await globby(['**/app'], {\n absolute: true,\n cwd: projectDir,\n ignore: ['**/node_modules/**'],\n onlyDirectories: true,\n })\n )?.[0]\n\n if (!nextAppDir || nextAppDir.length === 0) {\n nextAppDir = undefined\n }\n\n const configType = getProjectType({ nextConfigPath, packageObj })\n\n const hasTopLevelLayout = nextAppDir\n ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx'))\n : false\n\n return { hasTopLevelLayout, isSrcDir, nextAppDir, nextConfigPath, nextConfigType: configType }\n}\n\nfunction getProjectType(args: {\n nextConfigPath: string\n packageObj: Record<string, unknown>\n}): NextConfigType {\n const { nextConfigPath, packageObj } = args\n\n if (nextConfigPath.endsWith('.ts')) {\n return 'ts'\n }\n\n if (nextConfigPath.endsWith('.mjs')) {\n return 'esm'\n }\n if (nextConfigPath.endsWith('.cjs')) {\n return 'cjs'\n }\n\n const packageJsonType = packageObj.type\n if (packageJsonType === 'module') {\n return 'esm'\n }\n if (packageJsonType === 'commonjs') {\n return 'cjs'\n }\n\n return 'cjs'\n}\n"],"names":["p","parse","stringify","fs","fse","globby","fileURLToPath","path","promisify","copyRecursiveSync","debug","origDebug","warning","moveMessage","installPackages","wrapNextConfig","readFile","writeFile","filename","url","dirname","initNext","args","dbType","packageManager","projectDir","nextAppDetails","getNextAppDetails","nextAppDir","createdAppDir","resolve","isSrcDir","mkdirSync","recursive","hasTopLevelLayout","isPayloadInstalled","nextConfigType","reason","success","log","warn","installSpinner","spinner","start","configurationResult","installAndConfigurePayload","useDistFiles","stop","installSuccess","installDeps","addPayloadConfigToTsConfig","tsConfigPath","existsSync","userTsConfigContent","encoding","userTsConfig","hasBaseUrl","compilerOptions","baseUrl","paths","nextConfigPath","logDebug","message","templateFilesPath","endsWith","templateSrcDir","payloadConfigPath","packagesToInstall","map","pkg","push","absolute","cwd","length","undefined","packageObj","readJson","dependencies","payload","ignore","onlyDirectories","configType","getProjectType","packageJsonType","type"],"mappings":"AAEA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,KAAK,EAAEC,SAAS,QAAQ,eAAc;AAE/C,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAIhC,SAASC,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,SAASC,SAAS,EAAEC,OAAO,QAAQ,kBAAiB;AAC7D,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,wBAAuB;AAEtD,MAAMC,WAAWR,UAAUL,GAAGa,QAAQ;AACtC,MAAMC,YAAYT,UAAUL,GAAGc,SAAS;AAExC,MAAMC,WAAWZ,cAAc,YAAYa,GAAG;AAC9C,MAAMC,UAAUb,KAAKa,OAAO,CAACF;AAmB7B,OAAO,eAAeG,SAASC,IAAkB;IAC/C,MAAM,EAAEC,QAAQA,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGH;IAEvD,MAAMI,iBAAi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1C7C,aAAa8C;IACf;IAEA,MAAMO,aAAaC,eAAe;QAAEtB;QAAgBe;IAAW;IAE/D,MAAMzC,oBAAoBN,aACtBzB,GAAGiD,UAAU,CAAC7C,KAAKuB,OAAO,CAACF,YAAY,iBACvC;IAEJ,OAAO;QAAEM;QAAmBH;QAAUH;QAAYgC;QAAgBxB,gBAAgB6C;IAAW;AAC/F;AAEA,SAASC,eAAe5D,IAGvB;IACC,MAAM,EAAEsC,cAAc,EAAEe,UAAU,EAAE,GAAGrD;IAEvC,IAAIsC,eAAeI,QAAQ,CAAC,QAAQ;QAClC,OAAO;IACT;IAEA,IAAIJ,eAAeI,QAAQ,CAAC,SAAS;QACnC,OAAO;IACT;IACA,IAAIJ,eAAeI,QAAQ,CAAC,SAAS;QACnC,OAAO;IACT;IAEA,MAAMmB,kBAAkBR,WAAWS,IAAI;IACvC,IAAID,oBAAoB,UAAU;QAChC,OAAO;IACT;IACA,IAAIA,oBAAoB,YAAY;QAClC,OAAO;IACT;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../src/lib/init-next.ts"],"sourcesContent":["import type { CompilerOptions } from 'typescript'\n\nimport * as p from '@clack/prompts'\nimport { parse, stringify } from 'comment-json'\nimport execa from 'execa'\nimport fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nimport { promisify } from 'util'\n\nimport type { CliArgs, DbType, NextAppDetails, NextConfigType, PackageManager } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { debug as origDebug, warning } from '../utils/log.js'\nimport { moveMessage } from '../utils/messages.js'\nimport { installPackages } from './install-packages.js'\nimport { wrapNextConfig } from './wrap-next-config.js'\n\nconst readFile = promisify(fs.readFile)\nconst writeFile = promisify(fs.writeFile)\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ntype InitNextArgs = {\n dbType: DbType\n nextAppDetails?: NextAppDetails\n packageManager: PackageManager\n projectDir: string\n useDistFiles?: boolean\n} & Pick<CliArgs, '--debug'>\n\ntype InitNextResult =\n | {\n isSrcDir: boolean\n nextAppDir: string\n payloadConfigPath: string\n success: true\n }\n | { isSrcDir: boolean; nextAppDir?: string; reason: string; success: false }\n\nexport async function initNext(args: InitNextArgs): Promise<InitNextResult> {\n const { dbType: dbType, packageManager, projectDir } = args\n\n const nextAppDetails = args.nextAppDetails || (await getNextAppDetails(projectDir))\n\n if (!nextAppDetails.nextAppDir) {\n warning(`Could not find app directory in ${projectDir}, creating...`)\n const createdAppDir = path.resolve(projectDir, nextAppDetails.isSrcDir ? 'src/app' : 'app')\n fse.mkdirSync(createdAppDir, { recursive: true })\n nextAppDetails.nextAppDir = createdAppDir\n }\n\n const { hasTopLevelLayout, isPayloadInstalled, isSrcDir, nextAppDir, nextConfigType } =\n nextAppDetails\n\n if (!nextConfigType) {\n return {\n isSrcDir,\n nextAppDir,\n reason: `Could not determine Next Config type in ${projectDir}. Possibly try renaming next.config.js to next.config.cjs or next.config.mjs.`,\n success: false,\n }\n }\n\n if (hasTopLevelLayout) {\n // Output directions for user to move all files from app to top-level directory named `(app)`\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n return {\n isSrcDir,\n nextAppDir,\n reason: 'Found existing layout.tsx in app directory',\n success: false,\n }\n }\n\n const installSpinner = p.spinner()\n installSpinner.start('Installing Payload and dependencies...')\n\n const configurationResult = await installAndConfigurePayload({\n ...args,\n nextAppDetails,\n nextConfigType,\n useDistFiles: true, // Requires running 'pnpm pack-template-files' in cpa\n })\n\n if (configurationResult.success === false) {\n installSpinner.stop(configurationResult.reason, 1)\n return { ...configurationResult, isSrcDir, success: false }\n }\n\n const { success: installSuccess } = await installDeps(projectDir, packageManager, dbType)\n if (!installSuccess) {\n installSpinner.stop('Failed to install dependencies', 1)\n return {\n ...configurationResult,\n isSrcDir,\n reason: 'Failed to install dependencies',\n success: false,\n }\n }\n\n // Add `@payload-config` to tsconfig.json `paths`\n await addPayloadConfigToTsConfig(projectDir, isSrcDir)\n installSpinner.stop('Successfully installed Payload and dependencies')\n return { ...configurationResult, isSrcDir, nextAppDir, success: true }\n}\n\nasync function addPayloadConfigToTsConfig(projectDir: string, isSrcDir: boolean) {\n const tsConfigPath = path.resolve(projectDir, 'tsconfig.json')\n\n // Check if tsconfig.json exists\n if (!fs.existsSync(tsConfigPath)) {\n warning(`Could not find tsconfig.json to add @payload-config path.`)\n return\n }\n const userTsConfigContent = await readFile(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = parse(userTsConfigContent) as {\n compilerOptions?: CompilerOptions\n }\n\n const hasBaseUrl =\n userTsConfig?.compilerOptions?.baseUrl && userTsConfig?.compilerOptions?.baseUrl !== '.'\n const baseUrl = hasBaseUrl ? userTsConfig?.compilerOptions?.baseUrl : './'\n\n if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) {\n userTsConfig.compilerOptions = {}\n }\n\n if (\n !userTsConfig.compilerOptions?.paths?.['@payload-config'] &&\n userTsConfig.compilerOptions?.paths\n ) {\n userTsConfig.compilerOptions.paths = {\n ...(userTsConfig.compilerOptions.paths || {}),\n '@payload-config': [`${baseUrl}${isSrcDir ? 'src/' : ''}payload.config.ts`],\n }\n await writeFile(tsConfigPath, stringify(userTsConfig, null, 2), { encoding: 'utf8' })\n }\n}\n\nasync function installAndConfigurePayload(\n args: {\n nextAppDetails: NextAppDetails\n nextConfigType: NextConfigType\n useDistFiles?: boolean\n } & InitNextArgs,\n): Promise<\n | { payloadConfigPath: string; success: true }\n | { payloadConfigPath?: string; reason: string; success: false }\n> {\n const {\n '--debug': debug,\n nextAppDetails: { isSrcDir, nextAppDir, nextConfigPath } = {},\n nextConfigType,\n projectDir,\n useDistFiles,\n } = args\n\n if (!nextAppDir || !nextConfigPath) {\n return {\n reason: 'Could not find app directory or next.config.js',\n success: false,\n }\n }\n\n const logDebug = (message: string) => {\n if (debug) origDebug(message)\n }\n\n if (!fs.existsSync(projectDir)) {\n return {\n reason: `Could not find specified project directory at ${projectDir}`,\n success: false,\n }\n }\n\n const templateFilesPath =\n dirname.endsWith('dist') || useDistFiles\n ? path.resolve(dirname, '../..', 'dist/template')\n : path.resolve(dirname, '../../../../templates/blank-3.0')\n\n logDebug(`Using template files from: ${templateFilesPath}`)\n\n if (!fs.existsSync(templateFilesPath)) {\n return {\n reason: `Could not find template source files from ${templateFilesPath}`,\n success: false,\n }\n } else {\n logDebug('Found template source files')\n }\n\n logDebug(`Copying template files from ${templateFilesPath} to ${nextAppDir}`)\n\n const templateSrcDir = path.resolve(templateFilesPath, isSrcDir ? '' : 'src')\n\n logDebug(`templateSrcDir: ${templateSrcDir}`)\n logDebug(`nextAppDir: ${nextAppDir}`)\n logDebug(`projectDir: ${projectDir}`)\n logDebug(`nextConfigPath: ${nextConfigPath}`)\n logDebug(`payloadConfigPath: ${path.resolve(projectDir, 'payload.config.ts')}`)\n\n logDebug(\n `isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`,\n )\n\n // This is a little clunky and needs to account for isSrcDir\n copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath), debug)\n\n // Wrap next.config.js with withPayload\n await wrapNextConfig({ nextConfigPath, nextConfigType })\n\n return {\n payloadConfigPath: path.resolve(nextAppDir, '../payload.config.ts'),\n success: true,\n }\n}\n\nasync function installDeps(projectDir: string, packageManager: PackageManager, dbType: DbType) {\n const packagesToInstall = [\n 'payload',\n '@payloadcms/next',\n '@payloadcms/richtext-lexical',\n '@payloadcms/plugin-cloud',\n ].map((pkg) => `${pkg}@beta`)\n\n packagesToInstall.push(`@payloadcms/db-${dbType}@beta`)\n\n // Match graphql version of @payloadcms/next\n packagesToInstall.push('graphql@^16.8.1')\n\n return await installPackages({ packageManager, packagesToInstall, projectDir })\n}\n\nexport async function getNextAppDetails(projectDir: string): Promise<NextAppDetails> {\n const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'))\n\n // Match next.config.js, next.config.ts, next.config.mjs, next.config.cjs\n const nextConfigPath: string | undefined = (\n await globby('next.config.(\\\\w)?(t|j)s', { absolute: true, cwd: projectDir })\n )?.[0]\n\n if (!nextConfigPath || nextConfigPath.length === 0) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath: undefined,\n nextVersion: null,\n }\n }\n\n const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'))\n // Check if Next.js version is new enough\n let nextVersion = null\n if (packageObj.dependencies?.next) {\n nextVersion = packageObj.dependencies.next\n // Match versions using regex matching groups\n const versionMatch = /(?<major>\\d+)/.exec(nextVersion)\n if (!versionMatch) {\n p.log.warn(`Could not determine Next.js version from ${nextVersion}`)\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath,\n nextVersion,\n }\n }\n\n const { major } = versionMatch.groups as { major: string }\n const majorVersion = parseInt(major)\n if (majorVersion < 15) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath,\n nextVersion,\n }\n }\n }\n\n const isSupportedNextVersion = true\n\n // Check if Payload already installed\n if (packageObj.dependencies?.payload) {\n return {\n hasTopLevelLayout: false,\n isPayloadInstalled: true,\n isSrcDir,\n isSupportedNextVersion,\n nextConfigPath,\n nextVersion,\n }\n }\n\n let nextAppDir: string | undefined = (\n await globby(['**/app'], {\n absolute: true,\n cwd: projectDir,\n ignore: ['**/node_modules/**'],\n onlyDirectories: true,\n })\n )?.[0]\n\n if (!nextAppDir || nextAppDir.length === 0) {\n nextAppDir = undefined\n }\n\n const configType = getProjectType({ nextConfigPath, packageObj })\n\n const hasTopLevelLayout = nextAppDir\n ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx'))\n : false\n\n return {\n hasTopLevelLayout,\n isSrcDir,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextConfigType: configType,\n nextVersion,\n }\n}\n\nfunction getProjectType(args: {\n nextConfigPath: string\n packageObj: Record<string, unknown>\n}): NextConfigType {\n const { nextConfigPath, packageObj } = args\n\n if (nextConfigPath.endsWith('.ts')) {\n return 'ts'\n }\n\n if (nextConfigPath.endsWith('.mjs')) {\n return 'esm'\n }\n if (nextConfigPath.endsWith('.cjs')) {\n return 'cjs'\n }\n\n const packageJsonType = packageObj.type\n if (packageJsonType === 'module') {\n return 'esm'\n }\n if (packageJsonType === 'commonjs') {\n return 'cjs'\n }\n\n return 'cjs'\n}\n"],"names":["p","parse","stringify","fs","fse","globby","fileURLToPath","path","promisify","copyRecursiveSync","debug","origDebug","warning","moveMessage","installPackages","wrapNextConfig","readFile","writeFile","filename","url","dirname","initNext","args","dbType","packageManager","projectDir","nextAppDetails","getNextAppDetails","nextAppDir","createdAppDir","resolve","isSrcDir","mkdirSync","recursive","hasTopLevelLayout","isPayloadInstalled","nextConfigType","reason","success","log","warn","installSpinner","spinner","start","configurationResult","installAndConfigurePayload","useDistFiles","stop","installSuccess","installDeps","addPayloadConfigToTsConfig","tsConfigPath","existsSync","userTsConfigContent","encoding","userTsConfig","hasBaseUrl","compilerOptions","baseUrl","paths","nextConfigPath","logDebug","message","templateFilesPath","endsWith","templateSrcDir","payloadConfigPath","packagesToInstall","map","pkg","push","absolute","cwd","length","isSupportedNextVersion","undefined","nextVersion","packageObj","readJson","dependencies","next","versionMatch","exec","major","groups","majorVersion","parseInt","payload","ignore","onlyDirectories","configType","getProjectType","packageJsonType","type"],"mappings":"AAEA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,KAAK,EAAEC,SAAS,QAAQ,eAAc;AAE/C,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAIhC,SAASC,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,SAASC,SAAS,EAAEC,OAAO,QAAQ,kBAAiB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iB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAUhE,CAAA"}
1
+ {"version":3,"file":"replacements.d.ts","sourceRoot":"","sources":["../../src/lib/replacements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE7D,KAAK,oBAAoB,GAAG;IAC1B,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IACjD,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAqCD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI/D,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AA4BD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE,yBAAyB,CAIrF,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG;IACvB,iBAAiB,EAAE;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAUhE,CAAA"}
@@ -19,9 +19,21 @@ const postgresReplacement = {
19
19
  importReplacement: "import { postgresAdapter } from '@payloadcms/db-postgres'",
20
20
  packageName: '@payloadcms/db-postgres'
21
21
  };
22
+ const sqliteReplacement = {
23
+ configReplacement: (envName = 'DATABASE_URI')=>[
24
+ ' db: sqliteAdapter({',
25
+ ' client: {',
26
+ ` url: process.env.${envName} || '',`,
27
+ ' },',
28
+ ' }),'
29
+ ],
30
+ importReplacement: "import { sqliteAdapter } from '@payloadcms/db-sqlite'",
31
+ packageName: '@payloadcms/db-sqlite'
32
+ };
22
33
  export const dbReplacements = {
23
34
  mongodb: mongodbReplacement,
24
- postgres: postgresReplacement
35
+ postgres: postgresReplacement,
36
+ sqlite: sqliteReplacement
25
37
  };
26
38
  const vercelBlobStorageReplacement = {
27
39
  // Replacement of `// storage-adapter-placeholder`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/replacements.ts"],"sourcesContent":["import type { DbType, StorageAdapterType } from '../types.js'\n\ntype DbAdapterReplacement = {\n configReplacement: (envName?: string) => string[]\n importReplacement: string\n packageName: string\n}\n\nconst mongodbReplacement: DbAdapterReplacement = {\n // Replacement between `// database-adapter-config-start` and `// database-adapter-config-end`\n configReplacement: (envName = 'DATABASE_URI') => [\n ' db: mongooseAdapter({',\n ` url: process.env.${envName} || '',`,\n ' }),',\n ],\n importReplacement: \"import { mongooseAdapter } from '@payloadcms/db-mongodb'\",\n packageName: '@payloadcms/db-mongodb',\n}\n\nconst postgresReplacement: DbAdapterReplacement = {\n configReplacement: (envName = 'DATABASE_URI') => [\n ' db: postgresAdapter({',\n ' pool: {',\n ` connectionString: process.env.${envName} || '',`,\n ' },',\n ' }),',\n ],\n importReplacement: \"import { postgresAdapter } from '@payloadcms/db-postgres'\",\n packageName: '@payloadcms/db-postgres',\n}\n\nexport const dbReplacements: Record<DbType, DbAdapterReplacement> = {\n mongodb: mongodbReplacement,\n postgres: postgresReplacement,\n}\n\ntype StorageAdapterReplacement = {\n configReplacement: string[]\n importReplacement?: string\n packageName?: string\n}\n\nconst vercelBlobStorageReplacement: StorageAdapterReplacement = {\n // Replacement of `// storage-adapter-placeholder`\n configReplacement: [\n ' vercelBlobStorage({',\n ' collections: {',\n ' [Media.slug]: true,',\n ' },',\n \" token: process.env.BLOB_READ_WRITE_TOKEN || '',\",\n ' }),',\n ],\n importReplacement: \"import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'\",\n packageName: '@payloadcms/storage-vercel-blob',\n}\n\nconst payloadCloudReplacement: StorageAdapterReplacement = {\n configReplacement: [' payloadCloudPlugin(),'],\n importReplacement: \"import { payloadCloudPlugin } from '@payloadcms/plugin-cloud'\",\n packageName: '@payloadcms/plugin-cloud',\n}\n\n// Removes placeholders\nconst diskReplacement: StorageAdapterReplacement = {\n configReplacement: [],\n importReplacement: '',\n}\n\nexport const storageReplacements: Record<StorageAdapterType, StorageAdapterReplacement> = {\n localDisk: diskReplacement,\n payloadCloud: payloadCloudReplacement,\n vercelBlobStorage: vercelBlobStorageReplacement,\n}\n\n/**\n * Generic config replacement\n */\ntype ConfigReplacement = {\n configReplacement: {\n match: string\n replacement: string\n }\n importReplacement: string\n packageName: string\n}\n\nexport const configReplacements: Record<string, ConfigReplacement> = {\n sharp: {\n // Replacement of `sharp, // Now optional`\n configReplacement: {\n match: 'sharp,',\n replacement: ' // sharp,',\n },\n importReplacement: \"import sharp from 'sharp'\",\n packageName: 'sharp',\n },\n}\n"],"names":["mongodbReplacement","configReplacement","envName","importReplacement","packageName","postgresReplacement","dbReplacements","mongodb","postgres","vercelBlobStorageReplacement","payloadCloudReplacement","diskReplacement","storageReplacements","localDisk","payloadCloud","vercelBlobStorage","configReplacements","sharp","match","replacement"],"mappings":"AAQA,MAAMA,qBAA2C;IAC/C,8FAA8F;IAC9FC,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA,CAAC,qBAAqB,EAAEA,QAAQ,OAAO,CAAC;YACxC;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMC,sBAA4C;IAChDJ,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA;YACA,CAAC,oCAAoC,EAAEA,QAAQ,OAAO,CAAC;YACvD;YACA;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,OAAO,MAAME,iBAAuD;IAClEC,SAASP;IACTQ,UAAUH;AACZ,EAAC;AAQD,MAAMI,+BAA0D;IAC9D,kDAAkD;IAClDR,mBAAmB;QACjB;QACA;QACA;QACA;QACA;QACA;KACD;IACDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMM,0BAAqD;IACzDT,mBAAmB;QAAC;KAA4B;IAChDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,uBAAuB;AACvB,MAAMO,kBAA6C;IACjDV,mBAAmB,EAAE;IACrBE,mBAAmB;AACrB;AAEA,OAAO,MAAMS,sBAA6E;IACxFC,WAAWF;IACXG,cAAcJ;IACdK,mBAAmBN;AACrB,EAAC;AAcD,OAAO,MAAMO,qBAAwD;IACnEC,OAAO;QACL,0CAA0C;QAC1ChB,mBAAmB;YACjBiB,OAAO;YACPC,aAAa;QACf;QACAhB,mBAAmB;QACnBC,aAAa;IACf;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/lib/replacements.ts"],"sourcesContent":["import type { DbType, StorageAdapterType } from '../types.js'\n\ntype DbAdapterReplacement = {\n configReplacement: (envName?: string) => string[]\n importReplacement: string\n packageName: string\n}\n\nconst mongodbReplacement: DbAdapterReplacement = {\n // Replacement between `// database-adapter-config-start` and `// database-adapter-config-end`\n configReplacement: (envName = 'DATABASE_URI') => [\n ' db: mongooseAdapter({',\n ` url: process.env.${envName} || '',`,\n ' }),',\n ],\n importReplacement: \"import { mongooseAdapter } from '@payloadcms/db-mongodb'\",\n packageName: '@payloadcms/db-mongodb',\n}\n\nconst postgresReplacement: DbAdapterReplacement = {\n configReplacement: (envName = 'DATABASE_URI') => [\n ' db: postgresAdapter({',\n ' pool: {',\n ` connectionString: process.env.${envName} || '',`,\n ' },',\n ' }),',\n ],\n importReplacement: \"import { postgresAdapter } from '@payloadcms/db-postgres'\",\n packageName: '@payloadcms/db-postgres',\n}\n\nconst sqliteReplacement: DbAdapterReplacement = {\n configReplacement: (envName = 'DATABASE_URI') => [\n ' db: sqliteAdapter({',\n ' client: {',\n ` url: process.env.${envName} || '',`,\n ' },',\n ' }),',\n ],\n importReplacement: \"import { sqliteAdapter } from '@payloadcms/db-sqlite'\",\n packageName: '@payloadcms/db-sqlite',\n}\n\nexport const dbReplacements: Record<DbType, DbAdapterReplacement> = {\n mongodb: mongodbReplacement,\n postgres: postgresReplacement,\n sqlite: sqliteReplacement,\n}\n\ntype StorageAdapterReplacement = {\n configReplacement: string[]\n importReplacement?: string\n packageName?: string\n}\n\nconst vercelBlobStorageReplacement: StorageAdapterReplacement = {\n // Replacement of `// storage-adapter-placeholder`\n configReplacement: [\n ' vercelBlobStorage({',\n ' collections: {',\n ' [Media.slug]: true,',\n ' },',\n \" token: process.env.BLOB_READ_WRITE_TOKEN || '',\",\n ' }),',\n ],\n importReplacement: \"import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'\",\n packageName: '@payloadcms/storage-vercel-blob',\n}\n\nconst payloadCloudReplacement: StorageAdapterReplacement = {\n configReplacement: [' payloadCloudPlugin(),'],\n importReplacement: \"import { payloadCloudPlugin } from '@payloadcms/plugin-cloud'\",\n packageName: '@payloadcms/plugin-cloud',\n}\n\n// Removes placeholders\nconst diskReplacement: StorageAdapterReplacement = {\n configReplacement: [],\n importReplacement: '',\n}\n\nexport const storageReplacements: Record<StorageAdapterType, StorageAdapterReplacement> = {\n localDisk: diskReplacement,\n payloadCloud: payloadCloudReplacement,\n vercelBlobStorage: vercelBlobStorageReplacement,\n}\n\n/**\n * Generic config replacement\n */\ntype ConfigReplacement = {\n configReplacement: {\n match: string\n replacement: string\n }\n importReplacement: string\n packageName: string\n}\n\nexport const configReplacements: Record<string, ConfigReplacement> = {\n sharp: {\n // Replacement of `sharp, // Now optional`\n configReplacement: {\n match: 'sharp,',\n replacement: ' // sharp,',\n },\n importReplacement: \"import sharp from 'sharp'\",\n packageName: 'sharp',\n },\n}\n"],"names":["mongodbReplacement","configReplacement","envName","importReplacement","packageName","postgresReplacement","sqliteReplacement","dbReplacements","mongodb","postgres","sqlite","vercelBlobStorageReplacement","payloadCloudReplacement","diskReplacement","storageReplacements","localDisk","payloadCloud","vercelBlobStorage","configReplacements","sharp","match","replacement"],"mappings":"AAQA,MAAMA,qBAA2C;IAC/C,8FAA8F;IAC9FC,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA,CAAC,qBAAqB,EAAEA,QAAQ,OAAO,CAAC;YACxC;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMC,sBAA4C;IAChDJ,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA;YACA,CAAC,oCAAoC,EAAEA,QAAQ,OAAO,CAAC;YACvD;YACA;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAME,oBAA0C;IAC9CL,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA;YACA,CAAC,uBAAuB,EAAEA,QAAQ,OAAO,CAAC;YAC1C;YACA;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,OAAO,MAAMG,iBAAuD;IAClEC,SAASR;IACTS,UAAUJ;IACVK,QAAQJ;AACV,EAAC;AAQD,MAAMK,+BAA0D;IAC9D,kDAAkD;IAClDV,mBAAmB;QACjB;QACA;QACA;QACA;QACA;QACA;KACD;IACDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMQ,0BAAqD;IACzDX,mBAAmB;QAAC;KAA4B;IAChDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,uBAAuB;AACvB,MAAMS,kBAA6C;IACjDZ,mBAAmB,EAAE;IACrBE,mBAAmB;AACrB;AAEA,OAAO,MAAMW,sBAA6E;IACxFC,WAAWF;IACXG,cAAcJ;IACdK,mBAAmBN;AACrB,EAAC;AAcD,OAAO,MAAMO,qBAAwD;IACnEC,OAAO;QACL,0CAA0C;QAC1ClB,mBAAmB;YACjBmB,OAAO;YACPC,aAAa;QACf;QACAlB,mBAAmB;QACnBC,aAAa;IACf;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"select-db.d.ts","sourceRoot":"","sources":["../../src/lib/select-db.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAU,MAAM,aAAa,CAAA;AAqB7D,wBAAsB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA8CrF"}
1
+ {"version":3,"file":"select-db.d.ts","sourceRoot":"","sources":["../../src/lib/select-db.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAU,MAAM,aAAa,CAAA;AA4B7D,wBAAsB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA8CrF"}
@@ -10,6 +10,12 @@ const dbChoiceRecord = {
10
10
  dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',
11
11
  title: 'PostgreSQL (beta)',
12
12
  value: 'postgres'
13
+ },
14
+ sqlite: {
15
+ dbConnectionPrefix: 'file:./',
16
+ dbConnectionSuffix: '.db',
17
+ title: 'SQLite (beta)',
18
+ value: 'sqlite'
13
19
  }
14
20
  };
15
21
  export async function selectDb(args, projectName) {
@@ -23,22 +29,16 @@ export async function selectDb(args, projectName) {
23
29
  dbType = await p.select({
24
30
  initialValue: 'mongodb',
25
31
  message: `Select a database`,
26
- options: [
27
- {
28
- label: 'MongoDB',
29
- value: 'mongodb'
30
- },
31
- {
32
- label: 'Postgres',
33
- value: 'postgres'
34
- }
35
- ]
32
+ options: Object.values(dbChoiceRecord).map((dbChoice)=>({
33
+ label: dbChoice.title,
34
+ value: dbChoice.value
35
+ }))
36
36
  });
37
37
  if (p.isCancel(dbType)) process.exit(0);
38
38
  }
39
39
  const dbChoice = dbChoiceRecord[dbType];
40
40
  let dbUri = undefined;
41
- const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)}`;
41
+ const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)}${dbChoice.dbConnectionSuffix || ''}`;
42
42
  if (args['--db-accept-recommended']) {
43
43
  dbUri = initialDbUri;
44
44
  } else if (args['--db-connection-string']) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/select-db.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\n\nimport type { CliArgs, DbDetails, DbType } from '../types.js'\n\ntype DbChoice = {\n dbConnectionPrefix: `${string}/`\n title: string\n value: DbType\n}\n\nconst dbChoiceRecord: Record<DbType, DbChoice> = {\n mongodb: {\n dbConnectionPrefix: 'mongodb://127.0.0.1/',\n title: 'MongoDB',\n value: 'mongodb',\n },\n postgres: {\n dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',\n title: 'PostgreSQL (beta)',\n value: 'postgres',\n },\n}\n\nexport async function selectDb(args: CliArgs, projectName: string): Promise<DbDetails> {\n let dbType: DbType | symbol | undefined = undefined\n if (args['--db']) {\n if (!Object.values(dbChoiceRecord).some((dbChoice) => dbChoice.value === args['--db'])) {\n throw new Error(\n `Invalid database type given. Valid types are: ${Object.values(dbChoiceRecord)\n .map((dbChoice) => dbChoice.value)\n .join(', ')}`,\n )\n }\n dbType = args['--db'] as DbType\n } else {\n dbType = await p.select<{ label: string; value: DbType }[], DbType>({\n initialValue: 'mongodb',\n message: `Select a database`,\n options: [\n { label: 'MongoDB', value: 'mongodb' },\n { label: 'Postgres', value: 'postgres' },\n ],\n })\n if (p.isCancel(dbType)) process.exit(0)\n }\n\n const dbChoice = dbChoiceRecord[dbType]\n\n let dbUri: string | symbol | undefined = undefined\n const initialDbUri = `${dbChoice.dbConnectionPrefix}${\n projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)\n }`\n\n if (args['--db-accept-recommended']) {\n dbUri = initialDbUri\n } else if (args['--db-connection-string']) {\n dbUri = args['--db-connection-string']\n } else {\n dbUri = await p.text({\n initialValue: initialDbUri,\n message: `Enter ${dbChoice.title.split(' ')[0]} connection string`, // strip beta from title\n })\n if (p.isCancel(dbUri)) process.exit(0)\n }\n\n return {\n type: dbChoice.value,\n dbUri,\n }\n}\n\nfunction getRandomDigitSuffix(): string {\n return (Math.random() * Math.pow(10, 6)).toFixed(0)\n}\n"],"names":["p","slugify","dbChoiceRecord","mongodb","dbConnectionPrefix","title","value","postgres","selectDb","args","projectName","dbType","undefined","Object","values","some","dbChoice","Error","map","join","select","initialValue","message","options","label","isCancel","process","exit","dbUri","initialDbUri","getRandomDigitSuffix","text","split","type","Math","random","pow","toFixed"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAU3C,MAAMC,iBAA2C;IAC/CC,SAAS;QACPC,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;IACAC,UAAU;QACRH,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;AACF;AAEA,OAAO,eAAeE,SAASC,IAAa,EAAEC,WAAmB;IAC/D,IAAIC,SAAsCC;IAC1C,IAAIH,IAAI,CAAC,OAAO,EAAE;QAChB,IAAI,CAACI,OAAOC,MAAM,CAACZ,gBAAgBa,IAAI,CAAC,CAACC,WAAaA,SAASV,KAAK,KAAKG,IAAI,CAAC,OAAO,GAAG;YACtF,MAAM,IAAIQ,MACR,CAAC,8CAA8C,EAAEJ,OAAOC,MAAM,CAACZ,gBAC5DgB,GAAG,CAAC,CAACF,WAAaA,SAASV,KAAK,EAChCa,IAAI,CAAC,MAAM,CAAC;QAEnB;QACAR,SAASF,IAAI,CAAC,OAAO;IACvB,OAAO;QACLE,SAAS,MAAMX,EAAEoB,MAAM,CAA6C;YAClEC,cAAc;YACdC,SAAS,CAAC,iBAAiB,CAAC;YAC5BC,SAAS;gBACP;oBAAEC,OAAO;oBAAWlB,OAAO;gBAAU;gBACrC;oBAAEkB,OAAO;oBAAYlB,OAAO;gBAAW;aACxC;QACH;QACA,IAAIN,EAAEyB,QAAQ,CAACd,SAASe,QAAQC,IAAI,CAAC;IACvC;IAEA,MAAMX,WAAWd,cAAc,CAACS,OAAO;IAEvC,IAAIiB,QAAqChB;IACzC,MAAMiB,eAAe,CAAC,EAAEb,SAASZ,kBAAkB,CAAC,EAClDM,gBAAgB,MAAM,CAAC,QAAQ,EAAEoB,uBAAuB,CAAC,GAAG7B,QAAQS,aACrE,CAAC;IAEF,IAAID,IAAI,CAAC,0BAA0B,EAAE;QACnCmB,QAAQC;IACV,OAAO,IAAIpB,IAAI,CAAC,yBAAyB,EAAE;QACzCmB,QAAQnB,IAAI,CAAC,yBAAyB;IACxC,OAAO;QACLmB,QAAQ,MAAM5B,EAAE+B,IAAI,CAAC;YACnBV,cAAcQ;YACdP,SAAS,CAAC,MAAM,EAAEN,SAASX,KAAK,CAAC2B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC;QACpE;QACA,IAAIhC,EAAEyB,QAAQ,CAACG,QAAQF,QAAQC,IAAI,CAAC;IACtC;IAEA,OAAO;QACLM,MAAMjB,SAASV,KAAK;QACpBsB;IACF;AACF;AAEA,SAASE;IACP,OAAO,AAACI,CAAAA,KAAKC,MAAM,KAAKD,KAAKE,GAAG,CAAC,IAAI,EAAC,EAAGC,OAAO,CAAC;AACnD"}
1
+ {"version":3,"sources":["../../src/lib/select-db.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\n\nimport type { CliArgs, DbDetails, DbType } from '../types.js'\n\ntype DbChoice = {\n dbConnectionPrefix: `${string}/`\n dbConnectionSuffix?: string\n title: string\n value: DbType\n}\n\nconst dbChoiceRecord: Record<DbType, DbChoice> = {\n mongodb: {\n dbConnectionPrefix: 'mongodb://127.0.0.1/',\n title: 'MongoDB',\n value: 'mongodb',\n },\n postgres: {\n dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',\n title: 'PostgreSQL (beta)',\n value: 'postgres',\n },\n sqlite: {\n dbConnectionPrefix: 'file:./',\n dbConnectionSuffix: '.db',\n title: 'SQLite (beta)',\n value: 'sqlite',\n },\n}\n\nexport async function selectDb(args: CliArgs, projectName: string): Promise<DbDetails> {\n let dbType: DbType | symbol | undefined = undefined\n if (args['--db']) {\n if (!Object.values(dbChoiceRecord).some((dbChoice) => dbChoice.value === args['--db'])) {\n throw new Error(\n `Invalid database type given. Valid types are: ${Object.values(dbChoiceRecord)\n .map((dbChoice) => dbChoice.value)\n .join(', ')}`,\n )\n }\n dbType = args['--db'] as DbType\n } else {\n dbType = await p.select<{ label: string; value: DbType }[], DbType>({\n initialValue: 'mongodb',\n message: `Select a database`,\n options: Object.values(dbChoiceRecord).map((dbChoice) => ({\n label: dbChoice.title,\n value: dbChoice.value,\n })),\n })\n if (p.isCancel(dbType)) process.exit(0)\n }\n\n const dbChoice = dbChoiceRecord[dbType]\n\n let dbUri: string | symbol | undefined = undefined\n const initialDbUri = `${dbChoice.dbConnectionPrefix}${\n projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)\n }${dbChoice.dbConnectionSuffix || ''}`\n\n if (args['--db-accept-recommended']) {\n dbUri = initialDbUri\n } else if (args['--db-connection-string']) {\n dbUri = args['--db-connection-string']\n } else {\n dbUri = await p.text({\n initialValue: initialDbUri,\n message: `Enter ${dbChoice.title.split(' ')[0]} connection string`, // strip beta from title\n })\n if (p.isCancel(dbUri)) process.exit(0)\n }\n\n return {\n type: dbChoice.value,\n dbUri,\n }\n}\n\nfunction getRandomDigitSuffix(): string {\n return (Math.random() * Math.pow(10, 6)).toFixed(0)\n}\n"],"names":["p","slugify","dbChoiceRecord","mongodb","dbConnectionPrefix","title","value","postgres","sqlite","dbConnectionSuffix","selectDb","args","projectName","dbType","undefined","Object","values","some","dbChoice","Error","map","join","select","initialValue","message","options","label","isCancel","process","exit","dbUri","initialDbUri","getRandomDig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E,EAAEM,SAAST,kBAAkB,IAAI,GAAG,CAAC;IAEtC,IAAIE,IAAI,CAAC,0BAA0B,EAAE;QACnCmB,QAAQC;IACV,OAAO,IAAIpB,IAAI,CAAC,yBAAyB,EAAE;QACzCmB,QAAQnB,IAAI,CAAC,yBAAyB;IACxC,OAAO;QACLmB,QAAQ,MAAM9B,EAAEiC,IAAI,CAAC;YACnBV,cAAcQ;YACdP,SAAS,CAAC,MAAM,EAAEN,SAASb,KAAK,CAAC6B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC;QACpE;QACA,IAAIlC,EAAE2B,QAAQ,CAACG,QAAQF,QAAQC,IAAI,CAAC;IACtC;IAEA,OAAO;QACLM,MAAMjB,SAASZ,KAAK;QACpBwB;IACF;AACF;AAEA,SAASE;IACP,OAAO,AAACI,CAAAA,KAAKC,MAAM,KAAKD,KAAKE,GAAG,CAAC,IAAI,EAAC,EAAGC,OAAO,CAAC;AACnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"update-payload-in-project.d.ts","sourceRoot":"","sources":["../../src/lib/update-payload-in-project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAOjD,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAuEhD"}
1
+ {"version":3,"file":"update-payload-in-project.d.ts","sourceRoot":"","sources":["../../src/lib/update-payload-in-project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAOjD,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAyEhD"}
@@ -59,7 +59,7 @@ export async function updatePayloadInProject(appDetails) {
59
59
  }
60
60
  info('Payload packages updated successfully.');
61
61
  info(`Updating Payload Next.js files...`);
62
- const templateFilesPath = dirname.endsWith('dist') ? path.resolve(dirname, '../..', 'dist/template') : path.resolve(dirname, '../../../../templates/blank-3.0');
62
+ const templateFilesPath = process.env.JEST_WORKER_ID !== undefined ? path.resolve(dirname, '../../../../templates/blank-3.0') : path.resolve(dirname, '../..', 'dist/template');
63
63
  const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)');
64
64
  copyRecursiveSync(templateSrcDir, path.resolve(projectDir, appDetails.isSrcDir ? 'src/app' : 'app', '(payload)'));
65
65
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/update-payload-in-project.ts"],"sourcesContent":["import execa from 'execa'\nimport fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport type { NextAppDetails } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { info } from '../utils/log.js'\nimport { getPackageManager } from './get-package-manager.js'\nimport { installPackages } from './install-packages.js'\n\nexport async function updatePayloadInProject(\n appDetails: NextAppDetails,\n): Promise<{ message: string; success: boolean }> {\n if (!appDetails.nextConfigPath) return { message: 'No Next.js config found', success: false }\n\n const projectDir = path.dirname(appDetails.nextConfigPath)\n\n const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n if (!packageObj?.dependencies) {\n throw new Error('No package.json found in this project')\n }\n\n const payloadVersion = packageObj.dependencies?.payload\n if (!payloadVersion) {\n throw new Error('Payload is not installed in this project')\n }\n\n const packageManager = await getPackageManager({ projectDir })\n\n // Fetch latest Payload version from npm\n const { exitCode: getLatestVersionExitCode, stdout: latestPayloadVersion } = await execa('npm', [\n 'show',\n 'payload@beta',\n 'version',\n ])\n if (getLatestVersionExitCode !== 0) {\n throw new Error('Failed to fetch latest Payload version')\n }\n\n if (payloadVersion === latestPayloadVersion) {\n return { message: `Payload v${payloadVersion} is already up to date.`, success: true }\n }\n\n // Update all existing Payload packages\n const payloadPackages = Object.keys(packageObj.dependencies).filter((dep) =>\n dep.startsWith('@payloadcms/'),\n )\n\n const packageNames = ['payload', ...payloadPackages]\n\n const packagesToUpdate = packageNames.map((pkg) => `${pkg}@${latestPayloadVersion}`)\n\n info(`Using ${packageManager}.\\n`)\n info(\n `Updating ${packagesToUpdate.length} Payload packages to v${latestPayloadVersion}...\\n\\n${packageNames.map((p) => ` - ${p}`).join('\\n')}`,\n )\n\n const { success: updateSuccess } = await installPackages({\n packageManager,\n packagesToInstall: packagesToUpdate,\n projectDir,\n })\n\n if (!updateSuccess) {\n throw new Error('Failed to update Payload packages')\n }\n info('Payload packages updated successfully.')\n\n info(`Updating Payload Next.js files...`)\n const templateFilesPath = dirname.endsWith('dist')\n ? path.resolve(dirname, '../..', 'dist/template')\n : path.resolve(dirname, '../../../../templates/blank-3.0')\n\n const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)')\n\n copyRecursiveSync(\n templateSrcDir,\n path.resolve(projectDir, appDetails.isSrcDir ? 'src/app' : 'app', '(payload)'),\n )\n\n return { message: 'Payload updated successfully.', success: true }\n}\n"],"names":["execa","fse","fileURLToPath","path","filename","url","dirname","copyRecursiveSync","info","getPackageManager","installPackages","updatePayloadInProject","appDetails","nextConfigPath","message","success","projectDir","packageObj","readJson","resolve","dependencies","Error","payloadVersion","payload","packageManager","exitCode","getLatestVersionExitCode","stdout","latestPayloadVersion","payloadPackages","Object","keys","filter","dep","startsWith","packageNames","packagesToUpdate","map","pkg","length","p","join","updateSuccess","packagesToInstall","templateFilesPath","endsWith","templateSrcDir","isSrcDir"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,OAAOC,SAAS,WAAU;AAC1B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AAEvB,MAAMC,WAAWF,cAAc,YAAYG,G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KAAK,CAAC,MAAM,EAAEgB,eAAe,GAAG,CAAC;IACjChB,KACE,CAAC,SAAS,EAAE4B,iBAAiBG,MAAM,CAAC,sBAAsB,EAAEX,qBAAqB,OAAO,EAAEO,aAAaE,GAAG,CAAC,CAACG,IAAM,CAAC,IAAI,EAAEA,EAAE,CAAC,EAAEC,IAAI,CAAC,MAAM,CAAC;IAG5I,MAAM,EAAE1B,SAAS2B,aAAa,EAAE,GAAG,MAAMhC,gBAAgB;QACvDc;QACAmB,mBAAmBP;QACnBpB;IACF;IAEA,IAAI,CAAC0B,eAAe;QAClB,MAAM,IAAIrB,MAAM;IAClB;IACAb,KAAK;IAELA,KAAK,CAAC,iCAAiC,CAAC;IACxC,MAAMoC,oBAAoBtC,QAAQuC,QAAQ,CAAC,UACvC1C,KAAKgB,OAAO,CAACb,SAAS,SAAS,mBAC/BH,KAAKgB,OAAO,CAACb,SAAS;IAE1B,MAAMwC,iBAAiB3C,KAAKgB,OAAO,CAACyB,mBAAmB;IAEvDrC,kBACEuC,gBACA3C,KAAKgB,OAAO,CAACH,YAAYJ,WAAWmC,QAAQ,GAAG,YAAY,OAAO;IAGpE,OAAO;QAAEjC,SAAS;QAAiCC,SAAS;IAAK;AACnE"}
1
+ {"version":3,"sources":["../../src/lib/update-payload-in-project.ts"],"sourcesContent":["import execa from 'execa'\nimport fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport type { NextAppDetails } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { info } from '../utils/log.js'\nimport { getPackageManager } from './get-package-manager.js'\nimport { installPackages } from './install-packages.js'\n\nexport async function updatePayloadInProject(\n appDetails: NextAppDetails,\n): Promise<{ message: string; success: boolean }> {\n if (!appDetails.nextConfigPath) return { message: 'No Next.js config found', success: false }\n\n const projectDir = path.dirname(appDetails.nextConfigPath)\n\n const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n if (!packageObj?.dependencies) {\n throw new Error('No package.json found in this project')\n }\n\n const payloadVersion = packageObj.dependencies?.payload\n if (!payloadVersion) {\n throw new Error('Payload is not installed in this project')\n }\n\n const packageManager = await getPackageManager({ projectDir })\n\n // Fetch latest Payload version from npm\n const { exitCode: getLatestVersionExitCode, stdout: latestPayloadVersion } = await execa('npm', [\n 'show',\n 'payload@beta',\n 'version',\n ])\n if (getLatestVersionExitCode !== 0) {\n throw new Error('Failed to fetch latest Payload version')\n }\n\n if (payloadVersion === latestPayloadVersion) {\n return { message: `Payload v${payloadVersion} is already up to date.`, success: true }\n }\n\n // Update all existing Payload packages\n const payloadPackages = Object.keys(packageObj.dependencies).filter((dep) =>\n dep.startsWith('@payloadcms/'),\n )\n\n const packageNames = ['payload', ...payloadPackages]\n\n const packagesToUpdate = packageNames.map((pkg) => `${pkg}@${latestPayloadVersion}`)\n\n info(`Using ${packageManager}.\\n`)\n info(\n `Updating ${packagesToUpdate.length} Payload packages to v${latestPayloadVersion}...\\n\\n${packageNames.map((p) => ` - ${p}`).join('\\n')}`,\n )\n\n const { success: updateSuccess } = await installPackages({\n packageManager,\n packagesToInstall: packagesToUpdate,\n projectDir,\n })\n\n if (!updateSuccess) {\n throw new Error('Failed to update Payload packages')\n }\n info('Payload packages updated successfully.')\n\n info(`Updating Payload Next.js files...`)\n\n const templateFilesPath =\n process.env.JEST_WORKER_ID !== undefined\n ? path.resolve(dirname, '../../../../templates/blank-3.0')\n : path.resolve(dirname, '../..', 'dist/template')\n\n const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)')\n\n copyRecursiveSync(\n templateSrcDir,\n path.resolve(projectDir, appDetails.isSrcDir ? 'src/app' : 'app', '(payload)'),\n )\n\n return { message: 'Payload updated successfully.', success: true }\n}\n"],"names":["execa","fse","fileURLToPath","path","filename","url","dirname","copyRecursiveSync","info","getPackageManager","installPackages","updatePayloadInProject","appDetails","nextConfigPath","message","success","projectDir","packageObj","readJson","resolve","dependencies","Error","payloadVersion","payload","packageManager","exitCode","getLatestVersionExitCode","stdout","latestPayloadVersion","payloadPackages","Object","keys","filter","dep","startsWith","packageNames","packagesToUpdate","map","pkg","length","p","join","updateSuccess","packagesToInstall","templateFilesPath","process","env","JEST_WORKER_ID","undefined","templateSrcDir","isSrcDir"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,OAAOC,SAAS,WAAU;AAC1B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AAEvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAI7B,SAASG,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,eAAe,QAAQ,wBAAuB;AAEvD,OAAO,eAAeC,uBACpBC,UAA0B;IAE1B,IAAI,CAACA,WAAWC,cAAc,EAAE,OAAO;QAAEC,SAAS;QAA2BC,SAAS;IAAM;IAE5F,MAAMC,aAAab,KAAKG,OAAO,CAACM,WAAWC,cAAc;IAEzD,MAAMI,aAAc,MAAMhB,IAAIiB,QAAQ,CAACf,KAAKgB,OAAO,CAACH,YAAY;IAGhE,IAAI,CAACC,YAAYG,cAAc;QAC7B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,iBAAiBL,WAAWG,YAAY,EAAEG;IAChD,IAAI,CAACD,gBAAgB;QACnB,MAAM,IAAID,MAAM;IAClB;IAEA,MAAMG,iBAAiB,MAAMf,kBAAkB;QAAEO;IAAW;IAE5D,wCAAwC;IACxC,MAAM,EAAES,UAAUC,wBAAwB,EAAEC,QAAQC,oBAAoB,EAAE,GAAG,MAAM5B,MAAM,OAAO;QAC9F;QACA;QACA;KACD;IACD,IAAI0B,6BAA6B,GAAG;QAClC,MAAM,IAAIL,MAAM;IAClB;IAEA,IAAIC,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AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAsBzC,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IA2CP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiK5B"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAsBzC,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IA2CP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgL5B"}
package/dist/main.js CHANGED
@@ -65,7 +65,12 @@ export class Main {
65
65
  p.note("Welcome to Payload. Let's create a project!");
66
66
  // Detect if inside Next.js project
67
67
  const nextAppDetails = await getNextAppDetails(process.cwd());
68
- const { hasTopLevelLayout, isPayloadInstalled, nextAppDir, nextConfigPath } = nextAppDetails;
68
+ const { hasTopLevelLayout, isPayloadInstalled, isSupportedNextVersion, nextAppDir, nextConfigPath, nextVersion } = nextAppDetails;
69
+ if (nextConfigPath && !isSupportedNextVersion) {
70
+ p.log.warn(`Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`);
71
+ p.outro(feedbackOutro());
72
+ process.exit(0);
73
+ }
69
74
  // Upgrade Payload in existing project
70
75
  if (isPayloadInstalled && nextConfigPath) {
71
76
  p.log.warn(`Payload installation detected in current project.`);
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getPackageManager } from './lib/get-package-manager.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { updatePayloadInProject } from './lib/update-payload-in-project.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Other\n '--no-git': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const { hasTopLevelLayout, isPayloadInstalled, nextAppDir, nextConfigPath } = nextAppDetails\n\n // Upgrade Payload in existing project\n if (isPayloadInstalled && nextConfigPath) {\n p.log.warn(`Payload installation detected in current project.`)\n const shouldUpdate = await p.confirm({\n initialValue: false,\n message: chalk.bold(`Upgrade Payload in this project?`),\n })\n\n if (!p.isCancel(shouldUpdate) && shouldUpdate) {\n const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails)\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbType: dbDetails?.type,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","generateSecret","getPackageManager","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","writeEnvFile","error","info","feedbackOutro","helpMessage","moveMessage","successMessage","successfulNextInit","Main","args","constructor","String","Boolean","permissive","init","process","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","isPayloadInstalled","nextAppDir","nextConfigPath","warn","shouldUpdate","confirm","initialValue","message","bold","isCancel","success","updateSuccess","outro","basename","dirname","projectName","projectDir","resolve","packageManager","cliArgs","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","validTemplates","template","err","Error"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAA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gBACf,MAAMC,QAAQhE,iBAAiB+D;gBAC/B,IAAI,CAACC,OAAO;oBACV1D;oBACAW,QAAQC,IAAI,CAAC;gBACf;YACF;YAEA,MAAM+C,iBAAiBlE;YACvB,MAAMmE,WAAW,MAAMrE,cAAc,IAAI,CAACc,IAAI,EAAEsD;YAChD,IAAI,CAACC,UAAU;gBACblF,EAAEoC,GAAG,CAACjB,KAAK,CAAC;gBACZnB,EAAEwD,KAAK,CAACnC;gBACRY,QAAQC,IAAI,CAAC;YACf;YAEA,OAAQgD,SAASV,IAAI;gBACnB,KAAK;oBAAW;wBACd,MAAMH,YAAY,MAAMvD,SAAS,IAAI,CAACa,IAAI,EAAEgC;wBAC5C,MAAMkB,gBAAgBrE;wBACtB,MAAMD,cAAc;4BAClBwD,SAAS,IAAI,CAACpC,IAAI;4BAClB0C;4BACAP;4BACAF;4BACAD;4BACAuB;wBACF;wBACA,MAAMhE,aAAa;4BACjB6C,SAAS,IAAI,CAACpC,IAAI;4BAClBgD,aAAaN,UAAUO,KAAK;4BAC5BC;4BACAjB;4BACAsB;wBACF;wBACA;oBACF;gBACA,KAAK;oBAAU;wBACb,MAAM3E,cAAc;4BAClBwD,SAAS,IAAI,CAACpC,IAAI;4BAClBmC;4BACAF;4BACAD;4BACAuB;wBACF;wBACA;oBACF;YACF;YAEA9D,KAAK;YACLpB,EAAEwC,IAAI,CAAChB,eAAeoC,YAAYE,iBAAiB3D,MAAM2E,OAAO,CAAC3E,MAAMoC,KAAK,CAAC;YAC7EvC,EAAEwD,KAAK,CAACnC;QACV,EAAE,OAAO8D,KAAc;YACrBhE,MAAMgE,eAAeC,QAAQD,IAAIhC,OAAO,GAAG;QAC7C;IACF;AACF"}
1
+ {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getPackageManager } from './lib/get-package-manager.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { updatePayloadInProject } from './lib/update-payload-in-project.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Other\n '--no-git': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const {\n hasTopLevelLayout,\n isPayloadInstalled,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextVersion,\n } = nextAppDetails\n\n if (nextConfigPath && !isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Upgrade Payload in existing project\n if (isPayloadInstalled && nextConfigPath) {\n p.log.warn(`Payload installation detected in current project.`)\n const shouldUpdate = await p.confirm({\n initialValue: false,\n message: chalk.bold(`Upgrade Payload in this project?`),\n })\n\n if (!p.isCancel(shouldUpdate) && shouldUpdate) {\n const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails)\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbType: dbDetails?.type,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","generateSecret","getPackageManager","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","writeEnvFile","error","info","feedbackOutro","helpMessage","moveMessage","successMessage","successfulNextInit","Main","args","constructor","String","Boolean","permissive","init","process","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","isPayloadInstalled","isSupportedNextVersion","nextAppDir","nextConfigPath","nextVersion","warn","outro","shouldUpdate","confirm","initialValue","message","bold","isCancel","success","updateSuccess","basename","dirname","projectName","projectDir","resolve","packageManager","cliArgs","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","validTemplates","template","err","Error"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,qBAAoB;AAChE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,qBAAoB;AACxE,SAASC,sBAAsB,QAAQ,qCAAoC;AAC3E,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,KAAK,EAAEC,IAAI,QAAQ,iBAAgB;AAC5C,SACEC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,kBAAkB,QACb,sBAAqB;AAE5B,OAAO,MAAMC;IACXC,KAAa;IAEbC,aAAc;QACZ,+BAA+B;QAC/B,IAAI,CAACD,IAAI,GAAGzB,IACV;YACE,QAAQ2B;YACR,2BAA2BC;YAC3B,0BAA0BD;YAC1B,UAAUC;YACV,oBAAoBD;YACpB,UAAUA;YACV,YAAYA;YACZ,cAAcA;YACd,qBAAqBA;YAErB,UAAU;YACV,eAAeC;YAEf,kBAAkB;YAClB,aAAaA;YACb,aAAaA;YACb,cAAcA;YACd,cAAcA;YAEd,QAAQ;YACR,YAAYA;YAEZ,QAAQ;YACR,UAAUA;YACV,WAAWA;YACX,aAAaA;YAEb,UAAU;YACV,MAAM;YACN,MAAM;YACN,M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U;wBACb,MAAM7E,cAAc;4BAClB0D,SAAS,IAAI,CAACtC,IAAI;4BAClBqC;4BACAF;4BACAD;4BACAuB;wBACF;wBACA;oBACF;YACF;YAEAhE,KAAK;YACLpB,EAAEwC,IAAI,CAAChB,eAAesC,YAAYE,iBAAiB7D,MAAM6E,OAAO,CAAC7E,MAAMoC,KAAK,CAAC;YAC7EvC,EAAEkD,KAAK,CAAC7B;QACV,EAAE,OAAOgE,KAAc;YACrBlE,MAAMkE,eAAeC,QAAQD,IAAI/B,OAAO,GAAG;QAC7C;IACF;AACF"}
package/dist/types.d.ts CHANGED
@@ -46,7 +46,7 @@ interface Template {
46
46
  type: ProjectTemplate['type'];
47
47
  }
48
48
  export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
49
- export type DbType = 'mongodb' | 'postgres';
49
+ export type DbType = 'mongodb' | 'postgres' | 'sqlite';
50
50
  export type DbDetails = {
51
51
  dbUri: string;
52
52
  type: DbType;
@@ -56,9 +56,11 @@ export type NextAppDetails = {
56
56
  hasTopLevelLayout: boolean;
57
57
  isPayloadInstalled?: boolean;
58
58
  isSrcDir: boolean;
59
+ isSupportedNextVersion: boolean;
59
60
  nextAppDir?: string;
60
61
  nextConfigPath?: string;
61
62
  nextConfigType?: NextConfigType;
63
+ nextVersion: null | string;
62
64
  };
63
65
  export type NextConfigType = 'cjs' | 'esm' | 'ts';
64
66
  export type StorageAdapterType = 'localDisk' | 'payloadCloud' | 'vercelBlobStorage';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,MAAM,WAAW,IAAK,SAAQ,GAAG,CAAC,IAAI;IACpC,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,MAAM,EAAE,iBAAiB,CAAA;IACzB,yBAAyB,EAAE,kBAAkB,CAAA;IAC7C,wBAAwB,EAAE,iBAAiB,CAAA;IAC3C,S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IAC/B,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,cAAc,GAAG,mBAAmB,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--beta': BooleanConstructor\n '--db': StringConstructor\n '--db-accept-recommended': BooleanConstructor\n '--db-connection-string': StringConstructor\n '--debug': BooleanConstructor\n '--dry-run': BooleanConstructor\n '--help': BooleanConstructor\n '--init-next': BooleanConstructor\n '--local-template': StringConstructor\n '--name': StringConstructor\n '--no-deps': BooleanConstructor\n '--no-git': BooleanConstructor\n '--secret': StringConstructor\n '--template': StringConstructor\n '--template-branch': StringConstructor\n '--use-npm': BooleanConstructor\n '--use-pnpm': BooleanConstructor\n '--use-yarn': BooleanConstructor\n\n // Aliases\n\n '-h': string\n '-n': string\n '-t': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'mongodb' | 'postgres'\n\nexport type DbDetails = {\n dbUri: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'payloadCloud' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AA+EA,WAAmF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--beta': BooleanConstructor\n '--db': StringConstructor\n '--db-accept-recommended': BooleanConstructor\n '--db-connection-string': StringConstructor\n '--debug': BooleanConstructor\n '--dry-run': BooleanConstructor\n '--help': BooleanConstructor\n '--init-next': BooleanConstructor\n '--local-template': StringConstructor\n '--name': StringConstructor\n '--no-deps': BooleanConstructor\n '--no-git': BooleanConstructor\n '--secret': StringConstructor\n '--template': StringConstructor\n '--template-branch': StringConstructor\n '--use-npm': BooleanConstructor\n '--use-pnpm': BooleanConstructor\n '--use-yarn': BooleanConstructor\n\n // Aliases\n\n '-h': string\n '-n': string\n '-t': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'mongodb' | 'postgres' | 'sqlite'\n\nexport type DbDetails = {\n dbUri: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'payloadCloud' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AAiFA,WAAmF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-payload-app",
3
- "version": "3.0.0-canary.ac498e7",
3
+ "version": "3.0.0-canary.b6520aa",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",