create-payload-app 3.0.0-canary.c27a334 → 3.0.0-canary.c96fa61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. package/dist/index.js.map +1 -1
  2. package/dist/lib/configure-payload-config.d.ts +8 -2
  3. package/dist/lib/configure-payload-config.d.ts.map +1 -1
  4. package/dist/lib/configure-payload-config.js +74 -25
  5. package/dist/lib/configure-payload-config.js.map +1 -1
  6. package/dist/lib/constants.d.ts +2 -0
  7. package/dist/lib/constants.d.ts.map +1 -0
  8. package/dist/lib/constants.js +9 -0
  9. package/dist/lib/constants.js.map +1 -0
  10. package/dist/lib/create-project.d.ts.map +1 -1
  11. package/dist/lib/create-project.js +10 -5
  12. package/dist/lib/create-project.js.map +1 -1
  13. package/dist/lib/create-project.spec.js +24 -25
  14. package/dist/lib/create-project.spec.js.map +1 -1
  15. package/dist/lib/download-template.d.ts +10 -0
  16. package/dist/lib/download-template.d.ts.map +1 -0
  17. package/dist/lib/download-template.js +21 -0
  18. package/dist/lib/download-template.js.map +1 -0
  19. package/dist/lib/generate-secret.js.map +1 -1
  20. package/dist/lib/get-package-manager.js +26 -5
  21. package/dist/lib/get-package-manager.js.map +1 -1
  22. package/dist/lib/init-next.d.ts +2 -2
  23. package/dist/lib/init-next.d.ts.map +1 -1
  24. package/dist/lib/init-next.js +54 -12
  25. package/dist/lib/init-next.js.map +1 -1
  26. package/dist/lib/install-packages.js.map +1 -1
  27. package/dist/lib/parse-project-name.d.ts.map +1 -1
  28. package/dist/lib/parse-project-name.js +9 -3
  29. package/dist/lib/parse-project-name.js.map +1 -1
  30. package/dist/lib/parse-template.d.ts.map +1 -1
  31. package/dist/lib/parse-template.js +3 -1
  32. package/dist/lib/parse-template.js.map +1 -1
  33. package/dist/lib/replacements.d.ts +27 -0
  34. package/dist/lib/replacements.d.ts.map +1 -0
  35. package/dist/lib/replacements.js +92 -0
  36. package/dist/lib/replacements.js.map +1 -0
  37. package/dist/lib/select-db.d.ts.map +1 -1
  38. package/dist/lib/select-db.js +23 -14
  39. package/dist/lib/select-db.js.map +1 -1
  40. package/dist/lib/templates.d.ts.map +1 -1
  41. package/dist/lib/templates.js +8 -1
  42. package/dist/lib/templates.js.map +1 -1
  43. package/dist/lib/update-payload-in-project.d.ts.map +1 -1
  44. package/dist/lib/update-payload-in-project.js +7 -5
  45. package/dist/lib/update-payload-in-project.js.map +1 -1
  46. package/dist/lib/wrap-next-config.d.ts +5 -5
  47. package/dist/lib/wrap-next-config.d.ts.map +1 -1
  48. package/dist/lib/wrap-next-config.js +120 -61
  49. package/dist/lib/wrap-next-config.js.map +1 -1
  50. package/dist/lib/wrap-next-config.spec.js +84 -34
  51. package/dist/lib/wrap-next-config.spec.js.map +1 -1
  52. package/dist/lib/write-env-file.d.ts +2 -1
  53. package/dist/lib/write-env-file.d.ts.map +1 -1
  54. package/dist/lib/write-env-file.js +31 -26
  55. package/dist/lib/write-env-file.js.map +1 -1
  56. package/dist/main.d.ts.map +1 -1
  57. package/dist/main.js +18 -5
  58. package/dist/main.js.map +1 -1
  59. package/dist/scripts/pack-template-files.js +3 -3
  60. package/dist/scripts/pack-template-files.js.map +1 -1
  61. package/dist/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +8 -6
  62. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +8 -6
  63. package/dist/template/src/app/(payload)/admin/importMap.js +1 -0
  64. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +11 -2
  65. package/dist/template/src/app/(payload)/api/graphql/route.ts +4 -2
  66. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +2 -1
  67. package/dist/template/src/app/(payload)/layout.tsx +19 -4
  68. package/dist/template/src/collections/Media.ts +16 -0
  69. package/dist/template/src/collections/Users.ts +1 -1
  70. package/dist/template/src/payload-types.ts +127 -0
  71. package/dist/template/src/payload.config.ts +13 -15
  72. package/dist/types.d.ts +6 -2
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/types.js.map +1 -1
  75. package/dist/utils/copy-recursive-sync.d.ts +3 -1
  76. package/dist/utils/copy-recursive-sync.d.ts.map +1 -1
  77. package/dist/utils/copy-recursive-sync.js +3 -1
  78. package/dist/utils/copy-recursive-sync.js.map +1 -1
  79. package/dist/utils/git.js.map +1 -1
  80. package/dist/utils/log.d.ts.map +1 -1
  81. package/dist/utils/log.js +1 -1
  82. package/dist/utils/log.js.map +1 -1
  83. package/dist/utils/messages.d.ts.map +1 -1
  84. package/dist/utils/messages.js +1 -0
  85. package/dist/utils/messages.js.map +1 -1
  86. package/package.json +25 -7
  87. package/dist/lib/packages.d.ts +0 -9
  88. package/dist/lib/packages.d.ts.map +0 -1
  89. package/dist/lib/packages.js +0 -27
  90. package/dist/lib/packages.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/wrap-next-config.spec.ts"],"sourcesContent":["import { parseAndModifyConfigContent, withPayloadStatement } from './wrap-next-config.js'\nimport * as p from '@clack/prompts'\nimport { jest } from '@jest/globals'\n\nconst esmConfigs = {\n defaultNextConfig: `/** @type {import('next').NextConfig} */\nconst nextConfig = {};\nexport default nextConfig;\n`,\n nextConfigWithFunc: `const nextConfig = {};\nexport default someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};;\nexport default someFunc(\n nextConfig\n);\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nexport { wrapped as default };\n`,\n nextConfigWithSpread: `const nextConfig = {\n ...someConfig,\n};\nexport default nextConfig;\n`,\n}\n\nconst cjsConfigs = {\n defaultNextConfig: `\n /** @type {import('next').NextConfig} */\nconst nextConfig = {};\nmodule.exports = nextConfig;\n`,\n anonConfig: `module.exports = {};`,\n nextConfigWithFunc: `const nextConfig = {};\nmodule.exports = someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};\nmodule.exports = someFunc(\n nextConfig\n);\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nmodule.exports = wrapped;\n`,\n nextConfigWithSpread: `const nextConfig = { ...someConfig };\nmodule.exports = nextConfig;\n`,\n}\n\ndescribe('parseAndInsertWithPayload', () => {\n describe('esm', () => {\n const configType = 'esm'\n const importStatement = withPayloadStatement[configType]\n it('should parse the default next config', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n esmConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse the config with a function', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a function on a new line', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n nextConfig\\n\\)\\)/)\n })\n\n it('should parse the config with a spread', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n esmConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n\n // Unsupported: export { wrapped as default }\n it('should give warning with a named export as default', () => {\n const warnLogSpy = jest.spyOn(p.log, 'warn').mockImplementation(() => {})\n\n const { modifiedConfigContent, success } = parseAndModifyConfigContent(\n esmConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(success).toBe(false)\n\n expect(warnLogSpy).toHaveBeenCalledWith(\n expect.stringContaining('Could not automatically wrap'),\n )\n })\n })\n\n describe('cjs', () => {\n const configType = 'cjs'\n const requireStatement = withPayloadStatement[configType]\n it('should parse the default next config', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse anonymous default config', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.anonConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload({})')\n })\n it('should parse the config with a function', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n it('should parse the config with a function on a new line', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n nextConfig\\n\\)\\)/)\n })\n it('should parse the config with a named export as default', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(wrapped)')\n })\n\n it('should parse the config with a spread', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n })\n})\n"],"names":["parseAndModifyConfigContent","withPayloadStatement","p","jest","esmConfigs","defaultNextConfig","nextConfigWithFunc","nextConfigWithFuncMultiline","nextConfigExportNamedDefault","nextConfigWithSpread","cjsConfigs","anonConfig","describe","configType","importStatement","it","modifiedConfigContent","expect","toContain","toMatch","warnLogSpy","spyOn","log","mockImplementation","success","toBe","toHaveBeenCalledWith","stringContaining","requireStatement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;QACAJ,GAAG,0DAA0D;YAC3D,MAAM,EAAEC,qBAAqB,EAAE,GAAGhB,4BAChCU,WAAWF,4BAA4B,EACvCK;YAEFI,OAAOD,uBAAuBE,SAAS,CAACU;YACxCX,OAAOD,uBAAuBE,SAAS,CAAC;QAC1C;QAEAH,GAAG,yCAAyC;YAC1C,MAAM,EAAEC,qBAAqB,EAAE,GAAGhB,4BAChCU,WAAWD,oBAAoB,EAC/BI;YAEFI,OAAOD,uBAAuBE,SAAS,CAACU;YACxCX,OAAOD,uBAAuBE,SAAS,CAAC;QAC1C;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/wrap-next-config.spec.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport { jest } from '@jest/globals'\n\nimport { parseAndModifyConfigContent, withPayloadStatement } from './wrap-next-config.js'\n\nconst tsConfigs = {\n defaultNextConfig: `import type { NextConfig } from \"next\";\n\nconst nextConfig: NextConfig = {};\nexport default nextConfig;`,\n\n nextConfigExportNamedDefault: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nconst wrapped = someFunc(asdf);\nexport { wrapped as default };\n`,\n nextConfigWithFunc: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nexport default someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nexport default someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {\n ...someConfig,\n};\nexport default nextConfig;\n`,\n}\n\nconst esmConfigs = {\n defaultNextConfig: `/** @type {import('next').NextConfig} */\nconst nextConfig = {};\nexport default nextConfig;\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nexport { wrapped as default };\n`,\n nextConfigWithFunc: `const nextConfig = {};\nexport default someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};;\nexport default someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `const nextConfig = {\n ...someConfig,\n};\nexport default nextConfig;\n`,\n}\n\nconst cjsConfigs = {\n anonConfig: `module.exports = {};`,\n defaultNextConfig: `\n /** @type {import('next').NextConfig} */\nconst nextConfig = {};\nmodule.exports = nextConfig;\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nmodule.exports = wrapped;\n`,\n nextConfigWithFunc: `const nextConfig = {};\nmodule.exports = someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};\nmodule.exports = someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `const nextConfig = { ...someConfig };\nmodule.exports = nextConfig;\n`,\n}\n\ndescribe('parseAndInsertWithPayload', () => {\n describe('ts', () => {\n const configType = 'ts'\n const importStatement = withPayloadStatement[configType]\n\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent: modifiedConfigContent2 } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent2).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n })\n describe('esm', () => {\n const configType = 'esm'\n const importStatement = withPayloadStatement[configType]\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n\n // Unsupported: export { wrapped as default }\n it('should give warning with a named export as default', async () => {\n const warnLogSpy = jest.spyOn(p.log, 'warn').mockImplementation(() => {})\n\n const { modifiedConfigContent, success } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(success).toBe(false)\n\n expect(warnLogSpy).toHaveBeenCalledWith(\n expect.stringContaining('Could not automatically wrap'),\n )\n })\n })\n\n describe('cjs', () => {\n const configType = 'cjs'\n const requireStatement = withPayloadStatement[configType]\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse anonymous default config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.anonConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload({})')\n })\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n it('should parse the config with a named export as default', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(wrapped)')\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n })\n})\n"],"names":["p","jest","parseAndModifyConfigContent","withPayloadStatement","tsConfigs","defaultNextConfig","nextConfigExportNamedDefault","nextConfigWithFunc","nextConfigWithFuncMultiline","nextConfigWithSpread","esmConfigs","cjsConfigs","anonConfig","describe","configType","importStatement","it","modifiedConfigContent","expect","toContain","modifiedConfigContent2","toMatch","warnLogSpy","spyOn","log","mockImplementation","success","toBe","toHaveBeenCalledWith","stringContaining","requireStatement"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,IAAI,QAAQ,gBAAe;AAEpC,SAASC,2BAA2B,EAAEC,oBAAoB,QAAQ,wBAAuB;AAEzF,MAAMC,YAAY;IAChBC,mBAAmB,CAAC;;;0BAGI,CAAC;IAEzBC,8BAA8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@@
1
- import type { CliArgs, ProjectTemplate } from '../types.js';
1
+ import type { CliArgs, DbType, ProjectTemplate } from '../types.js';
2
2
  /** Parse and swap .env.example values and write .env */
3
3
  export declare function writeEnvFile(args: {
4
4
  cliArgs: CliArgs;
5
+ databaseType?: DbType;
5
6
  databaseUri: string;
6
7
  payloadSecret: string;
7
8
  projectDir: string;
@@ -1 +1 @@
1
- {"version":3,"file":"write-env-file.d.ts","sourceRoot":"","sources":["../../src/lib/write-env-file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI3D,wDAAwD;AACxD,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDhB"}
1
+ {"version":3,"file":"write-env-file.d.ts","sourceRoot":"","sources":["../../src/lib/write-env-file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAInE,wDAAwD;AACxD,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEhB"}
@@ -2,40 +2,45 @@ import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import { debug, error } from '../utils/log.js';
4
4
  /** Parse and swap .env.example values and write .env */ export async function writeEnvFile(args) {
5
- const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args;
5
+ const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args;
6
6
  if (cliArgs['--dry-run']) {
7
7
  debug(`DRY RUN: .env file created`);
8
8
  return;
9
9
  }
10
10
  const envOutputPath = path.join(projectDir, '.env');
11
11
  try {
12
- if (fs.existsSync(envOutputPath)) {
13
- if (template?.type === 'starter') {
14
- // Parse .env file into key/value pairs
15
- const envFile = await fs.readFile(path.join(projectDir, '.env.example'), 'utf8');
16
- const envWithValues = envFile.split('\n').filter((e)=>e).map((line)=>{
17
- if (line.startsWith('#') || !line.includes('=')) return line;
18
- const split = line.split('=');
19
- const key = split[0];
20
- let value = split[1];
21
- if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI') {
22
- value = databaseUri;
23
- }
24
- if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {
25
- value = payloadSecret;
12
+ let fileContents;
13
+ if (template?.type === 'starter') {
14
+ // Parse .env file into key/value pairs
15
+ const envExample = path.join(projectDir, '.env.example');
16
+ const envFile = await fs.readFile(envExample, 'utf8');
17
+ fileContents = `# Added by Payload\n` + envFile.split('\n').filter((e)=>e).map((line)=>{
18
+ if (line.startsWith('#') || !line.includes('=')) {
19
+ return line;
20
+ }
21
+ const split = line.split('=');
22
+ let key = split[0];
23
+ let value = split[1];
24
+ if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI' || key === 'POSTGRES_URL') {
25
+ if (databaseType === 'vercel-postgres') {
26
+ key = 'POSTGRES_URL';
26
27
  }
27
- return `${key}=${value}`;
28
- });
29
- // Write new .env file
30
- await fs.writeFile(envOutputPath, envWithValues.join('\n'));
31
- } else {
32
- const existingEnv = await fs.readFile(envOutputPath, 'utf8');
33
- const newEnv = existingEnv + `\nDATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}\n`;
34
- await fs.writeFile(envOutputPath, newEnv);
35
- }
28
+ value = databaseUri;
29
+ }
30
+ if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {
31
+ value = payloadSecret;
32
+ }
33
+ return `${key}=${value}`;
34
+ }).join('\n');
35
+ } else {
36
+ fileContents = `# Added by Payload\nDATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}\n`;
37
+ }
38
+ if (fs.existsSync(envOutputPath)) {
39
+ const existingEnv = await fs.readFile(envOutputPath, 'utf8');
40
+ const newEnv = existingEnv + '\n# Added by Payload' + fileContents;
41
+ await fs.writeFile(envOutputPath, newEnv);
36
42
  } else {
37
- const content = `DATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`;
38
- await fs.outputFile(`${projectDir}/.env`, content);
43
+ await fs.writeFile(envOutputPath, fileContents);
39
44
  }
40
45
  } catch (err) {
41
46
  error('Unable to write .env file');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/write-env-file.ts"],"sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nimport type { CliArgs, ProjectTemplate } from '../types.js'\n\nimport { debug, error } from '../utils/log.js'\n\n/** Parse and swap .env.example values and write .env */\nexport async function writeEnvFile(args: {\n cliArgs: CliArgs\n databaseUri: string\n payloadSecret: string\n projectDir: string\n template?: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`DRY RUN: .env file created`)\n return\n }\n\n const envOutputPath = path.join(projectDir, '.env')\n\n try {\n if (fs.existsSync(envOutputPath)) {\n if (template?.type === 'starter') {\n // Parse .env file into key/value pairs\n const envFile = await fs.readFile(path.join(projectDir, '.env.example'), 'utf8')\n const envWithValues: string[] = envFile\n .split('\\n')\n .filter((e) => e)\n .map((line) => {\n if (line.startsWith('#') || !line.includes('=')) return line\n\n const split = line.split('=')\n const key = split[0]\n let value = split[1]\n\n if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI') {\n value = databaseUri\n }\n if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {\n value = payloadSecret\n }\n\n return `${key}=${value}`\n })\n\n // Write new .env file\n await fs.writeFile(envOutputPath, envWithValues.join('\\n'))\n } else {\n const existingEnv = await fs.readFile(envOutputPath, 'utf8')\n const newEnv =\n existingEnv + `\\nDATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}\\n`\n await fs.writeFile(envOutputPath, newEnv)\n }\n } else {\n const content = `DATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}`\n await fs.outputFile(`${projectDir}/.env`, content)\n }\n } catch (err: unknown) {\n error('Unable to write .env file')\n if (err instanceof Error) {\n error(err.message)\n }\n process.exit(1)\n }\n}\n"],"names":["fs","path","debug","error","writeEnvFile","args","cliArgs","databaseUri","payloadSecret","projectDir","template","envOutputPath","join","existsSync","type","envFile","readFile","envWithValues","split","filter","e","map","line","startsWith","includes","key","value","writeFile","existingEnv","newEnv","content","outputFile","err","Error","message","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,QAAQ,WAAU;AACzB,OAAOC,UAAU,OAAM;AAIvB,SAASC,KAAK,EAAEC,KAAK,QAAQ,kBAAiB;AAE9C,sDAAsD,GACtD,OAAO,eAAeC,aAAaC,IAMlC;IACC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAEtE,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBJ,MAAM,CAAC,0BAA0B,CAAC;QAClC;IACF;IAEA,MAAMS,gBAAgBV,KAAKW,IAAI,CAACH,YAAY;IAE5C,IAAI;QACF,IAAIT,GAAGa,UAAU,CAACF,gBAAgB;YAChC,IAAID,UAAUI,SAAS,WAAW;gBAChC,uCAAuC;gBACvC,MAAMC,UAAU,MAAMf,GAAGgB,QAAQ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'path'\n\nimport type { CliArgs, DbType, ProjectTemplate } from '../types.js'\n\nimport { debug, error } from '../utils/log.js'\n\n/** Parse and swap .env.example values and write .env */\nexport async function writeEnvFile(args: {\n cliArgs: CliArgs\n databaseType?: DbType\n databaseUri: string\n payloadSecret: string\n projectDir: string\n template?: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`DRY RUN: .env file created`)\n return\n }\n\n const envOutputPath = path.join(projectDir, '.env')\n\n try {\n let fileContents: string\n\n if (template?.type === 'starter') {\n // Parse .env file into key/value pairs\n const envExample = path.join(projectDir, '.env.example')\n const envFile = await fs.readFile(envExample, 'utf8')\n\n fileContents =\n `# Added by Payload\\n` +\n envFile\n .split('\\n')\n .filter((e) => e)\n .map((line) => {\n if (line.startsWith('#') || !line.includes('=')) {\n return line\n }\n\n const split = line.split('=')\n let key = split[0]\n let value = split[1]\n\n if (\n key === 'MONGODB_URI' ||\n key === 'MONGO_URL' ||\n key === 'DATABASE_URI' ||\n key === 'POSTGRES_URL'\n ) {\n if (databaseType === 'vercel-postgres') {\n key = 'POSTGRES_URL'\n }\n value = databaseUri\n }\n if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {\n value = payloadSecret\n }\n\n return `${key}=${value}`\n })\n .join('\\n')\n } else {\n fileContents = `# Added by Payload\\nDATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}\\n`\n }\n\n if (fs.existsSync(envOutputPath)) {\n const existingEnv = await fs.readFile(envOutputPath, 'utf8')\n const newEnv = existingEnv + '\\n# Added by Payload' + fileContents\n await fs.writeFile(envOutputPath, newEnv)\n } else {\n await fs.writeFile(envOutputPath, fileContents)\n }\n } catch (err: unknown) {\n error('Unable to write .env file')\n if (err instanceof Error) {\n error(err.message)\n }\n process.exit(1)\n }\n}\n"],"names":["fs","path","debug","error","writeEnvFile","args","cliArgs","databaseType","databaseUri","payloadSecret","projectDir","template","envOutputPath","join","fileContents","type","envExample","envFile","readFile","split","filter","e","map","line","startsWith","includes","key","value","existsSync","existingEnv","newEnv","writeFile","err","Error","message","process","exit"],"mappings":"AAAA,OAAOA,QAAQ,WAAU;AACzB,OAAOC,UAAU,OAAM;AAIvB,SAASC,KAAK,EAAEC,KAAK,QAAQ,kBAAiB;AAE9C,sDAAsD,GACtD,OAAO,eAAeC,aAAaC,IAOlC;IACC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGN;IAEpF,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBJ,MAAM,CAAC,0BAA0B,CAAC;QAClC;IACF;IAEA,MAAMU,gBAAgBX,KAAKY,IAAI,CAACH,YAAY;IAE5C,IAAI;QACF,IAAII;QAEJ,IAAIH,UAAUI,SAAS,WAAW;YAChC,uCAAuC;YACvC,MAAMC,aAAaf,KAAKY,IAAI,CAACH,YAAY;YACzC,MAAMO,UAAU,MAAMjB,GAAGkB,QAAQ,CAACF,YAAY;YAE9CF,eACE,CAAC,oBAAoB,CAAC,GACtBG,QACGE,KAAK,CAAC,MACNC,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACC;gBACJ,IAAIA,KAAKC,UAAU,CAAC,QAAQ,CAACD,KAAKE,QAAQ,CAAC,MAAM;oBAC/C,OAAOF;gBACT;gBAEA,MAAMJ,QAAQI,KAAKJ,KAAK,CAAC;gBACzB,IAAIO,MAAMP,KAAK,CAAC,EAAE;gBAClB,IAAIQ,QAAQR,KAAK,CAAC,EAAE;gBAEpB,IACEO,QAAQ,iBACRA,QAAQ,eACRA,QAAQ,kBACRA,QAAQ,gBACR;oBACA,IAAInB,iBAAiB,mBAAmB;wBACtCmB,MAAM;oBACR;oBACAC,QAAQnB;gBACV;gBACA,IAAIkB,QAAQ,oBAAoBA,QAAQ,sBAAsB;oBAC5DC,QAAQlB;gBACV;gBAEA,OAAO,CAAC,EAAEiB,IAAI,CAAC,EAAEC,MAAM,CAAC;YAC1B,GACCd,IAAI,CAAC;QACZ,OAAO;YACLC,eAAe,CAAC,iCAAiC,EAAEN,YAAY,iBAAiB,EAAEC,cAAc,EAAE,CAAC;QACrG;QAEA,IAAIT,GAAG4B,UAAU,CAAChB,gBAAgB;YAChC,MAAMiB,cAAc,MAAM7B,GAAGkB,QAAQ,CAACN,eAAe;YACrD,MAAMkB,SAASD,cAAc,yBAAyBf;YACtD,MAAMd,GAAG+B,SAAS,CAACnB,eAAekB;QACpC,OAAO;YACL,MAAM9B,GAAG+B,SAAS,CAACnB,eAAeE;QACpC;IACF,EAAE,OAAOkB,KAAc;QACrB7B,MAAM;QACN,IAAI6B,eAAeC,OAAO;YACxB9B,MAAM6B,IAAIE,OAAO;QACnB;QACAC,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -1 +1 @@
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;CAiK5B"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAuBzC,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IA4CP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAwL5B"}
package/dist/main.js CHANGED
@@ -5,6 +5,7 @@ import chalk from 'chalk';
5
5
  import figures from 'figures';
6
6
  import path from 'path';
7
7
  import { configurePayloadConfig } from './lib/configure-payload-config.js';
8
+ import { PACKAGE_VERSION } from './lib/constants.js';
8
9
  import { createProject } from './lib/create-project.js';
9
10
  import { generateSecret } from './lib/generate-secret.js';
10
11
  import { getPackageManager } from './lib/get-package-manager.js';
@@ -15,8 +16,8 @@ import { selectDb } from './lib/select-db.js';
15
16
  import { getValidTemplates, validateTemplate } from './lib/templates.js';
16
17
  import { updatePayloadInProject } from './lib/update-payload-in-project.js';
17
18
  import { writeEnvFile } from './lib/write-env-file.js';
18
- import { error, info } from './utils/log.js';
19
- import { feedbackOutro, helpMessage, moveMessage, successMessage, successfulNextInit } from './utils/messages.js';
19
+ import { debug, error, info } from './utils/log.js';
20
+ import { feedbackOutro, helpMessage, moveMessage, successfulNextInit, successMessage } from './utils/messages.js';
20
21
  export class Main {
21
22
  args;
22
23
  constructor(){
@@ -35,6 +36,7 @@ export class Main {
35
36
  '--init-next': Boolean,
36
37
  // Package manager
37
38
  '--no-deps': Boolean,
39
+ '--use-bun': Boolean,
38
40
  '--use-npm': Boolean,
39
41
  '--use-pnpm': Boolean,
40
42
  '--use-yarn': Boolean,
@@ -59,13 +61,19 @@ export class Main {
59
61
  helpMessage();
60
62
  process.exit(0);
61
63
  }
64
+ const debugFlag = this.args['--debug'];
62
65
  // eslint-disable-next-line no-console
63
66
  console.log('\n');
64
67
  p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')));
65
68
  p.note("Welcome to Payload. Let's create a project!");
66
69
  // Detect if inside Next.js project
67
70
  const nextAppDetails = await getNextAppDetails(process.cwd());
68
- const { hasTopLevelLayout, isPayloadInstalled, nextAppDir, nextConfigPath } = nextAppDetails;
71
+ const { hasTopLevelLayout, isPayloadInstalled, isSupportedNextVersion, nextAppDir, nextConfigPath, nextVersion } = nextAppDetails;
72
+ if (nextConfigPath && !isSupportedNextVersion) {
73
+ p.log.warn(`Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`);
74
+ p.outro(feedbackOutro());
75
+ process.exit(0);
76
+ }
69
77
  // Upgrade Payload in existing project
70
78
  if (isPayloadInstalled && nextConfigPath) {
71
79
  p.log.warn(`Payload installation detected in current project.`);
@@ -73,7 +81,7 @@ export class Main {
73
81
  initialValue: false,
74
82
  message: chalk.bold(`Upgrade Payload in this project?`)
75
83
  });
76
- if (!p.isCancel(shouldUpdate) || shouldUpdate) {
84
+ if (!p.isCancel(shouldUpdate) && shouldUpdate) {
77
85
  const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails);
78
86
  if (updateSuccess) {
79
87
  info(message);
@@ -125,13 +133,14 @@ export class Main {
125
133
  process.exit(1);
126
134
  }
127
135
  await configurePayloadConfig({
128
- dbDetails,
136
+ dbType: dbDetails?.type,
129
137
  projectDirOrConfigPath: {
130
138
  payloadConfigPath: result.payloadConfigPath
131
139
  }
132
140
  });
133
141
  await writeEnvFile({
134
142
  cliArgs: this.args,
143
+ databaseType: dbDetails.type,
135
144
  databaseUri: dbDetails.dbUri,
136
145
  payloadSecret: generateSecret(),
137
146
  projectDir
@@ -149,6 +158,9 @@ export class Main {
149
158
  process.exit(1);
150
159
  }
151
160
  }
161
+ if (debugFlag) {
162
+ debug(`Using templates from git tag: ${PACKAGE_VERSION}`);
163
+ }
152
164
  const validTemplates = getValidTemplates();
153
165
  const template = await parseTemplate(this.args, validTemplates);
154
166
  if (!template) {
@@ -171,6 +183,7 @@ export class Main {
171
183
  });
172
184
  await writeEnvFile({
173
185
  cliArgs: this.args,
186
+ databaseType: dbDetails.type,
174
187
  databaseUri: dbDetails.dbUri,
175
188
  payloadSecret,
176
189
  projectDir,
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 dbDetails,\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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA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G;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 { PACKAGE_VERSION } from './lib/constants.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 { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successMessage,\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-bun': 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 const debugFlag = this.args['--debug']\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 databaseType: dbDetails.type,\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 if (debugFlag) {\n debug(`Using templates from git tag: ${PACKAGE_VERSION}`)\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 databaseType: dbDetails.type,\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","PACKAGE_VERSION","createProject","generateSecret","getPackageManager","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","writeEnvFile","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successMessage","Main","args","constructor","String","Boolean","permissive","init","process","exit","debugFlag","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","databaseType","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,eAAe,QAAQ,qBAAoB;AACpD,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,KAAK,EAAEC,IAAI,QAAQ,iBAAgB;AACnD,SACEC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,kBAAkB,EAClBC,cA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gBAAgB,CAAC;YAC1D;YAEA,MAAMgF,iBAAiBvE;YACvB,MAAMwE,WAAW,MAAM1E,cAAc,IAAI,CAACe,IAAI,EAAE0D;YAChD,IAAI,CAACC,UAAU;gBACbxF,EAAEuC,GAAG,CAAClB,KAAK,CAAC;gBACZrB,EAAEqD,KAAK,CAAC9B;gBACRY,QAAQC,IAAI,CAAC;YACf;YAEA,OAAQoD,SAASX,IAAI;gBACnB,KAAK;oBAAW;wBACd,MAAMH,YAAY,MAAM3D,SAAS,IAAI,CAACc,IAAI,EAAEmC;wBAC5C,MAAMmB,gBAAgB1E;wBACtB,MAAMD,cAAc;4BAClB4D,SAAS,IAAI,CAACvC,IAAI;4BAClB6C;4BACAP;4BACAF;4BACAD;4BACAwB;wBACF;wBACA,MAAMrE,aAAa;4BACjBiD,SAAS,IAAI,CAACvC,IAAI;4BAClBmD,cAAcN,UAAUG,IAAI;4BAC5BI,aAAaP,UAAUQ,KAAK;4BAC5BC;4BACAlB;4BACAuB;wBACF;wBACA;oBACF;gBACA,KAAK;oBAAU;wBACb,MAAMhF,cAAc;4BAClB4D,SAAS,IAAI,CAACvC,IAAI;4BAClBsC;4BACAF;4BACAD;4BACAwB;wBACF;wBACA;oBACF;YACF;YAEAlE,KAAK;YACLtB,EAAE2C,IAAI,CAAChB,eAAesC,YAAYE,iBAAiBhE,MAAMiF,OAAO,CAACjF,MAAMuC,KAAK,CAAC;YAC7E1C,EAAEqD,KAAK,CAAC9B;QACV,EAAE,OAAOkE,KAAc;YACrBpE,MAAMoE,eAAeC,QAAQD,IAAIhC,OAAO,GAAG;QAC7C;IACF;AACF"}
@@ -7,13 +7,13 @@ const dirname = path.dirname(filename);
7
7
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
8
8
  main();
9
9
  /**
10
- * Copy the necessary template files from `templates/blank-3.0` to `dist/template`
10
+ * Copy the necessary template files from `templates/blank` to `dist/template`
11
11
  *
12
12
  * Eventually, this should be replaced with using tar.x to stream from the git repo
13
13
  */ async function main() {
14
14
  const root = path.resolve(dirname, '../../../../');
15
15
  const outputPath = path.resolve(dirname, '../../dist/template');
16
- const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0');
16
+ const sourceTemplatePath = path.resolve(root, 'templates/blank');
17
17
  if (!fs.existsSync(sourceTemplatePath)) {
18
18
  throw new Error(`Source path does not exist: ${sourceTemplatePath}`);
19
19
  }
@@ -22,7 +22,7 @@ main();
22
22
  recursive: true
23
23
  });
24
24
  }
25
- // Copy the src directory from `templates/blank-3.0` to `dist`
25
+ // Copy the src directory from `templates/blank` to `dist`
26
26
  const srcPath = path.resolve(sourceTemplatePath, 'src');
27
27
  const distSrcPath = path.resolve(outputPath, 'src');
28
28
  // Copy entire file structure from src to dist
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank-3.0` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank-3.0` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["fs","fsp","fileURLToPath","path","filename","url","dirname","main","root","resolve","outputPath","sourceTemplatePath","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","cp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,cAAa;AAC7B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAE7B,mEAAmE;AACnEG;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOL,KAAKM,OAAO,CAACH,SAAS;IACnC,MAAMI,aAAaP,KAAKM,OAAO,CAACH,SAAS;IACzC,MAAMK,qBAAqBR,KAAKM,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACR,GAAGY,UAAU,CAACD,qBAAqB;QACtC,MAAM,IAAIE,MAAM,CAAC,4BAA4B,EAAEF,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACX,GAAGY,UAAU,CAACF,aAAa;QAC9BV,GAAGc,SAAS,CAACJ,YAAY;YAAEK,WAAW;QAAK;IAC7C;IAEA,8DAA8D;IAC9D,MAAMC,UAAUb,KAAKM,OAAO,CAACE,oBAAoB;IACjD,MAAMM,cAAcd,KAAKM,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMT,IAAIiB,EAAE,CAACF,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
1
+ {"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["fs","fsp","fileURLToPath","path","filename","url","dirname","main","root","resolve","outputPath","sourceTemplatePath","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","cp"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,cAAa;AAC7B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAE7B,mEAAmE;AACnEG;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOL,KAAKM,OAAO,CAACH,SAAS;IACnC,MAAMI,aAAaP,KAAKM,OAAO,CAACH,SAAS;IACzC,MAAMK,qBAAqBR,KAAKM,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACR,GAAGY,UAAU,CAACD,qBAAqB;QACtC,MAAM,IAAIE,MAAM,CAAC,4BAA4B,EAAEF,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACX,GAAGY,UAAU,CAACF,aAAa;QAC9BV,GAAGc,SAAS,CAACJ,YAAY;YAAEK,WAAW;QAAK;IAC7C;IAEA,0DAA0D;IAC1D,MAAMC,UAAUb,KAAKM,OAAO,CAACE,oBAAoB;IACjD,MAAMM,cAAcd,KAAKM,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMT,IAAIiB,EAAE,CAACF,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
@@ -1,22 +1,24 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
2
3
  import type { Metadata } from 'next'
3
4
 
4
5
  import config from '@payload-config'
5
- /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
6
6
  import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views'
7
+ import { importMap } from '../importMap'
7
8
 
8
9
  type Args = {
9
- params: {
10
+ params: Promise<{
10
11
  segments: string[]
11
- }
12
- searchParams: {
12
+ }>
13
+ searchParams: Promise<{
13
14
  [key: string]: string | string[]
14
- }
15
+ }>
15
16
  }
16
17
 
17
18
  export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
18
19
  generatePageMetadata({ config, params, searchParams })
19
20
 
20
- const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams })
21
+ const NotFound = ({ params, searchParams }: Args) =>
22
+ NotFoundPage({ config, params, searchParams, importMap })
21
23
 
22
24
  export default NotFound
@@ -1,22 +1,24 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
2
3
  import type { Metadata } from 'next'
3
4
 
4
5
  import config from '@payload-config'
5
- /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
6
6
  import { RootPage, generatePageMetadata } from '@payloadcms/next/views'
7
+ import { importMap } from '../importMap'
7
8
 
8
9
  type Args = {
9
- params: {
10
+ params: Promise<{
10
11
  segments: string[]
11
- }
12
- searchParams: {
12
+ }>
13
+ searchParams: Promise<{
13
14
  [key: string]: string | string[]
14
- }
15
+ }>
15
16
  }
16
17
 
17
18
  export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
18
19
  generatePageMetadata({ config, params, searchParams })
19
20
 
20
- const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
21
+ const Page = ({ params, searchParams }: Args) =>
22
+ RootPage({ config, params, searchParams, importMap })
21
23
 
22
24
  export default Page
@@ -0,0 +1 @@
1
+ export const importMap = {}
@@ -1,10 +1,19 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
- /* DO NOT MODIFY it because it could be re-written at any time. */
2
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
3
3
  import config from '@payload-config'
4
- import { REST_DELETE, REST_GET, REST_OPTIONS, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
4
+ import '@payloadcms/next/css'
5
+ import {
6
+ REST_DELETE,
7
+ REST_GET,
8
+ REST_OPTIONS,
9
+ REST_PATCH,
10
+ REST_POST,
11
+ REST_PUT,
12
+ } from '@payloadcms/next/routes'
5
13
 
6
14
  export const GET = REST_GET(config)
7
15
  export const POST = REST_POST(config)
8
16
  export const DELETE = REST_DELETE(config)
9
17
  export const PATCH = REST_PATCH(config)
18
+ export const PUT = REST_PUT(config)
10
19
  export const OPTIONS = REST_OPTIONS(config)
@@ -1,6 +1,8 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
- /* DO NOT MODIFY it because it could be re-written at any time. */
2
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
3
3
  import config from '@payload-config'
4
- import { GRAPHQL_POST } from '@payloadcms/next/routes'
4
+ import { GRAPHQL_POST, REST_OPTIONS } from '@payloadcms/next/routes'
5
5
 
6
6
  export const POST = GRAPHQL_POST(config)
7
+
8
+ export const OPTIONS = REST_OPTIONS(config)
@@ -1,6 +1,7 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
- /* DO NOT MODIFY it because it could be re-written at any time. */
2
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
3
3
  import config from '@payload-config'
4
+ import '@payloadcms/next/css'
4
5
  import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes'
5
6
 
6
7
  export const GET = GRAPHQL_PLAYGROUND_GET(config)
@@ -1,16 +1,31 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
- import configPromise from '@payload-config'
3
- import '@payloadcms/next/css'
4
- import { RootLayout } from '@payloadcms/next/layouts'
5
2
  /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
3
+ import config from '@payload-config'
4
+ import '@payloadcms/next/css'
5
+ import type { ServerFunctionClient } from 'payload'
6
+ import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts'
6
7
  import React from 'react'
7
8
 
9
+ import { importMap } from './admin/importMap.js'
8
10
  import './custom.scss'
9
11
 
10
12
  type Args = {
11
13
  children: React.ReactNode
12
14
  }
13
15
 
14
- const Layout = ({ children }: Args) => <RootLayout config={configPromise}>{children}</RootLayout>
16
+ const serverFunction: ServerFunctionClient = async function (args) {
17
+ 'use server'
18
+ return handleServerFunctions({
19
+ ...args,
20
+ config,
21
+ importMap,
22
+ })
23
+ }
24
+
25
+ const Layout = ({ children }: Args) => (
26
+ <RootLayout config={config} importMap={importMap} serverFunction={serverFunction}>
27
+ {children}
28
+ </RootLayout>
29
+ )
15
30
 
16
31
  export default Layout
@@ -0,0 +1,16 @@
1
+ import type { CollectionConfig } from 'payload'
2
+
3
+ export const Media: CollectionConfig = {
4
+ slug: 'media',
5
+ access: {
6
+ read: () => true,
7
+ },
8
+ fields: [
9
+ {
10
+ name: 'alt',
11
+ type: 'text',
12
+ required: true,
13
+ },
14
+ ],
15
+ upload: true,
16
+ }
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig } from 'payload/types'
1
+ import type { CollectionConfig } from 'payload'
2
2
 
3
3
  export const Users: CollectionConfig = {
4
4
  slug: 'users',