create-payload-app 0.5.1 → 1.0.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,55 +1,12 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var main_1 = require("./main");
40
- var log_1 = require("./utils/log");
41
- function main() {
42
- return __awaiter(this, void 0, void 0, function () {
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0: return [4 /*yield*/, new main_1.Main().init()];
46
- case 1:
47
- _a.sent();
48
- return [2 /*return*/];
49
- }
50
- });
51
- });
52
- }
53
- main().catch(function (e) {
54
- return (0, log_1.error)("An error has occurred: ".concat(e instanceof Error ? e.message : e));
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
55
4
  });
5
+ const _main = require("./main");
6
+ const _log = require("./utils/log");
7
+ async function main() {
8
+ await new _main.Main().init();
9
+ }
10
+ main().catch((e)=>(0, _log.error)(`An error has occurred: ${e instanceof Error ? e.message : e}`));
11
+
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBNYWluIH0gZnJvbSAnLi9tYWluJ1xuaW1wb3J0IHsgZXJyb3IgfSBmcm9tICcuL3V0aWxzL2xvZydcblxuYXN5bmMgZnVuY3Rpb24gbWFpbigpOiBQcm9taXNlPHZvaWQ+IHtcbiAgYXdhaXQgbmV3IE1haW4oKS5pbml0KClcbn1cblxubWFpbigpLmNhdGNoKChlKSA9PiBlcnJvcihgQW4gZXJyb3IgaGFzIG9jY3VycmVkOiAke2UgaW5zdGFuY2VvZiBFcnJvciA/IGUubWVzc2FnZSA6IGV9YCkpXG4iXSwibmFtZXMiOlsibWFpbiIsIk1haW4iLCJpbml0IiwiY2F0Y2giLCJlIiwiZXJyb3IiLCJFcnJvciIsIm1lc3NhZ2UiXSwibWFwcGluZ3MiOiI7Ozs7c0JBQXFCO3FCQUNDO0FBRXRCLGVBQWVBO0lBQ2IsTUFBTSxJQUFJQyxVQUFJLEdBQUdDLElBQUk7QUFDdkI7QUFFQUYsT0FBT0csS0FBSyxDQUFDLENBQUNDLElBQU1DLElBQUFBLFVBQUssRUFBQyxDQUFDLHVCQUF1QixFQUFFRCxhQUFhRSxRQUFRRixFQUFFRyxPQUFPLEdBQUdILEVBQUUsQ0FBQyJ9
@@ -1,149 +1,104 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "configurePayloadConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return configurePayloadConfig;
9
+ }
10
+ });
11
+ const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ const _log = require("../utils/log");
14
+ const _packages = require("./packages");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ async function configurePayloadConfig(args) {
21
+ if (!args.dbDetails) {
22
+ return;
23
+ }
24
+ // Update package.json
25
+ const packageJsonPath = _path.default.resolve(args.projectDir, 'package.json');
26
+ 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];
32
36
  }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
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');
36
46
  }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
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
+ let payloadConfigPath;
53
+ possiblePaths.forEach((p)=>{
54
+ if (_fsextra.default.pathExistsSync(p) && !payloadConfigPath) {
55
+ payloadConfigPath = p;
56
+ }
57
+ });
58
+ if (!payloadConfigPath) {
59
+ (0, _log.warning)('Unable to update payload.config.ts with plugins');
60
+ return;
43
61
  }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- var __importDefault = (this && this.__importDefault) || function (mod) {
48
- return (mod && mod.__esModule) ? mod : { "default": mod };
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.configurePayloadConfig = void 0;
52
- var fs_extra_1 = __importDefault(require("fs-extra"));
53
- var path_1 = __importDefault(require("path"));
54
- var log_1 = require("../utils/log");
55
- var packages_1 = require("./packages");
56
- /** Update payload config with necessary imports and adapters */
57
- function configurePayloadConfig(args) {
58
- return __awaiter(this, void 0, void 0, function () {
59
- var packageJsonPath, packageObj, dbPackage, bundlerPackage, editorPackage, err_1, possiblePaths, payloadConfigPath_1, configContent, configLines_1, dbReplacement_1, bundlerReplacement_1, editorReplacement_1, dbConfigStartLineIndex_1, dbConfigEndLineIndex_1;
60
- return __generator(this, function (_a) {
61
- switch (_a.label) {
62
- case 0:
63
- if (!args.dbDetails) {
64
- return [2 /*return*/];
65
- }
66
- packageJsonPath = path_1.default.resolve(args.projectDir, 'package.json');
67
- _a.label = 1;
68
- case 1:
69
- _a.trys.push([1, 4, , 5]);
70
- return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
71
- case 2:
72
- packageObj = _a.sent();
73
- packageObj.dependencies['payload'] = '^2.0.0';
74
- dbPackage = packages_1.dbPackages[args.dbDetails.type];
75
- bundlerPackage = packages_1.bundlerPackages['webpack'];
76
- editorPackage = packages_1.editorPackages['slate'];
77
- packageObj.dependencies[dbPackage.packageName] = dbPackage.version;
78
- packageObj.dependencies[bundlerPackage.packageName] = bundlerPackage.version;
79
- packageObj.dependencies[editorPackage.packageName] = editorPackage.version;
80
- return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj, { spaces: 2 })];
81
- case 3:
82
- _a.sent();
83
- return [3 /*break*/, 5];
84
- case 4:
85
- err_1 = _a.sent();
86
- (0, log_1.warning)('Unable to update name in package.json');
87
- return [3 /*break*/, 5];
88
- case 5:
89
- try {
90
- possiblePaths = [
91
- path_1.default.resolve(args.projectDir, 'src/payload.config.ts'),
92
- path_1.default.resolve(args.projectDir, 'src/payload/payload.config.ts'),
93
- ];
94
- possiblePaths.forEach(function (p) {
95
- if (fs_extra_1.default.pathExistsSync(p) && !payloadConfigPath_1) {
96
- payloadConfigPath_1 = p;
97
- }
98
- });
99
- if (!payloadConfigPath_1) {
100
- (0, log_1.warning)('Unable to update payload.config.ts with plugins');
101
- return [2 /*return*/];
102
- }
103
- configContent = fs_extra_1.default.readFileSync(payloadConfigPath_1, 'utf-8');
104
- configLines_1 = configContent.split('\n');
105
- dbReplacement_1 = packages_1.dbPackages[args.dbDetails.type];
106
- bundlerReplacement_1 = packages_1.bundlerPackages['webpack'];
107
- editorReplacement_1 = packages_1.editorPackages['slate'];
108
- configLines_1.forEach(function (l, i) {
109
- if (l.includes('// database-adapter-import')) {
110
- configLines_1[i] = dbReplacement_1.importReplacement;
111
- }
112
- if (l.includes('// bundler-import')) {
113
- configLines_1[i] = bundlerReplacement_1.importReplacement;
114
- }
115
- if (l.includes('// bundler-config')) {
116
- configLines_1[i] = bundlerReplacement_1.configReplacement;
117
- }
118
- if (l.includes('// editor-import')) {
119
- configLines_1[i] = editorReplacement_1.importReplacement;
120
- }
121
- if (l.includes('// editor-config')) {
122
- configLines_1[i] = editorReplacement_1.configReplacement;
123
- }
124
- if (l.includes('// database-adapter-config-start')) {
125
- dbConfigStartLineIndex_1 = i;
126
- }
127
- if (l.includes('// database-adapter-config-end')) {
128
- dbConfigEndLineIndex_1 = i;
129
- }
130
- });
131
- if (!dbConfigStartLineIndex_1 || !dbConfigEndLineIndex_1) {
132
- (0, log_1.warning)('Unable to update payload.config.ts with database adapter import');
133
- }
134
- else {
135
- // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`
136
- configLines_1.splice.apply(configLines_1, __spreadArray([dbConfigStartLineIndex_1,
137
- dbConfigEndLineIndex_1 - dbConfigStartLineIndex_1 + 1], dbReplacement_1.configReplacement, false));
138
- }
139
- fs_extra_1.default.writeFileSync(payloadConfigPath_1, configLines_1.join('\n'));
140
- }
141
- catch (err) {
142
- (0, log_1.warning)('Unable to update payload.config.ts with plugins');
143
- }
144
- return [2 /*return*/];
62
+ const configContent = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8');
63
+ const configLines = configContent.split('\n');
64
+ const dbReplacement = _packages.dbPackages[args.dbDetails.type];
65
+ const bundlerReplacement = _packages.bundlerPackages['webpack'];
66
+ const editorReplacement = _packages.editorPackages['slate'];
67
+ let dbConfigStartLineIndex;
68
+ let dbConfigEndLineIndex;
69
+ configLines.forEach((l, i)=>{
70
+ if (l.includes('// database-adapter-import')) {
71
+ configLines[i] = dbReplacement.importReplacement;
72
+ }
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
+ if (l.includes('// database-adapter-config-start')) {
86
+ dbConfigStartLineIndex = i;
87
+ }
88
+ if (l.includes('// database-adapter-config-end')) {
89
+ dbConfigEndLineIndex = i;
145
90
  }
146
91
  });
147
- });
92
+ if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) {
93
+ (0, _log.warning)('Unable to update payload.config.ts with database adapter import');
94
+ } else {
95
+ // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`
96
+ configLines.splice(dbConfigStartLineIndex, dbConfigEndLineIndex - dbConfigStartLineIndex + 1, ...dbReplacement.configReplacement);
97
+ }
98
+ _fsextra.default.writeFileSync(payloadConfigPath, configLines.join('\n'));
99
+ } catch (err) {
100
+ (0, _log.warning)('Unable to update payload.config.ts with plugins');
101
+ }
148
102
  }
