@configjs/cli 1.1.4 → 1.1.6

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.
@@ -0,0 +1,114 @@
1
+ import {
2
+ logger
3
+ } from "./chunk-HM2JWJOO.js";
4
+
5
+ // src/utils/package-manager.ts
6
+ import { execa } from "execa";
7
+ import fs from "fs-extra";
8
+ import { resolve, join } from "path";
9
+ async function detectPackageManager(projectRoot) {
10
+ const root = resolve(projectRoot);
11
+ const lockfiles = [
12
+ { file: "pnpm-lock.yaml", manager: "pnpm" },
13
+ { file: "yarn.lock", manager: "yarn" },
14
+ { file: "package-lock.json", manager: "npm" },
15
+ { file: "bun.lockb", manager: "bun" }
16
+ ];
17
+ for (const { file, manager } of lockfiles) {
18
+ const lockfilePath = join(root, file);
19
+ if (await fs.pathExists(lockfilePath)) {
20
+ logger.debug(`Detected package manager: ${manager} (found ${file})`);
21
+ return manager;
22
+ }
23
+ }
24
+ logger.debug("No lockfile found, defaulting to npm");
25
+ return "npm";
26
+ }
27
+ async function installPackages(packages, options) {
28
+ if (packages.length === 0) {
29
+ logger.warn("No packages to install");
30
+ return { success: true, packages: [] };
31
+ }
32
+ const {
33
+ packageManager,
34
+ projectRoot,
35
+ dev = false,
36
+ exact = false,
37
+ silent = false
38
+ } = options;
39
+ logger.info(
40
+ `Installing ${packages.length} package(s) with ${packageManager}...`
41
+ );
42
+ try {
43
+ const command = getInstallCommand(packageManager, packages, { dev, exact });
44
+ const cwd = resolve(projectRoot);
45
+ logger.debug(`Executing: ${command.join(" ")} in ${cwd}`);
46
+ const [cmd, ...args] = command;
47
+ if (!cmd) {
48
+ throw new Error("Command is empty");
49
+ }
50
+ const result = await execa(cmd, args, {
51
+ cwd,
52
+ stdio: silent ? "pipe" : "inherit",
53
+ env: {
54
+ ...process.env,
55
+ // Désactiver les prompts interactifs
56
+ npm_config_yes: "true",
57
+ YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
58
+ }
59
+ });
60
+ if (result.exitCode !== 0) {
61
+ throw new Error(`Installation failed with exit code ${result.exitCode}`);
62
+ }
63
+ logger.success(`Successfully installed ${packages.length} package(s)`);
64
+ return {
65
+ success: true,
66
+ packages
67
+ };
68
+ } catch (error) {
69
+ const errorMessage = error instanceof Error ? error.message : String(error);
70
+ logger.error(`Failed to install packages: ${errorMessage}`);
71
+ return {
72
+ success: false,
73
+ packages,
74
+ error: errorMessage
75
+ };
76
+ }
77
+ }
78
+ function getInstallCommand(packageManager, packages, options) {
79
+ const { dev, exact } = options;
80
+ switch (packageManager) {
81
+ case "pnpm":
82
+ return [
83
+ "pnpm",
84
+ "add",
85
+ ...dev ? ["-D"] : [],
86
+ ...exact ? ["--save-exact"] : [],
87
+ ...packages
88
+ ];
89
+ case "yarn":
90
+ return [
91
+ "yarn",
92
+ "add",
93
+ ...dev ? ["--dev"] : [],
94
+ ...exact ? ["--exact"] : [],
95
+ ...packages
96
+ ];
97
+ case "bun":
98
+ return ["bun", "add", ...dev ? ["--dev"] : [], ...packages];
99
+ case "npm":
100
+ default:
101
+ return [
102
+ "npm",
103
+ "install",
104
+ ...dev ? ["--save-dev"] : [],
105
+ ...exact ? ["--save-exact"] : [],
106
+ ...packages
107
+ ];
108
+ }
109
+ }
110
+
111
+ export {
112
+ detectPackageManager,
113
+ installPackages
114
+ };
@@ -0,0 +1,386 @@
1
+ // src/cli/i18n/fr.ts
2
+ var fr = {
3
+ language: {
4
+ select: "Choisissez votre langue",
5
+ options: [
6
+ { value: "fr", name: "Fran\xE7ais" },
7
+ { value: "en", name: "English" },
8
+ { value: "es", name: "Espa\xF1ol" }
9
+ ]
10
+ },
11
+ common: {
12
+ continue: "Continuer",
13
+ cancel: "Annuler",
14
+ back: "Retour",
15
+ none: "Aucun",
16
+ selected: (count) => count === 0 ? "Aucune biblioth\xE8que s\xE9lectionn\xE9e" : count === 1 ? "1 biblioth\xE8que s\xE9lectionn\xE9e" : `${count} biblioth\xE8ques s\xE9lectionn\xE9es`
17
+ },
18
+ plugins: {
19
+ selectCategory: (category) => `S\xE9lectionnez vos biblioth\xE8ques : ${category}`,
20
+ selectMultiple: "S\xE9lection multiple",
21
+ pressSpace: "Appuyez sur <espace> pour s\xE9lectionner",
22
+ pressEnter: "Appuyez sur <entr\xE9e> pour valider",
23
+ description: "Description"
24
+ },
25
+ detection: {
26
+ detecting: "\u{1F50D} D\xE9tection du contexte...",
27
+ framework: "Framework",
28
+ typescript: "TypeScript",
29
+ bundler: "Bundler",
30
+ packageManager: "Gestionnaire de paquets"
31
+ },
32
+ confirmation: {
33
+ summary: "\u{1F4CB} R\xE9sum\xE9 de l'installation",
34
+ packagesToInstall: "\u{1F4E6} Packages \xE0 installer",
35
+ filesToCreate: "\u{1F4DD} Fichiers qui seront cr\xE9\xE9s",
36
+ filesToModify: "\u{1F4DD} Fichiers qui seront modifi\xE9s",
37
+ continueQuestion: "Continuer avec l'installation ?"
38
+ },
39
+ installation: {
40
+ installing: "Installation en cours...",
41
+ configuring: "Configuration en cours...",
42
+ success: "\u2728 Installation termin\xE9e !",
43
+ error: "\u274C Erreur lors de l'installation",
44
+ rollback: "\u21BA Rollback en cours..."
45
+ },
46
+ report: {
47
+ title: "\u2728 Installation termin\xE9e !",
48
+ packagesInstalled: "\u{1F4E6} Packages install\xE9s",
49
+ filesCreated: "\u{1F4DD} Fichiers cr\xE9\xE9s",
50
+ filesModified: "\u{1F4DD} Fichiers modifi\xE9s",
51
+ nextSteps: "\u{1F680} Prochaines \xE9tapes"
52
+ },
53
+ errors: {
54
+ detectionFailed: "\xC9chec de la d\xE9tection du contexte",
55
+ installationFailed: "\xC9chec de l'installation",
56
+ validationFailed: "\xC9chec de la validation",
57
+ incompatiblePlugins: (plugins) => `Plugins incompatibles d\xE9tect\xE9s : ${plugins.join(", ")}`
58
+ },
59
+ vite: {
60
+ noReactDetected: "\u26A0\uFE0F Aucun projet React d\xE9tect\xE9 dans le r\xE9pertoire actuel.",
61
+ proposeSetup: "Souhaitez-vous cr\xE9er un nouveau projet React avec Vite ?",
62
+ projectName: "Nom du projet",
63
+ projectNamePlaceholder: "mon-projet-react",
64
+ typescript: "Utiliser TypeScript ?",
65
+ template: "Template",
66
+ templateOptions: [
67
+ { value: "react", name: "React (JavaScript)" },
68
+ { value: "react-ts", name: "React (TypeScript)" }
69
+ ],
70
+ creating: "Cr\xE9ation du projet React avec Vite...",
71
+ success: "\u2705 Projet cr\xE9\xE9 avec succ\xE8s !",
72
+ error: "\u274C Erreur lors de la cr\xE9ation du projet",
73
+ changingDirectory: "Changement vers le r\xE9pertoire du projet...",
74
+ validation: {
75
+ empty: "Le nom du projet ne peut pas \xEAtre vide",
76
+ invalid: "Le nom du projet ne peut contenir que des lettres, chiffres, tirets et underscores"
77
+ },
78
+ folderExists: (name) => `Le dossier "${name}" existe d\xE9j\xE0. Veuillez choisir un autre nom.`
79
+ },
80
+ nextjs: {
81
+ noNextjsDetected: "\u26A0\uFE0F Aucun projet Next.js d\xE9tect\xE9 dans le r\xE9pertoire actuel.",
82
+ proposeSetup: "Souhaitez-vous cr\xE9er un nouveau projet Next.js ?",
83
+ projectName: "Nom du projet",
84
+ projectNamePlaceholder: "mon-projet-nextjs",
85
+ typescript: "Utiliser TypeScript ?",
86
+ eslint: "Utiliser ESLint ?",
87
+ tailwind: "Utiliser TailwindCSS ?",
88
+ srcDir: "Utiliser le dossier src/ ?",
89
+ appRouter: "Utiliser App Router (recommand\xE9) ?",
90
+ importAlias: "Alias d'import (ex: @/*)",
91
+ creating: "Cr\xE9ation du projet Next.js...",
92
+ success: "\u2705 Projet cr\xE9\xE9 avec succ\xE8s !",
93
+ error: "\u274C Erreur lors de la cr\xE9ation du projet",
94
+ changingDirectory: "Changement vers le r\xE9pertoire du projet...",
95
+ validation: {
96
+ empty: "Le nom du projet ne peut pas \xEAtre vide",
97
+ invalid: "Le nom du projet ne peut contenir que des lettres, chiffres, tirets et underscores"
98
+ },
99
+ folderExists: (name) => `Le dossier "${name}" existe d\xE9j\xE0. Veuillez choisir un autre nom.`
100
+ },
101
+ vue: {
102
+ noVueDetected: "\u26A0\uFE0F Aucun projet Vue.js d\xE9tect\xE9 dans le r\xE9pertoire actuel.",
103
+ proposeSetup: "Souhaitez-vous cr\xE9er un nouveau projet Vue.js avec Vite ?",
104
+ projectName: "Nom du projet",
105
+ projectNamePlaceholder: "mon-projet-vue",
106
+ typescript: "Utiliser TypeScript ?",
107
+ router: "Utiliser Vue Router ?",
108
+ pinia: "Utiliser Pinia (state management) ?",
109
+ vitest: "Utiliser Vitest (testing) ?",
110
+ eslint: "Utiliser ESLint ?",
111
+ prettier: "Utiliser Prettier ?",
112
+ creating: "Cr\xE9ation du projet Vue.js avec Vite...",
113
+ success: "\u2705 Projet cr\xE9\xE9 avec succ\xE8s !",
114
+ error: "\u274C Erreur lors de la cr\xE9ation du projet",
115
+ changingDirectory: "Changement vers le r\xE9pertoire du projet...",
116
+ validation: {
117
+ empty: "Le nom du projet ne peut pas \xEAtre vide",
118
+ invalid: "Le nom du projet ne peut contenir que des lettres, chiffres, tirets et underscores"
119
+ },
120
+ folderExists: (name) => `Le dossier "${name}" existe d\xE9j\xE0. Veuillez choisir un autre nom.`
121
+ }
122
+ };
123
+
124
+ // src/cli/i18n/en.ts
125
+ var en = {
126
+ language: {
127
+ select: "Choose your language",
128
+ options: [
129
+ { value: "fr", name: "Fran\xE7ais" },
130
+ { value: "en", name: "English" },
131
+ { value: "es", name: "Espa\xF1ol" }
132
+ ]
133
+ },
134
+ common: {
135
+ continue: "Continue",
136
+ cancel: "Cancel",
137
+ back: "Back",
138
+ none: "None",
139
+ selected: (count) => count === 0 ? "No library selected" : count === 1 ? "1 library selected" : `${count} libraries selected`
140
+ },
141
+ plugins: {
142
+ selectCategory: (category) => `Select your libraries: ${category}`,
143
+ selectMultiple: "Multiple selection",
144
+ pressSpace: "Press <space> to select",
145
+ pressEnter: "Press <enter> to confirm",
146
+ description: "Description"
147
+ },
148
+ detection: {
149
+ detecting: "\u{1F50D} Detecting context...",
150
+ framework: "Framework",
151
+ typescript: "TypeScript",
152
+ bundler: "Bundler",
153
+ packageManager: "Package manager"
154
+ },
155
+ confirmation: {
156
+ summary: "\u{1F4CB} Installation Summary",
157
+ packagesToInstall: "\u{1F4E6} Packages to install",
158
+ filesToCreate: "\u{1F4DD} Files that will be created",
159
+ filesToModify: "\u{1F4DD} Files that will be modified",
160
+ continueQuestion: "Continue with installation?"
161
+ },
162
+ installation: {
163
+ installing: "Installing...",
164
+ configuring: "Configuring...",
165
+ success: "\u2728 Installation completed!",
166
+ error: "\u274C Installation error",
167
+ rollback: "\u21BA Rolling back..."
168
+ },
169
+ report: {
170
+ title: "\u2728 Installation completed!",
171
+ packagesInstalled: "\u{1F4E6} Installed packages",
172
+ filesCreated: "\u{1F4DD} Created files",
173
+ filesModified: "\u{1F4DD} Modified files",
174
+ nextSteps: "\u{1F680} Next steps"
175
+ },
176
+ errors: {
177
+ detectionFailed: "Context detection failed",
178
+ installationFailed: "Installation failed",
179
+ validationFailed: "Validation failed",
180
+ incompatiblePlugins: (plugins) => `Incompatible plugins detected: ${plugins.join(", ")}`
181
+ },
182
+ vite: {
183
+ noReactDetected: "\u26A0\uFE0F No React project detected in the current directory.",
184
+ proposeSetup: "Would you like to create a new React project with Vite?",
185
+ projectName: "Project name",
186
+ projectNamePlaceholder: "my-react-project",
187
+ typescript: "Use TypeScript?",
188
+ template: "Template",
189
+ templateOptions: [
190
+ { value: "react", name: "React (JavaScript)" },
191
+ { value: "react-ts", name: "React (TypeScript)" }
192
+ ],
193
+ creating: "Creating React project with Vite...",
194
+ success: "\u2705 Project created successfully!",
195
+ error: "\u274C Error creating project",
196
+ changingDirectory: "Changing to project directory...",
197
+ validation: {
198
+ empty: "Project name cannot be empty",
199
+ invalid: "Project name can only contain letters, numbers, dashes and underscores"
200
+ },
201
+ folderExists: (name) => `Folder "${name}" already exists. Please choose another name.`
202
+ },
203
+ nextjs: {
204
+ noNextjsDetected: "\u26A0\uFE0F No Next.js project detected in the current directory.",
205
+ proposeSetup: "Would you like to create a new Next.js project?",
206
+ projectName: "Project name",
207
+ projectNamePlaceholder: "my-nextjs-project",
208
+ typescript: "Use TypeScript?",
209
+ eslint: "Use ESLint?",
210
+ tailwind: "Use TailwindCSS?",
211
+ srcDir: "Use src/ directory?",
212
+ appRouter: "Use App Router (recommended)?",
213
+ importAlias: "Import alias (e.g. @/*)",
214
+ creating: "Creating Next.js project...",
215
+ success: "\u2705 Project created successfully!",
216
+ error: "\u274C Error creating project",
217
+ changingDirectory: "Changing to project directory...",
218
+ validation: {
219
+ empty: "Project name cannot be empty",
220
+ invalid: "Project name can only contain letters, numbers, dashes and underscores"
221
+ },
222
+ folderExists: (name) => `Folder "${name}" already exists. Please choose another name.`
223
+ },
224
+ vue: {
225
+ noVueDetected: "\u26A0\uFE0F No Vue.js project detected in the current directory.",
226
+ proposeSetup: "Would you like to create a new Vue.js project with Vite?",
227
+ projectName: "Project name",
228
+ projectNamePlaceholder: "my-vue-project",
229
+ typescript: "Use TypeScript?",
230
+ router: "Use Vue Router?",
231
+ pinia: "Use Pinia (state management)?",
232
+ vitest: "Use Vitest (testing)?",
233
+ eslint: "Use ESLint?",
234
+ prettier: "Use Prettier?",
235
+ creating: "Creating Vue.js project with Vite...",
236
+ success: "\u2705 Project created successfully!",
237
+ error: "\u274C Error creating project",
238
+ changingDirectory: "Changing to project directory...",
239
+ validation: {
240
+ empty: "Project name cannot be empty",
241
+ invalid: "Project name can only contain letters, numbers, dashes and underscores"
242
+ },
243
+ folderExists: (name) => `Folder "${name}" already exists. Please choose another name.`
244
+ }
245
+ };
246
+
247
+ // src/cli/i18n/es.ts
248
+ var es = {
249
+ language: {
250
+ select: "Elige tu idioma",
251
+ options: [
252
+ { value: "fr", name: "Fran\xE7ais" },
253
+ { value: "en", name: "English" },
254
+ { value: "es", name: "Espa\xF1ol" }
255
+ ]
256
+ },
257
+ common: {
258
+ continue: "Continuar",
259
+ cancel: "Cancelar",
260
+ back: "Volver",
261
+ none: "Ninguno",
262
+ selected: (count) => count === 0 ? "Ninguna biblioteca seleccionada" : count === 1 ? "1 biblioteca seleccionada" : `${count} bibliotecas seleccionadas`
263
+ },
264
+ plugins: {
265
+ selectCategory: (category) => `Selecciona tus bibliotecas: ${category}`,
266
+ selectMultiple: "Selecci\xF3n m\xFAltiple",
267
+ pressSpace: "Presiona <espacio> para seleccionar",
268
+ pressEnter: "Presiona <entrar> para confirmar",
269
+ description: "Descripci\xF3n"
270
+ },
271
+ detection: {
272
+ detecting: "\u{1F50D} Detectando contexto...",
273
+ framework: "Framework",
274
+ typescript: "TypeScript",
275
+ bundler: "Bundler",
276
+ packageManager: "Gestor de paquetes"
277
+ },
278
+ confirmation: {
279
+ summary: "\u{1F4CB} Resumen de la instalaci\xF3n",
280
+ packagesToInstall: "\u{1F4E6} Paquetes a instalar",
281
+ filesToCreate: "\u{1F4DD} Archivos que se crear\xE1n",
282
+ filesToModify: "\u{1F4DD} Archivos que se modificar\xE1n",
283
+ continueQuestion: "\xBFContinuar con la instalaci\xF3n?"
284
+ },
285
+ installation: {
286
+ installing: "Instalando...",
287
+ configuring: "Configurando...",
288
+ success: "\u2728 \xA1Instalaci\xF3n completada!",
289
+ error: "\u274C Error en la instalaci\xF3n",
290
+ rollback: "\u21BA Revirtiendo..."
291
+ },
292
+ report: {
293
+ title: "\u2728 \xA1Instalaci\xF3n completada!",
294
+ packagesInstalled: "\u{1F4E6} Paquetes instalados",
295
+ filesCreated: "\u{1F4DD} Archivos creados",
296
+ filesModified: "\u{1F4DD} Archivos modificados",
297
+ nextSteps: "\u{1F680} Pr\xF3ximos pasos"
298
+ },
299
+ errors: {
300
+ detectionFailed: "Fallo en la detecci\xF3n del contexto",
301
+ installationFailed: "Fallo en la instalaci\xF3n",
302
+ validationFailed: "Fallo en la validaci\xF3n",
303
+ incompatiblePlugins: (plugins) => `Plugins incompatibles detectados: ${plugins.join(", ")}`
304
+ },
305
+ vite: {
306
+ noReactDetected: "\u26A0\uFE0F No se detect\xF3 ning\xFAn proyecto React en el directorio actual.",
307
+ proposeSetup: "\xBFDesea crear un nuevo proyecto React con Vite?",
308
+ projectName: "Nombre del proyecto",
309
+ projectNamePlaceholder: "mi-proyecto-react",
310
+ typescript: "\xBFUsar TypeScript?",
311
+ template: "Plantilla",
312
+ templateOptions: [
313
+ { value: "react", name: "React (JavaScript)" },
314
+ { value: "react-ts", name: "React (TypeScript)" }
315
+ ],
316
+ creating: "Creando proyecto React con Vite...",
317
+ success: "\u2705 \xA1Proyecto creado con \xE9xito!",
318
+ error: "\u274C Error al crear el proyecto",
319
+ changingDirectory: "Cambiando al directorio del proyecto...",
320
+ validation: {
321
+ empty: "El nombre del proyecto no puede estar vac\xEDo",
322
+ invalid: "El nombre del proyecto solo puede contener letras, n\xFAmeros, guiones y guiones bajos"
323
+ },
324
+ folderExists: (name) => `La carpeta "${name}" ya existe. Por favor, elija otro nombre.`
325
+ },
326
+ nextjs: {
327
+ noNextjsDetected: "\u26A0\uFE0F No se detect\xF3 ning\xFAn proyecto Next.js en el directorio actual.",
328
+ proposeSetup: "\xBFDesea crear un nuevo proyecto Next.js?",
329
+ projectName: "Nombre del proyecto",
330
+ projectNamePlaceholder: "mi-proyecto-nextjs",
331
+ typescript: "\xBFUsar TypeScript?",
332
+ eslint: "\xBFUsar ESLint?",
333
+ tailwind: "\xBFUsar TailwindCSS?",
334
+ srcDir: "\xBFUsar directorio src/?",
335
+ appRouter: "\xBFUsar App Router (recomendado)?",
336
+ importAlias: "Alias de importaci\xF3n (ej: @/*)",
337
+ creating: "Creando proyecto Next.js...",
338
+ success: "\u2705 \xA1Proyecto creado con \xE9xito!",
339
+ error: "\u274C Error al crear el proyecto",
340
+ changingDirectory: "Cambiando al directorio del proyecto...",
341
+ validation: {
342
+ empty: "El nombre del proyecto no puede estar vac\xEDo",
343
+ invalid: "El nombre del proyecto solo puede contener letras, n\xFAmeros, guiones y guiones bajos"
344
+ },
345
+ folderExists: (name) => `La carpeta "${name}" ya existe. Por favor, elija otro nombre.`
346
+ },
347
+ vue: {
348
+ noVueDetected: "\u26A0\uFE0F No se detect\xF3 ning\xFAn proyecto Vue.js en el directorio actual.",
349
+ proposeSetup: "\xBFDesea crear un nuevo proyecto Vue.js con Vite?",
350
+ projectName: "Nombre del proyecto",
351
+ projectNamePlaceholder: "mi-proyecto-vue",
352
+ typescript: "\xBFUsar TypeScript?",
353
+ router: "\xBFUsar Vue Router?",
354
+ pinia: "\xBFUsar Pinia (gesti\xF3n de estado)?",
355
+ vitest: "\xBFUsar Vitest (pruebas)?",
356
+ eslint: "\xBFUsar ESLint?",
357
+ prettier: "\xBFUsar Prettier?",
358
+ creating: "Creando proyecto Vue.js con Vite...",
359
+ success: "\u2705 \xA1Proyecto creado con \xE9xito!",
360
+ error: "\u274C Error al crear el proyecto",
361
+ changingDirectory: "Cambiando al directorio del proyecto...",
362
+ validation: {
363
+ empty: "El nombre del proyecto no puede estar vac\xEDo",
364
+ invalid: "El nombre del proyecto solo puede contener letras, n\xFAmeros, guiones y guiones bajos"
365
+ },
366
+ folderExists: (name) => `La carpeta "${name}" ya existe. Por favor, elija otro nombre.`
367
+ }
368
+ };
369
+
370
+ // src/cli/i18n/index.ts
371
+ function getTranslations(lang) {
372
+ switch (lang) {
373
+ case "fr":
374
+ return fr;
375
+ case "en":
376
+ return en;
377
+ case "es":
378
+ return es;
379
+ default:
380
+ return en;
381
+ }
382
+ }
383
+
384
+ export {
385
+ getTranslations
386
+ };