fenge 0.1.7 → 0.2.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # fenge
2
2
 
3
+ ## 0.2.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - be7e3d5: chore(fenge): upgrade `prettier` to 3.4.1
8
+ - 4c6fa59: refactor(fenge): optimize tsconfig exports and rename tsconfig.json to index.json
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [5adeeed]
13
+ - Updated dependencies [36d1fb0]
14
+ - Updated dependencies [3605e14]
15
+ - Updated dependencies [0d71378]
16
+ - Updated dependencies [a5fb6f8]
17
+ - Updated dependencies [41c783a]
18
+ - Updated dependencies [b1fc095]
19
+ - Updated dependencies [3f4e737]
20
+ - Updated dependencies [1f5fce3]
21
+ - Updated dependencies [51502cc]
22
+ - Updated dependencies [2f12ec2]
23
+ - @fenge/prettier-config@0.1.3-beta.0
24
+ - @fenge/eslint-config@0.4.0-beta.0
25
+ - @fenge/types@0.2.0-beta.0
26
+ - @fenge/tsconfig@0.1.1-beta.0
27
+
28
+ ## 0.1.8
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [1848169]
33
+ - Updated dependencies [9f04b44]
34
+ - Updated dependencies [55cf874]
35
+ - @fenge/prettier-config@0.1.2
36
+ - @fenge/eslint-config@0.3.0
37
+
3
38
  ## 0.1.7
4
39
 
5
40
  ### Patch Changes
package/README.md CHANGED
@@ -125,7 +125,7 @@ Config `tsconfig.json` file in your project root.
125
125
  }
126
126
  ```
127
127
 
128
- Config `tsconfig.build.json` file in sub-package or project root.
128
+ Config `tsconfig.build.json` file in your project root.
129
129
 
130
130
  ```json
131
131
  {
@@ -242,7 +242,6 @@ export default {
242
242
  omit: ["no-var"], // these rules will not work for js files
243
243
  })
244
244
  .enableTypescript({
245
- project: "tsconfig.json", // tsconfig.json path
246
245
  extend: {
247
246
  // apply additional rules for ts files
248
247
  "@typescript-eslint/no-explicit-any": "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fenge",
3
- "version": "0.1.7",
3
+ "version": "0.2.0-beta.0",
4
4
  "description": "A CLI tool for code quality",
5
5
  "keywords": [
6
6
  "cli",
@@ -35,9 +35,12 @@
35
35
  "./types": {
36
36
  "types": "./types/index.d.ts"
37
37
  },
38
- "./tsconfig": "./tsconfig/tsconfig.json",
39
- "./tsconfig/*": "./tsconfig/*.json",
40
- "./tsconfig/*.json": "./tsconfig/*.json"
38
+ "./tsconfig": "./tsconfig/index.json",
39
+ "./tsconfig.json": "./tsconfig/index.json",
40
+ "./tsconfig/esm": "./tsconfig/esm.json",
41
+ "./tsconfig/esm.json": "./tsconfig/esm.json",
42
+ "./tsconfig/cjs": "./tsconfig/cjs.json",
43
+ "./tsconfig/cjs.json": "./tsconfig/cjs.json"
41
44
  },
42
45
  "bin": "./src/bin/cli.js",
43
46
  "dependencies": {
@@ -47,15 +50,15 @@
47
50
  "lilconfig": "3.1.2",
48
51
  "lint-staged": "15.2.10",
49
52
  "ora": "8.1.1",
50
- "prettier": "3.3.3",
51
- "@fenge/eslint-config": "0.2.1",
52
- "@fenge/tsconfig": "0.1.0",
53
- "@fenge/prettier-config": "0.1.1",
54
- "@fenge/types": "0.1.0",
53
+ "prettier": "3.4.1",
54
+ "@fenge/eslint-config": "0.4.0-beta.0",
55
+ "@fenge/prettier-config": "0.1.3-beta.0",
56
+ "@fenge/tsconfig": "0.1.1-beta.0",
57
+ "@fenge/types": "0.2.0-beta.0",
55
58
  "prettier-ignore": "0.1.3"
56
59
  },
57
60
  "devDependencies": {
58
- "@types/node": "22.7.5"
61
+ "@types/node": "22.9.1"
59
62
  },
60
63
  "peerDependencies": {
61
64
  "typescript": "^5.6.0"
@@ -69,6 +72,6 @@
69
72
  "node": ">=18"
70
73
  },
71
74
  "scripts": {
72
- "build": "tsc --noEmit -p tsconfig.build.json"
75
+ "build": "tsc --noEmit"
73
76
  }
74
77
  }
@@ -9,15 +9,14 @@ import { dir, execAsync, getBinPath } from "../utils.js";
9
9
  * @param {{update?: boolean, write?: boolean, dryRun?: boolean, config?: string, default?: boolean}} options
10
10
  */
11
11
  export async function format(paths = [], options = {}) {
12
- const { update = false, write = false, dryRun = false, config } = options;
13
- const useDefaultConfig = options["default"] ?? false;
12
+ const {
13
+ update = false,
14
+ write = false,
15
+ dryRun = false,
16
+ config,
17
+ default: useDefaultConfig,
18
+ } = options;
14
19
 
15
- if (config) {
16
- process.env["FENGE_CONFIG"] = config;
17
- }
18
- if (useDefaultConfig) {
19
- process.env["FENGE_USE_DEFAULT_CONFIG"] = "true";
20
- }
21
20
  const ignores = [".gitignore", ".prettierignore", prettierignore]
22
21
  .map((p) => path.resolve(p))
23
22
  .flatMap((p) => ["--ignore-path", p]);
@@ -37,6 +36,13 @@ export async function format(paths = [], options = {}) {
37
36
  path.resolve(process.cwd(), p),
38
37
  ),
39
38
  ],
40
- { topic: "💃 Checking formatting", dryRun },
39
+ {
40
+ topic: "💃 Checking formatting",
41
+ dryRun,
42
+ env: {
43
+ ...(config && { FENGE_CONFIG: config }),
44
+ ...(useDefaultConfig && { FENGE_USE_DEFAULT_CONFIG: "true" }),
45
+ },
46
+ },
41
47
  );
42
48
  }
