create-payload-app 0.5.2 → 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,155 +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_1, dbPackage_1, 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_1 = _a.sent();
73
- packageObj_1.dependencies['payload'] = '^2.0.0';
74
- dbPackage_1 = packages_1.dbPackages[args.dbDetails.type];
75
- bundlerPackage = packages_1.bundlerPackages['webpack'];
76
- editorPackage = packages_1.editorPackages['slate'];
77
- // Delete all other db adapters
78
- Object.values(packages_1.dbPackages).forEach(function (p) {
79
- if (p.packageName !== dbPackage_1.packageName) {
80
- delete packageObj_1.dependencies[p.packageName];
81
- }
82
- });
83
- packageObj_1.dependencies[dbPackage_1.packageName] = dbPackage_1.version;
84
- packageObj_1.dependencies[bundlerPackage.packageName] = bundlerPackage.version;
85
- packageObj_1.dependencies[editorPackage.packageName] = editorPackage.version;
86
- return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj_1, { spaces: 2 })];
87
- case 3:
88
- _a.sent();
89
- return [3 /*break*/, 5];
90
- case 4:
91
- err_1 = _a.sent();
92
- (0, log_1.warning)('Unable to update name in package.json');
93
- return [3 /*break*/, 5];
94
- case 5:
95
- try {
96
- possiblePaths = [
97
- path_1.default.resolve(args.projectDir, 'src/payload.config.ts'),
98
- path_1.default.resolve(args.projectDir, 'src/payload/payload.config.ts'),
99
- ];
100
- possiblePaths.forEach(function (p) {
101
- if (fs_extra_1.default.pathExistsSync(p) && !payloadConfigPath_1) {
102
- payloadConfigPath_1 = p;
103
- }
104
- });
105
- if (!payloadConfigPath_1) {
106
- (0, log_1.warning)('Unable to update payload.config.ts with plugins');
107
- return [2 /*return*/];
108
- }
109
- configContent = fs_extra_1.default.readFileSync(payloadConfigPath_1, 'utf-8');
110
- configLines_1 = configContent.split('\n');
111
- dbReplacement_1 = packages_1.dbPackages[args.dbDetails.type];
112
- bundlerReplacement_1 = packages_1.bundlerPackages['webpack'];
113
- editorReplacement_1 = packages_1.editorPackages['slate'];
114
- configLines_1.forEach(function (l, i) {
115
- if (l.includes('// database-adapter-import')) {
116
- configLines_1[i] = dbReplacement_1.importReplacement;
117
- }
118
- if (l.includes('// bundler-import')) {
119
- configLines_1[i] = bundlerReplacement_1.importReplacement;
120
- }
121
- if (l.includes('// bundler-config')) {
122
- configLines_1[i] = bundlerReplacement_1.configReplacement;
123
- }
124
- if (l.includes('// editor-import')) {
125
- configLines_1[i] = editorReplacement_1.importReplacement;
126
- }
127
- if (l.includes('// editor-config')) {
128
- configLines_1[i] = editorReplacement_1.configReplacement;
129
- }
130
- if (l.includes('// database-adapter-config-start')) {
131
- dbConfigStartLineIndex_1 = i;
132
- }
133
- if (l.includes('// database-adapter-config-end')) {
134
- dbConfigEndLineIndex_1 = i;
135
- }
136
- });
137
- if (!dbConfigStartLineIndex_1 || !dbConfigEndLineIndex_1) {
138
- (0, log_1.warning)('Unable to update payload.config.ts with database adapter import');
139
- }
140
- else {
141
- // Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end`
142
- configLines_1.splice.apply(configLines_1, __spreadArray([dbConfigStartLineIndex_1,
143
- dbConfigEndLineIndex_1 - dbConfigStartLineIndex_1 + 1], dbReplacement_1.configReplacement, false));
144
- }
145
- fs_extra_1.default.writeFileSync(payloadConfigPath_1, configLines_1.join('\n'));
146
- }
147
- catch (err) {
148
- (0, log_1.warning)('Unable to update payload.config.ts with plugins');
149
- }
150
- 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;
151
90
  }
152
91
  });
153
- });
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
+ }
154
102
  }
155
- exports.configurePayloadConfig = configurePayloadConfig;
103
+
104
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29uZmlndXJlLXBheWxvYWQtY29uZmlnLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmc2UgZnJvbSAnZnMtZXh0cmEnXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuXG5pbXBvcnQgdHlwZSB7IERiRGV0YWlscyB9IGZyb20gJy4uL3R5c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