create-nexu 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +53 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -272,38 +272,60 @@ function getTemplateDir2() {
|
|
|
272
272
|
}
|
|
273
273
|
async function init(projectName, options) {
|
|
274
274
|
console.log(chalk3.bold("\n\u{1F680} Create Nexu Monorepo\n"));
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
275
|
+
const useCurrentDir = projectName === ".";
|
|
276
|
+
let projectDir;
|
|
277
|
+
if (useCurrentDir) {
|
|
278
|
+
projectDir = process.cwd();
|
|
279
|
+
projectName = path3.basename(projectDir);
|
|
280
|
+
const files = fs3.readdirSync(projectDir).filter((f) => !f.startsWith("."));
|
|
281
|
+
if (files.length > 0) {
|
|
282
|
+
const { proceed } = await inquirer2.prompt([
|
|
283
|
+
{
|
|
284
|
+
type: "confirm",
|
|
285
|
+
name: "proceed",
|
|
286
|
+
message: `Current directory is not empty. Continue anyway?`,
|
|
287
|
+
default: false
|
|
287
288
|
}
|
|
289
|
+
]);
|
|
290
|
+
if (!proceed) {
|
|
291
|
+
log("Aborted.", "warn");
|
|
292
|
+
process.exit(0);
|
|
288
293
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
if (!projectName) {
|
|
297
|
+
const answers = await inquirer2.prompt([
|
|
298
|
+
{
|
|
299
|
+
type: "input",
|
|
300
|
+
name: "projectName",
|
|
301
|
+
message: "Project name:",
|
|
302
|
+
default: "my-nexu-app",
|
|
303
|
+
validate: (input) => {
|
|
304
|
+
if (!/^[a-z0-9-]+$/.test(input)) {
|
|
305
|
+
return "Project name can only contain lowercase letters, numbers, and hyphens";
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
]);
|
|
311
|
+
projectName = answers.projectName;
|
|
312
|
+
}
|
|
313
|
+
projectDir = path3.resolve(process.cwd(), projectName);
|
|
314
|
+
if (fs3.existsSync(projectDir)) {
|
|
315
|
+
const { overwrite } = await inquirer2.prompt([
|
|
316
|
+
{
|
|
317
|
+
type: "confirm",
|
|
318
|
+
name: "overwrite",
|
|
319
|
+
message: `Directory ${projectName} already exists. Overwrite?`,
|
|
320
|
+
default: false
|
|
321
|
+
}
|
|
322
|
+
]);
|
|
323
|
+
if (!overwrite) {
|
|
324
|
+
log("Aborted.", "warn");
|
|
325
|
+
process.exit(0);
|
|
300
326
|
}
|
|
301
|
-
|
|
302
|
-
if (!overwrite) {
|
|
303
|
-
log("Aborted.", "warn");
|
|
304
|
-
process.exit(0);
|
|
327
|
+
fs3.removeSync(projectDir);
|
|
305
328
|
}
|
|
306
|
-
fs3.removeSync(projectDir);
|
|
307
329
|
}
|
|
308
330
|
const { selectedPackages } = await inquirer2.prompt([
|
|
309
331
|
{
|
|
@@ -408,7 +430,9 @@ async function init(projectName, options) {
|
|
|
408
430
|
}
|
|
409
431
|
console.log("\n" + chalk3.green.bold("\u2728 Project created successfully!\n"));
|
|
410
432
|
console.log("Next steps:\n");
|
|
411
|
-
|
|
433
|
+
if (!useCurrentDir) {
|
|
434
|
+
console.log(chalk3.cyan(` cd ${projectName}`));
|
|
435
|
+
}
|
|
412
436
|
if (options.skipInstall) {
|
|
413
437
|
console.log(chalk3.cyan(" pnpm install"));
|
|
414
438
|
}
|