@done-coding/cli-publish 0.4.3 → 0.4.5-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 r } from "./index-9e678a37.js";
2
+ import { c as r } from "./index-3eb0cae4.js";
3
3
  import "semver";
4
4
  import "node:path";
5
5
  import "node:child_process";
@@ -7,6 +7,7 @@ import "pinyin";
7
7
  import "node:fs";
8
8
  import "chalk";
9
9
  import "prompts";
10
+ import "@done-coding/cli-utils";
10
11
  import "yargs";
11
12
  import "yargs/helpers";
12
13
  r();
@@ -1,17 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { inc as A, prerelease as y } from "semver";
2
+ import { inc as A, prerelease as C } from "semver";
3
3
  import { join as v } from "node:path";
4
4
  import { execSync as n } from "node:child_process";
5
5
  import P from "pinyin";
6
- import { readFileSync as O, existsSync as I } from "node:fs";
6
+ import { readFileSync as h, existsSync as y } from "node:fs";
7
7
  import p from "chalk";
8
- import H from "prompts";
8
+ import I from "prompts";
9
+ import { onPromptFormStateForSigint as H } from "@done-coding/cli-utils";
9
10
  import w from "yargs";
10
11
  import { hideBin as J } from "yargs/helpers";
11
12
  var E = /* @__PURE__ */ ((t) => (t.NPM = "npm", t.WEB = "web", t))(E || {}), e = /* @__PURE__ */ ((t) => (t.MAJOR = "major", t.MINOR = "minor", t.PATCH = "patch", t.PREMAJOR = "premajor", t.PREMINOR = "preminor", t.PREPATCH = "prepatch", t.PRERELEASE = "prerelease", t))(e || {}), d = /* @__PURE__ */ ((t) => (t.LATEST = "latest", t.NEXT = "next", t.ALPHA = "alpha", t))(d || {});
