@fern-api/fern-api-dev 5.23.3-84-g4ddf0842ad3 → 5.23.3-99-g2ce21a4a41d
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/cli.cjs +488 -67
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44559,6 +44559,7 @@ function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
|
44559
44559
|
context3.failAndThrow(message, error50);
|
|
44560
44560
|
},
|
|
44561
44561
|
captureException: () => {
|
|
44562
|
+
return void 0;
|
|
44562
44563
|
},
|
|
44563
44564
|
getResult: () => TaskResult.Success,
|
|
44564
44565
|
getLastFailureMessage: () => void 0,
|
|
@@ -667930,13 +667931,20 @@ var AccessTokenPosthogManager = class {
|
|
|
667930
667931
|
properties: {
|
|
667931
667932
|
...event,
|
|
667932
667933
|
...event.properties,
|
|
667933
|
-
version: "5.23.3-
|
|
667934
|
+
version: "5.23.3-99-g2ce21a4a41d",
|
|
667934
667935
|
usingAccessToken: true,
|
|
667935
667936
|
...getRunIdProperties()
|
|
667936
667937
|
}
|
|
667937
667938
|
});
|
|
667938
667939
|
}
|
|
667939
667940
|
}
|
|
667941
|
+
sendAutomationEvent(event) {
|
|
667942
|
+
this.posthog.capture({
|
|
667943
|
+
distinctId: event.distinctId,
|
|
667944
|
+
event: event.event,
|
|
667945
|
+
properties: event.properties
|
|
667946
|
+
});
|
|
667947
|
+
}
|
|
667940
667948
|
async flush() {
|
|
667941
667949
|
try {
|
|
667942
667950
|
await Promise.race([this.posthog.flush(), new Promise((resolve15) => setTimeout(resolve15, 3e3))]);
|
|
@@ -667949,6 +667957,8 @@ var AccessTokenPosthogManager = class {
|
|
|
667949
667957
|
var NoopPosthogManager = class {
|
|
667950
667958
|
async sendEvent() {
|
|
667951
667959
|
}
|
|
667960
|
+
async sendAutomationEvent() {
|
|
667961
|
+
}
|
|
667952
667962
|
async identify() {
|
|
667953
667963
|
}
|
|
667954
667964
|
async flush() {
|
|
@@ -667985,7 +667995,7 @@ var UserPosthogManager = class {
|
|
|
667985
667995
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
667986
667996
|
event: "CLI",
|
|
667987
667997
|
properties: {
|
|
667988
|
-
version: "5.23.3-
|
|
667998
|
+
version: "5.23.3-99-g2ce21a4a41d",
|
|
667989
667999
|
...event,
|
|
667990
668000
|
...event.properties,
|
|
667991
668001
|
usingAccessToken: false,
|
|
@@ -667994,6 +668004,13 @@ var UserPosthogManager = class {
|
|
|
667994
668004
|
}
|
|
667995
668005
|
});
|
|
667996
668006
|
}
|
|
668007
|
+
sendAutomationEvent(event) {
|
|
668008
|
+
this.posthog.capture({
|
|
668009
|
+
distinctId: event.distinctId,
|
|
668010
|
+
event: event.event,
|
|
668011
|
+
properties: event.properties
|
|
668012
|
+
});
|
|
668013
|
+
}
|
|
667997
668014
|
async flush() {
|
|
667998
668015
|
try {
|
|
667999
668016
|
await Promise.race([this.posthog.flush(), new Promise((resolve15) => setTimeout(resolve15, 3e3))]);
|
|
@@ -671960,18 +671977,26 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
671960
671977
|
* The caller is responsible for deciding which errors are worth reporting
|
|
671961
671978
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
671962
671979
|
*/
|
|
671963
|
-
captureException(error50,
|
|
671980
|
+
captureException(error50, options2) {
|
|
671964
671981
|
if (this.sentry === void 0) {
|
|
671965
|
-
return;
|
|
671982
|
+
return void 0;
|
|
671966
671983
|
}
|
|
671967
671984
|
try {
|
|
671968
|
-
this.
|
|
671969
|
-
|
|
671970
|
-
|
|
671971
|
-
|
|
671985
|
+
const tags = { ...this.baseTags, ...this.accumulatedTags, ...options2?.tags };
|
|
671986
|
+
const context3 = options2?.context;
|
|
671987
|
+
return withScope2((scope) => {
|
|
671988
|
+
scope.setTags(tags);
|
|
671989
|
+
if (context3 != null) {
|
|
671990
|
+
for (const [key2, value2] of Object.entries(context3)) {
|
|
671991
|
+
if (value2 != null) {
|
|
671992
|
+
scope.setContext(key2, value2);
|
|
671993
|
+
}
|
|
671994
|
+
}
|
|
671972
671995
|
}
|
|
671996
|
+
return this.sentry?.captureException(error50, void 0, scope);
|
|
671973
671997
|
});
|
|
671974
671998
|
} catch {
|
|
671999
|
+
return void 0;
|
|
671975
672000
|
}
|
|
671976
672001
|
}
|
|
671977
672002
|
async flush() {
|
|
@@ -673459,7 +673484,9 @@ function reportError(context3, error50, options2) {
|
|
|
673459
673484
|
const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
|
|
673460
673485
|
if (shouldReportToSentry(code5)) {
|
|
673461
673486
|
context3.telemetry.captureException(capturable, {
|
|
673462
|
-
|
|
673487
|
+
tags: {
|
|
673488
|
+
"error.code": code5
|
|
673489
|
+
}
|
|
673463
673490
|
});
|
|
673464
673491
|
}
|
|
673465
673492
|
context3.telemetry.sendLifecycleEvent({
|
|
@@ -673658,9 +673685,8 @@ var TaskContextAdapter = class {
|
|
|
673658
673685
|
getLastFailureMessage() {
|
|
673659
673686
|
return this.lastFailureMessage;
|
|
673660
673687
|
}
|
|
673661
|
-
captureException(error50,
|
|
673662
|
-
|
|
673663
|
-
this.context.telemetry.captureException(error50, { errorCode });
|
|
673688
|
+
captureException(error50, options2) {
|
|
673689
|
+
return this.context.telemetry.captureException(error50, options2);
|
|
673664
673690
|
}
|
|
673665
673691
|
getFullErrorMessage(message, error50) {
|
|
673666
673692
|
const errorDetails = this.formatError(error50);
|
|
@@ -859541,7 +859567,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
859541
859567
|
var LOGS_FOLDER_NAME = "logs";
|
|
859542
859568
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
859543
859569
|
function getCliSource() {
|
|
859544
|
-
const version7 = "5.23.3-
|
|
859570
|
+
const version7 = "5.23.3-99-g2ce21a4a41d";
|
|
859545
859571
|
return `cli@${version7}`;
|
|
859546
859572
|
}
|
|
859547
859573
|
var DebugLogger = class {
|
|
@@ -873514,7 +873540,7 @@ var LegacyDocsPublisher = class {
|
|
|
873514
873540
|
previewId,
|
|
873515
873541
|
disableTemplates: void 0,
|
|
873516
873542
|
skipUpload,
|
|
873517
|
-
cliVersion: "5.23.3-
|
|
873543
|
+
cliVersion: "5.23.3-99-g2ce21a4a41d",
|
|
873518
873544
|
loginCommand: "fern auth login"
|
|
873519
873545
|
});
|
|
873520
873546
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -878121,23 +878147,16 @@ var AbstractDynamicSnippetsGeneratorContext = class {
|
|
|
878121
878147
|
}
|
|
878122
878148
|
associateByWireValue({ parameters: parameters2, values: values2, ignoreMissingParameters }) {
|
|
878123
878149
|
const instances2 = [];
|
|
878124
|
-
|
|
878150
|
+
const matchedWireValues = /* @__PURE__ */ new Set();
|
|
878151
|
+
for (const parameter6 of parameters2) {
|
|
878152
|
+
const wireValue = parameter6.name.wireValue;
|
|
878153
|
+
const value2 = values2[wireValue];
|
|
878125
878154
|
if (value2 === void 0) {
|
|
878126
878155
|
continue;
|
|
878127
878156
|
}
|
|
878128
|
-
|
|
878157
|
+
matchedWireValues.add(wireValue);
|
|
878158
|
+
this.errors.scope(wireValue);
|
|
878129
878159
|
try {
|
|
878130
|
-
const parameter6 = parameters2.find((param) => param.name.wireValue === key2);
|
|
878131
|
-
if (parameter6 == null) {
|
|
878132
|
-
if (ignoreMissingParameters) {
|
|
878133
|
-
continue;
|
|
878134
|
-
}
|
|
878135
|
-
this.errors.add({
|
|
878136
|
-
severity: Severity.Critical,
|
|
878137
|
-
message: this.newParameterNotRecognizedError(key2).message
|
|
878138
|
-
});
|
|
878139
|
-
continue;
|
|
878140
|
-
}
|
|
878141
878160
|
instances2.push({
|
|
878142
878161
|
name: parameter6.name,
|
|
878143
878162
|
typeReference: parameter6.typeReference,
|
|
@@ -878147,6 +878166,22 @@ var AbstractDynamicSnippetsGeneratorContext = class {
|
|
|
878147
878166
|
this.errors.unscope();
|
|
878148
878167
|
}
|
|
878149
878168
|
}
|
|
878169
|
+
if (!ignoreMissingParameters) {
|
|
878170
|
+
for (const [key2, value2] of Object.entries(values2)) {
|
|
878171
|
+
if (value2 === void 0 || matchedWireValues.has(key2)) {
|
|
878172
|
+
continue;
|
|
878173
|
+
}
|
|
878174
|
+
this.errors.scope(key2);
|
|
878175
|
+
try {
|
|
878176
|
+
this.errors.add({
|
|
878177
|
+
severity: Severity.Critical,
|
|
878178
|
+
message: this.newParameterNotRecognizedError(key2).message
|
|
878179
|
+
});
|
|
878180
|
+
} finally {
|
|
878181
|
+
this.errors.unscope();
|
|
878182
|
+
}
|
|
878183
|
+
}
|
|
878184
|
+
}
|
|
878150
878185
|
return instances2;
|
|
878151
878186
|
}
|
|
878152
878187
|
/**
|
|
@@ -902637,7 +902672,8 @@ var EndpointSnippetGenerator4 = class {
|
|
|
902637
902672
|
const args = [];
|
|
902638
902673
|
const pathParameters = this.context.associateByWireValue({
|
|
902639
902674
|
parameters: namedParameters,
|
|
902640
|
-
values: snippet2.pathParameters ?? {}
|
|
902675
|
+
values: snippet2.pathParameters ?? {},
|
|
902676
|
+
ignoreMissingParameters: true
|
|
902641
902677
|
});
|
|
902642
902678
|
for (const parameter6 of pathParameters) {
|
|
902643
902679
|
args.push({
|
|
@@ -908821,11 +908857,6 @@ var EndpointSnippetGenerator6 = class {
|
|
|
908821
908857
|
});
|
|
908822
908858
|
}
|
|
908823
908859
|
}
|
|
908824
|
-
this.context.errors.scope(Scope4.PathParameters);
|
|
908825
|
-
if (this.context.ir.pathParameters != null) {
|
|
908826
|
-
fields.push(...this.getPathParameters({ namedParameters: this.context.ir.pathParameters, snippet: snippet2 }));
|
|
908827
|
-
}
|
|
908828
|
-
this.context.errors.unscope();
|
|
908829
908860
|
this.context.errors.scope(Scope4.Headers);
|
|
908830
908861
|
if (this.context.ir.headers != null && snippet2.headers != null) {
|
|
908831
908862
|
fields.push(...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet2.headers }));
|
|
@@ -909309,9 +909340,10 @@ var EndpointSnippetGenerator6 = class {
|
|
|
909309
909340
|
const args = [];
|
|
909310
909341
|
const inlinePathParameters = this.context.shouldInlinePathParameters();
|
|
909311
909342
|
this.context.errors.scope(Scope4.PathParameters);
|
|
909343
|
+
const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
|
|
909312
909344
|
const pathParameterFields = [];
|
|
909313
|
-
if (
|
|
909314
|
-
pathParameterFields.push(...this.getPathParameters({ namedParameters:
|
|
909345
|
+
if (pathParameters.length > 0) {
|
|
909346
|
+
pathParameterFields.push(...this.getPathParameters({ namedParameters: pathParameters, snippet: snippet2 }));
|
|
909315
909347
|
}
|
|
909316
909348
|
this.context.errors.unscope();
|
|
909317
909349
|
this.context.errors.scope(Scope4.RequestBody);
|
|
@@ -912089,9 +912121,10 @@ var EndpointSnippetGenerator7 = class {
|
|
|
912089
912121
|
}
|
|
912090
912122
|
getMethodArgsForInlinedRequest({ request: request7, snippet: snippet2 }) {
|
|
912091
912123
|
const args = [];
|
|
912124
|
+
const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
|
|
912092
912125
|
args.push(...this.getNamedParameterArgs({
|
|
912093
912126
|
kind: "PathParameters",
|
|
912094
|
-
namedParameters:
|
|
912127
|
+
namedParameters: pathParameters,
|
|
912095
912128
|
values: snippet2.pathParameters
|
|
912096
912129
|
}));
|
|
912097
912130
|
args.push(...this.getNamedParameterArgs({
|
|
@@ -912199,9 +912232,10 @@ var EndpointSnippetGenerator7 = class {
|
|
|
912199
912232
|
}
|
|
912200
912233
|
getMethodArgsForBodyRequest({ request: request7, snippet: snippet2 }) {
|
|
912201
912234
|
const args = [];
|
|
912235
|
+
const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
|
|
912202
912236
|
args.push(...this.getNamedParameterArgs({
|
|
912203
912237
|
kind: "PathParameters",
|
|
912204
|
-
namedParameters:
|
|
912238
|
+
namedParameters: pathParameters,
|
|
912205
912239
|
values: snippet2.pathParameters
|
|
912206
912240
|
}));
|
|
912207
912241
|
if (request7.body != null && snippet2.requestBody != null) {
|
|
@@ -922028,10 +922062,11 @@ var EndpointSnippetGenerator9 = class {
|
|
|
922028
922062
|
getEndpointMethodArgsForInlinedRequest({ request: request7, snippet: snippet2 }) {
|
|
922029
922063
|
const args = [];
|
|
922030
922064
|
this.context.errors.scope(Scope4.PathParameters);
|
|
922065
|
+
const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
|
|
922031
922066
|
const pathParameterFields = [];
|
|
922032
|
-
if (
|
|
922067
|
+
if (pathParameters.length > 0) {
|
|
922033
922068
|
pathParameterFields.push(...this.getEndpointMethodPathParameters({
|
|
922034
|
-
namedParameters:
|
|
922069
|
+
namedParameters: pathParameters,
|
|
922035
922070
|
snippet: snippet2
|
|
922036
922071
|
}));
|
|
922037
922072
|
}
|
|
@@ -922070,21 +922105,33 @@ var EndpointSnippetGenerator9 = class {
|
|
|
922070
922105
|
return args;
|
|
922071
922106
|
}
|
|
922072
922107
|
getEndpointMethodPathParameters({ namedParameters, snippet: snippet2 }) {
|
|
922073
|
-
const moduleSymbol = this.context.nameRegistry.getRegisteredSourceModuleSymbolOrThrow();
|
|
922074
922108
|
return this.context.getExampleObjectProperties({
|
|
922075
922109
|
parameters: namedParameters,
|
|
922076
922110
|
snippetObject: snippet2.pathParameters ?? {}
|
|
922077
922111
|
}).map((parameter6) => {
|
|
922078
922112
|
return swift_exports.functionArgument({
|
|
922079
922113
|
label: parameter6.name.name.camelCase.unsafeName,
|
|
922080
|
-
|
|
922081
|
-
|
|
922082
|
-
|
|
922083
|
-
|
|
922084
|
-
|
|
922114
|
+
// Generated Swift SDKs declare every path parameter as `String` in
|
|
922115
|
+
// the endpoint method signature (the value is interpolated into the
|
|
922116
|
+
// URL string), so render non-string primitive literals as their
|
|
922117
|
+
// String representation here to keep the rendered snippet's
|
|
922118
|
+
// argument type compatible with the SDK signature.
|
|
922119
|
+
value: this.renderPathParameterValueAsSwiftString({ value: parameter6.value })
|
|
922085
922120
|
});
|
|
922086
922121
|
});
|
|
922087
922122
|
}
|
|
922123
|
+
renderPathParameterValueAsSwiftString({ value: value2 }) {
|
|
922124
|
+
if (typeof value2 === "string") {
|
|
922125
|
+
return swift_exports.Expression.escapedStringLiteral(value2);
|
|
922126
|
+
}
|
|
922127
|
+
if (typeof value2 === "number" || typeof value2 === "boolean" || typeof value2 === "bigint") {
|
|
922128
|
+
return swift_exports.Expression.escapedStringLiteral(String(value2));
|
|
922129
|
+
}
|
|
922130
|
+
if (value2 == null) {
|
|
922131
|
+
return swift_exports.Expression.nop();
|
|
922132
|
+
}
|
|
922133
|
+
return swift_exports.Expression.escapedStringLiteral(JSON.stringify(value2));
|
|
922134
|
+
}
|
|
922088
922135
|
getEndpointMethodQueryParameters({ namedParameters, snippet: snippet2 }) {
|
|
922089
922136
|
const moduleSymbol = this.context.nameRegistry.getRegisteredSourceModuleSymbolOrThrow();
|
|
922090
922137
|
return this.context.getExampleObjectProperties({
|
|
@@ -922191,7 +922238,6 @@ var EndpointSnippetGenerator9 = class {
|
|
|
922191
922238
|
}
|
|
922192
922239
|
getEndpointMethodArgsForBodyRequest({ request: request7, snippet: snippet2 }) {
|
|
922193
922240
|
const args = [];
|
|
922194
|
-
const moduleSymbol = this.context.nameRegistry.getRegisteredSourceModuleSymbolOrThrow();
|
|
922195
922241
|
this.context.errors.scope(Scope4.PathParameters);
|
|
922196
922242
|
const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
|
|
922197
922243
|
if (pathParameters.length > 0) {
|
|
@@ -947708,6 +947754,260 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
947708
947754
|
// src/cli-context/CliContext.ts
|
|
947709
947755
|
init_lodash();
|
|
947710
947756
|
|
|
947757
|
+
// src/telemetry/automationTelemetryEvent.ts
|
|
947758
|
+
var AUTOMATION_EVENT_NAMES = {
|
|
947759
|
+
GENERATION_STARTED: "generation_started",
|
|
947760
|
+
GENERATION_COMPLETED: "generation_completed",
|
|
947761
|
+
GENERATION_FAILED: "generation_failed",
|
|
947762
|
+
VERIFICATION_FAILED: "verification_failed",
|
|
947763
|
+
SDK_PR_CREATED: "sdk_pr_created",
|
|
947764
|
+
UPGRADE_APPLIED: "upgrade_applied",
|
|
947765
|
+
MAJOR_VERSION_BUMP: "major_version_bump"
|
|
947766
|
+
};
|
|
947767
|
+
var AUTOMATION_EVENT_FAILURE = {
|
|
947768
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_STARTED]: false,
|
|
947769
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_COMPLETED]: false,
|
|
947770
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_FAILED]: true,
|
|
947771
|
+
[AUTOMATION_EVENT_NAMES.VERIFICATION_FAILED]: true,
|
|
947772
|
+
[AUTOMATION_EVENT_NAMES.SDK_PR_CREATED]: false,
|
|
947773
|
+
[AUTOMATION_EVENT_NAMES.UPGRADE_APPLIED]: false,
|
|
947774
|
+
[AUTOMATION_EVENT_NAMES.MAJOR_VERSION_BUMP]: false
|
|
947775
|
+
};
|
|
947776
|
+
function isFailureAutomationEventName(event) {
|
|
947777
|
+
return AUTOMATION_EVENT_FAILURE[event];
|
|
947778
|
+
}
|
|
947779
|
+
function toPosthogProperties(event, context3) {
|
|
947780
|
+
return {
|
|
947781
|
+
automation_mode: true,
|
|
947782
|
+
surface: "cli",
|
|
947783
|
+
action: context3.action,
|
|
947784
|
+
run_id: context3.run_id,
|
|
947785
|
+
github_run_id: context3.github_run_id,
|
|
947786
|
+
github_run_url: context3.github_run_url,
|
|
947787
|
+
org: context3.org,
|
|
947788
|
+
config_repo: context3.config_repo,
|
|
947789
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947790
|
+
config_branch: context3.config_branch,
|
|
947791
|
+
config_pr_number: context3.config_pr_number,
|
|
947792
|
+
trigger: context3.trigger,
|
|
947793
|
+
cli_version: context3.cli_version,
|
|
947794
|
+
...event.errorCode !== void 0 ? { error_code: event.errorCode } : {},
|
|
947795
|
+
...event.attributes ?? {}
|
|
947796
|
+
};
|
|
947797
|
+
}
|
|
947798
|
+
function toSentryTags(event, context3) {
|
|
947799
|
+
function appendStringIfPresent(target, key2, value2) {
|
|
947800
|
+
if (value2 != null) {
|
|
947801
|
+
target[key2] = value2;
|
|
947802
|
+
}
|
|
947803
|
+
}
|
|
947804
|
+
const tags = {
|
|
947805
|
+
surface: "cli",
|
|
947806
|
+
automation_mode: "true"
|
|
947807
|
+
};
|
|
947808
|
+
appendStringIfPresent(tags, "event", event.event);
|
|
947809
|
+
appendStringIfPresent(tags, "action", context3.action);
|
|
947810
|
+
appendStringIfPresent(tags, "run_id", context3.run_id);
|
|
947811
|
+
appendStringIfPresent(tags, "org", context3.org);
|
|
947812
|
+
appendStringIfPresent(tags, "config_repo", context3.config_repo);
|
|
947813
|
+
appendStringIfPresent(tags, "trigger", context3.trigger);
|
|
947814
|
+
appendStringIfPresent(tags, "error_code", event.errorCode ?? "none");
|
|
947815
|
+
return tags;
|
|
947816
|
+
}
|
|
947817
|
+
function toSentryContext(event, context3) {
|
|
947818
|
+
return {
|
|
947819
|
+
github_run_id: context3.github_run_id,
|
|
947820
|
+
github_run_url: context3.github_run_url,
|
|
947821
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947822
|
+
config_branch: context3.config_branch,
|
|
947823
|
+
config_pr_number: context3.config_pr_number,
|
|
947824
|
+
cli_version: context3.cli_version,
|
|
947825
|
+
...event.attributes ?? {}
|
|
947826
|
+
};
|
|
947827
|
+
}
|
|
947828
|
+
function toAutomationEventApiBody(event, context3) {
|
|
947829
|
+
return {
|
|
947830
|
+
event: event.event,
|
|
947831
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
947832
|
+
surface: "cli",
|
|
947833
|
+
action: context3.action,
|
|
947834
|
+
run_id: context3.run_id,
|
|
947835
|
+
github_run_id: context3.github_run_id,
|
|
947836
|
+
github_run_url: context3.github_run_url,
|
|
947837
|
+
org: context3.org,
|
|
947838
|
+
config_repo: context3.config_repo,
|
|
947839
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947840
|
+
config_branch: context3.config_branch,
|
|
947841
|
+
config_pr_number: context3.config_pr_number,
|
|
947842
|
+
trigger: context3.trigger,
|
|
947843
|
+
cli_version: context3.cli_version,
|
|
947844
|
+
...event.errorCode !== void 0 ? { error_code: event.errorCode } : {},
|
|
947845
|
+
...event.attributes ?? {}
|
|
947846
|
+
};
|
|
947847
|
+
}
|
|
947848
|
+
function failureEventNameForCommand(argv) {
|
|
947849
|
+
const joined = argv.join(" ");
|
|
947850
|
+
if (/\bautomations\s+generate\b/.test(joined)) {
|
|
947851
|
+
return AUTOMATION_EVENT_NAMES.GENERATION_FAILED;
|
|
947852
|
+
}
|
|
947853
|
+
if (/\bautomations\s+preview\b/.test(joined)) {
|
|
947854
|
+
return AUTOMATION_EVENT_NAMES.VERIFICATION_FAILED;
|
|
947855
|
+
}
|
|
947856
|
+
return AUTOMATION_EVENT_NAMES.GENERATION_FAILED;
|
|
947857
|
+
}
|
|
947858
|
+
|
|
947859
|
+
// src/telemetry/AutomationEventApiClient.ts
|
|
947860
|
+
var DEFAULT_AUTOMATION_EVENTS_ORIGIN = "";
|
|
947861
|
+
var AUTOMATION_EVENTS_ORIGIN_ENV_VAR = "FERN_AUTOMATION_EVENTS_ORIGIN";
|
|
947862
|
+
var POST_TIMEOUT_MS = 3e3;
|
|
947863
|
+
var AutomationEventApiClient = class _AutomationEventApiClient {
|
|
947864
|
+
static instance;
|
|
947865
|
+
origin;
|
|
947866
|
+
inflight = [];
|
|
947867
|
+
static getInstance() {
|
|
947868
|
+
if (_AutomationEventApiClient.instance == null) {
|
|
947869
|
+
_AutomationEventApiClient.instance = new _AutomationEventApiClient(
|
|
947870
|
+
process.env[AUTOMATION_EVENTS_ORIGIN_ENV_VAR] ?? DEFAULT_AUTOMATION_EVENTS_ORIGIN
|
|
947871
|
+
);
|
|
947872
|
+
}
|
|
947873
|
+
return _AutomationEventApiClient.instance;
|
|
947874
|
+
}
|
|
947875
|
+
constructor(origin2) {
|
|
947876
|
+
this.origin = origin2;
|
|
947877
|
+
}
|
|
947878
|
+
/**
|
|
947879
|
+
* Resolves the automation event API endpoint from the baked origin.
|
|
947880
|
+
* Returns undefined when no origin is configured - callers silently skip
|
|
947881
|
+
* the POST in that case.
|
|
947882
|
+
*/
|
|
947883
|
+
resolveEndpoint() {
|
|
947884
|
+
if (this.origin.length === 0) {
|
|
947885
|
+
return void 0;
|
|
947886
|
+
}
|
|
947887
|
+
return `${this.origin.replace(/\/$/, "")}/v1/automation/events`;
|
|
947888
|
+
}
|
|
947889
|
+
/**
|
|
947890
|
+
* Enqueues an automation event POST to the automation event API.
|
|
947891
|
+
*
|
|
947892
|
+
* Best-effort: on any failure (timeout, DNS, non-2xx, missing endpoint),
|
|
947893
|
+
* the request settles without throwing. Sentry + PostHog already captured
|
|
947894
|
+
* the incident.
|
|
947895
|
+
*/
|
|
947896
|
+
post(event, context3) {
|
|
947897
|
+
this.inflight.push(this.send(event, context3));
|
|
947898
|
+
}
|
|
947899
|
+
async shutdown() {
|
|
947900
|
+
const pending = this.inflight;
|
|
947901
|
+
this.inflight = [];
|
|
947902
|
+
if (pending.length > 0) {
|
|
947903
|
+
await Promise.allSettled(pending);
|
|
947904
|
+
}
|
|
947905
|
+
}
|
|
947906
|
+
async send(event, context3) {
|
|
947907
|
+
const endpoint3 = this.resolveEndpoint();
|
|
947908
|
+
if (endpoint3 == null) {
|
|
947909
|
+
return;
|
|
947910
|
+
}
|
|
947911
|
+
const controller = new AbortController();
|
|
947912
|
+
const timer2 = setTimeout(() => controller.abort(), POST_TIMEOUT_MS);
|
|
947913
|
+
try {
|
|
947914
|
+
const headers2 = { "content-type": "application/json" };
|
|
947915
|
+
const token = await getAccessToken();
|
|
947916
|
+
if (token != null && token.value.length > 0) {
|
|
947917
|
+
headers2.Authorization = `Bearer ${token.value}`;
|
|
947918
|
+
}
|
|
947919
|
+
const response = await fetch(endpoint3, {
|
|
947920
|
+
method: "POST",
|
|
947921
|
+
headers: headers2,
|
|
947922
|
+
body: JSON.stringify(toAutomationEventApiBody(event, context3)),
|
|
947923
|
+
signal: controller.signal
|
|
947924
|
+
});
|
|
947925
|
+
void response;
|
|
947926
|
+
} catch {
|
|
947927
|
+
return;
|
|
947928
|
+
} finally {
|
|
947929
|
+
clearTimeout(timer2);
|
|
947930
|
+
}
|
|
947931
|
+
}
|
|
947932
|
+
};
|
|
947933
|
+
|
|
947934
|
+
// src/telemetry/automationTelemetryContext.ts
|
|
947935
|
+
function getAutomationContextFromEnv() {
|
|
947936
|
+
const { fern_run_id, github_run_id } = getRunIdProperties();
|
|
947937
|
+
return {
|
|
947938
|
+
action: process.env.FERN_ACTION,
|
|
947939
|
+
run_id: fern_run_id,
|
|
947940
|
+
github_run_id,
|
|
947941
|
+
github_run_url: process.env.FERN_GITHUB_RUN_URL,
|
|
947942
|
+
org: void 0,
|
|
947943
|
+
config_repo: process.env.FERN_CONFIG_REPO,
|
|
947944
|
+
config_commit_sha: process.env.FERN_CONFIG_COMMIT_SHA,
|
|
947945
|
+
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
947946
|
+
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
947947
|
+
trigger: process.env.GITHUB_EVENT_NAME,
|
|
947948
|
+
cli_version: "5.23.3-99-g2ce21a4a41d"
|
|
947949
|
+
};
|
|
947950
|
+
}
|
|
947951
|
+
function isAutomationMode() {
|
|
947952
|
+
return process.env.FERN_AUTOMATION === "true";
|
|
947953
|
+
}
|
|
947954
|
+
|
|
947955
|
+
// src/telemetry/AutomationTelemetryManager.ts
|
|
947956
|
+
var AutomationTelemetryManager = class {
|
|
947957
|
+
constructor(reporter, automationEventApiClient = AutomationEventApiClient.getInstance()) {
|
|
947958
|
+
this.reporter = reporter;
|
|
947959
|
+
this.automationEventApiClient = automationEventApiClient;
|
|
947960
|
+
this.context = getAutomationContextFromEnv();
|
|
947961
|
+
}
|
|
947962
|
+
reporter;
|
|
947963
|
+
automationEventApiClient;
|
|
947964
|
+
context;
|
|
947965
|
+
setOrganization(organization) {
|
|
947966
|
+
this.context = { ...this.context, org: organization };
|
|
947967
|
+
}
|
|
947968
|
+
emit(event, options2) {
|
|
947969
|
+
const sentryEventId = this.captureSentryForFailure({
|
|
947970
|
+
event,
|
|
947971
|
+
context: this.context,
|
|
947972
|
+
error: options2?.error
|
|
947973
|
+
});
|
|
947974
|
+
const eventWithSentry = sentryEventId == null ? event : { ...event, attributes: { ...event.attributes ?? {}, sentry_event_id: sentryEventId } };
|
|
947975
|
+
this.capturePostHogEvent({ event: eventWithSentry, context: this.context });
|
|
947976
|
+
this.captureAutomationEventApiEvent(eventWithSentry, this.context);
|
|
947977
|
+
}
|
|
947978
|
+
async flush() {
|
|
947979
|
+
await this.automationEventApiClient.shutdown();
|
|
947980
|
+
}
|
|
947981
|
+
capturePostHogEvent({
|
|
947982
|
+
event,
|
|
947983
|
+
context: context3
|
|
947984
|
+
}) {
|
|
947985
|
+
this.reporter.instrumentPostHogAutomationEvent({
|
|
947986
|
+
distinctId: context3.run_id ?? void 0,
|
|
947987
|
+
event: event.event,
|
|
947988
|
+
properties: toPosthogProperties(event, context3)
|
|
947989
|
+
});
|
|
947990
|
+
}
|
|
947991
|
+
captureSentryForFailure({
|
|
947992
|
+
event,
|
|
947993
|
+
context: context3,
|
|
947994
|
+
error: error50
|
|
947995
|
+
}) {
|
|
947996
|
+
if (!isFailureAutomationEventName(event.event) || event.errorCode == null) {
|
|
947997
|
+
return void 0;
|
|
947998
|
+
}
|
|
947999
|
+
return this.reporter.captureException(error50, {
|
|
948000
|
+
tags: toSentryTags(event, context3),
|
|
948001
|
+
context: {
|
|
948002
|
+
automation: toSentryContext(event, context3)
|
|
948003
|
+
}
|
|
948004
|
+
});
|
|
948005
|
+
}
|
|
948006
|
+
captureAutomationEventApiEvent(event, context3) {
|
|
948007
|
+
this.automationEventApiClient.post(event, context3);
|
|
948008
|
+
}
|
|
948009
|
+
};
|
|
948010
|
+
|
|
947711
948011
|
// src/telemetry/reportError.ts
|
|
947712
948012
|
init_lib6();
|
|
947713
948013
|
function reportError2(reporter, error50, options2) {
|
|
@@ -947715,17 +948015,47 @@ function reportError2(reporter, error50, options2) {
|
|
|
947715
948015
|
return;
|
|
947716
948016
|
}
|
|
947717
948017
|
const code5 = resolveErrorCode(error50, options2?.code);
|
|
948018
|
+
const argv = options2?.argv ?? process.argv;
|
|
948019
|
+
const command3 = argv.join(" ");
|
|
948020
|
+
const errorMessage = options2?.message ?? (error50 instanceof Error ? error50.message : void 0) ?? "";
|
|
948021
|
+
const reportedError = error50 ?? new CliError({ message: errorMessage, code: code5 });
|
|
948022
|
+
if (isAutomationMode()) {
|
|
948023
|
+
reportErrorForAutomationMode(argv, reporter, code5, errorMessage, reportedError);
|
|
948024
|
+
} else {
|
|
948025
|
+
reportErrorForNormalMode(reporter, command3, code5, reportedError);
|
|
948026
|
+
}
|
|
948027
|
+
}
|
|
948028
|
+
function reportErrorForNormalMode(reporter, command3, code5, reportedError) {
|
|
947718
948029
|
reporter.instrumentPostHogEvent({
|
|
947719
|
-
command:
|
|
948030
|
+
command: command3,
|
|
947720
948031
|
properties: {
|
|
947721
948032
|
failed: true,
|
|
947722
948033
|
errorCode: code5
|
|
947723
948034
|
}
|
|
947724
948035
|
});
|
|
947725
948036
|
if (shouldReportToSentry(code5)) {
|
|
947726
|
-
reporter.captureException(
|
|
948037
|
+
reporter.captureException(reportedError, {
|
|
948038
|
+
tags: {
|
|
948039
|
+
"error.code": code5
|
|
948040
|
+
}
|
|
948041
|
+
});
|
|
947727
948042
|
}
|
|
947728
948043
|
}
|
|
948044
|
+
function reportErrorForAutomationMode(argv, reporter, code5, errorMessage, reportedError) {
|
|
948045
|
+
const failureEventName = failureEventNameForCommand(argv);
|
|
948046
|
+
reporter.emitAutomationTelemetryEvent(
|
|
948047
|
+
{
|
|
948048
|
+
event: failureEventName,
|
|
948049
|
+
errorCode: code5,
|
|
948050
|
+
attributes: {
|
|
948051
|
+
error_message: errorMessage
|
|
948052
|
+
}
|
|
948053
|
+
},
|
|
948054
|
+
{
|
|
948055
|
+
error: reportedError
|
|
948056
|
+
}
|
|
948057
|
+
);
|
|
948058
|
+
}
|
|
947729
948059
|
|
|
947730
948060
|
// src/telemetry/SentryClient.ts
|
|
947731
948061
|
init_lib6();
|
|
@@ -947735,12 +948065,26 @@ function isTelemetryDisabled() {
|
|
|
947735
948065
|
return process.env.FERN_DISABLE_TELEMETRY === "true";
|
|
947736
948066
|
}
|
|
947737
948067
|
|
|
948068
|
+
// src/telemetry/shouldInitializeTelemetry.ts
|
|
948069
|
+
function shouldInitializeTelemetry({
|
|
948070
|
+
cliName,
|
|
948071
|
+
packageVersion: packageVersion3,
|
|
948072
|
+
isLocal
|
|
948073
|
+
}) {
|
|
948074
|
+
if (isTelemetryDisabled() || isLocal) {
|
|
948075
|
+
return false;
|
|
948076
|
+
}
|
|
948077
|
+
const isLocalDev = packageVersion3 === "0.0.0";
|
|
948078
|
+
const isProductionCli = cliName === "fern" && false;
|
|
948079
|
+
return !isLocalDev && isProductionCli;
|
|
948080
|
+
}
|
|
948081
|
+
|
|
947738
948082
|
// src/telemetry/SentryClient.ts
|
|
947739
948083
|
var SentryClient = class {
|
|
947740
948084
|
sentry;
|
|
947741
|
-
constructor({ release: release2 }) {
|
|
948085
|
+
constructor({ release: release2, telemetry }) {
|
|
947742
948086
|
const sentryDsn = "https://84f58b5e457f06999d92f11ce4b79158@o4509504076185600.ingest.us.sentry.io/4511021546602496";
|
|
947743
|
-
if (
|
|
948087
|
+
if (shouldInitializeTelemetry(telemetry) && sentryDsn != null && sentryDsn.length > 0) {
|
|
947744
948088
|
const sentryEnvironment = "development";
|
|
947745
948089
|
if (sentryEnvironment == null || sentryEnvironment.length === 0) {
|
|
947746
948090
|
throw new CliError({
|
|
@@ -947783,16 +948127,33 @@ var SentryClient = class {
|
|
|
947783
948127
|
setSentryRunIdTags();
|
|
947784
948128
|
}
|
|
947785
948129
|
}
|
|
947786
|
-
captureException(error50,
|
|
948130
|
+
captureException(error50, options2) {
|
|
947787
948131
|
if (this.sentry == null) {
|
|
947788
|
-
return;
|
|
948132
|
+
return void 0;
|
|
947789
948133
|
}
|
|
947790
948134
|
try {
|
|
947791
|
-
|
|
947792
|
-
|
|
947793
|
-
|
|
947794
|
-
);
|
|
948135
|
+
const tags = options2?.tags;
|
|
948136
|
+
const context3 = options2?.context;
|
|
948137
|
+
const hasTags = tags != null && Object.keys(tags).length > 0;
|
|
948138
|
+
const hasContext = context3 != null && Object.values(context3).some((value2) => value2 != null);
|
|
948139
|
+
if (!hasTags && !hasContext) {
|
|
948140
|
+
return this.sentry.captureException(error50);
|
|
948141
|
+
}
|
|
948142
|
+
return withScope2((scope) => {
|
|
948143
|
+
if (hasTags) {
|
|
948144
|
+
scope.setTags(tags);
|
|
948145
|
+
}
|
|
948146
|
+
if (context3 != null) {
|
|
948147
|
+
for (const [key2, value2] of Object.entries(context3)) {
|
|
948148
|
+
if (value2 != null) {
|
|
948149
|
+
scope.setContext(key2, value2);
|
|
948150
|
+
}
|
|
948151
|
+
}
|
|
948152
|
+
}
|
|
948153
|
+
return this.sentry?.captureException(error50, void 0, scope);
|
|
948154
|
+
});
|
|
947795
948155
|
} catch {
|
|
948156
|
+
return void 0;
|
|
947796
948157
|
}
|
|
947797
948158
|
}
|
|
947798
948159
|
async flush() {
|
|
@@ -947858,6 +948219,7 @@ var TaskContextImpl = class {
|
|
|
947858
948219
|
onResult;
|
|
947859
948220
|
instrumentPostHogEventImpl;
|
|
947860
948221
|
captureExceptionImpl;
|
|
948222
|
+
emitAutomationTelemetryEventImpl;
|
|
947861
948223
|
constructor({
|
|
947862
948224
|
logImmediately,
|
|
947863
948225
|
logPrefix,
|
|
@@ -947866,7 +948228,8 @@ var TaskContextImpl = class {
|
|
|
947866
948228
|
onResult,
|
|
947867
948229
|
shouldBufferLogs,
|
|
947868
948230
|
instrumentPostHogEvent,
|
|
947869
|
-
captureException: captureException2
|
|
948231
|
+
captureException: captureException2,
|
|
948232
|
+
emitAutomationTelemetryEvent
|
|
947870
948233
|
}) {
|
|
947871
948234
|
this.logImmediately = logImmediately;
|
|
947872
948235
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -947876,6 +948239,7 @@ var TaskContextImpl = class {
|
|
|
947876
948239
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
947877
948240
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
947878
948241
|
this.captureExceptionImpl = captureException2;
|
|
948242
|
+
this.emitAutomationTelemetryEventImpl = emitAutomationTelemetryEvent;
|
|
947879
948243
|
}
|
|
947880
948244
|
start() {
|
|
947881
948245
|
this.status = "running";
|
|
@@ -947915,8 +948279,11 @@ var TaskContextImpl = class {
|
|
|
947915
948279
|
getLastFailureMessage() {
|
|
947916
948280
|
return this.lastFailureMessage;
|
|
947917
948281
|
}
|
|
947918
|
-
captureException(error50,
|
|
947919
|
-
this.captureExceptionImpl?.(error50,
|
|
948282
|
+
captureException(error50, options2) {
|
|
948283
|
+
return this.captureExceptionImpl?.(error50, options2);
|
|
948284
|
+
}
|
|
948285
|
+
emitAutomationTelemetryEvent(event, options2) {
|
|
948286
|
+
this.emitAutomationTelemetryEventImpl(event, options2);
|
|
947920
948287
|
}
|
|
947921
948288
|
getResult() {
|
|
947922
948289
|
return this.result;
|
|
@@ -947959,7 +948326,8 @@ var TaskContextImpl = class {
|
|
|
947959
948326
|
onResult: this.onResult,
|
|
947960
948327
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
947961
948328
|
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
|
|
947962
|
-
captureException: this.captureExceptionImpl
|
|
948329
|
+
captureException: this.captureExceptionImpl,
|
|
948330
|
+
emitAutomationTelemetryEvent: this.emitAutomationTelemetryEventImpl
|
|
947963
948331
|
});
|
|
947964
948332
|
this.subtasks.push(subtask);
|
|
947965
948333
|
return subtask;
|
|
@@ -948356,6 +948724,7 @@ var CliContext = class _CliContext {
|
|
|
948356
948724
|
environment;
|
|
948357
948725
|
sentryClient;
|
|
948358
948726
|
posthogManager;
|
|
948727
|
+
automationTelemetryManager;
|
|
948359
948728
|
didSucceed = true;
|
|
948360
948729
|
numTasks = 0;
|
|
948361
948730
|
ttyAwareLogger;
|
|
@@ -948382,7 +948751,15 @@ var CliContext = class _CliContext {
|
|
|
948382
948751
|
packageVersion: packageVersion3,
|
|
948383
948752
|
cliName
|
|
948384
948753
|
};
|
|
948385
|
-
this.sentryClient = new SentryClient({
|
|
948754
|
+
this.sentryClient = new SentryClient({
|
|
948755
|
+
release: `cli@${this.environment.packageVersion}`,
|
|
948756
|
+
telemetry: {
|
|
948757
|
+
cliName: this.environment.cliName,
|
|
948758
|
+
packageVersion: this.environment.packageVersion,
|
|
948759
|
+
isLocal: this.isLocal
|
|
948760
|
+
}
|
|
948761
|
+
});
|
|
948762
|
+
this.automationTelemetryManager = new AutomationTelemetryManager(this);
|
|
948386
948763
|
}
|
|
948387
948764
|
getPackageName() {
|
|
948388
948765
|
if (false) {
|
|
@@ -948394,7 +948771,7 @@ var CliContext = class _CliContext {
|
|
|
948394
948771
|
if (false) {
|
|
948395
948772
|
this.logger.error("CLI_VERSION is not defined");
|
|
948396
948773
|
}
|
|
948397
|
-
return "5.23.3-
|
|
948774
|
+
return "5.23.3-99-g2ce21a4a41d";
|
|
948398
948775
|
}
|
|
948399
948776
|
getCliName() {
|
|
948400
948777
|
if (false) {
|
|
@@ -948459,6 +948836,7 @@ var CliContext = class _CliContext {
|
|
|
948459
948836
|
} catch {
|
|
948460
948837
|
}
|
|
948461
948838
|
await this.sentryClient.flush();
|
|
948839
|
+
await this.automationTelemetryManager.flush();
|
|
948462
948840
|
this.exitProgram({ code: code5 });
|
|
948463
948841
|
}
|
|
948464
948842
|
async nudgeUpgradeIfAvailable() {
|
|
@@ -948501,6 +948879,7 @@ var CliContext = class _CliContext {
|
|
|
948501
948879
|
project;
|
|
948502
948880
|
registerProject(project) {
|
|
948503
948881
|
this.project = project;
|
|
948882
|
+
this.automationTelemetryManager.setOrganization(project.config.organization);
|
|
948504
948883
|
}
|
|
948505
948884
|
runTask(run) {
|
|
948506
948885
|
return this.runTaskWithInit(this.constructTaskInit(), run);
|
|
@@ -948535,8 +948914,16 @@ var CliContext = class _CliContext {
|
|
|
948535
948914
|
this.posthogManager.sendEvent(event);
|
|
948536
948915
|
}
|
|
948537
948916
|
}
|
|
948538
|
-
|
|
948539
|
-
this.
|
|
948917
|
+
instrumentPostHogAutomationEvent(event) {
|
|
948918
|
+
if (!this.isLocal) {
|
|
948919
|
+
this.posthogManager.sendAutomationEvent(event);
|
|
948920
|
+
}
|
|
948921
|
+
}
|
|
948922
|
+
captureException(error50, options2) {
|
|
948923
|
+
return this.sentryClient.captureException(error50, options2);
|
|
948924
|
+
}
|
|
948925
|
+
emitAutomationTelemetryEvent(event, options2) {
|
|
948926
|
+
this.automationTelemetryManager.emit(event, options2);
|
|
948540
948927
|
}
|
|
948541
948928
|
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
948542
948929
|
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
@@ -948566,9 +948953,8 @@ var CliContext = class _CliContext {
|
|
|
948566
948953
|
this.instrumentPostHogEvent(event);
|
|
948567
948954
|
},
|
|
948568
948955
|
shouldBufferLogs: false,
|
|
948569
|
-
captureException: (error50,
|
|
948570
|
-
|
|
948571
|
-
}
|
|
948956
|
+
captureException: (error50, options2) => this.sentryClient.captureException(error50, options2),
|
|
948957
|
+
emitAutomationTelemetryEvent: (event, options2) => this.emitAutomationTelemetryEvent(event, options2)
|
|
948572
948958
|
};
|
|
948573
948959
|
}
|
|
948574
948960
|
log(level, ...parts) {
|
|
@@ -967764,6 +968150,40 @@ function evaluateRuntime4() {
|
|
|
967764
968150
|
};
|
|
967765
968151
|
}
|
|
967766
968152
|
|
|
968153
|
+
// src/telemetry/processHandlers.ts
|
|
968154
|
+
init_lib6();
|
|
968155
|
+
function installProcessHandlers(cliContext, { isLocal }) {
|
|
968156
|
+
if (!shouldInitializeTelemetry({
|
|
968157
|
+
cliName: cliContext.environment.cliName,
|
|
968158
|
+
packageVersion: cliContext.environment.packageVersion,
|
|
968159
|
+
isLocal
|
|
968160
|
+
})) {
|
|
968161
|
+
return;
|
|
968162
|
+
}
|
|
968163
|
+
let isHandlingFatal = false;
|
|
968164
|
+
const handleFatal = async (label, error50) => {
|
|
968165
|
+
if (isHandlingFatal) {
|
|
968166
|
+
process.exit(1);
|
|
968167
|
+
}
|
|
968168
|
+
isHandlingFatal = true;
|
|
968169
|
+
try {
|
|
968170
|
+
cliContext.failWithoutThrowing(label, error50, { code: CliError.Code.InternalError });
|
|
968171
|
+
} catch {
|
|
968172
|
+
}
|
|
968173
|
+
try {
|
|
968174
|
+
await cliContext.exit({ code: 1 });
|
|
968175
|
+
} catch {
|
|
968176
|
+
process.exit(1);
|
|
968177
|
+
}
|
|
968178
|
+
};
|
|
968179
|
+
process.on("uncaughtException", (error50) => {
|
|
968180
|
+
void handleFatal("uncaught exception", error50);
|
|
968181
|
+
});
|
|
968182
|
+
process.on("unhandledRejection", (reason) => {
|
|
968183
|
+
void handleFatal("unhandled promise rejection", reason);
|
|
968184
|
+
});
|
|
968185
|
+
}
|
|
968186
|
+
|
|
967767
968187
|
// src/cli.ts
|
|
967768
968188
|
if (process.platform === "linux" && parseInt(process.versions.node.split(".")[0] ?? "0", 10) >= 26 && process.env.UV_USE_IO_URING !== "0") {
|
|
967769
968189
|
const result = (0, import_node_child_process7.spawnSync)(process.execPath, process.argv.slice(1), {
|
|
@@ -967786,6 +968206,7 @@ async function runCli() {
|
|
|
967786
968206
|
if (isCompletion) {
|
|
967787
968207
|
cliContext.suppressUpgradeMessage();
|
|
967788
968208
|
}
|
|
968209
|
+
installProcessHandlers(cliContext, { isLocal });
|
|
967789
968210
|
const exit3 = async () => {
|
|
967790
968211
|
await cliContext.exit();
|
|
967791
968212
|
};
|
package/package.json
CHANGED