create-payload-app 1.0.0-beta.0 → 3.0.0-alpha.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +3 -3
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/configure-payload-config.d.ts +11 -0
  7. package/dist/lib/configure-payload-config.d.ts.map +1 -0
  8. package/dist/lib/configure-payload-config.js +15 -53
  9. package/dist/lib/configure-payload-config.js.map +1 -0
  10. package/dist/lib/create-project.d.ts +14 -0
  11. package/dist/lib/create-project.d.ts.map +1 -0
  12. package/dist/lib/create-project.js +84 -24
  13. package/dist/lib/create-project.js.map +1 -0
  14. package/dist/lib/create-project.spec.d.ts +2 -0
  15. package/dist/lib/create-project.spec.d.ts.map +1 -0
  16. package/dist/lib/create-project.spec.js +30 -75
  17. package/dist/lib/create-project.spec.js.map +1 -0
  18. package/dist/lib/generate-secret.d.ts +2 -0
  19. package/dist/lib/generate-secret.d.ts.map +1 -0
  20. package/dist/lib/generate-secret.js +1 -1
  21. package/dist/lib/generate-secret.js.map +1 -0
  22. package/dist/lib/init-next.d.ts +29 -0
  23. package/dist/lib/init-next.d.ts.map +1 -0
  24. package/dist/lib/init-next.js +285 -0
  25. package/dist/lib/init-next.js.map +1 -0
  26. package/dist/lib/packages.d.ts +9 -0
  27. package/dist/lib/packages.d.ts.map +1 -0
  28. package/dist/lib/packages.js +8 -52
  29. package/dist/lib/packages.js.map +1 -0
  30. package/dist/lib/parse-project-name.d.ts +3 -0
  31. package/dist/lib/parse-project-name.d.ts.map +1 -0
  32. package/dist/lib/parse-project-name.js +53 -12
  33. package/dist/lib/parse-project-name.js.map +1 -0
  34. package/dist/lib/parse-template.d.ts +3 -0
  35. package/dist/lib/parse-template.d.ts.map +1 -0
  36. package/dist/lib/parse-template.js +50 -20
  37. package/dist/lib/parse-template.js.map +1 -0
  38. package/dist/lib/select-db.d.ts +3 -0
  39. package/dist/lib/select-db.d.ts.map +1 -0
  40. package/dist/lib/select-db.js +72 -31
  41. package/dist/lib/select-db.js.map +1 -0
  42. package/dist/lib/templates.d.ts +4 -0
  43. package/dist/lib/templates.d.ts.map +1 -0
  44. package/dist/lib/templates.js +17 -11
  45. package/dist/lib/templates.js.map +1 -0
  46. package/dist/lib/wrap-next-config.d.ts +12 -0
  47. package/dist/lib/wrap-next-config.d.ts.map +1 -0
  48. package/dist/lib/wrap-next-config.js +110 -0
  49. package/dist/lib/wrap-next-config.js.map +1 -0
  50. package/dist/lib/wrap-next-config.spec.d.ts +2 -0
  51. package/dist/lib/wrap-next-config.spec.d.ts.map +1 -0
  52. package/dist/lib/wrap-next-config.spec.js +98 -0
  53. package/dist/lib/wrap-next-config.spec.js.map +1 -0
  54. package/dist/lib/write-env-file.d.ts +10 -0
  55. package/dist/lib/write-env-file.d.ts.map +1 -0
  56. package/dist/lib/write-env-file.js +9 -6
  57. package/dist/lib/write-env-file.js.map +1 -0
  58. package/dist/main.d.ts +7 -0
  59. package/dist/main.d.ts.map +1 -0
  60. package/dist/main.js +176 -60
  61. package/dist/main.js.map +1 -0
  62. package/dist/scripts/pack-template-files.d.ts +2 -0
  63. package/dist/scripts/pack-template-files.d.ts.map +1 -0
  64. package/dist/scripts/pack-template-files.js +43 -0
  65. package/dist/scripts/pack-template-files.js.map +1 -0
  66. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +17 -0
  67. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +9 -0
  68. package/dist/template/src/app/(payload)/api/graphql/route.ts +6 -0
  69. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +6 -0
  70. package/dist/template/src/app/(payload)/custom.scss +0 -0
  71. package/dist/template/src/app/(payload)/layout.tsx +16 -0
  72. package/dist/template/src/app/my-route/route.ts +14 -0
  73. package/dist/template/src/collections/Users.ts +13 -0
  74. package/dist/template/src/payload.config.ts +38 -0
  75. package/dist/types.d.ts +55 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +1 -1
  78. package/dist/types.js.map +1 -0
  79. package/dist/utils/copy-recursive-sync.d.ts +5 -0
  80. package/dist/utils/copy-recursive-sync.d.ts.map +1 -0
  81. package/dist/utils/copy-recursive-sync.js +34 -0
  82. package/dist/utils/copy-recursive-sync.js.map +1 -0
  83. package/dist/utils/log.d.ts +6 -0
  84. package/dist/utils/log.d.ts.map +1 -0
  85. package/dist/utils/log.js +62 -15
  86. package/dist/utils/log.js.map +1 -0
  87. package/dist/utils/messages.d.ts +11 -0
  88. package/dist/utils/messages.d.ts.map +1 -0
  89. package/dist/utils/messages.js +47 -16
  90. package/dist/utils/messages.js.map +1 -0
  91. package/package.json +27 -10
@@ -8,11 +8,47 @@ Object.defineProperty(exports, "parseTemplate", {
8
8
  return parseTemplate;
9
9
  }
10
10
  });
