@done-coding/cli-inject 0.4.1 → 0.4.2

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
@@ -1,37 +1,40 @@
1
1
  #!/usr/bin/env node
2
- import u from "node:path";
2
+ import a from "node:path";
3
3
  import t from "node:fs";
4
- import S from "lodash.get";
5
- import v from "lodash.set";
4
+ import v from "lodash.get";
5
+ import I from "lodash.set";
6
6
  import e from "chalk";
7
7
  import { getKey as J, paramsResolve as P } from "./utils/resolve.mjs";
8
- const O = async (a) => {
9
- const { sourceJsonFilePath: c, injectKeyPath: f, injectInfoFilePath: l } = a, i = process.cwd();
8
+ const O = async (g) => {
9
+ const { sourceJsonFilePath: c, injectKeyPath: m, injectInfoFilePath: l } = g, i = process.cwd();
10
10
  if (!c.endsWith(".json"))
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 m = u.resolve(i, c), p = t.readFileSync(m, "utf-8"), g = JSON.parse(p), s = f.reduce(
15
- (n, h) => {
16
- const { key: y, targetKey: d, paramsList: j } = J(h), F = S(g, y), I = P({
14
+ const p = a.resolve(i, c), d = t.readFileSync(p, "utf-8"), h = JSON.parse(d), r = m.reduce(
15
+ (o, u) => {
16
+ const { key: f, targetKey: y, paramsList: j } = J(u);
17
+ if (!f)
18
+ return console.log(e.red(`注入key不能为空,请检查配置${u}是否正确`)), o;
19
+ const F = v(h, f), S = P({
17
20
  valueInit: F,
18
21
  paramsList: j
19
22
  });
20
- return v(n, d, I), n;
23
+ return I(o, y, S), o;
21
24
  },
22
25
  {}
23
- ), o = u.resolve(i, l), r = JSON.stringify(s, null, 2);
24
- if (t.existsSync(o)) {
25
- const n = t.readFileSync(o, "utf-8");
26
- if (r === n)
27
- return console.log(e.gray("注入文件已存在且内容相同,无需重复注入")), s;
26
+ ), n = a.resolve(i, l), s = JSON.stringify(r, null, 2);
27
+ if (t.existsSync(n)) {
28
+ const o = t.readFileSync(n, "utf-8");
29
+ if (s === o)
30
+ return console.log(e.gray("注入文件已存在且内容相同,无需重复注入")), r;
28
31
  console.log(e.blue("文件内容变化,开始覆盖注入文件"));
29
32
  } else
30
33
  console.log(e.green("开始注入文件"));
31
- return t.writeFileSync(o, r), console.log(
32
- e.green(`文件注入成功: ${o}`),
33
- e.blue(r)
34
- ), s;
34
+ return t.writeFileSync(n, s), console.log(
35
+ e.green(`文件注入成功: ${n}`),
36
+ e.blue(s)
37
+ ), r;
35
38
  };
36
39
  export {
37
40
  O as handler
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const n = {
3
- version: "0.4.1",
3
+ version: "0.4.2",
4
4
  name: "@done-coding/cli-inject",
5
5
  description: "信息注入命令行工具",
6
6
  cliConfig: {
package/es/use.mjs CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { handler as o } from "./handler.mjs";
3
- const c = (n = [
2
+ import { handler as e } from "./handler.mjs";
3
+ const s = (n = `name:cliConfig.moduleName:REG:${/@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source}:$1`, o = [
4
4
  "version",
5
5
  "name",
6
6
  "description",
7
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`
8
+ n
9
9
  ]) => {
10
- o({
10
+ e({
11
11
  sourceJsonFilePath: "./package.json",
12
- injectKeyPath: n,
12
+ injectKeyPath: o,
13
13
  injectInfoFilePath: "./src/injectInfo.json"
14
14
  });
15
15
  };
16
16
  export {
17
- c as injectDoneCodingCliInfo
17
+ s as injectDoneCodingCliInfo
18
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-inject",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "信息注入命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -72,5 +72,5 @@
72
72
  "prompts": "^2.4.2",
73
73
  "yargs": "^17.7.2"
74
74
  },
75
- "gitHead": "1778df27cf625b5588b1de38d260cfed75e123f2"
75
+ "gitHead": "5a8844aa8d54b3f84ab8aa287479bda2da13467a"
76
76
  }
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- "version": "0.4.1",
2
+ "version": "0.4.2",
3
3
  "name": "@done-coding/cli-inject",
4
4
  "description": "信息注入命令行工具",
5
5
  "cliConfig": {
package/types/use.d.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * ---
4
4
  * 从 package.json 中注入 done-coding-cli 信息
5
5
  */
6
- export declare const injectDoneCodingCliInfo: (injectKeyPath?: string[]) => void;
6
+ export declare const injectDoneCodingCliInfo: (moduleNameConfig?: string, injectKeyPath?: string[]) => void;