@usesocial/cli 0.19.9 → 0.19.10
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/CHANGELOG.md +6 -0
- package/dist/index.mjs +42 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @usesocial/cli
|
|
2
2
|
|
|
3
|
+
## 0.19.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154](https://github.com/usesocial/monorepo/pull/154) [`6cf8bd8`](https://github.com/usesocial/monorepo/commit/6cf8bd8cb2cad1b577eef28bc11176a398b99251) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Classify wrapped sync access denials as expected CLI failures while preserving safe telemetry.
|
|
8
|
+
|
|
3
9
|
## 0.19.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.mjs
CHANGED
|
@@ -24845,7 +24845,7 @@ function createEnv(opts) {
|
|
|
24845
24845
|
}
|
|
24846
24846
|
//#endregion
|
|
24847
24847
|
//#region package.json
|
|
24848
|
-
var version$1 = "0.19.
|
|
24848
|
+
var version$1 = "0.19.10";
|
|
24849
24849
|
//#endregion
|
|
24850
24850
|
//#region src/lib/env.ts
|
|
24851
24851
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -31533,20 +31533,42 @@ var SilentExit = class extends Error {
|
|
|
31533
31533
|
this.code = code;
|
|
31534
31534
|
}
|
|
31535
31535
|
};
|
|
31536
|
+
const isKnownCLIError = (error) => error instanceof SilentExit || error instanceof ZodError || isCittyUsageError(error) || error instanceof UsageError || error instanceof CancelledError || error instanceof AuthError || error instanceof NotFoundError || error instanceof CLIAPIError;
|
|
31537
|
+
const isClassifiedCittyUsageError = (error) => error instanceof Error && error.name === "CLIError" && "code" in error && typeof error.code === "string";
|
|
31538
|
+
/** Returns the first known CLI/API error in a bounded cause chain. */
|
|
31539
|
+
const classificationErrorFor = (error) => {
|
|
31540
|
+
let candidate = error;
|
|
31541
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31542
|
+
for (let depth = 0; depth < 5; depth += 1) {
|
|
31543
|
+
if (isKnownCLIError(candidate)) return candidate;
|
|
31544
|
+
if (!(candidate && typeof candidate === "object")) break;
|
|
31545
|
+
if (seen.has(candidate)) break;
|
|
31546
|
+
seen.add(candidate);
|
|
31547
|
+
if (!("cause" in candidate)) break;
|
|
31548
|
+
candidate = candidate.cause;
|
|
31549
|
+
}
|
|
31550
|
+
};
|
|
31536
31551
|
const exitCodeFor = (error) => {
|
|
31537
|
-
|
|
31538
|
-
if (
|
|
31539
|
-
if (
|
|
31540
|
-
if (
|
|
31541
|
-
if (
|
|
31542
|
-
if (
|
|
31543
|
-
|
|
31544
|
-
|
|
31545
|
-
if (
|
|
31546
|
-
if (
|
|
31552
|
+
const classified = classificationErrorFor(error);
|
|
31553
|
+
if (!classified) return EXIT.api;
|
|
31554
|
+
if (classified instanceof SilentExit) return classified.code;
|
|
31555
|
+
if (classified instanceof ZodError || isClassifiedCittyUsageError(classified)) return EXIT.usage;
|
|
31556
|
+
if (classified instanceof UsageError || classified instanceof CancelledError) return EXIT.usage;
|
|
31557
|
+
if (classified instanceof AuthError) return EXIT.auth;
|
|
31558
|
+
if (classified instanceof NotFoundError) return EXIT.notFound;
|
|
31559
|
+
if (classified instanceof CLIAPIError) {
|
|
31560
|
+
if (classified.status === 404) return EXIT.notFound;
|
|
31561
|
+
if (classified.status === 401 || classified.status === 403) return EXIT.auth;
|
|
31562
|
+
if (classified.status === 429) return EXIT.rateLimited;
|
|
31563
|
+
if (classified.status >= 400) return EXIT.api;
|
|
31547
31564
|
}
|
|
31548
31565
|
return EXIT.api;
|
|
31549
31566
|
};
|
|
31567
|
+
const isExpectedFailure = (error, exitCode) => {
|
|
31568
|
+
if (exitCode === EXIT.usage || exitCode === EXIT.auth || exitCode === EXIT.notFound || exitCode === EXIT.rateLimited) return true;
|
|
31569
|
+
const classified = classificationErrorFor(error);
|
|
31570
|
+
return classified instanceof CLIAPIError && classified.status < 500;
|
|
31571
|
+
};
|
|
31550
31572
|
//#endregion
|
|
31551
31573
|
//#region src/lib/analytics.ts
|
|
31552
31574
|
/**
|
|
@@ -31654,17 +31676,19 @@ const topFrameLabel = (error) => {
|
|
|
31654
31676
|
return frame ? `${frame.functionName}@${frame.basename}:${frame.line}` : void 0;
|
|
31655
31677
|
};
|
|
31656
31678
|
const failureFingerprint = (error, command) => {
|
|
31657
|
-
|
|
31658
|
-
|
|
31659
|
-
|
|
31679
|
+
const metadata = errorMetadata(error);
|
|
31680
|
+
const classified = metadata?.name === "SyncPageError" && metadata._tag === "SyncPageError" ? classificationErrorFor(error) : error;
|
|
31681
|
+
if (classified instanceof CLIAPIError) return `CLIAPIError:${classified.status}:${classified.code ?? "unknown"}`;
|
|
31682
|
+
if (classified instanceof ZodError) {
|
|
31683
|
+
const [issue] = classified.issues;
|
|
31660
31684
|
const issuePath = issue?.path.map(String).join(".") || "unknown";
|
|
31661
31685
|
return `ZodError:${command ?? "unknown"}:${issuePath}:${issue?.code ?? "unknown"}`;
|
|
31662
31686
|
}
|
|
31663
|
-
if (
|
|
31664
|
-
const code = cittyErrorCode(
|
|
31687
|
+
if (classified instanceof Error) {
|
|
31688
|
+
const code = cittyErrorCode(classified);
|
|
31665
31689
|
if (code !== void 0) return `CLIError:${code}:${command ?? "unknown"}`;
|
|
31666
31690
|
}
|
|
31667
|
-
if (isTypedCLIError(
|
|
31691
|
+
if (isTypedCLIError(classified)) return `${classified.name}:${command ?? "unknown"}`;
|
|
31668
31692
|
return `${errorName(error)}:unknown:${topFrameLabel(error) ?? "unknown"}`;
|
|
31669
31693
|
};
|
|
31670
31694
|
const sanitizeExceptionForPostHog = (error, command) => {
|
|
@@ -41158,7 +41182,7 @@ const captureCommandException = (error, exitCode, telemetry, now) => {
|
|
|
41158
41182
|
command: commandContext?.command,
|
|
41159
41183
|
durationMs: commandContext ? now() - commandContext.startedAt : void 0,
|
|
41160
41184
|
exitCode,
|
|
41161
|
-
expected:
|
|
41185
|
+
expected: isExpectedFailure(error, exitCode),
|
|
41162
41186
|
group: commandContext?.group,
|
|
41163
41187
|
handled: true
|
|
41164
41188
|
}));
|