dc-publish 0.7.5 → 0.7.8

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-1345b1c1.js";
2
+ import { c as m } from "./index-eb03530f.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:os";
5
5
  import "node:child_process";
@@ -0,0 +1,316 @@
1
+ #!/usr/bin/env node
2
+ import { getConfigFileCommonOptions as O, initHandlerCommon as F, log as d, readConfigFile as _, getPackageJson as w, getGitLastCommitInfo as G, pushGitPublishInfoToRemote as W, xPrompts as $, createSubcommand as D, getRootScriptName as X, createMainCommand as V } from "@done-coding/cli-utils";
3
+ import { tmpdir as q } from "node:os";
4
+ import { execSync as l } from "node:child_process";
5
+ import { inc as L } from "semver";
6
+ import { v4 as z } from "uuid";
7
+ import T from "node:path";
8
+ import b, { rmSync as K } from "node:fs";
9
+ var g = /* @__PURE__ */ ((e) => (e.INIT = "init", e.EXEC = "exec", e.ALIAS = "alias", e))(g || {}), r = /* @__PURE__ */ ((e) => (e.MAJOR = "major", e.MINOR = "minor", e.PATCH = "patch", e.PREMAJOR = "premajor", e.PREMINOR = "preminor", e.PREPATCH = "prepatch", e.PRERELEASE = "prerelease", e.CUSTOM_VERSION = "custom version", e))(r || {}), f = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e.BETA = "beta", e.RC = "rc", e))(f || {}), c = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(c || {});
10
+ const P = {
11
+ name: "@done-coding/cli-publish",
12
+ version: "0.7.8",
13
+ description: "项目发布命令行工具",
14
+ bin: {
15
+ "dc-publish": "es/cli.mjs"
16
+ },
17
+ cliConfig: {
18
+ namespaceDir: ".done-coding",
19
+ moduleName: "publish"
20
+ }
21
+ }, Q = `${q()}/.DONE_CODING_CLI/PUBLISH_ALIAS_TEMP_DIR`, {
22
+ cliConfig: { namespaceDir: Y, moduleName: Z }
23
+ } = P, ee = `./${Y}/${Z}`, v = `${ee}.json`, te = {
24
+ [c.WEB]: {},
25
+ [c.NPM]: {
26
+ aliasInfo: [
27
+ {
28
+ packageJson: {
29
+ name: "",
30
+ bin: "",
31
+ scripts: {}
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ }, ne = () => O({
37
+ configPathDefault: v
38
+ }), k = async (e) => F(te, e, {
39
+ onFileGenerated: () => {
40
+ d.info("文件生成成功");
41
+ }
42
+ }), oe = {
43
+ command: g.INIT,
44
+ describe: "初始化配置文件",
45
+ options: ne(),
46
+ handler: k
47
+ }, se = () => O({
48
+ configPathDefault: v
49
+ }), y = (e) => {
50
+ var o;
51
+ const t = ((o = e[c.NPM]) == null ? void 0 : o.aliasInfo) || [];
52
+ if (t.length)
53
+ return t;
54
+ }, S = async (e) => {
55
+ var u;
56
+ const t = await _(e, () => ({})), o = y(t);
57
+ if (!o) {
58
+ d.warn("没有配置别名发布信息");
59
+ return;
60
+ }
61
+ const { rootDir: m } = e, s = w({ rootDir: m }), { name: a, version: i } = s, n = T.resolve(Q, z());
62
+ b.mkdirSync(n, { recursive: !0 }), l(`pnpm add ${a}@${i}`, {
63
+ stdio: "inherit",
64
+ cwd: n
65
+ });
66
+ const h = (u = l(`npm dist-tag ${a}`).toString().trim().split(`
67
+ `).map((C) => C.split(":").map((R) => R.trim())).find(
68
+ ([, C]) => C === i
69
+ )) == null ? void 0 : u[0];
70
+ if (!h)
71
+ return d.warn(`没有找到 ${a}@${i} 对应的dist-tag`);
72
+ const E = T.resolve(n, "node_modules", a), I = w({
73
+ rootDir: E
74
+ });
75
+ for (let C of o) {
76
+ const { packageJson: R } = C, j = {
77
+ ...I,
78
+ ...R
79
+ }, U = `${E}/package.json`;
80
+ b.writeFileSync(
81
+ U,
82
+ JSON.stringify(j, null, 2)
83
+ ), l(`pnpm publish --tag ${h}`, {
84
+ stdio: "inherit",
85
+ cwd: E
86
+ });
87
+ }
88
+ K(n, { recursive: !0, force: !0 });
89
+ }, re = {
90
+ command: g.ALIAS,
91
+ describe: "别名发布",
92
+ options: se(),
93
+ handler: S
94
+ }, ie = () => ({
95
+ ...O({
96
+ configPathDefault: v
97
+ }),
98
+ mode: {
99
+ alias: "m",
100
+ describe: "发布模式",
101
+ choices: [c.NPM, c.WEB],
102
+ default: c.NPM
103
+ },
104
+ type: {
105
+ alias: "t",
106
+ describe: "发布类型",
107
+ choices: Object.values(r)
108
+ },
109
+ push: {
110
+ alias: "p",
111
+ describe: "是否推送至远程仓库",
112
+ type: "boolean",
113
+ default: !0
114
+ },
115
+ distTag: {
116
+ alias: "d",
117
+ describe: "发布标签",
118
+ choices: Object.values(f)
119
+ }
120
+ }), N = async ({
121
+ packageJson: e,
122
+ type: t,
123
+ distTag: o
124
+ }) => {
125
+ let m = e.name, s = "", a;
126
+ const { version: i } = e;
127
+ if (!i)
128
+ throw new Error("当前版本号为空");
129
+ switch (t) {
130
+ case r.PATCH:
131
+ case r.MINOR:
132
+ case r.MAJOR: {
133
+ s = L(i, t), a = o || f.LATEST;
134
+ break;
135
+ }
136
+ case r.PREPATCH:
137
+ case r.PREMINOR:
138
+ case r.PREMAJOR: {
139
+ s = L(i, t, f.ALPHA), a = o || f.ALPHA;
140
+ break;
141
+ }
142
+ case r.PRERELEASE: {
143
+ const n = (await $({
144
+ type: "text",
145
+ name: "identifier",
146
+ message: "请输入修饰符",
147
+ initial: f.ALPHA
148
+ })).identifier;
149
+ s = L(i, t, n), a = o || n;
150
+ break;
151
+ }
152
+ default:
153
+ s = (await $({
154
+ type: "text",
155
+ name: "customVersion",
156
+ message: "请输入自定义版本号"
157
+ })).customVersion, a = o || f.LATEST;
158
+ }
159
+ if (!s)
160
+ throw new Error("version is empty");
161
+ return {
162
+ name: m,
163
+ version: s,
164
+ tag: a
165
+ };
166
+ }, ae = async ({
167
+ type: e,
168
+ packageJson: t,
169
+ distTag: o
170
+ }) => {
171
+ if (e)
172
+ return await N({
173
+ packageJson: t,
174
+ type: e,
175
+ distTag: o
176
+ });
177
+ {
178
+ const m = {}, s = [
179
+ r.PATCH,
180
+ r.MINOR,
181
+ r.MAJOR,
182
+ r.PREPATCH,
183
+ r.PREMINOR,
184
+ r.PREMAJOR
185
+ ];
186
+ for (let n of s)
187
+ m[n] = await N({
188
+ packageJson: t,
189
+ type: n,
190
+ distTag: o
191
+ });
192
+ const a = [
193
+ ...s.map((n) => ({
194
+ title: `${n} (${m[n].version})`,
195
+ value: n
196
+ })),
197
+ ...[
198
+ r.PRERELEASE,
199
+ r.CUSTOM_VERSION
200
+ ].map((n) => ({
201
+ title: n,
202
+ value: n
203
+ }))
204
+ ], i = (await $({
205
+ type: "select",
206
+ name: "selectType",
207
+ message: `请选择发布类型,当前版本:${t.version}`,
208
+ choices: a
209
+ })).selectType;
210
+ return s.includes(i) ? m[i] : N({
211
+ packageJson: t,
212
+ type: i,
213
+ distTag: o
214
+ });
215
+ }
216
+ }, J = async (e) => {
217
+ const { mode: t, type: o, push: m, rootDir: s, distTag: a } = e, i = await _(e, () => ({})), n = i[t], A = await G(n), M = w({ rootDir: s }), p = await ae({
218
+ type: o,
219
+ packageJson: M,
220
+ distTag: a
221
+ }), { version: h } = p;
222
+ l(`npm version ${h}`, {
223
+ cwd: s,
224
+ stdio: "inherit"
225
+ });
226
+ const { tag: E } = p;
227
+ try {
228
+ switch (t) {
229
+ case c.WEB: {
230
+ const { build: I } = n;
231
+ if (I)
232
+ l(`${I}`, {
233
+ stdio: "inherit",
234
+ cwd: s
235
+ });
236
+ else
237
+ throw new Error("未配置build命令");
238
+ break;
239
+ }
240
+ case c.NPM: {
241
+ l(`npm publish --tag ${E}`, {
242
+ cwd: s,
243
+ stdio: "inherit"
244
+ });
245
+ break;
246
+ }
247
+ default:
248
+ throw new Error(`未知发布模式:${t}`);
249
+ }
250
+ } catch (I) {
251
+ d.error(`发布失败, error: ${I.message}`);
252
+ try {
253
+ d.info(`回滚本地版本到发布前的版本:${A.lastHash}`);
254
+ const { lastHash: u } = A;
255
+ l(`git reset --hard ${u}`, {
256
+ stdio: "inherit"
257
+ }), d.info(`删除本次发布时生成的tag:v${p.version}`), l(`git tag -d v${p.version}`, {
258
+ stdio: "inherit"
259
+ });
260
+ } catch (u) {
261
+ d.error(`回滚失败, error: ${u.message}`);
262
+ }
263
+ return process.exit(1);
264
+ }
265
+ m && W({
266
+ branchName: A.branchName,
267
+ version: p.version,
268
+ remoteInfo: A.remoteInfo
269
+ }), d.success(`发布成功,版本号:${h}`), t === c.NPM && y(i) && S(e);
270
+ }, ce = {
271
+ command: "$0",
272
+ describe: "执行发布命令",
273
+ options: ie(),
274
+ handler: J
275
+ }, he = async (e, t) => {
276
+ switch (e) {
277
+ case g.INIT:
278
+ return k(t);
279
+ case g.EXEC:
280
+ return J(t);
281
+ case g.ALIAS:
282
+ return S(t);
283
+ default:
284
+ throw new Error(`不支持的命令 ${e}`);
285
+ }
286
+ }, { version: me, description: de } = P, x = {
287
+ describe: de,
288
+ version: me,
289
+ subcommands: [
290
+ oe,
291
+ ce,
292
+ re
293
+ ].map(D),
294
+ demandCommandCount: 1,
295
+ rootScriptName: X({ packageJson: P })
296
+ }, {
297
+ cliConfig: { moduleName: H }
298
+ } = P, B = (e = !1) => {
299
+ const t = e ? H : void 0, o = `$0${e ? ` ${H}` : ""} [options]`;
300
+ return { command: t, usage: o };
301
+ }, Ee = async () => V({
302
+ ...x,
303
+ ...B()
304
+ }), Ce = () => D({
305
+ ...x,
306
+ ...B(!0)
307
+ });
308
+ export {
309
+ r as P,
310
+ g as S,
311
+ Ce as a,
312
+ f as b,
313
+ Ee as c,
314
+ c as d,
315
+ he as h
316
+ };
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as t, b as e, P as b, S as d, a as h, h as l } from "./index-1345b1c1.js";
2
+ import { d as t, b as e, P as b, S as d, a as h, h as l } from "./index-eb03530f.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:os";
5
5
  import "node:child_process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dc-publish",
3
- "version": "0.7.5",
3
+ "version": "0.7.8",
4
4
  "description": "项目发布命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -9,7 +9,8 @@
9
9
  "bin": "es/cli.mjs",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./es/index.mjs"
12
+ "import": "./es/index.mjs",
13
+ "types": "./types/index.d.ts"
13
14
  }
14
15
  },
15
16
  "files": [
@@ -30,7 +31,7 @@
30
31
  "license": "MIT",
31
32
  "sideEffects": false,
32
33
  "devDependencies": {
33
- "@done-coding/cli-inject": "^0.5.13",
34
+ "@done-coding/cli-inject": "^0.5.15",
34
35
  "@types/node": "^18.0.0",
35
36
  "@types/semver": "^7.5.3",
36
37
  "@types/uuid": "^10.0.0",
@@ -44,10 +45,10 @@
44
45
  "node": ">=18.0.0"
45
46
  },
46
47
  "dependencies": {
47
- "@done-coding/cli-utils": "^0.7.4",
48
+ "@done-coding/cli-utils": "^0.7.6",
48
49
  "semver": "^7.5.4",
49
50
  "uuid": "^11.1.0"
50
51
  },
51
- "gitHead": "9b52d0d18f2b0f7e0498a8ef4dbd4a4c5fcd1ddf",
52
+ "gitHead": "ad9548c74a5e7a108874ab2c91a20b4c41ee079c",
52
53
  "scripts": {}
53
54
  }
package/types/index.d.ts CHANGED
@@ -51,6 +51,8 @@ export declare interface ExecOptions extends ReadConfigFileOptions {
51
51
  type?: PublishVersionTypeEnum;
52
52
  /** (发布成功后)是否推送至远程仓库 */
53
53
  push: boolean;
54
+ /** 发布标签 */
55
+ distTag: PublishTagEnum;
54
56
  }
55
57
 
56
58
  export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
@@ -98,7 +100,15 @@ export declare enum PublishTagEnum {
98
100
  /**
99
101
  * alpha版本
100
102
  */
101
- ALPHA = "alpha"
103
+ ALPHA = "alpha",
104
+ /**
105
+ * beta版本
106
+ */
107
+ BETA = "beta",
108
+ /**
109
+ * rc版本
110
+ */
111
+ RC = "rc"
102
112
  }
103
113
 
104
114
  /**
@@ -129,10 +139,10 @@ export declare enum PublishVersionTypeEnum {
129
139
  * 预发布修订版本号
130
140
  */
131
141
  PREPATCH = "prepatch",
132
- /**
133
- * 预发布版本号
134
- */
135
- PRERELEASE = "prerelease"
142
+ /** 自定义预发布修饰符 */
143
+ PRERELEASE = "prerelease",
144
+ /** 自定义版本号 */
145
+ CUSTOM_VERSION = "custom version"
136
146
  }
