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.
- package/README.md +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -0
- package/dist/lib/configure-payload-config.d.ts +11 -0
- package/dist/lib/configure-payload-config.d.ts.map +1 -0
- package/dist/lib/configure-payload-config.js +15 -53
- package/dist/lib/configure-payload-config.js.map +1 -0
- package/dist/lib/create-project.d.ts +14 -0
- package/dist/lib/create-project.d.ts.map +1 -0
- package/dist/lib/create-project.js +84 -24
- package/dist/lib/create-project.js.map +1 -0
- package/dist/lib/create-project.spec.d.ts +2 -0
- package/dist/lib/create-project.spec.d.ts.map +1 -0
- package/dist/lib/create-project.spec.js +30 -75
- package/dist/lib/create-project.spec.js.map +1 -0
- package/dist/lib/generate-secret.d.ts +2 -0
- package/dist/lib/generate-secret.d.ts.map +1 -0
- package/dist/lib/generate-secret.js +1 -1
- package/dist/lib/generate-secret.js.map +1 -0
- package/dist/lib/init-next.d.ts +29 -0
- package/dist/lib/init-next.d.ts.map +1 -0
- package/dist/lib/init-next.js +285 -0
- package/dist/lib/init-next.js.map +1 -0
- package/dist/lib/packages.d.ts +9 -0
- package/dist/lib/packages.d.ts.map +1 -0
- package/dist/lib/packages.js +8 -52
- package/dist/lib/packages.js.map +1 -0
- package/dist/lib/parse-project-name.d.ts +3 -0
- package/dist/lib/parse-project-name.d.ts.map +1 -0
- package/dist/lib/parse-project-name.js +53 -12
- package/dist/lib/parse-project-name.js.map +1 -0
- package/dist/lib/parse-template.d.ts +3 -0
- package/dist/lib/parse-template.d.ts.map +1 -0
- package/dist/lib/parse-template.js +50 -20
- package/dist/lib/parse-template.js.map +1 -0
- package/dist/lib/select-db.d.ts +3 -0
- package/dist/lib/select-db.d.ts.map +1 -0
- package/dist/lib/select-db.js +72 -31
- package/dist/lib/select-db.js.map +1 -0
- package/dist/lib/templates.d.ts +4 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +17 -11
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/wrap-next-config.d.ts +12 -0
- package/dist/lib/wrap-next-config.d.ts.map +1 -0
- package/dist/lib/wrap-next-config.js +110 -0
- package/dist/lib/wrap-next-config.js.map +1 -0
- package/dist/lib/wrap-next-config.spec.d.ts +2 -0
- package/dist/lib/wrap-next-config.spec.d.ts.map +1 -0
- package/dist/lib/wrap-next-config.spec.js +98 -0
- package/dist/lib/wrap-next-config.spec.js.map +1 -0
- package/dist/lib/write-env-file.d.ts +10 -0
- package/dist/lib/write-env-file.d.ts.map +1 -0
- package/dist/lib/write-env-file.js +9 -6
- package/dist/lib/write-env-file.js.map +1 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +176 -60
- package/dist/main.js.map +1 -0
- package/dist/scripts/pack-template-files.d.ts +2 -0
- package/dist/scripts/pack-template-files.d.ts.map +1 -0
- package/dist/scripts/pack-template-files.js +43 -0
- package/dist/scripts/pack-template-files.js.map +1 -0
- package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +17 -0
- package/dist/template/src/app/(payload)/api/[...slug]/route.ts +9 -0
- package/dist/template/src/app/(payload)/api/graphql/route.ts +6 -0
- package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +6 -0
- package/dist/template/src/app/(payload)/custom.scss +0 -0
- package/dist/template/src/app/(payload)/layout.tsx +16 -0
- package/dist/template/src/app/my-route/route.ts +14 -0
- package/dist/template/src/collections/Users.ts +13 -0
- package/dist/template/src/payload.config.ts +38 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -0
- package/dist/utils/copy-recursive-sync.d.ts +5 -0
- package/dist/utils/copy-recursive-sync.d.ts.map +1 -0
- package/dist/utils/copy-recursive-sync.js +34 -0
- package/dist/utils/copy-recursive-sync.js.map +1 -0
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +62 -15
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/messages.d.ts +11 -0
- package/dist/utils/messages.d.ts.map +1 -0
- package/dist/utils/messages.js +47 -16
- package/dist/utils/messages.js.map +1 -0
- 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__*/
|
12
|
-
function
|
13
|
-
|
14
|
-
|
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
|
25
|
-
|
26
|
-
|
60
|
+
const response = await _prompts.select({
|
61
|
+
message: 'Choose project template',
|
62
|
+
options: validTemplates.map((p)=>{
|
27
63
|
return {
|
28
|
-
|
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
|
-
|
42
|
-
|
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=
|
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 @@
|
|
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"}
|
package/dist/lib/select-db.js
CHANGED
@@ -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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
93
|
+
if (_prompts.isCancel(dbType)) process.exit(0);
|
55
94
|
}
|
56
95
|
const dbChoice = dbChoiceRecord[dbType];
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
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
|
-
|
70
|
-
|
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=
|
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 @@
|
|
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"}
|
package/dist/lib/templates.js
CHANGED
@@ -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.com/payloadcms/website-cms'
|
66
72
|
}
|
67
73
|
];
|
68
74
|
}
|
69
75
|
|
70
|
-
//# sourceMappingURL=
|
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":"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"}
|
@@ -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"}
|