@done-coding/cli-publish 0.7.0-alpha.2 → 0.7.1-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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-73a13ac6.js";
2
+ import { c as m } from "./index-93ce7060.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:os";
5
5
  import "node:child_process";
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
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";
2
+ import { getConfigFileCommonOptions as v, initHandlerCommon as U, log as d, readConfigFile as J, getPackageJson as C, getGitLastCommitInfo as j, pushGitPublishInfoToRemote as G, xPrompts as W, createSubcommand as b, createMainCommand as X } from "@done-coding/cli-utils";
3
3
  import { tmpdir as q } from "node:os";
4
4
  import { execSync as f } from "node:child_process";
5
5
  import { inc as A, prerelease as z } from "semver";
6
6
  import { v4 as K } from "uuid";
7
7
  import w from "node:path";
8
8
  import T, { rmSync as Q } 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 || {}), 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 || {});
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 || {}), P = /* @__PURE__ */ ((e) => (e.LATEST = "latest", e.NEXT = "next", e.ALPHA = "alpha", e))(P || {}), 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.2",
12
+ version: "0.7.1-alpha.0",
13
13
  description: "项目发布命令行工具",
14
14
  cliConfig: {
15
15
  namespaceDir: ".done-coding",
@@ -32,27 +32,27 @@ const $ = {
32
32
  }
33
33
  }, ne = () => v({
34
34
  configPathDefault: N
35
- }), _ = async (e) => U(te, e, {
35
+ }), D = async (e) => U(te, e, {
36
36
  onFileGenerated: () => {
37
- m.info("文件生成成功");
37
+ d.info("文件生成成功");
38
38
  }
39
39
  }), oe = {
40
40
  command: E.INIT,
41
41
  describe: "初始化配置文件",
42
42
  options: ne(),
43
- handler: _
43
+ handler: D
44
44
  }, se = () => v({
45
45
  configPathDefault: N
46
- }), b = (e) => {
46
+ }), _ = (e) => {
47
47
  var a;
48
48
  const n = ((a = e[l.NPM]) == null ? void 0 : a.aliasInfo) || [];
49
49
  if (n.length)
50
50
  return n;
51
51
  }, L = async (e) => {
52
52
  var O;
53
- const n = await J(e, () => ({})), a = b(n);
53
+ const n = await J(e, () => ({})), a = _(n);
54
54
  if (!a) {
55
- m.warn("没有配置别名发布信息");
55
+ d.warn("没有配置别名发布信息");
56
56
  return;
57
57
  }
58
58
  const { rootDir: o } = e, i = C({ rootDir: o }), { name: s, version: r } = i, c = w.resolve(Y, K());
@@ -65,21 +65,21 @@ const $ = {
65
65
  ([, I]) => I === r
66
66
  )) == null ? void 0 : O[0];
67
67
  if (!R)
68
- return m.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
69
- const d = w.resolve(c, "node_modules", s), u = C({
70
- rootDir: d
68
+ return d.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
69
+ const m = w.resolve(c, "node_modules", s), u = C({
70
+ rootDir: m
71
71
  });
72
72
  for (let I of a) {
73
73
  const { packageJson: h } = I, B = {
74
74
  ...u,
75
75
  ...h
76
- }, F = `${d}/package.json`;
76
+ }, F = `${m}/package.json`;
77
77
  T.writeFileSync(
78
78
  F,
79
79
  JSON.stringify(B, null, 2)
80
80
  ), f(`pnpm publish --tag ${R}`, {
81
81
  stdio: "inherit",
82
- cwd: d
82
+ cwd: m
83
83
  });
84
84
  }
85
85
  Q(c, { recursive: !0, force: !0 });
@@ -117,7 +117,7 @@ const $ = {
117
117
  type: "boolean",
118
118
  default: !0
119
119
  }
120
- }), H = ({
120
+ }), S = ({
121
121
  packageJson: e,
122
122
  type: n
123
123
  }) => {
@@ -130,19 +130,19 @@ const $ = {
130
130
  t.MINOR,
131
131
  t.PATCH
132
132
  ].includes(n))
133
- o = A(s, n), i = g.LATEST;
133
+ o = A(s, n), i = P.LATEST;
134
134
  else if ([
135
135
  t.PREMAJOR,
136
136
  t.PREMINOR,
137
137
  t.PREPATCH
138
138
  ].includes(n)) {
139
139
  const r = z(s);
140
- r ? (m.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = A(
140
+ r ? (d.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = A(
141
141
  s,
142
142
  t.PRERELEASE
143
- ) : o = s.split("-")[0] + "-0") : o = A(s, n), i = g.NEXT;
143
+ ) : o = s.split("-")[0] + "-0") : o = A(s, n), i = P.NEXT;
144
144
  } else
