@done-coding/cli-publish 0.7.13 → 0.7.14-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 CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-f33712b6.js";
2
+ import { c as m } from "./index-37198ba2.js";
3
3
  import "@done-coding/cli-utils";
4
- import "node:child_process";
5
4
  import "semver";
6
5
  import "node:path";
7
6
  import "node:fs";
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env node
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";
3
- import { execSync as l } from "node:child_process";
2
+ import { getConfigFileCommonOptions as O, initHandlerCommon as F, log as m, readConfigFile as H, getPackageJson as L, applyUseTempDir as U, getCliModuleTempDir as G, execSyncWithLogDispatch as l, getGitLastCommitInfo as W, pushGitPublishInfoToRemote as X, xPrompts as $, createSubcommand as y, getRootScriptName as V, createMainCommand as q } from "@done-coding/cli-utils";
4
3
  import { inc as N } from "semver";
5
4
  import z from "node:path";
6
5
  import S, { rmSync as K } from "node:fs";
7
6
  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
7
  const R = {
9
8
  name: "@done-coding/cli-publish",
10
- version: "0.7.13",
9
+ version: "0.7.14-alpha.1",
11
10
  description: "项目发布命令行工具",
12
11
  bin: {
13
12
  "dc-publish": "es/cli.mjs"
@@ -55,22 +54,22 @@ const R = {
55
54
  m.warn("没有配置别名发布信息");
56
55
  return;
57
56
  }
58
- const { rootDir: d } = e, s = $({ rootDir: d }), { name: a, version: i } = s;
57
+ const { rootDir: d } = e, s = L({ rootDir: d }), { name: i, version: a } = s;
59
58
  return U({
60
59
  dir: G(R.cliConfig.moduleName),
61
60
  fn: async (n) => {
62
61
  var g;
63
- S.mkdirSync(n, { recursive: !0 }), l(`pnpm add ${a}@${i}`, {
62
+ S.mkdirSync(n, { recursive: !0 }), l(`pnpm add ${i}@${a}`, {
64
63
  stdio: "inherit",
65
64
  cwd: n
66
65
  });
67
- const h = (g = l(`npm dist-tag ${a}`).toString().trim().split(`
66
+ const A = (g = l(`npm dist-tag ${i}`).toString().trim().split(`
68
67
  `).map((E) => E.split(":").map((w) => w.trim())).find(
69
- ([, E]) => E === i
68
+ ([, E]) => E === a
70
69
  )) == 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 = $({
70
+ if (!A)
71
+ return m.warn(`没有找到 ${i}@${a} 对应的dist-tag`);
72
+ const C = z.resolve(n, "node_modules", i), u = L({
74
73
  rootDir: C
75
74
  });
76
75
  for (let E of o) {
@@ -81,7 +80,7 @@ const R = {
81
80
  S.writeFileSync(
82
81
  B,
83
82
  JSON.stringify(j, null, 2)
84
- ), l(`pnpm publish --tag ${h}`, {
83
+ ), l(`pnpm publish --tag ${A}`, {
85
84
  stdio: "inherit",
86
85
  cwd: C
87
86
  });
@@ -125,48 +124,48 @@ const R = {
125
124
  type: t,
126
125
  distTag: o
127
126
  }) => {
128
- let d = e.name, s = "", a;
129
- const { version: i } = e;
130
- if (!i)
127
+ let d = e.name, s = "", i;
128
+ const { version: a } = e;
129
+ if (!a)
131
130
  throw new Error("当前版本号为空");
132
131
  switch (t) {
133
132
  case r.PATCH:
134
133
  case r.MINOR:
135
134
  case r.MAJOR: {
136
- s = N(i, t), a = o || f.LATEST;
135
+ s = N(a, t), i = o || f.LATEST;
137
136
  break;
138
137
  }
139
138
  case r.PREPATCH:
140
139
  case r.PREMINOR:
141
140
  case r.PREMAJOR: {
142
- s = N(i, t, f.ALPHA), a = o || f.ALPHA;
141
+ s = N(a, t, f.ALPHA), i = o || f.ALPHA;
143
142
  break;
144
143
  }
145
144
  case r.PRERELEASE: {
146
- const n = (await L({
145
+ const n = (await $({
147
146
  type: "text",
148
147
  name: "identifier",
149
148
  message: "请输入修饰符",
150
149
  initial: f.ALPHA
151
150
  })).identifier;
152
- s = N(i, t, n), a = o || n;
151
+ s = N(a, t, n), i = o || n;
153
152
  break;
154
153
  }
155
154
  default:
156
- s = (await L({
155
+ s = (await $({
157
156
  type: "text",
158
157
  name: "customVersion",
159
158
  message: "请输入自定义版本号"
160
- })).customVersion, a = o || f.LATEST;
159
+ })).customVersion, i = o || f.LATEST;
161
160
  }
162
161
  if (!s)
163
162
  throw new Error("version is empty");
164
163
  return {
165
164
  name: d,
166
165
  version: s,
167
- tag: a
166
+ tag: i
168
167
  };
169
- }, ie = async ({
168
+ }, ae = async ({
170
169
  type: e,
171
170
  packageJson: t,
172
171
  distTag: o
@@ -192,7 +191,7 @@ const R = {
192
191
  type: n,
193
192
  distTag: o
194
193
  });
195
- const a = [
194
+ const i = [
196
195
  ...s.map((n) => ({
197
196
  title: `${n} (${d[n].version})`,
198
197
  value: n
@@ -204,25 +203,25 @@ const R = {
204
203
  title: n,
205
204
  value: n
206
205
  }))
207
- ], i = (await L({
206
+ ], a = (await $({
208
207
  type: "select",
209
208
  name: "selectType",
210
209
  message: `请选择发布类型,当前版本:${t.version}`,
211
- choices: a
210
+ choices: i
212
211
  })).selectType;
213
- return s.includes(i) ? d[i] : P({
212
+ return s.includes(a) ? d[a] : P({
214
213
  packageJson: t,
215
- type: i,
214
+ type: a,
216
215
  distTag: o
217
216
  });
218
217
  }
219
218
  }, 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({
219
+ const { mode: t, type: o, push: d, rootDir: s, distTag: i } = e, a = await H(e, () => ({})), n = a[t], h = await W(n), T = L({ rootDir: s }), p = await ae({
221
220
  type: o,
222
221
  packageJson: T,
223
- distTag: a
224
- }), { version: h } = p;
225
- l(`npm version ${h}`, {
222
+ distTag: i
223
+ }), { version: A } = p;
224
+ l(`npm version ${A}`, {
226
225
  cwd: s,
227
226
  stdio: "inherit"
228
227
  });
@@ -253,8 +252,8 @@ const R = {
253
252
  } catch (u) {
254
253
  m.error(`发布失败, error: ${u.message}`);
255
254
  try {
256
- m.info(`回滚本地版本到发布前的版本:${A.lastHash}`);
257
- const { lastHash: g } = A;
255
+ m.info(`回滚本地版本到发布前的版本:${h.lastHash}`);
256
+ const { lastHash: g } = h;
258
257
  l(`git reset --hard ${g}`, {
259
258
  stdio: "inherit"
260
259
  }), m.info(`删除本次发布时生成的tag:v${p.version}`), l(`git tag -d v${p.version}`, {
@@ -266,16 +265,16 @@ const R = {
266
265
  return process.exit(1);
267
266
  }
268
267
  d && X({
269
- branchName: A.branchName,
268
+ branchName: h.branchName,
270
269
  version: p.version,
271
- remoteInfo: A.remoteInfo
272
- }), m.success(`发布成功,版本号:${h}`), t === c.NPM && J(i) && M(e);
273
- }, ae = {
270
+ remoteInfo: h.remoteInfo
271
+ }), m.success(`发布成功,版本号:${A}`), t === c.NPM && J(a) && M(e);
272
+ }, ie = {
274
273
  command: "$0",
275
274
  describe: "执行发布命令",
276
275
  options: re(),
277
276
  handler: x
278
- }, ge = async (e, t) => {
277
+ }, ue = async (e, t) => {
279
278
  switch (e) {
280
279
  case I.INIT:
281
280
  return k(t);
@@ -291,7 +290,7 @@ const R = {
291
290
  version: ce,
292
291
  subcommands: [
293
292
  ne,
294
- ae,
293
+ ie,
295
294
  se
296
295
  ].map(y),
297
296
  demandCommandCount: 1,
@@ -301,19 +300,19 @@ const R = {
301
300
  } = R, _ = (e = !1) => {
302
301
  const t = e ? b : void 0, o = `$0${e ? ` ${b}` : ""} [options]`;
303
302
  return { command: t, usage: o };
304
- }, Ie = async () => q({
303
+ }, ge = async () => q({
305
304
  ...D,
306
305
  ..._()
307
- }), Ae = () => y({
306
+ }), Ie = () => y({
308
307
  ...D,
309
308
  ..._(!0)
310
309
  });
311
310
  export {
312
311
  r as P,
313
312
  I as S,
314
- Ae as a,
313
+ Ie as a,
315
314
  f as b,
316
- Ie as c,
315
+ ge as c,
317
316
  c as d,
318
- ge as h
317
+ ue as h
319
318
  };
package/es/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { d as u, b as e, P as b, S as p, a as t, h as d } from "./index-f33712b6.js";
2
+ import { d as u, b as i, P as e, S as b, a as d, h as p } from "./index-37198ba2.js";
3
3
  import "@done-coding/cli-utils";
4
- import "node:child_process";
5
4
  import "semver";
6
5
  import "node:path";
7
6
  import "node:fs";
8
7
  export {
9
8
  u as PublishModeEnum,
10
- e as PublishTagEnum,
11
- b as PublishVersionTypeEnum,
12
- p as SubcommandEnum,
13
- t as crateAsSubcommand,
14
- d as handler
9
+ i as PublishTagEnum,
10
+ e as PublishVersionTypeEnum,
11
+ b as SubcommandEnum,
12
+ d as crateAsSubcommand,
13
+ p as handler
15
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-publish",
3
- "version": "0.7.13",
3
+ "version": "0.7.14-alpha.1",
4
4
  "description": "项目发布命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -41,12 +41,12 @@
41
41
  "license": "MIT",
42
42
  "sideEffects": false,
43
43
  "devDependencies": {
44
- "@done-coding/cli-inject": "0.5.20",
44
+ "@done-coding/cli-inject": "0.5.21-alpha.1",
45
45
  "@types/node": "^18.0.0",
46
46
  "@types/semver": "^7.5.3",
47
47
  "@types/yargs": "^17.0.28",
48
48
  "rimraf": "^6.0.1",
49
- "typescript": "^5.2.2",
49
+ "typescript": "^5.8.3",
50
50
  "vite": "^4.4.11",
51
51
  "vite-plugin-dts": "^3.6.0"
52
52
  },
@@ -54,8 +54,8 @@
54
54
  "node": ">=18.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "@done-coding/cli-utils": "0.8.1",
57
+ "@done-coding/cli-utils": "0.8.2-alpha.1",
58
58
  "semver": "^7.5.4"
59
59
  },
60
- "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6"
60
+ "gitHead": "660e39fc523e4eba1ea621e3c59122f98015a2de"
61
61
  }