create-payload-app 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib/createProject.js +23 -22
- package/package.json +1 -1
@@ -50,19 +50,19 @@ var log_1 = require("../utils/log");
|
|
50
50
|
var usage_1 = require("../utils/usage");
|
51
51
|
function createProjectDir(projectDir) {
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
53
|
-
var
|
53
|
+
var pathExists;
|
54
54
|
return __generator(this, function (_a) {
|
55
55
|
switch (_a.label) {
|
56
|
-
case 0: return [4 /*yield*/, fs_extra_1.default.
|
56
|
+
case 0: return [4 /*yield*/, fs_extra_1.default.pathExists(projectDir)];
|
57
57
|
case 1:
|
58
|
-
_a.sent();
|
59
|
-
|
60
|
-
|
61
|
-
readDir = _a.sent();
|
62
|
-
if (readDir && readDir.length > 0) {
|
63
|
-
log_1.error("The project directory '" + projectDir + "' is not empty");
|
58
|
+
pathExists = _a.sent();
|
59
|
+
if (pathExists) {
|
60
|
+
log_1.error("The project directory '" + projectDir + "' already exists");
|
64
61
|
process.exit(1);
|
65
62
|
}
|
63
|
+
return [4 /*yield*/, fs_extra_1.default.mkdir(projectDir)];
|
64
|
+
case 2:
|
65
|
+
_a.sent();
|
66
66
|
return [2 /*return*/];
|
67
67
|
}
|
68
68
|
});
|
@@ -155,37 +155,38 @@ function createProject(args, projectDir, template, packageManager) {
|
|
155
155
|
var templateDir, emitter, err_2, msg, spinner, result;
|
156
156
|
return __generator(this, function (_a) {
|
157
157
|
switch (_a.label) {
|
158
|
-
case 0:
|
159
|
-
|
158
|
+
case 0: return [4 /*yield*/, createProjectDir(projectDir)];
|
159
|
+
case 1:
|
160
|
+
_a.sent();
|
160
161
|
templateDir = path_1.default.resolve(__dirname, "../templates/" + template.name);
|
161
162
|
console.log("\n Creating a new Payload app in " + chalk_1.default.green(path_1.default.resolve(projectDir)) + "\n");
|
162
|
-
if (!(template.type === 'starter')) return [3 /*break*/,
|
163
|
+
if (!(template.type === 'starter')) return [3 /*break*/, 3];
|
163
164
|
emitter = degit_1.default(template.url);
|
164
165
|
return [4 /*yield*/, emitter.clone(projectDir)];
|
165
|
-
case 1:
|
166
|
-
_a.sent();
|
167
|
-
return [3 /*break*/, 5];
|
168
166
|
case 2:
|
169
|
-
_a.
|
170
|
-
return [
|
167
|
+
_a.sent();
|
168
|
+
return [3 /*break*/, 6];
|
171
169
|
case 3:
|
170
|
+
_a.trys.push([3, 5, , 6]);
|
171
|
+
return [4 /*yield*/, fs_extra_1.default.copy(templateDir, projectDir, { recursive: true })];
|
172
|
+
case 4:
|
172
173
|
_a.sent();
|
173
174
|
log_1.success('Project directory created');
|
174
|
-
return [3 /*break*/,
|
175
|
-
case
|
175
|
+
return [3 /*break*/, 6];
|
176
|
+
case 5:
|
176
177
|
err_2 = _a.sent();
|
177
178
|
msg = 'Unable to copy template files. Please check template name or directory permissions.';
|
178
179
|
log_1.error(msg);
|
179
180
|
process.exit(1);
|
180
|
-
return [3 /*break*/,
|
181
|
-
case
|
181
|
+
return [3 /*break*/, 6];
|
182
|
+
case 6:
|
182
183
|
spinner = ora_1.default('Checking latest Payload version...').start();
|
183
184
|
return [4 /*yield*/, updatePayloadVersion(projectDir)];
|
184
|
-
case
|
185
|
+
case 7:
|
185
186
|
_a.sent();
|
186
187
|
spinner.text = 'Installing dependencies...';
|
187
188
|
return [4 /*yield*/, installDeps(args, projectDir, packageManager)];
|
188
|
-
case
|
189
|
+
case 8:
|
189
190
|
result = _a.sent();
|
190
191
|
spinner.stop();
|
191
192
|
spinner.clear();
|