pkg-pr-new 0.0.61 → 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.
Files changed (3) hide show
  1. package/dist/index.js +56 -27
  2. package/index.ts +56 -24
  3. package/package.json +1 -1
package/index.ts CHANGED
@@ -155,10 +155,10 @@ const main = defineCommand({
155
155
  );
156
156
  process.exit(1);
157
157
  }
158
- for (let i = 0; i < packageManagers.length; i++) {
159
- if (!packageManagers.includes(packageManagers[i])) {
158
+ for (let i = 0; i < selectedPackageManager.length; i++) {
159
+ if (!packageManagers.includes(selectedPackageManager[i])) {
160
160
  console.error(
161
- `Unsupported package manager: ${packageManagers[i]}. Supported managers are npm, bun, pnpm, yarn.`,
161
+ `Unsupported package manager: ${selectedPackageManager[i]}. Supported managers are npm, bun, pnpm, yarn.`,
162
162
  );
163
163
  process.exit(1);
164
164
  }
@@ -191,17 +191,26 @@ const main = defineCommand({
191
191
 
192
192
  const key = hash(metadata);
193
193
 
194
- const checkResponse = await fetch(new URL("/check", apiUrl), {
195
- method: "POST",
196
- body: JSON.stringify({
197
- owner,
198
- repo,
199
- key,
200
- }),
201
- });
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
+ }
202
208
 
203
209
  if (!checkResponse.ok) {
204
- console.error(await checkResponse.text());
210
+ const errorText = await checkResponse.text();
211
+ console.error(
212
+ `Check failed (${checkResponse.status}): ${errorText}`,
213
+ );
205
214
  process.exit(1);
206
215
  }
207
216
 
@@ -247,12 +256,26 @@ const main = defineCommand({
247
256
  realDeps?.set(pJson.name, pJson.version ?? longDepUrl);
248
257
 
249
258
  const controller = new AbortController();
250
- const resource = await fetch(longDepUrl, {
251
- signal: controller.signal,
252
- });
253
- if (resource.ok) {
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) {
254
277
  console.warn(
255
- `${pJson.name}@${formattedSha} was already published on ${longDepUrl}`,
278
+ `Failed to check if package exists at ${longDepUrl}: ${error}`,
256
279
  );
257
280
  }
258
281
  controller.abort();
@@ -517,17 +540,26 @@ const main = defineCommand({
517
540
  "sb-shasums": JSON.stringify(shasums),
518
541
  "sb-run-id": GITHUB_RUN_ID,
519
542
  "sb-bin": `${isBinaryApplication}`,
520
- "sb-package-manager": selectedPackageManager[0],
543
+ "sb-package-manager": selectedPackageManager.join(","),
521
544
  "sb-only-templates": `${isOnlyTemplates}`,
522
545
  },
523
546
  body: formData,
524
547
  });
525
- const laterRes = await res.clone().json();
526
- assert.equal(
527
- res.status,
528
- 200,
529
- `publishing failed: ${await res.text()}`,
530
- );
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
+ }
531
563
 
532
564
  const debug = laterRes.debug;
533
565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pkg-pr-new",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",