145
- i = g.ALPHA, o = A(
145
+ i = P.ALPHA, o = A(
146
146
  s,
147
147
  t.PRERELEASE,
148
148
  i
@@ -159,7 +159,7 @@ const $ = {
159
159
  packageJson: n
160
160
  }) => {
161
161
  if (e)
162
- return await H({
162
+ return await S({
163
163
  packageJson: n,
164
164
  type: e
165
165
  });
@@ -167,7 +167,7 @@ const $ = {
167
167
  const o = Object.values(t).filter(
168
168
  (r) => r.toUpperCase() !== r
169
169
  ).reduce(
170
- (r, c) => (r[c] = H({
170
+ (r, c) => (r[c] = S({
171
171
  packageJson: n,
172
172
  type: c
173
173
  }), r),
@@ -213,8 +213,8 @@ const $ = {
213
213
  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({
214
214
  type: a,
215
215
  packageJson: M
216
- }), { version: P } = p;
217
- f(`npm version ${P}`, {
216
+ }), { version: g } = p;
217
+ f(`npm version ${g}`, {
218
218
  cwd: i,
219
219
  stdio: "inherit"
220
220
  });
@@ -222,9 +222,9 @@ const $ = {
222
222
  try {
223
223
  switch (n) {
224
224
  case l.WEB: {
225
- const { build: d } = r;
226
- if (d)
227
- f(`${d}`, {
225
+ const { build: m } = r;
226
+ if (m)
227
+ f(`${m}`, {
228
228
  stdio: "inherit",
229
229
  cwd: i
230
230
  });
@@ -242,18 +242,18 @@ const $ = {
242
242
  default:
243
243
  throw new Error(`未知发布模式:${n}`);
244
244
  }
245
- } catch (d) {
246
- m.error(`发布失败, error: ${d.message}`);
245
+ } catch (m) {
246
+ d.error(`发布失败, error: ${m.message}`);
247
247
  try {
248
- m.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
248
+ d.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
249
249
  const { lastHash: u } = c;
250
250
  f(`git reset --hard ${u}`, {
251
251
  stdio: "inherit"
252
- }), m.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
252
+ }), d.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
253
253
  stdio: "inherit"
254
254
  });
255
255
  } catch (u) {
256
- m.error(`回滚失败, error: ${u.message}`);
256
+ d.error(`回滚失败, error: ${u.message}`);
257
257
  }
258
258
  return process.exit(1);
259
259
  }
@@ -261,7 +261,7 @@ const $ = {
261
261
  branchName: c.branchName,
262
262
  version: p.version,
263
263
  remoteInfo: c.remoteInfo
264
- }), m.success(`发布成功,版本号:${P}`), n === l.NPM && b(s) && L(e);
264
+ }), d.success(`发布成功,版本号:${g}`), n === l.NPM && _(s) && L(e);
265
265
  }, ce = {
266
266
  command: "$0",
267
267
  describe: "执行发布命令",
@@ -270,7 +270,7 @@ const $ = {
270
270
  }, Ae = async (e, n) => {
271
271
  switch (e) {
272
272
  case E.INIT:
273
- return _(n);
273
+ return D(n);
274
274
  case E.EXEC:
275
275
  return y(n);
276
276
  case E.ALIAS:
@@ -278,29 +278,33 @@ const $ = {
278
278
  default:
279
279
  throw new Error(`不支持的命令 ${e}`);
280
280
  }
281
- }, { version: le, description: me } = $, k = {
282
- describe: me,
281
+ }, { version: le, description: de } = $, k = {
282
+ describe: de,
283
283
  version: le,
284
284
  subcommands: [
285
285
  oe,
286
286
  ce,
287
287
  re
288
- ].map(D),
288
+ ].map(b),
289
289
  demandCommandCount: 1
290
290
  }, {
291
- cliConfig: { moduleName: S }
291
+ cliConfig: { moduleName: H }
292
292
  } = $, x = (e = !1) => {
293
- const n = e ? S : void 0, a = `$0${e ? ` ${S}` : ""} [options]`;
293
+ const n = e ? H : void 0, a = `$0${e ? ` ${H}` : ""} [options]`;
294
294
  return { command: n, usage: a };
295
- }, ge = async () => X({
295
+ }, Pe = async () => X({
296
296
  ...k,
297
297
  ...x()
298
- }), Pe = () => D({
298
+ }), ge = () => b({
299
299
  ...k,
300
300
  ...x(!0)
301
301
  });
302
302
  export {
303
- Pe as a,
304
- ge as c,
303
+ t as P,
304
+ E as S,
305
+ ge as a,
306
+ P as b,
307
+ Pe as c,
308
+ l as d,
305
309
  Ae as h
306
310
  };
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as s, h as d } from "./index-73a13ac6.js";
2
+ import { d as t, b as e, P as b, S as d, a as h, h as l } from "./index-93ce7060.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:os";
5
5
  import "node:child_process";
@@ -8,6 +8,10 @@ import "uuid";
8
8
  import "node:path";
9
9
  import "node:fs";
10
10
  export {
11
- s as crateAsSubcommand,
12
- d as handler
11
+ t as PublishModeEnum,
12
+ e as PublishTagEnum,
13
+ b as PublishVersionTypeEnum,
14
+ d as SubcommandEnum,
15
+ h as crateAsSubcommand,
16
+ l as handler
13
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.7.0-alpha.2",
3
+ "version": "0.7.1-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.8-alpha.1",
43
+ "@done-coding/cli-inject": "^0.5.9-alpha.0",
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.7.0-alpha.0",
57
+ "@done-coding/cli-utils": "^0.7.0",
58
58
  "semver": "^7.5.4",
59
59
  "uuid": "^11.1.0"
60
60
  },
61
- "gitHead": "2ab236d6a17411d64f4429eeacf39e40a10576e4"
61
+ "gitHead": "62a4c9df2bf8690e52753e0734ebb09010bb2e88"
62
62
  }
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { handler } from './handlers';
2
2
  export { crateAsSubcommand } from "./main";
3
+ export * from './types';
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.7.0-alpha.2",
3
+ "version": "0.7.1-alpha.0",
4
4
  "description": "项目发布命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",