socket 1.1.114 → 1.1.116

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-default-org-slug.d.mts","sourceRoot":"","sources":["../../../../src/commands/ci/fetch-default-org-slug.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,sEAAsE;AACtE,wBAAsB,iBAAiB,CACrC,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAoD1B"}
1
+ {"version":3,"file":"fetch-default-org-slug.d.mts","sourceRoot":"","sources":["../../../../src/commands/ci/fetch-default-org-slug.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,sEAAsE;AACtE,wBAAsB,iBAAiB,CACrC,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAwD1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"dlx.d.mts","sourceRoot":"","sources":["../../../src/utils/dlx.mts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAMpE,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG;IAC1C,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC3C,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE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,GAClC,OAAO,CAAC,eAAe,CAAC,CAU1B;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,EAChC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,GAClC,OAAO,CAAC,eAAe,CAAC,CAU1B"}
package/dist/utils.js CHANGED
@@ -3821,7 +3821,12 @@ async function getDefaultOrgSlug(silence) {
3821
3821
  data: `No organization associated with the Socket API token. Unable to continue.`
3822
3822
  };
3823
3823
  }
3824
- const slug = organizations[keys[0]]?.name ?? undefined;
3824
+
3825
+ // Use the org's URL-safe `slug`, not its display `name`: this value is
3826
+ // exported as SOCKET_ORG_SLUG for the Coana CLI, which resolves the org by
3827
+ // slug. `name` is the human-readable display name (and may be null), so using
3828
+ // it here produced a wrong/empty org identifier.
3829
+ const slug = organizations[0]?.slug ?? undefined;
3825
3830
  if (!slug) {
3826
3831
  return {
3827
3832
  ok: false,
@@ -5469,6 +5474,18 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
5469
5474
  cwd: dlxOptions.cwd
5470
5475
  }, spawnExtra);
5471
5476
  }