137
147
 
138
148
  /** 子命令枚举 */
@@ -1,314 +0,0 @@
1
- #!/usr/bin/env node
2
- import { getConfigFileCommonOptions as N, initHandlerCommon as F, log as m, readConfigFile as b, getPackageJson as v, getGitLastCommitInfo as U, pushGitPublishInfoToRemote as G, xPrompts as W, createSubcommand as J, getRootScriptName as X, createMainCommand as q } from "@done-coding/cli-utils";
3
- import { tmpdir as z } from "node:os";
4
- import { execSync as f } from "node:child_process";
5
- import { inc as g, prerelease as K } from "semver";
6
- import { v4 as Q } from "uuid";
7
- import w from "node:path";
8
- import T, { rmSync as Y } from "node:fs";
9
- var E = /* @__PURE__ */ ((e) => (e.INIT = "init", e.EXEC = "exec", e.ALIAS = "alias", e))(E || {}), t = /* @__PURE__ */ ((e) => (e.MAJOR = "major", e.MINOR = "minor", e.PATCH = "patch", e.PREMAJOR = "premajor", e.PREMINOR = "preminor", e.PREPATCH = "prepatch", e.PRERELEASE = "prerelease", e))(t || {}), A = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e))(A || {}), l = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(l || {});
10
- const P = {
11
- name: "@done-coding/cli-publish",
12
- version: "0.7.5",
13
- description: "项目发布命令行工具",
14
- bin: {
15
- "dc-publish": "es/cli.mjs"
16
- },
17
- cliConfig: {
18
- namespaceDir: ".done-coding",
19
- moduleName: "publish"
20
- }
21
- }, Z = `${z()}/.DONE_CODING_CLI/PUBLISH_ALIAS_TEMP_DIR`, {
22
- cliConfig: { namespaceDir: V, moduleName: ee }
23
- } = P, te = `./${V}/${ee}`, $ = `${te}.json`, ne = {
24
- [l.WEB]: {},
25
- [l.NPM]: {
26
- aliasInfo: [
27
- {
28
- packageJson: {
29
- name: "",
30
- bin: "",
31
- scripts: {}
32
- }
33
- }
34
- ]
35
- }
36
- }, oe = () => N({
37
- configPathDefault: $
38
- }), D = async (e) => F(ne, e, {
39
- onFileGenerated: () => {
40
- m.info("文件生成成功");
41
- }
42
- }), se = {
43
- command: E.INIT,
44
- describe: "初始化配置文件",
45
- options: oe(),
46
- handler: D
47
- }, re = () => N({
48
- configPathDefault: $
49
- }), _ = (e) => {
50
- var a;
51
- const n = ((a = e[l.NPM]) == null ? void 0 : a.aliasInfo) || [];
52
- if (n.length)
53
- return n;
54
- }, L = async (e) => {
55
- var O;
56
- const n = await b(e, () => ({})), a = _(n);
57
- if (!a) {
58
- m.warn("没有配置别名发布信息");
59
- return;
60
- }
61
- const { rootDir: o } = e, i = v({ rootDir: o }), { name: s, version: r } = i, c = w.resolve(Z, Q());
62
- T.mkdirSync(c, { recursive: !0 }), f(`pnpm add ${s}@${r}`, {
63
- stdio: "inherit",
64
- cwd: c
65
- });
66
- const R = (O = f(`npm dist-tag ${s}`).toString().trim().split(`
67
- `).map((I) => I.split(":").map((C) => C.trim())).find(
68
- ([, I]) => I === r
69
- )) == null ? void 0 : O[0];
70
- if (!R)
71
- return m.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
72
- const d = w.resolve(c, "node_modules", s), u = v({
73
- rootDir: d
74
- });
75
- for (let I of a) {
76
- const { packageJson: C } = I, B = {
77
- ...u,
78
- ...C
79
- }, j = `${d}/package.json`;
80
- T.writeFileSync(
81
- j,
82
- JSON.stringify(B, null, 2)
83
- ), f(`pnpm publish --tag ${R}`, {
84
- stdio: "inherit",
85
- cwd: d
86
- });
87
- }
88
- Y(c, { recursive: !0, force: !0 });
89
- }, ie = {
90
- command: E.ALIAS,
91
- describe: "别名发布",
92
- options: re(),
93
- handler: L
94
- }, ae = () => ({
95
- ...N({
96
- configPathDefault: $
97
- }),
98
- mode: {
99
- alias: "m",
100
- describe: "发布模式",
101
- choices: [l.NPM, l.WEB],
102
- default: l.NPM
103
- },
104
- type: {
105
- alias: "t",
106
- describe: "发布类型",
107
- choices: [
108
- t.MAJOR,
109
- t.MINOR,
110
- t.PATCH,
111
- t.PREMAJOR,
112
- t.PREMINOR,
113
- t.PREPATCH,
114
- t.PRERELEASE
115
- ]
116
- },
117
- push: {
118
- alias: "p",
119
- describe: "是否推送至远程仓库",
120
- type: "boolean",
121
- default: !0
122
- }
123
- }), S = ({
124
- packageJson: e,
125
- type: n
126
- }) => {
127
- let a = e.name, o = "", i;
128
- const { version: s } = e;
129
- if (!s)
130
- throw new Error("当前版本号为空");
131
- if ([
132
- t.MAJOR,
133
- t.MINOR,
134
- t.PATCH
135
- ].includes(n))
136
- o = g(s, n), i = A.LATEST;
137
- else if ([
138
- t.PREMAJOR,
139
- t.PREMINOR,
140
- t.PREPATCH
141
- ].includes(n)) {
142
- const r = K(s);
143
- r ? (m.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = g(
144
- s,
145
- t.PRERELEASE
146
- ) : o = s.split("-")[0] + "-0") : o = g(s, n), i = A.NEXT;
147
- } else
148
- i = A.ALPHA, o = g(
149
- s,
150
- t.PRERELEASE,
151
- i
152
- );
153
- if (!o)
154
- throw new Error("version is empty");
155
- return {
156
- name: a,
157
- version: o,
158
- tag: i
159
- };
160
- }, ce = async ({
161
- type: e,
162
- packageJson: n
163
- }) => {
164
- if (e)
165
- return await S({
166
- packageJson: n,
167
- type: e
168
- });
169
- {
170
- const o = Object.values(t).filter(
171
- (r) => r.toUpperCase() !== r
172
- ).reduce(
173
- (r, c) => (r[c] = S({
174
- packageJson: n,
175
- type: c
176
- }), r),
177
- {}
178
- ), i = [
179
- {
180
- title: `主版本(${o[t.MAJOR].version})`,
181
- value: t.MAJOR
182
- },
183
- {
184
- title: `次版本(${o[t.MINOR].version})`,
185
- value: t.MINOR
186
- },
187
- {
188
- title: `修订版本(${o[t.PATCH].version})`,
189
- value: t.PATCH
190
- },
191
- {
192
- title: `预发布主版本(${o[t.PREMAJOR].version})`,
193
- value: t.PREMAJOR
194
- },
195
- {
196
- title: `预发布次版本(${o[t.PREMINOR].version})`,
197
- value: t.PREMINOR
198
- },
199
- {
200
- title: `预发布修订版本(${o[t.PREPATCH].version})`,
201
- value: t.PREPATCH
202
- },
203
- {
204
- title: `alpha版本(${o[t.PRERELEASE].version})`,
205
- value: t.PRERELEASE
206
- }
207
- ], { type: s } = await W({
208
- type: "select",
209
- name: "type",
210
- message: `请选择发布类型,当前版本:${n.version}`,
211
- choices: i
212
- });
213
- return o[s];
214
- }
215
- }, k = async (e) => {
216
- const { mode: n, type: a, push: o, rootDir: i } = e, s = await b(e, () => ({})), r = s[n], c = await U(r), M = v({ rootDir: i }), p = await ce({
217
- type: a,
218
- packageJson: M
219
- }), { version: h } = p;
220
- f(`npm version ${h}`, {
221
- cwd: i,
222
- stdio: "inherit"
223
- });
224
- const { tag: R } = p;
225
- try {
226
- switch (n) {
227
- case l.WEB: {
228
- const { build: d } = r;
229
- if (d)
230
- f(`${d}`, {
231
- stdio: "inherit",
232
- cwd: i
233
- });
234
- else
235
- throw new Error("未配置build命令");
236
- break;
237
- }
238
- case l.NPM: {
239
- f(`npm publish --tag ${R}`, {
240
- cwd: i,
241
- stdio: "inherit"
242
- });
243
- break;
244
- }
245
- default:
246
- throw new Error(`未知发布模式:${n}`);
247
- }
248
- } catch (d) {
249
- m.error(`发布失败, error: ${d.message}`);
250
- try {
251
- m.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
252
- const { lastHash: u } = c;
253
- f(`git reset --hard ${u}`, {
254
- stdio: "inherit"
255
- }), m.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
256
- stdio: "inherit"
257
- });
258
- } catch (u) {
259
- m.error(`回滚失败, error: ${u.message}`);
260
- }
261
- return process.exit(1);
262
- }
263
- o && G({
264
- branchName: c.branchName,
265
- version: p.version,
266
- remoteInfo: c.remoteInfo
267
- }), m.success(`发布成功,版本号:${h}`), n === l.NPM && _(s) && L(e);
268
- }, le = {
269
- command: "$0",
270
- describe: "执行发布命令",
271
- options: ae(),
272
- handler: k
273
- }, Ae = async (e, n) => {
274
- switch (e) {
275
- case E.INIT:
276
- return D(n);
277
- case E.EXEC:
278
- return k(n);
279
- case E.ALIAS:
280
- return L(n);
281
- default:
282
- throw new Error(`不支持的命令 ${e}`);
283
- }
284
- }, { version: me, description: de } = P, y = {
285
- describe: de,
286
- version: me,
287
- subcommands: [
288
- se,
289
- le,
290
- ie
291
- ].map(J),
292
- demandCommandCount: 1,
293
- rootScriptName: X({ packageJson: P })
294
- }, {
295
- cliConfig: { moduleName: H }
296
- } = P, x = (e = !1) => {
297
- const n = e ? H : void 0, a = `$0${e ? ` ${H}` : ""} [options]`;
298
- return { command: n, usage: a };
299
- }, Pe = async () => q({
300
- ...y,
301
- ...x()
302
- }), he = () => J({
303
- ...y,
304
- ...x(!0)
305
- });
306
- export {
307
- t as P,
308
- E as S,
309
- he as a,
310
- A as b,
311
- Pe as c,
312
- l as d,
313
- Ae as h
314
- };