@configjs/cli 1.1.2 → 1.1.3

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.
@@ -412,6 +412,7 @@ var PluginTracker = class {
412
412
  };
413
413
 
414
414
  export {
415
+ DetectionError,
415
416
  detectContext,
416
417
  PluginTracker
417
418
  };
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import "./chunk-QGM4M3NI.js";
5
5
  import { Command } from "commander";
6
6
 
7
7
  // package.json
8
- var version = "1.1.2";
8
+ var version = "1.1.3";
9
9
 
10
10
  // src/cli.ts
11
11
  var program = new Command();
@@ -13,7 +13,7 @@ program.name("confjs").description("Configure your frontend stack, instantly").v
13
13
  program.command("react").description("Configure a React project").option("-y, --yes", "Accept all defaults").option("-d, --dry-run", "Simulate without writing to disk").option("-s, --silent", "Non-interactive mode").option("--debug", "Enable debug logs").option("-c, --config <file>", "Use configuration file").option("-f, --force", "Force installation (overwrite configs)").option("--no-install", "Generate configs only, skip package installation").action(
14
14
  async (options) => {
15
15
  try {
16
- const { installReact } = await import("./install-UTFQ545S.js");
16
+ const { installReact } = await import("./install-7LTMBLVZ.js");
17
17
  await installReact(options);
18
18
  } catch (error) {
19
19
  console.error("Error:", error);
@@ -41,7 +41,7 @@ program.command("check").description("Check compatibility without installing").o
41
41
  });
42
42
  program.command("installed").description("List installed plugins").action(async () => {
43
43
  try {
44
- const { installedCommand } = await import("./installed-G2RXXXZ6.js");
44
+ const { installedCommand } = await import("./installed-Y76PWTXI.js");
45
45
  await installedCommand();
46
46
  } catch (error) {
47
47
  console.error("Error:", error);
@@ -50,7 +50,7 @@ program.command("installed").description("List installed plugins").action(async
50
50
  });
51
51
  program.command("remove <plugin>").description("Remove an installed plugin").action(async (plugin) => {
52
52
  try {
53
- const { removeCommand } = await import("./remove-QDF5BA6U.js");
53
+ const { removeCommand } = await import("./remove-7HJKNAEX.js");
54
54
  await removeCommand(plugin);
55
55
  } catch (error) {
56
56
  console.error("Error:", error);
@@ -9,10 +9,12 @@ import {
9
9
  pluginRegistry
10
10
  } from "./chunk-OJGTPK6N.js";
11
11
  import {
12
+ DetectionError,
12
13
  PluginTracker,
13
14
  detectContext
14
- } from "./chunk-QDVUNUTK.js";
15
+ } from "./chunk-ZSDLWQSS.js";
15
16
  import {
17
+ checkPathExists,
16
18
  installPackages,
17
19
  logger
18
20
  } from "./chunk-QRFLHLFE.js";
@@ -78,6 +80,26 @@ var fr = {
78
80
  installationFailed: "\xC9chec de l'installation",
79
81
  validationFailed: "\xC9chec de la validation",
80
82
  incompatiblePlugins: (plugins) => `Plugins incompatibles d\xE9tect\xE9s : ${plugins.join(", ")}`
83
+ },
84
+ vite: {
85
+ noReactDetected: "\u26A0\uFE0F Aucun projet React d\xE9tect\xE9 dans le r\xE9pertoire actuel.",
86
+ proposeSetup: "Souhaitez-vous cr\xE9er un nouveau projet React avec Vite ?",
87
+ projectName: "Nom du projet",
88
+ projectNamePlaceholder: "mon-projet-react",
89
+ template: "Template",
90
+ templateOptions: [
91
+ { value: "react", name: "React (JavaScript)" },
92
+ { value: "react-ts", name: "React (TypeScript)" }
93
+ ],
94
+ creating: "Cr\xE9ation du projet React avec Vite...",
95
+ success: "\u2705 Projet cr\xE9\xE9 avec succ\xE8s !",
96
+ error: "\u274C Erreur lors de la cr\xE9ation du projet",
97
+ changingDirectory: "Changement vers le r\xE9pertoire du projet...",
98
+ validation: {
99
+ empty: "Le nom du projet ne peut pas \xEAtre vide",
100
+ invalid: "Le nom du projet ne peut contenir que des lettres, chiffres, tirets et underscores"
101
+ },
102
+ folderExists: (name) => `Le dossier "${name}" existe d\xE9j\xE0. Veuillez choisir un autre nom.`
81
103
  }
82
104
  };
83
105
 
@@ -138,6 +160,26 @@ var en = {
138
160
  installationFailed: "Installation failed",
139
161
  validationFailed: "Validation failed",
140
162
  incompatiblePlugins: (plugins) => `Incompatible plugins detected: ${plugins.join(", ")}`
163
+ },
164
+ vite: {
165
+ noReactDetected: "\u26A0\uFE0F No React project detected in the current directory.",
166
+ proposeSetup: "Would you like to create a new React project with Vite?",
167
+ projectName: "Project name",
168
+ projectNamePlaceholder: "my-react-project",
169
+ template: "Template",
170
+ templateOptions: [
171
+ { value: "react", name: "React (JavaScript)" },
172
+ { value: "react-ts", name: "React (TypeScript)" }
173
+ ],
174
+ creating: "Creating React project with Vite...",
175
+ success: "\u2705 Project created successfully!",
176
+ error: "\u274C Error creating project",
177
+ changingDirectory: "Changing to project directory...",
178
+ validation: {
179
+ empty: "Project name cannot be empty",
180
+ invalid: "Project name can only contain letters, numbers, dashes and underscores"
181
+ },
182
+ folderExists: (name) => `Folder "${name}" already exists. Please choose another name.`
141
183
  }
142
184
  };
143
185
 
@@ -198,6 +240,26 @@ var es = {
198
240
  installationFailed: "Fallo en la instalaci\xF3n",
199
241
  validationFailed: "Fallo en la validaci\xF3n",
200
242
  incompatiblePlugins: (plugins) => `Plugins incompatibles detectados: ${plugins.join(", ")}`
243
+ },
244
+ vite: {
245
+ noReactDetected: "\u26A0\uFE0F No se detect\xF3 ning\xFAn proyecto React en el directorio actual.",
246
+ proposeSetup: "\xBFDesea crear un nuevo proyecto React con Vite?",
247
+ projectName: "Nombre del proyecto",
248
+ projectNamePlaceholder: "mi-proyecto-react",
249
+ template: "Plantilla",
250
+ templateOptions: [
251
+ { value: "react", name: "React (JavaScript)" },
252
+ { value: "react-ts", name: "React (TypeScript)" }
253
+ ],
254
+ creating: "Creando proyecto React con Vite...",
255
+ success: "\u2705 \xA1Proyecto creado con \xE9xito!",
256
+ error: "\u274C Error al crear el proyecto",
257
+ changingDirectory: "Cambiando al directorio del proyecto...",
258
+ validation: {
259
+ empty: "El nombre del proyecto no puede estar vac\xEDo",
260
+ invalid: "El nombre del proyecto solo puede contener letras, n\xFAmeros, guiones y guiones bajos"
261
+ },
262
+ folderExists: (name) => `La carpeta "${name}" ya existe. Por favor, elija otro nombre.`
201
263
  }
202
264
  };
203
265
 
@@ -347,6 +409,88 @@ ${translations.confirmation.summary}
347
409
  return confirm;
348
410
  }
349
411
 
412
+ // src/cli/prompts/vite-setup.ts
413
+ import inquirer4 from "inquirer";
414
+ async function promptViteSetup(language) {
415
+ const t = getTranslations(language);
416
+ const answers = await inquirer4.prompt([
417
+ {
418
+ type: "confirm",
419
+ name: "shouldCreate",
420
+ message: t.vite.proposeSetup,
421
+ default: true
422
+ },
423
+ {
424
+ type: "input",
425
+ name: "projectName",
426
+ message: t.vite.projectName,
427
+ default: t.vite.projectNamePlaceholder,
428
+ when: (answers2) => answers2.shouldCreate === true,
429
+ validate: (input) => {
430
+ if (!input || input.trim().length === 0) {
431
+ return t.vite.validation.empty;
432
+ }
433
+ if (!/^[a-z0-9-_]+$/i.test(input)) {
434
+ return t.vite.validation.invalid;
435
+ }
436
+ return true;
437
+ }
438
+ },
439
+ {
440
+ type: "list",
441
+ name: "template",
442
+ message: t.vite.template,
443
+ choices: t.vite.templateOptions,
444
+ when: (answers2) => answers2.shouldCreate === true
445
+ }
446
+ ]);
447
+ if (!answers.shouldCreate) {
448
+ return null;
449
+ }
450
+ return {
451
+ projectName: answers.projectName.trim(),
452
+ template: answers.template
453
+ };
454
+ }
455
+
456
+ // src/cli/utils/vite-installer.ts
457
+ import { resolve } from "path";
458
+ import { execa } from "execa";
459
+ async function createViteProject(options, currentDir, language) {
460
+ const t = getTranslations(language);
461
+ const { projectName, template } = options;
462
+ const projectPath = resolve(currentDir, projectName);
463
+ if (await checkPathExists(projectPath)) {
464
+ throw new Error(t.vite.folderExists(projectName));
465
+ }
466
+ logger.info(t.vite.creating);
467
+ try {
468
+ const result = await execa(
469
+ "npm",
470
+ ["create", "vite@latest", projectName, "--", "--template", template],
471
+ {
472
+ cwd: currentDir,
473
+ stdio: "inherit",
474
+ env: {
475
+ ...process.env,
476
+ // Désactiver les prompts interactifs de Vite
477
+ npm_config_yes: "true"
478
+ }
479
+ }
480
+ );
481
+ if (result.exitCode !== 0) {
482
+ throw new Error(`${t.vite.error}: exit code ${result.exitCode}`);
483
+ }
484
+ logger.success(t.vite.success);
485
+ logger.info(t.vite.changingDirectory);
486
+ return projectPath;
487
+ } catch (error) {
488
+ const errorMessage = error instanceof Error ? error.message : String(error);
489
+ logger.error(`${t.vite.error}: ${errorMessage}`);
490
+ throw error;
491
+ }
492
+ }
493
+
350
494
  // src/core/installer.ts
351
495
  var Installer = class {
352
496
  /**
@@ -888,8 +1032,34 @@ async function installReact(options) {
888
1032
  const t = getTranslations(language);
889
1033
  console.log();
890
1034
  console.log(pc2.bold(pc2.cyan(`\u{1F50D} ${t.detection.detecting}`)));
891
- const projectRoot = process.cwd();
892
- const ctx = await detectContext(projectRoot);
1035
+ let projectRoot = process.cwd();
1036
+ let ctx;
1037
+ try {
1038
+ ctx = await detectContext(projectRoot);
1039
+ } catch (error) {
1040
+ if (error instanceof DetectionError) {
1041
+ console.log();
1042
+ console.log(pc2.yellow(t.vite.noReactDetected));
1043
+ console.log();
1044
+ const viteOptions = await promptViteSetup(language);
1045
+ if (!viteOptions) {
1046
+ console.log();
1047
+ console.log(pc2.gray(t.common.cancel));
1048
+ return;
1049
+ }
1050
+ const newProjectPath = await createViteProject(
1051
+ viteOptions,
1052
+ projectRoot,
1053
+ language
1054
+ );
1055
+ process.chdir(newProjectPath);
1056
+ projectRoot = newProjectPath;
1057
+ console.log();
1058
+ ctx = await detectContext(projectRoot);
1059
+ } else {
1060
+ throw error;
1061
+ }
1062
+ }
893
1063
  console.log(
894
1064
  pc2.green(` \u2713 ${t.detection.framework}: `) + pc2.bold(`${ctx.framework} ${pc2.gray(ctx.frameworkVersion)}`)
895
1065
  );
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PluginTracker,
3
3
  detectContext
4
- } from "./chunk-QDVUNUTK.js";
4
+ } from "./chunk-ZSDLWQSS.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-QRFLHLFE.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PluginTracker,
3
3
  detectContext
4
- } from "./chunk-QDVUNUTK.js";
4
+ } from "./chunk-ZSDLWQSS.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-QRFLHLFE.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configjs/cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "Configure your frontend stack, instantly - Utilitaire CLI d'installation modulaire de bibliothèques frontend",
6
6
  "keywords": [