Skip to content
Merged
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ With `--comment=create`, each commit would generate a comment for itself, useful

And `--comment=off` would turn off comments for maintainers who prefer minimal pull requests.

> `--commentWithSha` specify whether to replace the pr number with sha commit in the generated comments.

With `--commentWithSha`:

```sh
npm i https://pkg.pr.new/tinybench@a832a55
```

Without `--commentWithSha`:

```sh
npm i https://pkg.pr.new/tinybench@123
```

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`.

For repositories with many packages, comments might get too long. In that case, you can use `--only-templates` to only show templates.
Expand Down
4 changes: 3 additions & 1 deletion packages/app/server/routes/publish.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export default eventHandler(async (event) => {
"sb-bin": binHeader,
"sb-package-manager": packageManagerHeader,
"sb-only-templates": onlyTemplatesHeader,
"sb-comment-with-sha": commentWithShaHeader,
} = getHeaders(event);
const compact = compactHeader === "true";
const onlyTemplates = onlyTemplatesHeader === "true";
const comment: Comment = (commentHeader ?? "update") as Comment;
const bin = binHeader === "true";
const packageManager: PackageManager =
(packageManagerHeader as PackageManager) || "npm";
const commentWithSha = commentWithShaHeader === "true";

if (!key || !runIdHeader || !shasumsHeader) {
throw createError({
Expand Down Expand Up @@ -290,7 +292,7 @@ export default eventHandler(async (event) => {
onlyTemplates,
checkRunUrl,
packageManager,
"ref",
commentWithSha ? "sha" : "ref",
bin,
),
},
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable unicorn/no-process-exit */
import assert from "node:assert";
import path from "node:path";
import { createHash } from "node:crypto";
import fsSync from "node:fs";
Expand Down Expand Up @@ -89,6 +88,12 @@ const main = defineCommand({
description: `"off" for no comments (silent mode). "create" for comment on each publish. "update" for one comment across the pull request with edits on each publish (default)`,
default: "update",
},
commentWithSha: {
type: "boolean",
description:
"use commit sha instead of the pr number in the comment links",
default: false,
},
"only-templates": {
type: "boolean",
description: `generate only stackblitz templates`,
Expand Down Expand Up @@ -143,6 +148,7 @@ const main = defineCommand({
const isPeerDepsEnabled = !!args.peerDeps;
const isOnlyTemplates = !!args["only-templates"];
const isBinaryApplication = !!args.bin;
const isCommentWithSha = !!args.commentWithSha;
const comment: Comment = args.comment as Comment;
const selectedPackageManager = (args.packageManager as string)
.split(",")
Expand Down Expand Up @@ -542,6 +548,7 @@ const main = defineCommand({
"sb-bin": `${isBinaryApplication}`,
"sb-package-manager": selectedPackageManager.join(","),
"sb-only-templates": `${isOnlyTemplates}`,
"sb-comment-with-sha": `${isCommentWithSha}`,
},
body: formData,
});
Expand Down
Loading