149
- exports.configurePayloadConfig = configurePayloadConfig;
103
+
104
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29uZmlndXJlLXBheWxvYWQtY29uZmlnLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmc2UgZnJvbSAnZnMtZXh0cmEnXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuXG5pbXBvcnQgdHlwZSB7IERiRGV0YWlscyB9IGZyb20gJy4uL3R5cGVzJ1xuXG5pbXBvcnQgeyB3YXJuaW5nIH0gZnJvbSAnLi4vdXRpbHMvbG9nJ1xuaW1wb3J0IHsgYnVuZGxlclBhY2thZ2VzLCBkYlBhY2thZ2VzLCBlZGl0b3JQYWN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0JBQUcsQ0FBQ3NDLGFBQWEsQ0FBQ2pCLG1CQUFtQkksWUFBWWMsSUFBSSxDQUFDO0lBQ3hELEVBQUUsT0FBT3JCLEtBQWM7UUFDckJDLElBQUFBLFlBQU8sRUFBQztJQUNWO0FBQ0YifQ==
@@ -1,184 +1,111 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
9
  });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
10
+ }
11
+ _export(exports, {
12
+ createProject: function() {
13
+ return createProject;
14
+ },
15
+ updatePackageJSON: function() {
16
+ return updatePackageJSON;
36
17
  }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.updatePackageJSON = exports.createProject = void 0;
43
- var path_1 = __importDefault(require("path"));
44
- var chalk_1 = __importDefault(require("chalk"));
45
- var fs_extra_1 = __importDefault(require("fs-extra"));
46
- var execa_1 = __importDefault(require("execa"));
47
- var ora_1 = __importDefault(require("ora"));
48
- var degit_1 = __importDefault(require("degit"));
49
- var log_1 = require("../utils/log");
50
- var configure_payload_config_1 = require("./configure-payload-config");
51
- function createOrFindProjectDir(projectDir) {
52
- return __awaiter(this, void 0, void 0, function () {
53
- var pathExists;
54
- return __generator(this, function (_a) {
55
- switch (_a.label) {
56
- case 0: return [4 /*yield*/, fs_extra_1.default.pathExists(projectDir)];
57
- case 1:
58
- pathExists = _a.sent();
59
- if (!!pathExists) return [3 /*break*/, 3];
60
- return [4 /*yield*/, fs_extra_1.default.mkdir(projectDir)];
61
- case 2:
62
- _a.sent();
63
- _a.label = 3;
64
- case 3: return [2 /*return*/];
65
- }
66
- });
67
- });
18
+ });
19
+ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
20
+ const _degit = /*#__PURE__*/ _interop_require_default(require("degit"));
21
+ const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
22
+ const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
23
+ const _ora = /*#__PURE__*/ _interop_require_default(require("ora"));
24
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
25
+ const _log = require("../utils/log");
26
+ const _configurepayloadconfig = require("./configure-payload-config");
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
68
31
  }
