diff --git a/README.md b/README.md index 759e8052..f5bd72b6 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ 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. -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. +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. diff --git a/packages/app/server/utils/markdown.ts b/packages/app/server/utils/markdown.ts index e5bcb277..028d5ab2 100644 --- a/packages/app/server/utils/markdown.ts +++ b/packages/app/server/utils/markdown.ts @@ -35,18 +35,22 @@ export function generateCommitPublishMessage( workflowData, compact, ); - - if (packageManager === "yarn") { - shaUrl = `${shaUrl}.tgz`; - } - - const descriptor = `${packageManager === "yarn" ? `${packageName}@` : ""}${shaUrl}`; - - return ` -\`\`\` -${bin ? binCommands[packageManager] : installCommands[packageManager]} ${descriptor} -\`\`\` - `; + return packageManager + .split(",") + .map((pm) => { + if (pm === "yarn") { + shaUrl = `${shaUrl}.tgz`; + } + + const descriptor = `${pm === "yarn" ? `${packageName}@` : ""}${shaUrl}`; + + return ` + \`\`\` + ${bin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${descriptor} + \`\`\` + `; + }) + .join("\n"); }) .map((message, i) => isMoreThanFour @@ -86,16 +90,20 @@ export function generatePullRequestPublishMessage( workflowData, compact, ); - - if (packageManager === "yarn") { - refUrl = `${refUrl}.tgz`; - } - - return ` -\`\`\` -${bin ? binCommands[packageManager] : installCommands[packageManager]} ${refUrl} -\`\`\` -`; + return packageManager + .split(",") + .map((pm) => { + if (pm === "yarn") { + refUrl = `${refUrl}.tgz`; + } + + return ` + \`\`\` + ${bin ? binCommands[pm as PackageManager] : installCommands[pm as PackageManager]} ${refUrl} + \`\`\` + `; + }) + .join("\n"); }) .map((message, i) => isMoreThanFour diff --git a/packages/cli/index.ts b/packages/cli/index.ts index d7a5c706..2f024039 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -143,20 +143,25 @@ const main = defineCommand({ const isOnlyTemplates = !!args["only-templates"]; const isBinaryApplication = !!args.bin; const comment: Comment = args.comment as Comment; - const selectedPackageManager = args.packageManager as - | "npm" - | "bun" - | "pnpm" - | "yarn"; - - if ( - !["npm", "bun", "pnpm", "yarn"].includes(selectedPackageManager) - ) { + const selectedPackageManager = (args.packageManager as string) + .split(",") + .filter((s) => s.trim()) as Array<"npm" | "bun" | "pnpm" | "yarn">; + const packageManagers = ["npm", "bun", "pnpm", "yarn"]; + + if (!selectedPackageManager.length) { console.error( - `Unsupported package manager: ${selectedPackageManager}. Supported managers are npm, bun, pnpm, yarn.`, + `Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn.`, ); process.exit(1); } + for (let i = 0; i < packageManagers.length; i++) { + if (!packageManagers.includes(packageManagers[i])) { + console.error( + `Unsupported package manager: ${packageManagers[i]}. Supported managers are npm, bun, pnpm, yarn.`, + ); + process.exit(1); + } + } if (!process.env.TEST && process.env.GITHUB_ACTIONS !== "true") { console.error( @@ -511,7 +516,7 @@ const main = defineCommand({ "sb-shasums": JSON.stringify(shasums), "sb-run-id": GITHUB_RUN_ID, "sb-bin": `${isBinaryApplication}`, - "sb-package-manager": selectedPackageManager, + "sb-package-manager": selectedPackageManager[0], "sb-only-templates": `${isOnlyTemplates}`, }, body: formData,