@done-coding/cli-publish 0.4.2 → 0.4.4
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 +2 -1
- package/es/{index-03276083.js → index-482d005d.js} +42 -41
- package/es/index.mjs +5 -4
- package/package.json +4 -3
- package/types/injectInfo.json.d.ts +1 -1
package/es/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as r } from "./index-
|
|
2
|
+
import { c as r } from "./index-482d005d.js";
|
|
3
3
|
import "semver";
|
|
4
4
|
import "node:path";
|
|
5
5
|
import "node:child_process";
|
|
@@ -7,6 +7,7 @@ import "pinyin";
|
|
|
7
7
|
import "node:fs";
|
|
8
8
|
import "chalk";
|
|
9
9
|
import "prompts";
|
|
10
|
+
import "@done-coding/node-tools";
|
|
10
11
|
import "yargs";
|
|
11
12
|
import "yargs/helpers";
|
|
12
13
|
r();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { inc as A, prerelease as
|
|
2
|
+
import { inc as A, prerelease as C } from "semver";
|
|
3
3
|
import { join as v } from "node:path";
|
|
4
4
|
import { execSync as n } from "node:child_process";
|
|
5
5
|
import P from "pinyin";
|
|
6
|
-
import { readFileSync as O, existsSync as
|
|
6
|
+
import { readFileSync as O, existsSync as y } from "node:fs";
|
|
7
7
|
import p from "chalk";
|
|
8
|
-
import
|
|
8
|
+
import I from "prompts";
|
|
9
|
+
import { onPromptFormStateForSigint as H } from "@done-coding/node-tools";
|
|
9
10
|
import w from "yargs";
|
|
10
11
|
import { hideBin as J } from "yargs/helpers";
|
|
11
12
|
var E = /* @__PURE__ */ ((t) => (t.NPM = "npm", t.WEB = "web", t))(E || {}), e = /* @__PURE__ */ ((t) => (t.MAJOR = "major", t.MINOR = "minor", t.PATCH = "patch", t.PREMAJOR = "premajor", t.PREMINOR = "preminor", t.PREPATCH = "prepatch", t.PRERELEASE = "prerelease", t))(e || {}), d = /* @__PURE__ */ ((t) => (t.LATEST = "latest", t.NEXT = "next", t.ALPHA = "alpha", t))(d || {});
|
|
12
|
-
const L = "/.dc/publish.json",
|
|
13
|
+
const L = "/.dc/publish.json", N = "/package.json", T = ({ gitOriginName: t = "origin" }) => {
|
|
13
14
|
try {
|
|
14
|
-
const o = n("git rev-parse HEAD").toString().trim(),
|
|
15
|
+
const o = n("git rev-parse HEAD").toString().trim(), m = n('git log -1 --pretty=format:"%an"').toString().trim(), c = n('git log -1 --pretty=format:"%ae"').toString().trim(), i = n('git log -1 --pretty=format:"%s"').toString().trim(), s = n("git config user.name").toString().trim(), l = n("git config user.email").toString().trim(), g = n("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
15
16
|
let f = "";
|
|
16
17
|
try {
|
|
17
18
|
f = n(`git config --get remote.${t}.url`).toString().trim();
|
|
@@ -20,8 +21,8 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
20
21
|
}
|
|
21
22
|
return {
|
|
22
23
|
lastHash: o,
|
|
23
|
-
lastCommitter:
|
|
24
|
-
lastCommitterPinYin: P(
|
|
24
|
+
lastCommitter: m,
|
|
25
|
+
lastCommitterPinYin: P(m, {
|
|
25
26
|
style: P.STYLE_NORMAL,
|
|
26
27
|
heteronym: !1
|
|
27
28
|
}).join(""),
|
|
@@ -33,14 +34,14 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
33
34
|
heteronym: !1
|
|
34
35
|
}).join(""),
|
|
35
36
|
userEmail: l,
|
|
36
|
-
branchName:
|
|
37
|
+
branchName: g,
|
|
37
38
|
remoteUrl: f
|
|
38
39
|
};
|
|
39
40
|
} catch (o) {
|
|
40
41
|
throw console.error("Error fetching git information:", o), o;
|
|
41
42
|
}
|
|
42
|
-
}, R = (t, o = JSON.parse(O(v(process.cwd(),
|
|
43
|
-
let
|
|
43
|
+
}, R = (t, o = JSON.parse(O(v(process.cwd(), N), "utf-8"))) => {
|
|
44
|
+
let m = o.name, c = "", i;
|
|
44
45
|
const { version: s } = o;
|
|
45
46
|
if ([
|
|
46
47
|
e.MAJOR,
|
|
@@ -53,7 +54,7 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
53
54
|
e.PREMINOR,
|
|
54
55
|
e.PREPATCH
|
|
55
56
|
].includes(t)) {
|
|
56
|
-
const l =
|
|
57
|
+
const l = C(s);
|
|
57
58
|
l ? (console.log(
|
|
58
59
|
p.yellow("当前版本已经是预发布版本,将会在当前版本基础上进行发布")
|
|
59
60
|
), l.length === 1 && typeof l[0] == "number" ? c = A(
|
|
@@ -69,16 +70,16 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
69
70
|
if (!c)
|
|
70
71
|
throw new Error("version is empty");
|
|
71
72
|
return {
|
|
72
|
-
name:
|
|
73
|
+
name: m,
|
|
73
74
|
version: c,
|
|
74
75
|
tag: i
|
|
75
76
|
};
|
|
76
77
|
}, b = () => {
|
|
77
78
|
let t;
|
|
78
79
|
const o = v(process.cwd(), L);
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
t = JSON.parse(
|
|
80
|
+
if (y(o)) {
|
|
81
|
+
const m = O(o, "utf-8");
|
|
82
|
+
t = JSON.parse(m);
|
|
82
83
|
} else
|
|
83
84
|
console.log(
|
|
84
85
|
p.yellow(`未找到配置文件,将使用默认配置
|
|
@@ -89,15 +90,15 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
89
90
|
gitOriginName: "origin",
|
|
90
91
|
...t || {}
|
|
91
92
|
};
|
|
92
|
-
},
|
|
93
|
+
}, M = async (t) => {
|
|
93
94
|
console.log(t);
|
|
94
|
-
const { mode: o, type:
|
|
95
|
+
const { mode: o, type: m, push: c } = t, i = b(), s = T(i);
|
|
95
96
|
console.log("gitInfo:", s);
|
|
96
|
-
let l =
|
|
97
|
+
let l = m, g;
|
|
97
98
|
if (l)
|
|
98
|
-
console.log("type:", l),
|
|
99
|
+
console.log("type:", l), g = await R(l);
|
|
99
100
|
else {
|
|
100
|
-
const r = JSON.parse(O(v(process.cwd(),
|
|
101
|
+
const r = JSON.parse(O(v(process.cwd(), N), "utf-8")), a = {
|
|
101
102
|
[e.MAJOR]: R(
|
|
102
103
|
e.MAJOR,
|
|
103
104
|
r
|
|
@@ -156,19 +157,19 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
156
157
|
value: e.PRERELEASE
|
|
157
158
|
}
|
|
158
159
|
];
|
|
159
|
-
l = (await
|
|
160
|
+
l = (await I({
|
|
160
161
|
type: "select",
|
|
161
162
|
name: "type",
|
|
162
163
|
message: `请选择发布类型,当前版本:${r.version}`,
|
|
163
164
|
choices: $,
|
|
164
|
-
|
|
165
|
-
})).type,
|
|
165
|
+
onState: H
|
|
166
|
+
})).type, g = a[l];
|
|
166
167
|
}
|
|
167
|
-
const { version: f } =
|
|
168
|
-
console.log("npmInfo:",
|
|
168
|
+
const { version: f } = g;
|
|
169
|
+
console.log("npmInfo:", g), n(`npm version ${f} 1>&2`);
|
|
169
170
|
try {
|
|
170
171
|
if (o === E.NPM) {
|
|
171
|
-
const { tag: r } =
|
|
172
|
+
const { tag: r } = g;
|
|
172
173
|
n(`npm publish --tag ${r} 1>&2`);
|
|
173
174
|
} else if (o === E.WEB) {
|
|
174
175
|
const { webBuild: r } = i;
|
|
@@ -182,15 +183,15 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
182
183
|
p.blue(`回滚本地版本到发布前的版本:${s.lastHash}`)
|
|
183
184
|
);
|
|
184
185
|
const { lastHash: a } = s;
|
|
185
|
-
n(`git reset --hard ${a} 1>&2`), console.log(p.blue(`删除本次发布时生成的tag:v${
|
|
186
|
+
n(`git reset --hard ${a} 1>&2`), console.log(p.blue(`删除本次发布时生成的tag:v${g.version}`)), n(`git tag -d v${g.version} 1>&2`);
|
|
186
187
|
} catch (a) {
|
|
187
188
|
console.log(p.red(`回滚失败, error: ${a.message}`));
|
|
188
189
|
}
|
|
189
190
|
return process.exit(1);
|
|
190
191
|
}
|
|
191
|
-
c && (n(`git push ${i.gitOriginName} v${
|
|
192
|
+
c && (n(`git push ${i.gitOriginName} v${g.version} 1>&2`), n(`git push ${i.gitOriginName} ${s.branchName} 1>&2`)), console.log(p.green("发布成功"));
|
|
192
193
|
}, h = {
|
|
193
|
-
version: "0.4.
|
|
194
|
+
version: "0.4.4",
|
|
194
195
|
name: "@done-coding/cli-publish",
|
|
195
196
|
description: "项目发布命令行工具",
|
|
196
197
|
cliConfig: {
|
|
@@ -223,23 +224,23 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
|
|
|
223
224
|
type: "boolean",
|
|
224
225
|
default: !0
|
|
225
226
|
}
|
|
226
|
-
}),
|
|
227
|
+
}), u = h.cliConfig.moduleName, x = (t, o) => {
|
|
227
228
|
console.log(t ? p.red(t) : p.red(o.message)), process.exit(1);
|
|
228
|
-
}, B = h.description, U = `Usage: $0 ${
|
|
229
|
-
const
|
|
230
|
-
return t.strict().usage(o).help("help").version(h.version).alias("v", "version").alias("h", "help").options(
|
|
231
|
-
}, Y = (t) => S(t, U),
|
|
232
|
-
command:
|
|
229
|
+
}, B = h.description, U = `Usage: $0 ${u} [options]`, D = "Usage: $0 [options]", S = (t, o) => {
|
|
230
|
+
const m = j();
|
|
231
|
+
return t.strict().usage(o).help("help").version(h.version).alias("v", "version").alias("h", "help").options(m).fail(x).argv;
|
|
232
|
+
}, Y = (t) => S(t, U), Z = {
|
|
233
|
+
command: u,
|
|
233
234
|
describe: B,
|
|
234
235
|
builder: Y,
|
|
235
|
-
handler:
|
|
236
|
-
},
|
|
236
|
+
handler: M
|
|
237
|
+
}, V = async () => {
|
|
237
238
|
const t = w(J(process.argv)), o = await S(t, D);
|
|
238
|
-
return
|
|
239
|
+
return M(o);
|
|
239
240
|
};
|
|
240
241
|
export {
|
|
241
242
|
E as P,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
Z as a,
|
|
244
|
+
V as c,
|
|
245
|
+
M as h
|
|
245
246
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { P as
|
|
2
|
+
import { P as u, a as b, h as l } from "./index-482d005d.js";
|
|
3
3
|
import "semver";
|
|
4
4
|
import "node:path";
|
|
5
5
|
import "node:child_process";
|
|
@@ -7,10 +7,11 @@ import "pinyin";
|
|
|
7
7
|
import "node:fs";
|
|
8
8
|
import "chalk";
|
|
9
9
|
import "prompts";
|
|
10
|
+
import "@done-coding/node-tools";
|
|
10
11
|
import "yargs";
|
|
11
12
|
import "yargs/helpers";
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
u as PublishModeEnum,
|
|
15
|
+
b as command,
|
|
16
|
+
l as handler
|
|
16
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-publish",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "项目发布命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "^0.4.
|
|
44
|
+
"@done-coding/cli-inject": "^0.4.5",
|
|
45
45
|
"@types/node": "^18.0.0",
|
|
46
46
|
"@types/pinyin": "^2.10.0",
|
|
47
47
|
"@types/prompts": "^2.4.6",
|
|
@@ -56,11 +56,12 @@
|
|
|
56
56
|
"node": ">=18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
+
"@done-coding/node-tools": "^0.2.0",
|
|
59
60
|
"chalk": "^5.3.0",
|
|
60
61
|
"pinyin": "^2.11.2",
|
|
61
62
|
"prompts": "^2.4.2",
|
|
62
63
|
"semver": "^7.5.4",
|
|
63
64
|
"yargs": "^17.7.2"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "0dde53af70143475f5149714152d714802f846f8"
|
|
66
67
|
}
|