@vitejs/release-scripts 1.6.0 → 1.7.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/dist/index.d.ts CHANGED
@@ -21,6 +21,8 @@ export declare function publish(options: {
21
21
  }): Promise<void>;
22
22
 
23
23
  export declare function release(options: {
24
+ /** @default 'vitejs' */
25
+ org?: string;
24
26
  repo: string;
25
27
  packages: string[];
26
28
  logChangelog: (pkg: string) => void | Promise<void>;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // src/publish.ts
2
- import semver2 from "semver";
2
+ import * as semver2 from "semver";
3
3
 
4
4
  // src/utils.ts
5
5
  import { writeFileSync, readFileSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import colors from "picocolors";
8
- import { execa } from "execa";
9
- import semver from "semver";
8
+ import { exec } from "tinyexec";
9
+ import * as semver from "semver";
10
10
  import mri from "mri";
11
11
  var args = mri(process.argv.slice(2));
12
12
  var isDryRun = !!args.dry;
@@ -24,7 +24,14 @@ function getPackageInfo(pkgName, getPkgDir = (pkg) => `packages/${pkg}`) {
24
24
  return { pkg, pkgDir, pkgPath };
25
25
  }
26
26
  async function run(bin, args2, opts = {}) {
27
- return execa(bin, args2, { stdio: "inherit", ...opts });
27
+ return exec(bin, args2, {
28
+ throwOnError: true,
29
+ ...opts,
30
+ nodeOptions: {
31
+ stdio: "inherit",
32
+ ...opts.nodeOptions
33
+ }
34
+ });
28
35
  }
29
36
  async function dryRun(bin, args2, opts) {
30
37
  return console.log(
@@ -40,51 +47,51 @@ function getVersionChoices(currentVersion) {
40
47
  const currentBeta = currentVersion.includes("beta");
41
48
  const currentAlpha = currentVersion.includes("alpha");
42
49
  const isStable = !currentBeta && !currentAlpha;
43
- function inc(i, tag = currentAlpha ? "alpha" : "beta") {
50
+ function inc2(i, tag = currentAlpha ? "alpha" : "beta") {
44
51
  return semver.inc(currentVersion, i, tag);
45
52
  }
46
53
  let versionChoices = [
47
54
  {
48
55
  title: "next",
49
- value: inc(isStable ? "patch" : "prerelease")
56
+ value: inc2(isStable ? "patch" : "prerelease")
50
57
  }
51
58
  ];
52
59
  if (isStable) {
53
60
  versionChoices.push(
54
61
  {
55
62
  title: "beta-minor",
56
- value: inc("preminor")
63
+ value: inc2("preminor")
57
64
  },
58
65
  {
59
66
  title: "beta-major",
60
- value: inc("premajor")
67
+ value: inc2("premajor")
61
68
  },
62
69
  {
63
70
  title: "alpha-minor",
64
- value: inc("preminor", "alpha")
71
+ value: inc2("preminor", "alpha")
65
72
  },
66
73
  {
67
74
  title: "alpha-major",
68
- value: inc("premajor", "alpha")
75
+ value: inc2("premajor", "alpha")
69
76
  },
70
77
  {
71
78
  title: "minor",
72
- value: inc("minor")
79
+ value: inc2("minor")
73
80
  },
74
81
  {
75
82
  title: "major",
76
- value: inc("major")
83
+ value: inc2("major")
77
84
  }
78
85
  );
79
86
  } else if (currentAlpha) {
80
87
  versionChoices.push({
81
88
  title: "beta",
82
- value: inc("patch") + "-beta.0"
89
+ value: inc2("patch") + "-beta.0"
83
90
  });
84
91
  } else {
85
92
  versionChoices.push({
86
93
  title: "stable",
87
- value: inc("patch")
94
+ value: inc2("patch")
88
95
  });
89
96
  }
90
97
  versionChoices.push({ value: "custom", title: "custom" });
@@ -111,7 +118,7 @@ async function publishPackage(pkgDir, tag, provenance, packageManager = "npm") {
111
118
  publicArgs.push(`--no-git-checks`);
112
119
  }
113
120
  await runIfNotDry(packageManager, publicArgs, {
114
- cwd: pkgDir
121
+ nodeOptions: { cwd: pkgDir }
115
122
  });
116
123
  }
117
124
  async function getActiveVersion(npmName) {
@@ -119,7 +126,7 @@ async function getActiveVersion(npmName) {
119
126
  const { stdout } = await run(
120
127
  "npm",
121
128
  ["info", npmName, "version", "--json"],
122
- { stdio: "pipe" }
129
+ { nodeOptions: { stdio: "pipe" } }
123
130
  );
124
131
  return JSON.parse(stdout);
125
132
  } catch (e) {
@@ -169,6 +176,7 @@ import colors2 from "picocolors";
169
176
  import { publint } from "publint";
170
177
  import { formatMessage } from "publint/utils";
171
178
  var release = async ({
179
+ org = "vitejs",
172
180
  repo,
173
181
  packages,
174
182
  logChangelog,
@@ -234,7 +242,9 @@ var release = async ({
234
242
  step("\nUpdating package version...");
235
243
  updateVersion(pkgPath, targetVersion);
236
244
  await generateChangelog2(selectedPkg, targetVersion);
237
- const { stdout } = await run("git", ["diff"], { stdio: "pipe" });
245
+ const { stdout } = await run("git", ["diff"], {
246
+ nodeOptions: { stdio: "pipe" }
247
+ });
238
248
  if (stdout) {
239
249
  step("\nCommitting changes...");
240
250
  await runIfNotDry("git", ["add", "-A"]);
@@ -255,7 +265,7 @@ Dry run finished - run git diff to see package changes.`);
255
265
  colors2.green(
256
266
  `
257
267
  Pushed, publishing should starts shortly on CI.
258
- https://github.com/vitejs/${repo}/actions/workflows/publish.yml`
268
+ https://github.com/${org}/${repo}/actions/workflows/publish.yml`
259
269
  )
260
270
  );
261
271
  }
@@ -264,6 +274,7 @@ https://github.com/vitejs/${repo}/actions/workflows/publish.yml`
264
274
 
265
275
  // src/changelog.ts
266
276
  import fs from "node:fs";
277
+ import path2 from "node:path";
267
278
  import { ConventionalChangelog } from "conventional-changelog";
268
279
  import createPreset, {
269
280
  DEFAULT_COMMIT_TYPES
@@ -301,14 +312,35 @@ var generateChangelog = async ({
301
312
  {{~/if}}
302
313
  {{~#if isPatch~}} </small> {{~/if}}
303
314
  `.trim();
304
- preset.writer.mainTemplate += "\n";
315
+ preset.writer.mainTemplate = `
316
+ {{> header}}
317
+ {{#if noteGroups}}
318
+ {{#each noteGroups}}
319
+
320
+ ### \u26A0 {{title}}
321
+
322
+ {{#each notes}}
323
+ * {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{commit.subject}} {{#if commit.hash}}([{{commit.shortHash}}](https://github.com/{{@root.owner}}/{{@root.repository}}/commit/{{commit.hash}})){{/if}}
324
+ {{/each}}
325
+ {{/each}}
326
+ {{/if}}
327
+ {{#each commitGroups}}
328
+
329
+ {{#if title}}
330
+ ### {{title}}
331
+
332
+ {{/if}}
333
+ {{#each commits}}
334
+ {{> commit root=@root}}
335
+ {{/each}}
336
+ {{/each}}`.trim() + "\n";
305
337
  const pkgDir = getPkgDir();
306
- const generator = new ConventionalChangelog().readPackage(`${pkgDir}/package.json`).config(preset).options({ releaseCount: 1 }).commits({ path: pkgDir });
338
+ const generator = new ConventionalChangelog(pkgDir).readPackage().config(preset).options({ releaseCount: 1 });
307
339
  if (tagPrefix) {
308
340
  generator.tags({ prefix: tagPrefix });
309
341
  }
310
- const originalChangelog = fs.readFileSync(`${pkgDir}/CHANGELOG.md`, "utf-8");
311
- const writeStream = fs.createWriteStream(`${pkgDir}/CHANGELOG.md`);
342
+ const originalChangelog = fs.existsSync(path2.join(pkgDir, "CHANGELOG.md")) ? fs.readFileSync(path2.join(pkgDir, "CHANGELOG.md"), "utf-8") : "";
343
+ const writeStream = fs.createWriteStream(path2.join(pkgDir, "CHANGELOG.md"));
312
344
  for await (const chunk of generator.write()) {
313
345
  writeStream.write(chunk);
314
346
  }
package/package.json CHANGED
@@ -1,48 +1,44 @@
1
1
  {
2
2
  "name": "@vitejs/release-scripts",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "@vitejs release scripts",
5
5
  "license": "MIT",
6
- "main": "dist/index.js",
7
6
  "type": "module",
8
7
  "files": [
9
8
  "dist"
10
9
  ],
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- }
16
- },
10
+ "exports": "./dist/index.js",
17
11
  "repository": {
18
12
  "type": "git",
19
13
  "url": "git+https://github.com/vitejs/release-scripts.git"
20
14
  },
21
15
  "scripts": {
22
- "build": "tnode scripts/build.ts",
16
+ "build": "node scripts/build.ts",
17
+ "test": "vitest",
23
18
  "prettier": "pnpm prettier-ci --write",
24
19
  "prettier-ci": "prettier --cache --ignore-path=.gitignore --check '**/*.{ts,json,md,yml}'",
25
- "qa": "tsc && pnpm prettier-ci && pnpm build",
26
- "release": "tnode scripts/release.ts"
20
+ "qa": "tsc && pnpm prettier-ci && pnpm build && vitest run",
21
+ "release": "node scripts/release.ts"
27
22
  },
28
23
  "dependencies": {
29
- "conventional-changelog": "^7.1.0",
30
- "conventional-changelog-conventionalcommits": "^9.0.0",
31
- "execa": "^8.0.1",
24
+ "conventional-changelog": "^7.2.0",
25
+ "conventional-changelog-conventionalcommits": "^9.3.1",
32
26
  "mri": "^1.2.0",
33
27
  "picocolors": "^1.1.1",
34
28
  "prompts": "^2.4.2",
35
- "publint": "^0.3.12",
36
- "semver": "^7.7.2"
29
+ "publint": "^0.3.18",
30
+ "semver": "^7.7.4",
31
+ "tinyexec": "^1.1.1"
37
32
  },
38
33
  "devDependencies": {
39
- "@arnaud-barre/tnode": "^0.25.0",
40
- "@types/node": "^22.15.33",
34
+ "@types/node": "^24.12.2",
41
35
  "@types/prompts": "^2.4.9",
42
- "@types/semver": "^7.7.0",
43
- "esbuild": "^0.25.0",
44
- "prettier": "^3.6.2",
45
- "typescript": "^5.8.3"
36
+ "@types/semver": "^7.7.1",
37
+ "esbuild": "^0.28.0",
38
+ "fs-fixture": "^2.13.0",
39
+ "prettier": "^3.8.3",
40
+ "typescript": "^6.0.3",
41
+ "vitest": "^4.1.5"
46
42
  },
47
- "packageManager": "pnpm@10.12.4"
43
+ "packageManager": "pnpm@10.33.0"
48
44
  }