@varlet/release 2.2.1 → 2.2.3-alpha.1779709734936
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 +6 -0
- package/README.zh-CN.md +6 -0
- package/dist/cli.js +7 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/{src-DwRUa0a2.js → src-DR5i3Sn4.js} +31 -23
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
> `Varlet Release` requires `Node.js` ^20.19.0 || >=22.12.0 and `esm` only.
|
|
22
22
|
|
|
23
|
+
If you are upgrading from `v1` to `v2`, read the [migration guide](./MIGRATION.md) first.
|
|
24
|
+
|
|
23
25
|
## Quick Start
|
|
24
26
|
|
|
25
27
|
Install dependencies:
|
|
@@ -160,6 +162,7 @@ Usage: vr publish [flags...]
|
|
|
160
162
|
Flags:
|
|
161
163
|
--check-remote-version Check remote version
|
|
162
164
|
--npm-tag string npm tag
|
|
165
|
+
--otp string npm one-time password
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
_Example_:
|
|
@@ -172,6 +175,8 @@ pnpm exec vr publish
|
|
|
172
175
|
pnpm exec vr publish --check-remote-version
|
|
173
176
|
# Specify the npm dist-tag
|
|
174
177
|
pnpm exec vr publish --npm-tag alpha
|
|
178
|
+
# Publish with npm two-factor authentication
|
|
179
|
+
pnpm exec vr publish --otp 123456
|
|
175
180
|
```
|
|
176
181
|
|
|
177
182
|
**Node API**:
|
|
@@ -183,6 +188,7 @@ publish({
|
|
|
183
188
|
preRelease?: boolean // Pre-release indicator, will add the '--tag alpha' option
|
|
184
189
|
checkRemoteVersion?: boolean // Check if the same version exists on the remote npm before publishing
|
|
185
190
|
npmTag?: string // NPM tag to publish
|
|
191
|
+
otp?: string // npm one-time password
|
|
186
192
|
cwd?: string // Working directory, defaults to process.cwd()
|
|
187
193
|
})
|
|
188
194
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
> `Varlet Release` 需要 `Node.js` ^20.19.0 || >=22.12.0,并且仅支持 `esm`。
|
|
22
22
|
|
|
23
|
+
从 `v1` 升级到 `v2` 时,请先阅读 [迁移指南](./MIGRATION.zh-CN.md)。
|
|
24
|
+
|
|
23
25
|
## 快速开始
|
|
24
26
|
|
|
25
27
|
安装依赖:
|
|
@@ -160,6 +162,7 @@ _标志参考_:
|
|
|
160
162
|
标志:
|
|
161
163
|
--check-remote-version 检查远程版本
|
|
162
164
|
--npm-tag string npm tag
|
|
165
|
+
--otp string npm 一次性验证码
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
_使用示例_:
|
|
@@ -172,6 +175,8 @@ pnpm exec vr publish
|
|
|
172
175
|
pnpm exec vr publish --check-remote-version
|
|
173
176
|
# 指定 npm 的 dist-tag
|
|
174
177
|
pnpm exec vr publish --npm-tag alpha
|
|
178
|
+
# 使用 npm 双因素认证验证码发布
|
|
179
|
+
pnpm exec vr publish --otp 123456
|
|
175
180
|
```
|
|
176
181
|
|
|
177
182
|
**Node 调用**:
|
|
@@ -183,6 +188,7 @@ publish({
|
|
|
183
188
|
preRelease?: boolean // 预发布标示,将添加 '--tag alpha' 选项
|
|
184
189
|
checkRemoteVersion?: boolean // 发布前检查远程 npm 上是否已存在相同版本
|
|
185
190
|
npmTag?: string // 发布的 npm tag
|
|
191
|
+
otp?: string // npm 一次性验证码
|
|
186
192
|
cwd?: string // 工作目录,默认为 process.cwd()
|
|
187
193
|
})
|
|
188
194
|
```
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as release, i as lockfileCheck, p as commitLint, s as publish, u as changelog } from "./src-
|
|
2
|
+
import { c as release, i as lockfileCheck, p as commitLint, s as publish, u as changelog } from "./src-DR5i3Sn4.js";
|
|
3
3
|
import { cli, command } from "cleye";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/cli.ts
|
|
6
6
|
cli({
|
|
7
7
|
name: "vr",
|
|
8
|
-
version: "2.2.
|
|
8
|
+
version: "2.2.3-alpha.1779709734936",
|
|
9
9
|
commands: [
|
|
10
10
|
command({
|
|
11
11
|
name: "release",
|
|
@@ -53,6 +53,11 @@ cli({
|
|
|
53
53
|
type: String,
|
|
54
54
|
alias: "t",
|
|
55
55
|
description: "Npm tag"
|
|
56
|
+
},
|
|
57
|
+
otp: {
|
|
58
|
+
type: String,
|
|
59
|
+
alias: "o",
|
|
60
|
+
description: "Npm one-time password"
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
help: { description: "Publish to npm" }
|
package/dist/index.d.ts
CHANGED
|
@@ -15,12 +15,14 @@ interface PublishCommandOptions {
|
|
|
15
15
|
preRelease?: boolean;
|
|
16
16
|
checkRemoteVersion?: boolean;
|
|
17
17
|
npmTag?: string;
|
|
18
|
+
otp?: string;
|
|
18
19
|
cwd?: string;
|
|
19
20
|
}
|
|
20
21
|
declare function publish({
|
|
21
22
|
preRelease,
|
|
22
23
|
checkRemoteVersion,
|
|
23
24
|
npmTag,
|
|
25
|
+
otp,
|
|
24
26
|
cwd
|
|
25
27
|
}: PublishCommandOptions): Promise<void>;
|
|
26
28
|
declare function getPackageJsons(cwd?: string): PackageJsonEntry[];
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getPackageJsons, c as release, d as COMMIT_HEADER_RE, f as COMMIT_MESSAGE_RE, h as isVersionCommitMessage, i as lockfileCheck, l as updateVersion, m as getCommitMessage, n as getLockfilePath, o as isSameVersion, p as commitLint, r as installDependencies, s as publish, t as checkLockfileSync, u as changelog } from "./src-
|
|
1
|
+
import { a as getPackageJsons, c as release, d as COMMIT_HEADER_RE, f as COMMIT_MESSAGE_RE, h as isVersionCommitMessage, i as lockfileCheck, l as updateVersion, m as getCommitMessage, n as getLockfilePath, o as isSameVersion, p as commitLint, r as installDependencies, s as publish, t as checkLockfileSync, u as changelog } from "./src-DR5i3Sn4.js";
|
|
2
2
|
export { COMMIT_HEADER_RE, COMMIT_MESSAGE_RE, changelog, checkLockfileSync, commitLint, getCommitMessage, getLockfilePath, getPackageJsons, installDependencies, isSameVersion, isVersionCommitMessage, lockfileCheck, publish, release, updateVersion };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createWriteStream,
|
|
1
|
+
import { createWriteStream, globSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
|
-
import { cancel, confirm, isCancel, select, spinner } from "@clack/prompts";
|
|
4
|
+
import { cancel, confirm, isCancel, select, spinner, text } from "@clack/prompts";
|
|
5
5
|
import { logger } from "rslog";
|
|
6
6
|
import semver from "semver";
|
|
7
7
|
import { x } from "tinyexec";
|
|
@@ -261,7 +261,7 @@ async function isSameVersion(version, cwd = process.cwd()) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
async function publish({ preRelease, checkRemoteVersion, npmTag, cwd = process.cwd() }) {
|
|
264
|
+
async function publish({ preRelease, checkRemoteVersion, npmTag, otp, cwd = process.cwd() }) {
|
|
265
265
|
const s = spinner();
|
|
266
266
|
s.start("Publishing all packages");
|
|
267
267
|
const args = [
|
|
@@ -277,13 +277,16 @@ async function publish({ preRelease, checkRemoteVersion, npmTag, cwd = process.c
|
|
|
277
277
|
}
|
|
278
278
|
if (preRelease) args.push("--tag", "alpha");
|
|
279
279
|
else if (npmTag) args.push("--tag", npmTag);
|
|
280
|
+
const normalizedOtp = otp?.trim();
|
|
281
|
+
if (normalizedOtp) args.push("--otp", normalizedOtp);
|
|
280
282
|
try {
|
|
283
|
+
console.log("pnpm", args);
|
|
281
284
|
const ret = await x("pnpm", args, { throwOnError: true });
|
|
282
285
|
s.stop("Publish all packages successfully");
|
|
283
286
|
logStdout(ret);
|
|
284
287
|
} catch (error) {
|
|
285
288
|
s.cancel("Publish all packages failed");
|
|
286
|
-
throw error?.output?.stderr
|
|
289
|
+
throw error?.output?.stderr || error?.output?.stdout || error;
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
@@ -300,13 +303,7 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
300
303
|
logStdout(ret);
|
|
301
304
|
}
|
|
302
305
|
function getPackageJsons(cwd = process.cwd()) {
|
|
303
|
-
|
|
304
|
-
const packagesDir = resolve(cwd, "packages");
|
|
305
|
-
if (existsSync(packagesDir)) for (const name of readdirSync(packagesDir)) {
|
|
306
|
-
const pkgPath = resolve(packagesDir, name, "package.json");
|
|
307
|
-
if (existsSync(pkgPath)) packageJsonPaths.push(pkgPath);
|
|
308
|
-
}
|
|
309
|
-
return packageJsonPaths.map((path) => ({
|
|
306
|
+
return ["package.json", "packages/*/package.json"].flatMap((pattern) => globSync(pattern, { cwd }).map((relativePath) => resolve(cwd, relativePath))).map((path) => ({
|
|
310
307
|
filePath: path,
|
|
311
308
|
config: readJSONSync(path)
|
|
312
309
|
}));
|
|
@@ -329,7 +326,7 @@ async function confirmVersion(currentVersion, expectVersion) {
|
|
|
329
326
|
return unwrapPromptResult(await select({
|
|
330
327
|
message: "Version confirm",
|
|
331
328
|
options: [{
|
|
332
|
-
label: `All packages version ${currentVersion} -> ${expectVersion}`,
|
|
329
|
+
label: `All packages version ${styleText("red", currentVersion)} -> ${styleText("green", expectVersion)}`,
|
|
333
330
|
value: "confirm"
|
|
334
331
|
}, {
|
|
335
332
|
label: "Back to previous step",
|
|
@@ -351,8 +348,12 @@ function computeExpectVersion(currentVersion, type) {
|
|
|
351
348
|
}
|
|
352
349
|
async function getReleaseType(currentVersion) {
|
|
353
350
|
return unwrapPromptResult(await select({
|
|
354
|
-
message: `Please select release type
|
|
355
|
-
options:
|
|
351
|
+
message: `Please select release type`,
|
|
352
|
+
options: (semver.prerelease(currentVersion) ? [
|
|
353
|
+
...RELEASE_TYPES.slice(0, 3),
|
|
354
|
+
"prerelease",
|
|
355
|
+
...RELEASE_TYPES.slice(3)
|
|
356
|
+
] : RELEASE_TYPES).map((type) => {
|
|
356
357
|
return {
|
|
357
358
|
label: `${type} (${computeExpectVersion(currentVersion, type)})`,
|
|
358
359
|
value: type
|
|
@@ -371,6 +372,12 @@ async function getReleaseVersion(currentVersion) {
|
|
|
371
372
|
};
|
|
372
373
|
}
|
|
373
374
|
}
|
|
375
|
+
async function getPublishOtp() {
|
|
376
|
+
return unwrapPromptResult(await text({
|
|
377
|
+
message: "Please input npm otp",
|
|
378
|
+
placeholder: "Press enter to skip"
|
|
379
|
+
})).trim();
|
|
380
|
+
}
|
|
374
381
|
async function restorePackageJsons(cwd = process.cwd()) {
|
|
375
382
|
const paths = getPackageJsons(cwd).map(({ filePath }) => filePath);
|
|
376
383
|
if (paths.length > 0) await execGit("restore", ...paths);
|
|
@@ -383,10 +390,7 @@ async function release(options) {
|
|
|
383
390
|
logger.error("Your package is missing the version field");
|
|
384
391
|
return;
|
|
385
392
|
}
|
|
386
|
-
if (!await isWorktreeEmpty())
|
|
387
|
-
logger.error("Git worktree is not empty, please commit changed");
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
393
|
+
if (!await isWorktreeEmpty()) logger.error("Git worktree is not empty, please commit changed");
|
|
390
394
|
if (!await confirmRefs(options.remote)) return;
|
|
391
395
|
if (!options.skipNpmPublish && !await confirmRegistry()) return;
|
|
392
396
|
const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
|
|
@@ -396,11 +400,15 @@ async function release(options) {
|
|
|
396
400
|
}
|
|
397
401
|
updateVersion(expectVersion, cwd);
|
|
398
402
|
if (options.task) await options.task(expectVersion, currentVersion);
|
|
399
|
-
if (!options.skipNpmPublish)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
if (!options.skipNpmPublish) {
|
|
404
|
+
const otp = await getPublishOtp();
|
|
405
|
+
await publish({
|
|
406
|
+
preRelease: isPreRelease,
|
|
407
|
+
npmTag: options.npmTag,
|
|
408
|
+
otp,
|
|
409
|
+
cwd
|
|
410
|
+
});
|
|
411
|
+
}
|
|
404
412
|
if (!isPreRelease) {
|
|
405
413
|
if (!options.skipChangelog) await changelog({ cwd });
|
|
406
414
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/release",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3-alpha.1779709734936",
|
|
4
4
|
"description": "publish all packages, generate changelogs and check commit messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"changelog",
|
|
@@ -30,20 +30,19 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@clack/prompts": "^1.
|
|
34
|
-
"cleye": "^2.
|
|
33
|
+
"@clack/prompts": "^1.4.0",
|
|
34
|
+
"cleye": "^2.6.0",
|
|
35
35
|
"rslog": "^2.1.1",
|
|
36
|
-
"semver": "^7.
|
|
36
|
+
"semver": "^7.8.1",
|
|
37
37
|
"standard-changelog": "^7.0.1",
|
|
38
|
-
"tinyexec": "^1.
|
|
38
|
+
"tinyexec": "^1.2.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@configurajs/vite-plus": "^0.2.
|
|
41
|
+
"@configurajs/vite-plus": "^0.2.6",
|
|
42
42
|
"@types/node": "^22.14.0",
|
|
43
43
|
"@types/semver": "^7.7.1",
|
|
44
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
45
|
-
"@vitest/coverage-v8": "^4.1.
|
|
46
|
-
"conventional-changelog-angular": "^8.3.1",
|
|
44
|
+
"@typescript/native-preview": "7.0.0-dev.20260524.1",
|
|
45
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
47
46
|
"vite-plus": "latest"
|
|
48
47
|
},
|
|
49
48
|
"engines": {
|