12
- const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "origin" }) => {
13
+ const L = "/.dc/publish.json", N = "/package.json", T = ({ gitOriginName: t = "origin" }) => {
13
14
  try {
14
- const o = n("git rev-parse HEAD").toString().trim(), g = n('git log -1 --pretty=format:"%an"').toString().trim(), c = n('git log -1 --pretty=format:"%ae"').toString().trim(), i = n('git log -1 --pretty=format:"%s"').toString().trim(), s = n("git config user.name").toString().trim(), l = n("git config user.email").toString().trim(), m = n("git rev-parse --abbrev-ref HEAD").toString().trim();
15
+ const o = n("git rev-parse HEAD").toString().trim(), m = n('git log -1 --pretty=format:"%an"').toString().trim(), c = n('git log -1 --pretty=format:"%ae"').toString().trim(), i = n('git log -1 --pretty=format:"%s"').toString().trim(), s = n("git config user.name").toString().trim(), l = n("git config user.email").toString().trim(), g = n("git rev-parse --abbrev-ref HEAD").toString().trim();
15
16
  let f = "";
16
17
  try {
17
18
  f = n(`git config --get remote.${t}.url`).toString().trim();
@@ -20,8 +21,8 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
20
21
  }
21
22
  return {
22
23
  lastHash: o,
23
- lastCommitter: g,
24
- lastCommitterPinYin: P(g, {
24
+ lastCommitter: m,
25
+ lastCommitterPinYin: P(m, {
25
26
  style: P.STYLE_NORMAL,
26
27
  heteronym: !1
27
28
  }).join(""),
@@ -33,14 +34,14 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
33
34
  heteronym: !1
34
35
  }).join(""),
35
36
  userEmail: l,
36
- branchName: m,
37
+ branchName: g,
37
38
  remoteUrl: f
38
39
  };
39
40
  } catch (o) {
40
41
  throw console.error("Error fetching git information:", o), o;
41
42
  }
42
- }, R = (t, o = JSON.parse(O(v(process.cwd(), u), "utf-8"))) => {
43
- let g = o.name, c = "", i;
43
+ }, R = (t, o = JSON.parse(h(v(process.cwd(), N), "utf-8"))) => {
44
+ let m = o.name, c = "", i;
44
45
  const { version: s } = o;
45
46
  if ([
46
47
  e.MAJOR,
@@ -53,7 +54,7 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
53
54
  e.PREMINOR,
54
55
  e.PREPATCH
55
56
  ].includes(t)) {
56
- const l = y(s);
57
+ const l = C(s);
57
58
  l ? (console.log(
58
59
  p.yellow("当前版本已经是预发布版本,将会在当前版本基础上进行发布")
59
60
  ), l.length === 1 && typeof l[0] == "number" ? c = A(
@@ -69,16 +70,16 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
69
70
  if (!c)
70
71
  throw new Error("version is empty");
71
72
  return {
72
- name: g,
73
+ name: m,
73
74
  version: c,
74
75
  tag: i
75
76
  };
76
77
  }, b = () => {
77
78
  let t;
78
79
  const o = v(process.cwd(), L);
79
- if (I(o)) {
80
- const g = O(o, "utf-8");
81
- t = JSON.parse(g);
80
+ if (y(o)) {
81
+ const m = h(o, "utf-8");
82
+ t = JSON.parse(m);
82
83
  } else
83
84
  console.log(
84
85
  p.yellow(`未找到配置文件,将使用默认配置
@@ -89,15 +90,15 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
89
90
  gitOriginName: "origin",
90
91
  ...t || {}
91
92
  };
92
- }, N = async (t) => {
93
+ }, M = async (t) => {
93
94
  console.log(t);
94
- const { mode: o, type: g, push: c } = t, i = b(), s = T(i);
95
+ const { mode: o, type: m, push: c } = t, i = b(), s = T(i);
95
96
  console.log("gitInfo:", s);
96
- let l = g, m;
97
+ let l = m, g;
97
98
  if (l)
98
- console.log("type:", l), m = await R(l);
99
+ console.log("type:", l), g = await R(l);
99
100
  else {
100
- const r = JSON.parse(O(v(process.cwd(), u), "utf-8")), a = {
101
+ const r = JSON.parse(h(v(process.cwd(), N), "utf-8")), a = {
101
102
  [e.MAJOR]: R(
102
103
  e.MAJOR,
103
104
  r
@@ -156,19 +157,19 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
156
157
  value: e.PRERELEASE
157
158
  }
158
159
  ];
159
- l = (await H({
160
+ l = (await I({
160
161
  type: "select",
161
162
  name: "type",
162
163
  message: `请选择发布类型,当前版本:${r.version}`,
163
164
  choices: $,
164
- validate: (C) => C ? !0 : "请选择发布类型"
165
- })).type, m = a[l];
165
+ onState: H
166
+ })).type, g = a[l];
166
167
  }
167
- const { version: f } = m;
168
- console.log("npmInfo:", m), n(`npm version ${f} 1>&2`);
168
+ const { version: f } = g;
169
+ console.log("npmInfo:", g), n(`npm version ${f} 1>&2`);
169
170
  try {
170
171
  if (o === E.NPM) {
171
- const { tag: r } = m;
172
+ const { tag: r } = g;
172
173
  n(`npm publish --tag ${r} 1>&2`);
173
174
  } else if (o === E.WEB) {
174
175
  const { webBuild: r } = i;
@@ -182,15 +183,15 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
182
183
  p.blue(`回滚本地版本到发布前的版本:${s.lastHash}`)
183
184
  );
184
185
  const { lastHash: a } = s;
185
- n(`git reset --hard ${a} 1>&2`), console.log(p.blue(`删除本次发布时生成的tag:v${m.version}`)), n(`git tag -d v${m.version} 1>&2`);
186
+ n(`git reset --hard ${a} 1>&2`), console.log(p.blue(`删除本次发布时生成的tag:v${g.version}`)), n(`git tag -d v${g.version} 1>&2`);
186
187
  } catch (a) {
187
188
  console.log(p.red(`回滚失败, error: ${a.message}`));
188
189
  }
189
190
  return process.exit(1);
190
191
  }
191
- c && (n(`git push ${i.gitOriginName} v${m.version} 1>&2`), n(`git push ${i.gitOriginName} ${s.branchName} 1>&2`)), console.log(p.green("发布成功"));
192
- }, h = {
193
- version: "0.4.3",
192
+ c && (n(`git push ${i.gitOriginName} v${g.version} 1>&2`), n(`git push ${i.gitOriginName} ${s.branchName} 1>&2`)), console.log(p.green("发布成功"));
193
+ }, O = {
194
+ version: "0.4.5-alpha.0",
194
195
  name: "@done-coding/cli-publish",
195
196
  description: "项目发布命令行工具",
196
197
  cliConfig: {
@@ -223,23 +224,23 @@ const L = "/.dc/publish.json", u = "/package.json", T = ({ gitOriginName: t = "o
223
224
  type: "boolean",
224
225
  default: !0
225
226
  }
226
- }), M = h.cliConfig.moduleName, x = (t, o) => {
227
+ }), u = O.cliConfig.moduleName, x = (t, o) => {
227
228
  console.log(t ? p.red(t) : p.red(o.message)), process.exit(1);
228
- }, B = h.description, U = `Usage: $0 ${M} [options]`, D = "Usage: $0 [options]", S = (t, o) => {
229
- const g = j();
230
- return t.strict().usage(o).help("help").version(h.version).alias("v", "version").alias("h", "help").options(g).fail(x).argv;
231
- }, Y = (t) => S(t, U), Q = {
232
- command: M,
229
+ }, B = O.description, U = `Usage: $0 ${u} [options]`, D = "Usage: $0 [options]", S = (t, o) => {
230
+ const m = j();
231
+ return t.strict().usage(o).help("help").version(O.version).alias("v", "version").alias("h", "help").options(m).fail(x).argv;
232
+ }, Y = (t) => S(t, U), Z = {
233
+ command: u,
233
234
  describe: B,
234
235
  builder: Y,
235
- handler: N
236
- }, Z = async () => {
236
+ handler: M
237
+ }, V = async () => {
237
238
  const t = w(J(process.argv)), o = await S(t, D);
238
- return N(o);
239
+ return M(o);
239
240
  };
240
241
  export {
241
242
  E as P,
242
- Q as a,
243
- Z as c,
244
- N as h
243
+ Z as a,
244
+ V as c,
245
+ M as h
245
246
  };
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { P as h, a as u, h as b } from "./index-9e678a37.js";
2
+ import { P as u, a as b, h as l } from "./index-3eb0cae4.js";
3
3
  import "semver";
4
4
  import "node:path";
5
5
  import "node:child_process";
@@ -7,10 +7,11 @@ import "pinyin";
7
7
  import "node:fs";
8
8
  import "chalk";
9
9
  import "prompts";
10
+ import "@done-coding/cli-utils";
10
11
  import "yargs";
11
12
  import "yargs/helpers";
12
13
  export {
13
- h as PublishModeEnum,
14
- u as command,
15
- b as handler
14
+ u as PublishModeEnum,
15
+ b as command,
16
+ l as handler
16
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.4.3",
3
+ "version": "0.4.5-alpha.0",
4
4
  "description": "项目发布命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -41,7 +41,7 @@
41
41
  "license": "MIT",
42
42
  "sideEffects": false,
43
43
  "devDependencies": {
44
- "@done-coding/cli-inject": "^0.4.5",
44
+ "@done-coding/cli-inject": "^0.4.6-alpha.0",
45
45
  "@types/node": "^18.0.0",
46
46
  "@types/pinyin": "^2.10.0",
47
47
  "@types/prompts": "^2.4.6",
@@ -56,11 +56,12 @@
56
56
  "node": ">=18.0.0"
57
57
  },
58
58
  "dependencies": {
59
+ "@done-coding/cli-utils": "^0.2.1-alpha.0",
59
60
  "chalk": "^5.3.0",
60
61
  "pinyin": "^2.11.2",
61
62
  "prompts": "^2.4.2",
62
63
  "semver": "^7.5.4",
63
64
  "yargs": "^17.7.2"
64
65
  },
65
- "gitHead": "465ac238437ab8bd3803c5e6fe8ac5a30bc445f3"
66
+ "gitHead": "21eb698f64179882cfec979bd8f19920b047dacb"
66
67
  }
@@ -1,5 +1,5 @@
1
1
  declare const _default: {
2
- "version": "0.4.3",
2
+ "version": "0.4.5-alpha.0",
3
3
  "name": "@done-coding/cli-publish",
4
4
  "description": "项目发布命令行工具",
5
5
  "cliConfig": {