@done-coding/cli-publish 0.7.11 → 0.7.13
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/README.md +246 -3
- package/es/cli.mjs +1 -3
- package/es/{index-ccdf15a3.js → index-f33712b6.js} +121 -118
- package/es/index.mjs +5 -7
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -1,7 +1,250 @@
|
|
|
1
1
|
# @done-coding/cli-publish
|
|
2
2
|
|
|
3
|
-
项目发布命令行工具
|
|
3
|
+
项目发布命令行工具 - 自动化项目版本管理和发布流程
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@done-coding/cli-publish)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
### 独立安装
|
|
11
|
+
```bash
|
|
12
|
+
npm install @done-coding/cli-publish
|
|
13
|
+
# 或
|
|
14
|
+
pnpm add @done-coding/cli-publish
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 作为 done-coding CLI 的一部分
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @done-coding/cli
|
|
20
|
+
# 然后使用
|
|
21
|
+
DC publish [command]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 快速开始
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 独立使用
|
|
28
|
+
dc-publish [command]
|
|
29
|
+
|
|
30
|
+
# 作为主 CLI 的子命令
|
|
31
|
+
DC publish [command]
|
|
32
|
+
|
|
33
|
+
# 查看帮助
|
|
34
|
+
dc-publish --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 功能特性
|
|
38
|
+
|
|
39
|
+
- ✅ **版本管理**: 支持语义化版本号管理
|
|
40
|
+
- 📦 **多模式发布**: 支持 npm 和 web 两种发布模式
|
|
41
|
+
- 🏷️ **标签管理**: 支持不同的发布标签(latest、next、alpha、beta、rc)
|
|
42
|
+
- 🔄 **Git 集成**: 支持自动推送到远程仓库
|
|
43
|
+
- ⚙️ **配置管理**: 支持配置文件管理发布规则
|
|
44
|
+
|
|
45
|
+
## API 文档
|
|
46
|
+
|
|
47
|
+
### 基础命令
|
|
48
|
+
|
|
49
|
+
#### `dc-publish init`
|
|
50
|
+
初始化配置文件
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# 创建默认配置文件
|
|
54
|
+
dc-publish init
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### `dc-publish` (默认命令)
|
|
58
|
+
执行发布命令
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# 使用默认配置发布
|
|
62
|
+
dc-publish
|
|
63
|
+
|
|
64
|
+
# 指定发布类型
|
|
65
|
+
dc-publish -t patch
|
|
66
|
+
|
|
67
|
+
# 指定发布模式
|
|
68
|
+
dc-publish -m npm
|
|
69
|
+
|
|
70
|
+
# 指定发布标签
|
|
71
|
+
dc-publish -d next
|
|
72
|
+
|
|
73
|
+
# 禁用推送到远程仓库
|
|
74
|
+
dc-publish -p false
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `dc-publish alias`
|
|
78
|
+
别名发布
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# 执行别名发布
|
|
82
|
+
dc-publish alias
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 命令选项
|
|
86
|
+
|
|
87
|
+
- `-R, --rootDir`: 运行目录
|
|
88
|
+
- `-C, --configPath`: 配置文件相对路径,默认为 `./.done-coding/publish.json`
|
|
89
|
+
- `-m, --mode`: 发布模式,可选值:`npm`(默认)、`web`
|
|
90
|
+
- `-t, --type`: 发布类型,可选值:`major`、`minor`、`patch`、`premajor`、`preminor`、`prepatch`、`prerelease`、`custom version`
|
|
91
|
+
- `-p, --push`: 是否推送至远程仓库,默认为 `true`
|
|
92
|
+
- `-d, --distTag`: 发布标签,可选值:`latest`、`next`、`alpha`、`beta`、`rc`
|
|
93
|
+
|
|
94
|
+
## 使用示例
|
|
95
|
+
|
|
96
|
+
### 基础使用场景
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# 1. 初始化配置
|
|
100
|
+
dc-publish init
|
|
101
|
+
|
|
102
|
+
# 2. 发布补丁版本
|
|
103
|
+
dc-publish -t patch
|
|
104
|
+
|
|
105
|
+
# 3. 发布到 next 标签
|
|
106
|
+
dc-publish -t minor -d next
|
|
107
|
+
|
|
108
|
+
# 4. 发布但不推送到远程仓库
|
|
109
|
+
dc-publish -t patch -p false
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 不同发布类型
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# 主版本发布 (1.0.0 -> 2.0.0)
|
|
116
|
+
dc-publish -t major
|
|
117
|
+
|
|
118
|
+
# 次版本发布 (1.0.0 -> 1.1.0)
|
|
119
|
+
dc-publish -t minor
|
|
120
|
+
|
|
121
|
+
# 补丁版本发布 (1.0.0 -> 1.0.1)
|
|
122
|
+
dc-publish -t patch
|
|
123
|
+
|
|
124
|
+
# 预发布版本 (1.0.0 -> 1.0.1-0)
|
|
125
|
+
dc-publish -t prerelease
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 不同发布模式
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# npm 模式发布
|
|
132
|
+
dc-publish -m npm
|
|
133
|
+
|
|
134
|
+
# web 模式发布
|
|
135
|
+
dc-publish -m web
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 作为主 CLI 的一部分
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Windows 系统
|
|
142
|
+
dc publish init
|
|
143
|
+
dc publish -t patch
|
|
144
|
+
dc publish alias
|
|
145
|
+
|
|
146
|
+
# macOS/Linux 系统
|
|
147
|
+
DC publish init
|
|
148
|
+
DC publish -t patch
|
|
149
|
+
DC publish alias
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 配置
|
|
153
|
+
|
|
154
|
+
通过 `dc-publish init` 命令可以初始化配置文件 `.done-coding/publish.json`。
|
|
155
|
+
|
|
156
|
+
具体的配置选项需要查看初始化后生成的配置文件内容。
|
|
157
|
+
|
|
158
|
+
## 编程接口
|
|
159
|
+
|
|
160
|
+
本包提供了编程接口,具体的导出内容请查看包的类型定义文件。
|
|
161
|
+
|
|
162
|
+
## 故障排除
|
|
163
|
+
|
|
164
|
+
### 常见问题
|
|
165
|
+
|
|
166
|
+
**Q: 配置文件找不到**
|
|
167
|
+
```bash
|
|
168
|
+
# 检查配置文件是否存在
|
|
169
|
+
ls -la .done-coding/publish.json
|
|
170
|
+
|
|
171
|
+
# 重新初始化配置
|
|
172
|
+
dc-publish init
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Q: 发布失败**
|
|
176
|
+
```bash
|
|
177
|
+
# 检查 npm 登录状态
|
|
178
|
+
npm whoami
|
|
179
|
+
|
|
180
|
+
# 检查包名是否已存在
|
|
181
|
+
npm view @your-package-name
|
|
182
|
+
|
|
183
|
+
# 检查网络连接
|
|
184
|
+
npm ping
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Q: Git 推送失败**
|
|
188
|
+
```bash
|
|
189
|
+
# 检查 Git 远程仓库配置
|
|
190
|
+
git remote -v
|
|
191
|
+
|
|
192
|
+
# 检查 Git 认证
|
|
193
|
+
git config --list | grep user
|
|
194
|
+
|
|
195
|
+
# 禁用自动推送
|
|
196
|
+
dc-publish -p false
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 调试模式
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# 查看版本信息
|
|
203
|
+
dc-publish --version
|
|
204
|
+
|
|
205
|
+
# 查看帮助信息
|
|
206
|
+
dc-publish --help
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 贡献指南
|
|
210
|
+
|
|
211
|
+
我们欢迎贡献!请遵循以下步骤:
|
|
212
|
+
|
|
213
|
+
1. Fork 本仓库
|
|
214
|
+
2. 创建功能分支:`git checkout -b feature/amazing-feature`
|
|
215
|
+
3. 提交更改:`git commit -m "feat: add amazing feature"`
|
|
216
|
+
4. 推送分支:`git push origin feature/amazing-feature`
|
|
217
|
+
5. 创建 Pull Request
|
|
218
|
+
|
|
219
|
+
### 开发环境设置
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# 克隆仓库
|
|
223
|
+
git clone https://gitee.com/done-coding/done-coding-cli.git
|
|
224
|
+
cd done-coding-cli/packages/publish
|
|
225
|
+
|
|
226
|
+
# 安装依赖
|
|
227
|
+
pnpm install
|
|
228
|
+
|
|
229
|
+
# 开发模式
|
|
230
|
+
pnpm dev
|
|
231
|
+
|
|
232
|
+
# 构建
|
|
233
|
+
pnpm build
|
|
234
|
+
|
|
235
|
+
# 本地开发测试
|
|
236
|
+
node es/cli.mjs --help
|
|
237
|
+
|
|
238
|
+
# 注意:本地使用 node + 入口文件,发布后使用 bin 命令名
|
|
239
|
+
# 功能完全一致,只是调用方式不同
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## 许可证
|
|
243
|
+
|
|
244
|
+
MIT © [JustSoSu](https://gitee.com/done-coding)
|
|
245
|
+
|
|
246
|
+
## 相关链接
|
|
247
|
+
|
|
248
|
+
- [主 CLI 工具](https://www.npmjs.com/package/@done-coding/cli)
|
|
249
|
+
- [Gitee 仓库](https://gitee.com/done-coding/done-coding-cli)
|
|
250
|
+
- [更新日志](./CHANGELOG.md)
|
package/es/cli.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as m } from "./index-
|
|
2
|
+
import { c as m } from "./index-f33712b6.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
|
-
import "node:os";
|
|
5
4
|
import "node:child_process";
|
|
6
5
|
import "semver";
|
|
7
|
-
import "uuid";
|
|
8
6
|
import "node:path";
|
|
9
7
|
import "node:fs";
|
|
10
8
|
m();
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getConfigFileCommonOptions as O, initHandlerCommon as F, log as
|
|
3
|
-
import { tmpdir as q } from "node:os";
|
|
2
|
+
import { getConfigFileCommonOptions as O, initHandlerCommon as F, log as m, readConfigFile as H, getPackageJson as $, applyUseTempDir as U, getCliModuleTempDir as G, getGitLastCommitInfo as W, pushGitPublishInfoToRemote as X, xPrompts as L, createSubcommand as y, getRootScriptName as V, createMainCommand as q } from "@done-coding/cli-utils";
|
|
4
3
|
import { execSync as l } from "node:child_process";
|
|
5
|
-
import { inc as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const P = {
|
|
4
|
+
import { inc as N } from "semver";
|
|
5
|
+
import z from "node:path";
|
|
6
|
+
import S, { rmSync as K } from "node:fs";
|
|
7
|
+
var I = /* @__PURE__ */ ((e) => (e.INIT = "init", e.EXEC = "exec", e.ALIAS = "alias", e))(I || {}), 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 || {});
|
|
8
|
+
const R = {
|
|
11
9
|
name: "@done-coding/cli-publish",
|
|
12
|
-
version: "0.7.
|
|
10
|
+
version: "0.7.13",
|
|
13
11
|
description: "项目发布命令行工具",
|
|
14
12
|
bin: {
|
|
15
13
|
"dc-publish": "es/cli.mjs"
|
|
@@ -18,9 +16,9 @@ const P = {
|
|
|
18
16
|
namespaceDir: ".done-coding",
|
|
19
17
|
moduleName: "publish"
|
|
20
18
|
}
|
|
21
|
-
},
|
|
22
|
-
cliConfig: { namespaceDir:
|
|
23
|
-
} =
|
|
19
|
+
}, {
|
|
20
|
+
cliConfig: { namespaceDir: Q, moduleName: Y }
|
|
21
|
+
} = R, Z = `./${Q}/${Y}`, v = `${Z}.json`, ee = {
|
|
24
22
|
[c.WEB]: {},
|
|
25
23
|
[c.NPM]: {
|
|
26
24
|
aliasInfo: [
|
|
@@ -33,65 +31,70 @@ const P = {
|
|
|
33
31
|
}
|
|
34
32
|
]
|
|
35
33
|
}
|
|
36
|
-
},
|
|
34
|
+
}, te = () => O({
|
|
37
35
|
configPathDefault: v
|
|
38
|
-
}), k = async (e) => F(
|
|
36
|
+
}), k = async (e) => F(ee, e, {
|
|
39
37
|
onFileGenerated: () => {
|
|
40
|
-
|
|
38
|
+
m.info("文件生成成功");
|
|
41
39
|
}
|
|
42
|
-
}),
|
|
43
|
-
command:
|
|
40
|
+
}), ne = {
|
|
41
|
+
command: I.INIT,
|
|
44
42
|
describe: "初始化配置文件",
|
|
45
|
-
options:
|
|
43
|
+
options: te(),
|
|
46
44
|
handler: k
|
|
47
|
-
},
|
|
45
|
+
}, oe = () => O({
|
|
48
46
|
configPathDefault: v
|
|
49
|
-
}),
|
|
47
|
+
}), J = (e) => {
|
|
50
48
|
var o;
|
|
51
49
|
const t = ((o = e[c.NPM]) == null ? void 0 : o.aliasInfo) || [];
|
|
52
50
|
if (t.length)
|
|
53
51
|
return t;
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
const t = await _(e, () => ({})), o = y(t);
|
|
52
|
+
}, M = async (e) => {
|
|
53
|
+
const t = await H(e, () => ({})), o = J(t);
|
|
57
54
|
if (!o) {
|
|
58
|
-
|
|
55
|
+
m.warn("没有配置别名发布信息");
|
|
59
56
|
return;
|
|
60
57
|
}
|
|
61
|
-
const { rootDir:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
const { rootDir: d } = e, s = $({ rootDir: d }), { name: a, version: i } = s;
|
|
59
|
+
return U({
|
|
60
|
+
dir: G(R.cliConfig.moduleName),
|
|
61
|
+
fn: async (n) => {
|
|
62
|
+
var g;
|
|
63
|
+
S.mkdirSync(n, { recursive: !0 }), l(`pnpm add ${a}@${i}`, {
|
|
64
|
+
stdio: "inherit",
|
|
65
|
+
cwd: n
|
|
66
|
+
});
|
|
67
|
+
const h = (g = l(`npm dist-tag ${a}`).toString().trim().split(`
|
|
68
|
+
`).map((E) => E.split(":").map((w) => w.trim())).find(
|
|
69
|
+
([, E]) => E === i
|
|
70
|
+
)) == null ? void 0 : g[0];
|
|
71
|
+
if (!h)
|
|
72
|
+
return m.warn(`没有找到 ${a}@${i} 对应的dist-tag`);
|
|
73
|
+
const C = z.resolve(n, "node_modules", a), u = $({
|
|
74
|
+
rootDir: C
|
|
75
|
+
});
|
|
76
|
+
for (let E of o) {
|
|
77
|
+
const { packageJson: w } = E, j = {
|
|
78
|
+
...u,
|
|
79
|
+
...w
|
|
80
|
+
}, B = `${C}/package.json`;
|
|
81
|
+
S.writeFileSync(
|
|
82
|
+
B,
|
|
83
|
+
JSON.stringify(j, null, 2)
|
|
84
|
+
), l(`pnpm publish --tag ${h}`, {
|
|
85
|
+
stdio: "inherit",
|
|
86
|
+
cwd: C
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
K(n, { recursive: !0, force: !0 });
|
|
90
|
+
}
|
|
74
91
|
});
|
|
75
|
-
|
|
76
|
-
|
|
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,
|
|
92
|
+
}, se = {
|
|
93
|
+
command: I.ALIAS,
|
|
91
94
|
describe: "别名发布",
|
|
92
|
-
options:
|
|
93
|
-
handler:
|
|
94
|
-
},
|
|
95
|
+
options: oe(),
|
|
96
|
+
handler: M
|
|
97
|
+
}, re = () => ({
|
|
95
98
|
...O({
|
|
96
99
|
configPathDefault: v
|
|
97
100
|
}),
|
|
@@ -117,12 +120,12 @@ const P = {
|
|
|
117
120
|
describe: "发布标签",
|
|
118
121
|
choices: Object.values(f)
|
|
119
122
|
}
|
|
120
|
-
}),
|
|
123
|
+
}), P = async ({
|
|
121
124
|
packageJson: e,
|
|
122
125
|
type: t,
|
|
123
126
|
distTag: o
|
|
124
127
|
}) => {
|
|
125
|
-
let
|
|
128
|
+
let d = e.name, s = "", a;
|
|
126
129
|
const { version: i } = e;
|
|
127
130
|
if (!i)
|
|
128
131
|
throw new Error("当前版本号为空");
|
|
@@ -130,27 +133,27 @@ const P = {
|
|
|
130
133
|
case r.PATCH:
|
|
131
134
|
case r.MINOR:
|
|
132
135
|
case r.MAJOR: {
|
|
133
|
-
s =
|
|
136
|
+
s = N(i, t), a = o || f.LATEST;
|
|
134
137
|
break;
|
|
135
138
|
}
|
|
136
139
|
case r.PREPATCH:
|
|
137
140
|
case r.PREMINOR:
|
|
138
141
|
case r.PREMAJOR: {
|
|
139
|
-
s =
|
|
142
|
+
s = N(i, t, f.ALPHA), a = o || f.ALPHA;
|
|
140
143
|
break;
|
|
141
144
|
}
|
|
142
145
|
case r.PRERELEASE: {
|
|
143
|
-
const n = (await
|
|
146
|
+
const n = (await L({
|
|
144
147
|
type: "text",
|
|
145
148
|
name: "identifier",
|
|
146
149
|
message: "请输入修饰符",
|
|
147
150
|
initial: f.ALPHA
|
|
148
151
|
})).identifier;
|
|
149
|
-
s =
|
|
152
|
+
s = N(i, t, n), a = o || n;
|
|
150
153
|
break;
|
|
151
154
|
}
|
|
152
155
|
default:
|
|
153
|
-
s = (await
|
|
156
|
+
s = (await L({
|
|
154
157
|
type: "text",
|
|
155
158
|
name: "customVersion",
|
|
156
159
|
message: "请输入自定义版本号"
|
|
@@ -159,23 +162,23 @@ const P = {
|
|
|
159
162
|
if (!s)
|
|
160
163
|
throw new Error("version is empty");
|
|
161
164
|
return {
|
|
162
|
-
name:
|
|
165
|
+
name: d,
|
|
163
166
|
version: s,
|
|
164
167
|
tag: a
|
|
165
168
|
};
|
|
166
|
-
},
|
|
169
|
+
}, ie = async ({
|
|
167
170
|
type: e,
|
|
168
171
|
packageJson: t,
|
|
169
172
|
distTag: o
|
|
170
173
|
}) => {
|
|
171
174
|
if (e)
|
|
172
|
-
return await
|
|
175
|
+
return await P({
|
|
173
176
|
packageJson: t,
|
|
174
177
|
type: e,
|
|
175
178
|
distTag: o
|
|
176
179
|
});
|
|
177
180
|
{
|
|
178
|
-
const
|
|
181
|
+
const d = {}, s = [
|
|
179
182
|
r.PATCH,
|
|
180
183
|
r.MINOR,
|
|
181
184
|
r.MAJOR,
|
|
@@ -184,14 +187,14 @@ const P = {
|
|
|
184
187
|
r.PREMAJOR
|
|
185
188
|
];
|
|
186
189
|
for (let n of s)
|
|
187
|
-
|
|
190
|
+
d[n] = await P({
|
|
188
191
|
packageJson: t,
|
|
189
192
|
type: n,
|
|
190
193
|
distTag: o
|
|
191
194
|
});
|
|
192
195
|
const a = [
|
|
193
196
|
...s.map((n) => ({
|
|
194
|
-
title: `${n} (${
|
|
197
|
+
title: `${n} (${d[n].version})`,
|
|
195
198
|
value: n
|
|
196
199
|
})),
|
|
197
200
|
...[
|
|
@@ -201,35 +204,35 @@ const P = {
|
|
|
201
204
|
title: n,
|
|
202
205
|
value: n
|
|
203
206
|
}))
|
|
204
|
-
], i = (await
|
|
207
|
+
], i = (await L({
|
|
205
208
|
type: "select",
|
|
206
209
|
name: "selectType",
|
|
207
210
|
message: `请选择发布类型,当前版本:${t.version}`,
|
|
208
211
|
choices: a
|
|
209
212
|
})).selectType;
|
|
210
|
-
return s.includes(i) ?
|
|
213
|
+
return s.includes(i) ? d[i] : P({
|
|
211
214
|
packageJson: t,
|
|
212
215
|
type: i,
|
|
213
216
|
distTag: o
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
|
-
},
|
|
217
|
-
const { mode: t, type: o, push:
|
|
219
|
+
}, x = async (e) => {
|
|
220
|
+
const { mode: t, type: o, push: d, rootDir: s, distTag: a } = e, i = await H(e, () => ({})), n = i[t], A = await W(n), T = $({ rootDir: s }), p = await ie({
|
|
218
221
|
type: o,
|
|
219
|
-
packageJson:
|
|
222
|
+
packageJson: T,
|
|
220
223
|
distTag: a
|
|
221
224
|
}), { version: h } = p;
|
|
222
225
|
l(`npm version ${h}`, {
|
|
223
226
|
cwd: s,
|
|
224
227
|
stdio: "inherit"
|
|
225
228
|
});
|
|
226
|
-
const { tag:
|
|
229
|
+
const { tag: C } = p;
|
|
227
230
|
try {
|
|
228
231
|
switch (t) {
|
|
229
232
|
case c.WEB: {
|
|
230
|
-
const { build:
|
|
231
|
-
if (
|
|
232
|
-
l(`${
|
|
233
|
+
const { build: u } = n;
|
|
234
|
+
if (u)
|
|
235
|
+
l(`${u}`, {
|
|
233
236
|
stdio: "inherit",
|
|
234
237
|
cwd: s
|
|
235
238
|
});
|
|
@@ -238,7 +241,7 @@ const P = {
|
|
|
238
241
|
break;
|
|
239
242
|
}
|
|
240
243
|
case c.NPM: {
|
|
241
|
-
l(`npm publish --tag ${
|
|
244
|
+
l(`npm publish --tag ${C}`, {
|
|
242
245
|
cwd: s,
|
|
243
246
|
stdio: "inherit"
|
|
244
247
|
});
|
|
@@ -247,70 +250,70 @@ const P = {
|
|
|
247
250
|
default:
|
|
248
251
|
throw new Error(`未知发布模式:${t}`);
|
|
249
252
|
}
|
|
250
|
-
} catch (
|
|
251
|
-
|
|
253
|
+
} catch (u) {
|
|
254
|
+
m.error(`发布失败, error: ${u.message}`);
|
|
252
255
|
try {
|
|
253
|
-
|
|
254
|
-
const { lastHash:
|
|
255
|
-
l(`git reset --hard ${
|
|
256
|
+
m.info(`回滚本地版本到发布前的版本:${A.lastHash}`);
|
|
257
|
+
const { lastHash: g } = A;
|
|
258
|
+
l(`git reset --hard ${g}`, {
|
|
256
259
|
stdio: "inherit"
|
|
257
|
-
}),
|
|
260
|
+
}), m.info(`删除本次发布时生成的tag:v${p.version}`), l(`git tag -d v${p.version}`, {
|
|
258
261
|
stdio: "inherit"
|
|
259
262
|
});
|
|
260
|
-
} catch (
|
|
261
|
-
|
|
263
|
+
} catch (g) {
|
|
264
|
+
m.error(`回滚失败, error: ${g.message}`);
|
|
262
265
|
}
|
|
263
266
|
return process.exit(1);
|
|
264
267
|
}
|
|
265
|
-
|
|
268
|
+
d && X({
|
|
266
269
|
branchName: A.branchName,
|
|
267
270
|
version: p.version,
|
|
268
271
|
remoteInfo: A.remoteInfo
|
|
269
|
-
}),
|
|
270
|
-
},
|
|
272
|
+
}), m.success(`发布成功,版本号:${h}`), t === c.NPM && J(i) && M(e);
|
|
273
|
+
}, ae = {
|
|
271
274
|
command: "$0",
|
|
272
275
|
describe: "执行发布命令",
|
|
273
|
-
options:
|
|
274
|
-
handler:
|
|
275
|
-
},
|
|
276
|
+
options: re(),
|
|
277
|
+
handler: x
|
|
278
|
+
}, ge = async (e, t) => {
|
|
276
279
|
switch (e) {
|
|
277
|
-
case
|
|
280
|
+
case I.INIT:
|
|
278
281
|
return k(t);
|
|
279
|
-
case
|
|
280
|
-
return
|
|
281
|
-
case
|
|
282
|
-
return
|
|
282
|
+
case I.EXEC:
|
|
283
|
+
return x(t);
|
|
284
|
+
case I.ALIAS:
|
|
285
|
+
return M(t);
|
|
283
286
|
default:
|
|
284
287
|
throw new Error(`不支持的命令 ${e}`);
|
|
285
288
|
}
|
|
286
|
-
}, { version:
|
|
289
|
+
}, { version: ce, description: de } = R, D = {
|
|
287
290
|
describe: de,
|
|
288
|
-
version:
|
|
291
|
+
version: ce,
|
|
289
292
|
subcommands: [
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
].map(
|
|
293
|
+
ne,
|
|
294
|
+
ae,
|
|
295
|
+
se
|
|
296
|
+
].map(y),
|
|
294
297
|
demandCommandCount: 1,
|
|
295
|
-
rootScriptName:
|
|
298
|
+
rootScriptName: V({ packageJson: R })
|
|
296
299
|
}, {
|
|
297
|
-
cliConfig: { moduleName:
|
|
298
|
-
} =
|
|
299
|
-
const t = e ?
|
|
300
|
+
cliConfig: { moduleName: b }
|
|
301
|
+
} = R, _ = (e = !1) => {
|
|
302
|
+
const t = e ? b : void 0, o = `$0${e ? ` ${b}` : ""} [options]`;
|
|
300
303
|
return { command: t, usage: o };
|
|
301
|
-
},
|
|
302
|
-
...
|
|
303
|
-
...
|
|
304
|
-
}),
|
|
305
|
-
...
|
|
306
|
-
...
|
|
304
|
+
}, Ie = async () => q({
|
|
305
|
+
...D,
|
|
306
|
+
..._()
|
|
307
|
+
}), Ae = () => y({
|
|
308
|
+
...D,
|
|
309
|
+
..._(!0)
|
|
307
310
|
});
|
|
308
311
|
export {
|
|
309
312
|
r as P,
|
|
310
|
-
|
|
311
|
-
|
|
313
|
+
I as S,
|
|
314
|
+
Ae as a,
|
|
312
315
|
f as b,
|
|
313
|
-
|
|
316
|
+
Ie as c,
|
|
314
317
|
c as d,
|
|
315
|
-
|
|
318
|
+
ge as h
|
|
316
319
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as
|
|
2
|
+
import { d as u, b as e, P as b, S as p, a as t, h as d } from "./index-f33712b6.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
|
-
import "node:os";
|
|
5
4
|
import "node:child_process";
|
|
6
5
|
import "semver";
|
|
7
|
-
import "uuid";
|
|
8
6
|
import "node:path";
|
|
9
7
|
import "node:fs";
|
|
10
8
|
export {
|
|
11
|
-
|
|
9
|
+
u as PublishModeEnum,
|
|
12
10
|
e as PublishTagEnum,
|
|
13
11
|
b as PublishVersionTypeEnum,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
p as SubcommandEnum,
|
|
13
|
+
t as crateAsSubcommand,
|
|
14
|
+
d as handler
|
|
17
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-publish",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"description": "项目发布命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -41,10 +41,9 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "0.5.
|
|
44
|
+
"@done-coding/cli-inject": "0.5.20",
|
|
45
45
|
"@types/node": "^18.0.0",
|
|
46
46
|
"@types/semver": "^7.5.3",
|
|
47
|
-
"@types/uuid": "^10.0.0",
|
|
48
47
|
"@types/yargs": "^17.0.28",
|
|
49
48
|
"rimraf": "^6.0.1",
|
|
50
49
|
"typescript": "^5.2.2",
|
|
@@ -55,9 +54,8 @@
|
|
|
55
54
|
"node": ">=18.0.0"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"@done-coding/cli-utils": "0.
|
|
59
|
-
"semver": "^7.5.4"
|
|
60
|
-
"uuid": "^11.1.0"
|
|
57
|
+
"@done-coding/cli-utils": "0.8.1",
|
|
58
|
+
"semver": "^7.5.4"
|
|
61
59
|
},
|
|
62
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6"
|
|
63
61
|
}
|