pkg-pr-new 0.0.60 → 0.0.62
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.
- package/dist/index.js +72 -28
- package/index.ts +70 -32
- 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";
|
|
@@ -143,20 +144,25 @@ const main = defineCommand({
|
|
|
143
144
|
const isOnlyTemplates = !!args["only-templates"];
|
|
144
145
|
const isBinaryApplication = !!args.bin;
|
|
145
146
|
const comment: Comment = args.comment as Comment;
|
|
146
|
-
const selectedPackageManager = args.packageManager as
|
|
147
|
-
|
|
148
|
-
| "bun"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
!["npm", "bun", "pnpm", "yarn"].includes(selectedPackageManager)
|
|
154
|
-
) {
|
|
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) {
|
|
155
153
|
console.error(
|
|
156
|
-
`Unsupported package manager: ${
|
|
154
|
+
`Unsupported package manager: ${args.packageManager}. Supported managers are npm, bun, pnpm, yarn.`,
|
|
157
155
|
);
|
|
158
156
|
process.exit(1);
|
|
159
157
|
}
|
|
158
|
+
for (let i = 0; i < selectedPackageManager.length; i++) {
|
|
159
|
+
if (!packageManagers.includes(selectedPackageManager[i])) {
|
|
160
|
+
console.error(
|
|
161
|
+
`Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn.`,
|
|
162
|
+
);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
160
166
|
|
|
161
167
|
if (!process.env.TEST && process.env.GITHUB_ACTIONS !== "true") {
|
|
162
168
|
console.error(
|
|
@@ -185,17 +191,26 @@ const main = defineCommand({
|
|
|
185
191
|
|
|
186
192
|
const key = hash(metadata);
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
let checkResponse;
|
|
195
|
+
try {
|
|
196
|
+
checkResponse = await fetch(new URL("/check", apiUrl), {
|
|
197
|
+
method: "POST",
|
|
198
|
+
body: JSON.stringify({
|
|
199
|
+
owner,
|
|
200
|
+
repo,
|
|
201
|
+
key,
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error(`Failed to connect to server: ${error}`);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
196
208
|
|
|
197
209
|
if (!checkResponse.ok) {
|
|
198
|
-
|
|
210
|
+
const errorText = await checkResponse.text();
|
|
211
|
+
console.error(
|
|
212
|
+
`Check failed (${checkResponse.status}): ${errorText}`,
|
|
213
|
+
);
|
|
199
214
|
process.exit(1);
|
|
200
215
|
}
|
|
201
216
|
|
|
@@ -241,12 +256,26 @@ const main = defineCommand({
|
|
|
241
256
|
realDeps?.set(pJson.name, pJson.version ?? longDepUrl);
|
|
242
257
|
|
|
243
258
|
const controller = new AbortController();
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
259
|
+
try {
|
|
260
|
+
const resource = await fetch(longDepUrl, {
|
|
261
|
+
signal: controller.signal,
|
|
262
|
+
});
|
|
263
|
+
if (resource.ok) {
|
|
264
|
+
console.warn(
|
|
265
|
+
`${pJson.name}@${formattedSha} was already published on ${longDepUrl}`,
|
|
266
|
+
);
|
|
267
|
+
} else if (resource.status >= 500) {
|
|
268
|
+
console.warn(
|
|
269
|
+
`Server error checking ${longDepUrl} (${resource.status}), proceeding with publish`,
|
|
270
|
+
);
|
|
271
|
+
} else {
|
|
272
|
+
console.warn(
|
|
273
|
+
`Unexpected response checking ${longDepUrl} (${resource.status})`,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
} catch (error) {
|
|
248
277
|
console.warn(
|
|
249
|
-
|
|
278
|
+
`Failed to check if package exists at ${longDepUrl}: ${error}`,
|
|
250
279
|
);
|
|
251
280
|
}
|
|
252
281
|
controller.abort();
|
|
@@ -511,17 +540,26 @@ const main = defineCommand({
|
|
|
511
540
|
"sb-shasums": JSON.stringify(shasums),
|
|
512
541
|
"sb-run-id": GITHUB_RUN_ID,
|
|
513
542
|
"sb-bin": `${isBinaryApplication}`,
|
|
514
|
-
"sb-package-manager": selectedPackageManager,
|
|
543
|
+
"sb-package-manager": selectedPackageManager.join(","),
|
|
515
544
|
"sb-only-templates": `${isOnlyTemplates}`,
|
|
516
545
|
},
|
|
517
546
|
body: formData,
|
|
518
547
|
});
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
res.
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
548
|
+
|
|
549
|
+
if (!res.ok) {
|
|
550
|
+
const errorText = await res.text();
|
|
551
|
+
console.error(`Publishing failed (${res.status}): ${errorText}`);
|
|
552
|
+
process.exit(1);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let laterRes;
|
|
556
|
+
try {
|
|
557
|
+
laterRes = await res.json();
|
|
558
|
+
} catch (error) {
|
|
559
|
+
console.error(`Failed to parse server response as JSON: ${error}`);
|
|
560
|
+
console.error(`Raw response: ${await res.text()}`);
|
|
561
|
+
process.exit(1);
|
|
562
|
+
}
|
|
525
563
|
|
|
526
564
|
const debug = laterRes.debug;
|
|
527
565
|
|
|
@@ -544,7 +582,7 @@ const main = defineCommand({
|
|
|
544
582
|
return `${packageName}:
|
|
545
583
|
- sha: ${shasums[packageName]}
|
|
546
584
|
- publint: ${publintUrl}
|
|
547
|
-
-
|
|
585
|
+
- ${packMethod}: ${installCommands[packMethod]} ${url}`;
|
|
548
586
|
})
|
|
549
587
|
.join("\n\n");
|
|
550
588
|
|