@vitejs/release-scripts 1.7.0 → 1.8.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/README.md +2 -7
- package/dist/index.js +239 -329
- package/package.json +21 -21
package/README.md
CHANGED
|
@@ -12,15 +12,10 @@ release({
|
|
|
12
12
|
repo: "release-scripts",
|
|
13
13
|
// List of options. Choice will be available in following callback as `pkg`
|
|
14
14
|
packages: ["release-scripts"],
|
|
15
|
-
toTag: (pkg, version) =>
|
|
16
|
-
pkg === "vite" ? `v${version}` : `${pkg}@${version}`,
|
|
15
|
+
toTag: (pkg, version) => (pkg === "vite" ? `v${version}` : `${pkg}@${version}`),
|
|
17
16
|
// Not shared until we find a new changelog process
|
|
18
17
|
logChangelog: (pkg) =>
|
|
19
|
-
console.log(
|
|
20
|
-
execSync(
|
|
21
|
-
"git log $(git describe --tags --abbrev=0)..HEAD --oneline",
|
|
22
|
-
).toString(),
|
|
23
|
-
),
|
|
18
|
+
console.log(execSync("git log $(git describe --tags --abbrev=0)..HEAD --oneline").toString()),
|
|
24
19
|
generateChangelog: (pkg, version) => {},
|
|
25
20
|
// Use getPkgDir when not using a monorepo. Default to `packages/${pkg}`
|
|
26
21
|
getPkgDir: (pkg) => ".",
|
package/dist/index.js
CHANGED
|
@@ -1,353 +1,263 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// src/utils.ts
|
|
5
|
-
import { writeFileSync, readFileSync } from "node:fs";
|
|
1
|
+
import * as semver$1 from "semver";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import fs, { readFileSync, writeFileSync } from "node:fs";
|
|
6
4
|
import path from "node:path";
|
|
7
5
|
import colors from "picocolors";
|
|
8
6
|
import { exec } from "tinyexec";
|
|
9
|
-
import * as semver from "semver";
|
|
10
7
|
import mri from "mri";
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import prompts from "prompts";
|
|
9
|
+
import { publint } from "publint";
|
|
10
|
+
import { formatMessage } from "publint/utils";
|
|
11
|
+
import { ConventionalChangelog } from "conventional-changelog";
|
|
12
|
+
import createPreset, { DEFAULT_COMMIT_TYPES, formatCommitUrl } from "conventional-changelog-conventionalcommits";
|
|
13
|
+
import { bold, compareUrl, each, heading, link, list, newline, segments, words } from "@conventional-changelog/template";
|
|
14
|
+
//#region src/utils.ts
|
|
15
|
+
const args = mri(process.argv.slice(2));
|
|
16
|
+
const isDryRun = !!args.dry;
|
|
13
17
|
if (isDryRun) {
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
console.log(colors.inverse(colors.yellow(" DRY RUN ")));
|
|
19
|
+
console.log();
|
|
16
20
|
}
|
|
17
21
|
function getPackageInfo(pkgName, getPkgDir = (pkg) => `packages/${pkg}`) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const pkgDir = path.resolve(getPkgDir(pkgName));
|
|
23
|
+
const pkgPath = path.resolve(pkgDir, "package.json");
|
|
24
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
25
|
+
if (pkg.private) throw new Error(`Package ${pkgName} is private`);
|
|
26
|
+
return {
|
|
27
|
+
pkg,
|
|
28
|
+
pkgDir,
|
|
29
|
+
pkgPath
|
|
30
|
+
};
|
|
25
31
|
}
|
|
26
|
-
async function run(bin,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
async function run(bin, args, opts = {}) {
|
|
33
|
+
return exec(bin, args, {
|
|
34
|
+
throwOnError: true,
|
|
35
|
+
...opts,
|
|
36
|
+
nodeOptions: {
|
|
37
|
+
stdio: "inherit",
|
|
38
|
+
...opts.nodeOptions
|
|
39
|
+
}
|
|
40
|
+
});
|
|
35
41
|
}
|
|
36
|
-
async function dryRun(bin,
|
|
37
|
-
|
|
38
|
-
colors.blue(`[dryrun] ${bin} ${args2.join(" ")}`),
|
|
39
|
-
opts || ""
|
|
40
|
-
);
|
|
42
|
+
async function dryRun(bin, args, opts) {
|
|
43
|
+
return console.log(colors.blue(`[dryrun] ${bin} ${args.join(" ")}`), opts || "");
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
const runIfNotDry = isDryRun ? dryRun : run;
|
|
43
46
|
function step(msg) {
|
|
44
|
-
|
|
47
|
+
return console.log(colors.cyan(msg));
|
|
45
48
|
}
|
|
46
49
|
function getVersionChoices(currentVersion) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
title: "stable",
|
|
94
|
-
value: inc2("patch")
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
versionChoices.push({ value: "custom", title: "custom" });
|
|
98
|
-
versionChoices = versionChoices.map((i) => {
|
|
99
|
-
i.title = `${i.title} (${i.value})`;
|
|
100
|
-
return i;
|
|
101
|
-
});
|
|
102
|
-
return versionChoices;
|
|
50
|
+
const currentBeta = currentVersion.includes("beta");
|
|
51
|
+
const currentAlpha = currentVersion.includes("alpha");
|
|
52
|
+
const isStable = !currentBeta && !currentAlpha;
|
|
53
|
+
function inc(i, tag = currentAlpha ? "alpha" : "beta") {
|
|
54
|
+
return semver$1.inc(currentVersion, i, tag);
|
|
55
|
+
}
|
|
56
|
+
let versionChoices = [{
|
|
57
|
+
title: "next",
|
|
58
|
+
value: inc(isStable ? "patch" : "prerelease")
|
|
59
|
+
}];
|
|
60
|
+
if (isStable) versionChoices.push({
|
|
61
|
+
title: "beta-minor",
|
|
62
|
+
value: inc("preminor")
|
|
63
|
+
}, {
|
|
64
|
+
title: "beta-major",
|
|
65
|
+
value: inc("premajor")
|
|
66
|
+
}, {
|
|
67
|
+
title: "alpha-minor",
|
|
68
|
+
value: inc("preminor", "alpha")
|
|
69
|
+
}, {
|
|
70
|
+
title: "alpha-major",
|
|
71
|
+
value: inc("premajor", "alpha")
|
|
72
|
+
}, {
|
|
73
|
+
title: "minor",
|
|
74
|
+
value: inc("minor")
|
|
75
|
+
}, {
|
|
76
|
+
title: "major",
|
|
77
|
+
value: inc("major")
|
|
78
|
+
});
|
|
79
|
+
else if (currentAlpha) versionChoices.push({
|
|
80
|
+
title: "beta",
|
|
81
|
+
value: inc("patch") + "-beta.0"
|
|
82
|
+
});
|
|
83
|
+
else versionChoices.push({
|
|
84
|
+
title: "stable",
|
|
85
|
+
value: inc("patch")
|
|
86
|
+
});
|
|
87
|
+
versionChoices.push({
|
|
88
|
+
value: "custom",
|
|
89
|
+
title: "custom"
|
|
90
|
+
});
|
|
91
|
+
versionChoices = versionChoices.map((i) => {
|
|
92
|
+
i.title = `${i.title} (${i.value})`;
|
|
93
|
+
return i;
|
|
94
|
+
});
|
|
95
|
+
return versionChoices;
|
|
103
96
|
}
|
|
104
97
|
function updateVersion(pkgPath, version) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
99
|
+
pkg.version = version;
|
|
100
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
108
101
|
}
|
|
109
102
|
async function publishPackage(pkgDir, tag, provenance, packageManager = "npm") {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
await runIfNotDry(packageManager, publicArgs, {
|
|
121
|
-
nodeOptions: { cwd: pkgDir }
|
|
122
|
-
});
|
|
103
|
+
const publicArgs = [
|
|
104
|
+
"publish",
|
|
105
|
+
"--access",
|
|
106
|
+
"public"
|
|
107
|
+
];
|
|
108
|
+
if (tag) publicArgs.push(`--tag`, tag);
|
|
109
|
+
if (provenance) publicArgs.push(`--provenance`);
|
|
110
|
+
if (packageManager === "pnpm") publicArgs.push(`--no-git-checks`);
|
|
111
|
+
await runIfNotDry(packageManager, publicArgs, { nodeOptions: { cwd: pkgDir } });
|
|
123
112
|
}
|
|
124
113
|
async function getActiveVersion(npmName) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
throw e;
|
|
140
|
-
}
|
|
114
|
+
try {
|
|
115
|
+
const { stdout } = await run("npm", [
|
|
116
|
+
"info",
|
|
117
|
+
npmName,
|
|
118
|
+
"version",
|
|
119
|
+
"--json"
|
|
120
|
+
], { nodeOptions: { stdio: "pipe" } });
|
|
121
|
+
return JSON.parse(stdout);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
if (e.stdout) {
|
|
124
|
+
if (JSON.parse(e.stdout).error.code === "E404") return;
|
|
125
|
+
}
|
|
126
|
+
throw e;
|
|
127
|
+
}
|
|
141
128
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
throw new Error(
|
|
159
|
-
`Package name should be specified in tag "${tag}" when defaultPackage is not set`
|
|
160
|
-
);
|
|
161
|
-
const { pkg, pkgDir } = getPackageInfo(pkgName, getPkgDir);
|
|
162
|
-
if (pkg.version !== version)
|
|
163
|
-
throw new Error(
|
|
164
|
-
`Package version from tag "${version}" mismatches with current version "${pkg.version}"`
|
|
165
|
-
);
|
|
166
|
-
const activeVersion = await getActiveVersion(pkg.name);
|
|
167
|
-
step("Publishing package...");
|
|
168
|
-
const releaseTag = version.includes("beta") ? "beta" : version.includes("alpha") ? "alpha" : activeVersion && semver2.lt(pkg.version, activeVersion) ? "previous" : void 0;
|
|
169
|
-
await publishPackage(pkgDir, releaseTag, provenance, packageManager);
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/publish.ts
|
|
131
|
+
const publish = async ({ defaultPackage, getPkgDir, provenance, packageManager }) => {
|
|
132
|
+
const tag = args._[0];
|
|
133
|
+
if (!tag) throw new Error("No tag specified");
|
|
134
|
+
let pkgName = defaultPackage;
|
|
135
|
+
let version;
|
|
136
|
+
if (tag.includes("@")) [pkgName, version] = tag.split("@");
|
|
137
|
+
else version = tag;
|
|
138
|
+
if (version.startsWith("v")) version = version.slice(1);
|
|
139
|
+
if (pkgName === void 0) throw new Error(`Package name should be specified in tag "${tag}" when defaultPackage is not set`);
|
|
140
|
+
const { pkg, pkgDir } = getPackageInfo(pkgName, getPkgDir);
|
|
141
|
+
if (pkg.version !== version) throw new Error(`Package version from tag "${version}" mismatches with current version "${pkg.version}"`);
|
|
142
|
+
const activeVersion = await getActiveVersion(pkg.name);
|
|
143
|
+
step("Publishing package...");
|
|
144
|
+
await publishPackage(pkgDir, version.includes("beta") ? "beta" : version.includes("alpha") ? "alpha" : activeVersion && semver$1.lt(pkg.version, activeVersion) ? "previous" : void 0, provenance, packageManager);
|
|
170
145
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
console.log("No changes to commit.");
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
step("\nPushing to GitHub...");
|
|
258
|
-
await runIfNotDry("git", ["push", "origin", `refs/tags/${tag}`]);
|
|
259
|
-
await runIfNotDry("git", ["push"]);
|
|
260
|
-
if (isDryRun) {
|
|
261
|
-
console.log(`
|
|
262
|
-
Dry run finished - run git diff to see package changes.`);
|
|
263
|
-
} else {
|
|
264
|
-
console.log(
|
|
265
|
-
colors2.green(
|
|
266
|
-
`
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/release.ts
|
|
148
|
+
const release = async ({ org = "vitejs", repo, packages, logChangelog, generateChangelog, toTag, getPkgDir }) => {
|
|
149
|
+
let targetVersion;
|
|
150
|
+
const selectedPkg = packages.length === 1 ? packages[0] : (await prompts({
|
|
151
|
+
type: "select",
|
|
152
|
+
name: "pkg",
|
|
153
|
+
message: "Select package",
|
|
154
|
+
choices: packages.map((i) => ({
|
|
155
|
+
value: i,
|
|
156
|
+
title: i
|
|
157
|
+
}))
|
|
158
|
+
})).pkg;
|
|
159
|
+
if (!selectedPkg) return;
|
|
160
|
+
await logChangelog(selectedPkg);
|
|
161
|
+
const { pkg, pkgPath, pkgDir } = getPackageInfo(selectedPkg, getPkgDir);
|
|
162
|
+
const { messages } = await publint({ pkgDir });
|
|
163
|
+
if (messages.length) {
|
|
164
|
+
for (const message of messages) console.log(formatMessage(message, pkg));
|
|
165
|
+
const { yes } = await prompts({
|
|
166
|
+
type: "confirm",
|
|
167
|
+
name: "yes",
|
|
168
|
+
message: `${messages.length} messages from publint. Continue anyway?`
|
|
169
|
+
});
|
|
170
|
+
if (!yes) process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
if (!targetVersion) {
|
|
173
|
+
const { release } = await prompts({
|
|
174
|
+
type: "select",
|
|
175
|
+
name: "release",
|
|
176
|
+
message: "Select release type",
|
|
177
|
+
choices: getVersionChoices(pkg.version)
|
|
178
|
+
});
|
|
179
|
+
if (release === "custom") targetVersion = (await prompts({
|
|
180
|
+
type: "text",
|
|
181
|
+
name: "version",
|
|
182
|
+
message: "Input custom version",
|
|
183
|
+
initial: pkg.version
|
|
184
|
+
})).version;
|
|
185
|
+
else targetVersion = release;
|
|
186
|
+
}
|
|
187
|
+
if (!semver.valid(targetVersion)) throw new Error(`invalid target version: ${targetVersion}`);
|
|
188
|
+
const tag = toTag(selectedPkg, targetVersion);
|
|
189
|
+
if (targetVersion.includes("beta") && !args.tag) args.tag = "beta";
|
|
190
|
+
if (targetVersion.includes("alpha") && !args.tag) args.tag = "alpha";
|
|
191
|
+
const { yes } = await prompts({
|
|
192
|
+
type: "confirm",
|
|
193
|
+
name: "yes",
|
|
194
|
+
message: `Releasing ${colors.yellow(tag)} Confirm?`
|
|
195
|
+
});
|
|
196
|
+
if (!yes) return;
|
|
197
|
+
step("\nUpdating package version...");
|
|
198
|
+
updateVersion(pkgPath, targetVersion);
|
|
199
|
+
await generateChangelog(selectedPkg, targetVersion);
|
|
200
|
+
const { stdout } = await run("git", ["diff"], { nodeOptions: { stdio: "pipe" } });
|
|
201
|
+
if (stdout) {
|
|
202
|
+
step("\nCommitting changes...");
|
|
203
|
+
await runIfNotDry("git", ["add", "-A"]);
|
|
204
|
+
await runIfNotDry("git", [
|
|
205
|
+
"commit",
|
|
206
|
+
"-m",
|
|
207
|
+
`release: ${tag}`
|
|
208
|
+
]);
|
|
209
|
+
await runIfNotDry("git", [
|
|
210
|
+
"tag",
|
|
211
|
+
"-a",
|
|
212
|
+
"-m",
|
|
213
|
+
tag,
|
|
214
|
+
tag
|
|
215
|
+
]);
|
|
216
|
+
} else {
|
|
217
|
+
console.log("No changes to commit.");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
step("\nPushing to GitHub...");
|
|
221
|
+
await runIfNotDry("git", [
|
|
222
|
+
"push",
|
|
223
|
+
"origin",
|
|
224
|
+
`refs/tags/${tag}`
|
|
225
|
+
]);
|
|
226
|
+
await runIfNotDry("git", ["push"]);
|
|
227
|
+
if (isDryRun) console.log(`\nDry run finished - run git diff to see package changes.`);
|
|
228
|
+
else console.log(colors.green(`
|
|
267
229
|
Pushed, publishing should starts shortly on CI.
|
|
268
|
-
https://github.com/${org}/${repo}/actions/workflows/publish.yml`
|
|
269
|
-
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
console.log();
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// src/changelog.ts
|
|
276
|
-
import fs from "node:fs";
|
|
277
|
-
import path2 from "node:path";
|
|
278
|
-
import { ConventionalChangelog } from "conventional-changelog";
|
|
279
|
-
import createPreset, {
|
|
280
|
-
DEFAULT_COMMIT_TYPES
|
|
281
|
-
} from "conventional-changelog-conventionalcommits";
|
|
282
|
-
var generateChangelog = async ({
|
|
283
|
-
getPkgDir,
|
|
284
|
-
tagPrefix
|
|
285
|
-
}) => {
|
|
286
|
-
const preset = await createPreset({
|
|
287
|
-
types: DEFAULT_COMMIT_TYPES.map((t) => ({ ...t, hidden: false }))
|
|
288
|
-
});
|
|
289
|
-
preset.writer ??= {};
|
|
290
|
-
preset.writer.headerPartial = `
|
|
291
|
-
## {{#if isPatch~}} <small> {{~/if~}}
|
|
292
|
-
{{#if @root.linkCompare~}}
|
|
293
|
-
[{{version}}](
|
|
294
|
-
{{~#if @root.repository~}}
|
|
295
|
-
{{~#if @root.host}}
|
|
296
|
-
{{~@root.host}}/
|
|
297
|
-
{{~/if}}
|
|
298
|
-
{{~#if @root.owner}}
|
|
299
|
-
{{~@root.owner}}/
|
|
300
|
-
{{~/if}}
|
|
301
|
-
{{~@root.repository}}
|
|
302
|
-
{{~else}}
|
|
303
|
-
{{~@root.repoUrl}}
|
|
304
|
-
{{~/if~}}
|
|
305
|
-
/compare/{{previousTag}}...{{currentTag}})
|
|
306
|
-
{{~else}}
|
|
307
|
-
{{~version}}
|
|
308
|
-
{{~/if}}
|
|
309
|
-
{{~#if title}} "{{title}}"
|
|
310
|
-
{{~/if}}
|
|
311
|
-
{{~#if date}} ({{date}})
|
|
312
|
-
{{~/if}}
|
|
313
|
-
{{~#if isPatch~}} </small> {{~/if}}
|
|
314
|
-
`.trim();
|
|
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";
|
|
337
|
-
const pkgDir = getPkgDir();
|
|
338
|
-
const generator = new ConventionalChangelog(pkgDir).readPackage().config(preset).options({ releaseCount: 1 });
|
|
339
|
-
if (tagPrefix) {
|
|
340
|
-
generator.tags({ prefix: tagPrefix });
|
|
341
|
-
}
|
|
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"));
|
|
344
|
-
for await (const chunk of generator.write()) {
|
|
345
|
-
writeStream.write(chunk);
|
|
346
|
-
}
|
|
347
|
-
writeStream.write(originalChangelog);
|
|
230
|
+
https://github.com/${org}/${repo}/actions/workflows/publish.yml`));
|
|
231
|
+
console.log();
|
|
348
232
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/changelog.ts
|
|
235
|
+
const generateChangelog = async ({ getPkgDir, tagPrefix }) => {
|
|
236
|
+
const preset = createPreset({ types: DEFAULT_COMMIT_TYPES.map((t) => ({
|
|
237
|
+
...t,
|
|
238
|
+
effect: t.effect === "hidden" ? "changelog" : t.effect
|
|
239
|
+
})) });
|
|
240
|
+
preset.writer ??= {};
|
|
241
|
+
preset.writer.headerPartial = function(context) {
|
|
242
|
+
const { linkCompare, version, title, date, isPatch } = context;
|
|
243
|
+
const headingText = words(linkCompare ? link(version, compareUrl(context)) : version, title && `"${title}"`, date && `(${date})`);
|
|
244
|
+
return heading(2, isPatch ? `<small>${headingText}</small>` : headingText);
|
|
245
|
+
};
|
|
246
|
+
preset.writer.template = function(context) {
|
|
247
|
+
const { headerPartial, preamblePartial, commitPartial, footerPartial, noteGroups, commitGroups } = context;
|
|
248
|
+
return headerPartial(context) + "\n" + segments(preamblePartial(context), each(noteGroups, (group) => segments(heading(3, words("⚠", group.title)), list(group.notes, (_note) => {
|
|
249
|
+
const note = _note;
|
|
250
|
+
return words(note.commit.scope && bold(`${note.commit.scope}:`), note.commit.subject, note.commit.hash && `(${link(note.commit.shortHash, formatCommitUrl(context, note.commit))})`);
|
|
251
|
+
})), newline(2)), each(commitGroups, (group) => segments(group.title && heading(3, group.title), list(group.commits, (commit) => commitPartial(context, commit))), newline(2)), footerPartial(context));
|
|
252
|
+
};
|
|
253
|
+
const pkgDir = getPkgDir();
|
|
254
|
+
const generator = new ConventionalChangelog(pkgDir).readPackage().config(preset).options({ releaseCount: 1 }).commits({ path: "." });
|
|
255
|
+
if (tagPrefix) generator.tags({ prefix: tagPrefix });
|
|
256
|
+
const originalChangelog = fs.existsSync(path.join(pkgDir, "CHANGELOG.md")) ? fs.readFileSync(path.join(pkgDir, "CHANGELOG.md"), "utf-8") : "";
|
|
257
|
+
const writeStream = fs.createWriteStream(path.join(pkgDir, "CHANGELOG.md"));
|
|
258
|
+
for await (const chunk of generator.write()) writeStream.write(chunk);
|
|
259
|
+
writeStream.write("\n");
|
|
260
|
+
writeStream.write(originalChangelog);
|
|
353
261
|
};
|
|
262
|
+
//#endregion
|
|
263
|
+
export { generateChangelog, publish, release };
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/release-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "@vitejs release scripts",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"exports": "./dist/index.js",
|
|
11
6
|
"repository": {
|
|
12
7
|
"type": "git",
|
|
13
8
|
"url": "git+https://github.com/vitejs/release-scripts.git"
|
|
14
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": "./dist/index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "
|
|
16
|
+
"build": "rolldown -c",
|
|
17
17
|
"test": "vitest",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"qa": "tsc && pnpm prettier-ci && pnpm build && vitest run",
|
|
18
|
+
"format": "oxfmt",
|
|
19
|
+
"qa": "tsc && pnpm format --check && pnpm build && vitest run",
|
|
21
20
|
"release": "node scripts/release.ts"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"conventional-changelog": "^
|
|
25
|
-
"conventional-changelog
|
|
23
|
+
"@conventional-changelog/template": "^1.2.1",
|
|
24
|
+
"conventional-changelog": "^8.0.1",
|
|
25
|
+
"conventional-changelog-conventionalcommits": "^10.2.1",
|
|
26
26
|
"mri": "^1.2.0",
|
|
27
27
|
"picocolors": "^1.1.1",
|
|
28
28
|
"prompts": "^2.4.2",
|
|
29
|
-
"publint": "^0.3.
|
|
30
|
-
"semver": "^7.
|
|
31
|
-
"tinyexec": "^1.
|
|
29
|
+
"publint": "^0.3.21",
|
|
30
|
+
"semver": "^7.8.5",
|
|
31
|
+
"tinyexec": "^1.2.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^24.
|
|
34
|
+
"@types/node": "^24.13.2",
|
|
35
35
|
"@types/prompts": "^2.4.9",
|
|
36
36
|
"@types/semver": "^7.7.1",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
37
|
+
"fs-fixture": "^2.14.0",
|
|
38
|
+
"oxfmt": "^0.58.0",
|
|
39
|
+
"rolldown": "^1.1.4",
|
|
40
40
|
"typescript": "^6.0.3",
|
|
41
|
-
"vitest": "^4.1.
|
|
41
|
+
"vitest": "^4.1.10"
|
|
42
42
|
},
|
|
43
|
-
"packageManager": "pnpm@10.
|
|
43
|
+
"packageManager": "pnpm@11.10.0"
|
|
44
44
|
}
|