Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<sha>` before packing |
| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` |
| `--json <file>` | 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-<sha>` before packing |
| `--pnpm` / `--yarn` / `--bun` | Use `pnpm pack`, `yarn pack`, or `bun pm pack` instead of `npm pack` |
| `--json <file>` | Write publish metadata to a JSON file (see [Custom GitHub Messages and Comments](#custom-github-messages-and-comments)) |

#### Comment Options

Expand Down Expand Up @@ -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`.

**`--only-templates`**

Expand Down
4 changes: 4 additions & 0 deletions packages/app/server/utils/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ const installCommands: Record<PackageManager, string> = {
pnpm: "pnpm add",
yarn: "yarn add",
bun: "bun add",
upm: "upm add",
nub: "nub add",
};

const binCommands: Record<PackageManager, string> = {
npm: "npx",
pnpm: "pnpm dlx",
yarn: "npx",
bun: "bunx",
upm: "upx",
nub: "nubx",
};
const isMoreThanFourPackages = (
packages: string[],
Expand Down
23 changes: 14 additions & 9 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -219,23 +219,28 @@ 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);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/template.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -16,7 +17,7 @@ function generateShellCommand(
export const createDefaultTemplate = (
dependencies: Record<string, string>,
isCommentWithDev: boolean,
selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[],
selectedPackageManager: PackageManager[],
) => ({
"index.js": "",
"README.md": `
Expand Down
4 changes: 3 additions & 1 deletion packages/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackageManager, string> = {
npm: "npm i",
pnpm: "pnpm add",
yarn: "yarn add",
bun: "bun add",
upm: "upm add",
nub: "nub add",
};

const whitelist =
Expand Down
Loading