create-payload-app 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) 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 +19 -9
  12. package/dist/lib/create-project.js.map +1 -1
  13. package/dist/lib/create-project.spec.js +27 -31
  14. package/dist/lib/create-project.spec.js.map +1 -1
  15. package/dist/lib/download-template.d.ts +7 -0
  16. package/dist/lib/download-template.d.ts.map +1 -0
  17. package/dist/lib/download-template.js +28 -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.d.ts +6 -0
  21. package/dist/lib/get-package-manager.d.ts.map +1 -0
  22. package/dist/lib/get-package-manager.js +50 -0
  23. package/dist/lib/get-package-manager.js.map +1 -0
  24. package/dist/lib/init-next.d.ts +8 -16
  25. package/dist/lib/init-next.d.ts.map +1 -1
  26. package/dist/lib/init-next.js +81 -58
  27. package/dist/lib/init-next.js.map +1 -1
  28. package/dist/lib/install-packages.d.ts +9 -0
  29. package/dist/lib/install-packages.d.ts.map +1 -0
  30. package/dist/lib/install-packages.js +43 -0
  31. package/dist/lib/install-packages.js.map +1 -0
  32. package/dist/lib/parse-project-name.d.ts.map +1 -1
  33. package/dist/lib/parse-project-name.js +9 -3
  34. package/dist/lib/parse-project-name.js.map +1 -1
  35. package/dist/lib/parse-template.d.ts.map +1 -1
  36. package/dist/lib/parse-template.js +3 -1
  37. package/dist/lib/parse-template.js.map +1 -1
  38. package/dist/lib/replacements.d.ts +27 -0
  39. package/dist/lib/replacements.d.ts.map +1 -0
  40. package/dist/lib/replacements.js +92 -0
  41. package/dist/lib/replacements.js.map +1 -0
  42. package/dist/lib/select-db.d.ts.map +1 -1
  43. package/dist/lib/select-db.js +23 -14
  44. package/dist/lib/select-db.js.map +1 -1
  45. package/dist/lib/templates.d.ts.map +1 -1
  46. package/dist/lib/templates.js +8 -25
  47. package/dist/lib/templates.js.map +1 -1
  48. package/dist/lib/update-payload-in-project.d.ts +6 -0
  49. package/dist/lib/update-payload-in-project.d.ts.map +1 -0
  50. package/dist/lib/update-payload-in-project.js +73 -0
  51. package/dist/lib/update-payload-in-project.js.map +1 -0
  52. package/dist/lib/wrap-next-config.d.ts +5 -5
  53. package/dist/lib/wrap-next-config.d.ts.map +1 -1
  54. package/dist/lib/wrap-next-config.js +120 -61
  55. package/dist/lib/wrap-next-config.js.map +1 -1
  56. package/dist/lib/wrap-next-config.spec.js +85 -34
  57. package/dist/lib/wrap-next-config.spec.js.map +1 -1
  58. package/dist/lib/write-env-file.d.ts +2 -1
  59. package/dist/lib/write-env-file.d.ts.map +1 -1
  60. package/dist/lib/write-env-file.js +31 -26
  61. package/dist/lib/write-env-file.js.map +1 -1
  62. package/dist/main.d.ts.map +1 -1
  63. package/dist/main.js +54 -34
  64. package/dist/main.js.map +1 -1
  65. package/dist/scripts/pack-template-files.js +3 -3
  66. package/dist/scripts/pack-template-files.js.map +1 -1
  67. package/dist/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +8 -6
  68. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +8 -6
  69. package/dist/template/src/app/(payload)/admin/importMap.js +1 -0
  70. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +11 -2
  71. package/dist/template/src/app/(payload)/api/graphql/route.ts +4 -2
  72. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +2 -1
  73. package/dist/template/src/app/(payload)/layout.tsx +19 -4
  74. package/dist/template/src/collections/Media.ts +16 -0
  75. package/dist/template/src/collections/Users.ts +1 -1
  76. package/dist/template/src/payload-types.ts +127 -0
  77. package/dist/template/src/payload.config.ts +13 -15
  78. package/dist/types.d.ts +15 -1
  79. package/dist/types.d.ts.map +1 -1
  80. package/dist/types.js.map +1 -1
  81. package/dist/utils/copy-recursive-sync.d.ts +3 -1
  82. package/dist/utils/copy-recursive-sync.d.ts.map +1 -1
  83. package/dist/utils/copy-recursive-sync.js +6 -1
  84. package/dist/utils/copy-recursive-sync.js.map +1 -1
  85. package/dist/utils/git.d.ts +4 -0
  86. package/dist/utils/git.d.ts.map +1 -0
  87. package/dist/utils/git.js +46 -0
  88. package/dist/utils/git.js.map +1 -0
  89. package/dist/utils/log.d.ts.map +1 -1
  90. package/dist/utils/log.js +1 -1
  91. package/dist/utils/log.js.map +1 -1
  92. package/dist/utils/messages.d.ts.map +1 -1
  93. package/dist/utils/messages.js +1 -0
  94. package/dist/utils/messages.js.map +1 -1
  95. package/license.md +22 -0
  96. package/package.json +34 -10
  97. package/dist/lib/packages.d.ts +0 -9
  98. package/dist/lib/packages.d.ts.map +0 -1
  99. package/dist/lib/packages.js +0 -27
  100. package/dist/lib/packages.js.map +0 -1
