Skip to content

Commit 5e3a62c

Browse files
authored
feat: support upm and nub in --packageManager flag (#562)
1 parent 9201a0a commit 5e3a62c

5 files changed

Lines changed: 39 additions & 27 deletions

File tree

‎README.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ pnpm exec pkg-pr-new publish './artifacts/*.tgz'
103103

104104
Quick reference:
105105

106-
| Flag | Description |
107-
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
108-
| `--comment=update\|create\|off` | How PR comments are posted (default: `update`) |
109-
| `--commentWithSha` | Use commit SHA URLs instead of PR number URLs in comments |
110-
| `--commentWithDev` | Add the `-D` flag to install commands in comments |
111-
| `--packageManager=npm\|pnpm\|yarn\|bun` | Package manager(s) shown in comments; accepts comma-separated values |
112-
| `--only-templates` | Show only templates in comments |
113-
| `--template './examples/*'` | Generate StackBlitz templates for the given directories (experimental) |
114-
| `--no-template` | Disable the default template |
115-
| `--no-compact` | Force long-form URLs instead of compact URLs |
116-
| `--bin` | Show `npx` instead of `npm i` in comments |
117-
| `--previewVersion` | Rewrite package versions to `0.0.0-preview-<sha>` before packing |
118-
| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` |
119-
| `--json <file>` | Write publish metadata to a JSON file (see [Custom GitHub Messages and Comments](#custom-github-messages-and-comments)) |
106+
| Flag | Description |
107+
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
108+
| `--comment=update\|create\|off` | How PR comments are posted (default: `update`) |
109+
| `--commentWithSha` | Use commit SHA URLs instead of PR number URLs in comments |
110+
| `--commentWithDev` | Add the `-D` flag to install commands in comments |
111+
| `--packageManager=npm\|pnpm\|yarn\|bun\|upm\|nub` | Package manager(s) shown in comments; accepts comma-separated values |
112+
| `--only-templates` | Show only templates in comments |
113+
| `--template './examples/*'` | Generate StackBlitz templates for the given directories (experimental) |
114+
| `--no-template` | Disable the default template |
115+
| `--no-compact` | Force long-form URLs instead of compact URLs |
116+
| `--bin` | Show `npx` instead of `npm i` in comments |
117+
| `--previewVersion` | Rewrite package versions to `0.0.0-preview-<sha>` before packing |
118+
| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` |
119+
| `--json <file>` | Write publish metadata to a JSON file (see [Custom GitHub Messages and Comments](#custom-github-messages-and-comments)) |
120120

121121
#### Comment Options
122122

@@ -180,7 +180,7 @@ npm i https://pkg.pr.new/tinybench@123
180180

181181
**`--packageManager`**
182182

183-
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`.
183+
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`.
184184

185185
**`--only-templates`**
186186

‎packages/app/server/utils/markdown.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ const installCommands: Record<PackageManager, string> = {
77
pnpm: "pnpm add",
88
yarn: "yarn add",
99
bun: "bun add",
10+
upm: "upm add",
11+
nub: "nub add",
1012
};
1113

1214
const binCommands: Record<PackageManager, string> = {
1315
npm: "npx",
1416
pnpm: "pnpm dlx",
1517
yarn: "npx",
1618
bun: "bunx",
19+
upm: "upx",
20+
nub: "nubx",
1721
};
1822
const isMoreThanFourPackages = (
1923
packages: string[],

‎packages/cli/index.ts‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { hash } from "ohash";
77
import ezSpawn from "@jsdevtools/ez-spawn";
88
import { defineCommand, runMain } from "citty";
99
import { getPackageManifest, type PackageManifest } from "query-registry";
10-
import type { Comment } from "@pkg-pr-new/utils";
10+
import type { Comment, PackageManager } from "@pkg-pr-new/utils";
1111
import {
1212
abbreviateCommitHash,
1313
extractOwnerAndRepo,
@@ -113,8 +113,8 @@ const main = defineCommand({
113113
packageManager: {
114114
type: "string",
115115
description:
116-
"Specify the package manager to use (npm, bun, pnpm, yarn). Comma-separated values are supported.",
117-
enum: ["npm", "bun", "pnpm", "yarn"],
116+
"Specify the package manager to use (npm, bun, pnpm, yarn, upm, nub). Comma-separated values are supported.",
117+
enum: ["npm", "bun", "pnpm", "yarn", "upm", "nub"],
118118
default: "npm",
119119
},
120120
bin: {
@@ -219,23 +219,28 @@ const main = defineCommand({
219219
...new Set(
220220
(args.packageManager as string)
221221
.split(",")
222-
.filter((s) => s.trim()) as Array<
223-
"npm" | "bun" | "pnpm" | "yarn"
224-
>,
222+
.filter((s) => s.trim()) as PackageManager[],
225223
),
226224
];
227-
const packageManagers = ["npm", "bun", "pnpm", "yarn"];
225+
const packageManagers: PackageManager[] = [
226+
"npm",
227+
"bun",
228+
"pnpm",
229+
"yarn",
230+
"upm",
231+
"nub",
232+
];
228233

229234
if (!selectedPackageManager.length) {
230235
console.error(
231-
`Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn.`,
236+
`Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn, upm, nub.`,
232237
);
233238
process.exit(1);
234239
}
235240
for (let i = 0; i < selectedPackageManager.length; i++) {
236241
if (!packageManagers.includes(selectedPackageManager[i])) {
237242
console.error(
238-
`Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn.`,
243+
`Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn, upm, nub.`,
239244
);
240245
process.exit(1);
241246
}

‎packages/cli/template.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import type { PackageManager } from "@pkg-pr-new/utils";
12
import { installCommands } from "@pkg-pr-new/utils";
23

34
function generateShellCommand(
45
url: string,
56
isCommentWithDev: boolean,
6-
selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[],
7+
selectedPackageManager: PackageManager[],
78
) {
89
return selectedPackageManager
910
.map(
@@ -16,7 +17,7 @@ function generateShellCommand(
1617
export const createDefaultTemplate = (
1718
dependencies: Record<string, string>,
1819
isCommentWithDev: boolean,
19-
selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[],
20+
selectedPackageManager: PackageManager[],
2021
) => ({
2122
"index.js": "",
2223
"README.md": `

‎packages/utils/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ export function isPullRequest(ref: string) {
5252
}
5353

5454
export type Comment = "off" | "create" | "update";
55-
export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
55+
export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "upm" | "nub";
5656

5757
export const installCommands: Record<PackageManager, string> = {
5858
npm: "npm i",
5959
pnpm: "pnpm add",
6060
yarn: "yarn add",
6161
bun: "bun add",
62+
upm: "upm add",
63+
nub: "nub add",
6264
};
6365

6466
const whitelist =

0 commit comments

Comments
 (0)