@done-coding/cli-publish 0.5.5 → 0.6.0-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 CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-b550c95a.js";
2
+ import { c as m } from "./index-69c14c7f.js";
3
+ import "@done-coding/cli-utils";
3
4
  import "semver";
4
- import "node:path";
5
5
  import "node:child_process";
6
6
  import "pinyin";
7
- import "node:fs";
8
- import "@done-coding/cli-utils";
9
7
  m();
@@ -0,0 +1,252 @@
1
+ #!/usr/bin/env node
2
+ import { getConfigFileCommonOptions as I, initHandlerCommon as b, log as g, readConfigFile as D, getPackageJson as J, xPrompts as x, createSubcommand as M, createMainCommand as _ } from "@done-coding/cli-utils";
3
+ import { inc as A, prerelease as j } from "semver";
4
+ import { execSync as o } from "node:child_process";
5
+ import u from "pinyin";
6
+ var v = /* @__PURE__ */ ((e) => (e.INIT = "init", e.EXEC = "exec", e))(v || {}), 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 || {}), h = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e))(h || {}), f = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(f || {});
7
+ const C = {
8
+ name: "@done-coding/cli-publish",
9
+ version: "0.6.0-alpha.0",
10
+ description: "项目发布命令行工具",
11
+ cliConfig: {
12
+ namespaceDir: ".done-coding",
13
+ moduleName: "publish"
14
+ }
15
+ }, {
16
+ cliConfig: { namespaceDir: F, moduleName: U }
17
+ } = C, B = `./${F}/${U}`, H = `${B}.json`, G = {}, X = () => I({
18
+ configPathDefault: H
19
+ }), w = async (e) => b(G, e, {
20
+ onFileGenerated: () => {
21
+ g.info("文件生成成功");
22
+ }
23
+ }), Y = {
24
+ command: v.INIT,
25
+ describe: "初始化配置文件",
26
+ options: X(),
27
+ handler: w
28
+ }, k = () => ({
29
+ ...I({
30
+ configPathDefault: H
31
+ }),
32
+ mode: {
33
+ alias: "m",
34
+ describe: "发布模式",
35
+ choices: [f.NPM, f.WEB],
36
+ default: f.NPM
37
+ },
38
+ type: {
39
+ alias: "t",
40
+ describe: "发布类型",
41
+ choices: [
42
+ t.MAJOR,
43
+ t.MINOR,
44
+ t.PATCH,
45
+ t.PREMAJOR,
46
+ t.PREMINOR,
47
+ t.PREPATCH,
48
+ t.PRERELEASE
49
+ ]
50
+ },
51
+ push: {
52
+ alias: "p",
53
+ describe: "是否推送至远程仓库",
54
+ type: "boolean",
55
+ default: !0
56
+ }
57
+ }), W = ({ gitOriginName: e }) => {
58
+ try {
59
+ const r = o("git rev-parse HEAD").toString().trim(), l = o('git log -1 --pretty=format:"%an"').toString().trim(), s = o('git log -1 --pretty=format:"%ae"').toString().trim(), a = o('git log -1 --pretty=format:"%s"').toString().trim(), n = o("git config user.name").toString().trim(), c = o("git config user.email").toString().trim(), p = o("git rev-parse --abbrev-ref HEAD").toString().trim();
60
+ let E = "";
61
+ try {
62
+ E = o(`git config --get remote.${e}.url`).toString().trim();
63
+ } catch {
64
+ throw new Error(`git remote ${e} 不存在`);
65
+ }
66
+ return {
67
+ lastHash: r,
68
+ lastCommitter: l,
69
+ lastCommitterPinYin: u(l, {
70
+ style: u.STYLE_NORMAL,
71
+ heteronym: !1
72
+ }).join(""),
73
+ lastCommitEmail: s,
74
+ lastCommitMsg: a,
75
+ userName: n,
76
+ userNamePinYin: u(n, {
77
+ style: u.STYLE_NORMAL,
78
+ heteronym: !1
79
+ }).join(""),
80
+ userEmail: c,
81
+ branchName: p,
82
+ remoteUrl: E
83
+ };
84
+ } catch (r) {
85
+ throw console.error("Error fetching git information:", r), r;
86
+ }
87
+ }, $ = ({
88
+ packageJson: e,
89
+ type: r
90
+ }) => {
91
+ let l = e.name, s = "", a;
92
+ const { version: n } = e;
93
+ if (!n)
94
+ throw new Error("当前版本号为空");
95
+ if ([
96
+ t.MAJOR,
97
+ t.MINOR,
98
+ t.PATCH
99
+ ].includes(r))
100
+ s = A(n, r), a = h.LATEST;
101
+ else if ([
102
+ t.PREMAJOR,
103
+ t.PREMINOR,
104
+ t.PREPATCH
105
+ ].includes(r)) {
106
+ const c = j(n);
107
+ c ? (g.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), c.length === 1 && typeof c[0] == "number" ? s = A(
108
+ n,
109
+ t.PRERELEASE
110
+ ) : s = n.split("-")[0] + "-0") : s = A(n, r), a = h.NEXT;
111
+ } else
112
+ a = h.ALPHA, s = A(
113
+ n,
114
+ t.PRERELEASE,
115
+ a
116
+ );
117
+ if (!s)
118
+ throw new Error("version is empty");
119
+ return {
120
+ name: l,
121
+ version: s,
122
+ tag: a
123
+ };
124
+ }, y = async (e) => {
125
+ const { mode: r, type: l, push: s, rootDir: a } = e, n = await D(e, () => ({
126
+ gitOriginName: "origin"
127
+ })), c = W(n), p = J({ rootDir: a });
128
+ let E = l, m;
129
+ if (E)
130
+ m = await $({
131
+ packageJson: p,
132
+ type: E
133
+ });
134
+ else {
135
+ const i = Object.values(t).filter(
136
+ (R) => R.toUpperCase() !== R
137
+ ).reduce(
138
+ (R, N) => (R[N] = $({
139
+ packageJson: p,
140
+ type: N
141
+ }), R),
142
+ {}
143
+ ), T = [
144
+ {
145
+ title: `主版本(${i[t.MAJOR].version})`,
146
+ value: t.MAJOR
147
+ },
148
+ {
149
+ title: `次版本(${i[t.MINOR].version})`,
150
+ value: t.MINOR
151
+ },
152
+ {
153
+ title: `修订版本(${i[t.PATCH].version})`,
154
+ value: t.PATCH
155
+ },
156
+ {
157
+ title: `预发布主版本(${i[t.PREMAJOR].version})`,
158
+ value: t.PREMAJOR
159
+ },
160
+ {
161
+ title: `预发布次版本(${i[t.PREMINOR].version})`,
162
+ value: t.PREMINOR
163
+ },
164
+ {
165
+ title: `预发布修订版本(${i[t.PREPATCH].version})`,
166
+ value: t.PREPATCH
167
+ },
168
+ {
169
+ title: `alpha版本(${i[t.PRERELEASE].version})`,
170
+ value: t.PRERELEASE
171
+ }
172
+ ];
173
+ E = (await x({
174
+ type: "select",
175
+ name: "type",
176
+ message: `请选择发布类型,当前版本:${p.version}`,
177
+ choices: T
178
+ })).type, m = i[E];
179
+ }
180
+ const { version: P } = m;
181
+ o(`npm version ${P}`, {
182
+ stdio: "inherit"
183
+ });
184
+ try {
185
+ if (r === f.NPM) {
186
+ const { tag: d } = m;
187
+ o(`npm publish --tag ${d}`, {
188
+ stdio: "inherit"
189
+ });
190
+ } else if (r === f.WEB) {
191
+ const { webBuild: d } = n;
192
+ d ? o(`${d}`, {
193
+ stdio: "inherit"
194
+ }) : g.warn("webBuild为空,不执行web构建");
195
+ } else
196
+ throw new Error("未知命令");
197
+ } catch (d) {
198
+ g.error(`发布失败, error: ${d.message}`);
199
+ try {
200
+ g.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
201
+ const { lastHash: i } = c;
202
+ o(`git reset --hard ${i}`, {
203
+ stdio: "inherit"
204
+ }), g.info(`删除本次发布时生成的tag:v${m.version}`), o(`git tag -d v${m.version}`, {
205
+ stdio: "inherit"
206
+ });
207
+ } catch (i) {
208
+ g.error(`回滚失败, error: ${i.message}`);
209
+ }
210
+ return process.exit(1);
211
+ }
212
+ s && (o(`git push ${n.gitOriginName} v${m.version}`, {
213
+ stdio: "inherit"
214
+ }), o(`git push ${n.gitOriginName} ${c.branchName}`, {
215
+ stdio: "inherit"
216
+ })), g.success(`发布成功,版本号:${P}`);
217
+ }, q = {
218
+ command: "$0",
219
+ describe: "执行发布命令",
220
+ options: k(),
221
+ handler: y
222
+ }, te = async (e, r) => {
223
+ switch (e) {
224
+ case v.INIT:
225
+ return w(r);
226
+ case v.EXEC:
227
+ return y(r);
228
+ default:
229
+ throw new Error(`不支持的命令 ${e}`);
230
+ }
231
+ }, { version: z, description: K } = C, L = {
232
+ describe: K,
233
+ version: z,
234
+ subcommands: [Y, q].map(M),
235
+ demandCommandCount: 1
236
+ }, {
237
+ cliConfig: { moduleName: O }
238
+ } = C, S = (e = !1) => {
239
+ const r = e ? O : void 0, l = `$0${e ? ` ${O}` : ""} [options]`;
240
+ return { command: r, usage: l };
241
+ }, re = async () => _({
242
+ ...L,
243
+ ...S()
244
+ }), ne = () => M({
245
+ ...L,
246
+ ...S(!0)
247
+ });
248
+ export {
249
+ ne as a,
250
+ re as c,
251
+ te as h
252
+ };
package/es/index.mjs CHANGED
@@ -1,13 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { P as n, a as s, h as d } from "./index-b550c95a.js";
2
+ import { a as i, h as n } from "./index-69c14c7f.js";
3
+ import "@done-coding/cli-utils";
3
4
  import "semver";
