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
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Main } from './main.js'\nimport { error } from './utils/log.js'\n\nexport async function main(): Promise<void> {\n try {\n await new Main().init()\n } catch (e) {\n if (e instanceof Error) {\n error(e.message)\n }\n }\n}\n"],"names":["Main","error","main","init","e","Error","message"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAW;AAChC,SAASC,KAAK,QAAQ,iBAAgB;AAEtC,OAAO,eAAeC;IACpB,IAAI;QACF,MAAM,IAAIF,OAAOG,IAAI;IACvB,EAAE,OAAOC,GAAG;QACV,IAAIA,aAAaC,OAAO;YACtBJ,MAAMG,EAAEE,OAAO;QACjB;IACF;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Main } from './main.js'\nimport { error } from './utils/log.js'\n\nexport async function main(): Promise<void> {\n try {\n await new Main().init()\n } catch (e) {\n if (e instanceof Error) {\n error(e.message)\n }\n }\n}\n"],"names":["Main","error","main","init","e","Error","message"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAW;AAChC,SAASC,KAAK,QAAQ,iBAAgB;AAEtC,OAAO,eAAeC;IACpB,IAAI;QACF,MAAM,IAAIF,OAAOG,IAAI;IACvB,EAAE,OAAOC,GAAG;QACV,IAAIA,aAAaC,OAAO;YACtBJ,MAAMG,EAAEE,OAAO;QACjB;IACF;AACF"}
@@ -1,11 +1,17 @@
1
- import type { DbDetails } from '../types.js';
1
+ import type { DbType, StorageAdapterType } from '../types.js';
2
2
  /** Update payload config with necessary imports and adapters */
3
3
  export declare function configurePayloadConfig(args: {
4
- dbDetails: DbDetails | undefined;
4
+ dbType?: DbType;
5
+ envNames?: {
6
+ dbUri: string;
7
+ };
8
+ packageJsonName?: string;
5
9
  projectDirOrConfigPath: {
6
10
  payloadConfigPath: string;
7
11
  } | {
8
12
  projectDir: string;
9
13
  };
14
+ sharp?: boolean;
15
+ storageAdapter?: StorageAdapterType;
10
16
  }): Promise<void>;
11
17
  //# sourceMappingURL=configure-payload-config.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"configure-payload-config.d.ts","sourceRoot":"","sources":["../../src/lib/configure-payload-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAK7D,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sBAAsB,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,kBAAkB,CAAA;CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8HhB"}
@@ -1,13 +1,10 @@
1
1
  import fse from 'fs-extra';
2
2
  import globby from 'globby';
3
- import { fileURLToPath } from 'node:url';
4
3
  import path from 'path';
5
- const filename = fileURLToPath(import.meta.url);
6
- const dirname = path.dirname(filename);
7
4
  import { warning } from '../utils/log.js';
8
- import { dbReplacements } from './packages.js';
5
+ import { dbReplacements, storageReplacements } from './replacements.js';
9
6
  /** Update payload config with necessary imports and adapters */ export async function configurePayloadConfig(args) {
10
- if (!args.dbDetails) {
7
+ if (!args.dbType) {
11
8
  return;
12
9
  }
13
10
  // Update package.json
@@ -15,7 +12,7 @@ import { dbReplacements } from './packages.js';
15
12
  if (packageJsonPath && fse.existsSync(packageJsonPath)) {
16
13
  try {
17
14
  const packageObj = await fse.readJson(packageJsonPath);
18
- const dbPackage = dbReplacements[args.dbDetails.type];
15
+ const dbPackage = dbReplacements[args.dbType];
19
16
  // Delete all other db adapters
20
17
  Object.values(dbReplacements).forEach((p)=>{
21
18
  if (p.packageName !== dbPackage.packageName) {
@@ -24,6 +21,20 @@ import { dbReplacements } from './packages.js';
24
21
  });
25
22
  // Set version of db adapter to match payload version
26
23
  packageObj.dependencies[dbPackage.packageName] = packageObj.dependencies['payload'];
24
+ if (args.storageAdapter) {
25
+ const storagePackage = storageReplacements[args.storageAdapter];
26
+ if (storagePackage?.packageName) {
27
+ // Set version of storage adapter to match payload version
28
+ packageObj.dependencies[storagePackage.packageName] = packageObj.dependencies['payload'];
29
+ }
30
+ }
31
+ // Sharp provided by default, only remove if explicitly set to false
32
+ if (args.sharp === false) {
33
+ delete packageObj.dependencies['sharp'];
34
+ }
35
+ if (args.packageJsonName) {
36
+ packageObj.name = args.packageJsonName;
37
+ }
27
38
  await fse.writeJson(packageJsonPath, packageObj, {
28
39
  spaces: 2
29
40
  });
@@ -47,31 +58,69 @@ import { dbReplacements } from './packages.js';
47
58
  return;
48
59
  }
49
60
  const configContent = fse.readFileSync(payloadConfigPath, 'utf-8');
50
- const configLines = configContent.split('\n');
51
- const dbReplacement = dbReplacements[args.dbDetails.type];
52
- let dbConfigStartLineIndex;
53
- let dbConfigEndLineIndex;
54
- configLines.forEach((l, i)=>{
55
- if (l.includes('// database-adapter-import')) {
56
- configLines[i] = dbReplacement.importReplacement;
57
- }
58
- if (l.includes('// database-adapter-config-start')) {
59
- dbConfigStartLineIndex = i;
60
- }
61
- if (l.includes('// database-adapter-config-end')) {
62
- dbConfigEndLineIndex = i;
63
- }
61
+ let configLines = configContent.split('\n');
62
+ // DB Replacement
63
+ const dbReplacement = dbReplacements[args.dbType];
64
+ configLines = replaceInConfigLines({
65
+ endMatch: `// database-adapter-config-end`,
66
+ lines: configLines,
67
+ replacement: dbReplacement.configReplacement(args.envNames?.dbUri),
68
+ startMatch: `// database-adapter-config-start`
64
69
  });
65
- if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) {
66
- warning('Unable to update payload.config.ts with database adapter import');
67
- } else {
68
- // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`
69
- configLines.splice(dbConfigStartLineIndex, dbConfigEndLineIndex - dbConfigStartLineIndex + 1, ...dbReplacement.configReplacement);
70
+ configLines = replaceInConfigLines({
71
+ lines: configLines,
72
+ replacement: [
73
+ dbReplacement.importReplacement
74
+ ],
75
+ startMatch: '// database-adapter-import'
76
+ });
77
+ // Storage Adapter Replacement
78
+ if (args.storageAdapter) {
79
+ const replacement = storageReplacements[args.storageAdapter];
80
+ configLines = replaceInConfigLines({
81
+ lines: configLines,
82
+ replacement: replacement.configReplacement,
83
+ startMatch: '// storage-adapter-placeholder'
84
+ });
85
+ if (replacement?.importReplacement !== undefined) {
86
+ configLines = replaceInConfigLines({
87
+ lines: configLines,
88
+ replacement: [
89
+ replacement.importReplacement
90
+ ],
91
+ startMatch: '// storage-adapter-import-placeholder'
92
+ });
93
+ }
94
+ }
95
+ // Sharp Replacement (provided by default, only remove if explicitly set to false)
96
+ if (args.sharp === false) {
97
+ configLines = replaceInConfigLines({
98
+ lines: configLines,
99
+ replacement: [],
100
+ startMatch: 'sharp,'
101
+ });
102
+ configLines = replaceInConfigLines({
103
+ lines: configLines,
104
+ replacement: [],
105
+ startMatch: "import sharp from 'sharp'"
106
+ });
70
107
  }
71
108
  fse.writeFileSync(payloadConfigPath, configLines.join('\n'));
72
109
  } catch (err) {
73
110
  warning(`Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`);
74
111
  }
75
112
  }
113
+ function replaceInConfigLines({ endMatch, lines, replacement, startMatch }) {
114
+ if (!replacement) {
115
+ return lines;
116
+ }
117
+ const startIndex = lines.findIndex((l)=>l.includes(startMatch));
118
+ const endIndex = endMatch ? lines.findIndex((l)=>l.includes(endMatch)) : startIndex;
119
+ if (startIndex === -1 || endIndex === -1) {
120
+ return lines;
121
+ }
122
+ lines.splice(startIndex, endIndex - startIndex + 1, ...replacement);
123
+ return lines;
124
+ }
76
125
 
77
126
  //# sourceMappingURL=configure-payload-config.js.map
@@ -1 +1 @@
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;IAC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,gBAAgB/B,cAAc,CAACE,KAAKC,SAAS,CAACS,IAAI,CAAC;QAEzD,IAAIoB;QACJ,IAAIC;QAEJJ,YAAYd,OAAO,CAAC,CAACmB,GAAGC;YACtB,IAAID,EAAEE,QAAQ,CAAC,+BAA+B;gBAC5CP,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"}
1
+ {"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\n\nimport type { DbType, StorageAdapterType } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { dbReplacements, storageReplacements } from './replacements.js'\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbType?: DbType\n envNames?: {\n dbUri: string\n }\n packageJsonName?: string\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n sharp?: boolean\n storageAdapter?: StorageAdapterType\n}): Promise<void> {\n if (!args.dbType) {\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.dbType]\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 if (args.storageAdapter) {\n const storagePackage = storageReplacements[args.storageAdapter]\n\n if (storagePackage?.packageName) {\n // Set version of storage adapter to match payload version\n packageObj.dependencies[storagePackage.packageName] = packageObj.dependencies['payload']\n }\n }\n\n // Sharp provided by default, only remove if explicitly set to false\n if (args.sharp === false) {\n delete packageObj.dependencies['sharp']\n }\n\n if (args.packageJsonName) {\n packageObj.name = args.packageJsonName\n }\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 let configLines = configContent.split('\\n')\n\n // DB Replacement\n const dbReplacement = dbReplacements[args.dbType]\n\n configLines = replaceInConfigLines({\n endMatch: `// database-adapter-config-end`,\n lines: configLines,\n replacement: dbReplacement.configReplacement(args.envNames?.dbUri),\n startMatch: `// database-adapter-config-start`,\n })\n\n configLines = replaceInConfigLines({\n lines: configLines,\n replacement: [dbReplacement.importReplacement],\n startMatch: '// database-adapter-import',\n })\n\n // Storage Adapter Replacement\n if (args.storageAdapter) {\n const replacement = storageReplacements[args.storageAdapter]\n configLines = replaceInConfigLines({\n lines: configLines,\n replacement: replacement.configReplacement,\n startMatch: '// storage-adapter-placeholder',\n })\n\n if (replacement?.importReplacement !== undefined) {\n configLines = replaceInConfigLines({\n lines: configLines,\n replacement: [replacement.importReplacement],\n startMatch: '// storage-adapter-import-placeholder',\n })\n }\n }\n\n // Sharp Replacement (provided by default, only remove if explicitly set to false)\n if (args.sharp === false) {\n configLines = replaceInConfigLines({\n lines: configLines,\n replacement: [],\n startMatch: 'sharp,',\n })\n configLines = replaceInConfigLines({\n lines: configLines,\n replacement: [],\n startMatch: \"import sharp from 'sharp'\",\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\nfunction replaceInConfigLines({\n endMatch,\n lines,\n replacement,\n startMatch,\n}: {\n /** Optional endMatch to replace multiple lines */\n endMatch?: string\n lines: string[]\n replacement: string[]\n startMatch: string\n}) {\n if (!replacement) {\n return lines\n }\n\n const startIndex = lines.findIndex((l) => l.includes(startMatch))\n const endIndex = endMatch ? lines.findIndex((l) => l.includes(endMatch)) : startIndex\n\n if (startIndex === -1 || endIndex === -1) {\n return lines\n }\n\n lines.splice(startIndex, endIndex - startIndex + 1, ...replacement)\n return lines\n}\n"],"names":["fse","globby","path","warning","dbReplacements","storageReplacements","configurePayloadConfig","args","dbType","packageJsonPath","projectDirOrConfigPath","resolve","projectDir","existsSync","packageObj","readJson","dbPackage","Object","values","forEach","p","packageName","dependencies","storageAdapter","storagePackage","sharp","packageJsonName","name","writeJson","spaces","err","Error","message","payloadConfigPath","absolute","cwd","configContent","readFileSync","configLines","split","dbReplacement","replaceInConfigLines","endMatch","lines","replacement","configReplacement","envNames","dbUri","startMatch","importReplacement","undefined","writeFileSync","join","startIndex","findIndex","l","includes","endIndex","splice"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YA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ACjCE,OAAOL;oBACPM,aAAa;wBAACA,YAAYK,iBAAiB;qBAAC;oBAC5CD,YAAY;gBACd;YACF;QACF;QAEA,kFAAkF;QAClF,IAAIzC,KAAKkB,KAAK,KAAK,OAAO;YACxBa,cAAcG,qBAAqB;gBACjCE,OAAOL;gBACPM,aAAa,EAAE;gBACfI,YAAY;YACd;YACAV,cAAcG,qBAAqB;gBACjCE,OAAOL;gBACPM,aAAa,EAAE;gBACfI,YAAY;YACd;QACF;QAEAhD,IAAImD,aAAa,CAAClB,mBAAmBK,YAAYc,IAAI,CAAC;IACxD,EAAE,OAAOtB,KAAc;QACrB3B,QACE,CAAC,iDAAiD,EAAE2B,eAAeC,QAAQD,IAAIE,OAAO,GAAG,GAAG,CAAC;IAEjG;AACF;AAEA,SAASS,qBAAqB,EAC5BC,QAAQ,EACRC,KAAK,EACLC,WAAW,EACXI,UAAU,EAOX;IACC,IAAI,CAACJ,aAAa;QAChB,OAAOD;IACT;IAEA,MAAMU,aAAaV,MAAMW,SAAS,CAAC,CAACC,IAAMA,EAAEC,QAAQ,CAACR;IACrD,MAAMS,WAAWf,WAAWC,MAAMW,SAAS,CAAC,CAACC,IAAMA,EAAEC,QAAQ,CAACd,aAAaW;IAE3E,IAAIA,eAAe,CAAC,KAAKI,aAAa,CAAC,GAAG;QACxC,OAAOd;IACT;IAEAA,MAAMe,MAAM,CAACL,YAAYI,WAAWJ,aAAa,MAAMT;IACvD,OAAOD;AACT"}
@@ -0,0 +1,2 @@
1
+ export declare const PACKAGE_VERSION: any;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,KAAsB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from 'fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import path from 'path';
4
+ const filename = fileURLToPath(import.meta.url);
5
+ const dirname = path.dirname(filename);
6
+ const packageJson = JSON.parse(readFileSync(path.resolve(dirname, '../../package.json'), 'utf-8'));
7
+ export const PACKAGE_VERSION = packageJson.version;
8
+
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/constants.ts"],"sourcesContent":["import { readFileSync } from 'fs'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nconst packageJson = JSON.parse(readFileSync(path.resolve(dirname, '../../package.json'), 'utf-8'))\nexport const PACKAGE_VERSION = packageJson.version\n"],"names":["readFileSync","fileURLToPath","path","filename","url","dirname","packageJson","JSON","parse","resolve","PACKAGE_VERSION","version"],"mappings":"AAAA,SAASA,YAAY,QAAQ,KAAI;AACjC,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAE7B,MAAMG,cAAcC,KAAKC,KAAK,CAACR,aAAaE,KAAKO,OAAO,CAACJ,SAAS,uBAAuB;AACzF,OAAO,MAAMK,kBAAkBJ,YAAYK,OAAO,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../src/lib/create-project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA2CtF,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,eAAe,CAAA;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB"}
1
+ {"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../src/lib/create-project.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA+CtF,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,eAAe,CAAA;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB"}
@@ -1,12 +1,13 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import chalk from 'chalk';
3
- import degit from 'degit';
4
3
  import execa from 'execa';
5
4
  import fse from 'fs-extra';
6
5
  import { fileURLToPath } from 'node:url';
7
6
  import path from 'path';
8
- import { debug, error, warning } from '../utils/log.js';
7
+ import { tryInitRepoAndCommit } from '../utils/git.js';
8
+ import { debug, error, info, warning } from '../utils/log.js';
9
9
  import { configurePayloadConfig } from './configure-payload-config.js';
10
+ import { downloadTemplate } from './download-template.js';
10
11
  const filename = fileURLToPath(import.meta.url);
11
12
  const dirname = path.dirname(filename);
12
13
  async function createOrFindProjectDir(projectDir) {
@@ -25,6 +26,8 @@ async function installDeps(args) {
25
26
  installCmd = 'yarn';
26
27
  } else if (packageManager === 'pnpm') {
27
28
  installCmd = 'pnpm install';
29
+ } else if (packageManager === 'bun') {
30
+ installCmd = 'bun install';
28
31
  }
29
32
  try {
30
33
  await execa.command(installCmd, {
@@ -48,13 +51,14 @@ export async function createProject(args) {
48
51
  const localTemplate = path.resolve(dirname, '../../../../templates/', cliArgs['--local-template']);
49
52
  await fse.copy(localTemplate, projectDir);
50
53
  } else if ('url' in template) {
51
- let templateUrl = template.url;
52
54
  if (cliArgs['--template-branch']) {
53
- templateUrl = `${template.url}#${cliArgs['--template-branch']}`;
54
- debug(`Using template url: ${templateUrl}`);
55
+ template.url = `${template.url.split('#')?.[0]}#${cliArgs['--template-branch']}`;
55
56
  }
56
- const emitter = degit(templateUrl);
57
- await emitter.clone(projectDir);
57
+ await downloadTemplate({
58
+ debug: cliArgs['--debug'],
59
+ projectDir,
60
+ template
61
+ });
58
62
  }
59
63
  const spinner = p.spinner();
60
64
  spinner.start('Checking latest Payload version...');
@@ -64,17 +68,18 @@ export async function createProject(args) {
64
68
  });
65
69
  spinner.message('Configuring Payload...');
66
70
  await configurePayloadConfig({
67
- dbDetails,
71
+ dbType: dbDetails?.type,
68
72
  projectDirOrConfigPath: {
69
73
  projectDir
70
74
  }
71
75
  });
72
76
  // Remove yarn.lock file. This is only desired in Payload Cloud.
73
- const lockPath = path.resolve(projectDir, 'yarn.lock');
77
+ const lockPath = path.resolve(projectDir, 'pnpm-lock.yaml');
74
78
  if (fse.existsSync(lockPath)) {
75
79
  await fse.remove(lockPath);
76
80
  }
77
81
  if (!cliArgs['--no-deps']) {
82
+ info(`Using ${packageManager}.\n`);
78
83
  spinner.message('Installing dependencies...');
79
84
  const result = await installDeps({
80
85
  cliArgs,
@@ -89,6 +94,11 @@ export async function createProject(args) {
89
94
  } else {
90
95
  spinner.stop('Dependency installation skipped');
91
96
  }
97
+ if (!cliArgs['--no-git']) {
98
+ tryInitRepoAndCommit({
99
+ cwd: projectDir
100
+ });
101
+ }
92
102
  }
93
103
  export async function updatePackageJSON(args) {
94
104
  const { projectDir, projectName } = args;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/create-project.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport chalk from 'chalk'\nimport degit from 'degit'\nimport execa from 'execa'\nimport fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nimport type { CliArgs, DbDetails, PackageManager, ProjectTemplate } from '../types.js'\n\nimport { debug, error, warning } from '../utils/log.js'\nimport { configurePayloadConfig } from './configure-payload-config.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nasync function createOrFindProjectDir(projectDir: string): Promise<void> {\n const pathExists = await fse.pathExists(projectDir)\n if (!pathExists) {\n await fse.mkdir(projectDir)\n }\n}\n\nasync function installDeps(args: {\n cliArgs: CliArgs\n packageManager: PackageManager\n projectDir: string\n}): Promise<boolean> {\n const { cliArgs, packageManager, projectDir } = args\n if (cliArgs['--no-deps']) {\n return true\n }\n let installCmd = 'npm install --legacy-peer-deps'\n\n if (packageManager === 'yarn') {\n installCmd = 'yarn'\n } else if (packageManager === 'pnpm') {\n installCmd = 'pnpm install'\n }\n\n try {\n await execa.command(installCmd, {\n cwd: path.resolve(projectDir),\n })\n return true\n } catch (err: unknown) {\n error(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`)\n return false\n }\n}\n\nexport async function createProject(args: {\n cliArgs: CliArgs\n dbDetails?: DbDetails\n packageManager: PackageManager\n projectDir: string\n projectName: string\n template: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`Dry run: Creating project in ${chalk.green(projectDir)}`)\n return\n }\n\n await createOrFindProjectDir(projectDir)\n\n if (cliArgs['--local-template']) {\n // Copy template from local path. For development purposes.\n const localTemplate = path.resolve(\n dirname,\n '../../../../templates/',\n cliArgs['--local-template'],\n )\n await fse.copy(localTemplate, projectDir)\n } else if ('url' in template) {\n let templateUrl = template.url\n if (cliArgs['--template-branch']) {\n templateUrl = `${template.url}#${cliArgs['--template-branch']}`\n debug(`Using template url: ${templateUrl}`)\n }\n const emitter = degit(templateUrl)\n await emitter.clone(projectDir)\n }\n\n const spinner = p.spinner()\n spinner.start('Checking latest Payload version...')\n\n await updatePackageJSON({ projectDir, projectName })\n spinner.message('Configuring Payload...')\n await configurePayloadConfig({ dbDetails, projectDirOrConfigPath: { projectDir } })\n\n // Remove yarn.lock file. This is only desired in Payload Cloud.\n const lockPath = path.resolve(projectDir, 'yarn.lock')\n if (fse.existsSync(lockPath)) {\n await fse.remove(lockPath)\n }\n\n if (!cliArgs['--no-deps']) {\n spinner.message('Installing dependencies...')\n const result = await installDeps({ cliArgs, packageManager, projectDir })\n if (result) {\n spinner.stop('Successfully installed Payload and dependencies')\n } else {\n spinner.stop('Error installing dependencies', 1)\n }\n } else {\n spinner.stop('Dependency installation skipped')\n }\n}\n\nexport async function updatePackageJSON(args: {\n projectDir: string\n projectName: string\n}): Promise<void> {\n const { projectDir, projectName } = args\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n try {\n const packageObj = await fse.readJson(packageJsonPath)\n packageObj.name = projectName\n await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })\n } catch (err: unknown) {\n warning(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`)\n }\n}\n"],"names":["p","chalk","degit","execa","fse","fileURLToPath","path","debug","error","warning","configurePayloadConfig","filename","url","dirname","createOrFindProjectDir","projectDir","pathExists","mkdir","installDeps","args","cliArgs","packageManager","installCmd","command","cwd","resolve","err","Error","message","createProject","dbDetails","projectName","template","green","localTemplate","copy","templateUrl","emitter","clone","spinner","start","updatePackageJSON","projectDirOrConfigPath","lockPath","existsSync","remove","result","stop","packageJsonPath","packageObj","readJson","name","writeJson","spaces"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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f;AACF;AAEA,OAAO,eAAeN,kBAAkBtB,IAGvC;IACC,MAAM,EAAEJ,UAAU,EAAEgB,WAAW,EAAE,GAAGZ;IACpC,MAAM6B,kBAAkB1C,KAAKmB,OAAO,CAACV,YAAY;IACjD,IAAI;QACF,MAAMkC,aAAa,MAAM7C,IAAI8C,QAAQ,CAACF;QACtCC,WAAWE,IAAI,GAAGpB;QAClB,MAAM3B,IAAIgD,SAAS,CAACJ,iBAAiBC,YAAY;YAAEI,QAAQ;QAAE;IAC/D,EAAE,OAAO3B,KAAc;QACrBjB,QAAQ,CAAC,uCAAuC,EAAEiB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,GAAG,CAAC;IAC7F;AACF"}
1
+ {"version":3,"sources":["../../src/lib/create-project.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport chalk from 'chalk'\nimport execa from 'execa'\nimport fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nimport type { CliArgs, DbDetails, PackageManager, ProjectTemplate } from '../types.js'\n\nimport { tryInitRepoAndCommit } from '../utils/git.js'\nimport { debug, error, info, warning } from '../utils/log.js'\nimport { configurePayloadConfig } from './configure-payload-config.js'\nimport { downloadTemplate } from './download-template.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nasync function createOrFindProjectDir(projectDir: string): Promise<void> {\n const pathExists = await fse.pathExists(projectDir)\n if (!pathExists) {\n await fse.mkdir(projectDir)\n }\n}\n\nasync function installDeps(args: {\n cliArgs: CliArgs\n packageManager: PackageManager\n projectDir: string\n}): Promise<boolean> {\n const { cliArgs, packageManager, projectDir } = args\n if (cliArgs['--no-deps']) {\n return true\n }\n let installCmd = 'npm install --legacy-peer-deps'\n\n if (packageManager === 'yarn') {\n installCmd = 'yarn'\n } else if (packageManager === 'pnpm') {\n installCmd = 'pnpm install'\n } else if (packageManager === 'bun') {\n installCmd = 'bun install'\n }\n\n try {\n await execa.command(installCmd, {\n cwd: path.resolve(projectDir),\n })\n return true\n } catch (err: unknown) {\n error(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`)\n return false\n }\n}\n\nexport async function createProject(args: {\n cliArgs: CliArgs\n dbDetails?: DbDetails\n packageManager: PackageManager\n projectDir: string\n projectName: string\n template: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`Dry run: Creating project in ${chalk.green(projectDir)}`)\n return\n }\n\n await createOrFindProjectDir(projectDir)\n\n if (cliArgs['--local-template']) {\n // Copy template from local path. For development purposes.\n const localTemplate = path.resolve(\n dirname,\n '../../../../templates/',\n cliArgs['--local-template'],\n )\n await fse.copy(localTemplate, projectDir)\n } else if ('url' in template) {\n if (cliArgs['--template-branch']) {\n template.url = `${template.url.split('#')?.[0]}#${cliArgs['--template-branch']}`\n }\n\n await downloadTemplate({\n debug: cliArgs['--debug'],\n projectDir,\n template,\n })\n }\n\n const spinner = p.spinner()\n spinner.start('Checking latest Payload version...')\n\n await updatePackageJSON({ projectDir, projectName })\n spinner.message('Configuring Payload...')\n await configurePayloadConfig({\n dbType: dbDetails?.type,\n projectDirOrConfigPath: { projectDir },\n })\n\n // Remove yarn.lock file. This is only desired in Payload Cloud.\n const lockPath = path.resolve(projectDir, 'pnpm-lock.yaml')\n if (fse.existsSync(lockPath)) {\n await fse.remove(lockPath)\n }\n\n if (!cliArgs['--no-deps']) {\n info(`Using ${packageManager}.\\n`)\n spinner.message('Installing dependencies...')\n const result = await installDeps({ cliArgs, packageManager, projectDir })\n if (result) {\n spinner.stop('Successfully installed Payload and dependencies')\n } else {\n spinner.stop('Error installing dependencies', 1)\n }\n } else {\n spinner.stop('Dependency installation skipped')\n }\n\n if (!cliArgs['--no-git']) {\n tryInitRepoAndCommit({ cwd: projectDir })\n }\n}\n\nexport async function updatePackageJSON(args: {\n projectDir: string\n projectName: string\n}): Promise<void> {\n const { projectDir, projectName } = args\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n try {\n const packageObj = await fse.readJson(packageJsonPath)\n packageObj.name = projectName\n await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })\n } catch (err: unknown) {\n warning(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`)\n }\n}\n"],"names":["p","chalk","execa","fse","fileURLToPath","path","tryInitRepoAndCommit","debug","error","info","warning","configurePayloadConfig","downloadTemplate","filename","url","dirname","createOrFindProjectDir","projectDir","pathExists","mkdir","installDeps","args","cliArgs","packageManager","installCmd","command","cwd","resolve","err","Error","message","createProject","dbDetails","projectName","template","green","localTemplate","copy","split","spinner","start","updatePackageJSON","dbType","type","projectDirOrConfigPath","lockPath","existsSync","remove","result","stop","packageJsonPath","packageObj","readJson","name","writeJson","spaces"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,WAAW,QAAO;AACzB,OAAOC,WAAW,QAAO;AACzB,OAAOC,SAAS,WAAU;AAC1B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AAIvB,SAASC,oBAAoB,QAAQ,kBAAiB;AACtD,SAASC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,QAAQ,kBAAiB;AAC7D,SAASC,sBAAsB,QAAQ,gCAA+B;AACtE,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,MAAMC,WAAWT,cAAc,YAAYU,GAAG;AAC9C,MAAMC,UAAUV,KAAKU,OAAO,CAACF;AAE7B,eAAeG,uBAAuBC,UAAkB;IACtD,MAAMC,aAAa,MAAMf,IAAIe,UAAU,CAACD;IACxC,IAAI,CAACC,YAAY;QACf,MAAMf,IAAIgB,KAAK,CAACF;IAClB;AACF;AAEA,eAAeG,YAAYC,IAI1B;IACC,MAAM,EAAEC,OAAO,EAAEC,cAAc,EAAEN,UAAU,EAAE,GAAGI;IAChD,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxB,OAAO;IACT;IACA,IAAIE,aAAa;IAEjB,I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by';
5
+ import * as os from 'node:os';
2
6
  import path from 'path';
3
7
  import { createProject } from './create-project.js';
4
- import { fileURLToPath } from 'node:url';
5
- import { dbReplacements } from './packages.js';
8
+ import { dbReplacements } from './replacements.js';
6
9
  import { getValidTemplates } from './templates.js';
7
- import globby from 'globby';
8
- const filename = fileURLToPath(import.meta.url);
9
- const dirname = path.dirname(filename);
10
- const projectDir = path.resolve(dirname, './tmp');
11
10
  describe('createProject', ()=>{
11
+ let projectDir;
12
12
  beforeAll(()=>{
13
+ // eslint-disable-next-line no-console
13
14
  console.log = jest.fn();
14
15
  });
15
16
  beforeEach(()=>{
16
- if (fse.existsSync(projectDir)) {
17
- fse.rmdirSync(projectDir, {
18
- recursive: true
19
- });
20
- }
17
+ const tempDirectory = fs.realpathSync(os.tmpdir());
18
+ projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`;
21
19
  });
22
20
  afterEach(()=>{
23
21
  if (fse.existsSync(projectDir)) {
@@ -27,7 +25,6 @@ describe('createProject', ()=>{
27
25
  }
28
26
  });
29
27
  describe('#createProject', ()=>{
30
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
31
28
  const args = {
32
29
  _: [
33
30
  'project-name'
@@ -42,30 +39,30 @@ describe('createProject', ()=>{
42
39
  const template = {
43
40
  name: 'plugin',
44
41
  type: 'plugin',
45
- url: 'https://github.com/payloadcms/payload-plugin-template',
46
- description: 'Template for creating a Payload plugin'
42
+ description: 'Template for creating a Payload plugin',
43
+ url: 'https://github.com/payloadcms/payload-plugin-template'
47
44
  };
48
45
  await createProject({
49
46
  cliArgs: args,
50
- projectName,
47
+ packageManager,
51
48
  projectDir,
52
- template,
53
- packageManager
49
+ projectName,
50
+ template
54
51
  });
55
52
  const packageJsonPath = path.resolve(projectDir, 'package.json');
56
53
  const packageJson = fse.readJsonSync(packageJsonPath);
57
54
  // Check package name and description
58
- expect(packageJson.name).toEqual(projectName);
55
+ expect(packageJson.name).toStrictEqual(projectName);
59
56
  });
60
57
  describe('creates project from template', ()=>{
61
58
  const templates = getValidTemplates();
62
59
  it.each([
63
60
  [
64
- 'blank-3.0',
61
+ 'blank',
65
62
  'mongodb'
66
63
  ],
67
64
  [
68
- 'blank-3.0',
65
+ 'blank',
69
66
  'postgres'
70
67
  ]
71
68
  ])('update config and deps: %s, %s', async (templateName, db)=>{
@@ -78,34 +75,33 @@ describe('createProject', ()=>{
78
75
  };
79
76
  await createProject({
80
77
  cliArgs,
81
- projectName,
82
- projectDir,
83
- template: template,
84
- packageManager,
85
78
  dbDetails: {
86
- dbUri: `${db}://localhost:27017/create-project-test`,
87
- type: db
88
- }
79
+ type: db,
80
+ dbUri: `${db}://localhost:27017/create-project-test`
81
+ },
82
+ packageManager,
83
+ projectDir,
84
+ projectName,
85
+ template: template
89
86
  });
90
87
  const dbReplacement = dbReplacements[db];
91
88
  const packageJsonPath = path.resolve(projectDir, 'package.json');
92
89
  const packageJson = fse.readJsonSync(packageJsonPath);
90
+ // Verify git was initialized
91
+ expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true);
93
92
  // Should only have one db adapter
94
93
  expect(Object.keys(packageJson.dependencies).filter((n)=>n.startsWith('@payloadcms/db-'))).toHaveLength(1);
95
94
  const payloadConfigPath = (await globby('**/payload.config.ts', {
96
95
  absolute: true,
97
96
  cwd: projectDir
98
97
  }))?.[0];
99
- if (!payloadConfigPath) {
100
- throw new Error(`Could not find payload.config.ts inside ${projectDir}`);
101
- }
102
98
  const content = fse.readFileSync(payloadConfigPath, 'utf-8');
103
99
  // Check payload.config.ts
104
100
  expect(content).not.toContain('// database-adapter-import');
105
101
  expect(content).toContain(dbReplacement.importReplacement);
106
102
  expect(content).not.toContain('// database-adapter-config-start');
107
103
  expect(content).not.toContain('// database-adapter-config-end');
108
- expect(content).toContain(dbReplacement.configReplacement.join('\n'));
104
+ expect(content).toContain(dbReplacement.configReplacement().join('\n'));
109
105
  });
110
106
  });
111
107
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport path from 'path'\nimport type { CliArgs, DbType, ProjectTemplate } from '../types.js'\nimport { createProject } from './create-project.js'\nimport { fileURLToPath } from 'node:url'\nimport { dbReplacements } from './packages.js'\nimport { getValidTemplates } from './templates.js'\nimport globby from 'globby'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nconst projectDir = path.resolve(dirname, './tmp')\ndescribe('createProject', () => {\n beforeAll(() => {\n console.log = jest.fn()\n })\n\n beforeEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmdirSync(projectDir, { recursive: true })\n }\n })\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n url: 'https://github.com/payloadcms/payload-plugin-template',\n description: 'Template for creating a Payload plugin',\n }\n await createProject({\n cliArgs: args,\n projectName,\n projectDir,\n template,\n packageManager,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toEqual(projectName)\n })\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank-3.0', 'mongodb'],\n ['blank-3.0', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n projectName,\n projectDir,\n template: template as ProjectTemplate,\n packageManager,\n dbDetails: {\n dbUri: `${db}://localhost:27017/create-project-test`,\n type: db as DbType,\n },\n })\n\n const dbReplacement = dbReplacements[db as DbType]\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n if (!payloadConfigPath) {\n throw new Error(`Could not find payload.config.ts inside ${projectDir}`)\n }\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts\n expect(content).not.toContain('// database-adapter-import')\n expect(content).toContain(dbReplacement.importReplacement)\n\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n expect(content).toContain(dbReplacement.configReplacement.join('\\n'))\n })\n })\n })\n})\n"],"names":["fse","path","createProject","fileURLToPath","dbReplacements","getValidTemplates","globby","filename","url","dirname","projectDir","resolve","describe","beforeAll","console","log","jest","fn","beforeEach","existsSync","rmdirSync","recursive","afterEach","rmSync","args","_","packageManager","it","projectName","template","name","type","description","cliArgs","packageJsonPath","packageJson","readJsonSync","expect","toEqual","templates","each","templateName","db","find","t","dbDetails","dbUri","dbReplacement","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","Error","content","readFileSync","not","toContain","importReplacement","configReplacement","join"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,UAAU,OAAM;AAEv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version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import { jest } from '@jest/globals'\nimport fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport * as os from 'node:os'\nimport path from 'path'\n\nimport type { CliArgs, DbType, ProjectTemplate } from '../types.js'\n\nimport { createProject } from './create-project.js'\nimport { dbReplacements } from './replacements.js'\nimport { getValidTemplates } from './templates.js'\n\ndescribe('createProject', () => {\n let projectDir: string\n beforeAll(() => {\n // eslint-disable-next-line no-console\n console.log = jest.fn()\n })\n\n beforeEach(() => {\n const tempDirectory = fs.realpathSync(os.tmpdir())\n projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`\n })\n\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload-plugin-template',\n }\n await createProject({\n cliArgs: args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n })\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank', 'mongodb'],\n ['blank', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n dbDetails: {\n type: db as DbType,\n dbUri: `${db}://localhost:27017/create-project-test`,\n },\n packageManager,\n projectDir,\n projectName,\n template: template as ProjectTemplate,\n })\n\n const dbReplacement = dbReplacements[db as DbType]\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Verify git was initialized\n expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts\n expect(content).not.toContain('// database-adapter-import')\n expect(content).toContain(dbReplacement.importReplacement)\n\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n expect(content).toContain(dbReplacement.configReplacement().join('\\n'))\n })\n })\n })\n})\n"],"names":["jest","fs","fse","globby","os","path","createProject","dbReplacements","getValidTemplates","describe","projectDir","beforeAll","console","log","fn","beforeEach","tempDirectory","realpathSync","tmpdir","Math","random","toString","substring","afterEach","existsSync","rmSync","recursive","args","_","packageManager","it","projectName","template","name","type","description","url","cliArgs","packageJsonPath","resolve","packageJson","readJsonSync","expect","toStrictEqual","templates","each","templateName","db","find","t","dbDetails","dbUri","dbReplacement","toBe","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","content","readFileSync","not","toContain","importReplacement","configReplacement","join"],"mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAe;AACpC,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,YAAYC,QAAQ,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,sBAAq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I,KAAKa;gBAElD,MAAMT,UAAU;oBACd,GAAGV,IAAI;oBACP,QAAQoB;oBACR,oBAAoBD;gBACtB;gBAEA,MAAMxC,cAAc;oBAClB+B;oBACAa,WAAW;wBACThB,MAAMa;wBACNI,OAAO,CAAC,EAAEJ,GAAG,sCAAsC,CAAC;oBACtD;oBACAlB;oBACAnB;oBACAqB;oBACAC,UAAUA;gBACZ;gBAEA,MAAMoB,gBAAgB7C,cAAc,CAACwC,GAAa;gBAElD,MAAMT,kBAAkBjC,KAAKkC,OAAO,CAAC7B,YAAY;gBACjD,MAAM8B,cAActC,IAAIuC,YAAY,CAACH;gBAErC,6BAA6B;gBAC7BI,OAAOxC,IAAIsB,UAAU,CAACnB,KAAKkC,OAAO,CAAC7B,YAAY,UAAU2C,IAAI,CAAC;gBAE9D,kCAAkC;gBAClCX,OACEY,OAAOC,IAAI,CAACf,YAAYgB,YAAY,EAAEC,MAAM,CAAC,CAACC,IAAMA,EAAEC,UAAU,CAAC,qBACjEC,YAAY,CAAC;gBAEf,MAAMC,oBACJ,CAAA,MAAM1D,OAAO,wBAAwB;oBACnC2D,UAAU;oBACVC,KAAKrD;gBACP,EAAC,GACA,CAAC,EAAE;gBAEN,MAAMsD,UAAU9D,IAAI+D,YAAY,CAACJ,mBAAmB;gBAEpD,0BAA0B;gBAC1BnB,OAAOsB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9BzB,OAAOsB,SAASG,SAAS,CAACf,cAAcgB,iBAAiB;gBAEzD1B,OAAOsB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9BzB,OAAOsB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9BzB,OAAOsB,SAASG,SAAS,CAACf,cAAciB,iBAAiB,GAAGC,IAAI,CAAC;YACnE;QACF;IACF;AACF"}
@@ -0,0 +1,7 @@
1
+ import type { ProjectTemplate } from '../types.js';
2
+ export declare function downloadTemplate({ debug, projectDir, template, }: {
3
+ debug?: boolean;
4
+ projectDir: string;
5
+ template: ProjectTemplate;
6
+ }): Promise<void>;
7
+ //# sourceMappingURL=download-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download-template.d.ts","sourceRoot":"","sources":["../../src/lib/download-template.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAsB,gBAAgB,CAAC,EACrC,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,eAAe,CAAA;CAC1B,iBAmBA"}
@@ -0,0 +1,28 @@
1
+ import { Readable } from 'node:stream';
2
+ import { pipeline } from 'node:stream/promises';
3
+ import { x } from 'tar';
4
+ import { debug as debugLog } from '../utils/log.js';
5
+ export async function downloadTemplate({ debug, projectDir, template }) {
6
+ const branchOrTag = template.url.split('#')?.[1] || 'beta';
7
+ const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`;
8
+ const filter = `payload-${branchOrTag.replace(/^v/, '')}/templates/${template.name}/`;
9
+ if (debug) {
10
+ debugLog(`Using template url: ${template.url}`);
11
+ debugLog(`Codeload url: ${url}`);
12
+ debugLog(`Filter: ${filter}`);
13
+ }
14
+ await pipeline(await downloadTarStream(url), x({
15
+ cwd: projectDir,
16
+ filter: (p)=>p.includes(filter),
17
+ strip: 2 + template.name.split('/').length
18
+ }));
19
+ }
20
+ async function downloadTarStream(url) {
21
+ const res = await fetch(url);
22
+ if (!res.body) {
23
+ throw new Error(`Failed to download: ${url}`);
24
+ }
25
+ return Readable.from(res.body);
26
+ }
27
+
28
+ //# sourceMappingURL=download-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/download-template.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectTemplate } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadTemplate({\n debug,\n projectDir,\n template,\n}: {\n debug?: boolean\n projectDir: string\n template: ProjectTemplate\n}) {\n const branchOrTag = template.url.split('#')?.[1] || 'beta'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '')}/templates/${template.name}/`\n\n if (debug) {\n debugLog(`Using template url: ${template.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + template.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body as unknown as NodeJS.ReadableStream)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadTemplate","projectDir","template","branchOrTag","url","split","filter","replace","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,iBAAiB,EACrCF,KAAK,EACLG,UAAU,EACVC,QAAQ,EAKT;IACC,MAAMC,cAAcD,SAASE,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACpD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,YAAY,CAAC;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAI,WAAW,EAAEL,SAASM,IAAI,CAAC,CAAC,CAAC;IAErF,IAAIV,OAAO;QACTC,SAAS,CAAC,oBAAoB,EAAEG,SAASE,GAAG,CAAC,CAAC;QAC9CL,SAAS,CAAC,cAAc,EAAEK,IAAI,CAAC;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,OAAO,CAAC;IAC9B;IAEA,MAAMV,SACJ,MAAMa,kBAAkBL,MACxBP,EAAE;QACAa,KAAKT;QACLK,QAAQ,CAACK,IAAMA,EAAEC,QAAQ,CAACN;QAC1BO,OAAO,IAAIX,SAASM,IAAI,CAACH,KAAK,CAAC,KAAKS,MAAM;IAC5C;AAEJ;AAEA,eAAeL,kBAAkBL,GAAW;IAC1C,MAAMW,MAAM,MAAMC,MAAMZ;IAExB,IAAI,CAACW,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEd,IAAI,CAAC;IAC9C;IAEA,OAAOT,SAASwB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/generate-secret.ts"],"sourcesContent":["import { randomBytes } from 'crypto'\n\nexport function generateSecret(): string {\n return randomBytes(32).toString('hex').slice(0, 24)\n}\n"],"names":["randomBytes","generateSecret","toString","slice"],"rangeMappings":";;;","mappings":"AAAA,SAASA,WAAW,QAAQ,SAAQ;AAEpC,OAAO,SAASC;IACd,OAAOD,YAAY,IAAIE,QAAQ,CAAC,OAAOC,KAAK,CAAC,GAAG;AAClD"}
1
+ {"version":3,"sources":["../../src/lib/generate-secret.ts"],"sourcesContent":["import { randomBytes } from 'crypto'\n\nexport function generateSecret(): string {\n return randomBytes(32).toString('hex').slice(0, 24)\n}\n"],"names":["randomBytes","generateSecret","toString","slice"],"mappings":"AAAA,SAASA,WAAW,QAAQ,SAAQ;AAEpC,OAAO,SAASC;IACd,OAAOD,YAAY,IAAIE,QAAQ,CAAC,OAAOC,KAAK,CAAC,GAAG;AAClD"}
@@ -0,0 +1,6 @@
1
+ import type { CliArgs, PackageManager } from '../types.js';
2
+ export declare function getPackageManager(args: {
3
+ cliArgs?: CliArgs;
4
+ projectDir: string;
5
+ }): Promise<PackageManager>;
6
+ //# sourceMappingURL=get-package-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-package-manager.d.ts","sourceRoot":"","sources":["../../src/lib/get-package-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE1D,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,cAAc,CAAC,CA0B1B"}