@varlet/release 2.2.2 → 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 CHANGED
@@ -162,6 +162,7 @@ Usage: vr publish [flags...]
162
162
  Flags:
163
163
  --check-remote-version Check remote version
164
164
  --npm-tag string npm tag
165
+ --otp string npm one-time password
165
166
  ```
166
167
 
167
168
  _Example_:
@@ -174,6 +175,8 @@ pnpm exec vr publish
174
175
  pnpm exec vr publish --check-remote-version
175
176
  # Specify the npm dist-tag
176
177
  pnpm exec vr publish --npm-tag alpha
178
+ # Publish with npm two-factor authentication
179
+ pnpm exec vr publish --otp 123456
177
180
  ```
178
181
 
179
182
  **Node API**:
@@ -185,6 +188,7 @@ publish({
185
188
  preRelease?: boolean // Pre-release indicator, will add the '--tag alpha' option
186
189
  checkRemoteVersion?: boolean // Check if the same version exists on the remote npm before publishing
187
190
  npmTag?: string // NPM tag to publish
191
+ otp?: string // npm one-time password
188
192
  cwd?: string // Working directory, defaults to process.cwd()
189
193
  })
190
194
  ```
package/README.zh-CN.md CHANGED
@@ -162,6 +162,7 @@ _标志参考_:
162
162
  标志:
163
163
  --check-remote-version 检查远程版本
164
164
  --npm-tag string npm tag
165
+ --otp string npm 一次性验证码
165
166
  ```
166
167
 
167
168
  _使用示例_:
@@ -174,6 +175,8 @@ pnpm exec vr publish
174
175
  pnpm exec vr publish --check-remote-version
175
176
  # 指定 npm 的 dist-tag
176
177
  pnpm exec vr publish --npm-tag alpha
178
+ # 使用 npm 双因素认证验证码发布
179
+ pnpm exec vr publish --otp 123456
177
180
  ```
178
181
 
179
182
  **Node 调用**:
@@ -185,6 +188,7 @@ publish({
185
188
  preRelease?: boolean // 预发布标示,将添加 '--tag alpha' 选项
186
189
  checkRemoteVersion?: boolean // 发布前检查远程 npm 上是否已存在相同版本
187
190
  npmTag?: string // 发布的 npm tag
191
+ otp?: string // npm 一次性验证码
188
192
  cwd?: string // 工作目录,默认为 process.cwd()
189
193
  })
190
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-Cz2-oOom.js";
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.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-Cz2-oOom.js";
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
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,7 +277,10 @@ 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);
@@ -346,7 +349,11 @@ function computeExpectVersion(currentVersion, type) {
346
349
  async function getReleaseType(currentVersion) {
347
350
  return unwrapPromptResult(await select({
348
351
  message: `Please select release type`,
349
- options: RELEASE_TYPES.map((type) => {
352
+ options: (semver.prerelease(currentVersion) ? [
353
+ ...RELEASE_TYPES.slice(0, 3),
354
+ "prerelease",
355
+ ...RELEASE_TYPES.slice(3)
356
+ ] : RELEASE_TYPES).map((type) => {
350
357
  return {
351
358
  label: `${type} (${computeExpectVersion(currentVersion, type)})`,
352
359
  value: type
@@ -365,6 +372,12 @@ async function getReleaseVersion(currentVersion) {
365
372
  };
366
373
  }
367
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
+ }
368
381
  async function restorePackageJsons(cwd = process.cwd()) {
369
382
  const paths = getPackageJsons(cwd).map(({ filePath }) => filePath);
370
383
  if (paths.length > 0) await execGit("restore", ...paths);
@@ -377,10 +390,7 @@ async function release(options) {
377
390
  logger.error("Your package is missing the version field");
378
391
  return;
379
392
  }
380
- if (!await isWorktreeEmpty()) {
381
- logger.error("Git worktree is not empty, please commit changed");
382
- return;
383
- }
393
+ if (!await isWorktreeEmpty()) logger.error("Git worktree is not empty, please commit changed");
384
394
  if (!await confirmRefs(options.remote)) return;
385
395
  if (!options.skipNpmPublish && !await confirmRegistry()) return;
386
396
  const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
@@ -390,11 +400,15 @@ async function release(options) {
390
400
  }
391
401
  updateVersion(expectVersion, cwd);
392
402
  if (options.task) await options.task(expectVersion, currentVersion);
393
- if (!options.skipNpmPublish) await publish({
394
- preRelease: isPreRelease,
395
- npmTag: options.npmTag,
396
- cwd
397
- });
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
+ }
398
412
  if (!isPreRelease) {
399
413
  if (!options.skipChangelog) await changelog({ cwd });
400
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.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,18 +30,18 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@clack/prompts": "^1.3.0",
33
+ "@clack/prompts": "^1.4.0",
34
34
  "cleye": "^2.6.0",
35
35
  "rslog": "^2.1.1",
36
- "semver": "^7.7.4",
36
+ "semver": "^7.8.1",
37
37
  "standard-changelog": "^7.0.1",
38
- "tinyexec": "^1.1.2"
38
+ "tinyexec": "^1.2.2"
39
39
  },
40
40
  "devDependencies": {
41
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.20260504.1",
44
+ "@typescript/native-preview": "7.0.0-dev.20260524.1",
45
45
  "@vitest/coverage-v8": "^4.1.5",
46
46
  "vite-plus": "latest"
47
47
  },