fenge 0.6.2 → 0.7.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.
- package/CHANGELOG.md +26 -0
- package/README.md +1 -1
- package/package.json +8 -8
- package/src/bin/fenge.cli.js +1 -3
- package/src/command/install.js +3 -4
- package/src/command/uninstall.js +3 -3
- package/src/utils.js +4 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# fenge
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c4931eb: chore: upgrade deps
|
|
8
|
+
- Updated dependencies [c4931eb]
|
|
9
|
+
- Updated dependencies [9b7c7f4]
|
|
10
|
+
- Updated dependencies [d15775e]
|
|
11
|
+
- @fenge/eslint-config@0.6.1
|
|
12
|
+
|
|
13
|
+
## 0.7.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 28d8553: chore: required node ^18.20.0 or >=20.10.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [fe27531]
|
|
22
|
+
- Updated dependencies [28d8553]
|
|
23
|
+
- @fenge/tsconfig@0.5.0
|
|
24
|
+
- @fenge/prettier-config@0.3.0
|
|
25
|
+
- prettier-ignore@0.3.0
|
|
26
|
+
- @fenge/eslint-config@0.6.0
|
|
27
|
+
- @fenge/types@0.3.0
|
|
28
|
+
|
|
3
29
|
## 0.6.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -329,7 +329,7 @@ npm run prepare
|
|
|
329
329
|
## Contributing
|
|
330
330
|
|
|
331
331
|
- Clone this repository.
|
|
332
|
-
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable
|
|
332
|
+
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` or globally install [@rnm/pm](https://www.npmjs.com/package/@rnm/pm).
|
|
333
333
|
- Install dependencies using `pnpm install`.
|
|
334
334
|
- Run `pnpm style:update` to develop.
|
|
335
335
|
- Start coding and submit your PR.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fenge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "A CLI tool for code quality",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"commander": "13.1.0",
|
|
48
48
|
"eslint": "9.22.0",
|
|
49
49
|
"lilconfig": "3.1.3",
|
|
50
|
-
"lint-staged": "15.
|
|
50
|
+
"lint-staged": "15.5.0",
|
|
51
51
|
"ora": "8.2.0",
|
|
52
52
|
"prettier": "3.5.3",
|
|
53
53
|
"yoctocolors": "2.1.1",
|
|
54
|
-
"@fenge/eslint-config": "0.
|
|
55
|
-
"@fenge/
|
|
56
|
-
"@fenge/
|
|
57
|
-
"@fenge/
|
|
58
|
-
"prettier-ignore": "0.
|
|
54
|
+
"@fenge/eslint-config": "0.6.1",
|
|
55
|
+
"@fenge/prettier-config": "0.3.0",
|
|
56
|
+
"@fenge/types": "0.3.0",
|
|
57
|
+
"@fenge/tsconfig": "0.5.0",
|
|
58
|
+
"prettier-ignore": "0.3.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "22.13.10"
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
72
|
+
"node": "^18.20.0 || >=20.10.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsc --noEmit"
|
package/src/bin/fenge.cli.js
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
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" };
|
|
6
7
|
import { format } from "../command/format.js";
|
|
7
8
|
import { install } from "../command/install.js";
|
|
8
9
|
import { lint } from "../command/lint.js";
|
|
9
10
|
import { uninstall } from "../command/uninstall.js";
|
|
10
|
-
import { importJson } from "../utils.js";
|
|
11
|
-
|
|
12
|
-
const pkgJson = await importJson(import.meta.url, "../../package.json");
|
|
13
11
|
|
|
14
12
|
const program = new Command().enablePositionalOptions();
|
|
15
13
|
|
package/src/command/install.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import
|
|
5
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
6
|
+
import { dir, exists, getBinPath } from "../utils.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @param {string} file
|
|
@@ -21,9 +22,7 @@ async function writeGitHook(file, content) {
|
|
|
21
22
|
|
|
22
23
|
const hookFilePath = path.resolve(hooksPath, file);
|
|
23
24
|
if (await exists(hookFilePath)) {
|
|
24
|
-
const pkgJsonName =
|
|
25
|
-
await importJson(import.meta.url, "../../package.json")
|
|
26
|
-
).name; // fenge
|
|
25
|
+
const pkgJsonName = packageJson.name; // fenge
|
|
27
26
|
if (!(await fs.readFile(hookFilePath, "utf8")).includes(pkgJsonName)) {
|
|
28
27
|
throw new Error(
|
|
29
28
|
`Cannot install git hook file since ${hookFilePath} is already existing. Please remove it first.`,
|
package/src/command/uninstall.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import
|
|
5
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
6
|
+
import { exists } from "../utils.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @param {string} file
|
|
9
10
|
*/
|
|
10
11
|
async function removeGitHook(file) {
|
|
11
|
-
const pkgJsonName =
|
|
12
|
-
.name; // fenge
|
|
12
|
+
const pkgJsonName = packageJson.name; // fenge
|
|
13
13
|
const hookFilePath = path.resolve(process.cwd(), ".git", "hooks", file);
|
|
14
14
|
if (
|
|
15
15
|
(await exists(hookFilePath)) &&
|
package/src/utils.js
CHANGED
|
@@ -40,18 +40,6 @@ export async function resolveConfig(module, loadPath) {
|
|
|
40
40
|
: await searcher.search(process.cwd());
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* Usage: `importJson(import.meta.url, '../xx.json')`
|
|
45
|
-
* @param {string} importMetaUrl
|
|
46
|
-
* @param {string} jsonPath
|
|
47
|
-
* @returns {Promise<any>}
|
|
48
|
-
*/
|
|
49
|
-
export async function importJson(importMetaUrl, jsonPath) {
|
|
50
|
-
return JSON.parse(
|
|
51
|
-
await fs.readFile(path.resolve(dir(importMetaUrl), jsonPath), "utf8"),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
43
|
/**
|
|
56
44
|
* @param {number} startTime
|
|
57
45
|
*/
|
|
@@ -150,21 +138,23 @@ function getExitCode(error) {
|
|
|
150
138
|
export async function getBinPath(
|
|
151
139
|
moduleName,
|
|
152
140
|
from = fileURLToPath(import.meta.url),
|
|
141
|
+
cliName = moduleName,
|
|
153
142
|
) {
|
|
154
143
|
const fromPath =
|
|
155
144
|
!from.endsWith(path.sep) && (await fs.stat(from)).isDirectory()
|
|
156
145
|
? from + path.sep
|
|
157
146
|
: from;
|
|
158
|
-
const cliName = moduleName;
|
|
159
147
|
const packageJsonPath = createRequire(fromPath).resolve(
|
|
160
148
|
`${moduleName}/package.json`,
|
|
161
149
|
);
|
|
162
150
|
/** @type {any} */
|
|
163
151
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
164
|
-
const modulePath =
|
|
152
|
+
const modulePath = path.dirname(packageJsonPath);
|
|
165
153
|
const binPath =
|
|
166
154
|
typeof packageJson.bin === "string"
|
|
167
155
|
? packageJson.bin
|
|
168
156
|
: packageJson.bin[cliName];
|
|
157
|
+
if (typeof binPath !== "string")
|
|
158
|
+
throw new Error(`Cannot find bin ${cliName} in module ${moduleName}`);
|
|
169
159
|
return path.resolve(modulePath, binPath);
|
|
170
160
|
}
|