create-payload-app 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js.map +1 -1
- package/dist/lib/configure-payload-config.d.ts +8 -2
- package/dist/lib/configure-payload-config.d.ts.map +1 -1
- package/dist/lib/configure-payload-config.js +74 -25
- package/dist/lib/configure-payload-config.js.map +1 -1
- package/dist/lib/constants.d.ts +2 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/create-project.d.ts.map +1 -1
- package/dist/lib/create-project.js +19 -9
- package/dist/lib/create-project.js.map +1 -1
- package/dist/lib/create-project.spec.js +27 -31
- package/dist/lib/create-project.spec.js.map +1 -1
- package/dist/lib/download-template.d.ts +7 -0
- package/dist/lib/download-template.d.ts.map +1 -0
- package/dist/lib/download-template.js +28 -0
- package/dist/lib/download-template.js.map +1 -0
- package/dist/lib/generate-secret.js.map +1 -1
- package/dist/lib/get-package-manager.d.ts +6 -0
- package/dist/lib/get-package-manager.d.ts.map +1 -0
- package/dist/lib/get-package-manager.js +50 -0
- package/dist/lib/get-package-manager.js.map +1 -0
- package/dist/lib/init-next.d.ts +8 -16
- package/dist/lib/init-next.d.ts.map +1 -1
- package/dist/lib/init-next.js +81 -58
- package/dist/lib/init-next.js.map +1 -1
- package/dist/lib/install-packages.d.ts +9 -0
- package/dist/lib/install-packages.d.ts.map +1 -0
- package/dist/lib/install-packages.js +43 -0
- package/dist/lib/install-packages.js.map +1 -0
- package/dist/lib/parse-project-name.d.ts.map +1 -1
- package/dist/lib/parse-project-name.js +9 -3
- package/dist/lib/parse-project-name.js.map +1 -1
- package/dist/lib/parse-template.d.ts.map +1 -1
- package/dist/lib/parse-template.js +3 -1
- package/dist/lib/parse-template.js.map +1 -1
- package/dist/lib/replacements.d.ts +27 -0
- package/dist/lib/replacements.d.ts.map +1 -0
- package/dist/lib/replacements.js +92 -0
- package/dist/lib/replacements.js.map +1 -0
- package/dist/lib/select-db.d.ts.map +1 -1
- package/dist/lib/select-db.js +23 -14
- package/dist/lib/select-db.js.map +1 -1
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +8 -25
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/update-payload-in-project.d.ts +6 -0
- package/dist/lib/update-payload-in-project.d.ts.map +1 -0
- package/dist/lib/update-payload-in-project.js +73 -0
- package/dist/lib/update-payload-in-project.js.map +1 -0
- package/dist/lib/wrap-next-config.d.ts +5 -5
- package/dist/lib/wrap-next-config.d.ts.map +1 -1
- package/dist/lib/wrap-next-config.js +120 -61
- package/dist/lib/wrap-next-config.js.map +1 -1
- package/dist/lib/wrap-next-config.spec.js +85 -34
- package/dist/lib/wrap-next-config.spec.js.map +1 -1
- package/dist/lib/write-env-file.d.ts +2 -1
- package/dist/lib/write-env-file.d.ts.map +1 -1
- package/dist/lib/write-env-file.js +31 -26
- package/dist/lib/write-env-file.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +54 -34
- package/dist/main.js.map +1 -1
- package/dist/scripts/pack-template-files.js +3 -3
- package/dist/scripts/pack-template-files.js.map +1 -1
- package/dist/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +8 -6
- package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +8 -6
- package/dist/template/src/app/(payload)/admin/importMap.js +1 -0
- package/dist/template/src/app/(payload)/api/[...slug]/route.ts +11 -2
- package/dist/template/src/app/(payload)/api/graphql/route.ts +4 -2
- package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +2 -1
- package/dist/template/src/app/(payload)/layout.tsx +19 -4
- package/dist/template/src/collections/Media.ts +16 -0
- package/dist/template/src/collections/Users.ts +1 -1
- package/dist/template/src/payload-types.ts +127 -0
- package/dist/template/src/payload.config.ts +13 -15
- package/dist/types.d.ts +15 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/copy-recursive-sync.d.ts +3 -1
- package/dist/utils/copy-recursive-sync.d.ts.map +1 -1
- package/dist/utils/copy-recursive-sync.js +6 -1
- package/dist/utils/copy-recursive-sync.js.map +1 -1
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +46 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/log.d.ts.map +1 -1
- package/dist/utils/log.js +1 -1
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +1 -0
- package/dist/utils/messages.js.map +1 -1
- package/license.md +22 -0
- package/package.json +34 -10
- package/dist/lib/packages.d.ts +0 -9
- package/dist/lib/packages.d.ts.map +0 -1
- package/dist/lib/packages.js +0 -27
- package/dist/lib/packages.js.map +0 -1
@@ -2,40 +2,45 @@ import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
3
3
|
import { debug, error } from '../utils/log.js';
|
4
4
|
/** Parse and swap .env.example values and write .env */ export async function writeEnvFile(args) {
|
5
|
-
const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args;
|
5
|
+
const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args;
|
6
6
|
if (cliArgs['--dry-run']) {
|
7
7
|
debug(`DRY RUN: .env file created`);
|
8
8
|
return;
|
9
9
|
}
|
10
10
|
const envOutputPath = path.join(projectDir, '.env');
|
11
11
|
try {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
12
|
+
let fileContents;
|
13
|
+
if (template?.type === 'starter') {
|
14
|
+
// Parse .env file into key/value pairs
|
15
|
+
const envExample = path.join(projectDir, '.env.example');
|
16
|
+
const envFile = await fs.readFile(envExample, 'utf8');
|
17
|
+
fileContents = `# Added by Payload\n` + envFile.split('\n').filter((e)=>e).map((line)=>{
|
18
|
+
if (line.startsWith('#') || !line.includes('=')) {
|
19
|
+
return line;
|
20
|
+
}
|
21
|
+
const split = line.split('=');
|
22
|
+
let key = split[0];
|
23
|
+
let value = split[1];
|
24
|
+
if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI' || key === 'POSTGRES_URL') {
|
25
|
+
if (databaseType === 'vercel-postgres') {
|
26
|
+
key = 'POSTGRES_URL';
|
26
27
|
}
|
27
|
-
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
28
|
+
value = databaseUri;
|
29
|
+
}
|
30
|
+
if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {
|
31
|
+
value = payloadSecret;
|
32
|
+
}
|
33
|
+
return `${key}=${value}`;
|
34
|
+
}).join('\n');
|
35
|
+
} else {
|
36
|
+
fileContents = `# Added by Payload\nDATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}\n`;
|
37
|
+
}
|
38
|
+
if (fs.existsSync(envOutputPath)) {
|
39
|
+
const existingEnv = await fs.readFile(envOutputPath, 'utf8');
|
40
|
+
const newEnv = existingEnv + '\n# Added by Payload' + fileContents;
|
41
|
+
await fs.writeFile(envOutputPath, newEnv);
|
36
42
|
} else {
|
37
|
-
|
38
|
-
await fs.outputFile(`${projectDir}/.env`, content);
|
43
|
+
await fs.writeFile(envOutputPath, fileContents);
|
39
44
|
}
|
40
45
|
} catch (err) {
|
41
46
|
error('Unable to write .env file');
|
@@ -1 +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 const envOutputPath = path.join(projectDir, '.env')\n\n try {\n
|
1
|
+
{"version":3,"sources":["../../src/lib/write-env-file.ts"],"sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nimport type { CliArgs, DbType, 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 databaseType?: DbType\n databaseUri: string\n payloadSecret: string\n projectDir: string\n template?: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`DRY RUN: .env file created`)\n return\n }\n\n const envOutputPath = path.join(projectDir, '.env')\n\n try {\n let fileContents: string\n\n if (template?.type === 'starter') {\n // Parse .env file into key/value pairs\n const envExample = path.join(projectDir, '.env.example')\n const envFile = await fs.readFile(envExample, 'utf8')\n\n fileContents =\n `# Added by Payload\\n` +\n envFile\n .split('\\n')\n .filter((e) => e)\n .map((line) => {\n if (line.startsWith('#') || !line.includes('=')) {\n return line\n }\n\n const split = line.split('=')\n let key = split[0]\n let value = split[1]\n\n if (\n key === 'MONGODB_URI' ||\n key === 'MONGO_URL' ||\n key === 'DATABASE_URI' ||\n key === 'POSTGRES_URL'\n ) {\n if (databaseType === 'vercel-postgres') {\n key = 'POSTGRES_URL'\n }\n value = databaseUri\n }\n if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {\n value = payloadSecret\n }\n\n return `${key}=${value}`\n })\n .join('\\n')\n } else {\n fileContents = `# Added by Payload\\nDATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}\\n`\n }\n\n if (fs.existsSync(envOutputPath)) {\n const existingEnv = await fs.readFile(envOutputPath, 'utf8')\n const newEnv = existingEnv + '\\n# Added by Payload' + fileContents\n await fs.writeFile(envOutputPath, newEnv)\n } else {\n await fs.writeFile(envOutputPath, fileContents)\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":["fs","path","debug","error","writeEnvFile","args","cliArgs","databaseType","databaseUri","payloadSecret","projectDir","template","envOutputPath","join","fileContents","type","envExample","envFile","readFile","split","filter","e","map","line","startsWith","includes","key","value","existsSync","existingEnv","newEnv","writeFile","err","Error","message","process","exit"],"mappings":"AAAA,OAAOA,QAAQ,WAAU;AACzB,OAAOC,UAAU,OAAM;AAIvB,SAASC,KAAK,EAAEC,KAAK,QAAQ,kBAAiB;AAE9C,sDAAsD,GACtD,OAAO,eAAeC,aAAaC,IAOlC;IACC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGN;IAEpF,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBJ,MAAM,CAAC,0BAA0B,CAAC;QAClC;IACF;IAEA,MAAMU,gBAAgBX,KAAKY,IAAI,CAACH,YAAY;IAE5C,IAAI;QACF,IAAII;QAEJ,IAAIH,UAAUI,SAAS,WAAW;YAChC,uCAAuC;YACvC,MAAMC,aAAaf,KAAKY,IAAI,CAACH,YAAY;YACzC,MAAMO,UAAU,MAAMjB,GAAGkB,QAAQ,CAACF,YAAY;YAE9CF,eACE,CAAC,oBAAoB,CAAC,GACtBG,QACGE,KAAK,CAAC,MACNC,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACC;gBACJ,IAAIA,KAAKC,UAAU,CAAC,QAAQ,CAACD,KAAKE,QAAQ,CAAC,MAAM;oBAC/C,OAAOF;gBACT;gBAEA,MAAMJ,QAAQI,KAAKJ,KAAK,CAAC;gBACzB,IAAIO,MAAMP,KAAK,CAAC,EAAE;gBAClB,IAAIQ,QAAQR,KAAK,CAAC,EAAE;gBAEpB,IACEO,QAAQ,iBACRA,QAAQ,eACRA,QAAQ,kBACRA,QAAQ,gBACR;oBACA,IAAInB,iBAAiB,mBAAmB;wBACtCmB,MAAM;oBACR;oBACAC,QAAQnB;gBACV;gBACA,IAAIkB,QAAQ,oBAAoBA,QAAQ,sBAAsB;oBAC5DC,QAAQlB;gBACV;gBAEA,OAAO,CAAC,EAAEiB,IAAI,CAAC,EAAEC,MAAM,CAAC;YAC1B,GACCd,IAAI,CAAC;QACZ,OAAO;YACLC,eAAe,CAAC,iCAAiC,EAAEN,YAAY,iBAAiB,EAAEC,cAAc,EAAE,CAAC;QACrG;QAEA,IAAIT,GAAG4B,UAAU,CAAChB,gBAAgB;YAChC,MAAMiB,cAAc,MAAM7B,GAAGkB,QAAQ,CAACN,eAAe;YACrD,MAAMkB,SAASD,cAAc,yBAAyBf;YACtD,MAAMd,GAAG+B,SAAS,CAACnB,eAAekB;QACpC,OAAO;YACL,MAAM9B,GAAG+B,SAAS,CAACnB,eAAeE;QACpC;IACF,EAAE,OAAOkB,KAAc;QACrB7B,MAAM;QACN,IAAI6B,eAAeC,OAAO;YACxB9B,MAAM6B,IAAIE,OAAO;QACnB;QACAC,QAAQC,IAAI,CAAC;IACf;AACF"}
|
package/dist/main.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAuBzC,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IA4CP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAwL5B"}
|
package/dist/main.js
CHANGED
@@ -2,21 +2,22 @@ import * as p from '@clack/prompts';
|
|
2
2
|
import slugify from '@sindresorhus/slugify';
|
3
3
|
import arg from 'arg';
|
4
4
|
import chalk from 'chalk';
|
5
|
-
// @ts-expect-error no types
|
6
|
-
import { detect } from 'detect-package-manager';
|
7
5
|
import figures from 'figures';
|
8
6
|
import path from 'path';
|
9
7
|
import { configurePayloadConfig } from './lib/configure-payload-config.js';
|
8
|
+
import { PACKAGE_VERSION } from './lib/constants.js';
|
10
9
|
import { createProject } from './lib/create-project.js';
|
11
10
|
import { generateSecret } from './lib/generate-secret.js';
|
11
|
+
import { getPackageManager } from './lib/get-package-manager.js';
|
12
12
|
import { getNextAppDetails, initNext } from './lib/init-next.js';
|
13
13
|
import { parseProjectName } from './lib/parse-project-name.js';
|
14
14
|
import { parseTemplate } from './lib/parse-template.js';
|
15
15
|
import { selectDb } from './lib/select-db.js';
|
16
16
|
import { getValidTemplates, validateTemplate } from './lib/templates.js';
|
17
|
+
import { updatePayloadInProject } from './lib/update-payload-in-project.js';
|
17
18
|
import { writeEnvFile } from './lib/write-env-file.js';
|
18
|
-
import { error, info } from './utils/log.js';
|
19
|
-
import { feedbackOutro, helpMessage, moveMessage,
|
19
|
+
import { debug, error, info } from './utils/log.js';
|
20
|
+
import { feedbackOutro, helpMessage, moveMessage, successfulNextInit, successMessage } from './utils/messages.js';
|
20
21
|
export class Main {
|
21
22
|
args;
|
22
23
|
constructor(){
|
@@ -35,9 +36,12 @@ export class Main {
|
|
35
36
|
'--init-next': Boolean,
|
36
37
|
// Package manager
|
37
38
|
'--no-deps': Boolean,
|
39
|
+
'--use-bun': Boolean,
|
38
40
|
'--use-npm': Boolean,
|
39
41
|
'--use-pnpm': Boolean,
|
40
42
|
'--use-yarn': Boolean,
|
43
|
+
// Other
|
44
|
+
'--no-git': Boolean,
|
41
45
|
// Flags
|
42
46
|
'--beta': Boolean,
|
43
47
|
'--debug': Boolean,
|
@@ -57,19 +61,46 @@ export class Main {
|
|
57
61
|
helpMessage();
|
58
62
|
process.exit(0);
|
59
63
|
}
|
64
|
+
const debugFlag = this.args['--debug'];
|
60
65
|
// eslint-disable-next-line no-console
|
61
66
|
console.log('\n');
|
62
67
|
p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')));
|
63
68
|
p.note("Welcome to Payload. Let's create a project!");
|
64
69
|
// Detect if inside Next.js project
|
65
70
|
const nextAppDetails = await getNextAppDetails(process.cwd());
|
66
|
-
const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails;
|
71
|
+
const { hasTopLevelLayout, isPayloadInstalled, isSupportedNextVersion, nextAppDir, nextConfigPath, nextVersion } = nextAppDetails;
|
72
|
+
if (nextConfigPath && !isSupportedNextVersion) {
|
73
|
+
p.log.warn(`Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`);
|
74
|
+
p.outro(feedbackOutro());
|
75
|
+
process.exit(0);
|
76
|
+
}
|
77
|
+
// Upgrade Payload in existing project
|
78
|
+
if (isPayloadInstalled && nextConfigPath) {
|
79
|
+
p.log.warn(`Payload installation detected in current project.`);
|
80
|
+
const shouldUpdate = await p.confirm({
|
81
|
+
initialValue: false,
|
82
|
+
message: chalk.bold(`Upgrade Payload in this project?`)
|
83
|
+
});
|
84
|
+
if (!p.isCancel(shouldUpdate) && shouldUpdate) {
|
85
|
+
const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails);
|
86
|
+
if (updateSuccess) {
|
87
|
+
info(message);
|
88
|
+
} else {
|
89
|
+
error(message);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
p.outro(feedbackOutro());
|
93
|
+
process.exit(0);
|
94
|
+
}
|
67
95
|
if (nextConfigPath) {
|
68
96
|
this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)));
|
69
97
|
}
|
70
98
|
const projectName = await parseProjectName(this.args);
|
71
99
|
const projectDir = nextConfigPath ? path.dirname(nextConfigPath) : path.resolve(process.cwd(), slugify(projectName));
|
72
|
-
const packageManager = await getPackageManager(
|
100
|
+
const packageManager = await getPackageManager({
|
101
|
+
cliArgs: this.args,
|
102
|
+
projectDir
|
103
|
+
});
|
73
104
|
if (nextConfigPath) {
|
74
105
|
p.log.step(chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`));
|
75
106
|
const proceed = await p.confirm({
|
@@ -102,13 +133,14 @@ export class Main {
|
|
102
133
|
process.exit(1);
|
103
134
|
}
|
104
135
|
await configurePayloadConfig({
|
105
|
-
dbDetails,
|
136
|
+
dbType: dbDetails?.type,
|
106
137
|
projectDirOrConfigPath: {
|
107
138
|
payloadConfigPath: result.payloadConfigPath
|
108
139
|
}
|
109
140
|
});
|
110
141
|
await writeEnvFile({
|
111
142
|
cliArgs: this.args,
|
143
|
+
databaseType: dbDetails.type,
|
112
144
|
databaseUri: dbDetails.dbUri,
|
113
145
|
payloadSecret: generateSecret(),
|
114
146
|
projectDir
|
@@ -126,6 +158,9 @@ export class Main {
|
|
126
158
|
process.exit(1);
|
127
159
|
}
|
128
160
|
}
|
161
|
+
if (debugFlag) {
|
162
|
+
debug(`Using templates from git tag: v${PACKAGE_VERSION}`);
|
163
|
+
}
|
129
164
|
const validTemplates = getValidTemplates();
|
130
165
|
const template = await parseTemplate(this.args, validTemplates);
|
131
166
|
if (!template) {
|
@@ -134,6 +169,17 @@ export class Main {
|
|
134
169
|
process.exit(1);
|
135
170
|
}
|
136
171
|
switch(template.type){
|
172
|
+
case 'plugin':
|
173
|
+
{
|
174
|
+
await createProject({
|
175
|
+
cliArgs: this.args,
|
176
|
+
packageManager,
|
177
|
+
projectDir,
|
178
|
+
projectName,
|
179
|
+
template
|
180
|
+
});
|
181
|
+
break;
|
182
|
+
}
|
137
183
|
case 'starter':
|
138
184
|
{
|
139
185
|
const dbDetails = await selectDb(this.args, projectName);
|
@@ -148,6 +194,7 @@ export class Main {
|
|
148
194
|
});
|
149
195
|
await writeEnvFile({
|
150
196
|
cliArgs: this.args,
|
197
|
+
databaseType: dbDetails.type,
|
151
198
|
databaseUri: dbDetails.dbUri,
|
152
199
|
payloadSecret,
|
153
200
|
projectDir,
|
@@ -155,17 +202,6 @@ export class Main {
|
|
155
202
|
});
|
156
203
|
break;
|
157
204
|
}
|
158
|
-
case 'plugin':
|
159
|
-
{
|
160
|
-
await createProject({
|
161
|
-
cliArgs: this.args,
|
162
|
-
packageManager,
|
163
|
-
projectDir,
|
164
|
-
projectName,
|
165
|
-
template
|
166
|
-
});
|
167
|
-
break;
|
168
|
-
}
|
169
205
|
}
|
170
206
|
info('Payload project successfully created!');
|
171
207
|
p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')));
|
@@ -175,21 +211,5 @@ export class Main {
|
|
175
211
|
}
|
176
212
|
}
|
177
213
|
}
|
178
|
-
async function getPackageManager(args, projectDir) {
|
179
|
-
let packageManager = 'npm';
|
180
|
-
if (args['--use-npm']) {
|
181
|
-
packageManager = 'npm';
|
182
|
-
} else if (args['--use-yarn']) {
|
183
|
-
packageManager = 'yarn';
|
184
|
-
} else if (args['--use-pnpm']) {
|
185
|
-
packageManager = 'pnpm';
|
186
|
-
} else {
|
187
|
-
const detected = await detect({
|
188
|
-
cwd: projectDir
|
189
|
-
});
|
190
|
-
packageManager = detected || 'npm';
|
191
|
-
}
|
192
|
-
return packageManager;
|
193
|
-
}
|
194
214
|
|
195
215
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
@@ -1 +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":["p","slugify","arg","chalk","detect","figures","path","configurePayloadConfig","createProject","generateSecret","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","writeEnvFile","error","info","feedbackOutro","helpMessage","moveMessage","successMessage","successfulNextInit","Main","args","constructor","String","Boolean","permissive","init","process","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","nextAppDir","nextConfigPath","basename","dirname","projectName","projectDir","resolve","packageManager","getPackageManager","step","bold","bgBlack","triangleUp","proceed","confirm","initialValue","message","green","isCancel","outro","warn","dbDetails","result","dbType","type","success","projectDirOrConfigPath","payloadConfigPath","cliArgs","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","validTemplates","template","err","Error","detected"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,4BAA4B;AAC5B,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC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;oBACF;gBACA,KAAK;oBAAU;wBACb,MAAMvE,cAAc;4BAClB+D,SAAS,IAAI,CAAC7C,IAAI;4BAClBwB;4BACAF;4BACAD;4BACAgC;wBACF;wBACA;oBACF;YACF;YAEA5D,KAAK;YACLnB,EAAEuC,IAAI,CAAChB,eAAeyB,YAAYE,iBAAiB/C,MAAMwE,OAAO,CAACxE,MAAMmC,KAAK,CAAC;YAC7EtC,EAAE8D,KAAK,CAAC1C;QACV,EAAE,OAAO4D,KAAc;YACrB9D,MAAM8D,eAAeC,QAAQD,IAAIrB,OAAO,GAAG;QAC7C;IACF;AACF;AAEA,eAAeR,kBAAkBzB,IAAa,EAAEsB,UAAkB;IAChE,IAAIE,iBAAiC;IAErC,IAAIxB,IAAI,CAAC,YAAY,EAAE;QACrBwB,iBAAiB;IACnB,OAAO,IAAIxB,IAAI,CAAC,aAAa,EAAE;QAC7BwB,iBAAiB;IACnB,OAAO,IAAIxB,IAAI,CAAC,aAAa,EAAE;QAC7BwB,iBAAiB;IACnB,OAAO;QACL,MAAMgC,WAAW,MAAM9E,OAAO;YAAEqC,KAAKO;QAAW;QAChDE,iBAAiBgC,YAAY;IAC/B;IACA,OAAOhC;AACT"}
|
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'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { PACKAGE_VERSION } from './lib/constants.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getPackageManager } from './lib/get-package-manager.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 { updatePayloadInProject } from './lib/update-payload-in-project.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successMessage,\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-bun': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Other\n '--no-git': 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 const debugFlag = this.args['--debug']\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 {\n hasTopLevelLayout,\n isPayloadInstalled,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextVersion,\n } = nextAppDetails\n\n if (nextConfigPath && !isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Upgrade Payload in existing project\n if (isPayloadInstalled && nextConfigPath) {\n p.log.warn(`Payload installation detected in current project.`)\n const shouldUpdate = await p.confirm({\n initialValue: false,\n message: chalk.bold(`Upgrade Payload in this project?`),\n })\n\n if (!p.isCancel(shouldUpdate) && shouldUpdate) {\n const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails)\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n process.exit(0)\n }\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({ cliArgs: 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 dbType: dbDetails?.type,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseType: dbDetails.type,\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 if (debugFlag) {\n debug(`Using templates from git tag: v${PACKAGE_VERSION}`)\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 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\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 databaseType: dbDetails.type,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\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"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","PACKAGE_VERSION","createProject","generateSecret","getPackageManager","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","writeEnvFile","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successMessage","Main","args","constructor","String","Boolean","permissive","init","process","exit","debugFlag","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","isPayloadInstalled","isSupportedNextVersion","nextAppDir","nextConfigPath","nextVersion","warn","outro","shouldUpdate","confirm","initialValue","message","bold","isCancel","success","updateSuccess","basename","dirname","projectName","projectDir","resolve","packageManager","cliArgs","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseType","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","validTemplates","template","err","Error"],"mappings":"AAAA,YAAYA,O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AAMD,cAAc;4BAClB4D,SAAS,IAAI,CAACvC,IAAI;4BAClB6C;4BACAP;4BACAF;4BACAD;4BACAwB;wBACF;wBACA,MAAMrE,aAAa;4BACjBiD,SAAS,IAAI,CAACvC,IAAI;4BAClBmD,cAAcN,UAAUG,IAAI;4BAC5BI,aAAaP,UAAUQ,KAAK;4BAC5BC;4BACAlB;4BACAuB;wBACF;wBACA;oBACF;YACF;YAEAlE,KAAK;YACLtB,EAAE2C,IAAI,CAAChB,eAAesC,YAAYE,iBAAiBhE,MAAMiF,OAAO,CAACjF,MAAMuC,KAAK,CAAC;YAC7E1C,EAAEqD,KAAK,CAAC9B;QACV,EAAE,OAAOkE,KAAc;YACrBpE,MAAMoE,eAAeC,QAAQD,IAAIhC,OAAO,GAAG;QAC7C;IACF;AACF"}
|
@@ -7,13 +7,13 @@ const dirname = path.dirname(filename);
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
8
8
|
main();
|
9
9
|
/**
|
10
|
-
* Copy the necessary template files from `templates/blank
|
10
|
+
* Copy the necessary template files from `templates/blank` to `dist/template`
|
11
11
|
*
|
12
12
|
* Eventually, this should be replaced with using tar.x to stream from the git repo
|
13
13
|
*/ async function main() {
|
14
14
|
const root = path.resolve(dirname, '../../../../');
|
15
15
|
const outputPath = path.resolve(dirname, '../../dist/template');
|
16
|
-
const sourceTemplatePath = path.resolve(root, 'templates/blank
|
16
|
+
const sourceTemplatePath = path.resolve(root, 'templates/blank');
|
17
17
|
if (!fs.existsSync(sourceTemplatePath)) {
|
18
18
|
throw new Error(`Source path does not exist: ${sourceTemplatePath}`);
|
19
19
|
}
|
@@ -22,7 +22,7 @@ main();
|
|
22
22
|
recursive: true
|
23
23
|
});
|
24
24
|
}
|
25
|
-
// Copy the src directory from `templates/blank
|
25
|
+
// Copy the src directory from `templates/blank` to `dist`
|
26
26
|
const srcPath = path.resolve(sourceTemplatePath, 'src');
|
27
27
|
const distSrcPath = path.resolve(outputPath, 'src');
|
28
28
|
// Copy entire file structure from src to dist
|
@@ -1 +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
|
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` 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')\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` 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":["fs","fsp","fileURLToPath","path","filename","url","dirname","main","root","resolve","outputPath","sourceTemplatePath","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","cp"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,cAAa;AAC7B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAE7B,mEAAmE;AACnEG;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOL,KAAKM,OAAO,CAACH,SAAS;IACnC,MAAMI,aAAaP,KAAKM,OAAO,CAACH,SAAS;IACzC,MAAMK,qBAAqBR,KAAKM,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACR,GAAGY,UAAU,CAACD,qBAAqB;QACtC,MAAM,IAAIE,MAAM,CAAC,4BAA4B,EAAEF,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACX,GAAGY,UAAU,CAACF,aAAa;QAC9BV,GAAGc,SAAS,CAACJ,YAAY;YAAEK,WAAW;QAAK;IAC7C;IAEA,0DAA0D;IAC1D,MAAMC,UAAUb,KAAKM,OAAO,CAACE,oBAAoB;IACjD,MAAMM,cAAcd,KAAKM,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMT,IAAIiB,EAAE,CAACF,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
|
@@ -1,22 +1,24 @@
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
2
3
|
import type { Metadata } from 'next'
|
3
4
|
|
4
5
|
import config from '@payload-config'
|
5
|
-
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
6
6
|
import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views'
|
7
|
+
import { importMap } from '../importMap'
|
7
8
|
|
8
9
|
type Args = {
|
9
|
-
params: {
|
10
|
+
params: Promise<{
|
10
11
|
segments: string[]
|
11
|
-
}
|
12
|
-
searchParams: {
|
12
|
+
}>
|
13
|
+
searchParams: Promise<{
|
13
14
|
[key: string]: string | string[]
|
14
|
-
}
|
15
|
+
}>
|
15
16
|
}
|
16
17
|
|
17
18
|
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
18
19
|
generatePageMetadata({ config, params, searchParams })
|
19
20
|
|
20
|
-
const NotFound = ({ params, searchParams }: Args) =>
|
21
|
+
const NotFound = ({ params, searchParams }: Args) =>
|
22
|
+
NotFoundPage({ config, params, searchParams, importMap })
|
21
23
|
|
22
24
|
export default NotFound
|
@@ -1,22 +1,24 @@
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
2
3
|
import type { Metadata } from 'next'
|
3
4
|
|
4
5
|
import config from '@payload-config'
|
5
|
-
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
6
6
|
import { RootPage, generatePageMetadata } from '@payloadcms/next/views'
|
7
|
+
import { importMap } from '../importMap'
|
7
8
|
|
8
9
|
type Args = {
|
9
|
-
params: {
|
10
|
+
params: Promise<{
|
10
11
|
segments: string[]
|
11
|
-
}
|
12
|
-
searchParams: {
|
12
|
+
}>
|
13
|
+
searchParams: Promise<{
|
13
14
|
[key: string]: string | string[]
|
14
|
-
}
|
15
|
+
}>
|
15
16
|
}
|
16
17
|
|
17
18
|
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
18
19
|
generatePageMetadata({ config, params, searchParams })
|
19
20
|
|
20
|
-
const Page = ({ params, searchParams }: Args) =>
|
21
|
+
const Page = ({ params, searchParams }: Args) =>
|
22
|
+
RootPage({ config, params, searchParams, importMap })
|
21
23
|
|
22
24
|
export default Page
|
@@ -0,0 +1 @@
|
|
1
|
+
export const importMap = {}
|
@@ -1,10 +1,19 @@
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
-
/* DO NOT MODIFY
|
2
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
3
3
|
import config from '@payload-config'
|
4
|
-
import
|
4
|
+
import '@payloadcms/next/css'
|
5
|
+
import {
|
6
|
+
REST_DELETE,
|
7
|
+
REST_GET,
|
8
|
+
REST_OPTIONS,
|
9
|
+
REST_PATCH,
|
10
|
+
REST_POST,
|
11
|
+
REST_PUT,
|
12
|
+
} from '@payloadcms/next/routes'
|
5
13
|
|
6
14
|
export const GET = REST_GET(config)
|
7
15
|
export const POST = REST_POST(config)
|
8
16
|
export const DELETE = REST_DELETE(config)
|
9
17
|
export const PATCH = REST_PATCH(config)
|
18
|
+
export const PUT = REST_PUT(config)
|
10
19
|
export const OPTIONS = REST_OPTIONS(config)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
-
/* DO NOT MODIFY
|
2
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
3
3
|
import config from '@payload-config'
|
4
|
-
import { GRAPHQL_POST } from '@payloadcms/next/routes'
|
4
|
+
import { GRAPHQL_POST, REST_OPTIONS } from '@payloadcms/next/routes'
|
5
5
|
|
6
6
|
export const POST = GRAPHQL_POST(config)
|
7
|
+
|
8
|
+
export const OPTIONS = REST_OPTIONS(config)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
2
|
-
/* DO NOT MODIFY
|
2
|
+
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
3
3
|
import config from '@payload-config'
|
4
|
+
import '@payloadcms/next/css'
|
4
5
|
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes'
|
5
6
|
|
6
7
|
export const GET = GRAPHQL_PLAYGROUND_GET(config)
|
@@ -1,16 +1,31 @@
|
|
1
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
2
|
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
3
|
+
import config from '@payload-config'
|
4
|
+
import '@payloadcms/next/css'
|
5
|
+
import type { ServerFunctionClient } from 'payload'
|
6
|
+
import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts'
|
6
7
|
import React from 'react'
|
7
8
|
|
9
|
+
import { importMap } from './admin/importMap.js'
|
8
10
|
import './custom.scss'
|
9
11
|
|
10
12
|
type Args = {
|
11
13
|
children: React.ReactNode
|
12
14
|
}
|
13
15
|
|
14
|
-
const
|
16
|
+
const serverFunction: ServerFunctionClient = async function (args) {
|
17
|
+
'use server'
|
18
|
+
return handleServerFunctions({
|
19
|
+
...args,
|
20
|
+
config,
|
21
|
+
importMap,
|
22
|
+
})
|
23
|
+
}
|
24
|
+
|
25
|
+
const Layout = ({ children }: Args) => (
|
26
|
+
<RootLayout config={config} importMap={importMap} serverFunction={serverFunction}>
|
27
|
+
{children}
|
28
|
+
</RootLayout>
|
29
|
+
)
|
15
30
|
|
16
31
|
export default Layout
|