11
- const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
11
+ const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
12
+ function _getRequireWildcardCache(nodeInterop) {
13
+ if (typeof WeakMap !== "function") return null;
14
+ var cacheBabelInterop = new WeakMap();
15
+ var cacheNodeInterop = new WeakMap();
16
+ return (_getRequireWildcardCache = function(nodeInterop) {
17
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
+ })(nodeInterop);
19
+ }
20
+ function _interop_require_wildcard(obj, nodeInterop) {
21
+ if (!nodeInterop && obj && obj.__esModule) {
22
+ return obj;
23
+ }
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
+ return {
26
+ default: obj
27
+ };
28
+ }
29
+ var cache = _getRequireWildcardCache(nodeInterop);
30
+ if (cache && cache.has(obj)) {
31
+ return cache.get(obj);
32
+ }
33
+ var newObj = {
34
+ __proto__: null
15
35
  };
36
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
+ for(var key in obj){
38
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
+ if (desc && (desc.get || desc.set)) {
41
+ Object.defineProperty(newObj, key, desc);
42
+ } else {
43
+ newObj[key] = obj[key];
44
+ }
45
+ }
46
+ }
47
+ newObj.default = obj;
48
+ if (cache) {
49
+ cache.set(obj, newObj);
50
+ }
51
+ return newObj;
16
52
  }
