@vc-shell/release-config 1.1.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.1.1](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.0...v1.1.1) (2025-04-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * enhance release process with npm tag detection and commit message generation ([fbc92b6](https://github.com/VirtoCommerce/vc-shell/commit/fbc92b62922a5ba118a87507293334fa5138b9f1))
7
+
8
+
9
+
1
10
  # [1.1.0](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.0-alpha.2...v1.1.0) (2025-04-29)
2
11
 
3
12
 
@@ -1,37 +1,45 @@
1
1
  import c from "prompts";
2
- import { inc as v, valid as C, parse as T } from "semver";
3
- import { readFileSync as V } from "node:fs";
4
- import w from "node:path";
2
+ import { inc as v, valid as C, parse as S } from "semver";
3
+ import { readFileSync as V, writeFileSync as I } from "node:fs";
4
+ import k from "node:path";
5
5
  import o from "chalk";
6
- import I from "mri";
7
- import { argv as R } from "node:process";
8
- import { sync as U } from "cross-spawn";
9
- const a = I(R.slice(2)), b = !!a.dry;
6
+ import R from "mri";
7
+ import { argv as U } from "node:process";
8
+ import { sync as A } from "cross-spawn";
9
+ const e = R(U.slice(2)), b = !!e.dry;
10
10
  b && (console.log(o.inverse(o.yellow(" DRY RUN "))), console.log());
11
- function y(n) {
12
- const s = w.resolve(n), l = w.resolve(s, "package.json");
11
+ function y(t) {
12
+ const s = k.resolve(t), l = k.resolve(s, "package.json");
13
13
  return { pkg: JSON.parse(V(l, "utf-8")), pkgDir: s, pkgPath: l };
14
14
  }
15
- async function k(n, s, l) {
16
- return U(n, s, { stdio: "inherit", ...l });
15
+ async function D(t, s) {
16
+ if (b) {
17
+ console.log(o.blue(`[dryrun] Writing package.json to ${t}`));
18
+ return;
19
+ }
20
+ I(t, JSON.stringify(s, null, 2) + `
21
+ `, "utf-8");
17
22
  }
18
- async function D(n, s, l) {
19
- return console.log(o.blue(`[dryrun] ${n} ${s.join(" ")}`), l || "");
23
+ async function N(t, s, l) {
24
+ return A(t, s, { stdio: "inherit", ...l });
20
25
  }
21
- const p = b ? D : k;
22
- function f(n) {
23
- return console.log(o.cyan(n));
26
+ async function M(t, s, l) {
27
+ return console.log(o.blue(`[dryrun] ${t} ${s.join(" ")}`), l || "");
24
28
  }
25
- function S(n) {
26
- function s(r, t) {
27
- if (r === "prerelease" && t === "alpha") {
28
- if (n.includes("-alpha")) {
29
- const [u, m] = n.split("-alpha."), $ = parseInt(m) + 1;
30
- return `${u}-alpha.${$}`;
29
+ const u = b ? M : N;
30
+ function $(t) {
31
+ return console.log(o.cyan(t));
32
+ }
33
+ function E(t) {
34
+ function s(r, n) {
35
+ if (r === "prerelease" && n === "alpha") {
36
+ if (t.includes("-alpha")) {
37
+ const [f, m] = t.split("-alpha."), h = parseInt(m) + 1;
38
+ return `${f}-alpha.${h}`;
31
39
  }
32
- return `${v(n, "patch")}-alpha.0`;
40
+ return `${v(t, "patch")}-alpha.0`;
33
41
  }
34
- return v(n, r);
42
+ return v(t, r);
35
43
  }
36
44
  return [
37
45
  {
@@ -56,35 +64,35 @@ function S(n) {
56
64
  }
57
65
  ].map((r) => (r.title = `${r.title} (${r.value})`, r));
58
66
  }
59
- const H = async ({
60
- packages: n,
67
+ const Y = async ({
68
+ packages: t,
61
69
  bumpVersion: s,
62
70
  generateChangelog: l,
63
71
  toTag: r
64
72
  }) => {
65
- let t;
66
- if (n.length === 0)
73
+ let n;
74
+ if (t.length === 0)
67
75
  throw new Error("No packages to release");
68
- const { pkg: h } = y(n[0]);
69
- if (!t) {
70
- const { release: e } = await c({
76
+ const { pkg: d } = y(t[0]);
77
+ if (!n) {
78
+ const { release: a } = await c({
71
79
  type: "select",
72
80
  name: "release",
73
81
  message: "Select release type",
74
- choices: S(h.version)
82
+ choices: E(d.version)
75
83
  });
76
- e === "custom" ? t = (await c({
84
+ a === "custom" ? n = (await c({
77
85
  type: "text",
78
86
  name: "version",
79
87
  message: "Input custom version",
80
- initial: h.version
81
- })).version : t = e;
88
+ initial: d.version
89
+ })).version : n = a;
82
90
  }
83
- if (!C(t))
84
- throw new Error(`invalid target version: ${t}`);
85
- const u = t.match(/-([a-zA-Z]+)(?:\.(\d+))?$/);
86
- if (u && !a.tag && (a.tag = u[1]), !a.tag) {
87
- const { npmTag: e } = await c({
91
+ if (!C(n))
92
+ throw new Error(`invalid target version: ${n}`);
93
+ const f = n.match(/-([a-zA-Z]+)(?:\.(\d+))?$/);
94
+ if (f && !e.tag && (e.tag = f[1]), !e.tag) {
95
+ const { npmTag: a } = await c({
88
96
  type: "select",
89
97
  name: "npmTag",
90
98
  message: "Select npm distribution tag",
@@ -96,60 +104,67 @@ const H = async ({
96
104
  { title: "custom", value: "custom" }
97
105
  ]
98
106
  });
99
- if (e === "custom") {
107
+ if (a === "custom") {
100
108
  const g = await c({
101
109
  type: "text",
102
110
  name: "customTag",
103
111
  message: "Input custom npm tag",
104
112
  initial: "latest"
105
113
  });
106
- a.tag = g.customTag;
107
- } else e !== "latest" && (a.tag = e);
114
+ e.tag = g.customTag;
115
+ } else a !== "latest" && (e.tag = a);
108
116
  }
109
- if (a.tag && a.tag !== "latest") {
110
- const e = T(t);
111
- if (e && !t.includes(`-${a.tag}`)) {
112
- let i, d = 0;
113
- e.prerelease.length > 0 ? (e.prerelease.length > 1 && typeof e.prerelease[1] == "number" && (d = e.prerelease[1]), i = `${`${e.major}.${e.minor}.${e.patch}`}-${a.tag}`) : i = `${v(t, "minor")}-${a.tag}`;
114
- const { usePreNum: x } = await c({
117
+ if (e.tag && e.tag !== "latest") {
118
+ const a = S(n);
119
+ if (a && !n.includes(`-${e.tag}`)) {
120
+ let i, p = 0;
121
+ a.prerelease.length > 0 ? (a.prerelease.length > 1 && typeof a.prerelease[1] == "number" && (p = a.prerelease[1]), i = `${`${a.major}.${a.minor}.${a.patch}`}-${e.tag}`) : i = `${v(n, "minor")}-${e.tag}`;
122
+ const { usePreNum: w } = await c({
115
123
  type: "confirm",
116
124
  name: "usePreNum",
117
- message: `Add prerelease number to version? (e.g. ${i}.${d})`,
125
+ message: `Add prerelease number to version? (e.g. ${i}.${p})`,
118
126
  initial: !0
119
127
  });
120
- x && (i = `${i}.${d}`);
121
- const { confirmVersionChange: P } = await c({
128
+ w && (i = `${i}.${p}`);
129
+ const { confirmVersionChange: j } = await c({
122
130
  type: "confirm",
123
131
  name: "confirmVersionChange",
124
- message: `Update version from ${o.yellow(t)} to ${o.green(i)} to match ${o.blue(a.tag)} tag?`
132
+ message: `Update version from ${o.yellow(n)} to ${o.green(i)} to match ${o.blue(e.tag)} tag?`
125
133
  });
126
- P && (t = i, console.log(`Version updated to ${o.green(t)}`));
134
+ j && (n = i, console.log(`Version updated to ${o.green(n)}`));
127
135
  }
128
136
  }
129
- const m = r(t), { yes: $ } = await c({
137
+ const m = r(n);
138
+ let h = `release: ${m}`;
139
+ e.tag && e.tag !== "latest" && (h += ` with npm tag ${e.tag}`);
140
+ const { yes: P } = await c({
130
141
  type: "confirm",
131
142
  name: "yes",
132
- message: `Releasing ${o.yellow(m)}${a.tag && a.tag !== "latest" ? ` with npm tag ${o.blue(a.tag)}` : ""} Confirm?`
143
+ message: `Releasing ${o.yellow(m)}${e.tag && e.tag !== "latest" ? ` with npm tag ${o.blue(e.tag)}` : ""} Confirm?`
133
144
  });
134
- if (!$) return;
135
- for (let e = 0; e < n.length; e++) {
136
- const g = n[e], { pkg: i } = y(g);
137
- f(`
138
- Updating ${o.green(i.name)} package version to ${o.green(t)}...`), await s(i.name, t), f(`
139
- Generating ${o.green(i.name)} changelog...`), await l(i.name, t, g);
145
+ if (!P) return;
146
+ for (let a = 0; a < t.length; a++) {
147
+ const g = t[a], { pkg: i } = y(g);
148
+ if ($(`
149
+ Updating ${o.green(i.name)} package version to ${o.green(n)}...`), await s(i.name, n), e.tag && e.tag !== "latest") {
150
+ const p = y(g), w = { ...p.pkg, npmTag: e.tag };
151
+ await D(p.pkgPath, w), console.log(`Added npmTag: ${o.blue(e.tag)} to ${o.green(i.name)}`);
152
+ }
153
+ $(`
154
+ Generating ${o.green(i.name)} changelog...`), await l(i.name, n, g);
140
155
  }
141
- const { stdout: N } = await k("git", ["diff"], { stdio: "pipe" });
142
- if (N)
143
- f(`
144
- Committing changes...`), await p("git", ["add", "-A"]), await p("git", ["commit", "-m", `release: ${m}`, "--no-verify"]), await p("git", ["tag", m]);
156
+ const { stdout: T } = await N("git", ["diff"], { stdio: "pipe" });
157
+ if (T)
158
+ $(`
159
+ Committing changes...`), await u("git", ["add", "-A"]), await u("git", ["commit", "-m", h, "--no-verify"]), await u("git", ["tag", m]);
145
160
  else {
146
161
  console.log("No changes to commit.");
147
162
  return;
148
163
  }
149
- f(`
150
- Pushing to GitHub...`), await p("git", ["push", "origin", `refs/tags/${m}`]), await p("git", ["push"]), a.tag && a.tag !== "latest" && console.log(`
151
- NOTE: This release will be published to npm with tag ${o.blue(a.tag)}`), console.log();
164
+ $(`
165
+ Pushing to GitHub...`), await u("git", ["push", "origin", `refs/tags/${m}`]), await u("git", ["push"]), e.tag && e.tag !== "latest" && console.log(`
166
+ NOTE: This release will be published to npm with tag ${o.blue(e.tag)}`), console.log();
152
167
  };
153
168
  export {
154
- H as release
169
+ Y as release
155
170
  };
@@ -1 +1 @@
1
- {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../src/release.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAU,sDAK3B;IACD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtG,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,kBAuKA,CAAC"}
1
+ {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../src/release.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAU,sDAK3B;IACD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtG,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,kBAqLA,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vc-shell/release-config",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/release-config.js",
6
6
  "types": "./dist/index.d.ts",
@@ -22,12 +22,13 @@
22
22
  "@types/cross-spawn": "^6.0.6",
23
23
  "@types/prompts": "^2.4.7",
24
24
  "@types/semver": "^7.5.4",
25
- "@vc-shell/ts-config": "^1.1.0",
25
+ "@vc-shell/ts-config": "^1.1.1",
26
26
  "typescript": "^5.8.3",
27
27
  "vite-plugin-dts": "^3.6.4"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public",
31
31
  "registry": "https://registry.npmjs.org/"
32
- }
32
+ },
33
+ "npmTag": "next"
33
34
  }