create-payload-app 3.0.0-alpha.64 → 3.0.0-alpha.66

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"configure-payload-config.d.ts","sourceRoot":"","sources":["../../src/lib/configure-payload-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAK5C,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,sBAAsB,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/E,GAAG,OAAO,CAAC,IAAI,CAAC,CA6DhB"}
1
+ {"version":3,"file":"configure-payload-config.d.ts","sourceRoot":"","sources":["../../src/lib/configure-payload-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAK5C,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,sBAAsB,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/E,GAAG,OAAO,CAAC,IAAI,CAAC,CAyFhB"}
@@ -1,11 +1,37 @@
1
1
  import fse from 'fs-extra';
2
2
  import globby from 'globby';
3
+ import { fileURLToPath } from 'node:url';
4
+ import path from 'path';
5
+ const filename = fileURLToPath(import.meta.url);
6
+ const dirname = path.dirname(filename);
3
7
  import { warning } from '../utils/log.js';
4
8
  import { dbReplacements } from './packages.js';
5
9
  /** Update payload config with necessary imports and adapters */ export async function configurePayloadConfig(args) {
6
10
  if (!args.dbDetails) {
7
11
  return;
8
12
  }
13
+ // Update package.json
14
+ const packageJsonPath = 'projectDir' in args.projectDirOrConfigPath && path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json');
15
+ if (packageJsonPath && fse.existsSync(packageJsonPath)) {
16
+ try {
17
+ const packageObj = await fse.readJson(packageJsonPath);
18
+ const dbPackage = dbReplacements[args.dbDetails.type];
19
+ // Delete all other db adapters
20
+ Object.values(dbReplacements).forEach((p)=>{
21
+ if (p.packageName !== dbPackage.packageName) {
22
+ delete packageObj.dependencies[p.packageName];
23
+ }
24
+ });
25
+ // Set version of db adapter to match payload version
26
+ packageObj.dependencies[dbPackage.packageName] = packageObj.dependencies['payload'];
27
+ await fse.writeJson(packageJsonPath, packageObj, {
28
+ spaces: 2
29
+ });
30
+ } catch (err) {
31
+ warning(`Unable to configure Payload in package.json`);
32
+ warning(err instanceof Error ? err.message : '');
33
+ }
34
+ }
9
35
  try {
10
36
  let payloadConfigPath;
11
37
  if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\n\nimport type { DbDetails } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { dbReplacements } from './packages.js'\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbDetails: DbDetails | undefined\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n}): Promise<void> {\n if (!args.dbDetails) {\n return\n }\n\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const configContent = fse.readFileSync(payloadConfigPath, 'utf-8')\n const configLines = configContent.split('\\n')\n\n const dbReplacement = dbReplacements[args.dbDetails.type]\n\n let dbConfigStartLineIndex: number | undefined\n let dbConfigEndLineIndex: number | undefined\n\n configLines.forEach((l, i) => {\n if (l.includes('// database-adapter-import')) {\n configLines[i] = dbReplacement.importReplacement\n }\n\n if (l.includes('// database-adapter-config-start')) {\n dbConfigStartLineIndex = i\n }\n if (l.includes('// database-adapter-config-end')) {\n dbConfigEndLineIndex = i\n }\n })\n\n if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) {\n warning('Unable to update payload.config.ts with database adapter import')\n } else {\n // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`\n configLines.splice(\n dbConfigStartLineIndex,\n dbConfigEndLineIndex - dbConfigStartLineIndex + 1,\n ...dbReplacement.configReplacement,\n )\n }\n\n fse.writeFileSync(payloadConfigPath, configLines.join('\\n'))\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["fse","globby","warning","dbReplacements","configurePayloadConfig","args","dbDetails","payloadConfigPath","projectDirOrConfigPath","absolute","cwd","projectDir","configContent","readFileSync","configLines","split","dbReplacement","type","dbConfigStartLineIndex","dbConfigEndLineIndex","forEach","l","i","includes","importReplacement","splice","configReplacement","writeFileSync","join","err","Error","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAI3B,SAASC,OAAO,QAAQ,kBAAiB;AACzC,SAASC,cAAc,QAAQ,gBAAe;AAE9C,8DAA8D,GAC9D,OAAO,eAAeC,uBAAuBC,IAG5C;IACC,IAAI,CAACA,KAAKC,SAAS,EAAE;QACnB;IACF;IAEA,IAAI;QACF,IAAIC;QACJ,IAAI,CAAE,CAAA,uBAAuBF,KAAKG,sBAAsB,AAAD,GAAI;YACzDD,oBACE,CAAA,MAAMN,OAAO,wBAAwB;gBACnCQ,UAAU;gBACVC,KAAKL,KAAKG,sBAAsB,CAACG,UAAU;YAC7C,EAAC,GACA,CAAC,EAAE;QACR,OAAO;YACLJ,oBAAoBF,KAAKG,sBAAsB,CAACD,iBAAiB;QACnE;QAEA,IAAI,CAACA,mBAAmB;YACtBL,QAAQ;YACR;QACF;QAEA,MAAMU,gBAAgBZ,IAAIa,YAAY,CAACN,mBAAmB;QAC1D,MAAMO,cAAcF,cAAcG,KAAK,CAAC;QAExC,MAAMC,gBAAgBb,cAAc,CAACE,KAAKC,SAAS,CAACW,IAAI,CAAC;QAEzD,IAAIC;QACJ,IAAIC;QAEJL,YAAYM,OAAO,CAAC,CAACC,GAAGC;YACtB,IAAID,EAAEE,QAAQ,CAAC,+BAA+B;gBAC5CT,WAAW,CAACQ,EAAE,GAAGN,cAAcQ,iBAAiB;YAClD;YAEA,IAAIH,EAAEE,QAAQ,CAAC,qCAAqC;gBAClDL,yBAAyBI;YAC3B;YACA,IAAID,EAAEE,QAAQ,CAAC,mCAAmC;gBAChDJ,uBAAuBG;YACzB;QACF;QAEA,IAAI,CAACJ,0BAA0B,CAACC,sBAAsB;YACpDjB,QAAQ;QACV,OAAO;YACL,iGAAiG;YACjGY,YAAYW,MAAM,CAChBP,wBACAC,uBAAuBD,yBAAyB,MAC7CF,cAAcU,iBAAiB;QAEtC;QAEA1B,IAAI2B,aAAa,CAACpB,mBAAmBO,YAAYc,IAAI,CAAC;IACxD,EAAE,OAAOC,KAAc;QACrB3B,QACE,CAAC,iDAAiD,EAAE2B,eAAeC,QAAQD,IAAIE,OAAO,GAAG,GAAG,CAAC;IAEjG;AACF"}
1
+ {"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport type { DbDetails } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { dbReplacements } from './packages.js'\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbDetails: DbDetails | undefined\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n}): Promise<void> {\n if (!args.dbDetails) {\n return\n }\n\n // Update package.json\n const packageJsonPath =\n 'projectDir' in args.projectDirOrConfigPath &&\n path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')\n\n if (packageJsonPath && fse.existsSync(packageJsonPath)) {\n try {\n const packageObj = await fse.readJson(packageJsonPath)\n\n const dbPackage = dbReplacements[args.dbDetails.type]\n\n // Delete all other db adapters\n Object.values(dbReplacements).forEach((p) => {\n if (p.packageName !== dbPackage.packageName) {\n delete packageObj.dependencies[p.packageName]\n }\n })\n\n // Set version of db adapter to match payload version\n packageObj.dependencies[dbPackage.packageName] = packageObj.dependencies['payload']\n\n await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })\n } catch (err: unknown) {\n warning(`Unable to configure Payload in package.json`)\n warning(err instanceof Error ? err.message : '')\n }\n }\n\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const configContent = fse.readFileSync(payloadConfigPath, 'utf-8')\n const configLines = configContent.split('\\n')\n\n const dbReplacement = dbReplacements[args.dbDetails.type]\n\n let dbConfigStartLineIndex: number | undefined\n let dbConfigEndLineIndex: number | undefined\n\n configLines.forEach((l, i) => {\n if (l.includes('// database-adapter-import')) {\n configLines[i] = dbReplacement.importReplacement\n }\n\n if (l.includes('// database-adapter-config-start')) {\n dbConfigStartLineIndex = i\n }\n if (l.includes('// database-adapter-config-end')) {\n dbConfigEndLineIndex = i\n }\n })\n\n if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) {\n warning('Unable to update payload.config.ts with database adapter import')\n } else {\n // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`\n configLines.splice(\n dbConfigStartLineIndex,\n dbConfigEndLineIndex - dbConfigStartLineIndex + 1,\n ...dbReplacement.configReplacement,\n )\n }\n\n fse.writeFileSync(payloadConfigPath, configLines.join('\\n'))\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["fse","globby","fileURLToPath","path","filename","url","dirname","warning","dbReplacements","configurePayloadConfig","args","dbDetails","packageJsonPath","projectDirOrConfigPath","resolve","projectDir","existsSync","packageObj","readJson","dbPackage","type","Object","values","forEach","p","packageName","dependencies","writeJson","spaces","err","Error","message","payloadConfigPath","absolute","cwd","configContent","readFileSync","configLines","split","dbReplacement","dbConfigStartLineIndex","dbConfigEndLineIndex","l","i","includes","importReplacement","splice","configReplacement","writeFileSync","join"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAI7B,SAASG,OAAO,QAAQ,kBAAiB;AACzC,SAASC,cAAc,QAAQ,gBAAe;AAE9C,8DAA8D,GAC9D,OAAO,eAAeC,uBAAuBC,IAG5C;IACC,IAAI,CAACA,KAAKC,SAAS,EAAE;QACnB;IACF;IAEA,sBAAsB;IACtB,MAAMC,kBACJ,gBAAgBF,KAAKG,sBAAsB,IAC3CV,KAAKW,OAAO,CAACJ,KAAKG,sBAAsB,CAACE,UAAU,EAAE;IAEvD,IAAIH,mBAAmBZ,IAAIgB,UAAU,CAACJ,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5CP,WAAW,CAACM,EAAE,GAAGJ,cAAcM,iBAAiB;YAClD;YAEA,IAAIH,EAAEE,QAAQ,CAAC,qCAAqC;gBAClDJ,yBAAyBG;YAC3B;YACA,IAAID,EAAEE,QAAQ,CAAC,mCAAmC;gBAChDH,uBAAuBE;YACzB;QACF;QAEA,IAAI,CAACH,0BAA0B,CAACC,sBAAsB;YACpDlC,QAAQ;QACV,OAAO;YACL,iGAAiG;YACjG8B,YAAYS,MAAM,CAChBN,wBACAC,uBAAuBD,yBAAyB,MAC7CD,cAAcQ,iBAAiB;QAEtC;QAEA/C,IAAIgD,aAAa,CAAChB,mBAAmBK,YAAYY,IAAI,CAAC;IACxD,EAAE,OAAOpB,KAAc;QACrBtB,QACE,CAAC,iDAAiD,EAAEsB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,GAAG,CAAC;IAEjG;AACF"}
@@ -0,0 +1,22 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ import type { Metadata } from 'next'
3
+
4
+ import config from '@payload-config'
5
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
6
+ import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views'
7
+
8
+ type Args = {
9
+ params: {
10
+ segments: string[]
11
+ }
12
+ searchParams: {
13
+ [key: string]: string | string[]
14
+ }
15
+ }
16
+
17
+ export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
18
+ generatePageMetadata({ config, params, searchParams })
19
+
20
+ const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams })
21
+
22
+ export default NotFound
@@ -1,7 +1,9 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ import type { Metadata } from 'next'
3
+
2
4
  import config from '@payload-config'