17
53
  async function parseTemplate(args, validTemplates) {
18
54
  if (args['--template']) {
@@ -21,26 +57,20 @@ async function parseTemplate(args, validTemplates) {
21
57
  if (!template) throw new Error('Invalid template given');
22
58
  return template;
23
59
  }
24
- const response = await (0, _prompts.default)({
25
- name: 'value',
26
- choices: validTemplates.map((p)=>{
60
+ const response = await _prompts.select({
61
+ message: 'Choose project template',
62
+ options: validTemplates.map((p)=>{
27
63
  return {
28
- description: p.description,
29
- title: p.name,
64
+ label: p.name,
30
65
  value: p.name
31
66
  };
32
- }),
33
- message: 'Choose project template',
34
- type: 'select',
35
- validate: (value)=>!!value.length
36
- }, {
37
- onCancel: ()=>{
38
- process.exit(0);
39
- }
67
+ })
40
68
  });
41
- const template = validTemplates.find((t)=>t.name === response.value);
42
- if (!template) throw new Error('Template is undefined');
69
+ if (_prompts.isCancel(response)) {
70
+ process.exit(0);
71
+ }
72
+ const template = validTemplates.find((t)=>t.name === response);
43
73
  return template;
44
74
  }
45
75
 
46
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcGFyc2UtdGVtcGxhdGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHByb21wdHMgZnJvbSAncHJvbXB0cydcblxuaW1wb3J0IHR5cGUgeyBDbGlBcmdzLCBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHBhcnNlVGVtcGxhdGUo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UFDQVUsU0FBUztRQUNUQyxNQUFNO1FBQ05DLFVBQVUsQ0FBQ0gsUUFBa0IsQ0FBQyxDQUFDQSxNQUFNSSxNQUFNO0lBQzdDLEdBQ0E7UUFDRUMsVUFBVTtZQUNSQyxRQUFRQyxJQUFJLENBQUM7UUFDZjtJQUNGO0lBR0YsTUFBTW5CLFdBQVdGLGVBQWVHLElBQUksQ0FBQyxDQUFDQyxJQUFNQSxFQUFFQyxJQUFJLEtBQUtFLFNBQVNPLEtBQUs7SUFDckUsSUFBSSxDQUFDWixVQUFVLE1BQU0sSUFBSUksTUFBTTtJQUUvQixPQUFPSjtBQUNUIn0=
76
+ //# sourceMappingURL=parse-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/parse-template.ts"],"sourcesContent":["import * as p from '@clack/prompts'\n\nimport type { CliArgs, ProjectTemplate } from '../types.js'\n\nexport async function parseTemplate(\n args: CliArgs,\n validTemplates: ProjectTemplate[],\n): Promise<ProjectTemplate | undefined> {\n if (args['--template']) {\n const templateName = args['--template']\n const template = validTemplates.find((t) => t.name === templateName)\n if (!template) throw new Error('Invalid template given')\n return template\n }\n\n const response = await p.select<{ label: string; value: string }[], string>({\n message: 'Choose project template',\n options: validTemplates.map((p) => {\n return {\n label: p.name,\n value: p.name,\n }\n }),\n })\n if (p.isCancel(response)) {\n process.exit(0)\n }\n\n const template = validTemplates.find((t) => t.name === response)\n\n return template\n}\n"],"names":["parseTemplate","args","validTemplates","templateName","template","find","t","name","Error","response","p","select","message","options","map","label","value","isCancel","process","exit"],"mappings":";;;;+BAIsBA;;;eAAAA;;;iEAJH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIZ,eAAeA,cACpBC,IAAa,EACbC,cAAiC;IAEjC,IAAID,IAAI,CAAC,aAAa,EAAE;QACtB,MAAME,eAAeF,IAAI,CAAC,aAAa;QACvC,MAAMG,WAAWF,eAAeG,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ;QACvD,IAAI,CAACC,UAAU,MAAM,IAAII,MAAM;QAC/B,OAAOJ;IACT;IAEA,MAAMK,WAAW,MAAMC,SAAEC,MAAM,CAA6C;QAC1EC,SAAS;QACTC,SAASX,eAAeY,GAAG,CAAC,CAACJ;YAC3B,OAAO;gBACLK,OAAOL,EAAEH,IAAI;gBACbS,OAAON,EAAEH,IAAI;YACf;QACF;IACF;IACA,IAAIG,SAAEO,QAAQ,CAACR,WAAW;QACxBS,QAAQC,IAAI,CAAC;IACf;IAEA,MAAMf,WAAWF,eAAeG,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKE;IAEvD,OAAOL;AACT"}
@@ -0,0 +1,3 @@
1
+ import type { CliArgs, DbDetails } from '../types.js';
2
+ export declare function selectDb(args: CliArgs, projectName: string): Promise<DbDetails>;
3
+ //# sourceMappingURL=select-db.d.ts.map
@@ -0,0 +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"}
@@ -8,13 +8,54 @@ Object.defineProperty(exports, "selectDb", {
8
8
  return selectDb;
9
9
  }
10
10
  });
11
+ const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
11
12
  const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify"));
12
- const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts"));
13
13
  function _interop_require_default(obj) {
14
14
  return obj && obj.__esModule ? obj : {
15
15
  default: obj
16
16
  };
17
17
  }
18
+ function _getRequireWildcardCache(nodeInterop) {
19
+ if (typeof WeakMap !== "function") return null;
20
+ var cacheBabelInterop = new WeakMap();
21
+ var cacheNodeInterop = new WeakMap();
22
+ return (_getRequireWildcardCache = function(nodeInterop) {
23
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
24
+ })(nodeInterop);
25
+ }
26
+ function _interop_require_wildcard(obj, nodeInterop) {
27
+ if (!nodeInterop && obj && obj.__esModule) {
28
+ return obj;
29
+ }
30
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
31
+ return {
32
+ default: obj
33
+ };
34
+ }
35
+ var cache = _getRequireWildcardCache(nodeInterop);
36
+ if (cache && cache.has(obj)) {
37
+ return cache.get(obj);
38
+ }
39
+ var newObj = {
40
+ __proto__: null
41
+ };
42
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
+ for(var key in obj){
44
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
+ if (desc && (desc.get || desc.set)) {
47
+ Object.defineProperty(newObj, key, desc);
48
+ } else {
49
+ newObj[key] = obj[key];
50
+ }
51
+ }
52
+ }
53
+ newObj.default = obj;
54
+ if (cache) {
55
+ cache.set(obj, newObj);
56
+ }
57
+ return newObj;
58
+ }
18
59
  const dbChoiceRecord = {
19
60
  mongodb: {
20
61
  dbConnectionPrefix: 'mongodb://127.0.0.1/',
@@ -35,43 +76,43 @@ async function selectDb(args, projectName) {
35
76
  }
36
77
  dbType = args['--db'];
37
78
  } else {
38
- const dbTypeRes = await (0, _prompts.default)({
39
- name: 'value',
40
- choices: Object.values(dbChoiceRecord).map((dbChoice)=>{
41
- return {
42
- title: dbChoice.title,
43
- value: dbChoice.value
44
- };
45
- }),
46
- message: 'Select a database',
47
- type: 'select',
48
- validate: (value)=>!!value.length
49
- }, {
50
- onCancel: ()=>{
51
- process.exit(0);
52
- }
79
+ dbType = await _prompts.select({
80
+ initialValue: 'mongodb',
81
+ message: `Select a database`,
82
+ options: [
83
+ {
84
+ label: 'MongoDB',
85
+ value: 'mongodb'
86
+ },
87
+ {
88
+ label: 'Postgres',
89
+ value: 'postgres'
90
+ }
91
+ ]
53
92
  });
54
- dbType = dbTypeRes.value;
93
+ if (_prompts.isCancel(dbType)) process.exit(0);
55
94
  }
56
95
  const dbChoice = dbChoiceRecord[dbType];
57
- const dbUriRes = await (0, _prompts.default)({
58
- name: 'value',
59
- initial: `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : (0, _slugify.default)(projectName)}`,
60
- message: `Enter ${dbChoice.title.split(' ')[0]} connection string`,
61
- type: 'text',
62
- validate: (value)=>!!value.length
63
- }, {
64
- onCancel: ()=>{
65
- process.exit(0);
66
- }
67
- });
96
+ let dbUri = undefined;
97
+ const initialDbUri = `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : (0, _slugify.default)(projectName)}`;
98
+ if (args['--db-accept-recommended']) {
99
+ dbUri = initialDbUri;
100
+ } else if (args['--db-connection-string']) {
101
+ dbUri = args['--db-connection-string'];
102
+ } else {
103
+ dbUri = await _prompts.text({
104
+ initialValue: initialDbUri,
105
+ message: `Enter ${dbChoice.title.split(' ')[0]} connection string`
106
+ });
107
+ if (_prompts.isCancel(dbUri)) process.exit(0);
108
+ }
68
109
  return {
69
- dbUri: dbUriRes.value,
70
- type: dbChoice.value
110
+ type: dbChoice.value,
111
+ dbUri
71
112
  };
72
113
  }
73
114
  function getRandomDigitSuffix() {
74
115
  return (Math.random() * Math.pow(10, 6)).toFixed(0);
75
116
  }
76
117
 
77
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvc2VsZWN0LWRiLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzbHVnaWZ5IGZyb20gJ0BzaW5kcmVzb3JodXMvc2x1Z2lmeSdcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgQ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EVBQUMsRUFBR0MsT0FBTyxDQUFDO0FBQ25EIn0=
118
+ //# sourceMappingURL=select-db.js.map
@@ -0,0 +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://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":["selectDb","dbChoiceRecord","mongodb","dbConnectionPrefix","title","value","postgres","args","projectName","dbType","undefined","Object","values","some","dbChoice","Error","map","join","p","select","initialValue","message","options","label","isCancel","process","exit","dbUri","initialDbUri","getRandomDigitSuffix","slugify","text","split","type","Math","random","pow","toFixed"],"mappings":";;;;+BAwBsBA;;;eAAAA;;;iEAxBH;gEACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUpB,MAAMC,iBAA2C;IAC/CC,SAAS;QACPC,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;IACAC,UAAU;QACRH,oBAAoB;QACpBC,OAAO;QACPC,OAAO;IACT;AACF;AAEO,eAAeL,SAASO,IAAa,EAAEC,WAAmB;IAC/D,IAAIC,SAAsCC;IAC1C,IAAIH,IAAI,CAAC,OAAO,EAAE;QAChB,IAAI,CAACI,OAAOC,MAAM,CAACX,gBAAgBY,IAAI,CAAC,CAACC,WAAaA,SAAST,KAAK,KAAKE,IAAI,CAAC,OAAO,GAAG;YACtF,MAAM,IAAIQ,MACR,CAAC,8CAA8C,EAAEJ,OAAOC,MAAM,CAACX,gBAC5De,GAAG,CAAC,CAACF,WAAaA,SAAST,KAAK,EAChCY,IAAI,CAAC,MAAM,CAAC;QAEnB;QACAR,SAASF,IAAI,CAAC,OAAO;IACvB,OAAO;QACLE,SAAS,MAAMS,SAAEC,MAAM,CAA6C;YAClEC,cAAc;YACdC,SAAS,CAAC,iBAAiB,CAAC;YAC5BC,SAAS;gBACP;oBAAEC,OAAO;oBAAWlB,OAAO;gBAAU;gBACrC;oBAAEkB,OAAO;oBAAYlB,OAAO;gBAAW;aACxC;QACH;QACA,IAAIa,SAAEM,QAAQ,CAACf,SAASgB,QAAQC,IAAI,CAAC;IACvC;IAEA,MAAMZ,WAAWb,cAAc,CAACQ,OAAO;IAEvC,IAAIkB,QAAqCjB;IACzC,MAAMkB,eAAe,CAAC,EAAEd,SAASX,kBAAkB,CAAC,EAClDK,gBAAgB,MAAM,CAAC,QAAQ,EAAEqB,uBAAuB,CAAC,GAAGC,IAAAA,gBAAO,EAACtB,aACrE,CAAC;IAEF,IAAID,IAAI,CAAC,0BAA0B,EAAE;QACnCoB,QAAQC;IACV,OAAO,IAAIrB,IAAI,CAAC,yBAAyB,EAAE;QACzCoB,QAAQpB,IAAI,CAAC,yBAAyB;IACxC,OAAO;QACLoB,QAAQ,MAAMT,SAAEa,IAAI,CAAC;YACnBX,cAAcQ;YACdP,SAAS,CAAC,MAAM,EAAEP,SAASV,KAAK,CAAC4B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC;QACpE;QACA,IAAId,SAAEM,QAAQ,CAACG,QAAQF,QAAQC,IAAI,CAAC;IACtC;IAEA,OAAO;QACLO,MAAMnB,SAAST,KAAK;QACpBsB;IACF;AACF;AAEA,SAASE;IACP,OAAO,AAACK,CAAAA,KAAKC,MAAM,KAAKD,KAAKE,GAAG,CAAC,IAAI,EAAC,EAAGC,OAAO,CAAC;AACnD"}
@@ -0,0 +1,4 @@
1
+ import type { ProjectTemplate } from '../types.js';
2
+ export declare function validateTemplate(templateName: string): boolean;
3
+ export declare function getValidTemplates(): ProjectTemplate[];
4
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +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,CA6CrD"}
@@ -9,14 +9,14 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- validateTemplate: function() {
13
- return validateTemplate;
14
- },
15
12
  getValidTemplates: function() {
16
13
  return getValidTemplates;
14
+ },
15
+ validateTemplate: function() {
16
+ return validateTemplate;
17
17
  }
18
18
  });
