create-payload-app 1.0.0 → 3.0.0-alpha.54
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
@@ -10,16 +10,20 @@ Object.defineProperty(exports, "writeEnvFile", {
|
|
10
10
|
});
|
11
11
|
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
13
|
-
const _log = require("../utils/log");
|
13
|
+
const _log = require("../utils/log.js");
|
14
14
|
function _interop_require_default(obj) {
|
15
15
|
return obj && obj.__esModule ? obj : {
|
16
16
|
default: obj
|
17
17
|
};
|
18
18
|
}
|
19
19
|
async function writeEnvFile(args) {
|
20
|
-
const { databaseUri, payloadSecret, projectDir, template } = args;
|
20
|
+
const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args;
|
21
|
+
if (cliArgs['--dry-run']) {
|
22
|
+
(0, _log.debug)(`DRY RUN: .env file created`);
|
23
|
+
return;
|
24
|
+
}
|
21
25
|
try {
|
22
|
-
if (template
|
26
|
+
if (template?.type === 'starter' && _fsextra.default.existsSync(_path.default.join(projectDir, '.env.example'))) {
|
23
27
|
// Parse .env file into key/value pairs
|
24
28
|
const envFile = await _fsextra.default.readFile(_path.default.join(projectDir, '.env.example'), 'utf8');
|
25
29
|
const envWithValues = envFile.split('\n').filter((e)=>e).map((line)=>{
|
@@ -38,10 +42,9 @@ async function writeEnvFile(args) {
|
|
38
42
|
// Write new .env file
|
39
43
|
await _fsextra.default.writeFile(_path.default.join(projectDir, '.env'), envWithValues.join('\n'));
|
40
44
|
} else {
|
41
|
-
const content = `
|
45
|
+
const content = `DATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`;
|
42
46
|
await _fsextra.default.outputFile(`${projectDir}/.env`, content);
|
43
47
|
}
|
44
|
-
(0, _log.success)('.env file created');
|
45
48
|
} catch (err) {
|
46
49
|
(0, _log.error)('Unable to write .env file');
|
47
50
|
if (err instanceof Error) {
|
@@ -51,4 +54,4 @@ async function writeEnvFile(args) {
|
|
51
54
|
}
|
52
55
|
}
|
53
56
|
|
54
|
-
//# sourceMappingURL=
|
57
|
+
//# sourceMappingURL=write-env-file.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/write-env-file.ts"],"sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nimport type { CliArgs, ProjectTemplate } from '../types.js'\n\nimport { debug, error } from '../utils/log.js'\n\n/** Parse and swap .env.example values and write .env */\nexport async function writeEnvFile(args: {\n cliArgs: CliArgs\n databaseUri: string\n payloadSecret: string\n projectDir: string\n template?: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`DRY RUN: .env file created`)\n return\n }\n\n try {\n if (template?.type === 'starter' && fs.existsSync(path.join(projectDir, '.env.example'))) {\n // Parse .env file into key/value pairs\n const envFile = await fs.readFile(path.join(projectDir, '.env.example'), 'utf8')\n const envWithValues: string[] = envFile\n .split('\\n')\n .filter((e) => e)\n .map((line) => {\n if (line.startsWith('#') || !line.includes('=')) return line\n\n const split = line.split('=')\n const key = split[0]\n let value = split[1]\n\n if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI') {\n value = databaseUri\n }\n if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {\n value = payloadSecret\n }\n\n return `${key}=${value}`\n })\n\n // Write new .env file\n await fs.writeFile(path.join(projectDir, '.env'), envWithValues.join('\\n'))\n } else {\n const content = `DATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}`\n await fs.outputFile(`${projectDir}/.env`, content)\n }\n } catch (err: unknown) {\n error('Unable to write .env file')\n if (err instanceof Error) {\n error(err.message)\n }\n process.exit(1)\n }\n}\n"],"names":["writeEnvFile","args","cliArgs","databaseUri","payloadSecret","projectDir","template","debug","type","fs","existsSync","path","join","envFile","readFile","envWithValues","split","filter","e","map","line","startsWith","includes","key","value","writeFile","content","outputFile","err","error","Error","message","process","exit"],"mappings":";;;;+BAQsBA;;;eAAAA;;;gEARP;6DACE;qBAIY;;;;;;AAGtB,eAAeA,aAAaC,IAMlC;IACC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAEtE,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBK,IAAAA,UAAK,EAAC,CAAC,0BAA0B,CAAC;QAClC;IACF;IAEA,IAAI;QACF,IAAID,UAAUE,SAAS,aAAaC,gBAAE,CAACC,UAAU,CAACC,aAAI,CAACC,IAAI,CAACP,YAAY,kBAAkB;YACxF,uCAAuC;YACvC,MAAMQ,UAAU,MAAMJ,gBAAE,CAACK,QAAQ,CAACH,aAAI,CAACC,IAAI,CAACP,YAAY,iBAAiB;YACzE,MAAMU,gBAA0BF,QAC7BG,KAAK,CAAC,MACNC,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACC;gBACJ,IAAIA,KAAKC,UAAU,CAAC,QAAQ,CAACD,KAAKE,QAAQ,CAAC,MAAM,OAAOF;gBAExD,MAAMJ,QAAQI,KAAKJ,KAAK,CAAC;gBACzB,MAAMO,MAAMP,KAAK,CAAC,EAAE;gBACpB,IAAIQ,QAAQR,KAAK,CAAC,EAAE;gBAEpB,IAAIO,QAAQ,iBAAiBA,QAAQ,eAAeA,QAAQ,gBAAgB;oBAC1EC,QAAQrB;gBACV;gBACA,IAAIoB,QAAQ,oBAAoBA,QAAQ,sBAAsB;oBAC5DC,QAAQpB;gBACV;gBAEA,OAAO,CAAC,EAAEmB,IAAI,CAAC,EAAEC,MAAM,CAAC;YAC1B;YAEF,sBAAsB;YACtB,MAAMf,gBAAE,CAACgB,SAAS,CAACd,aAAI,CAACC,IAAI,CAACP,YAAY,SAASU,cAAcH,IAAI,CAAC;QACvE,OAAO;YACL,MAAMc,UAAU,CAAC,aAAa,EAAEvB,YAAY,iBAAiB,EAAEC,cAAc,CAAC;YAC9E,MAAMK,gBAAE,CAACkB,UAAU,CAAC,CAAC,EAAEtB,WAAW,KAAK,CAAC,EAAEqB;QAC5C;IACF,EAAE,OAAOE,KAAc;QACrBC,IAAAA,UAAK,EAAC;QACN,IAAID,eAAeE,OAAO;YACxBD,IAAAA,UAAK,EAACD,IAAIG,OAAO;QACnB;QACAC,QAAQC,IAAI,CAAC;IACf;AACF"}
|
package/dist/main.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,YAAY,CAAA;AAoBzD,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IAwCP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CA4I5B"}
|
package/dist/main.js
CHANGED
@@ -8,33 +8,86 @@ Object.defineProperty(exports, "Main", {
|
|
8
8
|
return Main;
|
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
13
|
const _arg = /*#__PURE__*/ _interop_require_default(require("arg"));
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const
|
14
|
+
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
15
|
+
const _detectpackagemanager = require("detect-package-manager");
|
16
|
+
const _figures = /*#__PURE__*/ _interop_require_default(require("figures"));
|
17
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
18
|
+
const _configurepayloadconfig = require("./lib/configure-payload-config.js");
|
19
|
+
const _createproject = require("./lib/create-project.js");
|
20
|
+
const _generatesecret = require("./lib/generate-secret.js");
|
21
|
+
const _initnext = require("./lib/init-next.js");
|
22
|
+
const _parseprojectname = require("./lib/parse-project-name.js");
|
23
|
+
const _parsetemplate = require("./lib/parse-template.js");
|
24
|
+
const _selectdb = require("./lib/select-db.js");
|
25
|
+
const _templates = require("./lib/templates.js");
|
26
|
+
const _writeenvfile = require("./lib/write-env-file.js");
|
27
|
+
const _log = require("./utils/log.js");
|
28
|
+
const _messages = require("./utils/messages.js");
|
23
29
|
function _interop_require_default(obj) {
|
24
30
|
return obj && obj.__esModule ? obj : {
|
25
31
|
default: obj
|
26
32
|
};
|
27
33
|
}
|
34
|
+
function _getRequireWildcardCache(nodeInterop) {
|
35
|
+
if (typeof WeakMap !== "function") return null;
|
36
|
+
var cacheBabelInterop = new WeakMap();
|
37
|
+
var cacheNodeInterop = new WeakMap();
|
38
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
39
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
40
|
+
})(nodeInterop);
|
41
|
+
}
|
42
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
43
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
44
|
+
return obj;
|
45
|
+
}
|
46
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
47
|
+
return {
|
48
|
+
default: obj
|
49
|
+
};
|
50
|
+
}
|
51
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
52
|
+
if (cache && cache.has(obj)) {
|
53
|
+
return cache.get(obj);
|
54
|
+
}
|
55
|
+
var newObj = {
|
56
|
+
__proto__: null
|
57
|
+
};
|
58
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
59
|
+
for(var key in obj){
|
60
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
61
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
62
|
+
if (desc && (desc.get || desc.set)) {
|
63
|
+
Object.defineProperty(newObj, key, desc);
|
64
|
+
} else {
|
65
|
+
newObj[key] = obj[key];
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
newObj.default = obj;
|
70
|
+
if (cache) {
|
71
|
+
cache.set(obj, newObj);
|
72
|
+
}
|
73
|
+
return newObj;
|
74
|
+
}
|
28
75
|
class Main {
|
29
76
|
args;
|
30
77
|
constructor(){
|
31
78
|
// @ts-expect-error bad typings
|
32
79
|
this.args = (0, _arg.default)({
|
33
80
|
'--db': String,
|
81
|
+
'--db-accept-recommended': Boolean,
|
82
|
+
'--db-connection-string': String,
|
34
83
|
'--help': Boolean,
|
84
|
+
'--local-template': String,
|
35
85
|
'--name': String,
|
36
86
|
'--secret': String,
|
37
87
|
'--template': String,
|
88
|
+
'--template-branch': String,
|
89
|
+
// Next.js
|
90
|
+
'--init-next': Boolean,
|
38
91
|
// Package manager
|
39
92
|
'--no-deps': Boolean,
|
40
93
|
'--use-npm': Boolean,
|
@@ -42,6 +95,7 @@ class Main {
|
|
42
95
|
'--use-yarn': Boolean,
|
43
96
|
// Flags
|
44
97
|
'--beta': Boolean,
|
98
|
+
'--debug': Boolean,
|
45
99
|
'--dry-run': Boolean,
|
46
100
|
// Aliases
|
47
101
|
'-d': '--db',
|
@@ -55,61 +109,128 @@ class Main {
|
|
55
109
|
async init() {
|
56
110
|
try {
|
57
111
|
if (this.args['--help']) {
|
58
|
-
|
112
|
+
(0, _messages.helpMessage)();
|
59
113
|
process.exit(0);
|
60
114
|
}
|
115
|
+
// eslint-disable-next-line no-console
|
116
|
+
console.log('\n');
|
117
|
+
_prompts.intro(_chalk.default.bgCyan(_chalk.default.black(' create-payload-app ')));
|
118
|
+
_prompts.note("Welcome to Payload. Let's create a project!");
|
119
|
+
// Detect if inside Next.js project
|
120
|
+
const nextAppDetails = await (0, _initnext.getNextAppDetails)(process.cwd());
|
121
|
+
const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails;
|
122
|
+
if (nextConfigPath) {
|
123
|
+
this.args['--name'] = (0, _slugify.default)(_path.default.basename(_path.default.dirname(nextConfigPath)));
|
124
|
+
}
|
125
|
+
const projectName = await (0, _parseprojectname.parseProjectName)(this.args);
|
126
|
+
const projectDir = nextConfigPath ? _path.default.dirname(nextConfigPath) : _path.default.resolve(process.cwd(), (0, _slugify.default)(projectName));
|
127
|
+
const packageManager = await getPackageManager(this.args, projectDir);
|
128
|
+
if (nextConfigPath) {
|
129
|
+
_prompts.log.step(_chalk.default.bold(`${_chalk.default.bgBlack(` ${_figures.default.triangleUp} Next.js `)} project detected!`));
|
130
|
+
const proceed = await _prompts.confirm({
|
131
|
+
initialValue: true,
|
132
|
+
message: _chalk.default.bold(`Install ${_chalk.default.green('Payload')} in this project?`)
|
133
|
+
});
|
134
|
+
if (_prompts.isCancel(proceed) || !proceed) {
|
135
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
136
|
+
process.exit(0);
|
137
|
+
}
|
138
|
+
// Check for top-level layout.tsx
|
139
|
+
if (nextAppDir && hasTopLevelLayout) {
|
140
|
+
_prompts.log.warn((0, _messages.moveMessage)({
|
141
|
+
nextAppDir,
|
142
|
+
projectDir
|
143
|
+
}));
|
144
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
145
|
+
process.exit(0);
|
146
|
+
}
|
147
|
+
const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName);
|
148
|
+
const result = await (0, _initnext.initNext)({
|
149
|
+
...this.args,
|
150
|
+
dbType: dbDetails.type,
|
151
|
+
nextAppDetails,
|
152
|
+
packageManager,
|
153
|
+
projectDir
|
154
|
+
});
|
155
|
+
if (result.success === false) {
|
156
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
157
|
+
process.exit(1);
|
158
|
+
}
|
159
|
+
await (0, _configurepayloadconfig.configurePayloadConfig)({
|
160
|
+
dbDetails,
|
161
|
+
projectDirOrConfigPath: {
|
162
|
+
payloadConfigPath: result.payloadConfigPath
|
163
|
+
}
|
164
|
+
});
|
165
|
+
await (0, _writeenvfile.writeEnvFile)({
|
166
|
+
cliArgs: this.args,
|
167
|
+
databaseUri: dbDetails.dbUri,
|
168
|
+
payloadSecret: (0, _generatesecret.generateSecret)(),
|
169
|
+
projectDir
|
170
|
+
});
|
171
|
+
(0, _log.info)('Payload project successfully initialized!');
|
172
|
+
_prompts.note((0, _messages.successfulNextInit)(), _chalk.default.bgGreen(_chalk.default.black(' Documentation ')));
|
173
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
174
|
+
return;
|
175
|
+
}
|
61
176
|
const templateArg = this.args['--template'];
|
62
177
|
if (templateArg) {
|
63
178
|
const valid = (0, _templates.validateTemplate)(templateArg);
|
64
179
|
if (!valid) {
|
65
|
-
|
180
|
+
(0, _messages.helpMessage)();
|
66
181
|
process.exit(1);
|
67
182
|
}
|
68
183
|
}
|
69
|
-
console.log(_messages.welcomeMessage);
|
70
|
-
const projectName = await (0, _parseprojectname.parseProjectName)(this.args);
|
71
184
|
const validTemplates = (0, _templates.getValidTemplates)();
|
72
185
|
const template = await (0, _parsetemplate.parseTemplate)(this.args, validTemplates);
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
const payloadSecret = (0, _generatesecret.generateSecret)();
|
78
|
-
if (!this.args['--dry-run']) {
|
79
|
-
await (0, _createproject.createProject)({
|
80
|
-
cliArgs: this.args,
|
81
|
-
dbDetails,
|
82
|
-
packageManager,
|
83
|
-
projectDir,
|
84
|
-
projectName,
|
85
|
-
template
|
86
|
-
});
|
87
|
-
await (0, _writeenvfile.writeEnvFile)({
|
88
|
-
databaseUri: dbDetails.dbUri,
|
89
|
-
payloadSecret,
|
90
|
-
projectDir,
|
91
|
-
template
|
92
|
-
});
|
93
|
-
}
|
94
|
-
} else {
|
95
|
-
if (!this.args['--dry-run']) {
|
96
|
-
await (0, _createproject.createProject)({
|
97
|
-
cliArgs: this.args,
|
98
|
-
packageManager,
|
99
|
-
projectDir,
|
100
|
-
projectName,
|
101
|
-
template
|
102
|
-
});
|
103
|
-
}
|
186
|
+
if (!template) {
|
187
|
+
_prompts.log.error('Invalid template given');
|
188
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
189
|
+
process.exit(1);
|
104
190
|
}
|
105
|
-
(
|
106
|
-
|
107
|
-
|
108
|
-
|
191
|
+
switch(template.type){
|
192
|
+
case 'starter':
|
193
|
+
{
|
194
|
+
const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName);
|
195
|
+
const payloadSecret = (0, _generatesecret.generateSecret)();
|
196
|
+
await (0, _createproject.createProject)({
|
197
|
+
cliArgs: this.args,
|
198
|
+
dbDetails,
|
199
|
+
packageManager,
|
200
|
+
projectDir,
|
201
|
+
projectName,
|
202
|
+
template
|
203
|
+
});
|
204
|
+
await (0, _writeenvfile.writeEnvFile)({
|
205
|
+
cliArgs: this.args,
|
206
|
+
databaseUri: dbDetails.dbUri,
|
207
|
+
payloadSecret,
|
208
|
+
projectDir,
|
209
|
+
template
|
210
|
+
});
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
case 'plugin':
|
214
|
+
{
|
215
|
+
await (0, _createproject.createProject)({
|
216
|
+
cliArgs: this.args,
|
217
|
+
packageManager,
|
218
|
+
projectDir,
|
219
|
+
projectName,
|
220
|
+
template
|
221
|
+
});
|
222
|
+
break;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
(0, _log.info)('Payload project successfully created!');
|
226
|
+
_prompts.note((0, _messages.successMessage)(projectDir, packageManager), _chalk.default.bgGreen(_chalk.default.black(' Next Steps ')));
|
227
|
+
_prompts.outro((0, _messages.feedbackOutro)());
|
228
|
+
} catch (err) {
|
229
|
+
(0, _log.error)(err instanceof Error ? err.message : 'An error occurred');
|
109
230
|
}
|
110
231
|
}
|
111
232
|
}
|
112
|
-
async function getPackageManager(args) {
|
233
|
+
async function getPackageManager(args, projectDir) {
|
113
234
|
let packageManager = 'npm';
|
114
235
|
if (args['--use-npm']) {
|
115
236
|
packageManager = 'npm';
|
@@ -118,17 +239,12 @@ async function getPackageManager(args) {
|
|
118
239
|
} else if (args['--use-pnpm']) {
|
119
240
|
packageManager = 'pnpm';
|
120
241
|
} else {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
packageManager = 'pnpm';
|
126
|
-
}
|
127
|
-
} catch (error) {
|
128
|
-
packageManager = 'npm';
|
129
|
-
}
|
242
|
+
const detected = await (0, _detectpackagemanager.detect)({
|
243
|
+
cwd: projectDir
|
244
|
+
});
|
245
|
+
packageManager = detected || 'npm';
|
130
246
|
}
|
131
247
|
return packageManager;
|
132
248
|
}
|
133
249
|
|
134
|
-
//# sourceMappingURL=
|
250
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\n// @ts-expect-error no types\nimport { detect } from 'detect-package-manager'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs, PackageManager } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager(this.args, projectDir)\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbDetails,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n\nasync function getPackageManager(args: CliArgs, projectDir: string): Promise<PackageManager> {\n let packageManager: PackageManager = 'npm'\n\n if (args['--use-npm']) {\n packageManager = 'npm'\n } else if (args['--use-yarn']) {\n packageManager = 'yarn'\n } else if (args['--use-pnpm']) {\n packageManager = 'pnpm'\n } else {\n const detected = await detect({ cwd: projectDir })\n packageManager = detected || 'npm'\n }\n return packageManager\n}\n"],"names":["Main","args","constructor","arg","String","Boolean","permissive","init","helpMessage","process","exit","console","log","p","intro","chalk","bgCyan","black","note","nextAppDetails","getNextAppDetails","cwd","hasTopLevelLayout","nextAppDir","nextConfigPath","slugify","path","basename","dirname","projectName","parseProjectName","projectDir","resolve","packageManager","getPackageManager","step","bold","bgBlack","figures","triangleUp","proceed","confirm","initialValue","message","green","isCancel","outro","feedbackOutro","warn","moveMessage","dbDetails","selectDb","result","initNext","dbType","type","success","configurePayloadConfig","projectDirOrConfigPath","payloadConfigPath","writeEnvFile","cliArgs","databaseUri","dbUri","payloadSecret","generateSecret","info","successfulNextInit","bgGreen","templateArg","valid","validateTemplate","validTemplates","getValidTemplates","template","parseTemplate","error","createProject","successMessage","err","Error","detected","detect"],"mappings":";;;;+BA6BaA;;;eAAAA;;;iEA7BM;gEACC;4DACJ;8DACE;sCAEK;gEACH;6DACH;wCAIsB;+BACT;gCACC;0BACa;kCACX;+BACH;0BACL;2BAC2B;8BACvB;qBACD;0BAOrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA;IACXC,KAAa;IAEbC,aAAc;QACZ,+BAA+B;QAC/B,IAAI,CAACD,IAAI,GAAGE,IAAAA,YAAG,EACb;YACE,QAAQC;YACR,2BAA2BC;YAC3B,0BAA0BD;YAC1B,UAAUC;YACV,oBAAoBD;YACpB,UAAUA;YACV,YAAYA;YACZ,cAAcA;YACd,qBAAqBA;YAErB,UAAU;YACV,eAAeC;YAEf,kBAAkB;YAClB,aAAaA;YACb,aAAaA;YACb,cAAcA;YACd,cAAcA;YAEd,QAAQ;YACR,UAAUA;YACV,WAAWA;YACX,aAAaA;YAEb,UAAU;YACV,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;QACR,GACA;YAAEC,YAAY;QAAK;IAEvB;IAEA,MAAMC,OAAsB;QAC1B,IAAI;YACF,IAAI,IAAI,CAACN,IAAI,CAAC,SAAS,EAAE;gBACvBO,IAAAA,qBAAW;gBAC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AiB;IACnB,OAAO,IAAIhC,IAAI,CAAC,aAAa,EAAE;QAC7BgC,iBAAiB;IACnB,OAAO,IAAIhC,IAAI,CAAC,aAAa,EAAE;QAC7BgC,iBAAiB;IACnB,OAAO;QACL,MAAMgD,WAAW,MAAMC,IAAAA,4BAAM,EAAC;YAAE7D,KAAKU;QAAW;QAChDE,iBAAiBgD,YAAY;IAC/B;IACA,OAAOhD;AACT"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pack-template-files.d.ts","sourceRoot":"","sources":["../../src/scripts/pack-template-files.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
6
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
7
|
+
const _nodeurl = require("node:url");
|
8
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
9
|
+
function _interop_require_default(obj) {
|
10
|
+
return obj && obj.__esModule ? obj : {
|
11
|
+
default: obj
|
12
|
+
};
|
13
|
+
}
|
14
|
+
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
|
15
|
+
const dirname = _path.default.dirname(filename);
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
17
|
+
main();
|
18
|
+
/**
|
19
|
+
* Copy the necessary template files from `templates/blank-3.0` to `dist/template`
|
20
|
+
*
|
21
|
+
* Eventually, this should be replaced with using tar.x to stream from the git repo
|
22
|
+
*/ async function main() {
|
23
|
+
const root = _path.default.resolve(dirname, '../../../../');
|
24
|
+
const outputPath = _path.default.resolve(dirname, '../../dist/template');
|
25
|
+
const sourceTemplatePath = _path.default.resolve(root, 'templates/blank-3.0');
|
26
|
+
if (!_fs.default.existsSync(sourceTemplatePath)) {
|
27
|
+
throw new Error(`Source path does not exist: ${sourceTemplatePath}`);
|
28
|
+
}
|
29
|
+
if (!_fs.default.existsSync(outputPath)) {
|
30
|
+
_fs.default.mkdirSync(outputPath, {
|
31
|
+
recursive: true
|
32
|
+
});
|
33
|
+
}
|
34
|
+
// Copy the src directory from `templates/blank-3.0` to `dist`
|
35
|
+
const srcPath = _path.default.resolve(sourceTemplatePath, 'src');
|
36
|
+
const distSrcPath = _path.default.resolve(outputPath, 'src');
|
37
|
+
// Copy entire file structure from src to dist
|
38
|
+
await _promises.default.cp(srcPath, distSrcPath, {
|
39
|
+
recursive: true
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
//# sourceMappingURL=pack-template-files.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank-3.0` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank-3.0` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["filename","fileURLToPath","dirname","path","main","root","resolve","outputPath","sourceTemplatePath","fs","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","fsp","cp"],"mappings":";;;;2DAAe;iEACC;yBACc;6DACb;;;;;;AACjB,MAAMA,WAAWC,IAAAA,sBAAa,EAAC;AAC/B,MAAMC,UAAUC,aAAI,CAACD,OAAO,CAACF;AAE7B,mEAAmE;AACnEI;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOF,aAAI,CAACG,OAAO,CAACJ,SAAS;IACnC,MAAMK,aAAaJ,aAAI,CAACG,OAAO,CAACJ,SAAS;IACzC,MAAMM,qBAAqBL,aAAI,CAACG,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACI,WAAE,CAACC,UAAU,CAACF,qBAAqB;QACtC,MAAM,IAAIG,MAAM,CAAC,4BAA4B,EAAEH,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACC,WAAE,CAACC,UAAU,CAACH,aAAa;QAC9BE,WAAE,CAACG,SAAS,CAACL,YAAY;YAAEM,WAAW;QAAK;IAC7C;IAEA,8DAA8D;IAC9D,MAAMC,UAAUX,aAAI,CAACG,OAAO,CAACE,oBAAoB;IACjD,MAAMO,cAAcZ,aAAI,CAACG,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMS,iBAAG,CAACC,EAAE,CAACH,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
import config from '@payload-config'
|
3
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
4
|
+
import { RootPage } from '@payloadcms/next/views'
|
5
|
+
|
6
|
+
type Args = {
|
7
|
+
params: {
|
8
|
+
segments: string[]
|
9
|
+
}
|
10
|
+
searchParams: {
|
11
|
+
[key: string]: string | string[]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
|
16
|
+
|
17
|
+
export default Page
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
/* DO NOT MODIFY it because it could be re-written at any time. */
|
3
|
+
import config from '@payload-config'
|
4
|
+
import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
|
5
|
+
|
6
|
+
export const GET = REST_GET(config)
|
7
|
+
export const POST = REST_POST(config)
|
8
|
+
export const DELETE = REST_DELETE(config)
|
9
|
+
export const PATCH = REST_PATCH(config)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
/* DO NOT MODIFY it because it could be re-written at any time. */
|
3
|
+
import config from '@payload-config'
|
4
|
+
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes'
|
5
|
+
|
6
|
+
export const GET = GRAPHQL_PLAYGROUND_GET(config)
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
import configPromise from '@payload-config'
|
3
|
+
import '@payloadcms/next/css'
|
4
|
+
import { RootLayout } from '@payloadcms/next/layouts'
|
5
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
6
|
+
import React from 'react'
|
7
|
+
|
8
|
+
import './custom.scss'
|
9
|
+
|
10
|
+
type Args = {
|
11
|
+
children: React.ReactNode
|
12
|
+
}
|
13
|
+
|
14
|
+
const Layout = ({ children }: Args) => <RootLayout config={configPromise}>{children}</RootLayout>
|
15
|
+
|
16
|
+
export default Layout
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import configPromise from '@payload-config'
|
2
|
+
import { getPayload } from 'payload'
|
3
|
+
|
4
|
+
export const GET = async () => {
|
5
|
+
const payload = await getPayload({
|
6
|
+
config: configPromise,
|
7
|
+
})
|
8
|
+
|
9
|
+
const data = await payload.find({
|
10
|
+
collection: 'users',
|
11
|
+
})
|
12
|
+
|
13
|
+
return Response.json(data)
|
14
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { mongooseAdapter } from '@payloadcms/db-mongodb' // database-adapter-import
|
2
|
+
// import { payloadCloud } from '@payloadcms/plugin-cloud'
|
3
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical' // editor-import
|
4
|
+
import path from 'path'
|
5
|
+
import { buildConfig } from 'payload/config'
|
6
|
+
// import sharp from 'sharp'
|
7
|
+
import { fileURLToPath } from 'url'
|
8
|
+
|
9
|
+
import { Users } from './collections/Users'
|
10
|
+
|
11
|
+
const filename = fileURLToPath(import.meta.url)
|
12
|
+
const dirname = path.dirname(filename)
|
13
|
+
|
14
|
+
export default buildConfig({
|
15
|
+
admin: {
|
16
|
+
user: Users.slug,
|
17
|
+
},
|
18
|
+
collections: [Users],
|
19
|
+
editor: lexicalEditor({}),
|
20
|
+
// plugins: [payloadCloud()], // TODO: Re-enable when cloud supports 3.0
|
21
|
+
secret: process.env.PAYLOAD_SECRET || '',
|
22
|
+
typescript: {
|
23
|
+
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
24
|
+
},
|
25
|
+
// database-adapter-config-start
|
26
|
+
db: mongooseAdapter({
|
27
|
+
url: process.env.DATABASE_URI || '',
|
28
|
+
}),
|
29
|
+
// database-adapter-config-end
|
30
|
+
// Sharp is now an optional dependency -
|
31
|
+
// if you want to resize images, crop, set focal point, etc.
|
32
|
+
// make sure to install it and pass it to the config.
|
33
|
+
|
34
|
+
// This is temporary - we may make an adapter pattern
|
35
|
+
// for this before reaching 3.0 stable
|
36
|
+
|
37
|
+
// sharp,
|
38
|
+
})
|