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
@@ -0,0 +1,50 @@
|
|
1
|
+
import execa from 'execa';
|
2
|
+
import fse from 'fs-extra';
|
3
|
+
export async function getPackageManager(args) {
|
4
|
+
const { cliArgs, projectDir } = args;
|
5
|
+
try {
|
6
|
+
// Check for flag or lockfile
|
7
|
+
let detected = 'npm';
|
8
|
+
if (cliArgs?.['--use-pnpm'] || fse.existsSync(`${projectDir}/pnpm-lock.yaml`)) {
|
9
|
+
detected = 'pnpm';
|
10
|
+
} else if (cliArgs?.['--use-yarn'] || fse.existsSync(`${projectDir}/yarn.lock`)) {
|
11
|
+
detected = 'yarn';
|
12
|
+
} else if (cliArgs?.['--use-npm'] || fse.existsSync(`${projectDir}/package-lock.json`)) {
|
13
|
+
detected = 'npm';
|
14
|
+
} else if (cliArgs?.['--use-bun'] || fse.existsSync(`${projectDir}/bun.lockb`)) {
|
15
|
+
detected = 'bun';
|
16
|
+
} else if (await commandExists('pnpm')) {
|
17
|
+
// Prefer pnpm if it's installed
|
18
|
+
detected = 'pnpm';
|
19
|
+
} else {
|
20
|
+
// Otherwise check the execution environment
|
21
|
+
detected = getEnvironmentPackageManager();
|
22
|
+
}
|
23
|
+
return detected;
|
24
|
+
} catch (ignore) {
|
25
|
+
return 'npm';
|
26
|
+
}
|
27
|
+
}
|
28
|
+
function getEnvironmentPackageManager() {
|
29
|
+
const userAgent = process.env.npm_config_user_agent || '';
|
30
|
+
if (userAgent.startsWith('yarn')) {
|
31
|
+
return 'yarn';
|
32
|
+
}
|
33
|
+
if (userAgent.startsWith('pnpm')) {
|
34
|
+
return 'pnpm';
|
35
|
+
}
|
36
|
+
if (userAgent.startsWith('bun')) {
|
37
|
+
return 'bun';
|
38
|
+
}
|
39
|
+
return 'npm';
|
40
|
+
}
|
41
|
+
async function commandExists(command) {
|
42
|
+
try {
|
43
|
+
await execa.command(process.platform === 'win32' ? `where ${command}` : `command -v ${command}`);
|
44
|
+
return true;
|
45
|
+
} catch {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
//# sourceMappingURL=get-package-manager.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/get-package-manager.ts"],"sourcesContent":["import execa from 'execa'\nimport fse from 'fs-extra'\n\nimport type { CliArgs, PackageManager } from '../types.js'\n\nexport async function getPackageManager(args: {\n cliArgs?: CliArgs\n projectDir: string\n}): Promise<PackageManager> {\n const { cliArgs, projectDir } = args\n\n try {\n // Check for flag or lockfile\n let detected: PackageManager = 'npm'\n if (cliArgs?.['--use-pnpm'] || fse.existsSync(`${projectDir}/pnpm-lock.yaml`)) {\n detected = 'pnpm'\n } else if (cliArgs?.['--use-yarn'] || fse.existsSync(`${projectDir}/yarn.lock`)) {\n detected = 'yarn'\n } else if (cliArgs?.['--use-npm'] || fse.existsSync(`${projectDir}/package-lock.json`)) {\n detected = 'npm'\n } else if (cliArgs?.['--use-bun'] || fse.existsSync(`${projectDir}/bun.lockb`)) {\n detected = 'bun'\n } else if (await commandExists('pnpm')) {\n // Prefer pnpm if it's installed\n detected = 'pnpm'\n } else {\n // Otherwise check the execution environment\n detected = getEnvironmentPackageManager()\n }\n\n return detected\n } catch (ignore) {\n return 'npm'\n }\n}\n\nfunction getEnvironmentPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent || ''\n\n if (userAgent.startsWith('yarn')) {\n return 'yarn'\n }\n\n if (userAgent.startsWith('pnpm')) {\n return 'pnpm'\n }\n\n if (userAgent.startsWith('bun')) {\n return 'bun'\n }\n\n return 'npm'\n}\n\nasync function commandExists(command: string): Promise<boolean> {\n try {\n await execa.command(process.platform === 'win32' ? `where ${command}` : `command -v ${command}`)\n return true\n } catch {\n return false\n }\n}\n"],"names":["execa","fse","getPackageManager","args","cliArgs","projectDir","detected","existsSync","commandExists","getEnvironmentPackageManager","ignore","userAgent","process","env","npm_config_user_agent","startsWith","command","platform"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,OAAOC,SAAS,WAAU;AAI1B,OAAO,eAAeC,kBAAkBC,IAGvC;IACC,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGF;IAEhC,IAAI;QACF,6BAA6B;QAC7B,IAAIG,WAA2B;QAC/B,IAAIF,SAAS,CAAC,aAAa,IAAIH,IAAIM,UAAU,CAAC,CAAC,EAAEF,WAAW,eAAe,CAAC,GAAG;YAC7EC,WAAW;QACb,OAAO,IAAIF,SAAS,CAAC,aAAa,IAAIH,IAAIM,UAAU,CAAC,CAAC,EAAEF,WAAW,UAAU,CAAC,GAAG;YAC/EC,WAAW;QACb,OAAO,IAAIF,SAAS,CAAC,YAAY,IAAIH,IAAIM,UAAU,CAAC,CAAC,EAAEF,WAAW,kBAAkB,CAAC,GAAG;YACtFC,WAAW;QACb,OAAO,IAAIF,SAAS,CAAC,YAAY,IAAIH,IAAIM,UAAU,CAAC,CAAC,EAAEF,WAAW,UAAU,CAAC,GAAG;YAC9EC,WAAW;QACb,OAAO,IAAI,MAAME,cAAc,SAAS;YACtC,gCAAgC;YAChCF,WAAW;QACb,OAAO;YACL,4CAA4C;YAC5CA,WAAWG;QACb;QAEA,OAAOH;IACT,EAAE,OAAOI,QAAQ;QACf,OAAO;IACT;AACF;AAEA,SAASD;IACP,MAAME,YAAYC,QAAQC,GAAG,CAACC,qBAAqB,IAAI;IAEvD,IAAIH,UAAUI,UAAU,CAAC,SAAS;QAChC,OAAO;IACT;IAEA,IAAIJ,UAAUI,UAAU,CAAC,SAAS;QAChC,OAAO;IACT;IAEA,IAAIJ,UAAUI,UAAU,CAAC,QAAQ;QAC/B,OAAO;IACT;IAEA,OAAO;AACT;AAEA,eAAeP,cAAcQ,OAAe;IAC1C,IAAI;QACF,MAAMhB,MAAMgB,OAAO,CAACJ,QAAQK,QAAQ,KAAK,UAAU,CAAC,MAAM,EAAED,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAEA,QAAQ,CAAC;QAC/F,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
package/dist/lib/init-next.d.ts
CHANGED
@@ -1,31 +1,23 @@
|
|
1
|
-
import type { CliArgs, DbType, PackageManager } from '../types.js';
|
2
|
-
type InitNextArgs =
|
1
|
+
import type { CliArgs, DbType, NextAppDetails, PackageManager } from '../types.js';
|
2
|
+
type InitNextArgs = {
|
3
3
|
dbType: DbType;
|
4
4
|
nextAppDetails?: NextAppDetails;
|
5
5
|
packageManager: PackageManager;
|
6
6
|
projectDir: string;
|
7
7
|
useDistFiles?: boolean;
|
8
|
-
}
|
9
|
-
type NextConfigType = 'cjs' | 'esm';
|
8
|
+
} & Pick<CliArgs, '--debug'>;
|
10
9
|
type InitNextResult = {
|
11
|
-
isSrcDir: boolean;
|
12
|
-
nextAppDir: string;
|
13
|
-
payloadConfigPath: string;
|
14
|
-
success: true;
|
15
|
-
} | {
|
16
10
|
isSrcDir: boolean;
|
17
11
|
nextAppDir?: string;
|
18
12
|
reason: string;
|
19
13
|
success: false;
|
20
|
-
}
|
21
|
-
export declare function initNext(args: InitNextArgs): Promise<InitNextResult>;
|
22
|
-
type NextAppDetails = {
|
23
|
-
hasTopLevelLayout: boolean;
|
14
|
+
} | {
|
24
15
|
isSrcDir: boolean;
|
25
|
-
nextAppDir
|
26
|
-
|
27
|
-
|
16
|
+
nextAppDir: string;
|
17
|
+
payloadConfigPath: string;
|
18
|
+
success: true;
|
28
19
|
};
|
20
|
+
export declare function initNext(args: InitNextArgs): Promise<InitNextResult>;
|
29
21
|
export declare function getNextAppDetails(projectDir: string): Promise<NextAppDetails>;
|
30
22
|
export {};
|
31
23
|
//# sourceMappingURL=init-next.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init-next.d.ts","sourceRoot":"","sources":["../../src/lib/init-next.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"init-next.d.ts","sourceRoot":"","sources":["../../src/lib/init-next.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAkB,cAAc,EAAE,MAAM,aAAa,CAAA;AAclG,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAE5B,KAAK,cAAc,GACf;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,GAC1E;IACE,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,IAAI,CAAA;CACd,CAAA;AAEL,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAgE1E;AAqID,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA2FnF"}
|
package/dist/lib/init-next.js
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
import * as p from '@clack/prompts';
|
2
2
|
import { parse, stringify } from 'comment-json';
|
3
|
-
import execa from 'execa';
|
4
3
|
import fs from 'fs';
|
5
4
|
import fse from 'fs-extra';
|
6
5
|
import globby from 'globby';
|
6
|
+
import { fileURLToPath } from 'node:url';
|
7
7
|
import path from 'path';
|
8
8
|
import { promisify } from 'util';
|
9
|
-
const readFile = promisify(fs.readFile);
|
10
|
-
const writeFile = promisify(fs.writeFile);
|
11
|
-
const filename = fileURLToPath(import.meta.url);
|
12
|
-
const dirname = path.dirname(filename);
|
13
|
-
import { fileURLToPath } from 'node:url';
|
14
9
|
import { copyRecursiveSync } from '../utils/copy-recursive-sync.js';
|
15
10
|
import { debug as origDebug, warning } from '../utils/log.js';
|
16
11
|
import { moveMessage } from '../utils/messages.js';
|
12
|
+
import { installPackages } from './install-packages.js';
|
17
13
|
import { wrapNextConfig } from './wrap-next-config.js';
|
14
|
+
const readFile = promisify(fs.readFile);
|
15
|
+
const writeFile = promisify(fs.writeFile);
|
16
|
+
const filename = fileURLToPath(import.meta.url);
|
17
|
+
const dirname = path.dirname(filename);
|
18
18
|
export async function initNext(args) {
|
19
19
|
const { dbType: dbType, packageManager, projectDir } = args;
|
20
20
|
const nextAppDetails = args.nextAppDetails || await getNextAppDetails(projectDir);
|
@@ -50,7 +50,7 @@ export async function initNext(args) {
|
|
50
50
|
}
|
51
51
|
const installSpinner = p.spinner();
|
52
52
|
installSpinner.start('Installing Payload and dependencies...');
|
53
|
-
const configurationResult = installAndConfigurePayload({
|
53
|
+
const configurationResult = await installAndConfigurePayload({
|
54
54
|
...args,
|
55
55
|
nextAppDetails,
|
56
56
|
nextConfigType,
|
@@ -112,7 +112,7 @@ async function addPayloadConfigToTsConfig(projectDir, isSrcDir) {
|
|
112
112
|
});
|
113
113
|
}
|
114
114
|
}
|
115
|
-
function installAndConfigurePayload(args) {
|
115
|
+
async function installAndConfigurePayload(args) {
|
116
116
|
const { '--debug': debug, nextAppDetails: { isSrcDir, nextAppDir, nextConfigPath } = {}, nextConfigType, projectDir, useDistFiles } = args;
|
117
117
|
if (!nextAppDir || !nextConfigPath) {
|
118
118
|
return {
|
@@ -121,7 +121,9 @@ function installAndConfigurePayload(args) {
|
|
121
121
|
};
|
122
122
|
}
|
123
123
|
const logDebug = (message)=>{
|
124
|
-
if (debug)
|
124
|
+
if (debug) {
|
125
|
+
origDebug(message);
|
126
|
+
}
|
125
127
|
};
|
126
128
|
if (!fs.existsSync(projectDir)) {
|
127
129
|
return {
|
@@ -129,7 +131,7 @@ function installAndConfigurePayload(args) {
|
|
129
131
|
success: false
|
130
132
|
};
|
131
133
|
}
|
132
|
-
const templateFilesPath = dirname.endsWith('dist') || useDistFiles ? path.resolve(dirname, '../..', 'dist/template') : path.resolve(dirname, '../../../../templates/blank
|
134
|
+
const templateFilesPath = dirname.endsWith('dist') || useDistFiles ? path.resolve(dirname, '../..', 'dist/template') : path.resolve(dirname, '../../../../templates/blank');
|
133
135
|
logDebug(`Using template files from: ${templateFilesPath}`);
|
134
136
|
if (!fs.existsSync(templateFilesPath)) {
|
135
137
|
return {
|
@@ -148,9 +150,9 @@ function installAndConfigurePayload(args) {
|
|
148
150
|
logDebug(`payloadConfigPath: ${path.resolve(projectDir, 'payload.config.ts')}`);
|
149
151
|
logDebug(`isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`);
|
150
152
|
// This is a little clunky and needs to account for isSrcDir
|
151
|
-
copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath)
|
153
|
+
copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath));
|
152
154
|
// Wrap next.config.js with withPayload
|
153
|
-
wrapNextConfig({
|
155
|
+
await wrapNextConfig({
|
154
156
|
nextConfigPath,
|
155
157
|
nextConfigType
|
156
158
|
});
|
@@ -163,52 +165,22 @@ async function installDeps(projectDir, packageManager, dbType) {
|
|
163
165
|
const packagesToInstall = [
|
164
166
|
'payload',
|
165
167
|
'@payloadcms/next',
|
166
|
-
'@payloadcms/richtext-lexical'
|
168
|
+
'@payloadcms/richtext-lexical',
|
169
|
+
'@payloadcms/payload-cloud'
|
167
170
|
].map((pkg)=>`${pkg}@beta`);
|
168
171
|
packagesToInstall.push(`@payloadcms/db-${dbType}@beta`);
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
...packagesToInstall
|
177
|
-
], {
|
178
|
-
cwd: projectDir
|
179
|
-
}));
|
180
|
-
break;
|
181
|
-
}
|
182
|
-
case 'yarn':
|
183
|
-
case 'pnpm':
|
184
|
-
{
|
185
|
-
({ exitCode } = await execa(packageManager, [
|
186
|
-
'add',
|
187
|
-
...packagesToInstall
|
188
|
-
], {
|
189
|
-
cwd: projectDir
|
190
|
-
}));
|
191
|
-
break;
|
192
|
-
}
|
193
|
-
case 'bun':
|
194
|
-
{
|
195
|
-
warning('Bun support is untested.');
|
196
|
-
({ exitCode } = await execa('bun', [
|
197
|
-
'add',
|
198
|
-
...packagesToInstall
|
199
|
-
], {
|
200
|
-
cwd: projectDir
|
201
|
-
}));
|
202
|
-
break;
|
203
|
-
}
|
204
|
-
}
|
205
|
-
return {
|
206
|
-
success: exitCode === 0
|
207
|
-
};
|
172
|
+
// Match graphql version of @payloadcms/next
|
173
|
+
packagesToInstall.push('graphql@^16.8.1');
|
174
|
+
return await installPackages({
|
175
|
+
packageManager,
|
176
|
+
packagesToInstall,
|
177
|
+
projectDir
|
178
|
+
});
|
208
179
|
}
|
209
180
|
export async function getNextAppDetails(projectDir) {
|
210
181
|
const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'));
|
211
|
-
|
182
|
+
// Match next.config.js, next.config.ts, next.config.mjs, next.config.cjs
|
183
|
+
const nextConfigPath = (await globby('next.config.(\\w)?(t|j)s', {
|
212
184
|
absolute: true,
|
213
185
|
cwd: projectDir
|
214
186
|
}))?.[0];
|
@@ -216,7 +188,50 @@ export async function getNextAppDetails(projectDir) {
|
|
216
188
|
return {
|
217
189
|
hasTopLevelLayout: false,
|
218
190
|
isSrcDir,
|
219
|
-
|
191
|
+
isSupportedNextVersion: false,
|
192
|
+
nextConfigPath: undefined,
|
193
|
+
nextVersion: null
|
194
|
+
};
|
195
|
+
}
|
196
|
+
const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'));
|
197
|
+
// Check if Next.js version is new enough
|
198
|
+
let nextVersion = null;
|
199
|
+
if (packageObj.dependencies?.next) {
|
200
|
+
nextVersion = packageObj.dependencies.next;
|
201
|
+
// Match versions using regex matching groups
|
202
|
+
const versionMatch = /(?<major>\d+)/.exec(nextVersion);
|
203
|
+
if (!versionMatch) {
|
204
|
+
p.log.warn(`Could not determine Next.js version from ${nextVersion}`);
|
205
|
+
return {
|
206
|
+
hasTopLevelLayout: false,
|
207
|
+
isSrcDir,
|
208
|
+
isSupportedNextVersion: false,
|
209
|
+
nextConfigPath,
|
210
|
+
nextVersion
|
211
|
+
};
|
212
|
+
}
|
213
|
+
const { major } = versionMatch.groups;
|
214
|
+
const majorVersion = parseInt(major);
|
215
|
+
if (majorVersion < 15) {
|
216
|
+
return {
|
217
|
+
hasTopLevelLayout: false,
|
218
|
+
isSrcDir,
|
219
|
+
isSupportedNextVersion: false,
|
220
|
+
nextConfigPath,
|
221
|
+
nextVersion
|
222
|
+
};
|
223
|
+
}
|
224
|
+
}
|
225
|
+
const isSupportedNextVersion = true;
|
226
|
+
// Check if Payload already installed
|
227
|
+
if (packageObj.dependencies?.payload) {
|
228
|
+
return {
|
229
|
+
hasTopLevelLayout: false,
|
230
|
+
isPayloadInstalled: true,
|
231
|
+
isSrcDir,
|
232
|
+
isSupportedNextVersion,
|
233
|
+
nextConfigPath,
|
234
|
+
nextVersion
|
220
235
|
};
|
221
236
|
}
|
222
237
|
let nextAppDir = (await globby([
|
@@ -232,24 +247,32 @@ export async function getNextAppDetails(projectDir) {
|
|
232
247
|
if (!nextAppDir || nextAppDir.length === 0) {
|
233
248
|
nextAppDir = undefined;
|
234
249
|
}
|
235
|
-
const configType =
|
250
|
+
const configType = getProjectType({
|
251
|
+
nextConfigPath,
|
252
|
+
packageObj
|
253
|
+
});
|
236
254
|
const hasTopLevelLayout = nextAppDir ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx')) : false;
|
237
255
|
return {
|
238
256
|
hasTopLevelLayout,
|
239
257
|
isSrcDir,
|
258
|
+
isSupportedNextVersion,
|
240
259
|
nextAppDir,
|
241
260
|
nextConfigPath,
|
242
|
-
nextConfigType: configType
|
261
|
+
nextConfigType: configType,
|
262
|
+
nextVersion
|
243
263
|
};
|
244
264
|
}
|
245
|
-
|
265
|
+
function getProjectType(args) {
|
266
|
+
const { nextConfigPath, packageObj } = args;
|
267
|
+
if (nextConfigPath.endsWith('.ts')) {
|
268
|
+
return 'ts';
|
269
|
+
}
|
246
270
|
if (nextConfigPath.endsWith('.mjs')) {
|
247
271
|
return 'esm';
|
248
272
|
}
|
249
273
|
if (nextConfigPath.endsWith('.cjs')) {
|
250
274
|
return 'cjs';
|
251
275
|
}
|
252
|
-
const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'));
|
253
276
|
const packageJsonType = packageObj.type;
|
254
277
|
if (packageJsonType === 'module') {
|
255
278
|
return 'esm';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/lib/init-next.ts"],"sourcesContent":["import type { CompilerOptions } from 'typescript'\n\nimport * as p from '@clack/prompts'\nimport { parse, stringify } from 'comment-json'\nimport execa from 'execa'\nimport fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\nimport { promisify } from 'util'\n\nconst readFile = promisify(fs.readFile)\nconst writeFile = promisify(fs.writeFile)\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport { fileURLToPath } from 'node:url'\n\nimport type { CliArgs, DbType, PackageManager } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { debug as origDebug, warning } from '../utils/log.js'\nimport { moveMessage } from '../utils/messages.js'\nimport { wrapNextConfig } from './wrap-next-config.js'\n\ntype InitNextArgs = Pick<CliArgs, '--debug'> & {\n dbType: DbType\n nextAppDetails?: NextAppDetails\n packageManager: PackageManager\n projectDir: string\n useDistFiles?: boolean\n}\n\ntype NextConfigType = 'cjs' | 'esm'\n\ntype InitNextResult =\n | {\n isSrcDir: boolean\n nextAppDir: string\n payloadConfigPath: string\n success: true\n }\n | { isSrcDir: boolean; nextAppDir?: string; reason: string; success: false }\n\nexport async function initNext(args: InitNextArgs): Promise<InitNextResult> {\n const { dbType: dbType, packageManager, projectDir } = args\n\n const nextAppDetails = args.nextAppDetails || (await getNextAppDetails(projectDir))\n\n if (!nextAppDetails.nextAppDir) {\n warning(`Could not find app directory in ${projectDir}, creating...`)\n const createdAppDir = path.resolve(projectDir, nextAppDetails.isSrcDir ? 'src/app' : 'app')\n fse.mkdirSync(createdAppDir, { recursive: true })\n nextAppDetails.nextAppDir = createdAppDir\n }\n\n const { hasTopLevelLayout, isSrcDir, nextAppDir, nextConfigType } = nextAppDetails\n\n if (!nextConfigType) {\n return {\n isSrcDir,\n nextAppDir,\n reason: `Could not determine Next Config type in ${projectDir}. Possibly try renaming next.config.js to next.config.cjs or next.config.mjs.`,\n success: false,\n }\n }\n\n if (hasTopLevelLayout) {\n // Output directions for user to move all files from app to top-level directory named `(app)`\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n return {\n isSrcDir,\n nextAppDir,\n reason: 'Found existing layout.tsx in app directory',\n success: false,\n }\n }\n\n const installSpinner = p.spinner()\n installSpinner.start('Installing Payload and dependencies...')\n\n const configurationResult = installAndConfigurePayload({\n ...args,\n nextAppDetails,\n nextConfigType,\n useDistFiles: true, // Requires running 'pnpm pack-template-files' in cpa\n })\n\n if (configurationResult.success === false) {\n installSpinner.stop(configurationResult.reason, 1)\n return { ...configurationResult, isSrcDir, success: false }\n }\n\n const { success: installSuccess } = await installDeps(projectDir, packageManager, dbType)\n if (!installSuccess) {\n installSpinner.stop('Failed to install dependencies', 1)\n return {\n ...configurationResult,\n isSrcDir,\n reason: 'Failed to install dependencies',\n success: false,\n }\n }\n\n // Add `@payload-config` to tsconfig.json `paths`\n await addPayloadConfigToTsConfig(projectDir, isSrcDir)\n installSpinner.stop('Successfully installed Payload and dependencies')\n return { ...configurationResult, isSrcDir, nextAppDir, success: true }\n}\n\nasync function addPayloadConfigToTsConfig(projectDir: string, isSrcDir: boolean) {\n const tsConfigPath = path.resolve(projectDir, 'tsconfig.json')\n\n // Check if tsconfig.json exists\n if (!fs.existsSync(tsConfigPath)) {\n warning(`Could not find tsconfig.json to add @payload-config path.`)\n return\n }\n const userTsConfigContent = await readFile(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = parse(userTsConfigContent) as {\n compilerOptions?: CompilerOptions\n }\n\n const hasBaseUrl =\n userTsConfig?.compilerOptions?.baseUrl && userTsConfig?.compilerOptions?.baseUrl !== '.'\n const baseUrl = hasBaseUrl ? userTsConfig?.compilerOptions?.baseUrl : './'\n\n if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) {\n userTsConfig.compilerOptions = {}\n }\n\n if (\n !userTsConfig.compilerOptions?.paths?.['@payload-config'] &&\n userTsConfig.compilerOptions?.paths\n ) {\n userTsConfig.compilerOptions.paths = {\n ...(userTsConfig.compilerOptions.paths || {}),\n '@payload-config': [`${baseUrl}${isSrcDir ? 'src/' : ''}payload.config.ts`],\n }\n await writeFile(tsConfigPath, stringify(userTsConfig, null, 2), { encoding: 'utf8' })\n }\n}\n\nfunction installAndConfigurePayload(\n args: InitNextArgs & {\n nextAppDetails: NextAppDetails\n nextConfigType: NextConfigType\n useDistFiles?: boolean\n },\n):\n | { payloadConfigPath: string; success: true }\n | { payloadConfigPath?: string; reason: string; success: false } {\n const {\n '--debug': debug,\n nextAppDetails: { isSrcDir, nextAppDir, nextConfigPath } = {},\n nextConfigType,\n projectDir,\n useDistFiles,\n } = args\n\n if (!nextAppDir || !nextConfigPath) {\n return {\n reason: 'Could not find app directory or next.config.js',\n success: false,\n }\n }\n\n const logDebug = (message: string) => {\n if (debug) origDebug(message)\n }\n\n if (!fs.existsSync(projectDir)) {\n return {\n reason: `Could not find specified project directory at ${projectDir}`,\n success: false,\n }\n }\n\n const templateFilesPath =\n dirname.endsWith('dist') || useDistFiles\n ? path.resolve(dirname, '../..', 'dist/template')\n : path.resolve(dirname, '../../../../templates/blank-3.0')\n\n logDebug(`Using template files from: ${templateFilesPath}`)\n\n if (!fs.existsSync(templateFilesPath)) {\n return {\n reason: `Could not find template source files from ${templateFilesPath}`,\n success: false,\n }\n } else {\n logDebug('Found template source files')\n }\n\n logDebug(`Copying template files from ${templateFilesPath} to ${nextAppDir}`)\n\n const templateSrcDir = path.resolve(templateFilesPath, isSrcDir ? '' : 'src')\n\n logDebug(`templateSrcDir: ${templateSrcDir}`)\n logDebug(`nextAppDir: ${nextAppDir}`)\n logDebug(`projectDir: ${projectDir}`)\n logDebug(`nextConfigPath: ${nextConfigPath}`)\n logDebug(`payloadConfigPath: ${path.resolve(projectDir, 'payload.config.ts')}`)\n\n logDebug(\n `isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`,\n )\n\n // This is a little clunky and needs to account for isSrcDir\n copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath), debug)\n\n // Wrap next.config.js with withPayload\n wrapNextConfig({ nextConfigPath, nextConfigType })\n\n return {\n payloadConfigPath: path.resolve(nextAppDir, '../payload.config.ts'),\n success: true,\n }\n}\n\nasync function installDeps(projectDir: string, packageManager: PackageManager, dbType: DbType) {\n const packagesToInstall = ['payload', '@payloadcms/next', '@payloadcms/richtext-lexical'].map(\n (pkg) => `${pkg}@beta`,\n )\n\n packagesToInstall.push(`@payloadcms/db-${dbType}@beta`)\n\n let exitCode = 0\n switch (packageManager) {\n case 'npm': {\n ;({ exitCode } = await execa('npm', ['install', '--save', ...packagesToInstall], {\n cwd: projectDir,\n }))\n break\n }\n case 'yarn':\n case 'pnpm': {\n ;({ exitCode } = await execa(packageManager, ['add', ...packagesToInstall], {\n cwd: projectDir,\n }))\n break\n }\n case 'bun': {\n warning('Bun support is untested.')\n ;({ exitCode } = await execa('bun', ['add', ...packagesToInstall], { cwd: projectDir }))\n break\n }\n }\n\n return { success: exitCode === 0 }\n}\n\ntype NextAppDetails = {\n hasTopLevelLayout: boolean\n isSrcDir: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n}\n\nexport async function getNextAppDetails(projectDir: string): Promise<NextAppDetails> {\n const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'))\n\n const nextConfigPath: string | undefined = (\n await globby('next.config.*js', { absolute: true, cwd: projectDir })\n )?.[0]\n if (!nextConfigPath || nextConfigPath.length === 0) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n nextConfigPath: undefined,\n }\n }\n\n let nextAppDir: string | undefined = (\n await globby(['**/app'], {\n absolute: true,\n cwd: projectDir,\n ignore: ['**/node_modules/**'],\n onlyDirectories: true,\n })\n )?.[0]\n\n if (!nextAppDir || nextAppDir.length === 0) {\n nextAppDir = undefined\n }\n\n const configType = await getProjectType(projectDir, nextConfigPath)\n\n const hasTopLevelLayout = nextAppDir\n ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx'))\n : false\n\n return { hasTopLevelLayout, isSrcDir, nextAppDir, nextConfigPath, nextConfigType: configType }\n}\n\nasync function getProjectType(projectDir: string, nextConfigPath: string): Promise<'cjs' | 'esm'> {\n if (nextConfigPath.endsWith('.mjs')) {\n return 'esm'\n }\n if (nextConfigPath.endsWith('.cjs')) {\n return 'cjs'\n }\n\n const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'))\n const packageJsonType = packageObj.type\n if (packageJsonType === 'module') {\n return 'esm'\n }\n if (packageJsonType === 'commonjs') {\n return 'cjs'\n }\n\n return 'cjs'\n}\n"],"names":["p","parse","stringify","execa","fs","fse","globby","path","promisify","readFile","writeFile","filename","fileURLToPath","url","dirname","copyRecursiveSync","debug","origDebug","warning","moveMessage","wrapNextConfig","initNext","args","dbType","packageManager","projectDir","nextAppDetails","getNextAppDetails","nextAppDir","createdAppDir","resolve","isSrcDir","mkdirSync","recursive","hasTopLevelLayout","nextConfigType","reason","success","log","warn","installSpinner","spinner","start","configurationResult","installAndConfigurePayload","useDistFiles","stop","installSuccess","installDeps","addPayloadConfigToTsConfig","tsConfigPath","existsSync","userTsConfigContent","encoding","userTsConfig","hasBaseUrl","compilerOptions","baseUrl","paths","nextConfigPath","logDebug","message","templateFilesPath","endsWith","templateSrcDir","payloadConfigPath","packagesToInstall","map","pkg","push","exitCode","cwd","absolute","length","undefined","ignore","onlyDirectories","configType","getProjectType","packageObj","readJson","packageJsonType","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,KAAK,EAAEC,SAAS,QAAQ,eAAc;AAC/C,OAAOC,WAAW,QAAO;AACzB,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAEhC,MAAMC,WAAWD,UAAUJ,GAAGK,QAAQ;AACtC,MAAMC,YAAYF,UAAUJ,GAAGM,SAAS;AAExC,MAAMC,WAAWC,cAAc,YAAYC,GAAG;AAC9C,MAAMC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esContent":["import type { CompilerOptions } from 'typescript'\n\nimport * as p from '@clack/prompts'\nimport { parse, stringify } from 'comment-json'\nimport fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nimport { promisify } from 'util'\n\nimport type { CliArgs, DbType, NextAppDetails, NextConfigType, PackageManager } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { debug as origDebug, warning } from '../utils/log.js'\nimport { moveMessage } from '../utils/messages.js'\nimport { installPackages } from './install-packages.js'\nimport { wrapNextConfig } from './wrap-next-config.js'\n\nconst readFile = promisify(fs.readFile)\nconst writeFile = promisify(fs.writeFile)\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ntype InitNextArgs = {\n dbType: DbType\n nextAppDetails?: NextAppDetails\n packageManager: PackageManager\n projectDir: string\n useDistFiles?: boolean\n} & Pick<CliArgs, '--debug'>\n\ntype InitNextResult =\n | { isSrcDir: boolean; nextAppDir?: string; reason: string; success: false }\n | {\n isSrcDir: boolean\n nextAppDir: string\n payloadConfigPath: string\n success: true\n }\n\nexport async function initNext(args: InitNextArgs): Promise<InitNextResult> {\n const { dbType: dbType, packageManager, projectDir } = args\n\n const nextAppDetails = args.nextAppDetails || (await getNextAppDetails(projectDir))\n\n if (!nextAppDetails.nextAppDir) {\n warning(`Could not find app directory in ${projectDir}, creating...`)\n const createdAppDir = path.resolve(projectDir, nextAppDetails.isSrcDir ? 'src/app' : 'app')\n fse.mkdirSync(createdAppDir, { recursive: true })\n nextAppDetails.nextAppDir = createdAppDir\n }\n\n const { hasTopLevelLayout, isSrcDir, nextAppDir, nextConfigType } = nextAppDetails\n\n if (!nextConfigType) {\n return {\n isSrcDir,\n nextAppDir,\n reason: `Could not determine Next Config type in ${projectDir}. Possibly try renaming next.config.js to next.config.cjs or next.config.mjs.`,\n success: false,\n }\n }\n\n if (hasTopLevelLayout) {\n // Output directions for user to move all files from app to top-level directory named `(app)`\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n return {\n isSrcDir,\n nextAppDir,\n reason: 'Found existing layout.tsx in app directory',\n success: false,\n }\n }\n\n const installSpinner = p.spinner()\n installSpinner.start('Installing Payload and dependencies...')\n\n const configurationResult = await installAndConfigurePayload({\n ...args,\n nextAppDetails,\n nextConfigType,\n useDistFiles: true, // Requires running 'pnpm pack-template-files' in cpa\n })\n\n if (configurationResult.success === false) {\n installSpinner.stop(configurationResult.reason, 1)\n return { ...configurationResult, isSrcDir, success: false }\n }\n\n const { success: installSuccess } = await installDeps(projectDir, packageManager, dbType)\n if (!installSuccess) {\n installSpinner.stop('Failed to install dependencies', 1)\n return {\n ...configurationResult,\n isSrcDir,\n reason: 'Failed to install dependencies',\n success: false,\n }\n }\n\n // Add `@payload-config` to tsconfig.json `paths`\n await addPayloadConfigToTsConfig(projectDir, isSrcDir)\n installSpinner.stop('Successfully installed Payload and dependencies')\n return { ...configurationResult, isSrcDir, nextAppDir, success: true }\n}\n\nasync function addPayloadConfigToTsConfig(projectDir: string, isSrcDir: boolean) {\n const tsConfigPath = path.resolve(projectDir, 'tsconfig.json')\n\n // Check if tsconfig.json exists\n if (!fs.existsSync(tsConfigPath)) {\n warning(`Could not find tsconfig.json to add @payload-config path.`)\n return\n }\n const userTsConfigContent = await readFile(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = parse(userTsConfigContent) as {\n compilerOptions?: CompilerOptions\n }\n\n const hasBaseUrl =\n userTsConfig?.compilerOptions?.baseUrl && userTsConfig?.compilerOptions?.baseUrl !== '.'\n const baseUrl = hasBaseUrl ? userTsConfig?.compilerOptions?.baseUrl : './'\n\n if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) {\n userTsConfig.compilerOptions = {}\n }\n\n if (\n !userTsConfig.compilerOptions?.paths?.['@payload-config'] &&\n userTsConfig.compilerOptions?.paths\n ) {\n userTsConfig.compilerOptions.paths = {\n ...(userTsConfig.compilerOptions.paths || {}),\n '@payload-config': [`${baseUrl}${isSrcDir ? 'src/' : ''}payload.config.ts`],\n }\n await writeFile(tsConfigPath, stringify(userTsConfig, null, 2), { encoding: 'utf8' })\n }\n}\n\nasync function installAndConfigurePayload(\n args: {\n nextAppDetails: NextAppDetails\n nextConfigType: NextConfigType\n useDistFiles?: boolean\n } & InitNextArgs,\n): Promise<\n | { payloadConfigPath: string; success: true }\n | { payloadConfigPath?: string; reason: string; success: false }\n> {\n const {\n '--debug': debug,\n nextAppDetails: { isSrcDir, nextAppDir, nextConfigPath } = {},\n nextConfigType,\n projectDir,\n useDistFiles,\n } = args\n\n if (!nextAppDir || !nextConfigPath) {\n return {\n reason: 'Could not find app directory or next.config.js',\n success: false,\n }\n }\n\n const logDebug = (message: string) => {\n if (debug) {\n origDebug(message)\n }\n }\n\n if (!fs.existsSync(projectDir)) {\n return {\n reason: `Could not find specified project directory at ${projectDir}`,\n success: false,\n }\n }\n\n const templateFilesPath =\n dirname.endsWith('dist') || useDistFiles\n ? path.resolve(dirname, '../..', 'dist/template')\n : path.resolve(dirname, '../../../../templates/blank')\n\n logDebug(`Using template files from: ${templateFilesPath}`)\n\n if (!fs.existsSync(templateFilesPath)) {\n return {\n reason: `Could not find template source files from ${templateFilesPath}`,\n success: false,\n }\n } else {\n logDebug('Found template source files')\n }\n\n logDebug(`Copying template files from ${templateFilesPath} to ${nextAppDir}`)\n\n const templateSrcDir = path.resolve(templateFilesPath, isSrcDir ? '' : 'src')\n\n logDebug(`templateSrcDir: ${templateSrcDir}`)\n logDebug(`nextAppDir: ${nextAppDir}`)\n logDebug(`projectDir: ${projectDir}`)\n logDebug(`nextConfigPath: ${nextConfigPath}`)\n logDebug(`payloadConfigPath: ${path.resolve(projectDir, 'payload.config.ts')}`)\n\n logDebug(\n `isSrcDir: ${isSrcDir}. source: ${templateSrcDir}. dest: ${path.dirname(nextConfigPath)}`,\n )\n\n // This is a little clunky and needs to account for isSrcDir\n copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath))\n\n // Wrap next.config.js with withPayload\n await wrapNextConfig({ nextConfigPath, nextConfigType })\n\n return {\n payloadConfigPath: path.resolve(nextAppDir, '../payload.config.ts'),\n success: true,\n }\n}\n\nasync function installDeps(projectDir: string, packageManager: PackageManager, dbType: DbType) {\n const packagesToInstall = [\n 'payload',\n '@payloadcms/next',\n '@payloadcms/richtext-lexical',\n '@payloadcms/payload-cloud',\n ].map((pkg) => `${pkg}@beta`)\n\n packagesToInstall.push(`@payloadcms/db-${dbType}@beta`)\n\n // Match graphql version of @payloadcms/next\n packagesToInstall.push('graphql@^16.8.1')\n\n return await installPackages({ packageManager, packagesToInstall, projectDir })\n}\n\nexport async function getNextAppDetails(projectDir: string): Promise<NextAppDetails> {\n const isSrcDir = fs.existsSync(path.resolve(projectDir, 'src'))\n\n // Match next.config.js, next.config.ts, next.config.mjs, next.config.cjs\n const nextConfigPath: string | undefined = (\n await globby('next.config.(\\\\w)?(t|j)s', { absolute: true, cwd: projectDir })\n )?.[0]\n\n if (!nextConfigPath || nextConfigPath.length === 0) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath: undefined,\n nextVersion: null,\n }\n }\n\n const packageObj = await fse.readJson(path.resolve(projectDir, 'package.json'))\n // Check if Next.js version is new enough\n let nextVersion = null\n if (packageObj.dependencies?.next) {\n nextVersion = packageObj.dependencies.next\n // Match versions using regex matching groups\n const versionMatch = /(?<major>\\d+)/.exec(nextVersion)\n if (!versionMatch) {\n p.log.warn(`Could not determine Next.js version from ${nextVersion}`)\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath,\n nextVersion,\n }\n }\n\n const { major } = versionMatch.groups as { major: string }\n const majorVersion = parseInt(major)\n if (majorVersion < 15) {\n return {\n hasTopLevelLayout: false,\n isSrcDir,\n isSupportedNextVersion: false,\n nextConfigPath,\n nextVersion,\n }\n }\n }\n\n const isSupportedNextVersion = true\n\n // Check if Payload already installed\n if (packageObj.dependencies?.payload) {\n return {\n hasTopLevelLayout: false,\n isPayloadInstalled: true,\n isSrcDir,\n isSupportedNextVersion,\n nextConfigPath,\n nextVersion,\n }\n }\n\n let nextAppDir: string | undefined = (\n await globby(['**/app'], {\n absolute: true,\n cwd: projectDir,\n ignore: ['**/node_modules/**'],\n onlyDirectories: true,\n })\n )?.[0]\n\n if (!nextAppDir || nextAppDir.length === 0) {\n nextAppDir = undefined\n }\n\n const configType = getProjectType({ nextConfigPath, packageObj })\n\n const hasTopLevelLayout = nextAppDir\n ? fs.existsSync(path.resolve(nextAppDir, 'layout.tsx'))\n : false\n\n return {\n hasTopLevelLayout,\n isSrcDir,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextConfigType: configType,\n nextVersion,\n }\n}\n\nfunction getProjectType(args: {\n nextConfigPath: string\n packageObj: Record<string, unknown>\n}): NextConfigType {\n const { nextConfigPath, packageObj } = args\n\n if (nextConfigPath.endsWith('.ts')) {\n return 'ts'\n }\n\n if (nextConfigPath.endsWith('.mjs')) {\n return 'esm'\n }\n if (nextConfigPath.endsWith('.cjs')) {\n return 'cjs'\n }\n\n const packageJsonType = packageObj.type\n if (packageJsonType === 'module') {\n return 'esm'\n }\n if (packageJsonType === 'commonjs') {\n return 'cjs'\n }\n\n return 'cjs'\n}\n"],"names":["p","parse","stringify","fs","fse","globby","fileURLToPath","path","promisify","copyRecursiveSync","debug","origDebug","warning","moveMessage","installPackages","wrapNextConfig","readFile","writeFile","filename","url","dirname","initNext","args","dbType","packageManager","projectDir","nextAppDetails","getNextAppDetails","nextAppDir","createdAppDir","resolve","isSrcDir","mkdirSync","recursive","hasTopLevelLayout","nextConfigType","reason","success","log","warn","installSpinner","spinner","start","configurationResult","installAndConfigurePayload","useDistFiles","stop","installSuccess","installDeps","addPayloadConfigToTsConfig","tsConfigPath","existsSync","userTsConfigContent","encoding","userTsConfig","hasBaseUrl","compilerOptions","baseUrl","paths","nextConfigPath","logDebug","message","templateFilesPath","endsWith","templateSrcDir","payloadConfigPath","packagesToInstall","map","pkg","push","absolute","cwd","length","isSupportedNextVersion","undefined","nextVersion","packageObj","readJson","dependencies","next","versionMatch","exec","major","groups","majorVersion","parseInt","payload","isPayloadInstalled","ignore","onlyDirectories","configType","getProjectType","packageJsonType","type"],"mappings":"AAEA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,KAAK,EAAEC,SAAS,QAAQ,eAAc;AAC/C,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAIhC,SAASC,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,SAASC,SAAS,EAAEC,OAAO,QAAQ,kBAAiB;AAC7D,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,wBAAuB;AAEtD,MAAMC,WAAWR,UAAUL,GAAGa,QAAQ;AACtC,MAAMC,YAAYT,UAAUL,GAAGc,SAAS;AAExC,MAAMC,WAAWZ,cAAc,YAAYa,GAAG;AAC9C,MAAMC,UAAUb,KAAKa,OAAO,CAACF;AAmB7B,OAAO,eAAeG,SAASC,IAAkB;IAC/C,MAAM,EAAEC,QAAQA,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGH;IAEvD,MAAMI,iBAAiBJ,KAAKI,cAAc,IAAK,MAAMC,kBAAkBF;IAEvE,IAAI,CAACC,eAAeE,UAAU,EAAE;QAC9BhB,QAAQ,CAAC,gCAAgC,EAAEa,WAAW,aAAa,CAAC;QACpE,MAAMI,gBAAgBtB,KAAKuB,OAAO,CAACL,YAAYC,eAAeK,QAAQ,GAAG,YAAY;QACrF3B,IAAI4B,SAAS,CAACH,eAAe;YAAEI,WAAW;QAAK;QAC/CP,eAAeE,UAAU,GAAGC;IAC9B;IAEA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AAEQ,SAAS;QACpC,OAAO;YACLpD,mBAAmB;YACnBqD,oBAAoB;YACpBxD;YACA0C;YACAd;YACAgB;QACF;IACF;IAEA,IAAI/C,aACF,CAAA,MAAMvB,OAAO;QAAC;KAAS,EAAE;QACvBiE,UAAU;QACVC,KAAK9C;QACL+D,QAAQ;YAAC;SAAqB;QAC9BC,iBAAiB;IACnB,EAAC,GACA,CAAC,EAAE;IAEN,IAAI,CAAC7D,cAAcA,WAAW4C,MAAM,KAAK,GAAG;QAC1C5C,aAAa8C;IACf;IAEA,MAAMgB,aAAaC,eAAe;QAAEhC;QAAgBiB;IAAW;IAE/D,MAAM1C,oBAAoBN,aACtBzB,GAAGgD,UAAU,CAAC5C,KAAKuB,OAAO,CAACF,YAAY,iBACvC;IAEJ,OAAO;QACLM;QACAH;QACA0C;QACA7C;QACA+B;QACAxB,gBAAgBuD;QAChBf;IACF;AACF;AAEA,SAASgB,eAAerE,IAGvB;IACC,MAAM,EAAEqC,cAAc,EAAEiB,UAAU,EAAE,GAAGtD;IAEvC,IAAIqC,eAAeI,QAAQ,CAAC,QAAQ;QAClC,OAAO;IACT;IAEA,IAAIJ,eAAeI,QAAQ,CAAC,SAAS;QACnC,OAAO;IACT;IACA,IAAIJ,eAAeI,QAAQ,CAAC,SAAS;QACnC,OAAO;IACT;IAEA,MAAM6B,kBAAkBhB,WAAWiB,IAAI;IACvC,IAAID,oBAAoB,UAAU;QAChC,OAAO;IACT;IACA,IAAIA,oBAAoB,YAAY;QAClC,OAAO;IACT;IAEA,OAAO;AACT"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { PackageManager } from '../types.js';
|
2
|
+
export declare function installPackages(args: {
|
3
|
+
packageManager: PackageManager;
|
4
|
+
packagesToInstall: string[];
|
5
|
+
projectDir: string;
|
6
|
+
}): Promise<{
|
7
|
+
success: boolean;
|
8
|
+
}>;
|
9
|
+
//# sourceMappingURL=install-packages.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"install-packages.d.ts","sourceRoot":"","sources":["../../src/lib/install-packages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,cAAc,EAAE,cAAc,CAAA;IAC9B,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB;;GA+BA"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import execa from 'execa';
|
2
|
+
import { error, warning } from '../utils/log.js';
|
3
|
+
export async function installPackages(args) {
|
4
|
+
const { packageManager, packagesToInstall, projectDir } = args;
|
5
|
+
let exitCode = 0;
|
6
|
+
let stderr = '';
|
7
|
+
switch(packageManager){
|
8
|
+
case 'bun':
|
9
|
+
case 'pnpm':
|
10
|
+
case 'yarn':
|
11
|
+
{
|
12
|
+
if (packageManager === 'bun') {
|
13
|
+
warning('Bun support is untested.');
|
14
|
+
}
|
15
|
+
({ exitCode, stderr } = await execa(packageManager, [
|
16
|
+
'add',
|
17
|
+
...packagesToInstall
|
18
|
+
], {
|
19
|
+
cwd: projectDir
|
20
|
+
}));
|
21
|
+
break;
|
22
|
+
}
|
23
|
+
case 'npm':
|
24
|
+
{
|
25
|
+
({ exitCode, stderr } = await execa('npm', [
|
26
|
+
'install',
|
27
|
+
'--save',
|
28
|
+
...packagesToInstall
|
29
|
+
], {
|
30
|
+
cwd: projectDir
|
31
|
+
}));
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (exitCode !== 0) {
|
36
|
+
error(`Unable to install packages. Error: ${stderr}`);
|
37
|
+
}
|
38
|
+
return {
|
39
|
+
success: exitCode === 0
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
//# sourceMappingURL=install-packages.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/install-packages.ts"],"sourcesContent":["import execa from 'execa'\n\nimport type { PackageManager } from '../types.js'\n\nimport { error, warning } from '../utils/log.js'\n\nexport async function installPackages(args: {\n packageManager: PackageManager\n packagesToInstall: string[]\n projectDir: string\n}) {\n const { packageManager, packagesToInstall, projectDir } = args\n\n let exitCode = 0\n let stderr = ''\n\n switch (packageManager) {\n case 'bun':\n case 'pnpm':\n case 'yarn': {\n if (packageManager === 'bun') {\n warning('Bun support is untested.')\n }\n ;({ exitCode, stderr } = await execa(packageManager, ['add', ...packagesToInstall], {\n cwd: projectDir,\n }))\n break\n }\n case 'npm': {\n ;({ exitCode, stderr } = await execa('npm', ['install', '--save', ...packagesToInstall], {\n cwd: projectDir,\n }))\n break\n }\n }\n\n if (exitCode !== 0) {\n error(`Unable to install packages. Error: ${stderr}`)\n }\n\n return { success: exitCode === 0 }\n}\n"],"names":["execa","error","warning","installPackages","args","packageManager","packagesToInstall","projectDir","exitCode","stderr","cwd","success"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAIzB,SAASC,KAAK,EAAEC,OAAO,QAAQ,kBAAiB;AAEhD,OAAO,eAAeC,gBAAgBC,IAIrC;IACC,MAAM,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,UAAU,EAAE,GAAGH;IAE1D,IAAII,WAAW;IACf,IAAIC,SAAS;IAEb,OAAQJ;QACN,KAAK;QACL,KAAK;QACL,KAAK;YAAQ;gBACX,IAAIA,mBAAmB,OAAO;oBAC5BH,QAAQ;gBACV;gBACE,CAAA,EAAEM,QAAQ,EAAEC,MAAM,EAAE,GAAG,MAAMT,MAAMK,gBAAgB;oBAAC;uBAAUC;iBAAkB,EAAE;oBAClFI,KAAKH;gBACP,EAAC;gBACD;YACF;QACA,KAAK;YAAO;gBACR,CAAA,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAG,MAAMT,MAAM,OAAO;oBAAC;oBAAW;uBAAaM;iBAAkB,EAAE;oBACvFI,KAAKH;gBACP,EAAC;gBACD;YACF;IACF;IAEA,IAAIC,aAAa,GAAG;QAClBP,MAAM,CAAC,mCAAmC,EAAEQ,OAAO,CAAC;IACtD;IAEA,OAAO;QAAEE,SAASH,aAAa;IAAE;AACnC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parse-project-name.d.ts","sourceRoot":"","sources":["../../src/lib/parse-project-name.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"parse-project-name.d.ts","sourceRoot":"","sources":["../../src/lib/parse-project-name.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBrE"}
|
@@ -1,12 +1,18 @@
|
|
1
1
|
import * as p from '@clack/prompts';
|
2
2
|
import slugify from '@sindresorhus/slugify';
|
3
3
|
export async function parseProjectName(args) {
|
4
|
-
if (args['--name'])
|
5
|
-
|
4
|
+
if (args['--name']) {
|
5
|
+
return slugify(args['--name']);
|
6
|
+
}
|
7
|
+
if (args._[0]) {
|
8
|
+
return slugify(args._[0]);
|
9
|
+
}
|
6
10
|
const projectName = await p.text({
|
7
11
|
message: 'Project name?',
|
8
12
|
validate: (value)=>{
|
9
|
-
if (!value)
|
13
|
+
if (!value) {
|
14
|
+
return 'Please enter a project name.';
|
15
|
+
}
|
10
16
|
}
|
11
17
|
});
|
12
18
|
if (p.isCancel(projectName)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/lib/parse-project-name.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\n\nimport type { CliArgs } from '../types.js'\n\nexport async function parseProjectName(args: CliArgs): Promise<string> {\n if (args['--name']) return slugify(args['--name'])\n if (args._[0]) return slugify(args._[0])\n\n const projectName = await p.text({\n message: 'Project name?',\n validate: (value) => {\n if (!value) return 'Please enter a project name.'\n },\n })\n if (p.isCancel(projectName)) {\n process.exit(0)\n }\n return slugify(projectName)\n}\n"],"names":["p","slugify","parseProjectName","args","_","projectName","text","message","validate","value","isCancel","process","exit"],"
|
1
|
+
{"version":3,"sources":["../../src/lib/parse-project-name.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\n\nimport type { CliArgs } from '../types.js'\n\nexport async function parseProjectName(args: CliArgs): Promise<string> {\n if (args['--name']) {\n return slugify(args['--name'])\n }\n if (args._[0]) {\n return slugify(args._[0])\n }\n\n const projectName = await p.text({\n message: 'Project name?',\n validate: (value) => {\n if (!value) {\n return 'Please enter a project name.'\n }\n },\n })\n if (p.isCancel(projectName)) {\n process.exit(0)\n }\n return slugify(projectName)\n}\n"],"names":["p","slugify","parseProjectName","args","_","projectName","text","message","validate","value","isCancel","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAI3C,OAAO,eAAeC,iBAAiBC,IAAa;IAClD,IAAIA,IAAI,CAAC,SAAS,EAAE;QAClB,OAAOF,QAAQE,IAAI,CAAC,SAAS;IAC/B;IACA,IAAIA,KAAKC,CAAC,CAAC,EAAE,EAAE;QACb,OAAOH,QAAQE,KAAKC,CAAC,CAAC,EAAE;IAC1B;IAEA,MAAMC,cAAc,MAAML,EAAEM,IAAI,CAAC;QAC/BC,SAAS;QACTC,UAAU,CAACC;YACT,IAAI,CAACA,OAAO;gBACV,OAAO;YACT;QACF;IACF;IACA,IAAIT,EAAEU,QAAQ,CAACL,cAAc;QAC3BM,QAAQC,IAAI,CAAC;IACf;IACA,OAAOX,QAAQI;AACjB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parse-template.d.ts","sourceRoot":"","sources":["../../src/lib/parse-template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE3D,wBAAsB,aAAa,CACjC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,eAAe,EAAE,GAChC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,
|
1
|
+
{"version":3,"file":"parse-template.d.ts","sourceRoot":"","sources":["../../src/lib/parse-template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE3D,wBAAsB,aAAa,CACjC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,eAAe,EAAE,GAChC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CA0BtC"}
|
@@ -3,7 +3,9 @@ export async function parseTemplate(args, validTemplates) {
|
|
3
3
|
if (args['--template']) {
|
4
4
|
const templateName = args['--template'];
|
5
5
|
const template = validTemplates.find((t)=>t.name === templateName);
|
6
|
-
if (!template)
|
6
|
+
if (!template) {
|
7
|
+
throw new Error('Invalid template given');
|
8
|
+
}
|
7
9
|
return template;
|
8
10
|
}
|
9
11
|
const response = await p.select({
|
@@ -1 +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":["p","parseTemplate","args","validTemplates","templateName","template","find","t","name","Error","response","select","message","options","map","label","value","isCancel","process","exit"],"
|
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) {\n throw new Error('Invalid template given')\n }\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":["p","parseTemplate","args","validTemplates","templateName","template","find","t","name","Error","response","select","message","options","map","label","value","isCancel","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AAInC,OAAO,eAAeC,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;YACb,MAAM,IAAII,MAAM;QAClB;QACA,OAAOJ;IACT;IAEA,MAAMK,WAAW,MAAMV,EAAEW,MAAM,CAA6C;QAC1EC,SAAS;QACTC,SAASV,eAAeW,GAAG,CAAC,CAACd;YAC3B,OAAO;gBACLe,OAAOf,EAAEQ,IAAI;gBACbQ,OAAOhB,EAAEQ,IAAI;YACf;QACF;IACF;IACA,IAAIR,EAAEiB,QAAQ,CAACP,WAAW;QACxBQ,QAAQC,IAAI,CAAC;IACf;IAEA,MAAMd,WAAWF,eAAeG,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKE;IAEvD,OAAOL;AACT"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { DbType, StorageAdapterType } from '../types.js';
|
2
|
+
type DbAdapterReplacement = {
|
3
|
+
configReplacement: (envName?: string) => string[];
|
4
|
+
importReplacement: string;
|
5
|
+
packageName: string;
|
6
|
+
};
|
7
|
+
export declare const dbReplacements: Record<DbType, DbAdapterReplacement>;
|
8
|
+
type StorageAdapterReplacement = {
|
9
|
+
configReplacement: string[];
|
10
|
+
importReplacement?: string;
|
11
|
+
packageName?: string;
|
12
|
+
};
|
13
|
+
export declare const storageReplacements: Record<StorageAdapterType, StorageAdapterReplacement>;
|
14
|
+
/**
|
15
|
+
* Generic config replacement
|
16
|
+
*/
|
17
|
+
type ConfigReplacement = {
|
18
|
+
configReplacement: {
|
19
|
+
match: string;
|
20
|
+
replacement: string;
|
21
|
+
};
|
22
|
+
importReplacement: string;
|
23
|
+
packageName: string;
|
24
|
+
};
|
25
|
+
export declare const configReplacements: Record<string, ConfigReplacement>;
|
26
|
+
export {};
|
27
|
+
//# sourceMappingURL=replacements.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"replacements.d.ts","sourceRoot":"","sources":["../../src/lib/replacements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE7D,KAAK,oBAAoB,GAAG;IAC1B,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IACjD,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAiDD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAK/D,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AA4BD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE,yBAAyB,CAIrF,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG;IACvB,iBAAiB,EAAE;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAUhE,CAAA"}
|