@done-coding/cli-inject 0.3.1 → 0.4.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/es/handler.mjs CHANGED
@@ -11,21 +11,21 @@ const O = async (a) => {
11
11
  return console.log(e.red("源文件必须是json")), process.exit(1);
12
12
  if (!l.endsWith(".json"))
13
13
  return console.log(e.red("注入文件必须是json")), process.exit(1);
14
- const g = u.resolve(i, c), m = t.readFileSync(g, "utf-8"), p = JSON.parse(m), s = f.reduce(
14
+ const m = u.resolve(i, c), p = t.readFileSync(m, "utf-8"), g = JSON.parse(p), s = f.reduce(
15
15
  (n, h) => {
16
- const { key: d, targetKey: j, paramsList: y } = J(h), F = S(p, d), I = P({
16
+ const { key: y, targetKey: d, paramsList: j } = J(h), F = S(g, y), I = P({
17
17
  valueInit: F,
18
- paramsList: y
18
+ paramsList: j
19
19
  });
20
- return v(n, j, I), n;
20
+ return v(n, d, I), n;
21
21
  },
22
22
  {}
23
23
  ), o = u.resolve(i, l), r = JSON.stringify(s, null, 2);
24
24
  if (t.existsSync(o)) {
25
25
  const n = t.readFileSync(o, "utf-8");
26
26
  if (r === n)
27
- return console.log(e.green("注入文件已存在且内容相同,无需重复注入")), s;
28
- console.log(e.green("文件内容变化,开始覆盖注入文件"));
27
+ return console.log(e.gray("注入文件已存在且内容相同,无需重复注入")), s;
28
+ console.log(e.blue("文件内容变化,开始覆盖注入文件"));
29
29
  } else
30
30
  console.log(e.green("开始注入文件"));
31
31
  return t.writeFileSync(o, r), console.log(
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const n = {
3
- version: "0.3.1",
3
+ version: "0.4.1",
4
4
  name: "@done-coding/cli-inject",
5
5
  description: "信息注入命令行工具",
6
6
  cliConfig: {
package/es/use.mjs ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { handler as o } from "./handler.mjs";
3
+ const c = (n = [
4
+ "version",
5
+ "name",
6
+ "description",
7
+ "name:cliConfig.namespaceDir:VALUE:.done-coding",
8
+ `name:cliConfig.moduleName:REG:${/@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source}:$1`
9
+ ]) => {
10
+ o({
11
+ sourceJsonFilePath: "./package.json",
12
+ injectKeyPath: n,
13
+ injectInfoFilePath: "./src/injectInfo.json"
14
+ });
15
+ };
16
+ export {
17
+ c as injectDoneCodingCliInfo
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-inject",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "信息注入命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -12,6 +12,17 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "import": "./es/index.mjs"
15
+ },
16
+ "./use": {
17
+ "import": "./es/use.mjs",
18
+ "types": "./types/use.d.ts"
19
+ }
20
+ },
21
+ "typesVersions": {
22
+ "*": {
23
+ "use": [
24
+ "./types/use.d.ts"
25
+ ]
15
26
  }
16
27
  },
17
28
  "files": [
@@ -43,7 +54,7 @@
43
54
  "devDependencies": {
44
55
  "@types/lodash.get": "^4.4.9",
45
56
  "@types/lodash.set": "^4.3.9",
46
- "@types/node": "^20.0.0",
57
+ "@types/node": "^18.0.0",
47
58
  "@types/prompts": "^2.4.6",
48
59
  "@types/yargs": "^17.0.28",
49
60
  "rimraf": "^6.0.1",
@@ -52,7 +63,7 @@
52
63
  "vite-plugin-dts": "^3.6.0"
53
64
  },
54
65
  "engines": {
55
- "node": ">=16.0.0"
66
+ "node": ">=18.0.0"
56
67
  },
57
68
  "dependencies": {
58
69
  "chalk": "^5.3.0",
@@ -61,5 +72,5 @@
61
72
  "prompts": "^2.4.2",
62
73
  "yargs": "^17.7.2"
63
74
  },
64
- "gitHead": "d1dabd6e46a5e38793bba477449dd62aa4d9c4c1"
75
+ "gitHead": "1778df27cf625b5588b1de38d260cfed75e123f2"
65
76
  }
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- "version": "0.3.1",
2
+ "version": "0.4.1",
3
3
  "name": "@done-coding/cli-inject",
4
4
  "description": "信息注入命令行工具",
5
5
  "cliConfig": {
package/types/use.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * done-coding cli信息注入
3
+ * ---
4
+ * 从 package.json 中注入 done-coding-cli 信息
5
+ */
6
+ export declare const injectDoneCodingCliInfo: (injectKeyPath?: string[]) => void;