4
- import "node:path";
5
5
  import "node:child_process";
6
6
  import "pinyin";
7
- import "node:fs";
8
- import "@done-coding/cli-utils";
9
7
  export {
10
- n as PublishModeEnum,
11
- s as crateAsSubcommand,
12
- d as handler
8
+ i as crateAsSubcommand,
9
+ n as handler
13
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.5.5",
3
+ "version": "0.6.0-alpha.0",
4
4
  "description": "项目发布命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "license": "MIT",
41
41
  "sideEffects": false,
42
42
  "devDependencies": {
43
- "@done-coding/cli-inject": "^0.5.5",
43
+ "@done-coding/cli-inject": "^0.5.6-alpha.0",
44
44
  "@types/node": "^18.0.0",
45
45
  "@types/pinyin": "^2.10.0",
46
46
  "@types/semver": "^7.5.3",
@@ -54,9 +54,9 @@
54
54
  "node": ">=18.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "@done-coding/cli-utils": "^0.3.5",
57
+ "@done-coding/cli-utils": "^0.4.0-alpha.0",
58
58
  "pinyin": "^2.11.2",
59
59
  "semver": "^7.5.4"
60
60
  },
61
- "gitHead": "eccf973ebc52fc3b06d26391d371e8d2d1629a61"
61
+ "gitHead": "360b14a641064f732b01ffd6339c2f1963945b61"
62
62
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { type ExecOptions } from '../types';
2
+ import type { CliHandlerArgv, CliInfo, SubCliInfo } from "@done-coding/cli-utils";
3
+ export declare const getExecOptions: () => CliInfo["options"];
4
+ export type ChildCmd = "npm" | "web";
5
+ export declare const execHandler: (argv: CliHandlerArgv<ExecOptions>) => Promise<undefined>;
6
+ export declare const execCommandCliInfo: SubCliInfo;
@@ -0,0 +1,7 @@
1
+ import { initHandler, initCommandCliInfo } from "./init";
2
+ import { execHandler, execCommandCliInfo } from "./exec";
3
+ import { SubcommandEnum } from '../types';
4
+ import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
5
+ export { initHandler, initCommandCliInfo, execHandler, execCommandCliInfo };
6
+ export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
7
+ export declare const commandCliInfo: Omit<CliInfo, "usage">;
@@ -0,0 +1,8 @@
1
+ /// <reference types="yargs" />
2
+ import type { CliHandlerArgv, SubCliInfo } from "@done-coding/cli-utils";
3
+ import { type InitOptions } from '../types';
4
+ /** 获取初始化选项 */
5
+ export declare const getInitOptions: () => Record<keyof import("@done-coding/cli-utils").ConfigFileCommonOptions, import("yargs").Options>;
6
+ /** 初始化命令处理器 */
7
+ export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
8
+ export declare const initCommandCliInfo: SubCliInfo;
package/types/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export { handler } from "./handler";
1
+ export { handler } from './handlers';
2
2
  export { crateAsSubcommand } from "./main";
3
- export * from './utils/types';
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.5.5",
3
+ "version": "0.6.0-alpha.0",
4
4
  "description": "项目发布命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",
@@ -1,4 +1,62 @@
1
- import type { PublishTagEnum, PublishVersionTypeEnum } from "./enums";
1
+ import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
2
+ /** 子命令枚举 */
3
+ export declare enum SubcommandEnum {
4
+ /** 初始化发布配置文件 */
5
+ INIT = "init",
6
+ /** 发布执行 */
7
+ EXEC = "exec"
8
+ }
9
+ export type InitOptions = InitConfigFileOptions;
10
+ /**
11
+ * 发布版本类型
12
+ */
13
+ export declare enum PublishVersionTypeEnum {
14
+ /**
15
+ * 主版本号
16
+ */
17
+ MAJOR = "major",
18
+ /**
19
+ * 次版本号
20
+ */
21
+ MINOR = "minor",
22
+ /**
23
+ * 修订版本号
24
+ */
25
+ PATCH = "patch",
26
+ /**
27
+ * 预发布版本号
28
+ */
29
+ PREMAJOR = "premajor",
30
+ /**
31
+ * 预发布次版本号
32
+ */
33
+ PREMINOR = "preminor",
34
+ /**
35
+ * 预发布修订版本号
36
+ */
37
+ PREPATCH = "prepatch",
38
+ /**
39
+ * 预发布版本号
40
+ */
41
+ PRERELEASE = "prerelease"
42
+ }
43
+ /**
44
+ * 发布标签类型
45
+ */
46
+ export declare enum PublishTagEnum {
47
+ /**
48
+ * 最新版本
49
+ */
50
+ LATEST = "latest",
51
+ /**
52
+ * next版本
53
+ */
54
+ NEXT = "next",
55
+ /**
56
+ * alpha版本
57
+ */
58
+ ALPHA = "alpha"
59
+ }
2
60
  /**
3
61
  * git仓库信息
4
62
  */
@@ -68,7 +126,7 @@ export interface ConfigInfo {
68
126
  /**
69
127
  * web构建命令
70
128
  */
71
- webBuild: string;
129
+ webBuild?: string;
72
130
  /**
73
131
  * git远程仓库名
74
132
  */
@@ -81,7 +139,7 @@ export declare enum PublishModeEnum {
81
139
  /** web发布模式 */
82
140
  WEB = "web"
83
141
  }
84
- export interface Options {
142
+ export interface ExecOptions extends ReadConfigFileOptions {
85
143
  /** 发布模式 */
86
144
  mode: PublishModeEnum;
87
145
  /**
@@ -1,2 +1 @@
1
- export * from "./types";
2
- export * from "./enums";
1
+ export * from "./path";
@@ -0,0 +1,4 @@
1
+ /** 模块配置相对路径 */
2
+ export declare const MODULE_CONFIG_RELATIVE_PATH: string;
3
+ /** 模块默认配置文件相对路径 */
4
+ export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
@@ -1,252 +0,0 @@
1
- #!/usr/bin/env node
2
- import { inc as A, prerelease as $ } from "semver";
3
- import { join as h } from "node:path";
4
- import { execSync as i } from "node:child_process";
5
- import P from "pinyin";
6
- import { readFileSync as v, existsSync as C } from "node:fs";
7
- import { xPrompts as I, log as E, createMainCommand as H, createSubcommand as w } from "@done-coding/cli-utils";
8
- var p = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(p || {}), 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 || {}), d = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e))(d || {});
9
- const y = "/.dc/publish.json", M = "/package.json", J = ({ gitOriginName: e = "origin" }) => {
10
- try {
11
- const o = i("git rev-parse HEAD").toString().trim(), m = i('git log -1 --pretty=format:"%an"').toString().trim(), c = i('git log -1 --pretty=format:"%ae"').toString().trim(), s = i('git log -1 --pretty=format:"%s"').toString().trim(), n = i("git config user.name").toString().trim(), l = i("git config user.email").toString().trim(), R = i("git rev-parse --abbrev-ref HEAD").toString().trim();
12
- let f = "";
13
- try {
14
- f = i(`git config --get remote.${e}.url`).toString().trim();
15
- } catch {
16
- throw new Error(`git remote ${e} 不存在`);
17
- }
18
- return {
19
- lastHash: o,
20
- lastCommitter: m,
21
- lastCommitterPinYin: P(m, {
22
- style: P.STYLE_NORMAL,
23
- heteronym: !1
24
- }).join(""),
25
- lastCommitEmail: c,
26
- lastCommitMsg: s,
27
- userName: n,
28
- userNamePinYin: P(n, {
29
- style: P.STYLE_NORMAL,
30
- heteronym: !1
31
- }).join(""),
32
- userEmail: l,
33
- branchName: R,
34
- remoteUrl: f
35
- };
36
- } catch (o) {
37
- throw console.error("Error fetching git information:", o), o;
38
- }
39
- }, g = (e, o = JSON.parse(v(h(process.cwd(), M), "utf-8"))) => {
40
- let m = o.name, c = "", s;
41
- const { version: n } = o;
42
- if ([
43
- t.MAJOR,
44
- t.MINOR,
45
- t.PATCH
46
- ].includes(e))
47
- c = A(n, e), s = d.LATEST;
48
- else if ([
49
- t.PREMAJOR,
50
- t.PREMINOR,
51
- t.PREPATCH
52
- ].includes(e)) {
53
- const l = $(n);
54
- l ? (E.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), l.length === 1 && typeof l[0] == "number" ? c = A(
55
- n,
56
- t.PRERELEASE
57
- ) : c = n.split("-")[0] + "-0") : c = A(n, e), s = d.NEXT;
58
- } else
59
- s = d.ALPHA, c = A(
60
- n,
61
- t.PRERELEASE,
62
- s
63
- );
64
- if (!c)
65
- throw new Error("version is empty");
66
- return {
67
- name: m,
68
- version: c,
69
- tag: s
70
- };
71
- }, L = () => {
72
- let e;
73
- const o = h(process.cwd(), y);
74
- if (C(o)) {
75
- const m = v(o, "utf-8");
76
- e = JSON.parse(m);
77
- } else
78
- E.warn(`未找到配置文件,将使用默认配置
79
- { gitOriginName: "origin" }
80
- `);
81
- return {
82
- gitOriginName: "origin",
83
- ...e || {}
84
- };
85
- }, T = async (e) => {
86
- const { mode: o, type: m, push: c } = e, s = L(), n = J(s);
87
- let l = m, R;
88
- if (l)
89
- R = await g(l);
90
- else {
91
- const r = JSON.parse(v(h(process.cwd(), M), "utf-8")), a = {
92
- [t.MAJOR]: g(
93
- t.MAJOR,
94
- r
95
- ),
96
- [t.MINOR]: g(
97
- t.MINOR,
98
- r
99
- ),
100
- [t.PATCH]: g(
101
- t.PATCH,
102
- r
103
- ),
104
- [t.PREMAJOR]: g(
105
- t.PREMAJOR,
106
- r
107
- ),
108
- [t.PREMINOR]: g(
109
- t.PREMINOR,
110
- r
111
- ),
112
- [t.PREPATCH]: g(
113
- t.PREPATCH,
114
- r
115
- ),
116
- [t.PRERELEASE]: g(
117
- t.PRERELEASE,
118
- r
119
- )
120
- }, S = [
121
- {
122
- title: `主版本(${a[t.MAJOR].version})`,
123
- value: t.MAJOR
124
- },
125
- {
126
- title: `次版本(${a[t.MINOR].version})`,
127
- value: t.MINOR
128
- },
129
- {
130
- title: `修订版本(${a[t.PATCH].version})`,
131
- value: t.PATCH
132
- },
133
- {
134
- title: `预发布主版本(${a[t.PREMAJOR].version})`,
135
- value: t.PREMAJOR
136
- },
137
- {
138
- title: `预发布次版本(${a[t.PREMINOR].version})`,
139
- value: t.PREMINOR
140
- },
141
- {
142
- title: `预发布修订版本(${a[t.PREPATCH].version})`,
143
- value: t.PREPATCH
144
- },
145
- {
146
- title: `alpha版本(${a[t.PRERELEASE].version})`,
147
- value: t.PRERELEASE
148
- }
149
- ];
150
- l = (await I({
151
- type: "select",
152
- name: "type",
153
- message: `请选择发布类型,当前版本:${r.version}`,
154
- choices: S
155
- })).type, R = a[l];
156
- }
157
- const { version: f } = R;
158
- i(`npm version ${f}`, {
159
- stdio: "inherit"
160
- });
161
- try {
162
- if (o === p.NPM) {
163
- const { tag: r } = R;
164
- i(`npm publish --tag ${r}`, {
165
- stdio: "inherit"
166
- });
167
- } else if (o === p.WEB) {
168
- const { webBuild: r } = s;
169
- r ? i(`${r}`, {
170
- stdio: "inherit"
171
- }) : E.warn("webBuild为空,不执行web构建");
172
- } else
173
- throw new Error("未知命令");
174
- } catch (r) {
175
- E.error(`发布失败, error: ${r.message}`);
176
- try {
177
- E.info(`回滚本地版本到发布前的版本:${n.lastHash}`);
178
- const { lastHash: a } = n;
179
- i(`git reset --hard ${a}`, {
180
- stdio: "inherit"
181
- }), E.info(`删除本次发布时生成的tag:v${R.version}`), i(`git tag -d v${R.version}`, {
182
- stdio: "inherit"
183
- });
184
- } catch (a) {
185
- E.error(`回滚失败, error: ${a.message}`);
186
- }
187
- return process.exit(1);
188
- }
189
- c && (i(`git push ${s.gitOriginName} v${R.version}`, {
190
- stdio: "inherit"
191
- }), i(`git push ${s.gitOriginName} ${n.branchName}`, {
192
- stdio: "inherit"
193
- })), E.success(`发布成功,版本号:${f}`);
194
- }, b = {
195
- name: "@done-coding/cli-publish",
196
- version: "0.5.5",
197
- description: "项目发布命令行工具",
198
- cliConfig: {
199
- namespaceDir: ".done-coding",
200
- moduleName: "publish"
201
- }
202
- }, {
203
- version: j,
204
- description: x,
205
- cliConfig: { moduleName: O }
206
- } = b, B = () => ({
207
- mode: {
208
- alias: "m",
209
- describe: "发布模式",
210
- choices: [p.NPM, p.WEB],
211
- default: p.NPM
212
- },
213
- type: {
214
- alias: "t",
215
- describe: "发布类型",
216
- choices: [
217
- t.MAJOR,
218
- t.MINOR,
219
- t.PATCH,
220
- t.PREMAJOR,
221
- t.PREMINOR,
222
- t.PREPATCH,
223
- t.PRERELEASE
224
- ]
225
- },
226
- push: {
227
- alias: "p",
228
- describe: "是否推送至远程仓库",
229
- type: "boolean",
230
- default: !0
231
- }
232
- }), N = {
233
- describe: x,
234
- version: j,
235
- options: B(),
236
- handler: T
237
- }, u = (e = !1) => {
238
- const o = e ? O : void 0, m = `$0${e ? ` ${O}` : ""} [options]`;
239
- return { command: o, usage: m };
240
- }, _ = async () => H({
241
- ...N,
242
- ...u()
243
- }), F = () => w({
244
- ...N,
245
- ...u(!0)
246
- });
247
- export {
248
- p as P,
249
- F as a,
250
- _ as c,
251
- T as h
252
- };
@@ -1,4 +0,0 @@
1
- import { type Options } from './utils';
2
- import type { CliHandlerArgv } from "@done-coding/cli-utils";
3
- export type ChildCmd = "npm" | "web";
4
- export declare const handler: (argv: CliHandlerArgv<Options>) => Promise<undefined>;
@@ -1,50 +0,0 @@
1
- /**
2
- * 发布版本类型
3
- */
4
- export declare enum PublishVersionTypeEnum {
5
- /**
6
- * 主版本号
7
- */
8
- MAJOR = "major",
9
- /**
10
- * 次版本号
11
- */
12
- MINOR = "minor",
13
- /**
14
- * 修订版本号
15
- */
16
- PATCH = "patch",
17
- /**
18
- * 预发布版本号
19
- */
20
- PREMAJOR = "premajor",
21
- /**
22
- * 预发布次版本号
23
- */
24
- PREMINOR = "preminor",
25
- /**
26
- * 预发布修订版本号
27
- */
28
- PREPATCH = "prepatch",
29
- /**
30
- * 预发布版本号
31
- */
32
- PRERELEASE = "prerelease"
33
- }
34
- /**
35
- * 发布标签类型
36
- */
37
- export declare enum PublishTagEnum {
38
- /**
39
- * 最新版本
40
- */
41
- LATEST = "latest",
42
- /**
43
- * next版本
44
- */
45
- NEXT = "next",
46
- /**
47
- * alpha版本
48
- */
49
- ALPHA = "alpha"
50
- }