chapa-cli 0.2.4 → 0.2.5

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 (2) hide show
  1. package/dist/index.js +24 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -343,6 +343,24 @@ var TLS_ERROR_PATTERNS = [
343
343
  function isTlsError(message) {
344
344
  return TLS_ERROR_PATTERNS.some((p) => message.includes(p));
345
345
  }
346
+ function getRootErrorMessage(err) {
347
+ let current = err;
348
+ let message = "";
349
+ while (current instanceof Error) {
350
+ message = current.message;
351
+ current = current.cause;
352
+ }
353
+ return message;
354
+ }
355
+ function getFullErrorChain(err) {
356
+ const messages = [];
357
+ let current = err;
358
+ while (current instanceof Error) {
359
+ messages.push(current.message);
360
+ current = current.cause;
361
+ }
362
+ return messages.join(" | ");
363
+ }
346
364
  async function login(serverUrl, opts = {}) {
347
365
  const { verbose = false, insecure = false } = opts;
348
366
  const originalTlsSetting = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
@@ -387,13 +405,14 @@ Server returned ${res.status}. Retrying...`);
387
405
  console.error(`[poll ${i + 1}] ${data?.status ?? "no status"}`);
388
406
  }
389
407
  } catch (err) {
390
- const errMsg = err.message;
408
+ const rootMsg = getRootErrorMessage(err);
409
+ const fullChain = getFullErrorChain(err);
391
410
  if (verbose) {
392
- console.error(`[poll ${i + 1}] network error: ${errMsg}`);
411
+ console.error(`[poll ${i + 1}] network error: ${rootMsg}`);
393
412
  }
394
- if (!insecure && isTlsError(errMsg)) {
413
+ if (!insecure && isTlsError(fullChain)) {
395
414
  console.error(`
396
- TLS certificate error: ${errMsg}`);
415
+ TLS certificate error: ${rootMsg}`);
397
416
  console.error("This looks like a corporate network with TLS interception.");
398
417
  console.error(" try: chapa login --insecure\n");
399
418
  }
@@ -423,7 +442,7 @@ Logged in as ${data.handle}!`);
423
442
  }
424
443
 
425
444
  // src/index.ts
426
- var VERSION = true ? "0.2.4" : "0.0.0-dev";
445
+ var VERSION = true ? "0.2.5" : "0.0.0-dev";
427
446
  var HELP_TEXT = `chapa-cli v${VERSION}
428
447
 
429
448
  Merge GitHub EMU (Enterprise Managed User) contributions into your Chapa badge.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chapa-cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Merge GitHub EMU contributions into your Chapa developer impact badge",
5
5
  "type": "module",
6
6
  "bin": {