@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.
- package/README.fr.md +1 -1
- package/README.md +16 -2
- package/dist/{check-XDGAGYOE.js → check-AJ4GD66M.js} +6 -5
- package/dist/chunk-3NRMV3WL.js +569 -0
- package/dist/chunk-HM2JWJOO.js +418 -0
- package/dist/{chunk-OAAGGK2H.js → chunk-JTTIDBSN.js} +361 -317
- package/dist/chunk-MQV3WNMH.js +114 -0
- package/dist/chunk-QBMH2K7B.js +386 -0
- package/dist/{chunk-BVXGN3AC.js → chunk-TVZWTKJU.js} +316 -224
- package/dist/{chunk-4VHPGJVU.js → chunk-V75HW2AM.js} +8557 -6661
- package/dist/cli.js +23 -9
- package/dist/{installed-IKSARZIK.js → installed-WA6I2IFD.js} +4 -3
- package/dist/{list-IJK225B3.js → list-Y7I5NUWT.js} +3 -2
- package/dist/nextjs-command-4G7N6VPP.js +59 -0
- package/dist/nextjs-installer-5C3VBCZE.js +80 -0
- package/dist/nextjs-setup-YYXNONJ6.js +100 -0
- package/dist/react-command-C47QFAJ5.js +59 -0
- package/dist/{remove-IIT34Y3T.js → remove-JBICRDXX.js} +4 -3
- package/dist/vite-installer-OPE53M3C.js +49 -0
- package/dist/vite-setup-B5TXMX72.js +51 -0
- package/dist/vue-command-6I7JVUI2.js +73 -0
- package/dist/vue-installer-2VSYMM6R.js +74 -0
- package/dist/vue-setup-WY57VJB3.js +91 -0
- package/package.json +5 -2
- package/dist/chunk-QRFLHLFE.js +0 -300
- package/dist/chunk-WKYUK64P.js +0 -308
- package/dist/install-APYIRHSN.js +0 -258
- package/dist/install-nextjs-C3LEKJLY.js +0 -353
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Installer,
|
|
3
|
-
SpinnerManager,
|
|
4
|
-
displayInstallationReport,
|
|
5
|
-
getTranslations,
|
|
6
|
-
promptConfirmation,
|
|
7
|
-
promptLanguage,
|
|
8
|
-
promptPluginSelection
|
|
9
|
-
} from "./chunk-OAAGGK2H.js";
|
|
10
|
-
import {
|
|
11
|
-
CompatibilityValidator,
|
|
12
|
-
compatibilityRules
|
|
13
|
-
} from "./chunk-WKYUK64P.js";
|
|
14
|
-
import {
|
|
15
|
-
BackupManager,
|
|
16
|
-
ConfigWriter,
|
|
17
|
-
pluginRegistry
|
|
18
|
-
} from "./chunk-4VHPGJVU.js";
|
|
19
|
-
import {
|
|
20
|
-
DetectionError,
|
|
21
|
-
detectContext
|
|
22
|
-
} from "./chunk-BVXGN3AC.js";
|
|
23
|
-
import {
|
|
24
|
-
checkPathExists,
|
|
25
|
-
logger
|
|
26
|
-
} from "./chunk-QRFLHLFE.js";
|
|
27
|
-
import "./chunk-QGM4M3NI.js";
|
|
28
|
-
|
|
29
|
-
// src/cli/prompts/nextjs-setup.ts
|
|
30
|
-
import inquirer from "inquirer";
|
|
31
|
-
async function promptNextjsSetup(language) {
|
|
32
|
-
const t = getTranslations(language);
|
|
33
|
-
const answers = await inquirer.prompt([
|
|
34
|
-
{
|
|
35
|
-
type: "confirm",
|
|
36
|
-
name: "shouldCreate",
|
|
37
|
-
message: t.nextjs.proposeSetup,
|
|
38
|
-
default: true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: "input",
|
|
42
|
-
name: "projectName",
|
|
43
|
-
message: t.nextjs.projectName,
|
|
44
|
-
default: t.nextjs.projectNamePlaceholder,
|
|
45
|
-
when: (answers2) => answers2.shouldCreate === true,
|
|
46
|
-
validate: (input) => {
|
|
47
|
-
if (!input || input.trim().length === 0) {
|
|
48
|
-
return t.nextjs.validation.empty;
|
|
49
|
-
}
|
|
50
|
-
if (!/^[a-z0-9-_]+$/i.test(input)) {
|
|
51
|
-
return t.nextjs.validation.invalid;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
type: "confirm",
|
|
58
|
-
name: "typescript",
|
|
59
|
-
message: t.nextjs.typescript,
|
|
60
|
-
default: true,
|
|
61
|
-
when: (answers2) => answers2.shouldCreate === true
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
type: "confirm",
|
|
65
|
-
name: "eslint",
|
|
66
|
-
message: t.nextjs.eslint,
|
|
67
|
-
default: true,
|
|
68
|
-
when: (answers2) => answers2.shouldCreate === true
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: "confirm",
|
|
72
|
-
name: "tailwind",
|
|
73
|
-
message: t.nextjs.tailwind,
|
|
74
|
-
default: true,
|
|
75
|
-
when: (answers2) => answers2.shouldCreate === true
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
type: "confirm",
|
|
79
|
-
name: "srcDir",
|
|
80
|
-
message: t.nextjs.srcDir,
|
|
81
|
-
default: false,
|
|
82
|
-
when: (answers2) => answers2.shouldCreate === true
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
type: "confirm",
|
|
86
|
-
name: "appRouter",
|
|
87
|
-
message: t.nextjs.appRouter,
|
|
88
|
-
default: true,
|
|
89
|
-
when: (answers2) => answers2.shouldCreate === true
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: "input",
|
|
93
|
-
name: "importAlias",
|
|
94
|
-
message: t.nextjs.importAlias,
|
|
95
|
-
default: "@/*",
|
|
96
|
-
when: (answers2) => answers2.shouldCreate === true,
|
|
97
|
-
validate: (input) => {
|
|
98
|
-
if (!input || input.trim().length === 0) {
|
|
99
|
-
return "L'alias d'import ne peut pas \xEAtre vide";
|
|
100
|
-
}
|
|
101
|
-
if (!/^[@~]\/\*$/.test(input.trim())) {
|
|
102
|
-
return "L'alias doit \xEAtre au format @/* ou ~/*";
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
]);
|
|
108
|
-
if (!answers.shouldCreate) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
projectName: answers.projectName.trim(),
|
|
113
|
-
typescript: answers.typescript,
|
|
114
|
-
eslint: answers.eslint,
|
|
115
|
-
tailwind: answers.tailwind,
|
|
116
|
-
srcDir: answers.srcDir,
|
|
117
|
-
appRouter: answers.appRouter,
|
|
118
|
-
importAlias: answers.importAlias.trim()
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/cli/utils/nextjs-installer.ts
|
|
123
|
-
import { resolve } from "path";
|
|
124
|
-
import { execa } from "execa";
|
|
125
|
-
async function createNextjsProject(options, currentDir, language) {
|
|
126
|
-
const t = getTranslations(language);
|
|
127
|
-
const {
|
|
128
|
-
projectName,
|
|
129
|
-
typescript,
|
|
130
|
-
eslint,
|
|
131
|
-
tailwind,
|
|
132
|
-
srcDir,
|
|
133
|
-
appRouter,
|
|
134
|
-
importAlias
|
|
135
|
-
} = options;
|
|
136
|
-
const projectPath = resolve(currentDir, projectName);
|
|
137
|
-
if (await checkPathExists(projectPath)) {
|
|
138
|
-
throw new Error(t.nextjs.folderExists(projectName));
|
|
139
|
-
}
|
|
140
|
-
logger.info(t.nextjs.creating);
|
|
141
|
-
try {
|
|
142
|
-
const args = ["create", "next-app@latest", projectName];
|
|
143
|
-
if (typescript) {
|
|
144
|
-
args.push("--typescript");
|
|
145
|
-
} else {
|
|
146
|
-
args.push("--javascript");
|
|
147
|
-
}
|
|
148
|
-
if (eslint) {
|
|
149
|
-
args.push("--eslint");
|
|
150
|
-
} else {
|
|
151
|
-
args.push("--no-eslint");
|
|
152
|
-
}
|
|
153
|
-
if (tailwind) {
|
|
154
|
-
args.push("--tailwind");
|
|
155
|
-
} else {
|
|
156
|
-
args.push("--no-tailwind");
|
|
157
|
-
}
|
|
158
|
-
if (srcDir) {
|
|
159
|
-
args.push("--src-dir");
|
|
160
|
-
} else {
|
|
161
|
-
args.push("--no-src-dir");
|
|
162
|
-
}
|
|
163
|
-
if (appRouter) {
|
|
164
|
-
args.push("--app");
|
|
165
|
-
} else {
|
|
166
|
-
args.push("--pages");
|
|
167
|
-
}
|
|
168
|
-
args.push("--import-alias", importAlias);
|
|
169
|
-
const result = await execa("npm", args, {
|
|
170
|
-
cwd: currentDir,
|
|
171
|
-
stdio: "inherit",
|
|
172
|
-
env: {
|
|
173
|
-
...process.env,
|
|
174
|
-
// Désactiver les prompts interactifs de create-next-app
|
|
175
|
-
npm_config_yes: "true"
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
if (result.exitCode !== 0) {
|
|
179
|
-
throw new Error(`${t.nextjs.error}: exit code ${result.exitCode}`);
|
|
180
|
-
}
|
|
181
|
-
logger.success(t.nextjs.success);
|
|
182
|
-
logger.info(t.nextjs.changingDirectory);
|
|
183
|
-
return projectPath;
|
|
184
|
-
} catch (error) {
|
|
185
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
186
|
-
logger.error(`${t.nextjs.error}: ${errorMessage}`);
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// src/cli/commands/install-nextjs.ts
|
|
192
|
-
import pc from "picocolors";
|
|
193
|
-
async function installNextjs(options) {
|
|
194
|
-
try {
|
|
195
|
-
const language = await promptLanguage();
|
|
196
|
-
const t = getTranslations(language);
|
|
197
|
-
console.log();
|
|
198
|
-
console.log(pc.bold(pc.cyan(`\u{1F50D} ${t.detection.detecting}`)));
|
|
199
|
-
let projectRoot = process.cwd();
|
|
200
|
-
let ctx;
|
|
201
|
-
try {
|
|
202
|
-
ctx = await detectContext(projectRoot);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
if (error instanceof DetectionError) {
|
|
205
|
-
console.log();
|
|
206
|
-
console.log(pc.yellow(t.nextjs.noNextjsDetected));
|
|
207
|
-
console.log();
|
|
208
|
-
const nextjsOptions = await promptNextjsSetup(language);
|
|
209
|
-
if (!nextjsOptions) {
|
|
210
|
-
console.log();
|
|
211
|
-
console.log(pc.gray(t.common.cancel));
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const newProjectPath = await createNextjsProject(
|
|
215
|
-
nextjsOptions,
|
|
216
|
-
projectRoot,
|
|
217
|
-
language
|
|
218
|
-
);
|
|
219
|
-
process.chdir(newProjectPath);
|
|
220
|
-
projectRoot = newProjectPath;
|
|
221
|
-
console.log();
|
|
222
|
-
ctx = await detectContext(projectRoot);
|
|
223
|
-
} else {
|
|
224
|
-
throw error;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (ctx.framework !== "nextjs") {
|
|
228
|
-
console.log();
|
|
229
|
-
console.log(
|
|
230
|
-
pc.yellow(
|
|
231
|
-
`\u26A0\uFE0F Framework d\xE9tect\xE9: ${ctx.framework}. Cette commande est destin\xE9e aux projets Next.js.`
|
|
232
|
-
)
|
|
233
|
-
);
|
|
234
|
-
console.log(
|
|
235
|
-
pc.gray(
|
|
236
|
-
'Utilisez "npx @configjs/cli react" pour les projets React standard.'
|
|
237
|
-
)
|
|
238
|
-
);
|
|
239
|
-
console.log();
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
console.log(
|
|
243
|
-
pc.green(` \u2713 ${t.detection.framework}: `) + pc.bold(`${ctx.framework} ${pc.gray(ctx.frameworkVersion)}`)
|
|
244
|
-
);
|
|
245
|
-
console.log(
|
|
246
|
-
pc.green(` \u2713 ${t.detection.typescript}: `) + pc.bold(ctx.typescript ? "Oui" : "Non")
|
|
247
|
-
);
|
|
248
|
-
if (ctx.bundler) {
|
|
249
|
-
console.log(
|
|
250
|
-
pc.green(` \u2713 ${t.detection.bundler}: `) + pc.bold(`${ctx.bundler} ${pc.gray(ctx.bundlerVersion || "")}`)
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
console.log(
|
|
254
|
-
pc.green(` \u2713 ${t.detection.packageManager}: `) + pc.bold(ctx.packageManager)
|
|
255
|
-
);
|
|
256
|
-
console.log();
|
|
257
|
-
let selectedPlugins = [];
|
|
258
|
-
if (options.yes) {
|
|
259
|
-
logger.info("Using default recommendations (--yes mode)");
|
|
260
|
-
} else {
|
|
261
|
-
selectedPlugins = await promptPluginSelection(
|
|
262
|
-
ctx,
|
|
263
|
-
pluginRegistry,
|
|
264
|
-
language
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
if (selectedPlugins.length === 0) {
|
|
268
|
-
console.log();
|
|
269
|
-
console.log(pc.yellow(`\u26A0\uFE0F ${t.common.selected(0)}`));
|
|
270
|
-
console.log(pc.gray("Exiting..."));
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
console.log();
|
|
274
|
-
console.log(
|
|
275
|
-
pc.bold(pc.green(`\u2713 ${t.common.selected(selectedPlugins.length)}`))
|
|
276
|
-
);
|
|
277
|
-
console.log();
|
|
278
|
-
if (!options.yes && !options.silent) {
|
|
279
|
-
const confirmed = await promptConfirmation(selectedPlugins, language);
|
|
280
|
-
if (!confirmed) {
|
|
281
|
-
console.log(t.common.cancel);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (options.dryRun) {
|
|
286
|
-
console.log();
|
|
287
|
-
console.log(pc.bold(pc.yellow("\u2501".repeat(60))));
|
|
288
|
-
console.log(pc.bold(pc.yellow("\u{1F50D} MODE DRY-RUN (simulation uniquement)")));
|
|
289
|
-
console.log(pc.bold(pc.yellow("\u2501".repeat(60))));
|
|
290
|
-
console.log();
|
|
291
|
-
console.log(pc.bold(pc.cyan("\u{1F4E6} Packages \xE0 installer :")));
|
|
292
|
-
for (const plugin of selectedPlugins) {
|
|
293
|
-
console.log(
|
|
294
|
-
pc.blue(` \u2022 ${plugin.displayName}`) + pc.gray(
|
|
295
|
-
` (${plugin.name}${plugin.version ? `@${plugin.version}` : ""})`
|
|
296
|
-
)
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
console.log();
|
|
300
|
-
console.log(pc.bold(pc.cyan("\u{1F4DD} Fichiers qui seraient cr\xE9\xE9s/modifi\xE9s :")));
|
|
301
|
-
for (const plugin of selectedPlugins) {
|
|
302
|
-
console.log(pc.gray(` \u2022 ${plugin.displayName} configuration`));
|
|
303
|
-
}
|
|
304
|
-
console.log();
|
|
305
|
-
console.log(
|
|
306
|
-
pc.yellow("\u26A0\uFE0F Aucune modification n'a \xE9t\xE9 effectu\xE9e (dry-run)")
|
|
307
|
-
);
|
|
308
|
-
console.log(
|
|
309
|
-
pc.cyan("\u{1F4A1} Ex\xE9cutez sans --dry-run pour appliquer les changements")
|
|
310
|
-
);
|
|
311
|
-
console.log();
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const backupManager = new BackupManager();
|
|
315
|
-
const configWriter = new ConfigWriter(backupManager);
|
|
316
|
-
const validator = new CompatibilityValidator(compatibilityRules);
|
|
317
|
-
const installer = new Installer(ctx, validator, configWriter, backupManager);
|
|
318
|
-
if (options.install === false) {
|
|
319
|
-
console.log();
|
|
320
|
-
console.log(pc.yellow("\u2699\uFE0F Mode configuration uniquement (--no-install)"));
|
|
321
|
-
console.log(pc.gray("Les packages ne seront PAS install\xE9s"));
|
|
322
|
-
console.log();
|
|
323
|
-
}
|
|
324
|
-
const spinner = new SpinnerManager();
|
|
325
|
-
spinner.start(t.installation.installing);
|
|
326
|
-
try {
|
|
327
|
-
const result = await installer.install(selectedPlugins, {
|
|
328
|
-
skipPackageInstall: options.install === false
|
|
329
|
-
});
|
|
330
|
-
spinner.succeed(t.installation.success);
|
|
331
|
-
if (result.success) {
|
|
332
|
-
displayInstallationReport(result, selectedPlugins, language);
|
|
333
|
-
} else {
|
|
334
|
-
console.error(`
|
|
335
|
-
${t.installation.error}`);
|
|
336
|
-
process.exit(1);
|
|
337
|
-
}
|
|
338
|
-
} catch (error) {
|
|
339
|
-
spinner.fail(t.installation.error);
|
|
340
|
-
throw error;
|
|
341
|
-
}
|
|
342
|
-
} catch (error) {
|
|
343
|
-
logger.error("Installation failed:", error);
|
|
344
|
-
if (error instanceof Error) {
|
|
345
|
-
console.error(`
|
|
346
|
-
\u274C ${error.message}`);
|
|
347
|
-
}
|
|
348
|
-
process.exit(1);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
export {
|
|
352
|
-
installNextjs
|
|
353
|
-
};
|