From db6b426393e849826f609c1d0f5419467c4224bd Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 12 Oct 2026 08:42:24 +0800 Subject: [PATCH 1/2] feat: support upm and nub in --packageManager flag --- README.md | 30 +++++++++++----------- packages/app/server/utils/markdown.ts | 8 +++--- packages/cli/index.ts | 36 ++++++++++++++++++++------- packages/cli/template.ts | 5 ++-- packages/utils/index.ts | 4 ++- 5 files changed, 53 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index dd1457d7..07dddf3e 100644 --- a/README.md +++ b/README.md @@ -103,20 +103,20 @@ pnpm exec pkg-pr-new publish './artifacts/*.tgz' Quick reference: -| Flag | Description | -| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -| `--comment=update\|create\|off` | How PR comments are posted (default: `update`) | -| `--commentWithSha` | Use commit SHA URLs instead of PR number URLs in comments | -| `--commentWithDev` | Add the `-D` flag to install commands in comments | -| `--packageManager=npm\|pnpm\|yarn\|bun` | Package manager(s) shown in comments; accepts comma-separated values | -| `--only-templates` | Show only templates in comments | -| `--template './examples/*'` | Generate StackBlitz templates for the given directories (experimental) | -| `--no-template` | Disable the default template | -| `--no-compact` | Force long-form URLs instead of compact URLs | -| `--bin` | Show `npx` instead of `npm i` in comments | -| `--previewVersion` | Rewrite package versions to `0.0.0-preview-` before packing | -| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` | -| `--json ` | Write publish metadata to a JSON file (see [Custom GitHub Messages and Comments](#custom-github-messages-and-comments)) | +| Flag | Description | +| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | +| `--comment=update\|create\|off` | How PR comments are posted (default: `update`) | +| `--commentWithSha` | Use commit SHA URLs instead of PR number URLs in comments | +| `--commentWithDev` | Add the `-D` flag to install commands in comments | +| `--packageManager=npm\|pnpm\|yarn\|bun\|upm\|nub` | Package manager(s) shown in comments; accepts comma-separated values | +| `--only-templates` | Show only templates in comments | +| `--template './examples/*'` | Generate StackBlitz templates for the given directories (experimental) | +| `--no-template` | Disable the default template | +| `--no-compact` | Force long-form URLs instead of compact URLs | +| `--bin` | Show `npx` instead of `npm i` in comments | +| `--previewVersion` | Rewrite package versions to `0.0.0-preview-` before packing | +| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` | +| `--json ` | Write publish metadata to a JSON file (see [Custom GitHub Messages and Comments](#custom-github-messages-and-comments)) | #### Comment Options @@ -180,7 +180,7 @@ npm i https://pkg.pr.new/tinybench@123 **`--packageManager`** -To customize which package manager is reflected in the comments, use the `--packageManager=XYZ` flag. XYZ can be one of the following: npm (default), pnpm, yarn, or bun. Multiple valid values can also be configured at the same time, such as `--packageManager=ABC,XYZ`. +To customize which package manager is reflected in the comments, use the `--packageManager=XYZ` flag. XYZ can be one of the following: npm (default), pnpm, yarn, bun, upm, or nub. Multiple valid values can also be configured at the same time, such as `--packageManager=ABC,XYZ`. Note that `upm` and `nub` cannot be combined with `--bin`, since they have no run-command equivalent. **`--only-templates`** diff --git a/packages/app/server/utils/markdown.ts b/packages/app/server/utils/markdown.ts index bc803e95..7bd4d0f5 100644 --- a/packages/app/server/utils/markdown.ts +++ b/packages/app/server/utils/markdown.ts @@ -7,9 +7,11 @@ const installCommands: Record = { pnpm: "pnpm add", yarn: "yarn add", bun: "bun add", + upm: "upm add", + nub: "nub add", }; -const binCommands: Record = { +const binCommands: Partial> = { npm: "npx", pnpm: "pnpm dlx", yarn: "npx", @@ -52,7 +54,7 @@ export function generateCommitPublishMessage( return ` \`\`\` - ${packageIsBin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${descriptor} + ${(packageIsBin && binCommands[pm as PackageManager]) || installCommands[pm as PackageManager]} ${descriptor} \`\`\` `; }) @@ -107,7 +109,7 @@ export function generatePullRequestPublishMessage( return ` \`\`\` - ${packageIsBin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${refUrl + (commentWithDev ? " -D" : "")} + ${(packageIsBin && binCommands[pm as PackageManager]) || installCommands[pm as PackageManager]} ${refUrl + (commentWithDev ? " -D" : "")} \`\`\` `; }) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index b06c3a83..df0667c6 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -7,7 +7,7 @@ import { hash } from "ohash"; import ezSpawn from "@jsdevtools/ez-spawn"; import { defineCommand, runMain } from "citty"; import { getPackageManifest, type PackageManifest } from "query-registry"; -import type { Comment } from "@pkg-pr-new/utils"; +import type { Comment, PackageManager } from "@pkg-pr-new/utils"; import { abbreviateCommitHash, extractOwnerAndRepo, @@ -113,8 +113,8 @@ const main = defineCommand({ packageManager: { type: "string", description: - "Specify the package manager to use (npm, bun, pnpm, yarn). Comma-separated values are supported.", - enum: ["npm", "bun", "pnpm", "yarn"], + "Specify the package manager to use (npm, bun, pnpm, yarn, upm, nub). Comma-separated values are supported.", + enum: ["npm", "bun", "pnpm", "yarn", "upm", "nub"], default: "npm", }, bin: { @@ -219,28 +219,46 @@ const main = defineCommand({ ...new Set( (args.packageManager as string) .split(",") - .filter((s) => s.trim()) as Array< - "npm" | "bun" | "pnpm" | "yarn" - >, + .filter((s) => s.trim()) as PackageManager[], ), ]; - const packageManagers = ["npm", "bun", "pnpm", "yarn"]; + const packageManagers: PackageManager[] = [ + "npm", + "bun", + "pnpm", + "yarn", + "upm", + "nub", + ]; if (!selectedPackageManager.length) { console.error( - `Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn.`, + `Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn, upm, nub.`, ); process.exit(1); } for (let i = 0; i < selectedPackageManager.length; i++) { if (!packageManagers.includes(selectedPackageManager[i])) { console.error( - `Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn.`, + `Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn, upm, nub.`, ); process.exit(1); } } + const noRunCommandManagers = selectedPackageManager.filter((pm) => + ["upm", "nub"].includes(pm), + ); + if ( + (binAllPackages || binExplicitNames.length > 0) && + noRunCommandManagers.length > 0 + ) { + console.error( + `pkg-pr-new: --bin is not supported with --packageManager=${noRunCommandManagers.join(",")} because ${noRunCommandManagers.join(" and ")} ${noRunCommandManagers.length > 1 ? "have" : "has"} no run-command equivalent (npx, pnpm dlx, ...).`, + ); + process.exit(1); + } + if (!process.env.TEST && process.env.GITHUB_ACTIONS !== "true") { console.error( "Continuous Releases are only available in GitHub Actions.", diff --git a/packages/cli/template.ts b/packages/cli/template.ts index 2cd30ebf..b5237710 100644 --- a/packages/cli/template.ts +++ b/packages/cli/template.ts @@ -1,9 +1,10 @@ +import type { PackageManager } from "@pkg-pr-new/utils"; import { installCommands } from "@pkg-pr-new/utils"; function generateShellCommand( url: string, isCommentWithDev: boolean, - selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[], + selectedPackageManager: PackageManager[], ) { return selectedPackageManager .map( @@ -16,7 +17,7 @@ function generateShellCommand( export const createDefaultTemplate = ( dependencies: Record, isCommentWithDev: boolean, - selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[], + selectedPackageManager: PackageManager[], ) => ({ "index.js": "", "README.md": ` diff --git a/packages/utils/index.ts b/packages/utils/index.ts index 833eb4c4..f453bbf4 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -52,13 +52,15 @@ export function isPullRequest(ref: string) { } export type Comment = "off" | "create" | "update"; -export type PackageManager = "npm" | "pnpm" | "yarn" | "bun"; +export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "upm" | "nub"; export const installCommands: Record = { npm: "npm i", pnpm: "pnpm add", yarn: "yarn add", bun: "bun add", + upm: "upm add", + nub: "nub add", }; const whitelist = From ce8f2efd90c01928b504381e72ef2de3f9e55c36 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 12 Oct 2026 08:50:52 +0800 Subject: [PATCH 2/2] fix: update --- README.md | 2 +- packages/app/server/utils/markdown.ts | 8 +++++--- packages/cli/index.ts | 13 ------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 07dddf3e..0dc376ca 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ npm i https://pkg.pr.new/tinybench@123 **`--packageManager`** -To customize which package manager is reflected in the comments, use the `--packageManager=XYZ` flag. XYZ can be one of the following: npm (default), pnpm, yarn, bun, upm, or nub. Multiple valid values can also be configured at the same time, such as `--packageManager=ABC,XYZ`. Note that `upm` and `nub` cannot be combined with `--bin`, since they have no run-command equivalent. +To customize which package manager is reflected in the comments, use the `--packageManager=XYZ` flag. XYZ can be one of the following: npm (default), pnpm, yarn, bun, upm, or nub. Multiple valid values can also be configured at the same time, such as `--packageManager=ABC,XYZ`. **`--only-templates`** diff --git a/packages/app/server/utils/markdown.ts b/packages/app/server/utils/markdown.ts index 7bd4d0f5..9753b8e4 100644 --- a/packages/app/server/utils/markdown.ts +++ b/packages/app/server/utils/markdown.ts @@ -11,11 +11,13 @@ const installCommands: Record = { nub: "nub add", }; -const binCommands: Partial> = { +const binCommands: Record = { npm: "npx", pnpm: "pnpm dlx", yarn: "npx", bun: "bunx", + upm: "upx", + nub: "nubx", }; const isMoreThanFourPackages = ( packages: string[], @@ -54,7 +56,7 @@ export function generateCommitPublishMessage( return ` \`\`\` - ${(packageIsBin && binCommands[pm as PackageManager]) || installCommands[pm as PackageManager]} ${descriptor} + ${packageIsBin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${descriptor} \`\`\` `; }) @@ -109,7 +111,7 @@ export function generatePullRequestPublishMessage( return ` \`\`\` - ${(packageIsBin && binCommands[pm as PackageManager]) || installCommands[pm as PackageManager]} ${refUrl + (commentWithDev ? " -D" : "")} + ${packageIsBin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${refUrl + (commentWithDev ? " -D" : "")} \`\`\` `; }) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index df0667c6..7708bbfc 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -246,19 +246,6 @@ const main = defineCommand({ } } - const noRunCommandManagers = selectedPackageManager.filter((pm) => - ["upm", "nub"].includes(pm), - ); - if ( - (binAllPackages || binExplicitNames.length > 0) && - noRunCommandManagers.length > 0 - ) { - console.error( - `pkg-pr-new: --bin is not supported with --packageManager=${noRunCommandManagers.join(",")} because ${noRunCommandManagers.join(" and ")} ${noRunCommandManagers.length > 1 ? "have" : "has"} no run-command equivalent (npx, pnpm dlx, ...).`, - ); - process.exit(1); - } - if (!process.env.TEST && process.env.GITHUB_ACTIONS !== "true") { console.error( "Continuous Releases are only available in GitHub Actions.",