pkg-pr-new 0.0.59 → 0.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +31 -8
  2. package/index.ts +28 -14
  3. package/package.json +1 -1
package/index.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  abbreviateCommitHash,
14
14
  extractOwnerAndRepo,
15
15
  extractRepository,
16
+ installCommands,
16
17
  } from "@pkg-pr-new/utils";
17
18
  import { glob } from "tinyglobby";
18
19
  import ignore from "ignore";
@@ -74,6 +75,10 @@ const main = defineCommand({
74
75
  type: "boolean",
75
76
  description: "use `yarn pack` instead of `npm pack --json`",
76
77
  },
78
+ bun: {
79
+ type: "boolean",
80
+ description: "use `bun pm pack` instead of `npm pack --json`",
81
+ },
77
82
  template: {
78
83
  type: "string",
79
84
  description:
@@ -131,26 +136,33 @@ const main = defineCommand({
131
136
  packMethod = "pnpm";
132
137
  } else if (args.yarn) {
133
138
  packMethod = "yarn";
139
+ } else if (args.bun) {
140
+ packMethod = "bun";
134
141
  }
135
142
 
136
143
  const isPeerDepsEnabled = !!args.peerDeps;
137
144
  const isOnlyTemplates = !!args["only-templates"];
138
145
  const isBinaryApplication = !!args.bin;
139
146
  const comment: Comment = args.comment as Comment;
140
- const selectedPackageManager = args.packageManager as
141
- | "npm"
142
- | "bun"
143
- | "pnpm"
144
- | "yarn";
145
-
146
- if (
147
- !["npm", "bun", "pnpm", "yarn"].includes(selectedPackageManager)
148
- ) {
147
+ const selectedPackageManager = (args.packageManager as string)
148
+ .split(",")
149
+ .filter((s) => s.trim()) as Array<"npm" | "bun" | "pnpm" | "yarn">;
150
+ const packageManagers = ["npm", "bun", "pnpm", "yarn"];
151
+
152
+ if (!selectedPackageManager.length) {
149
153
  console.error(
150
- `Unsupported package manager: ${selectedPackageManager}. Supported managers are npm, bun, pnpm, yarn.`,
154
+ `Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn.`,
151
155
  );
152
156
  process.exit(1);
153
157
  }
158
+ for (let i = 0; i < packageManagers.length; i++) {
159
+ if (!packageManagers.includes(packageManagers[i])) {
160
+ console.error(
161
+ `Unsupported package manager: ${packageManagers[i]}. Supported managers are npm, bun, pnpm, yarn.`,
162
+ );
163
+ process.exit(1);
164
+ }
165
+ }
154
166
 
155
167
  if (!process.env.TEST && process.env.GITHUB_ACTIONS !== "true") {
156
168
  console.error(
@@ -505,7 +517,7 @@ const main = defineCommand({
505
517
  "sb-shasums": JSON.stringify(shasums),
506
518
  "sb-run-id": GITHUB_RUN_ID,
507
519
  "sb-bin": `${isBinaryApplication}`,
508
- "sb-package-manager": selectedPackageManager,
520
+ "sb-package-manager": selectedPackageManager[0],
509
521
  "sb-only-templates": `${isOnlyTemplates}`,
510
522
  },
511
523
  body: formData,
@@ -538,7 +550,7 @@ const main = defineCommand({
538
550
  return `${packageName}:
539
551
  - sha: ${shasums[packageName]}
540
552
  - publint: ${publintUrl}
541
- - npm: npm i ${url}`;
553
+ - ${packMethod}: ${installCommands[packMethod]} ${url}`;
542
554
  })
543
555
  .join("\n\n");
544
556
 
@@ -582,13 +594,15 @@ runMain(main)
582
594
  .then(() => process.exit(0))
583
595
  .catch(() => process.exit(1));
584
596
 
585
- type PackMethod = "npm" | "pnpm" | "yarn";
597
+ type PackMethod = "npm" | "pnpm" | "yarn" | "bun";
586
598
 
587
599
  async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) {
588
600
  let cmd = `${pm} pack`;
589
601
  let filename = `${pJson.name!.replace("/", "-")}-${pJson.version}.tgz`;
590
602
  if (pm === "yarn") {
591
603
  cmd += ` --filename ${filename}`;
604
+ } else if (pm === "bun") {
605
+ cmd = `bun pm pack --filename ${filename}`;
592
606
  }
593
607
  const { stdout } = await ezSpawn.async(cmd, {
594
608
  stdio: "overlapped",
@@ -596,7 +610,7 @@ async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) {
596
610
  });
597
611
  const lines = stdout.split("\n").filter(Boolean);
598
612
 
599
- if (pm !== "yarn") {
613
+ if (pm !== "yarn" && pm !== "bun") {
600
614
  filename = lines[lines.length - 1].trim();
601
615
  }
602
616
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pkg-pr-new",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",