dc-publish 0.7.3 → 0.7.4-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-5cfffda1.js";
2
+ import { c as m } from "./index-b491ec2d.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:os";
5
5
  import "node:child_process";
@@ -1,23 +1,26 @@
1
1
  #!/usr/bin/env node
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
- import { tmpdir as q } from "node:os";
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
4
  import { execSync as f } from "node:child_process";
5
- import { inc as A, prerelease as z } from "semver";
6
- import { v4 as K } from "uuid";
5
+ import { inc as g, prerelease as K } from "semver";
6
+ import { v4 as Q } from "uuid";
7
7
  import w from "node:path";
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 || {}), 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
- const $ = {
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
11
  name: "@done-coding/cli-publish",
12
- version: "0.7.3",
12
+ version: "0.7.4-alpha.0",
13
13
  description: "项目发布命令行工具",
14
+ bin: {
15
+ "dc-publish": "es/cli.mjs"
16
+ },
14
17
  cliConfig: {
15
18
  namespaceDir: ".done-coding",
16
19
  moduleName: "publish"
17
20
  }
18
- }, Y = `${q()}/.DONE_CODING_CLI/PUBLISH_ALIAS_TEMP_DIR`, {
19
- cliConfig: { namespaceDir: Z, moduleName: V }
20
- } = $, ee = `./${Z}/${V}`, N = `${ee}.json`, te = {
21
+ }, Z = `${z()}/.DONE_CODING_CLI/PUBLISH_ALIAS_TEMP_DIR`, {
22
+ cliConfig: { namespaceDir: V, moduleName: ee }
23
+ } = P, te = `./${V}/${ee}`, $ = `${te}.json`, ne = {
21
24
  [l.WEB]: {},
22
25
  [l.NPM]: {
23
26
  aliasInfo: [
@@ -30,19 +33,19 @@ const $ = {
30
33
  }
31
34
  ]
32
35
  }
33
- }, ne = () => v({
34
- configPathDefault: N
35
- }), D = async (e) => U(te, e, {
36
+ }, oe = () => N({
37
+ configPathDefault: $
38
+ }), D = async (e) => F(ne, e, {
36
39
  onFileGenerated: () => {
37
- d.info("文件生成成功");
40
+ m.info("文件生成成功");
38
41
  }
39
- }), oe = {
42
+ }), se = {
40
43
  command: E.INIT,
41
44
  describe: "初始化配置文件",
42
- options: ne(),
45
+ options: oe(),
43
46
  handler: D
44
- }, se = () => v({
45
- configPathDefault: N
47
+ }, re = () => N({
48
+ configPathDefault: $
46
49
  }), _ = (e) => {
47
50
  var a;
48
51
  const n = ((a = e[l.NPM]) == null ? void 0 : a.aliasInfo) || [];
@@ -50,47 +53,47 @@ const $ = {
50
53
  return n;
51
54
  }, L = async (e) => {
52
55
  var O;
53
- const n = await J(e, () => ({})), a = _(n);
56
+ const n = await b(e, () => ({})), a = _(n);
54
57
  if (!a) {
55
- d.warn("没有配置别名发布信息");
58
+ m.warn("没有配置别名发布信息");
56
59
  return;
57
60
  }
58
- const { rootDir: o } = e, i = C({ rootDir: o }), { name: s, version: r } = i, c = w.resolve(Y, K());
61
+ const { rootDir: o } = e, i = v({ rootDir: o }), { name: s, version: r } = i, c = w.resolve(Z, Q());
59
62
  T.mkdirSync(c, { recursive: !0 }), f(`pnpm add ${s}@${r}`, {
60
63
  stdio: "inherit",
61
64
  cwd: c
62
65
  });
63
66
  const R = (O = f(`npm dist-tag ${s}`).toString().trim().split(`
64
- `).map((I) => I.split(":").map((h) => h.trim())).find(
67
+ `).map((I) => I.split(":").map((C) => C.trim())).find(
65
68
  ([, I]) => I === r
66
69
  )) == null ? void 0 : O[0];
67
70
  if (!R)
68
- return d.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
69
- const m = w.resolve(c, "node_modules", s), u = C({
70
- rootDir: m
71
+ return m.warn(`没有找到 ${s}@${r} 对应的dist-tag`);
72
+ const d = w.resolve(c, "node_modules", s), u = v({
73
+ rootDir: d
71
74
  });
72
75
  for (let I of a) {
73
- const { packageJson: h } = I, B = {
76
+ const { packageJson: C } = I, B = {
74
77
  ...u,
75
- ...h
76
- }, F = `${m}/package.json`;
78
+ ...C
79
+ }, j = `${d}/package.json`;
77
80
  T.writeFileSync(
78
- F,
81
+ j,
79
82
  JSON.stringify(B, null, 2)
80
83
  ), f(`pnpm publish --tag ${R}`, {
81
84
  stdio: "inherit",
82
- cwd: m
85
+ cwd: d
83
86
  });
84
87
  }
85
- Q(c, { recursive: !0, force: !0 });
86
- }, re = {
88
+ Y(c, { recursive: !0, force: !0 });
89
+ }, ie = {
87
90
  command: E.ALIAS,
88
91
  describe: "别名发布",
89
- options: se(),
92
+ options: re(),
90
93
  handler: L
91
- }, ie = () => ({
92
- ...v({
93
- configPathDefault: N
94
+ }, ae = () => ({
95
+ ...N({
96
+ configPathDefault: $
94
97
  }),
95
98
  mode: {
96
99
  alias: "m",
@@ -130,19 +133,19 @@ const $ = {
130
133
  t.MINOR,
131
134
  t.PATCH
132
135
  ].includes(n))
133
- o = A(s, n), i = P.LATEST;
136
+ o = g(s, n), i = A.LATEST;
134
137
  else if ([
135
138
  t.PREMAJOR,
136
139
  t.PREMINOR,
137
140
  t.PREPATCH
138
141
  ].includes(n)) {
139
- const r = z(s);
140
- r ? (d.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = A(
142
+ const r = K(s);
143
+ r ? (m.warn("当前版本已经是预发布版本,将会在当前版本基础上进行发布"), r.length === 1 && typeof r[0] == "number" ? o = g(
141
144
  s,
142
145
  t.PRERELEASE
143
- ) : o = s.split("-")[0] + "-0") : o = A(s, n), i = P.NEXT;
146
+ ) : o = s.split("-")[0] + "-0") : o = g(s, n), i = A.NEXT;
144
147
  } else
145
- i = P.ALPHA, o = A(
148
+ i = A.ALPHA, o = g(
146
149
  s,
147
150
  t.PRERELEASE,
148
151
  i
@@ -154,7 +157,7 @@ const $ = {
154
157
  version: o,
155
158
  tag: i
156
159
  };
157
- }, ae = async ({
160
+ }, ce = async ({
158
161
  type: e,
159
162
  packageJson: n
160
163
  }) => {
@@ -209,12 +212,12 @@ const $ = {
209
212
  });
210
213
  return o[s];
211
214
  }
212
- }, y = async (e) => {
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({
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({
214
217
  type: a,
215
218
  packageJson: M
216
- }), { version: g } = p;
217
- f(`npm version ${g}`, {
219
+ }), { version: h } = p;
220
+ f(`npm version ${h}`, {
218
221
  cwd: i,
219
222
  stdio: "inherit"
220
223
  });
@@ -222,9 +225,9 @@ const $ = {
222
225
  try {
223
226
  switch (n) {
224
227
  case l.WEB: {
225
- const { build: m } = r;
226
- if (m)
227
- f(`${m}`, {
228
+ const { build: d } = r;
229
+ if (d)
230
+ f(`${d}`, {
228
231
  stdio: "inherit",
229
232
  cwd: i
230
233
  });
@@ -242,18 +245,18 @@ const $ = {
242
245
  default:
243
246
  throw new Error(`未知发布模式:${n}`);
244
247
  }
245
- } catch (m) {
246
- d.error(`发布失败, error: ${m.message}`);
248
+ } catch (d) {
249
+ m.error(`发布失败, error: ${d.message}`);
247
250
  try {
248
- d.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
251
+ m.info(`回滚本地版本到发布前的版本:${c.lastHash}`);
249
252
  const { lastHash: u } = c;
250
253
  f(`git reset --hard ${u}`, {
251
254
  stdio: "inherit"
252
- }), d.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
255
+ }), m.info(`删除本次发布时生成的tag:v${p.version}`), f(`git tag -d v${p.version}`, {
253
256
  stdio: "inherit"
254
257
  });
255
258
  } catch (u) {
256
- d.error(`回滚失败, error: ${u.message}`);
259
+ m.error(`回滚失败, error: ${u.message}`);
257
260
  }
258
261
  return process.exit(1);
259
262
  }
@@ -261,49 +264,50 @@ const $ = {
261
264
  branchName: c.branchName,
262
265
  version: p.version,
263
266
  remoteInfo: c.remoteInfo
264
- }), d.success(`发布成功,版本号:${g}`), n === l.NPM && _(s) && L(e);
265
- }, ce = {
267
+ }), m.success(`发布成功,版本号:${h}`), n === l.NPM && _(s) && L(e);
268
+ }, le = {
266
269
  command: "$0",
267
270
  describe: "执行发布命令",
268
- options: ie(),
269
- handler: y
271
+ options: ae(),
272
+ handler: k
270
273
  }, Ae = async (e, n) => {
271
274
  switch (e) {
272
275
  case E.INIT:
273
276
  return D(n);
274
277
  case E.EXEC:
275
- return y(n);
278
+ return k(n);
276
279
  case E.ALIAS:
277
280
  return L(n);
278
281
  default:
279
282
  throw new Error(`不支持的命令 ${e}`);
280
283
  }
281
- }, { version: le, description: de } = $, k = {
284
+ }, { version: me, description: de } = P, y = {
282
285
  describe: de,
283
- version: le,
286
+ version: me,
284
287
  subcommands: [
285
- oe,
286
- ce,
287
- re
288
- ].map(b),
289
- demandCommandCount: 1
288
+ se,
289
+ le,
290
+ ie
291
+ ].map(J),
292
+ demandCommandCount: 1,
293
+ rootScriptName: X({ packageJson: P })
290
294
  }, {
291
295
  cliConfig: { moduleName: H }
292
- } = $, x = (e = !1) => {
296
+ } = P, x = (e = !1) => {
293
297
  const n = e ? H : void 0, a = `$0${e ? ` ${H}` : ""} [options]`;
294
298
  return { command: n, usage: a };
295
- }, Pe = async () => X({
296
- ...k,
299
+ }, Pe = async () => q({
300
+ ...y,
297
301
  ...x()
298
- }), ge = () => b({
299
- ...k,
302
+ }), he = () => J({
303
+ ...y,
300
304
  ...x(!0)
301
305
  });
302
306
  export {
303
307
  t as P,
304
308
  E as S,
305
- ge as a,
306
- P as b,
309
+ he as a,
310
+ A as b,
307
311
  Pe as c,
308
312
  l as d,
309
313
  Ae as h
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-5cfffda1.js";
2
+ import { d as t, b as e, P as b, S as d, a as h, h as l } from "./index-b491ec2d.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.3",
3
+ "version": "0.7.4-alpha.0",
4
4
  "description": "项目发布命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -30,7 +30,7 @@
30
30
  "license": "MIT",
31
31
  "sideEffects": false,
32
32
  "devDependencies": {
33
- "@done-coding/cli-inject": "^0.5.11",
33
+ "@done-coding/cli-inject": "^0.5.12-alpha.0",
34
34
  "@types/node": "^18.0.0",
35
35
  "@types/semver": "^7.5.3",
36
36
  "@types/uuid": "^10.0.0",
@@ -44,10 +44,10 @@
44
44
  "node": ">=18.0.0"
45
45
  },
46
46
  "dependencies": {
47
- "@done-coding/cli-utils": "^0.7.2",
47
+ "@done-coding/cli-utils": "^0.7.3-alpha.0",
48
48
  "semver": "^7.5.4",
49
49
  "uuid": "^11.1.0"
50
50
  },
51
- "gitHead": "ad322da7f5d0897ee91a399aff9a14b111d62825",
51
+ "gitHead": "9d9a2e60f255038a0f065e3a4e6d6d35488408ae",
52
52
  "scripts": {}
53
53
  }