5477
+
5478
+ // `shadowNpmBase` (the dlx launcher) configures the child's stdio from its
5479
+ // `options` arg, NOT from the registry-spawn `extra` arg — the latter only
5480
+ // attaches metadata to the result. Callers that requested streaming via
5481
+ // `spawnExtra` (the 4th arg), e.g. `{ stdio: 'inherit' }` from
5482
+ // `socket manifest gradle`, were therefore silently ignored on this path:
5483
+ // Coana ran piped and its output — including the real failure reason — never
5484
+ // reached the user, leaving only an unhelpful "command failed". Promote the
5485
+ // requested stdio into the dlx options so it is honored here too.
5486
+ // `spawnCoanaScriptViaNode` already reads `spawnExtra.stdio` for the
5487
+ // local-path and npm-install branches, so this aligns all three paths.
5488
+ const requestedStdio = spawnExtra?.['stdio'] ?? require$$11.getOwn(dlxOptions, 'stdio');
5472
5489
  try {
5473
5490
  // Use npm/dlx version.
5474
5491
  const result = await spawnDlx({
@@ -5476,8 +5493,16 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
5476
5493
  version: resolvedVersion
5477
5494
  }, args, {
5478
5495
  force: true,
5479
- silent: true,
5496
+ // Do NOT silence the launcher. `--silent` (npm loglevel silent) hides
5497
+ // npm's own download/registry/launch errors, so when npx/pnpm-dlx fails
5498
+ // to fetch @coana-tech/cli the user is left with a bare exit code and no
5499
+ // cause. shadowNpmBase defaults to `--loglevel error`, which keeps real
5500
+ // launcher errors visible while staying quiet on success.
5501
+ silent: false,
5480
5502
  ...dlxOptions,
5503
+ ...(requestedStdio === undefined ? {} : {
5504
+ stdio: requestedStdio
5505
+ }),
5481
5506
  env: finalEnv,
5482
5507
  ipc: {
5483
5508
  [constants.default.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
@@ -5503,7 +5528,7 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
5503
5528
  if (!shouldFallbackOnDlxError(e)) {
5504
5529
  return dlxError;
5505
5530
  }
5506
- logger.logger.warn('Coana dlx invocation failed before Coana started; falling back to `npm install` + `node`.');
5531
+ logger.logger.warn('Coana dlx invocation failed; retrying via `npm install` + `node`.');
5507
5532
  const fallbackResult = await spawnCoanaViaNpmInstall(args, resolvedVersion, finalEnv, {
5508
5533
  cwd: dlxOptions.cwd
5509
5534
  }, spawnExtra);
@@ -5539,10 +5564,29 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
5539
5564
  * rather than blindly re-running Coana.
5540
5565
  */
5541
5566
  function shouldFallbackOnDlxError(e) {
5542
- const capturedStderr = String(e?.stderr ?? '');
5543
- if (capturedStderr && /Coana CLI version/i.test(capturedStderr)) {
5567
+ // Coana clearly ran (its banner is in the captured stderr) any later
5568
+ // non-zero exit is a real Coana failure and retrying would hit it again.
5569
+ if (coanaBannerSeen(e)) {
5544
5570
  return false;
5545
5571
  }
5572
+ return dlxLauncherFailedBeforeCoana(e);
5573
+ }
5574
+
5575
+ /**
5576
+ * Heuristic: did the dlx launcher (npx / pnpm dlx / yarn dlx) fail BEFORE the
5577
+ * Coana process itself started? True for spawn-level errors (a string `code`
5578
+ * like ENOENT), signal kills, and exit codes >= 128 (conventionally
5579
+ * signal-derived) — all cases where the launcher, not Coana, is the culprit
5580
+ * (e.g. npx missing from PATH, or @coana-tech/cli failing to download). A small
5581
+ * integer exit code is deliberately NOT treated as a launch failure: Coana's
5582
+ * own exit codes are small integers too, so it is genuinely ambiguous.
5583
+ *
5584
+ * Caveat: a launcher that fails to download the package can also exit with a
5585
+ * small integer (npm/npx often exit 1), which lands in the ambiguous bucket.
5586
+ * We cannot disambiguate those from a real Coana exit without inspecting the
5587
+ * launcher's output, so the npm-install fallback does not fire for them.
5588
+ */
5589
+ function dlxLauncherFailedBeforeCoana(e) {
5546
5590
  const code = e?.code;
5547
5591
  // Spawn-level failure (e.g. ENOENT when npx is missing from PATH).
5548
5592
  if (typeof code === 'string') {
@@ -5554,10 +5598,18 @@ function shouldFallbackOnDlxError(e) {
5554
5598
  }
5555
5599
  // Exit codes >= 128 are conventionally signal-derived, and the observed
5556
5600
  // npx-launcher failures in the wild fall into this range (e.g. 249, 254).
5557
- if (typeof code === 'number' && code >= 128) {
5558
- return true;
5559
- }
5560
- return false;
5601
+ return typeof code === 'number' && code >= 128;
5602
+ }
5603
+
5604
+ /**
5605
+ * Definitive proof Coana actually booted: its startup banner appears in the
5606
+ * captured stderr. Only available when the launcher's output was piped
5607
+ * (captured); with inherited stdio there is nothing to inspect, so this
5608
+ * returns false (the failure is then classified by exit code / signal alone).
5609
+ */
5610
+ function coanaBannerSeen(e) {
5611
+ const capturedStderr = String(e?.stderr ?? '');
5612
+ return !!capturedStderr && /Coana CLI version/i.test(capturedStderr);
5561
5613
  }
5562
5614
 
5563
5615
  /**
@@ -5566,6 +5618,7 @@ function shouldFallbackOnDlxError(e) {
5566
5618
  */
5567
5619
  function buildDlxErrorResult(e) {
5568
5620
  const stderr = e?.stderr;
5621
+ const stdout = e?.stdout;
5569
5622
  const exitCode = e?.code;
5570
5623
  const signal = e?.signal;
5571
5624
  const cause = getErrorCause(e);
@@ -5577,7 +5630,29 @@ function buildDlxErrorResult(e) {
5577
5630
  details.push(`signal ${signal}`);
5578
5631
  }
5579
5632
  const detailSuffix = details.length ? ` (${details.join(', ')})` : '';
5580
- const message = stderr ? `Coana command failed${detailSuffix}: ${stderr}` : `Coana command failed${detailSuffix}: ${cause}`;
5633
+ // Prefer captured stderr, then stdout, then the generic spawn error. Coana
5634
+ // logs some failures (e.g. unresolved Gradle dependencies) to stdout, so
5635
+ // without the stdout fallback a piped failure collapsed to an unhelpful
5636
+ // "command failed" even when the real reason was captured.
5637
+ const detail = stderr || stdout || cause;
5638
+ // Be honest about WHERE the failure happened. On the dlx path the spawned
5639
+ // process is the package-manager launcher (npx / pnpm dlx / yarn dlx), which
5640
+ // downloads @coana-tech/cli and only then runs it — so a failure may be the
5641
+ // launcher dying before Coana ever started, not Coana itself. We can only be
5642
+ // CERTAIN of that for a spawn-level error (a string `code` like ENOENT: the
5643
+ // launcher binary could not start, so Coana provably never ran). A non-zero
5644
+ // exit or signal is genuinely ambiguous — Coana may have started, streamed
5645
+ // output, and then died (e.g. OOM), or the launcher may have failed to fetch
5646
+ // the package — and with inherited stdio there is no captured output to tell
5647
+ // them apart, so we must not assert either way.
5648
+ let message;
5649
+ if (coanaBannerSeen(e)) {
5650
+ message = `Coana command failed${detailSuffix}: ${detail}`;
5651
+ } else if (typeof e?.code === 'string') {
5652
+ message = `Failed to launch Coana via the package manager${detailSuffix} — the npx/pnpm-dlx/yarn-dlx launcher could not start (e.g. it is missing from PATH): ${detail}`;
5653
+ } else {
5654
+ message = `Coana failed to run via the package manager${detailSuffix}: ${detail}`;
5655
+ }
5581
5656
  return {
5582
5657
  ok: false,
5583
5658
  data: e,
@@ -8280,5 +8355,5 @@ exports.updateConfigValue = updateConfigValue;
8280
8355
  exports.walkNestedMap = walkNestedMap;
8281
8356
  exports.webLink = webLink;
8282
8357
  exports.writeSocketJson = writeSocketJson;
8283
- //# debugId=3b36bb48-c24b-4b38-abfd-00291354493e
8358
+ //# debugId=94ef2183-dca4-487d-a212-97d72c67367e
8284
8359
  //# sourceMappingURL=utils.js.map