@isentinel/eslint-config 1.2.4 → 1.2.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/dist/cli.js +29 -21
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ init_esm_shims();
|
|
|
18
18
|
import ansis from "ansis";
|
|
19
19
|
|
|
20
20
|
// package.json
|
|
21
|
-
var version = "1.2.
|
|
21
|
+
var version = "1.2.6";
|
|
22
22
|
var package_default = {
|
|
23
23
|
name: "@isentinel/eslint-config",
|
|
24
24
|
version,
|
|
@@ -329,7 +329,7 @@ var versionsMap = {
|
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
// src/cli/stages/update-package-json.ts
|
|
332
|
-
async function updatePackageJson() {
|
|
332
|
+
async function updatePackageJson(result) {
|
|
333
333
|
const cwd = process2.cwd();
|
|
334
334
|
const pathPackageJSON = path2.join(cwd, "package.json");
|
|
335
335
|
log2.step(ansis3.cyan(`Bumping @isentinel/eslint-config to v${version}`));
|
|
@@ -339,9 +339,13 @@ async function updatePackageJson() {
|
|
|
339
339
|
parsedPackage.devDependencies["@isentinel/eslint-config"] = `^${version}`;
|
|
340
340
|
parsedPackage.devDependencies.eslint ??= versionsMap.eslint;
|
|
341
341
|
const addedPackages = [];
|
|
342
|
-
for (const
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
for (const framework of result.frameworks) {
|
|
343
|
+
if (framework in dependenciesMap) {
|
|
344
|
+
for (const dep of dependenciesMap[framework]) {
|
|
345
|
+
parsedPackage.devDependencies[dep] = versionsMap[dep];
|
|
346
|
+
addedPackages.push(dep);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
345
349
|
}
|
|
346
350
|
if (addedPackages.length) {
|
|
347
351
|
note2(`${ansis3.dim(addedPackages.join(", "))}`, "Added packages");
|
|
@@ -386,41 +390,42 @@ async function updateVscodeSettings(result) {
|
|
|
386
390
|
// src/cli/run.ts
|
|
387
391
|
async function run(options = {}) {
|
|
388
392
|
const argumentSkipPrompt = !!process4.env.SKIP_PROMPT || options.yes;
|
|
389
|
-
const argumentTemplate = options.frameworks?.map((framework) => framework
|
|
393
|
+
const argumentTemplate = options.frameworks?.map((framework) => framework.trim());
|
|
390
394
|
const eslintConfigFiles = fs3.readdirSync(process4.cwd()).filter((file) => file.startsWith("eslint.config."));
|
|
391
395
|
if (eslintConfigFiles.length > 0) {
|
|
392
396
|
log4.warn(ansis5.yellow(`${eslintConfigFiles[0]} already exists, migration wizard exited.`));
|
|
393
397
|
return process4.exit(1);
|
|
394
398
|
}
|
|
395
399
|
let result = {
|
|
396
|
-
frameworks: argumentTemplate,
|
|
400
|
+
frameworks: argumentTemplate ?? [],
|
|
397
401
|
uncommittedConfirmed: false,
|
|
398
402
|
updateVscodeSettings: true
|
|
399
403
|
};
|
|
400
404
|
if (!argumentSkipPrompt) {
|
|
401
405
|
result = await group(
|
|
402
406
|
{
|
|
407
|
+
uncommittedConfirmed: () => {
|
|
408
|
+
if (argumentSkipPrompt || isGitClean()) {
|
|
409
|
+
return Promise.resolve(true);
|
|
410
|
+
}
|
|
411
|
+
return confirm({
|
|
412
|
+
initialValue: false,
|
|
413
|
+
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
// eslint-disable-next-line perfectionist/sort-objects -- keep the order of prompts
|
|
403
417
|
frameworks: ({ results }) => {
|
|
404
|
-
const isArgumentTemplateValid =
|
|
418
|
+
const isArgumentTemplateValid = argumentTemplate && argumentTemplate.length > 0 && argumentTemplate.every((template) => frameworks.includes(template));
|
|
405
419
|
if (!results.uncommittedConfirmed || isArgumentTemplateValid) {
|
|
406
420
|
return;
|
|
407
421
|
}
|
|
408
|
-
const message =
|
|
422
|
+
const message = argumentTemplate && argumentTemplate.length > 0 && !isArgumentTemplateValid ? `"${argumentTemplate.join(", ")}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
409
423
|
return multiselect({
|
|
410
424
|
message: ansis5.reset(message),
|
|
411
425
|
options: frameworkOptions,
|
|
412
426
|
required: false
|
|
413
427
|
});
|
|
414
428
|
},
|
|
415
|
-
uncommittedConfirmed: () => {
|
|
416
|
-
if (argumentSkipPrompt || isGitClean()) {
|
|
417
|
-
return Promise.resolve(true);
|
|
418
|
-
}
|
|
419
|
-
return confirm({
|
|
420
|
-
initialValue: false,
|
|
421
|
-
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
422
|
-
});
|
|
423
|
-
},
|
|
424
429
|
updateVscodeSettings: ({ results }) => {
|
|
425
430
|
if (!results.uncommittedConfirmed) {
|
|
426
431
|
return;
|
|
@@ -442,7 +447,7 @@ async function run(options = {}) {
|
|
|
442
447
|
return process4.exit(1);
|
|
443
448
|
}
|
|
444
449
|
}
|
|
445
|
-
await updatePackageJson();
|
|
450
|
+
await updatePackageJson(result);
|
|
446
451
|
await updateEslintFiles(result);
|
|
447
452
|
await updateVscodeSettings(result);
|
|
448
453
|
log4.success(ansis5.green("Setup completed"));
|
|
@@ -469,14 +474,17 @@ var instance = yargs(hideBin(process5.argv)).scriptName("@isentinel/eslint-confi
|
|
|
469
474
|
type: "boolean"
|
|
470
475
|
}).option("template", {
|
|
471
476
|
alias: "t",
|
|
472
|
-
description: "Use the framework template for optimal customization: react",
|
|
477
|
+
description: "Use the framework template for optimal customization: react, jest",
|
|
473
478
|
type: "string"
|
|
474
479
|
}).help();
|
|
475
480
|
},
|
|
476
481
|
async (args) => {
|
|
477
482
|
header();
|
|
478
483
|
try {
|
|
479
|
-
await run(
|
|
484
|
+
await run({
|
|
485
|
+
...args,
|
|
486
|
+
frameworks: args.template ? [args.template] : void 0
|
|
487
|
+
});
|
|
480
488
|
} catch (err) {
|
|
481
489
|
log5.error(ansis6.inverse(ansis6.red(" Failed to migrate ")));
|
|
482
490
|
log5.error(ansis6.red(`\u2718 ${String(err)}`));
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isentinel/eslint-config",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "iSentinel's ESLint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"simple-git-hooks": "2.12.1",
|
|
111
111
|
"tsup": "8.4.0",
|
|
112
112
|
"typescript": "5.8.3",
|
|
113
|
-
"@isentinel/eslint-config": "1.2.
|
|
113
|
+
"@isentinel/eslint-config": "1.2.6"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@eslint-react/eslint-plugin": "^1.45.0",
|