@done-coding/cli-inject 0.5.21-alpha.1 → 0.5.22-alpha.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/es/cli.mjs +1 -1
- package/es/{index-6befd602.js → index-f66b1638.js} +10 -10
- package/es/index.mjs +1 -1
- package/package.json +8 -10
package/es/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { I as c, S as E } from "./index-a1ee6691.js";
|
|
3
|
-
import {
|
|
3
|
+
import { outputConsole as o, _get as I, initHandlerCommon as k, getConfigFileCommonOptions as A, _set as w, readConfigFile as T, createSubcommand as N, getRootScriptName as _, createMainCommand as M } from "@done-coding/cli-utils";
|
|
4
4
|
import D from "node:path";
|
|
5
|
-
import
|
|
5
|
+
import m from "node:fs";
|
|
6
6
|
const x = ({
|
|
7
7
|
sourceJson: e,
|
|
8
8
|
targetKey: n,
|
|
@@ -36,7 +36,7 @@ const x = ({
|
|
|
36
36
|
}
|
|
37
37
|
}, d = {
|
|
38
38
|
name: "@done-coding/cli-inject",
|
|
39
|
-
version: "0.5.
|
|
39
|
+
version: "0.5.22-alpha.0",
|
|
40
40
|
description: "信息(JSON)注入命令行工具",
|
|
41
41
|
bin: {
|
|
42
42
|
"dc-inject": "es/cli.mjs"
|
|
@@ -96,21 +96,21 @@ const x = ({
|
|
|
96
96
|
return o.error("源文件必须是json"), process.exit(1);
|
|
97
97
|
if (!r.endsWith(".json"))
|
|
98
98
|
return o.error("注入文件必须是json"), process.exit(1);
|
|
99
|
-
const p = D.resolve(e, s), g =
|
|
100
|
-
(
|
|
99
|
+
const p = D.resolve(e, s), g = m.readFileSync(p, "utf-8"), y = JSON.parse(g), i = Object.entries(f).reduce(
|
|
100
|
+
(u, [F, v]) => {
|
|
101
101
|
const P = x({ sourceJson: y, targetKey: F, keyConfig: v });
|
|
102
|
-
return w(
|
|
102
|
+
return w(u, F, P), u;
|
|
103
103
|
},
|
|
104
104
|
{}
|
|
105
105
|
), l = D.resolve(e, r), C = JSON.stringify(i, null, 2);
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
if (C ===
|
|
106
|
+
if (m.existsSync(l)) {
|
|
107
|
+
const u = m.readFileSync(l, "utf-8");
|
|
108
|
+
if (C === u)
|
|
109
109
|
return o.skip("注入文件已存在且内容相同,无需重复注入"), i;
|
|
110
110
|
o.stage("文件内容变化,开始覆盖注入文件");
|
|
111
111
|
} else
|
|
112
112
|
o.stage("开始注入文件");
|
|
113
|
-
|
|
113
|
+
m.writeFileSync(l, C), o.success(`文件注入成功: ${l}`), o.info(C);
|
|
114
114
|
}, h = async (e) => {
|
|
115
115
|
const n = await T(e, () => (o.info("配置文件为空,使用默认配置"), j));
|
|
116
116
|
if (!n)
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-
|
|
2
|
+
import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-f66b1638.js";
|
|
3
3
|
import { I as g, S as u } from "./index-a1ee6691.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
5
|
import "node:path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-inject",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.22-alpha.0",
|
|
4
4
|
"description": "信息(JSON)注入命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -32,11 +32,10 @@
|
|
|
32
32
|
"types"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"clean": "rimraf es lib types",
|
|
36
35
|
"local:init": "node ./scripts/local-init-inject.mjs",
|
|
37
|
-
"predev": "pnpm run
|
|
38
|
-
"dev": "vite build
|
|
39
|
-
"prebuild": "pnpm run
|
|
36
|
+
"predev": "pnpm run local:init",
|
|
37
|
+
"dev": "vite build -w -m hotBuild",
|
|
38
|
+
"prebuild": "pnpm run local:init",
|
|
40
39
|
"build": "vite build",
|
|
41
40
|
"prepack": "pnpm build"
|
|
42
41
|
},
|
|
@@ -55,16 +54,15 @@
|
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@types/node": "^18.0.0",
|
|
57
56
|
"@types/yargs": "^17.0.28",
|
|
58
|
-
"rimraf": "^6.0.1",
|
|
59
57
|
"typescript": "^5.8.3",
|
|
60
58
|
"vite": "^4.4.11",
|
|
61
59
|
"vite-plugin-dts": "^3.6.0"
|
|
62
60
|
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@done-coding/cli-utils": "0.8.3-alpha.0"
|
|
63
|
+
},
|
|
63
64
|
"engines": {
|
|
64
65
|
"node": ">=18.0.0"
|
|
65
66
|
},
|
|
66
|
-
"
|
|
67
|
-
"@done-coding/cli-utils": "0.8.2-alpha.1"
|
|
68
|
-
},
|
|
69
|
-
"gitHead": "660e39fc523e4eba1ea621e3c59122f98015a2de"
|
|
67
|
+
"gitHead": "906b7683d9e4dc75fb07806b12e5507827122a16"
|
|
70
68
|
}
|