3
5
  /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
4
- import { RootPage } from '@payloadcms/next/views'
6
+ import { RootPage, generatePageMetadata } from '@payloadcms/next/views'
5
7
 
6
8
  type Args = {
7
9
  params: {
@@ -12,6 +14,9 @@ type Args = {
12
14
  }
13
15
  }
14
16
 
17
+ export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
18
+ generatePageMetadata({ config, params, searchParams })
19
+
15
20
  const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
16
21
 
17
22
  export default Page
@@ -1,9 +1,10 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
2
  /* DO NOT MODIFY it because it could be re-written at any time. */
3
3
  import config from '@payload-config'
4
- import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
4
+ import { REST_DELETE, REST_GET, REST_OPTIONS, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
5
5
 
6
6
  export const GET = REST_GET(config)
7
7
  export const POST = REST_POST(config)
8
8
  export const DELETE = REST_DELETE(config)
9
9
  export const PATCH = REST_PATCH(config)
10
+ export const OPTIONS = REST_OPTIONS(config)
@@ -1,6 +1,5 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
2
  import configPromise from '@payload-config'
3
- import '@payloadcms/next/css'
4
3
  import { RootLayout } from '@payloadcms/next/layouts'
5
4
  /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
6
5
  import React from 'react'
package/package.json CHANGED
@@ -1,17 +1,24 @@
1
1
  {
2
2
  "name": "create-payload-app",
3
- "version": "3.0.0-alpha.64",
4
- "license": "MIT",
5
- "type": "module",
3
+ "version": "3.0.0-alpha.66",
6
4
  "homepage": "https://payloadcms.com",
7
- "bin": {
8
- "create-payload-app": "bin/cli.js"
9
- },
10
5
  "repository": {
11
6
  "type": "git",
12
7
  "url": "https://github.com/payloadcms/payload.git",
13
8
  "directory": "packages/create-payload-app"
14
9
  },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ "./commands": {
14
+ "import": "./src/lib/init-next.ts",
15
+ "require": "./src/lib/init-next.ts",
16
+ "types": "./src/lib/init-next.ts"
17
+ }
18
+ },
19
+ "bin": {
20
+ "create-payload-app": "bin/cli.js"
21
+ },
15
22
  "files": [
16
23
  "package.json",
17
24
  "dist",
@@ -41,19 +48,12 @@
41
48
  "@types/jest": "^27.0.3",
42
49
  "@types/node": "20.12.5"
43
50
  },
44
- "exports": {
45
- "./commands": {
46
- "import": "./src/lib/init-next.ts",
47
- "require": "./src/lib/init-next.ts",
48
- "types": "./src/lib/init-next.ts"
49
- }
50
- },
51
51
  "scripts": {
52
52
  "build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
53
- "typecheck": "tsc",
54
- "pack-template-files": "tsx src/scripts/pack-template-files.ts",
55
53
  "build:swc": "swc ./src -d ./dist --config-file .swcrc",
56
54
  "clean": "rimraf {dist,*.tsbuildinfo}",
57
- "test": "jest"
55
+ "pack-template-files": "tsx src/scripts/pack-template-files.ts",
56
+ "test": "jest",
57
+ "typecheck": "tsc"
58
58
  }
59
59
  }