69
- function installDeps(args) {
70
- return __awaiter(this, void 0, void 0, function () {
71
- var cliArgs, projectDir, packageManager, installCmd, err_1;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0:
75
- cliArgs = args.cliArgs, projectDir = args.projectDir, packageManager = args.packageManager;
76
- if (cliArgs['--no-deps']) {
77
- return [2 /*return*/, true];
78
- }
79
- installCmd = 'npm install --legacy-peer-deps';
80
- if (packageManager === 'yarn') {
81
- installCmd = 'yarn';
82
- }
83
- else if (packageManager === 'pnpm') {
84
- installCmd = 'pnpm install';
85
- }
86
- _a.label = 1;
87
- case 1:
88
- _a.trys.push([1, 3, , 4]);
89
- return [4 /*yield*/, execa_1.default.command(installCmd, {
90
- cwd: path_1.default.resolve(projectDir),
91
- })];
92
- case 2:
93
- _a.sent();
94
- return [2 /*return*/, true];
95
- case 3:
96
- err_1 = _a.sent();
97
- console.log({ err: err_1 });
98
- return [2 /*return*/, false];
99
- case 4: return [2 /*return*/];
100
- }
101
- });
102
- });
32
+ async function createOrFindProjectDir(projectDir) {
33
+ const pathExists = await _fsextra.default.pathExists(projectDir);
34
+ if (!pathExists) {
35
+ await _fsextra.default.mkdir(projectDir);
36
+ }
103
37
  }
