create-payload-app 0.3.16 → 0.3.18-beta.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,7 @@ var ora_1 = __importDefault(require("ora"));
|
|
48
48
|
var degit_1 = __importDefault(require("degit"));
|
49
49
|
var log_1 = require("../utils/log");
|
50
50
|
var write_common_files_1 = require("./write-common-files");
|
51
|
-
function
|
51
|
+
function createOrFindProjectDir(projectDir) {
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
53
53
|
var pathExists;
|
54
54
|
return __generator(this, function (_a) {
|
@@ -56,14 +56,12 @@ function createProjectDir(projectDir) {
|
|
56
56
|
case 0: return [4 /*yield*/, fs_extra_1.default.pathExists(projectDir)];
|
57
57
|
case 1:
|
58
58
|
pathExists = _a.sent();
|
59
|
-
if (pathExists)
|
60
|
-
(0, log_1.error)("The project directory '".concat(projectDir, "' already exists"));
|
61
|
-
process.exit(1);
|
62
|
-
}
|
59
|
+
if (!!pathExists) return [3 /*break*/, 3];
|
63
60
|
return [4 /*yield*/, fs_extra_1.default.mkdir(projectDir)];
|
64
61
|
case 2:
|
65
62
|
_a.sent();
|
66
|
-
|
63
|
+
_a.label = 3;
|
64
|
+
case 3: return [2 /*return*/];
|
67
65
|
}
|
68
66
|
});
|
69
67
|
});
|
@@ -165,7 +163,7 @@ function createProject(args, projectDir, template, packageManager) {
|
|
165
163
|
var templateDir, emitter, err_4, msg, spinner, result;
|
166
164
|
return __generator(this, function (_a) {
|
167
165
|
switch (_a.label) {
|
168
|
-
case 0: return [4 /*yield*/,
|
166
|
+
case 0: return [4 /*yield*/, createOrFindProjectDir(projectDir)];
|
169
167
|
case 1:
|
170
168
|
_a.sent();
|
171
169
|
templateDir = path_1.default.resolve(__dirname, "../templates/".concat(template.name));
|
@@ -54,7 +54,9 @@ function getDatabaseConnection(args, projectName) {
|
|
54
54
|
type: 'text',
|
55
55
|
name: 'value',
|
56
56
|
message: 'Enter MongoDB connection',
|
57
|
-
initial: "mongodb://localhost/".concat(
|
57
|
+
initial: "mongodb://localhost/".concat(projectName === '.'
|
58
|
+
? "payload-".concat(getRandomDigitSuffix())
|
59
|
+
: (0, slugify_1.default)(projectName)),
|
58
60
|
validate: function (value) { return value.length; },
|
59
61
|
}, {
|
60
62
|
onCancel: function () {
|
@@ -69,3 +71,6 @@ function getDatabaseConnection(args, projectName) {
|
|
69
71
|
});
|
70
72
|
}
|
71
73
|
exports.getDatabaseConnection = getDatabaseConnection;
|
74
|
+
function getRandomDigitSuffix() {
|
75
|
+
return (Math.random() * Math.pow(10, 6)).toFixed(0);
|
76
|
+
}
|
package/dist/main.js
CHANGED
@@ -118,7 +118,7 @@ var Main = /** @class */ (function () {
|
|
118
118
|
return [4 /*yield*/, (0, generate_secret_1.generateSecret)()];
|
119
119
|
case 11:
|
120
120
|
payloadSecret = _e.sent();
|
121
|
-
projectDir = "./".concat((0, slugify_1.default)(projectName));
|
121
|
+
projectDir = projectName === '.' ? process.cwd() : "./".concat((0, slugify_1.default)(projectName));
|
122
122
|
return [4 /*yield*/, getPackageManager(this.args)];
|
123
123
|
case 12:
|
124
124
|
packageManager = _e.sent();
|