@dhzh/eslint-config 1.27.0 → 1.27.1

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.
@@ -13,7 +13,7 @@ node_path = require_chunk.__toESM(node_path, 1);
13
13
  let node_fs = require("node:fs");
14
14
  node_fs = require_chunk.__toESM(node_fs, 1);
15
15
  //#region package.json
16
- var version = "1.27.0";
16
+ var version = "1.27.1";
17
17
  var devDependencies = {
18
18
  "@eslint/config-inspector": "^2.0.0",
19
19
  "@prettier/plugin-xml": "^3.4.2",
@@ -33,6 +33,22 @@ var devDependencies = {
33
33
  };
34
34
  //#endregion
35
35
  //#region src/cli/stages/update-package-json.ts
36
+ async function ensureScript(scripts, name, command) {
37
+ if (scripts[name] == null) {
38
+ scripts[name] = command;
39
+ return;
40
+ }
41
+ if (scripts[name] === command) return;
42
+ const shouldOverride = await _clack_prompts.confirm({
43
+ message: `Script "${name}" already exists as "${String(scripts[name])}". Replace it with "${command}"?`,
44
+ initialValue: true
45
+ });
46
+ if (_clack_prompts.isCancel(shouldOverride)) {
47
+ _clack_prompts.cancel("Operation cancelled");
48
+ throw new Error("Operation cancelled");
49
+ }
50
+ if (shouldOverride) scripts[name] = command;
51
+ }
36
52
  async function updatePackageJson() {
37
53
  const cwd = node_process.default.cwd();
38
54
  const pathPackageJSON = node_path.default.join(cwd, "package.json");
@@ -43,8 +59,8 @@ async function updatePackageJson() {
43
59
  pkg.devDependencies["@dhzh/eslint-config"] = `^${version}`;
44
60
  pkg.devDependencies.eslint ??= devDependencies.eslint;
45
61
  pkg.scripts ??= {};
46
- pkg.scripts.lint = "eslint .";
47
- pkg.scripts["lint-fix"] = "eslint --fix .";
62
+ await ensureScript(pkg.scripts, "lint", "eslint");
63
+ await ensureScript(pkg.scripts, "lint-fix", "eslint --fix .");
48
64
  await node_fs_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
49
65
  _clack_prompts.log.success(ansis.default.green`Changes wrote to package.json`);
50
66
  }
@@ -6,7 +6,7 @@ import fsp from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import fs from "node:fs";
8
8
  //#region package.json
9
- var version = "1.27.0";
9
+ var version = "1.27.1";
10
10
  var devDependencies = {
11
11
  "@eslint/config-inspector": "^2.0.0",
12
12
  "@prettier/plugin-xml": "^3.4.2",
@@ -26,6 +26,22 @@ var devDependencies = {
26
26
  };
27
27
  //#endregion
28
28
  //#region src/cli/stages/update-package-json.ts
29
+ async function ensureScript(scripts, name, command) {
30
+ if (scripts[name] == null) {
31
+ scripts[name] = command;
32
+ return;
33
+ }
34
+ if (scripts[name] === command) return;
35
+ const shouldOverride = await p.confirm({
36
+ message: `Script "${name}" already exists as "${String(scripts[name])}". Replace it with "${command}"?`,
37
+ initialValue: true
38
+ });
39
+ if (p.isCancel(shouldOverride)) {
40
+ p.cancel("Operation cancelled");
41
+ throw new Error("Operation cancelled");
42
+ }
43
+ if (shouldOverride) scripts[name] = command;
44
+ }
29
45
  async function updatePackageJson() {
30
46
  const cwd = process.cwd();
31
47
  const pathPackageJSON = path.join(cwd, "package.json");
@@ -36,8 +52,8 @@ async function updatePackageJson() {
36
52
  pkg.devDependencies["@dhzh/eslint-config"] = `^${version}`;
37
53
  pkg.devDependencies.eslint ??= devDependencies.eslint;
38
54
  pkg.scripts ??= {};
39
- pkg.scripts.lint = "eslint .";
40
- pkg.scripts["lint-fix"] = "eslint --fix .";
55
+ await ensureScript(pkg.scripts, "lint", "eslint");
56
+ await ensureScript(pkg.scripts, "lint-fix", "eslint --fix .");
41
57
  await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
42
58
  p.log.success(c.green`Changes wrote to package.json`);
43
59
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/eslint-config",
3
3
  "type": "module",
4
- "version": "1.27.0",
4
+ "version": "1.27.1",
5
5
  "description": "tinywaves's ESLint config",
6
6
  "author": {
7
7
  "name": "Lyle Zheng",