104
- function createProject(args) {
105
- return __awaiter(this, void 0, void 0, function () {
106
- var cliArgs, projectName, projectDir, template, packageManager, dbDetails, emitter, spinner, lockPath, result;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0:
110
- cliArgs = args.cliArgs, projectName = args.projectName, projectDir = args.projectDir, template = args.template, packageManager = args.packageManager, dbDetails = args.dbDetails;
111
- return [4 /*yield*/, createOrFindProjectDir(projectDir)];
112
- case 1:
113
- _a.sent();
114
- console.log("\n Creating project in ".concat(chalk_1.default.green(path_1.default.resolve(projectDir)), "\n"));
115
- if (!('url' in template)) return [3 /*break*/, 3];
116
- emitter = (0, degit_1.default)(template.url);
117
- return [4 /*yield*/, emitter.clone(projectDir)];
118
- case 2:
119
- _a.sent();
120
- _a.label = 3;
121
- case 3:
122
- spinner = (0, ora_1.default)('Checking latest Payload version...').start();
123
- return [4 /*yield*/, updatePackageJSON({ projectName: projectName, projectDir: projectDir })];
124
- case 4:
125
- _a.sent();
126
- return [4 /*yield*/, (0, configure_payload_config_1.configurePayloadConfig)({ projectDir: projectDir, dbDetails: dbDetails })
127
- // Remove yarn.lock file. This is only desired in Payload Cloud.
128
- ];
129
- case 5:
130
- _a.sent();
131
- lockPath = path_1.default.resolve(projectDir, 'yarn.lock');
132
- if (!fs_extra_1.default.existsSync(lockPath)) return [3 /*break*/, 7];
133
- return [4 /*yield*/, fs_extra_1.default.remove(lockPath)];
134
- case 6:
135
- _a.sent();
136
- _a.label = 7;
137
- case 7:
138
- spinner.text = 'Installing dependencies...';
139
- return [4 /*yield*/, installDeps({ cliArgs: cliArgs, projectDir: projectDir, packageManager: packageManager })];
140
- case 8:
141
- result = _a.sent();
142
- spinner.stop();
143
- spinner.clear();
144
- if (result) {
145
- (0, log_1.success)('Dependencies installed');
146
- }
147
- else {
148
- (0, log_1.error)('Error installing dependencies');
149
- }
150
- return [2 /*return*/];
151
- }
38
+ async function installDeps(args) {
39
+ const { cliArgs, packageManager, projectDir } = args;
40
+ if (cliArgs['--no-deps']) {
41
+ return true;
42
+ }
43
+ let installCmd = 'npm install --legacy-peer-deps';
44
+ if (packageManager === 'yarn') {
45
+ installCmd = 'yarn';
46
+ } else if (packageManager === 'pnpm') {
47
+ installCmd = 'pnpm install';
48
+ }
49
+ try {
50
+ await _execa.default.command(installCmd, {
51
+ cwd: _path.default.resolve(projectDir)
52
+ });
53
+ return true;
54
+ } catch (err) {
55
+ console.log({
56
+ err
152
57
  });
58
+ return false;
59
+ }
60
+ }
61
+ async function createProject(args) {
62
+ const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args;
63
+ await createOrFindProjectDir(projectDir);
64
+ console.log(`\n Creating project in ${_chalk.default.green(_path.default.resolve(projectDir))}\n`);
65
+ if ('url' in template) {
66
+ const emitter = (0, _degit.default)(template.url);
67
+ await emitter.clone(projectDir);
68
+ }
69
+ const spinner = (0, _ora.default)('Checking latest Payload version...').start();
70
+ await updatePackageJSON({
71
+ projectDir,
72
+ projectName
153
73
  });
74
+ await (0, _configurepayloadconfig.configurePayloadConfig)({
75
+ dbDetails,
76
+ projectDir
77
+ });
78
+ // Remove yarn.lock file. This is only desired in Payload Cloud.
79
+ const lockPath = _path.default.resolve(projectDir, 'yarn.lock');
80
+ if (_fsextra.default.existsSync(lockPath)) {
81
+ await _fsextra.default.remove(lockPath);
82
+ }
83
+ spinner.text = 'Installing dependencies...';
84
+ const result = await installDeps({
85
+ cliArgs,
86
+ packageManager,
87
+ projectDir
88
+ });
89
+ spinner.stop();
90
+ spinner.clear();
91
+ if (result) {
92
+ (0, _log.success)('Dependencies installed');
93
+ } else {
94
+ (0, _log.error)('Error installing dependencies');
95
+ }
154
96
  }
155
- exports.createProject = createProject;
156
- function updatePackageJSON(args) {
157
- return __awaiter(this, void 0, void 0, function () {
158
- var projectName, projectDir, packageJsonPath, packageObj, err_2;
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
161
- case 0:
162
- projectName = args.projectName, projectDir = args.projectDir;
163
- packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
164
- _a.label = 1;
165
- case 1:
166
- _a.trys.push([1, 4, , 5]);
167
- return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
168
- case 2:
169
- packageObj = _a.sent();
170
- packageObj.name = projectName;
171
- return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj, { spaces: 2 })];
172
- case 3:
173
- _a.sent();
174
- return [3 /*break*/, 5];
175
- case 4:
176
- err_2 = _a.sent();
177
- (0, log_1.warning)('Unable to update name in package.json');
178
- return [3 /*break*/, 5];
179
- case 5: return [2 /*return*/];
180
- }
97
+ async function updatePackageJSON(args) {
98
+ const { projectDir, projectName } = args;
99
+ const packageJsonPath = _path.default.resolve(projectDir, 'package.json');
100
+ try {
101
+ const packageObj = await _fsextra.default.readJson(packageJsonPath);
102
+ packageObj.name = projectName;
103
+ await _fsextra.default.writeJson(packageJsonPath, packageObj, {
104
+ spaces: 2
181
105
  });
182
- });
106
+ } catch (err) {
107
+ (0, _log.warning)('Unable to update name in package.json');
108
+ }
183
109
  }
184
- exports.updatePackageJSON = updatePackageJSON;
110
+
111
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY3JlYXRlLXByb2plY3QudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNoYWxrIGZyb20gJ2NoYWxrJ1xuaW1wb3J0IGRlZ2l0IGZyb20gJ2RlZ2l0J1xuaW1wb3J0IGV4ZWNhIGZyb20gJ2V4ZWNhJ1xuaW1wb3J0IGZzZSBmcm9tICdmcy1leHRyYSdcbmltcG9ydCBvcmEgZnJvbSAnb3JhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcblxuaW1wb3J0IHR5cGUgeyBDbGlBcmdzLCBEYkRldGFpbHMsIFBhY2thZ2VNYW5hZ2VyLCBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZXJyb3IsIHN1Y2Nlc3MsIHdhcm5pbmcgfSBmcm9tICcuLi91dGlscy9sb2cn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