@@ -0,0 +1,92 @@
1
+ const mongodbReplacement = {
2
+ // Replacement between `// database-adapter-config-start` and `// database-adapter-config-end`
3
+ configReplacement: (envName = 'DATABASE_URI')=>[
4
+ ' db: mongooseAdapter({',
5
+ ` url: process.env.${envName} || '',`,
6
+ ' }),'
7
+ ],
8
+ importReplacement: "import { mongooseAdapter } from '@payloadcms/db-mongodb'",
9
+ packageName: '@payloadcms/db-mongodb'
10
+ };
11
+ const postgresReplacement = {
12
+ configReplacement: (envName = 'DATABASE_URI')=>[
13
+ ' db: postgresAdapter({',
14
+ ' pool: {',
15
+ ` connectionString: process.env.${envName} || '',`,
16
+ ' },',
17
+ ' }),'
18
+ ],
19
+ importReplacement: "import { postgresAdapter } from '@payloadcms/db-postgres'",
20
+ packageName: '@payloadcms/db-postgres'
21
+ };
22
+ const vercelPostgresReplacement = {
23
+ configReplacement: (envName = 'POSTGRES_URL')=>[
24
+ ' db: vercelPostgresAdapter({',
25
+ ' pool: {',
26
+ ` connectionString: process.env.${envName} || '',`,
27
+ ' },',
28
+ ' }),'
29
+ ],
30
+ importReplacement: "import { vercelPostgresAdapter } from '@payloadcms/db-vercel-postgres'",
31
+ packageName: '@payloadcms/db-vercel-postgres'
32
+ };
33
+ const sqliteReplacement = {
34
+ configReplacement: (envName = 'DATABASE_URI')=>[
35
+ ' db: sqliteAdapter({',
36
+ ' client: {',
37
+ ` url: process.env.${envName} || '',`,
38
+ ' },',
39
+ ' }),'
40
+ ],
41
+ importReplacement: "import { sqliteAdapter } from '@payloadcms/db-sqlite'",
42
+ packageName: '@payloadcms/db-sqlite'
43
+ };
44
+ export const dbReplacements = {
45
+ mongodb: mongodbReplacement,
46
+ postgres: postgresReplacement,
47
+ sqlite: sqliteReplacement,
48
+ 'vercel-postgres': vercelPostgresReplacement
49
+ };
50
+ const vercelBlobStorageReplacement = {
51
+ // Replacement of `// storage-adapter-placeholder`
52
+ configReplacement: [
53
+ ' vercelBlobStorage({',
54
+ ' collections: {',
55
+ ' [Media.slug]: true,',
56
+ ' },',
57
+ " token: process.env.BLOB_READ_WRITE_TOKEN || '',",
58
+ ' }),'
59
+ ],
60
+ importReplacement: "import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'",
61
+ packageName: '@payloadcms/storage-vercel-blob'
62
+ };
63
+ const payloadCloudReplacement = {
64
+ configReplacement: [
65
+ ' payloadCloudPlugin(),'
66
+ ],
67
+ importReplacement: "import { payloadCloudPlugin } from '@payloadcms/payload-cloud'",
68
+ packageName: '@payloadcms/payload-cloud'
69
+ };
70
+ // Removes placeholders
71
+ const diskReplacement = {
72
+ configReplacement: [],
73
+ importReplacement: ''
74
+ };
75
+ export const storageReplacements = {
76
+ localDisk: diskReplacement,
77
+ payloadCloud: payloadCloudReplacement,
78
+ vercelBlobStorage: vercelBlobStorageReplacement
79
+ };
80
+ export const configReplacements = {
81
+ sharp: {
82
+ // Replacement of `sharp, // Now optional`
83
+ configReplacement: {
84
+ match: 'sharp,',
85
+ replacement: ' // sharp,'
86
+ },
87
+ importReplacement: "import sharp from 'sharp'",
88
+ packageName: 'sharp'
89
+ }
90
+ };
91
+
92
+ //# sourceMappingURL=replacements.js.map
@@ -0,0 +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\nconst vercelPostgresReplacement: DbAdapterReplacement = {\n configReplacement: (envName = 'POSTGRES_URL') => [\n ' db: vercelPostgresAdapter({',\n ' pool: {',\n ` connectionString: process.env.${envName} || '',`,\n ' },',\n ' }),',\n ],\n importReplacement: \"import { vercelPostgresAdapter } from '@payloadcms/db-vercel-postgres'\",\n packageName: '@payloadcms/db-vercel-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 'vercel-postgres': vercelPostgresReplacement,\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/payload-cloud'\",\n packageName: '@payloadcms/payload-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","vercelPostgresReplacement","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,4BAAkD;IACtDL,mBAAmB,CAACC,UAAU,cAAc,GAAK;YAC/C;YACA;YACA,CAAC,oCAAoC,EAAEA,QAAQ,OAAO,CAAC;YACvD;YACA;SACD;IACDC,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMG,oBAA0C;IAC9CN,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,MAAMI,iBAAuD;IAClEC,SAAST;IACTU,UAAUL;IACVM,QAAQJ;IACR,mBAAmBD;AACrB,EAAC;AAQD,MAAMM,+BAA0D;IAC9D,kDAAkD;IAClDX,mBAAmB;QACjB;QACA;QACA;QACA;QACA;QACA;KACD;IACDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,MAAMS,0BAAqD;IACzDZ,mBAAmB;QAAC;KAA4B;IAChDE,mBAAmB;IACnBC,aAAa;AACf;AAEA,uBAAuB;AACvB,MAAMU,kBAA6C;IACjDb,mBAAmB,EAAE;IACrBE,mBAAmB;AACrB;AAEA,OAAO,MAAMY,sBAA6E;IACxFC,WAAWF;IACXG,cAAcJ;IACdK,mBAAmBN;AACrB,EAAC;AAcD,OAAO,MAAMO,qBAAwD;IACnEC,OAAO;QACL,0CAA0C;QAC1CnB,mBAAmB;YACjBoB,OAAO;YACPC,aAAa;QACf;QACAnB,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;AAiC7D,wBAAsB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAkDrF"}
@@ -8,8 +8,19 @@ const dbChoiceRecord = {
8
8
  },