19
- const _log = require("../utils/log");
19
+ const _log = require("../utils/log.js");
20
20
  function validateTemplate(templateName) {
21
21
  const validTemplates = getValidTemplates();
22
22
  if (!validTemplates.map((t)=>t.name).includes(templateName)) {
@@ -28,43 +28,49 @@ function validateTemplate(templateName) {
28
28
  }
29
29
  function getValidTemplates() {
30
30
  return [
31
+ {
32
+ name: 'blank-3.0',
33
+ type: 'starter',
34
+ description: 'Blank 3.0 Template',
35
+ url: 'https://github.com/payloadcms/payload/templates/blank-3.0'
36
+ },
31
37
  {
32
38
  name: 'blank',
33
- description: 'Blank Template',
34
39
  type: 'starter',
40
+ description: 'Blank Template',
35
41
  url: 'https://github.com/payloadcms/payload/templates/blank'
36
42
  },
37
43
  {
38
44
  name: 'website',
39
- description: 'Website Template',
40
45
  type: 'starter',
46
+ description: 'Website Template',
41
47
  url: 'https://github.com/payloadcms/payload/templates/website'
42
48
  },
43
49
  {
44
50
  name: 'ecommerce',
45
- description: 'E-commerce Template',
46
51
  type: 'starter',
52
+ description: 'E-commerce Template',
47
53
  url: 'https://github.com/payloadcms/payload/templates/ecommerce'
48
54
  },
49
55
  {
50
56
  name: 'plugin',
51
- description: 'Template for creating a Payload plugin',
52
57
  type: 'plugin',
58
+ description: 'Template for creating a Payload plugin',
53
59
  url: 'https://github.com/payloadcms/payload-plugin-template'
54
60
  },
55
61
  {
56
62
  name: 'payload-demo',
57
- description: 'Payload demo site at https://demo.payloadcms.com',
58
63
  type: 'starter',
64
+ description: 'Payload demo site at https://demo.payloadcms.com',
59
65
  url: 'https://github.com/payloadcms/public-demo'
60
66
  },
61
67
  {
62
68
  name: 'payload-website',
63
- description: 'Payload website CMS at https://payloadcms.com',
64
69
  type: 'starter',
70
+ description: 'Payload website CMS at https://payloadcms.com',
65
71
  url: 'https://github.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FDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtRQUNBO1lBQ0VQLE1BQU07WUFDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtRQUNBO1lBQ0VQLE1BQU07WUFDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtRQUNBO1lBQ0VQLE1BQU07WUFDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtRQUNBO1lBQ0VQLE1BQU07WUFDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtLQUNEO0FBQ0gifQ==
76
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +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',\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',\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":["getValidTemplates","validateTemplate","templateName","validTemplates","map","t","name","includes","error","info","join","type","description","url"],"mappings":";;;;;;;;;;;IAcgBA,iBAAiB;eAAjBA;;IAVAC,gBAAgB;eAAhBA;;;qBAFY;AAErB,SAASA,iBAAiBC,YAAoB;IACnD,MAAMC,iBAAiBH;IACvB,IAAI,CAACG,eAAeC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACL,eAAe;QAC7DM,IAAAA,UAAK,EAAC,CAAC,CAAC,EAAEN,aAAa,0BAA0B,CAAC;QAClDO,IAAAA,SAAI,EAAC,CAAC,iBAAiB,EAAEN,eAAeC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEI,IAAI,CAAC,MAAM,CAAC;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEO,SAASV;IACd,OAAO;QACL;YACEM,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEP,MAAM;YACNK,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KACD;AACH"}
@@ -0,0 +1,12 @@
1
+ export declare const withPayloadImportStatement = "import { withPayload } from '@payloadcms/next'\n";
2
+ export declare const wrapNextConfig: (args: {
3
+ nextConfigPath: string;
4
+ }) => void;
5
+ /**
6
+ * Parses config content with AST and wraps it with withPayload function
7
+ */
8
+ export declare function parseAndModifyConfigContent(content: string): {
9
+ modifiedConfigContent: string;
10
+ success: boolean;
11
+ };
12
+ //# sourceMappingURL=wrap-next-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,0BAA0B,qDAAqD,CAAA;AAE5F,eAAO,MAAM,cAAc,SAAU;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,SAU9D,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG;IAC5D,qBAAqB,EAAE,MAAM,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;CACjB,CAgDA"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ parseAndModifyConfigContent: function() {
13
+ return parseAndModifyConfigContent;
14
+ },
15
+ withPayloadImportStatement: function() {
16
+ return withPayloadImportStatement;
17
+ },
18
+ wrapNextConfig: function() {
19
+ return wrapNextConfig;
20
+ }
21
+ });
22
+ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
23
+ const _esprima = require("esprima");
24
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
25
+ const _log = require("../utils/log.js");
26
+ function _interop_require_default(obj) {
27
+ return obj && obj.__esModule ? obj : {
28
+ default: obj
29
+ };
30
+ }
31
+ const withPayloadImportStatement = `import { withPayload } from '@payloadcms/next'\n`;
32
+ const wrapNextConfig = (args)=>{
33
+ const { nextConfigPath } = args;
34
+ const configContent = _fs.default.readFileSync(nextConfigPath, 'utf8');
35
+ const { modifiedConfigContent: newConfig, success } = parseAndModifyConfigContent(configContent);
36
+ if (!success) {
37
+ return;
38
+ }
39
+ _fs.default.writeFileSync(nextConfigPath, newConfig);
40
+ };
41
+ function parseAndModifyConfigContent(content) {
42
+ content = withPayloadImportStatement + content;
43
+ const ast = (0, _esprima.parseModule)(content, {
44
+ loc: true
45
+ });
46
+ const exportDefaultDeclaration = ast.body.find((p)=>p.type === 'ExportDefaultDeclaration');
47
+ const exportNamedDeclaration = ast.body.find((p)=>p.type === 'ExportNamedDeclaration');
48
+ if (!exportDefaultDeclaration && !exportNamedDeclaration) {
49
+ throw new Error('Could not find ExportDefaultDeclaration in next.config.js');
50
+ }
51
+ if (exportDefaultDeclaration && exportDefaultDeclaration.declaration?.loc) {
52
+ const modifiedConfigContent = insertBeforeAndAfter(content, exportDefaultDeclaration.declaration.loc);
53
+ return {
54
+ modifiedConfigContent,
55
+ success: true
56
+ };
57
+ } else if (exportNamedDeclaration) {
58
+ const exportSpecifier = exportNamedDeclaration.specifiers.find((s)=>s.type === 'ExportSpecifier' && s.exported?.name === 'default' && s.local?.type === 'Identifier' && s.local?.name);
59
+ if (exportSpecifier) {
60
+ (0, _log.warning)('Could not automatically wrap next.config.js with withPayload.');
61
+ (0, _log.warning)('Automatic wrapping of named exports as default not supported yet.');
62
+ warnUserWrapNotSuccessful();
63
+ return {
64
+ modifiedConfigContent: content,
65
+ success: false
66
+ };
67
+ }
68
+ }
69
+ (0, _log.warning)('Could not automatically wrap next.config.js with withPayload.');
70
+ warnUserWrapNotSuccessful();
71
+ return {
72
+ modifiedConfigContent: content,
73
+ success: false
74
+ };
75
+ }
76
+ function warnUserWrapNotSuccessful() {
77
+ // Output directions for user to update next.config.js
78
+ const withPayloadMessage = `
79
+
80
+ ${_chalk.default.bold(`Please manually wrap your existing next.config.js with the withPayload function. Here is an example:`)}
81
+
82
+ import withPayload from '@payloadcms/next/withPayload'
83
+
84
+ const nextConfig = {
85
+ // Your Next.js config here
86
+ }
87
+
88
+ export default withPayload(nextConfig)
89
+
90
+ `;
91
+ (0, _log.log)(withPayloadMessage);
92
+ }
93
+ function insertBeforeAndAfter(content, loc) {
94
+ const { end, start } = loc;
95
+ const lines = content.split('\n');
96
+ const insert = (line, column, text)=>{
97
+ return line.slice(0, column) + text + line.slice(column);
98
+ };
99
+ // insert ) after end
100
+ lines[end.line - 1] = insert(lines[end.line - 1], end.column, ')');
101
+ // insert withPayload before start
102
+ if (start.line === end.line) {
103
+ lines[end.line - 1] = insert(lines[end.line - 1], start.column, 'withPayload(');
104
+ } else {
105
+ lines[start.line - 1] = insert(lines[start.line - 1], start.column, 'withPayload(');
106
+ }
107
+ return lines.join('\n');
108
+ }
109
+
110
+ //# sourceMappingURL=wrap-next-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/wrap-next-config.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { parseModule } from 'esprima'\nimport fs from 'fs'\n\nimport { warning } from '../utils/log.js'\nimport { log } from '../utils/log.js'\n\nexport const withPayloadImportStatement = `import { withPayload } from '@payloadcms/next'\\n`\n\nexport const wrapNextConfig = (args: { nextConfigPath: string }) => {\n const { nextConfigPath } = args\n const configContent = fs.readFileSync(nextConfigPath, 'utf8')\n const { modifiedConfigContent: newConfig, success } = parseAndModifyConfigContent(configContent)\n\n if (!success) {\n return\n }\n\n fs.writeFileSync(nextConfigPath, newConfig)\n}\n\n/**\n * Parses config content with AST and wraps it with withPayload function\n */\nexport function parseAndModifyConfigContent(content: string): {\n modifiedConfigContent: string\n success: boolean\n} {\n content = withPayloadImportStatement + content\n const ast = parseModule(content, { loc: true })\n const exportDefaultDeclaration = ast.body.find((p) => p.type === 'ExportDefaultDeclaration') as\n | Directive\n | undefined\n\n const exportNamedDeclaration = ast.body.find((p) => p.type === 'ExportNamedDeclaration') as\n | ExportNamedDeclaration\n | undefined\n\n if (!exportDefaultDeclaration && !exportNamedDeclaration) {\n throw new Error('Could not find ExportDefaultDeclaration in next.config.js')\n }\n\n if (exportDefaultDeclaration && exportDefaultDeclaration.declaration?.loc) {\n const modifiedConfigContent = insertBeforeAndAfter(\n content,\n exportDefaultDeclaration.declaration.loc,\n )\n return { modifiedConfigContent, success: true }\n } else if (exportNamedDeclaration) {\n const exportSpecifier = exportNamedDeclaration.specifiers.find(\n (s) =>\n s.type === 'ExportSpecifier' &&\n s.exported?.name === 'default' &&\n s.local?.type === 'Identifier' &&\n s.local?.name,\n )\n\n if (exportSpecifier) {\n warning('Could not automatically wrap next.config.js with withPayload.')\n warning('Automatic wrapping of named exports as default not supported yet.')\n\n warnUserWrapNotSuccessful()\n return {\n modifiedConfigContent: content,\n success: false,\n }\n }\n }\n\n warning('Could not automatically wrap next.config.js with withPayload.')\n warnUserWrapNotSuccessful()\n return {\n modifiedConfigContent: content,\n success: false,\n }\n}\n\nfunction warnUserWrapNotSuccessful() {\n // Output directions for user to update next.config.js\n const withPayloadMessage = `\n\n ${chalk.bold(`Please manually wrap your existing next.config.js with the withPayload function. Here is an example:`)}\n\n import withPayload from '@payloadcms/next/withPayload'\n\n const nextConfig = {\n // Your Next.js config here\n }\n\n export default withPayload(nextConfig)\n\n`\n\n log(withPayloadMessage)\n}\n\ntype Directive = {\n declaration?: {\n loc: Loc\n }\n}\n\ntype ExportNamedDeclaration = {\n declaration: null\n loc: Loc\n specifiers: {\n exported: {\n loc: Loc\n name: string\n type: string\n }\n loc: Loc\n local: {\n loc: Loc\n name: string\n type: string\n }\n type: string\n }[]\n type: string\n}\n\ntype Loc = {\n end: { column: number; line: number }\n start: { column: number; line: number }\n}\n\nfunction insertBeforeAndAfter(content: string, loc: Loc) {\n const { end, start } = loc\n const lines = content.split('\\n')\n\n const insert = (line: string, column: number, text: string) => {\n return line.slice(0, column) + text + line.slice(column)\n }\n\n // insert ) after end\n lines[end.line - 1] = insert(lines[end.line - 1], end.column, ')')\n // insert withPayload before start\n if (start.line === end.line) {\n lines[end.line - 1] = insert(lines[end.line - 1], start.column, 'withPayload(')\n } else {\n lines[start.line - 1] = insert(lines[start.line - 1], start.column, 'withPayload(')\n }\n\n return lines.join('\\n')\n}\n"],"names":["parseAndModifyConfigContent","withPayloadImportStatement","wrapNextConfig","args","nextConfigPath","configContent","fs","readFileSync","modifiedConfigContent","newConfig","success","writeFileSync","content","ast","parseModule","loc","exportDefaultDeclaration","body","find","p","type","exportNamedDeclaration","Error","declaration","insertBeforeAndAfter","exportSpecifier","specifiers","s","exported","name","local","warning","warnUserWrapNotSuccessful","withPayloadMessage","chalk","bold","log","end","start","lines","split","insert","line","column","text","slice","join"],"mappings":";;;;;;;;;;;IAwBgBA,2BAA2B;eAA3BA;;IAjBHC,0BAA0B;eAA1BA;;IAEAC,cAAc;eAAdA;;;8DATK;yBACU;2DACb;qBAES;;;;;;AAGjB,MAAMD,6BAA6B,CAAC,gDAAgD,CAAC;AAErF,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,cAAc,EAAE,GAAGD;IAC3B,MAAME,gBAAgBC,WAAE,CAACC,YAAY,CAACH,gBAAgB;IACtD,MAAM,EAAEI,uBAAuBC,SAAS,EAAEC,OAAO,EAAE,GAAGV,4BAA4BK;IAElF,IAAI,CAACK,SAAS;QACZ;IACF;IAEAJ,WAAE,CAACK,aAAa,CAACP,gBAAgBK;AACnC;AAKO,SAAST,4BAA4BY,OAAe;IAIzDA,UAAUX,6BAA6BW;IACvC,MAAMC,MAAMC,IAAAA,oBAAW,EAACF,SAAS;QAAEG,KAAK;IAAK;IAC7C,MAAMC,2BAA2BH,IAAII,IAAI,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK;IAIjE,MAAMC,yBAAyBR,IAAII,IAAI,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK;IAI/D,IAAI,CAACJ,4BAA4B,CAACK,wBAAwB;QACxD,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIN,4BAA4BA,yBAAyBO,WAAW,EAAER,KAAK;QACzE,MAAMP,wBAAwBgB,qBAC5BZ,SACAI,yBAAyBO,WAAW,CAACR,GAA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,MAAMK,MAAM,EAAE;IAClE,OAAO;QACLJ,KAAK,CAACD,MAAMI,IAAI,GAAG,EAAE,GAAGD,OAAOF,KAAK,CAACD,MAAMI,IAAI,GAAG,EAAE,EAAEJ,MAAMK,MAAM,EAAE;IACtE;IAEA,OAAOJ,MAAMO,IAAI,CAAC;AACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wrap-next-config.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-next-config.spec.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _wrapnextconfig = require("./wrap-next-config.js");
6
+ const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
7
+ function _getRequireWildcardCache(nodeInterop) {
8
+ if (typeof WeakMap !== "function") return null;
9
+ var cacheBabelInterop = new WeakMap();
10
+ var cacheNodeInterop = new WeakMap();
11
+ return (_getRequireWildcardCache = function(nodeInterop) {
12
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
13
+ })(nodeInterop);
14
+ }
15
+ function _interop_require_wildcard(obj, nodeInterop) {
16
+ if (!nodeInterop && obj && obj.__esModule) {
17
+ return obj;
18
+ }
19
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
20
+ return {
21
+ default: obj
22
+ };
23
+ }
24
+ var cache = _getRequireWildcardCache(nodeInterop);
25
+ if (cache && cache.has(obj)) {
26
+ return cache.get(obj);
27
+ }
28
+ var newObj = {
29
+ __proto__: null
30
+ };
31
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
32
+ for(var key in obj){
33
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
34
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
35
+ if (desc && (desc.get || desc.set)) {
36
+ Object.defineProperty(newObj, key, desc);
37
+ } else {
38
+ newObj[key] = obj[key];
39
+ }
40
+ }
41
+ }
42
+ newObj.default = obj;
43
+ if (cache) {
44
+ cache.set(obj, newObj);
45
+ }
46
+ return newObj;
47
+ }
48
+ const defaultNextConfig = `/** @type {import('next').NextConfig} */
49
+ const nextConfig = {};
50
+
51
+ export default nextConfig;
52
+ `;
53
+ const nextConfigWithFunc = `const nextConfig = {
54
+ // Your Next.js config here
55
+ }
56
+
57
+ export default someFunc(nextConfig)
58
+ `;
59
+ const nextConfigWithFuncMultiline = `const nextConfig = {
60
+ // Your Next.js config here
61
+ }
62
+
63
+ export default someFunc(
64
+ nextConfig
65
+ )
66
+ `;
67
+ const nextConfigExportNamedDefault = `const nextConfig = {
68
+ // Your Next.js config here
69
+ }
70
+ const wrapped = someFunc(asdf)
71
+ export { wrapped as default }
72
+ `;
73
+ describe('parseAndInsertWithPayload', ()=>{
74
+ it('should parse the default next config', ()=>{
75
+ const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(defaultNextConfig);
76
+ expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement);
77
+ expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
78
+ });
79
+ it('should parse the config with a function', ()=>{
80
+ const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigWithFunc);
81
+ expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))');
82
+ });
83
+ it('should parse the config with a function on a new line', ()=>{
84
+ const { modifiedConfigContent } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigWithFuncMultiline);
85
+ expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement);
86
+ expect(modifiedConfigContent).toMatch(/withPayload\(someFunc\(\n nextConfig\n\)\)/);
87
+ });
88
+ // Unsupported: export { wrapped as default }
89
+ it('should give warning with a named export as default', ()=>{
90
+ const warnLogSpy = jest.spyOn(_prompts.log, 'warn').mockImplementation(()=>{});
91
+ const { modifiedConfigContent, success } = (0, _wrapnextconfig.parseAndModifyConfigContent)(nextConfigExportNamedDefault);
92
+ expect(modifiedConfigContent).toContain(_wrapnextconfig.withPayloadImportStatement);
93
+ expect(success).toBe(false);
94
+ expect(warnLogSpy).toHaveBeenCalledWith(expect.stringContaining('Could not automatically wrap'));
95
+ });
96
+ });
97
+
98
+ //# sourceMappingURL=wrap-next-config.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/wrap-next-config.spec.ts"],"sourcesContent":["import { parseAndModifyConfigContent, withPayloadImportStatement } from './wrap-next-config.js'\nimport * as p from '@clack/prompts'\n\nconst defaultNextConfig = `/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nexport default nextConfig;\n`\n\nconst nextConfigWithFunc = `const nextConfig = {\n // Your Next.js config here\n}\n\nexport default someFunc(nextConfig)\n`\nconst nextConfigWithFuncMultiline = `const nextConfig = {\n // Your Next.js config here\n}\n\nexport default someFunc(\n nextConfig\n)\n`\n\nconst nextConfigExportNamedDefault = `const nextConfig = {\n // Your Next.js config here\n}\nconst wrapped = someFunc(asdf)\nexport { wrapped as default }\n`\n\ndescribe('parseAndInsertWithPayload', () => {\n it('should parse the default next config', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(defaultNextConfig)\n expect(modifiedConfigContent).toContain(withPayloadImportStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse the config with a function', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(nextConfigWithFunc)\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a function on a new line', () => {\n const { modifiedConfigContent } = parseAndModifyConfigContent(nextConfigWithFuncMultiline)\n expect(modifiedConfigContent).toContain(withPayloadImportStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n nextConfig\\n\\)\\)/)\n })\n\n // Unsupported: export { wrapped as default }\n it('should give warning with a named export as default', () => {\n const warnLogSpy = jest.spyOn(p.log, 'warn').mockImplementation(() => {})\n\n const { modifiedConfigContent, success } = parseAndModifyConfigContent(\n nextConfigExportNamedDefault,\n )\n expect(modifiedConfigContent).toContain(withPayloadImportStatement)\n expect(success).toBe(false)\n\n expect(warnLogSpy).toHaveBeenCalledWith(expect.stringContaining('Could not automatically wrap'))\n })\n})\n"],"names":["defaultNextConfig","nextConfigWithFunc","nextConfigWithFuncMultiline","nextConfigExportNamedDefault","describe","it","modifiedConfigContent","parseAndModifyConfigContent","expect","toContain","withPayloadImportStatement","toMatch","warnLogSpy","jest","spyOn","p","log","mockImplementation","success","toBe","toHaveBeenCalledWith","stringContaining"],"mappings":";;;;gCAAwE;iEACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnB,MAAMA,oBAAoB,CAAC;;;;AAI3B,CAAC;AAED,MAAMC,qBAAqB,CAAC;;;;;AAK5B,CAAC;AACD,MAAMC,8BAA8B,CAAC;;;;;;;AAOrC,CAAC;AAED,MAAMC,+BAA+B,CAAC;;;;;AAKtC,CAAC;AAEDC,SAAS,6BAA6B;IACpCC,GAAG,wCAAwC;QACzC,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,IAAAA,2CAA2B,EAACP;QAC9DQ,OAAOF,uBAAuBG,SAAS,CAACC,0CAA0B;QAClEF,OAAOF,uBAAuBG,SAAS,CAAC;IAC1C;IACAJ,GAAG,2CAA2C;QAC5C,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,IAAAA,2CAA2B,EAACN;QAC9DO,OAAOF,uBAAuBG,SAAS,CAAC;IAC1C;IAEAJ,GAAG,yDAAyD;QAC1D,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,IAAAA,2CAA2B,EAACL;QAC9DM,OAAOF,uBAAuBG,SAAS,CAACC,0CAA0B;QAClEF,OAAOF,uBAAuBK,OAAO,CAAC;IACxC;IAEA,6CAA6C;IAC7CN,GAAG,sDAAsD;QACvD,MAAMO,aAAaC,KAAKC,KAAK,CAACC,SAAEC,GAAG,EAAE,QAAQC,kBAAkB,CAAC,KAAO;QAEvE,MAAM,EAAEX,qBAAqB,EAAEY,OAAO,EAAE,GAAGX,IAAAA,2CAA2B,EACpEJ;QAEFK,OAAOF,uBAAuBG,SAAS,CAACC,0CAA0B;QAClEF,OAAOU,SAASC,IAAI,CAAC;QAErBX,OAAOI,YAAYQ,oBAAoB,CAACZ,OAAOa,gBAAgB,CAAC;IAClE;AACF"}
@@ -0,0 +1,10 @@
1
+ import type { CliArgs, ProjectTemplate } from '../types.js';
2
+ /** Parse and swap .env.example values and write .env */
3
+ export declare function writeEnvFile(args: {
4
+ cliArgs: CliArgs;
5
+ databaseUri: string;
6
+ payloadSecret: string;
7
+ projectDir: string;
8
+ template?: ProjectTemplate;
9
+ }): Promise<void>;
10
+ //# sourceMappingURL=write-env-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-env-file.d.ts","sourceRoot":"","sources":["../../src/lib/write-env-file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI3D,wDAAwD;AACxD,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CA6ChB"}