@@ -8,16 +8,14 @@ import { dir, execAsync, getBinPath } from "../utils.js";
8
8
  * @param {{update?: boolean, fix?: boolean, dryRun?: boolean, config?: string, default?: boolean}} options
9
9
  */
10
10
  export async function lint(paths = [], options = {}) {
11
- const { update = false, fix = false, dryRun = false, config } = options;
12
- const useDefaultConfig = options["default"] ?? false;
11
+ const {
12
+ update = false,
13
+ fix = false,
14
+ dryRun = false,
15
+ config,
16
+ default: useDefaultConfig,
17
+ } = options;
13
18
 
14
- if (config) {
15
- process.env["FENGE_CONFIG"] = config;
16
- }
17
- if (useDefaultConfig) {
18
- process.env["FENGE_USE_DEFAULT_CONFIG"] = "true";
19
- }
20
- process.env["ESLINT_USE_FLAT_CONFIG"] = "true"; // TODO remove it once upgrade to eslint 9
21
19
  return execAsync(
22
20
  [
23
21
  // "node",
@@ -29,6 +27,14 @@ export async function lint(paths = [], options = {}) {
29
27
  path.resolve(process.cwd(), p),
30
28
  ),
31
29
  ],
32
- { topic: "📏 Checking linting", dryRun },
30
+ {
31
+ topic: "📏 Checking linting",
32
+ dryRun,
33
+ env: {
34
+ ESLINT_USE_FLAT_CONFIG: "true", // TODO remove it once upgrade to eslint 9
35
+ ...(config && { FENGE_CONFIG: config }),
36
+ ...(useDefaultConfig && { FENGE_USE_DEFAULT_CONFIG: "true" }),
37
+ },
38
+ },
33
39
  );
34
40
  }
@@ -3,7 +3,5 @@ import path from "node:path";
3
3
  import { dir, resolveConfig } from "../utils.js";
4
4
 
5
5
  const cliPath = path.resolve(dir(import.meta.url), "..", "bin", "cli.js");
6
- const defaultConfig = {
7
- "*": [`${cliPath} -w`],
8
- };
6
+ const defaultConfig = { "*": [`${cliPath} -w`] };
9
7
  export default (await resolveConfig("lint-staged"))?.config ?? defaultConfig;
package/src/utils.js CHANGED
@@ -48,7 +48,7 @@ export async function resolveConfig(module, loadPath) {
48
48
  */
49
49
  export async function importJson(importMetaUrl, jsonPath) {
50
50
  return JSON.parse(
51
- await fs.readFile(path.resolve(dir(importMetaUrl), jsonPath), "utf-8"),
51
+ await fs.readFile(path.resolve(dir(importMetaUrl), jsonPath), "utf8"),
52
52
  );
53
53
  }
54
54
 
@@ -69,23 +69,25 @@ function getSpentTime(startTime) {
69
69
 
70
70
  /**
71
71
  * @param {string[]} command
72
- * @param {{topic: string, dryRun: boolean}} options
72
+ * @param {{topic: string, dryRun: boolean, env: Record<string, string>}} options
73
73
  * @returns {Promise<number>}
74
74
  */
75
- export async function execAsync(command, { topic, dryRun }) {
76
- const [cmd, ...args] = command;
77
- if (!cmd) {
78
- throw new Error("cmd not found");
79
- }
80
- if (dryRun) {
81
- console.log(`${chalk.green(cmd)} ${args.join(" ")}`);
82
- return 0;
83
- }
84
- const startTime = Date.now();
85
- return new Promise((resolve) => {
75
+ export function execAsync(command, { topic, dryRun, env }) {
76
+ return new Promise((resolve, reject) => {
77
+ const startTime = Date.now();
78
+
79
+ const [cmd, ...args] = command;
80
+ if (!cmd) {
81
+ return reject(new Error("cmd not found"));
82
+ }
83
+ if (dryRun) {
84
+ console.log(`${chalk.green(cmd)} ${args.join(" ")}`);
85
+ return resolve(0);
86
+ }
87
+
86
88
  const spinner = ora(`${topic}...`).start();
87
89
  const cp = childProcess.spawn(cmd, args, {
88
- env: { FORCE_COLOR: "true", ...process.env },
90
+ env: { FORCE_COLOR: "true", ...process.env, ...env },
89
91
  });
90
92
  let stdout = Buffer.from([]);
91
93
  let stderr = Buffer.from([]);
package/tsconfig.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "./tsconfig/tsconfig.json"
2
+ "extends": "./tsconfig/index.json"
3
3
  }
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "./tsconfig",
3
- "include": ["src"],
4
- "exclude": ["**/*.spec.ts", "**/*.test.ts"]
5
- }
File without changes