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.
Files changed (2) hide show
  1. package/dist/index.js +53 -29
  2. 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
- if (!projectName) {
276
- const answers = await inquirer2.prompt([
277
- {
278
- type: "input",
279
- name: "projectName",
280
- message: "Project name:",
281
- default: "my-nexu-app",
282
- validate: (input) => {
283
- if (!/^[a-z0-9-]+$/.test(input)) {
284
- return "Project name can only contain lowercase letters, numbers, and hyphens";
285
- }
286
- return true;
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
- projectName = answers.projectName;
291
- }
292
- const projectDir = path3.resolve(process.cwd(), projectName);
293
- if (fs3.existsSync(projectDir)) {
294
- const { overwrite } = await inquirer2.prompt([
295
- {
296
- type: "confirm",
297
- name: "overwrite",
298
- message: `Directory ${projectName} already exists. Overwrite?`,
299
- default: false
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
- console.log(chalk3.cyan(` cd ${projectName}`));
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nexu",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "CLI to create and update Nexu monorepo projects",
5
5
  "author": "Nexu Team",
6
6
  "license": "MIT",