Skip to content

Commit

Permalink
feat: add --only-templates flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sadeghbarati committed Aug 15, 2024
1 parent 76eae52 commit af3bdd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/backend/server/routes/publish.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default eventHandler(async (event) => {
"sb-comment": commentHeader,
"sb-compact": compactHeader,
"sb-package-manager": packageManagerHeader,
"sb-only-templates": onlyTemplatesHeader,
} = getHeaders(event);
const compact = compactHeader === "true";
const onlyTemplates = onlyTemplatesHeader === "true";
const comment: Comment = (commentHeader ?? "update") as Comment;
const packageManager: PackageManager =
(packageManagerHeader as PackageManager) || "npm";
Expand Down Expand Up @@ -230,6 +232,7 @@ export default eventHandler(async (event) => {
packagesWithoutPrefix,
workflowData,
compact,
onlyTemplates,
checkRunUrl,
packageManager,
"ref",
Expand All @@ -249,6 +252,7 @@ export default eventHandler(async (event) => {
packagesWithoutPrefix,
workflowData,
compact,
onlyTemplates,
checkRunUrl,
packageManager,
comment === "update" ? "ref" : "sha",
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/server/utils/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function generatePullRequestPublishMessage(
packages: string[],
workflowData: WorkflowData,
compact: boolean,
onlyTemplates: boolean,
checkRunUrl: string,
packageManager: PackageManager,
base: "sha" | "ref",
Expand Down Expand Up @@ -80,6 +81,10 @@ ${packageManager} ${packageCommands[packageManager]} ${refUrl}

const templatesStr = generateTemplatesStr(templates);

if(onlyTemplates) {
return templatesStr
}

return `
_commit: <a href="${checkRunUrl}"><code>${abbreviateCommitHash(workflowData.sha)}</code></a>_
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ 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",
},
onlyTemplates: {
type: "boolean",
description: `generate only stackblitz templates`,
default: false,
},
},
run: async ({ args }) => {
const paths = (args._.length ? args._ : ["."])
Expand All @@ -83,6 +88,7 @@ const main = defineCommand({
const isCompact = !!args.compact;
const isPnpm = !!args.pnpm;
const isPeerDepsEnabled = !!args.peerDeps
const isOnlyTemplates = !!args.onlyTemplates

const comment: Comment = args.comment as Comment;

Expand Down Expand Up @@ -299,6 +305,7 @@ const main = defineCommand({
"sb-shasums": JSON.stringify(shasums),
"sb-run-id": GITHUB_RUN_ID,
"sb-package-manager": packageManager,
"sb-only-templates": `${isOnlyTemplates}`
},
body: formData,
});
Expand Down

0 comments on commit af3bdd3

Please sign in to comment.