9
9
  postgres: {
10
10
  dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',
11
- title: 'PostgreSQL (beta)',
11
+ title: 'PostgreSQL',
12
12
  value: 'postgres'
13
+ },
14
+ sqlite: {
15
+ dbConnectionPrefix: 'file:./',
16
+ dbConnectionSuffix: '.db',
17
+ title: 'SQLite (beta)',
18
+ value: 'sqlite'
19
+ },
20
+ 'vercel-postgres': {
21
+ dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',
22
+ title: 'Vercel Postgres (beta)',
23
+ value: 'vercel-postgres'
13
24
  }
14
25
  };
15
26
  export async function selectDb(args, projectName) {
@@ -23,22 +34,18 @@ export async function selectDb(args, projectName) {
23
34
  dbType = await p.select({
24
35
  initialValue: 'mongodb',
25
36
  message: `Select a database`,
26
- options: [
27
- {
28
- label: 'MongoDB',
29
- value: 'mongodb'
30
- },
31
- {
32
- label: 'Postgres',
33
- value: 'postgres'
34
- }
35
- ]
37
+ options: Object.values(dbChoiceRecord).map((dbChoice)=>({
38
+ label: dbChoice.title,
39
+ value: dbChoice.value
40
+ }))
36
41
  });
37
- if (p.isCancel(dbType)) process.exit(0);
42
+ if (p.isCancel(dbType)) {
43
+ process.exit(0);
44
+ }
38
45
  }
39
46
  const dbChoice = dbChoiceRecord[dbType];
40
47
  let dbUri = undefined;
41
- const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)}`;
48
+ const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : slugify(projectName)}${dbChoice.dbConnectionSuffix || ''}`;
42
49
  if (args['--db-accept-recommended']) {
43
50
  dbUri = initialDbUri;
44
51
  } else if (args['--db-connection-string']) {
@@ -48,7 +55,9 @@ export async function selectDb(args, projectName) {
48
55
  initialValue: initialDbUri,
49
56
  message: `Enter ${dbChoice.title.split(' ')[0]} connection string`
50
57
  });
