create-payload-app 0.3.17 → 0.3.18-beta.1

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 createProjectDir(projectDir) {
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
- return [2 /*return*/];
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*/, createProjectDir(projectDir)];
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((0, slugify_1.default)(projectName)),
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();
@@ -67,7 +67,13 @@ function helpMessage() {
67
67
  }
68
68
  exports.helpMessage = helpMessage;
69
69
  function successMessage(projectDir, packageManager) {
70
- return "\n ".concat(header('Launch Application:'), "\n\n - cd ").concat(projectDir, "\n - ").concat(packageManager === 'yarn' ? 'yarn' : 'npm run', " dev\n\n ").concat(header('Documentation:'), "\n\n - ").concat((0, terminal_link_1.default)('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat((0, terminal_link_1.default)('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n");
70
+ return "\n ".concat(header('Launch Application:'), "\n\n - cd ").concat(projectDir, "\n - ").concat(packageManager === 'yarn' ? 'yarn' : 'npm run', " dev\n\n ").concat(header('Documentation:'), "\n\n - ").concat(createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat(createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n");
71
71
  }
72
72
  exports.successMessage = successMessage;
73
+ // Create terminalLink with fallback for unsupported terminals
74
+ function createTerminalLink(text, url) {
75
+ return (0, terminal_link_1.default)(text, url, {
76
+ fallback: function (text, url) { return "".concat(text, ": ").concat(url); },
77
+ });
78
+ }
73
79
  var templateObject_1, templateObject_2;
package/package.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "prompts": "^2.4.0",
37
37
  "terminal-link": "^2.1.1"
38
38
  },
39
- "version": "0.3.17",
39
+ "version": "0.3.18-beta.1",
40
40
  "devDependencies": {
41
41
  "@types/command-exists": "^1.2.0",
42
42
  "@types/degit": "^2.8.3",