fenge 0.10.4 → 0.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fenge",
3
- "version": "0.10.4",
3
+ "version": "0.12.0",
4
4
  "description": "A CLI tool for code quality",
5
5
  "keywords": [
6
6
  "cli",
@@ -51,9 +51,9 @@
51
51
  "prettier": "3.6.2",
52
52
  "pretty-ms": "9.3.0",
53
53
  "yoctocolors": "2.1.2",
54
- "@fenge/tsconfig": "0.7.0",
54
+ "@fenge/eslint-config": "0.7.16",
55
55
  "@fenge/prettier-config": "0.3.10",
56
- "@fenge/eslint-config": "0.7.14",
56
+ "@fenge/tsconfig": "0.9.0",
57
57
  "prettier-ignore": "0.4.0"
58
58
  },
59
59
  "devDependencies": {
@@ -71,6 +71,6 @@
71
71
  "node": "^18.20.0 || >=20.10.0"
72
72
  },
73
73
  "scripts": {
74
- "build": "tsc --noEmit"
74
+ "test": "tsc --noEmit"
75
75
  }
76
76
  }
@@ -3,14 +3,15 @@
3
3
  import process from "node:process";
4
4
  import { initAction, setup } from "@fenge/tsconfig/setup";
5
5
  import { Command } from "commander";
6
- import pkgJson from "../../package.json" with { type: "json" };
7
6
  import { format } from "../command/format.js";
8
7
  import { install } from "../command/install.js";
9
8
  import { lint } from "../command/lint.js";
10
9
  import { uninstall } from "../command/uninstall.js";
10
+ import { getPkgJson } from "../utils.js";
11
11
 
12
12
  const program = new Command().enablePositionalOptions();
13
13
 
14
+ const pkgJson = await getPkgJson();
14
15
  program
15
16
  .name(pkgJson.name)
16
17
  .version(pkgJson.version, "-v, --version")
@@ -2,8 +2,7 @@
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
- import packageJson from "../../package.json" with { type: "json" };
6
- import { dir, exists, getBinPath } from "../utils.js";
5
+ import { dir, exists, getBinPath, getPkgJson } from "../utils.js";
7
6
 
8
7
  /**
9
8
  * @param {string} file
@@ -22,7 +21,7 @@ async function writeGitHook(file, content) {
22
21
 
23
22
  const hookFilePath = path.resolve(hooksPath, file);
24
23
  if (await exists(hookFilePath)) {
25
- const pkgJsonName = packageJson.name; // fenge
24
+ const pkgJsonName = (await getPkgJson()).name; // fenge
26
25
  if (!(await fs.readFile(hookFilePath, "utf8")).includes(pkgJsonName)) {
27
26
  throw new Error(
28
27
  `Cannot install git hook file since ${hookFilePath} is already existing. Please remove it first.`,
@@ -2,14 +2,13 @@
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
- import packageJson from "../../package.json" with { type: "json" };
6
- import { exists } from "../utils.js";
5
+ import { exists, getPkgJson } from "../utils.js";
7
6
 
8
7
  /**
9
8
  * @param {string} file
10
9
  */
11
10
  async function removeGitHook(file) {
12
- const pkgJsonName = packageJson.name; // fenge
11
+ const pkgJsonName = (await getPkgJson()).name; // fenge
13
12
  const hookFilePath = path.resolve(process.cwd(), ".git", "hooks", file);
14
13
  if (
15
14
  (await exists(hookFilePath)) &&
package/src/utils.js CHANGED
@@ -12,6 +12,17 @@ import ora from "ora";
12
12
  import prettyMs from "pretty-ms";
13
13
  import colors from "yoctocolors";
14
14
 
15
+ /**
16
+ * @returns {Promise<{name: string, version: string}>}
17
+ */
18
+ export async function getPkgJson() {
19
+ const content = await fs.readFile(
20
+ path.join(dir(import.meta.url), "..", "package.json"),
21
+ "utf8",
22
+ );
23
+ return JSON.parse(content);
24
+ }
25
+
15
26
  /**
16
27
  * @param {string} filepath
17
28
  */