create-payload-app 1.0.0 → 3.0.0-alpha.50
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -0
- package/dist/lib/configure-payload-config.d.ts +11 -0
- package/dist/lib/configure-payload-config.d.ts.map +1 -0
- package/dist/lib/configure-payload-config.js +15 -53
- package/dist/lib/configure-payload-config.js.map +1 -0
- package/dist/lib/create-project.d.ts +14 -0
- package/dist/lib/create-project.d.ts.map +1 -0
- package/dist/lib/create-project.js +84 -24
- package/dist/lib/create-project.js.map +1 -0
- package/dist/lib/create-project.spec.d.ts +2 -0
- package/dist/lib/create-project.spec.d.ts.map +1 -0
- package/dist/lib/create-project.spec.js +30 -75
- package/dist/lib/create-project.spec.js.map +1 -0
- package/dist/lib/generate-secret.d.ts +2 -0
- package/dist/lib/generate-secret.d.ts.map +1 -0
- package/dist/lib/generate-secret.js +1 -1
- package/dist/lib/generate-secret.js.map +1 -0
- package/dist/lib/init-next.d.ts +29 -0
- package/dist/lib/init-next.d.ts.map +1 -0
- package/dist/lib/init-next.js +285 -0
- package/dist/lib/init-next.js.map +1 -0
- package/dist/lib/packages.d.ts +9 -0
- package/dist/lib/packages.d.ts.map +1 -0
- package/dist/lib/packages.js +8 -52
- package/dist/lib/packages.js.map +1 -0
- package/dist/lib/parse-project-name.d.ts +3 -0
- package/dist/lib/parse-project-name.d.ts.map +1 -0
- package/dist/lib/parse-project-name.js +53 -12
- package/dist/lib/parse-project-name.js.map +1 -0
- package/dist/lib/parse-template.d.ts +3 -0
- package/dist/lib/parse-template.d.ts.map +1 -0
- package/dist/lib/parse-template.js +50 -20
- package/dist/lib/parse-template.js.map +1 -0
- package/dist/lib/select-db.d.ts +3 -0
- package/dist/lib/select-db.d.ts.map +1 -0
- package/dist/lib/select-db.js +72 -31
- package/dist/lib/select-db.js.map +1 -0
- package/dist/lib/templates.d.ts +4 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +17 -11
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/wrap-next-config.d.ts +12 -0
- package/dist/lib/wrap-next-config.d.ts.map +1 -0
- package/dist/lib/wrap-next-config.js +110 -0
- package/dist/lib/wrap-next-config.js.map +1 -0
- package/dist/lib/wrap-next-config.spec.d.ts +2 -0
- package/dist/lib/wrap-next-config.spec.d.ts.map +1 -0
- package/dist/lib/wrap-next-config.spec.js +98 -0
- package/dist/lib/wrap-next-config.spec.js.map +1 -0
- package/dist/lib/write-env-file.d.ts +10 -0
- package/dist/lib/write-env-file.d.ts.map +1 -0
- package/dist/lib/write-env-file.js +9 -6
- package/dist/lib/write-env-file.js.map +1 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +176 -60
- package/dist/main.js.map +1 -0
- package/dist/scripts/pack-template-files.d.ts +2 -0
- package/dist/scripts/pack-template-files.d.ts.map +1 -0
- package/dist/scripts/pack-template-files.js +43 -0
- package/dist/scripts/pack-template-files.js.map +1 -0
- package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +17 -0
- package/dist/template/src/app/(payload)/api/[...slug]/route.ts +9 -0
- package/dist/template/src/app/(payload)/api/graphql/route.ts +6 -0
- package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +6 -0
- package/dist/template/src/app/(payload)/custom.scss +0 -0
- package/dist/template/src/app/(payload)/layout.tsx +16 -0
- package/dist/template/src/app/my-route/route.ts +14 -0
- package/dist/template/src/collections/Users.ts +13 -0
- package/dist/template/src/payload.config.ts +38 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -0
- package/dist/utils/copy-recursive-sync.d.ts +5 -0
- package/dist/utils/copy-recursive-sync.d.ts.map +1 -0
- package/dist/utils/copy-recursive-sync.js +34 -0
- package/dist/utils/copy-recursive-sync.js.map +1 -0
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +62 -15
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/messages.d.ts +11 -0
- package/dist/utils/messages.d.ts.map +1 -0
- package/dist/utils/messages.js +47 -16
- package/dist/utils/messages.js.map +1 -0
- package/package.json +27 -10
package/README.md
CHANGED
package/dist/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const _main = require("./main");
|
6
|
-
const _log = require("./utils/log");
|
5
|
+
const _main = require("./main.js");
|
6
|
+
const _log = require("./utils/log.js");
|
7
7
|
async function main() {
|
8
8
|
await new _main.Main().init();
|
9
9
|
}
|
10
10
|
main().catch((e)=>(0, _log.error)(`An error has occurred: ${e instanceof Error ? e.message : e}`));
|
11
11
|
|
12
|
-
//# sourceMappingURL=
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Main } from './main.js'\nimport { error } from './utils/log.js'\n\nasync function main(): Promise<void> {\n await new Main().init()\n}\n\nmain().catch((e) => error(`An error has occurred: ${e instanceof Error ? e.message : e}`))\n"],"names":["main","Main","init","catch","e","error","Error","message"],"mappings":";;;;sBAAqB;qBACC;AAEtB,eAAeA;IACb,MAAM,IAAIC,UAAI,GAAGC,IAAI;AACvB;AAEAF,OAAOG,KAAK,CAAC,CAACC,IAAMC,IAAAA,UAAK,EAAC,CAAC,uBAAuB,EAAED,aAAaE,QAAQF,EAAEG,OAAO,GAAGH,EAAE,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { DbDetails } from '../types.js';
|
2
|
+
/** Update payload config with necessary imports and adapters */
|
3
|
+
export declare function configurePayloadConfig(args: {
|
4
|
+
dbDetails: DbDetails | undefined;
|
5
|
+
projectDirOrConfigPath: {
|
6
|
+
payloadConfigPath: string;
|
7
|
+
} | {
|
8
|
+
projectDir: string;
|
9
|
+
};
|
10
|
+
}): Promise<void>;
|
11
|
+
//# sourceMappingURL=configure-payload-config.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"configure-payload-config.d.ts","sourceRoot":"","sources":["../../src/lib/configure-payload-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAK5C,gEAAgE;AAChE,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,sBAAsB,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/E,GAAG,OAAO,CAAC,IAAI,CAAC,CA6DhB"}
|
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "configurePayloadConfig", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
12
|
-
const
|
13
|
-
const _log = require("../utils/log");
|
14
|
-
const _packages = require("./packages");
|
12
|
+
const _globby = /*#__PURE__*/ _interop_require_default(require("globby"));
|
13
|
+
const _log = require("../utils/log.js");
|
14
|
+
const _packages = require("./packages.js");
|
15
15
|
function _interop_require_default(obj) {
|
16
16
|
return obj && obj.__esModule ? obj : {
|
17
17
|
default: obj
|
@@ -21,67 +21,29 @@ async function configurePayloadConfig(args) {
|
|
21
21
|
if (!args.dbDetails) {
|
22
22
|
return;
|
23
23
|
}
|
24
|
-
// Update package.json
|
25
|
-
const packageJsonPath = _path.default.resolve(args.projectDir, 'package.json');
|
26
24
|
try {
|
27
|
-
const packageObj = await _fsextra.default.readJson(packageJsonPath);
|
28
|
-
packageObj.dependencies['payload'] = '^2.0.0';
|
29
|
-
const dbPackage = _packages.dbPackages[args.dbDetails.type];
|
30
|
-
const bundlerPackage = _packages.bundlerPackages['webpack'];
|
31
|
-
const editorPackage = _packages.editorPackages['slate'];
|
32
|
-
// Delete all other db adapters
|
33
|
-
Object.values(_packages.dbPackages).forEach((p)=>{
|
34
|
-
if (p.packageName !== dbPackage.packageName) {
|
35
|
-
delete packageObj.dependencies[p.packageName];
|
36
|
-
}
|
37
|
-
});
|
38
|
-
packageObj.dependencies[dbPackage.packageName] = dbPackage.version;
|
39
|
-
packageObj.dependencies[bundlerPackage.packageName] = bundlerPackage.version;
|
40
|
-
packageObj.dependencies[editorPackage.packageName] = editorPackage.version;
|
41
|
-
await _fsextra.default.writeJson(packageJsonPath, packageObj, {
|
42
|
-
spaces: 2
|
43
|
-
});
|
44
|
-
} catch (err) {
|
45
|
-
(0, _log.warning)('Unable to update name in package.json');
|
46
|
-
}
|
47
|
-
try {
|
48
|
-
const possiblePaths = [
|
49
|
-
_path.default.resolve(args.projectDir, 'src/payload.config.ts'),
|
50
|
-
_path.default.resolve(args.projectDir, 'src/payload/payload.config.ts')
|
51
|
-
];
|
52
25
|
let payloadConfigPath;
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
26
|
+
if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {
|
27
|
+
payloadConfigPath = (await (0, _globby.default)('**/payload.config.ts', {
|
28
|
+
absolute: true,
|
29
|
+
cwd: args.projectDirOrConfigPath.projectDir
|
30
|
+
}))?.[0];
|
31
|
+
} else {
|
32
|
+
payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath;
|
33
|
+
}
|
58
34
|
if (!payloadConfigPath) {
|
59
|
-
(0, _log.warning)('Unable to update payload.config.ts with plugins');
|
35
|
+
(0, _log.warning)('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.');
|
60
36
|
return;
|
61
37
|
}
|
62
38
|
const configContent = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8');
|
63
39
|
const configLines = configContent.split('\n');
|
64
|
-
const dbReplacement = _packages.
|
65
|
-
const bundlerReplacement = _packages.bundlerPackages['webpack'];
|
66
|
-
const editorReplacement = _packages.editorPackages['slate'];
|
40
|
+
const dbReplacement = _packages.dbReplacements[args.dbDetails.type];
|
67
41
|
let dbConfigStartLineIndex;
|
68
42
|
let dbConfigEndLineIndex;
|
69
43
|
configLines.forEach((l, i)=>{
|
70
44
|
if (l.includes('// database-adapter-import')) {
|
71
45
|
configLines[i] = dbReplacement.importReplacement;
|
72
46
|
}
|
73
|
-
if (l.includes('// bundler-import')) {
|
74
|
-
configLines[i] = bundlerReplacement.importReplacement;
|
75
|
-
}
|
76
|
-
if (l.includes('// bundler-config')) {
|
77
|
-
configLines[i] = bundlerReplacement.configReplacement;
|
78
|
-
}
|
79
|
-
if (l.includes('// editor-import')) {
|
80
|
-
configLines[i] = editorReplacement.importReplacement;
|
81
|
-
}
|
82
|
-
if (l.includes('// editor-config')) {
|
83
|
-
configLines[i] = editorReplacement.configReplacement;
|
84
|
-
}
|
85
47
|
if (l.includes('// database-adapter-config-start')) {
|
86
48
|
dbConfigStartLineIndex = i;
|
87
49
|
}
|
@@ -97,8 +59,8 @@ async function configurePayloadConfig(args) {
|
|
97
59
|
}
|
98
60
|
_fsextra.default.writeFileSync(payloadConfigPath, configLines.join('\n'));
|
99
61
|
} catch (err) {
|
100
|
-
(0, _log.warning)(
|
62
|
+
(0, _log.warning)(`Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`);
|
101
63
|
}
|
102
64
|
}
|
103
65
|
|
104
|
-
//# sourceMappingURL=
|
66
|
+
//# sourceMappingURL=configure-payload-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\n\nimport type { DbDetails } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { dbReplacements } from './packages.js'\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbDetails: DbDetails | undefined\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n}): Promise<void> {\n if (!args.dbDetails) {\n return\n }\n\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const configContent = fse.readFileSync(payloadConfigPath, 'utf-8')\n const configLines = configContent.split('\\n')\n\n const dbReplacement = dbReplacements[args.dbDetails.type]\n\n let dbConfigStartLineIndex: number | undefined\n let dbConfigEndLineIndex: number | undefined\n\n configLines.forEach((l, i) => {\n if (l.includes('// database-adapter-import')) {\n configLines[i] = dbReplacement.importReplacement\n }\n\n if (l.includes('// database-adapter-config-start')) {\n dbConfigStartLineIndex = i\n }\n if (l.includes('// database-adapter-config-end')) {\n dbConfigEndLineIndex = i\n }\n })\n\n if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) {\n warning('Unable to update payload.config.ts with database adapter import')\n } else {\n // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`\n configLines.splice(\n dbConfigStartLineIndex,\n dbConfigEndLineIndex - dbConfigStartLineIndex + 1,\n ...dbReplacement.configReplacement,\n )\n }\n\n fse.writeFileSync(payloadConfigPath, configLines.join('\\n'))\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["configurePayloadConfig","args","dbDetails","payloadConfigPath","projectDirOrConfigPath","globby","absolute","cwd","projectDir","warning","configContent","fse","readFileSync","configLines","split","dbReplacement","dbReplacements","type","dbConfigStartLineIndex","dbConfigEndLineIndex","forEach","l","i","includes","importReplacement","splice","configReplacement","writeFileSync","join","err","Error","message"],"mappings":";;;;+BASsBA;;;eAAAA;;;gEATN;+DACG;qBAIK;0BACO;;;;;;AAGxB,eAAeA,uBAAuBC,IAG5C;IACC,IAAI,CAACA,KAAKC,SAAS,EAAE;QACnB;IACF;IAEA,IAAI;QACF,IAAIC;QACJ,IAAI,CAAE,CAAA,uBAAuBF,KAAKG,sBAAsB,AAAD,GAAI;YACzDD,oBACE,CAAA,MAAME,IAAAA,eAAM,EAAC,wBAAwB;gBACnCC,UAAU;gBACVC,KAAKN,KAAKG,sBAAsB,CAACI,UAAU;YAC7C,EAAC,GACA,CAAC,EAAE;QACR,OAAO;YACLL,oBAAoBF,KAAKG,sBAAsB,CAACD,iBAAiB;QACnE;QAEA,IAAI,CAACA,mBAAmB;YACtBM,IAAAA,YAAO,EAAC;YACR;QACF;QAEA,MAAMC,gBAAgBC,gBAAG,CAACC,YAAY,CAACT,mBAAmB;QAC1D,MAAMU,cAAcH,cAAcI,KAAK,CAAC;QAExC,MAAMC,gBAAgBC,wBAAc,CAACf,KAAKC,SAAS,CAACe,IAAI,CAAC;QAEzD,IAAIC;QACJ,IAAIC;QAEJN,YAAYO,OAAO,CAAC,CAACC,GAAGC;YACtB,IAAID,EAAEE,QAAQ,CAAC,+BAA+B;gBAC5CV,WAAW,CAACS,EAAE,GAAGP,cAAcS,iBAAiB;YAClD;YAEA,IAAIH,EAAEE,QAAQ,CAAC,qCAAqC;gBAClDL,yBAAyBI;YAC3B;YACA,IAAID,EAAEE,QAAQ,CAAC,mCAAmC;gBAChDJ,uBAAuBG;YACzB;QACF;QAEA,IAAI,CAACJ,0BAA0B,CAACC,sBAAsB;YACpDV,IAAAA,YAAO,EAAC;QACV,OAAO;YACL,iGAAiG;YACjGI,YAAYY,MAAM,CAChBP,wBACAC,uBAAuBD,yBAAyB,MAC7CH,cAAcW,iBAAiB;QAEtC;QAEAf,gBAAG,CAACgB,aAAa,CAACxB,mBAAmBU,YAAYe,IAAI,CAAC;IACxD,EAAE,OAAOC,KAAc;QACrBpB,IAAAA,YAAO,EACL,CAAC,iDAAiD,EAAEoB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,GAAG,CAAC;IAEjG;AACF"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { CliArgs, DbDetails, PackageManager, ProjectTemplate } from '../types.js';
|
2
|
+
export declare function createProject(args: {
|
3
|
+
cliArgs: CliArgs;
|
4
|
+
dbDetails?: DbDetails;
|
5
|
+
packageManager: PackageManager;
|
6
|
+
projectDir: string;
|
7
|
+
projectName: string;
|
8
|
+
template: ProjectTemplate;
|
9
|
+
}): Promise<void>;
|
10
|
+
export declare function updatePackageJSON(args: {
|
11
|
+
projectDir: string;
|
12
|
+
projectName: string;
|
13
|
+
}): Promise<void>;
|
14
|
+
//# sourceMappingURL=create-project.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../src/lib/create-project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA2CtF,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,eAAe,CAAA;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB"}
|
@@ -16,19 +16,63 @@ _export(exports, {
|
|
16
16
|
return updatePackageJSON;
|
17
17
|
}
|
18
18
|
});
|
19
|
+
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
|
19
20
|
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
20
21
|
const _degit = /*#__PURE__*/ _interop_require_default(require("degit"));
|
21
22
|
const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
|
22
23
|
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
23
|
-
const
|
24
|
+
const _nodeurl = require("node:url");
|
24
25
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
25
|
-
const _log = require("../utils/log");
|
26
|
-
const _configurepayloadconfig = require("./configure-payload-config");
|
26
|
+
const _log = require("../utils/log.js");
|
27
|
+
const _configurepayloadconfig = require("./configure-payload-config.js");
|
27
28
|
function _interop_require_default(obj) {
|
28
29
|
return obj && obj.__esModule ? obj : {
|
29
30
|
default: obj
|
30
31
|
};
|
31
32
|
}
|
33
|
+
function _getRequireWildcardCache(nodeInterop) {
|
34
|
+
if (typeof WeakMap !== "function") return null;
|
35
|
+
var cacheBabelInterop = new WeakMap();
|
36
|
+
var cacheNodeInterop = new WeakMap();
|
37
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
38
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
39
|
+
})(nodeInterop);
|
40
|
+
}
|
41
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
42
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
43
|
+
return obj;
|
44
|
+
}
|
45
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
46
|
+
return {
|
47
|
+
default: obj
|
48
|
+
};
|
49
|
+
}
|
50
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
51
|
+
if (cache && cache.has(obj)) {
|
52
|
+
return cache.get(obj);
|
53
|
+
}
|
54
|
+
var newObj = {
|
55
|
+
__proto__: null
|
56
|
+
};
|
57
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
58
|
+
for(var key in obj){
|
59
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
60
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
61
|
+
if (desc && (desc.get || desc.set)) {
|
62
|
+
Object.defineProperty(newObj, key, desc);
|
63
|
+
} else {
|
64
|
+
newObj[key] = obj[key];
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
newObj.default = obj;
|
69
|
+
if (cache) {
|
70
|
+
cache.set(obj, newObj);
|
71
|
+
}
|
72
|
+
return newObj;
|
73
|
+
}
|
74
|
+
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
|
75
|
+
const dirname = _path.default.dirname(filename);
|
32
76
|
async function createOrFindProjectDir(projectDir) {
|
33
77
|
const pathExists = await _fsextra.default.pathExists(projectDir);
|
34
78
|
if (!pathExists) {
|
@@ -52,46 +96,62 @@ async function installDeps(args) {
|
|
52
96
|
});
|
53
97
|
return true;
|
54
98
|
} catch (err) {
|
55
|
-
|
56
|
-
err
|
57
|
-
});
|
99
|
+
(0, _log.error)(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`);
|
58
100
|
return false;
|
59
101
|
}
|
60
102
|
}
|
61
103
|
async function createProject(args) {
|
62
104
|
const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args;
|
105
|
+
if (cliArgs['--dry-run']) {
|
106
|
+
(0, _log.debug)(`Dry run: Creating project in ${_chalk.default.green(projectDir)}`);
|
107
|
+
return;
|
108
|
+
}
|
63
109
|
await createOrFindProjectDir(projectDir);
|
64
|
-
|
65
|
-
|
66
|
-
const
|
110
|
+
if (cliArgs['--local-template']) {
|
111
|
+
// Copy template from local path. For development purposes.
|
112
|
+
const localTemplate = _path.default.resolve(dirname, '../../../../templates/', cliArgs['--local-template']);
|
113
|
+
await _fsextra.default.copy(localTemplate, projectDir);
|
114
|
+
} else if ('url' in template) {
|
115
|
+
let templateUrl = template.url;
|
116
|
+
if (cliArgs['--template-branch']) {
|
117
|
+
templateUrl = `${template.url}#${cliArgs['--template-branch']}`;
|
118
|
+
(0, _log.debug)(`Using template url: ${templateUrl}`);
|
119
|
+
}
|
120
|
+
const emitter = (0, _degit.default)(templateUrl);
|
67
121
|
await emitter.clone(projectDir);
|
68
122
|
}
|
69
|
-
const spinner =
|
123
|
+
const spinner = _prompts.spinner();
|
124
|
+
spinner.start('Checking latest Payload version...');
|
70
125
|
await updatePackageJSON({
|
71
126
|
projectDir,
|
72
127
|
projectName
|
73
128
|
});
|
129
|
+
spinner.message('Configuring Payload...');
|
74
130
|
await (0, _configurepayloadconfig.configurePayloadConfig)({
|
75
131
|
dbDetails,
|
76
|
-
|
132
|
+
projectDirOrConfigPath: {
|
133
|
+
projectDir
|
134
|
+
}
|
77
135
|
});
|
78
136
|
// Remove yarn.lock file. This is only desired in Payload Cloud.
|
79
137
|
const lockPath = _path.default.resolve(projectDir, 'yarn.lock');
|
80
138
|
if (_fsextra.default.existsSync(lockPath)) {
|
81
139
|
await _fsextra.default.remove(lockPath);
|
82
140
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
141
|
+
if (!cliArgs['--no-deps']) {
|
142
|
+
spinner.message('Installing dependencies...');
|
143
|
+
const result = await installDeps({
|
144
|
+
cliArgs,
|
145
|
+
packageManager,
|
146
|
+
projectDir
|
147
|
+
});
|
148
|
+
if (result) {
|
149
|
+
spinner.stop('Successfully installed Payload and dependencies');
|
150
|
+
} else {
|
151
|
+
spinner.stop('Error installing dependencies', 1);
|
152
|
+
}
|
93
153
|
} else {
|
94
|
-
|
154
|
+
spinner.stop('Dependency installation skipped');
|
95
155
|
}
|
96
156
|
}
|
97
157
|
async function updatePackageJSON(args) {
|
@@ -104,8 +164,8 @@ async function updatePackageJSON(args) {
|
|
104
164
|
spaces: 2
|
105
165
|
});
|
106
166
|
} catch (err) {
|
107
|
-
(0, _log.warning)(
|
167
|
+
(0, _log.warning)(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`);
|
108
168
|
}
|
109
169
|
}
|
110
170
|
|
111
|
-
//# sourceMappingURL=
|
171
|
+
//# sourceMappingURL=create-project.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/create-project.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport chalk from 'chalk'\nimport degit from 'degit'\nimport execa from 'execa'\nimport fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nimport type { CliArgs, DbDetails, PackageManager, ProjectTemplate } from '../types.js'\n\nimport { debug, error, warning } from '../utils/log.js'\nimport { configurePayloadConfig } from './configure-payload-config.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nasync function createOrFindProjectDir(projectDir: string): Promise<void> {\n const pathExists = await fse.pathExists(projectDir)\n if (!pathExists) {\n await fse.mkdir(projectDir)\n }\n}\n\nasync function installDeps(args: {\n cliArgs: CliArgs\n packageManager: PackageManager\n projectDir: string\n}): Promise<boolean> {\n const { cliArgs, packageManager, projectDir } = args\n if (cliArgs['--no-deps']) {\n return true\n }\n let installCmd = 'npm install --legacy-peer-deps'\n\n if (packageManager === 'yarn') {\n installCmd = 'yarn'\n } else if (packageManager === 'pnpm') {\n installCmd = 'pnpm install'\n }\n\n try {\n await execa.command(installCmd, {\n cwd: path.resolve(projectDir),\n })\n return true\n } catch (err: unknown) {\n error(`Error installing dependencies${err instanceof Error ? `: ${err.message}` : ''}.`)\n return false\n }\n}\n\nexport async function createProject(args: {\n cliArgs: CliArgs\n dbDetails?: DbDetails\n packageManager: PackageManager\n projectDir: string\n projectName: string\n template: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`Dry run: Creating project in ${chalk.green(projectDir)}`)\n return\n }\n\n await createOrFindProjectDir(projectDir)\n\n if (cliArgs['--local-template']) {\n // Copy template from local path. For development purposes.\n const localTemplate = path.resolve(\n dirname,\n '../../../../templates/',\n cliArgs['--local-template'],\n )\n await fse.copy(localTemplate, projectDir)\n } else if ('url' in template) {\n let templateUrl = template.url\n if (cliArgs['--template-branch']) {\n templateUrl = `${template.url}#${cliArgs['--template-branch']}`\n debug(`Using template url: ${templateUrl}`)\n }\n const emitter = degit(templateUrl)\n await emitter.clone(projectDir)\n }\n\n const spinner = p.spinner()\n spinner.start('Checking latest Payload version...')\n\n await updatePackageJSON({ projectDir, projectName })\n spinner.message('Configuring Payload...')\n await configurePayloadConfig({ dbDetails, projectDirOrConfigPath: { projectDir } })\n\n // Remove yarn.lock file. This is only desired in Payload Cloud.\n const lockPath = path.resolve(projectDir, 'yarn.lock')\n if (fse.existsSync(lockPath)) {\n await fse.remove(lockPath)\n }\n\n if (!cliArgs['--no-deps']) {\n spinner.message('Installing dependencies...')\n const result = await installDeps({ cliArgs, packageManager, projectDir })\n if (result) {\n spinner.stop('Successfully installed Payload and dependencies')\n } else {\n spinner.stop('Error installing dependencies', 1)\n }\n } else {\n spinner.stop('Dependency installation skipped')\n }\n}\n\nexport async function updatePackageJSON(args: {\n projectDir: string\n projectName: string\n}): Promise<void> {\n const { projectDir, projectName } = args\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n try {\n const packageObj = await fse.readJson(packageJsonPath)\n packageObj.name = projectName\n await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })\n } catch (err: unknown) {\n warning(`Unable to update name in package.json. ${err instanceof Error ? err.message : ''}`)\n }\n}\n"],"names":["createProject","updatePackageJSON","filename","fileURLToPath","dirname","path","createOrFindProjectDir","projectDir","pathExists","fse","mkdir","installDeps","args","cliArgs","packageManager","installCmd","execa","command","cwd","resolve","err","error","Error","message","dbDetails","projectName","template","debug","chalk","green","localTemplate","copy","templateUrl","url","emitter","degit","clone","spinner","p","start","configurePayloadConfig","projectDirOrConfigPath","lockPath","existsSync","remove","result","stop","packageJsonPath","packageObj","readJson","name","writeJson","spaces","warning"],"mappings":";;;;;;;;;;;IAmDsBA,aAAa;eAAbA;;IA6DAC,iBAAiB;eAAjBA;;;iEAhHH;8DACD;8DACA;8DACA;gEACF;yBACc;6DACb;qBAIqB;wCACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,MAAMC,WAAWC,IAAAA,sBAAa,EAAC;AAC/B,MAAMC,UAAUC,aAAI,CAACD,OAAO,CAACF;AAE7B,eAAeI,uBAAuBC,UAAkB;IACtD,MAAMC,aAAa,MAAMC,gBAAG,CAACD,UAAU,CAACD;IACxC,IAAI,CAACC,YAAY;QACf,MAAMC,gBAAG,CAACC,KAAK,CAACH;IAClB;AACF;AAEA,eAAeI,YAAYC,IAI1B;IACC,MAAM,EAAEC,OAAO,EAAEC,cAAc,EAAEP,UAAU,EAAE,GAAGK;IAChD,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxB,OAAO;IACT;IACA,IAAIE,aAAa;IAEjB,IAAID,mBAAmB,QAAQ;QAC7BC,aAAa;IACf,OAAO,IAAID,mBAAmB,QAAQ;QACpCC,aAAa;IACf;IAEA,IAAI;QACF,MAAMC,cAAK,CAACC,OAAO,CAACF,YAAY;YAC9BG,KAAKb,aAAI,CAACc,OAAO,CAACZ;QACpB;QACA,OAAO;IACT,EAAE,OAAOa,KAAc;QACrBC,IAAAA,UAAK,EAAC,CAAC,6BAA6B,EAAED,eAAeE,QAAQ,CAAC,EAAE,EAAEF,IAAIG,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QACvF,OAAO;IACT;AACF;AAEO,eAAevB,cAAcY,IAOnC;IACC,MAAM,EAAEC,OAAO,EAAEW,SAAS,EAAEV,cAAc,EAAEP,UAAU,EAAEkB,WAAW,EAAEC,QAAQ,EAAE,GAAGd;IAElF,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBc,IAAAA,UA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C,iCAAiC;QAChD;IACF,OAAO;QACLT,QAAQS,IAAI,CAAC;IACf;AACF;AAEO,eAAe7C,kBAAkBW,IAGvC;IACC,MAAM,EAAEL,UAAU,EAAEkB,WAAW,EAAE,GAAGb;IACpC,MAAMmC,kBAAkB1C,aAAI,CAACc,OAAO,CAACZ,YAAY;IACjD,IAAI;QACF,MAAMyC,aAAa,MAAMvC,gBAAG,CAACwC,QAAQ,CAACF;QACtCC,WAAWE,IAAI,GAAGzB;QAClB,MAAMhB,gBAAG,CAAC0C,SAAS,CAACJ,iBAAiBC,YAAY;YAAEI,QAAQ;QAAE;IAC/D,EAAE,OAAOhC,KAAc;QACrBiC,IAAAA,YAAO,EAAC,CAAC,uCAAuC,EAAEjC,eAAeE,QAAQF,IAAIG,OAAO,GAAG,GAAG,CAAC;IAC7F;AACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-project.spec.d.ts","sourceRoot":"","sources":["../../src/lib/create-project.spec.ts"],"names":[],"mappings":""}
|
@@ -4,15 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
6
6
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
7
|
-
const _createproject = require("./create-project");
|
8
|
-
const
|
9
|
-
const
|
7
|
+
const _createproject = require("./create-project.js");
|
8
|
+
const _nodeurl = require("node:url");
|
9
|
+
const _packages = require("./packages.js");
|
10
|
+
const _templates = require("./templates.js");
|
11
|
+
const _globby = /*#__PURE__*/ _interop_require_default(require("globby"));
|
10
12
|
function _interop_require_default(obj) {
|
11
13
|
return obj && obj.__esModule ? obj : {
|
12
14
|
default: obj
|
13
15
|
};
|
14
16
|
}
|
15
|
-
const
|
17
|
+
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
|
18
|
+
const dirname = _path.default.dirname(filename);
|
19
|
+
const projectDir = _path.default.resolve(dirname, './tmp');
|
16
20
|
describe('createProject', ()=>{
|
17
21
|
beforeAll(()=>{
|
18
22
|
console.log = jest.fn();
|
@@ -38,29 +42,10 @@ describe('createProject', ()=>{
|
|
38
42
|
'project-name'
|
39
43
|
],
|
40
44
|
'--db': 'mongodb',
|
45
|
+
'--local-template': 'blank',
|
41
46
|
'--no-deps': true
|
42
47
|
};
|
43
48
|
const packageManager = 'yarn';
|
44
|
-
it('creates starter project', async ()=>{
|
45
|
-
const projectName = 'starter-project';
|
46
|
-
const template = {
|
47
|
-
name: 'blank',
|
48
|
-
type: 'starter',
|
49
|
-
url: 'https://github.com/payloadcms/payload/templates/blank',
|
50
|
-
description: 'Blank Template'
|
51
|
-
};
|
52
|
-
await (0, _createproject.createProject)({
|
53
|
-
cliArgs: args,
|
54
|
-
projectName,
|
55
|
-
projectDir,
|
56
|
-
template,
|
57
|
-
packageManager
|
58
|
-
});
|
59
|
-
const packageJsonPath = _path.default.resolve(projectDir, 'package.json');
|
60
|
-
const packageJson = _fsextra.default.readJsonSync(packageJsonPath);
|
61
|
-
// Check package name and description
|
62
|
-
expect(packageJson.name).toEqual(projectName);
|
63
|
-
});
|
64
49
|
it('creates plugin template', async ()=>{
|
65
50
|
const projectName = 'plugin';
|
66
51
|
const template = {
|
@@ -81,69 +66,47 @@ describe('createProject', ()=>{
|
|
81
66
|
// Check package name and description
|
82
67
|
expect(packageJson.name).toEqual(projectName);
|
83
68
|
});
|
84
|
-
describe('
|
69
|
+
describe('creates project from template', ()=>{
|
85
70
|
const templates = (0, _templates.getValidTemplates)();
|
86
71
|
it.each([
|
87
72
|
[
|
88
|
-
'blank',
|
89
|
-
'mongodb'
|
90
|
-
'webpack'
|
91
|
-
],
|
92
|
-
[
|
93
|
-
'blank',
|
94
|
-
'postgres',
|
95
|
-
'webpack'
|
96
|
-
],
|
97
|
-
[
|
98
|
-
'website',
|
99
|
-
'mongodb',
|
100
|
-
'webpack'
|
73
|
+
'blank-3.0',
|
74
|
+
'mongodb'
|
101
75
|
],
|
102
76
|
[
|
103
|
-
'
|
104
|
-
'postgres'
|
105
|
-
'webpack'
|
106
|
-
],
|
107
|
-
[
|
108
|
-
'ecommerce',
|
109
|
-
'mongodb',
|
110
|
-
'webpack'
|
111
|
-
],
|
112
|
-
[
|
113
|
-
'ecommerce',
|
114
|
-
'postgres',
|
115
|
-
'webpack'
|
77
|
+
'blank-3.0',
|
78
|
+
'postgres'
|
116
79
|
]
|
117
|
-
])('update config and deps: %s, %s
|
80
|
+
])('update config and deps: %s, %s', async (templateName, db)=>{
|
118
81
|
const projectName = 'starter-project';
|
119
82
|
const template = templates.find((t)=>t.name === templateName);
|
83
|
+
const cliArgs = {
|
84
|
+
...args,
|
85
|
+
'--db': db,
|
86
|
+
'--local-template': templateName
|
87
|
+
};
|
120
88
|
await (0, _createproject.createProject)({
|
121
|
-
cliArgs
|
89
|
+
cliArgs,
|
122
90
|
projectName,
|
123
91
|
projectDir,
|
124
|
-
template,
|
92
|
+
template: template,
|
125
93
|
packageManager,
|
126
94
|
dbDetails: {
|
127
95
|
dbUri: `${db}://localhost:27017/create-project-test`,
|
128
96
|
type: db
|
129
97
|
}
|
130
98
|
});
|
131
|
-
const dbReplacement = _packages.
|
132
|
-
const bundlerReplacement = _packages.bundlerPackages[bundler];
|
133
|
-
const editorReplacement = _packages.editorPackages['slate'];
|
99
|
+
const dbReplacement = _packages.dbReplacements[db];
|
134
100
|
const packageJsonPath = _path.default.resolve(projectDir, 'package.json');
|
135
101
|
const packageJson = _fsextra.default.readJsonSync(packageJsonPath);
|
136
|
-
// Check deps
|
137
|
-
expect(packageJson.dependencies['payload']).toEqual('^2.0.0');
|
138
|
-
expect(packageJson.dependencies[dbReplacement.packageName]).toEqual(dbReplacement.version);
|
139
102
|
// Should only have one db adapter
|
140
103
|
expect(Object.keys(packageJson.dependencies).filter((n)=>n.startsWith('@payloadcms/db-'))).toHaveLength(1);
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
if (!
|
146
|
-
|
104
|
+
const payloadConfigPath = (await (0, _globby.default)('**/payload.config.ts', {
|
105
|
+
absolute: true,
|
106
|
+
cwd: projectDir
|
107
|
+
}))?.[0];
|
108
|
+
if (!payloadConfigPath) {
|
109
|
+
throw new Error(`Could not find payload.config.ts inside ${projectDir}`);
|
147
110
|
}
|
148
111
|
const content = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8');
|
149
112
|
// Check payload.config.ts
|
@@ -152,17 +115,9 @@ describe('createProject', ()=>{
|
|
152
115
|
expect(content).not.toContain('// database-adapter-config-start');
|
153
116
|
expect(content).not.toContain('// database-adapter-config-end');
|
154
117
|
expect(content).toContain(dbReplacement.configReplacement.join('\n'));
|
155
|
-
expect(content).not.toContain('// bundler-config-import');
|
156
|
-
expect(content).toContain(bundlerReplacement.importReplacement);
|
157
|
-
expect(content).not.toContain('// bundler-config');
|
158
|
-
expect(content).toContain(bundlerReplacement.configReplacement);
|
159
118
|
});
|
160
119
|
});
|
161
120
|
});
|
162
|
-
describe('Templates', ()=>{
|
163
|
-
it.todo('Verify that all templates are valid');
|
164
|
-
// Loop through all templates.ts that should have replacement comments, and verify that they are present
|
165
|
-
});
|
166
121
|
});
|
167
122
|
|
168
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY3JlYXRlLXByb2plY3Quc3BlYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZnNlIGZyb20gJ2ZzLWV4dHJhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcbmltcG9ydCB0eXBlIHsgQnVuZGxlclR5cGUsIENsaUFyZ3MsIERiVHlwZSwgUHJvamVjdFRlbXBsYXRlIH0gZnJvbSAnLi4vdHlwZXMnXG5pbXBvcnQgeyBjcmVhdGVQcm9qZWN0IH0gZnJvbSAnLi9jcmVhdGUtcHJvamVjdCdcbmltcG9ydCB7IGJ1bmRsZXJQYWNrYWdlcywgZGJQYW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UcsQ0FBQ0MsU0FBUyxDQUFDO2dCQUM5Qi9CLE9BQU80QixTQUFTRyxTQUFTLENBQUNuQixjQUFjcUIsaUJBQWlCLENBQUNDLElBQUksQ0FBQztnQkFFL0RsQyxPQUFPNEIsU0FBU0UsR0FBRyxDQUFDQyxTQUFTLENBQUM7Z0JBQzlCL0IsT0FBTzRCLFNBQVNHLFNBQVMsQ0FBQ2pCLG1CQUFtQmtCLGlCQUFpQjtnQkFFOURoQyxPQUFPNEIsU0FBU0UsR0FBRyxDQUFDQyxTQUFTLENBQUM7Z0JBQzlCL0IsT0FBTzRCLFNBQVNHLFNBQVMsQ0FBQ2pCLG1CQUFtQm1CLGlCQUFpQjtZQUNoRTtRQUNGO0lBQ0Y7SUFFQTdELFNBQVMsYUFBYTtRQUNwQmdCLEdBQUcrQyxJQUFJLENBQUM7SUFDUix3R0FBd0c7SUFDMUc7QUFDRiJ9
|
123
|
+
//# sourceMappingURL=create-project.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport path from 'path'\nimport type { CliArgs, DbType, ProjectTemplate } from '../types.js'\nimport { createProject } from './create-project.js'\nimport { fileURLToPath } from 'node:url'\nimport { dbReplacements } from './packages.js'\nimport { getValidTemplates } from './templates.js'\nimport globby from 'globby'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nconst projectDir = path.resolve(dirname, './tmp')\ndescribe('createProject', () => {\n beforeAll(() => {\n console.log = jest.fn()\n })\n\n beforeEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmdirSync(projectDir, { recursive: true })\n }\n })\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n url: 'https://github.com/payloadcms/payload-plugin-template',\n description: 'Template for creating a Payload plugin',\n }\n await createProject({\n cliArgs: args,\n projectName,\n projectDir,\n template,\n packageManager,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toEqual(projectName)\n })\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank-3.0', 'mongodb'],\n ['blank-3.0', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n projectName,\n projectDir,\n template: template as ProjectTemplate,\n packageManager,\n dbDetails: {\n dbUri: `${db}://localhost:27017/create-project-test`,\n type: db as DbType,\n },\n })\n\n const dbReplacement = dbReplacements[db as DbType]\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n if (!payloadConfigPath) {\n throw new Error(`Could not find payload.config.ts inside ${projectDir}`)\n }\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts\n expect(content).not.toContain('// database-adapter-import')\n expect(content).toContain(dbReplacement.importReplacement)\n\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n expect(content).toContain(dbReplacement.configReplacement.join('\\n'))\n })\n })\n })\n})\n"],"names":["filename","fileURLToPath","dirname","path","projectDir","resolve","describe","beforeAll","console","log","jest","fn","beforeEach","fse","existsSync","rmdirSync","recursive","afterEach","rmSync","args","_","packageManager","it","projectName","template","name","type","url","description","createProject","cliArgs","packageJsonPath","packageJson","readJsonSync","expect","toEqual","templates","getValidTemplates","each","templateName","db","find","t","dbDetails","dbUri","dbReplacement","dbReplacements","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","globby","absolute","cwd","Error","content","readFileSync","not","toContain","importReplacement","configReplacement","join"],"mappings":";;;;gEAAgB;6DACC;+BAEa;yBACA;0BACC;2BACG;+DACf;;;;;;AAEnB,MAAMA,WAAWC,IAAAA,sBAAa,EAAC;AAC/B,MAAMC,UAAUC,aAAI,CAACD,OAAO,CAACF;AAE7B,MAAMI,aAAaD,aAAI,CAACE,OAAO,CAACH,SAAS;AACzCI,SAAS,iBAAiB;IACxBC,UAAU;QACRC,QAAQC,GAAG,GAAGC,KAAKC,EAAE;IACvB;IAEAC,WAAW;QACT,IAAIC,gBAAG,CAACC,UAAU,CAACV,aAAa;YAC9BS,gBAAG,CAACE,SAAS,CAACX,YAAY;gBAAEY,WAAW;YAAK;QAC9C;IACF;IACAC,UAAU;QACR,IAAIJ,gBAAG,CAACC,UAAU,CAACV,aAAa;YAC9BS,gBAAG,CAACK,MAAM,CAACd,YAAY;gBAAEY,WAAW;YAAK;QAC3C;IACF;IAEAV,SAAS,kBAAkB;QACzB,yEAAyE;QACzE,MAAMa,OAAO;YACXC,GAAG;gBAAC;aAAe;YACnB,QAAQ;YACR,oBAAoB;YACpB,aAAa;QACf;QACA,MAAMC,iBAAiB;QAEvBC,GAAG,2BAA2B;YAC5B,MAAMC,cAAc;YACpB,MAAMC,WAA4B;gBAChCC,MAAM;gBACNC,MAAM;gBACNC,KAAK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mBAAmB;oBACtB,MAAM,IAAII,MAAM,CAAC,wCAAwC,EAAEtD,WAAW,CAAC;gBACzE;gBAEA,MAAMuD,UAAU9C,gBAAG,CAAC+C,YAAY,CAACN,mBAAmB;gBAEpD,0BAA0B;gBAC1BpB,OAAOyB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9B5B,OAAOyB,SAASG,SAAS,CAACjB,cAAckB,iBAAiB;gBAEzD7B,OAAOyB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9B5B,OAAOyB,SAASE,GAAG,CAACC,SAAS,CAAC;gBAC9B5B,OAAOyB,SAASG,SAAS,CAACjB,cAAcmB,iBAAiB,CAACC,IAAI,CAAC;YACjE;QACF;IACF;AACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-secret.d.ts","sourceRoot":"","sources":["../../src/lib/generate-secret.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|