51
- if (p.isCancel(dbUri)) process.exit(0);
58
+ if (p.isCancel(dbUri)) {
59
+ process.exit(0);
60
+ }
52
61
  }
53
62
  return {
54
63
  type: dbChoice.value,
@@ -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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAU3C,MAAMC,iBAA2C;IAC/CC,SAAS;QACPC,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IAC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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',\n value: 'postgres',\n },\n sqlite: {\n dbConnectionPrefix: 'file:./',\n dbConnectionSuffix: '.db',\n title: 'SQLite (beta)',\n value: 'sqlite',\n },\n 'vercel-postgres': {\n dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',\n title: 'Vercel Postgres (beta)',\n value: 'vercel-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: Object.values(dbChoiceRecord).map((dbChoice) => ({\n label: dbChoice.title,\n value: dbChoice.value,\n })),\n })\n if (p.isCancel(dbType)) {\n process.exit(0)\n }\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)) {\n process.exit(0)\n }\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","getRandomDigitSuffix","text","split","type","Math","random","pow","toFixed"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAW3C,MAAMC,iBAA2C;IAC/CC,SAAS;QACPC,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;IACAC,UAAU;QACRH,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;IACAE,QAAQ;QACNJ,oBAAoB;QACpBK,oBAAoB;QACpBJ,OAAO;QACPC,OAAO;IACT;IACA,mBAAmB;QACjBF,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;AACF;AAEA,OAAO,eAAeI,SAASC,IAAa,EAAEC,WAAmB;IAC/D,IAAIC,SAAsCC;IAC1C,IAAIH,IAAI,CAAC,OAAO,EAAE;QAChB,IAAI,CA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CAAC;QACf;IACF;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":"templates.d.ts","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAQ9D;AAED,wBAAgB,iBAAiB,IAAI,eAAe,EAAE,CAgDrD"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAKlD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAQ9D;AAED,wBAAgB,iBAAiB,IAAI,eAAe,EAAE,CAuBrD"}
@@ -1,4 +1,5 @@
1
1
  import { error, info } from '../utils/log.js';
2
+ import { PACKAGE_VERSION } from './constants.js';
2
3
  export function validateTemplate(templateName) {
3
4
  const validTemplates = getValidTemplates();
4
5
  if (!validTemplates.map((t)=>t.name).includes(templateName)) {
@@ -9,37 +10,19 @@ export function validateTemplate(templateName) {
9
10
  return true;
10
11
  }
11
12
  export function getValidTemplates() {
13
+ // Starters _must_ be a valid template name from the templates/ directory
12
14
  return [
13
15
  {
14
- name: 'blank-3.0',
16
+ name: 'blank',
15
17
  type: 'starter',
16
18
  description: 'Blank 3.0 Template',
17
- url: 'https://github.com/payloadcms/payload/templates/blank-3.0#beta'
19
+ url: `https://github.com/payloadcms/payload/templates/blank#v${PACKAGE_VERSION}`
18
20
  },
19
- // Remove these until they have been updated for 3.0
20
- // {
21
- // name: 'blank',
22
- // type: 'starter',
23
- // description: 'Blank Template',
24
- // url: 'https://github.com/payloadcms/payload/templates/blank',
25
- // },
26
- // {
27
- // name: 'website',
28
- // type: 'starter',
29
- // description: 'Website Template',
30
- // url: 'https://github.com/payloadcms/payload/templates/website',
31
- // },
32
- // {
33
- // name: 'ecommerce',
34
- // type: 'starter',
35
- // description: 'E-commerce Template',
36
- // url: 'https://github.com/payloadcms/payload/templates/ecommerce',
37
- // },
38
21
  {
39
- name: 'plugin',
40
- type: 'plugin',
41
- description: 'Template for creating a Payload plugin',
42
- url: 'https://github.com/payloadcms/payload-plugin-template#beta'
22
+ name: 'website',
23
+ type: 'starter',
24
+ description: 'Website Template',
25
+ url: `https://github.com/payloadcms/payload/templates/website#v${PACKAGE_VERSION}`
43
26
  }
44
27
  ];
45
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\n\nexport function validateTemplate(templateName: string): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n return [\n {\n name: 'blank-3.0',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: 'https://github.com/payloadcms/payload/templates/blank-3.0#beta',\n },\n\n // Remove these until they have been updated for 3.0\n\n // {\n // name: 'blank',\n // type: 'starter',\n // description: 'Blank Template',\n // url: 'https://github.com/payloadcms/payload/templates/blank',\n // },\n // {\n // name: 'website',\n // type: 'starter',\n // description: 'Website Template',\n // url: 'https://github.com/payloadcms/payload/templates/website',\n // },\n // {\n // name: 'ecommerce',\n // type: 'starter',\n // description: 'E-commerce Template',\n // url: 'https://github.com/payloadcms/payload/templates/ecommerce',\n // },\n {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload-plugin-template#beta',\n },\n // {\n // name: 'payload-demo',\n // type: 'starter',\n // description: 'Payload demo site at https://demo.payloadcms.com',\n // url: 'https://github.com/payloadcms/public-demo',\n // },\n // {\n // name: 'payload-website',\n // type: 'starter',\n // description: 'Payload website CMS at https://payloadcms.com',\n // url: 'https://github.com/payloadcms/website-cms',\n // },\n ]\n}\n"],"names":["error","info","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAE7C,OAAO,SAASC,iBAAiBC,YAAoB;IACnD,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DH,MAAM,CAAC,CAAC,EAAEG,aAAa,0BAA0B,CAAC;QAClDF,KAAK,CAAC,iBAAiB,EAAEG,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,MAAM,CAAC;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QAEA,oDAAoD;QAEpD,IAAI;QACJ,mBAAmB;QACnB,qBAAqB;QACrB,mCAAmC;QACnC,kEAAkE;QAClE,KAAK;QACL,IAAI;QACJ,qBAAqB;QACrB,qBAAqB;QACrB,qCAAqC;QACrC,oEAAoE;QACpE,KAAK;QACL,IAAI;QACJ,uBAAuB;QACvB,qBAAqB;QACrB,wCAAwC;QACxC,sEAAsE;QACtE,KAAK;QACL;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KAaD;AACH"}
1
+ {"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\nimport { PACKAGE_VERSION } from './constants.js'\n\nexport function validateTemplate(templateName: string): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n // Starters _must_ be a valid template name from the templates/ directory\n return [\n {\n name: 'blank',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: `https://github.com/payloadcms/payload/templates/blank#v${PACKAGE_VERSION}`,\n },\n {\n name: 'website',\n type: 'starter',\n description: 'Website Template',\n url: `https://github.com/payloadcms/payload/templates/website#v${PACKAGE_VERSION}`,\n },\n\n // {\n // name: 'plugin',\n // type: 'plugin',\n // description: 'Template for creating a Payload plugin',\n // url: 'https://github.com/payloadcms/plugin-template#beta',\n // },\n ]\n}\n"],"names":["error","info","PACKAGE_VERSION","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url"],"mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAC7C,SAASC,eAAe,QAAQ,iBAAgB;AAEhD,OAAO,SAASC,iBAAiBC,YAAoB;IACnD,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DJ,MAAM,CAAC,CAAC,EAAEI,aAAa,0BAA0B,CAAC;QAClDH,KAAK,CAAC,iBAAiB,EAAEI,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,MAAM,CAAC;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,yEAAyE;IACzE,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,uDAAuD,EAAEZ,gBAAgB,CAAC;QAClF;QACA;YACEO,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,yDAAyD,EAAEZ,gBAAgB,CAAC;QACpF;KAQD;AACH"}
@@ -0,0 +1,6 @@
1
+ import type { NextAppDetails } from '../types.js';
2
+ export declare function updatePayloadInProject(appDetails: NextAppDetails): Promise<{
3
+ message: string;
4
+ success: boolean;
5
+ }>;
6
+ //# sourceMappingURL=update-payload-in-project.d.ts.map
@@ -0,0 +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,CA2EhD"}
@@ -0,0 +1,73 @@
1
+ import execa from 'execa';
2
+ import fse from 'fs-extra';
3
+ import { fileURLToPath } from 'node:url';
4
+ import path from 'path';
5
+ const filename = fileURLToPath(import.meta.url);
6
+ const dirname = path.dirname(filename);
7
+ import { copyRecursiveSync } from '../utils/copy-recursive-sync.js';
8
+ import { info } from '../utils/log.js';
9
+ import { getPackageManager } from './get-package-manager.js';
10
+ import { installPackages } from './install-packages.js';
11
+ export async function updatePayloadInProject(appDetails) {
12
+ if (!appDetails.nextConfigPath) {
13
+ return {
14
+ message: 'No Next.js config found',
15
+ success: false
16
+ };
17
+ }
18
+ const projectDir = path.dirname(appDetails.nextConfigPath);
19
+ const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'));
20
+ if (!packageObj?.dependencies) {
21
+ throw new Error('No package.json found in this project');
22
+ }
23
+ const payloadVersion = packageObj.dependencies?.payload;
24
+ if (!payloadVersion) {
25
+ throw new Error('Payload is not installed in this project');
26
+ }
27
+ const packageManager = await getPackageManager({
28
+ projectDir
29
+ });
30
+ // Fetch latest Payload version from npm
31
+ const { exitCode: getLatestVersionExitCode, stdout: latestPayloadVersion } = await execa('npm', [
32
+ 'show',
33
+ 'payload@beta',
34
+ 'version'
35
+ ]);
36
+ if (getLatestVersionExitCode !== 0) {
37
+ throw new Error('Failed to fetch latest Payload version');
38
+ }
39
+ if (payloadVersion === latestPayloadVersion) {
40
+ return {
41
+ message: `Payload v${payloadVersion} is already up to date.`,
42
+ success: true
43
+ };
44
+ }
45
+ // Update all existing Payload packages
46
+ const payloadPackages = Object.keys(packageObj.dependencies).filter((dep)=>dep.startsWith('@payloadcms/'));
47
+ const packageNames = [
48
+ 'payload',
49
+ ...payloadPackages
50
+ ];
51
+ const packagesToUpdate = packageNames.map((pkg)=>`${pkg}@${latestPayloadVersion}`);
52
+ info(`Using ${packageManager}.\n`);
53
+ info(`Updating ${packagesToUpdate.length} Payload packages to v${latestPayloadVersion}...\n\n${packageNames.map((p)=>` - ${p}`).join('\n')}`);
54
+ const { success: updateSuccess } = await installPackages({
55
+ packageManager,
56
+ packagesToInstall: packagesToUpdate,
57
+ projectDir
58
+ });
59
+ if (!updateSuccess) {
60
+ throw new Error('Failed to update Payload packages');
61
+ }
62
+ info('Payload packages updated successfully.');
63
+ info(`Updating Payload Next.js files...`);
64
+ const templateFilesPath = process.env.JEST_WORKER_ID !== undefined ? path.resolve(dirname, '../../../../templates/blank') : path.resolve(dirname, '../..', 'dist/template');
65
+ const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)');
66
+ copyRecursiveSync(templateSrcDir, path.resolve(projectDir, appDetails.isSrcDir ? 'src/app' : 'app', '(payload)'));
67
+ return {
68
+ message: 'Payload updated successfully.',
69
+ success: true
70
+ };
71
+ }
72
+
73
+ //# sourceMappingURL=update-payload-in-project.js.map
@@ -0,0 +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) {\n return { message: 'No Next.js config found', success: false }\n }\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')\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;QAC9B,OAAO;YAAEC,SAAS;YAA2BC,SAAS;QAAM;IAC9D;IAEA,MAAMC,aAAab,KAAKG,OAAO,CAACM,WAAWC,cAAc;IAEzD,MAAMI,aAAc,MAAMhB,IAAIiB,QAAQ,CAACf,KAAKgB,OAAO,CAACH,YAAY;IAGhE,IAAI,CAACC,YAAYG,cAAc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,GAAG,CAACC,cAAc,KAAKC,YAC3B7C,KAAKgB,OAAO,CAACb,SAAS,iCACtBH,KAAKgB,OAAO,CAACb,SAAS,SAAS;IAErC,MAAM2C,iBAAiB9C,KAAKgB,OAAO,CAACyB,mBAAmB;IAEvDrC,kBACE0C,gBACA9C,KAAKgB,OAAO,CAACH,YAAYJ,WAAWsC,QAAQ,GAAG,YAAY,OAAO;IAGpE,OAAO;QAAEpC,SAAS;QAAiCC,SAAS;IAAK;AACnE"}
@@ -1,18 +1,18 @@
1
+ import type { NextConfigType } from '../types.js';
1
2
  export declare const withPayloadStatement: {
2
3
  cjs: string;
3
4
  esm: string;
5
+ ts: string;
4
6
  };
5
- type NextConfigType = 'cjs' | 'esm';
6
7
  export declare const wrapNextConfig: (args: {
7
8
  nextConfigPath: string;
8
9
  nextConfigType: NextConfigType;
9
- }) => void;
10
+ }) => Promise<void>;
10
11
  /**
11
12
  * Parses config content with AST and wraps it with withPayload function
12
13
  */
13
- export declare function parseAndModifyConfigContent(content: string, configType: NextConfigType): {
14
+ export declare function parseAndModifyConfigContent(content: string, configType: NextConfigType): Promise<{
14
15
  modifiedConfigContent: string;
15
16
  success: boolean;
16
- };
17
- export {};
17
+ }>;
18
18
  //# sourceMappingURL=wrap-next-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AAED,KAAK,cAAc,GAAG,KAAK,GAAG,KAAK,CAAA;AAEnC,eAAO,MAAM,cAAc,SAAU;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;CAC/B,SAaA,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB;IAAE,qBAAqB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAiGrD"}
1
+ {"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,cAAc,SAAgB;IACzC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;CAC/B,kBAaA,CAAA;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,qBAAqB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA4H9D"}