@done-coding/cli-publish 0.7.0-alpha.0 → 0.7.0-alpha.1
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 -2
- package/es/{index-03fd1d3d.js → index-076b18ee.js} +85 -85
- package/es/index.mjs +2 -2
- package/package.json +4 -4
- package/types/injectInfo.json.d.ts +1 -1
- package/types/utils/path.d.ts +2 -0
package/es/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as m } from "./index-
|
|
2
|
+
import { c as m } from "./index-076b18ee.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
|
+
import "node:os";
|
|
4
5
|
import "node:child_process";
|
|
5
6
|
import "semver";
|
|
6
7
|
import "uuid";
|
|
7
8
|
import "node:path";
|
|
8
9
|
import "node:fs";
|
|
9
|
-
import "node:os";
|
|
10
10
|
m();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getConfigFileCommonOptions as v, initHandlerCommon as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { getConfigFileCommonOptions as v, initHandlerCommon as U, log as m, readConfigFile as J, getPackageJson as C, getGitLastCommitInfo as j, pushGitPublishInfoToRemote as G, xPrompts as W, createSubcommand as D, createMainCommand as X } from "@done-coding/cli-utils";
|
|
3
|
+
import { tmpdir as q } from "node:os";
|
|
4
|
+
import { execSync as f } from "node:child_process";
|
|
5
|
+
import { inc as A, prerelease as z } from "semver";
|
|
5
6
|
import { v4 as K } from "uuid";
|
|
6
7
|
import w from "node:path";
|
|
7
8
|
import T, { rmSync as Q } from "node:fs";
|
|
8
|
-
|
|
9
|
-
var R = /* @__PURE__ */ ((e) => (e.INIT = "init", e.EXEC = "exec", e.ALIAS = "alias", e))(R || {}), 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 || {}), c = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(c || {});
|
|
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 || {}), g = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e))(g || {}), l = /* @__PURE__ */ ((e) => (e.NPM = "npm", e.WEB = "web", e))(l || {});
|
|
10
10
|
const $ = {
|
|
11
11
|
name: "@done-coding/cli-publish",
|
|
12
|
-
version: "0.7.0-alpha.
|
|
12
|
+
version: "0.7.0-alpha.1",
|
|
13
13
|
description: "项目发布命令行工具",
|
|
14
14
|
cliConfig: {
|
|
15
15
|
namespaceDir: ".done-coding",
|
|
16
16
|
moduleName: "publish"
|
|
17
17
|
}
|
|
18
|
-
}, {
|
|
18
|
+
}, Y = `${q()}/.DONE_CODING_CLI/PUBLISH_ALIAS_TEMP_DIR`, {
|
|
19
19
|
cliConfig: { namespaceDir: Z, moduleName: V }
|
|
20
20
|
} = $, ee = `./${Z}/${V}`, N = `${ee}.json`, te = {
|
|
21
|
-
[
|
|
22
|
-
[
|
|
21
|
+
[l.WEB]: {},
|
|
22
|
+
[l.NPM]: {
|
|
23
23
|
aliasInfo: [
|
|
24
24
|
{
|
|
25
25
|
packageJson: {
|
|
@@ -32,61 +32,61 @@ const $ = {
|
|
|
32
32
|
}
|
|
33
33
|
}, ne = () => v({
|
|
34
34
|
configPathDefault: N
|
|
35
|
-
}),
|
|
35
|
+
}), _ = async (e) => U(te, e, {
|
|
36
36
|
onFileGenerated: () => {
|
|
37
37
|
m.info("文件生成成功");
|
|
38
38
|
}
|
|
39
39
|
}), oe = {
|
|
40
|
-
command:
|
|
40
|
+
command: E.INIT,
|
|
41
41
|
describe: "初始化配置文件",
|
|
42
42
|
options: ne(),
|
|
43
|
-
handler:
|
|
43
|
+
handler: _
|
|
44
44
|
}, se = () => v({
|
|
45
45
|
configPathDefault: N
|
|
46
|
-
}),
|
|
46
|
+
}), b = (e) => {
|
|
47
47
|
var a;
|
|
48
|
-
const n = ((a = e[
|
|
48
|
+
const n = ((a = e[l.NPM]) == null ? void 0 : a.aliasInfo) || [];
|
|
49
49
|
if (n.length)
|
|
50
50
|
return n;
|
|
51
|
-
},
|
|
52
|
-
var
|
|
53
|
-
const n = await J(e, () => ({})), a =
|
|
51
|
+
}, L = async (e) => {
|
|
52
|
+
var O;
|
|
53
|
+
const n = await J(e, () => ({})), a = b(n);
|
|
54
54
|
if (!a) {
|
|
55
55
|
m.warn("没有配置别名发布信息");
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const { rootDir: o } = e, i = C({ rootDir: o }), { name: s, version: r } = i,
|
|
59
|
-
T.mkdirSync(
|
|
58
|
+
const { rootDir: o } = e, i = C({ rootDir: o }), { name: s, version: r } = i, c = w.resolve(Y, K());
|
|
59
|
+
T.mkdirSync(c, { recursive: !0 }), f(`pnpm add ${s}@${r}`, {
|
|
60
60
|
stdio: "inherit",
|
|
61
|
-
cwd:
|
|
61
|
+
cwd: c
|
|
62
62
|
});
|
|
63
|
-
const
|
|
63
|
+
const R = (O = f(`npm dist-tag ${s}`).toString().trim().split(`
|
|
64
64
|
`).map((I) => I.split(":").map((h) => h.trim())).find(
|
|
65
65
|
([, I]) => I === r
|
|
66
|
-
)) == null ? void 0 :
|
|
67
|
-
if (!
|
|
66
|
+
)) == null ? void 0 : O[0];
|
|
67
|
+
if (!R)
|
|
68
68
|
return m.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
|
|
69
|
-
const
|
|
70
|
-
rootDir:
|
|
69
|
+
const d = w.resolve(c, "node_modules", s), u = C({
|
|
70
|
+
rootDir: d
|
|
71
71
|
});
|
|
72
72
|
for (let I of a) {
|
|
73
|
-
const { packageJson: h } = I,
|
|
74
|
-
...
|
|
73
|
+
const { packageJson: h } = I, B = {
|
|
74
|
+
...u,
|
|
75
75
|
...h
|
|
76
|
-
},
|
|
76
|
+
}, F = `${d}/package.json`;
|
|
77
77
|
T.writeFileSync(
|
|
78
|
-
|
|
79
|
-
JSON.stringify(
|
|
80
|
-
),
|
|
78
|
+
F,
|
|
79
|
+
JSON.stringify(B, null, 2)
|
|
80
|
+
), f(`pnpm publish --tag ${R}`, {
|
|
81
81
|
stdio: "inherit",
|
|
82
|
-
cwd:
|
|
83
|
-
}), Q(
|
|
82
|
+
cwd: d
|
|
83
|
+
}), Q(c, { recursive: !0, force: !0 });
|
|
84
84
|
}
|
|
85
85
|
}, re = {
|
|
86
|
-
command:
|
|
86
|
+
command: E.ALIAS,
|
|
87
87
|
describe: "别名发布",
|
|
88
88
|
options: se(),
|
|
89
|
-
handler:
|
|
89
|
+
handler: L
|
|
90
90
|
}, ie = () => ({
|
|
91
91
|
...v({
|
|
92
92
|
configPathDefault: N
|
|
@@ -94,8 +94,8 @@ const $ = {
|
|
|
94
94
|
mode: {
|
|
95
95
|
alias: "m",
|
|
96
96
|
describe: "发布模式",
|
|
97
|
-
choices: [
|
|
98
|
-
default:
|
|
97
|
+
choices: [l.NPM, l.WEB],
|
|
98
|
+
default: l.NPM
|
|
99
99
|
},
|
|
100
100
|
type: {
|
|
101
101
|
alias: "t",
|
|
@@ -129,19 +129,19 @@ const $ = {
|
|
|
129
129
|
t.MINOR,
|
|
130
130
|
t.PATCH
|
|
131
131
|
].includes(n))
|
|
132
|
-
o =
|
|
132
|
+
o = A(s, n), i = g.LATEST;
|
|
133
133
|
else if ([
|
|
134
134
|
t.PREMAJOR,
|
|
135
135
|
t.PREMINOR,
|
|
136
136
|
t.PREPATCH
|
|
137
137
|
].includes(n)) {
|
|
138
138
|
const r = z(s);
|
|
139
|
-
r ? (m.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o =
|
|
139
|
+
r ? (m.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = A(
|
|
140
140
|
s,
|
|
141
141
|
t.PRERELEASE
|
|
142
|
-
) : o = s.split("-")[0] + "-0") : o =
|
|
142
|
+
) : o = s.split("-")[0] + "-0") : o = A(s, n), i = g.NEXT;
|
|
143
143
|
} else
|
|
144
|
-
i =
|
|
144
|
+
i = g.ALPHA, o = A(
|
|
145
145
|
s,
|
|
146
146
|
t.PRERELEASE,
|
|
147
147
|
i
|
|
@@ -166,9 +166,9 @@ const $ = {
|
|
|
166
166
|
const o = Object.values(t).filter(
|
|
167
167
|
(r) => r.toUpperCase() !== r
|
|
168
168
|
).reduce(
|
|
169
|
-
(r,
|
|
169
|
+
(r, c) => (r[c] = H({
|
|
170
170
|
packageJson: n,
|
|
171
|
-
type:
|
|
171
|
+
type: c
|
|
172
172
|
}), r),
|
|
173
173
|
{}
|
|
174
174
|
), i = [
|
|
@@ -200,7 +200,7 @@ const $ = {
|
|
|
200
200
|
title: `alpha版本(${o[t.PRERELEASE].version})`,
|
|
201
201
|
value: t.PRERELEASE
|
|
202
202
|
}
|
|
203
|
-
], { type: s } = await
|
|
203
|
+
], { type: s } = await W({
|
|
204
204
|
type: "select",
|
|
205
205
|
name: "type",
|
|
206
206
|
message: `请选择发布类型,当前版本:${n.version}`,
|
|
@@ -208,22 +208,22 @@ const $ = {
|
|
|
208
208
|
});
|
|
209
209
|
return o[s];
|
|
210
210
|
}
|
|
211
|
-
},
|
|
212
|
-
const { mode: n, type: a, push: o, rootDir: i } = e, s = await J(e, () => ({})), r = s[n],
|
|
211
|
+
}, y = async (e) => {
|
|
212
|
+
const { mode: n, type: a, push: o, rootDir: i } = e, s = await J(e, () => ({})), r = s[n], c = await j(r), M = C({ rootDir: i }), p = await ae({
|
|
213
213
|
type: a,
|
|
214
|
-
packageJson:
|
|
215
|
-
}), { version: P } =
|
|
216
|
-
|
|
214
|
+
packageJson: M
|
|
215
|
+
}), { version: P } = p;
|
|
216
|
+
f(`npm version ${P}`, {
|
|
217
217
|
cwd: i,
|
|
218
218
|
stdio: "inherit"
|
|
219
219
|
});
|
|
220
|
-
const { tag:
|
|
220
|
+
const { tag: R } = p;
|
|
221
221
|
try {
|
|
222
222
|
switch (n) {
|
|
223
|
-
case
|
|
224
|
-
const { build:
|
|
225
|
-
if (
|
|
226
|
-
|
|
223
|
+
case l.WEB: {
|
|
224
|
+
const { build: d } = r;
|
|
225
|
+
if (d)
|
|
226
|
+
f(`${d}`, {
|
|
227
227
|
stdio: "inherit",
|
|
228
228
|
cwd: i
|
|
229
229
|
});
|
|
@@ -231,8 +231,8 @@ const $ = {
|
|
|
231
231
|
throw new Error("未配置build命令");
|
|
232
232
|
break;
|
|
233
233
|
}
|
|
234
|
-
case
|
|
235
|
-
|
|
234
|
+
case l.NPM: {
|
|
235
|
+
f(`npm publish --tag ${R}`, {
|
|
236
236
|
cwd: i,
|
|
237
237
|
stdio: "inherit"
|
|
238
238
|
});
|
|
@@ -241,65 +241,65 @@ const $ = {
|
|
|
241
241
|
default:
|
|
242
242
|
throw new Error(`未知发布模式:${n}`);
|
|
243
243
|
}
|
|
244
|
-
} catch (
|
|
245
|
-
m.error(`发布失败, error: ${
|
|
244
|
+
} catch (d) {
|
|
245
|
+
m.error(`发布失败, error: ${d.message}`);
|
|
246
246
|
try {
|
|
247
|
-
m.info(`回滚本地版本到发布前的版本:${
|
|
248
|
-
const { lastHash:
|
|
249
|
-
|
|
247
|
+
m.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
|
|
248
|
+
const { lastHash: u } = c;
|
|
249
|
+
f(`git reset --hard ${u}`, {
|
|
250
250
|
stdio: "inherit"
|
|
251
|
-
}), m.info(`删除本次发布时生成的tag:v${
|
|
251
|
+
}), m.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
|
|
252
252
|
stdio: "inherit"
|
|
253
253
|
});
|
|
254
|
-
} catch (
|
|
255
|
-
m.error(`回滚失败, error: ${
|
|
254
|
+
} catch (u) {
|
|
255
|
+
m.error(`回滚失败, error: ${u.message}`);
|
|
256
256
|
}
|
|
257
257
|
return process.exit(1);
|
|
258
258
|
}
|
|
259
|
-
o &&
|
|
260
|
-
branchName:
|
|
261
|
-
version:
|
|
262
|
-
remoteInfo:
|
|
263
|
-
}), m.success(`发布成功,版本号:${P}`), n ===
|
|
259
|
+
o && G({
|
|
260
|
+
branchName: c.branchName,
|
|
261
|
+
version: p.version,
|
|
262
|
+
remoteInfo: c.remoteInfo
|
|
263
|
+
}), m.success(`发布成功,版本号:${P}`), n === l.NPM && b(s) && L(e);
|
|
264
264
|
}, ce = {
|
|
265
265
|
command: "$0",
|
|
266
266
|
describe: "执行发布命令",
|
|
267
267
|
options: ie(),
|
|
268
|
-
handler:
|
|
269
|
-
},
|
|
268
|
+
handler: y
|
|
269
|
+
}, Ae = async (e, n) => {
|
|
270
270
|
switch (e) {
|
|
271
|
-
case
|
|
272
|
-
return
|
|
273
|
-
case
|
|
274
|
-
return
|
|
275
|
-
case
|
|
276
|
-
return
|
|
271
|
+
case E.INIT:
|
|
272
|
+
return _(n);
|
|
273
|
+
case E.EXEC:
|
|
274
|
+
return y(n);
|
|
275
|
+
case E.ALIAS:
|
|
276
|
+
return L(n);
|
|
277
277
|
default:
|
|
278
278
|
throw new Error(`不支持的命令 ${e}`);
|
|
279
279
|
}
|
|
280
|
-
}, { version: le, description: me } = $,
|
|
280
|
+
}, { version: le, description: me } = $, k = {
|
|
281
281
|
describe: me,
|
|
282
282
|
version: le,
|
|
283
283
|
subcommands: [
|
|
284
284
|
oe,
|
|
285
285
|
ce,
|
|
286
286
|
re
|
|
287
|
-
].map(
|
|
287
|
+
].map(D),
|
|
288
288
|
demandCommandCount: 1
|
|
289
289
|
}, {
|
|
290
290
|
cliConfig: { moduleName: S }
|
|
291
291
|
} = $, x = (e = !1) => {
|
|
292
292
|
const n = e ? S : void 0, a = `$0${e ? ` ${S}` : ""} [options]`;
|
|
293
293
|
return { command: n, usage: a };
|
|
294
|
-
},
|
|
295
|
-
...
|
|
294
|
+
}, ge = async () => X({
|
|
295
|
+
...k,
|
|
296
296
|
...x()
|
|
297
|
-
}), Pe = () =>
|
|
298
|
-
...
|
|
297
|
+
}), Pe = () => D({
|
|
298
|
+
...k,
|
|
299
299
|
...x(!0)
|
|
300
300
|
});
|
|
301
301
|
export {
|
|
302
302
|
Pe as a,
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
ge as c,
|
|
304
|
+
Ae as h
|
|
305
305
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as s, h as d } from "./index-
|
|
2
|
+
import { a as s, h as d } from "./index-076b18ee.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
|
+
import "node:os";
|
|
4
5
|
import "node:child_process";
|
|
5
6
|
import "semver";
|
|
6
7
|
import "uuid";
|
|
7
8
|
import "node:path";
|
|
8
9
|
import "node:fs";
|
|
9
|
-
import "node:os";
|
|
10
10
|
export {
|
|
11
11
|
s as crateAsSubcommand,
|
|
12
12
|
d as handler
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-publish",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.1",
|
|
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.8-alpha.
|
|
43
|
+
"@done-coding/cli-inject": "^0.5.8-alpha.1",
|
|
44
44
|
"@types/node": "^18.0.0",
|
|
45
45
|
"@types/semver": "^7.5.3",
|
|
46
46
|
"@types/uuid": "^10.0.0",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"node": ">=18.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@done-coding/cli-utils": "^0.
|
|
57
|
+
"@done-coding/cli-utils": "^0.7.0-alpha.0",
|
|
58
58
|
"semver": "^7.5.4",
|
|
59
59
|
"uuid": "^11.1.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "ff1616738586a268b50f46dce762774fa5fa6d52"
|
|
62
62
|
}
|