@fern-api/fern-api-dev 4.68.2-6-gdbf7c6b8be3 → 4.68.3-1-g429be56b56f
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 +1382 -1240
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -38969,7 +38969,7 @@ var require_errors = __commonJS({
|
|
|
38969
38969
|
exports2.keyword$DataError = {
|
|
38970
38970
|
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
|
|
38971
38971
|
};
|
|
38972
|
-
function
|
|
38972
|
+
function reportError3(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
|
|
38973
38973
|
const { it: it13 } = cxt;
|
|
38974
38974
|
const { gen, compositeRule, allErrors } = it13;
|
|
38975
38975
|
const errObj = errorObjectCode(cxt, error50, errorPaths);
|
|
@@ -38979,7 +38979,7 @@ var require_errors = __commonJS({
|
|
|
38979
38979
|
returnErrors(it13, (0, codegen_1._)`[${errObj}]`);
|
|
38980
38980
|
}
|
|
38981
38981
|
}
|
|
38982
|
-
exports2.reportError =
|
|
38982
|
+
exports2.reportError = reportError3;
|
|
38983
38983
|
function reportExtraError(cxt, error50 = exports2.keywordError, errorPaths) {
|
|
38984
38984
|
const { it: it13 } = cxt;
|
|
38985
38985
|
const { gen, compositeRule, allErrors } = it13;
|
|
@@ -54543,7 +54543,7 @@ function childLoggerName(name2, childDebugger, { namespace: parentNamespace }) {
|
|
|
54543
54543
|
}
|
|
54544
54544
|
return childNamespace || parentNamespace;
|
|
54545
54545
|
}
|
|
54546
|
-
function
|
|
54546
|
+
function createLogger2(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
54547
54547
|
const labelPrefix = label && `[${label}]` || "";
|
|
54548
54548
|
const spawned = [];
|
|
54549
54549
|
const debugDebugger = typeof verbose === "string" ? infoDebugger.extend(verbose) : verbose;
|
|
@@ -54552,7 +54552,7 @@ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
|
54552
54552
|
function sibling2(name2, initial) {
|
|
54553
54553
|
return append(
|
|
54554
54554
|
spawned,
|
|
54555
|
-
|
|
54555
|
+
createLogger2(label, key2.replace(/^[^:]+/, name2), initial, infoDebugger)
|
|
54556
54556
|
);
|
|
54557
54557
|
}
|
|
54558
54558
|
function step(phase) {
|
|
@@ -56283,7 +56283,7 @@ var init_esm16 = __esm({
|
|
|
56283
56283
|
}
|
|
56284
56284
|
createProgress(task) {
|
|
56285
56285
|
const name2 = _TasksPendingQueue.getName(task.commands[0]);
|
|
56286
|
-
const logger4 =
|
|
56286
|
+
const logger4 = createLogger2(this.logLabel, name2);
|
|
56287
56287
|
return {
|
|
56288
56288
|
task,
|
|
56289
56289
|
logger: logger4,
|
|
@@ -57566,7 +57566,7 @@ var init_esm16 = __esm({
|
|
|
57566
57566
|
Scheduler = class {
|
|
57567
57567
|
constructor(concurrency = 2) {
|
|
57568
57568
|
this.concurrency = concurrency;
|
|
57569
|
-
this.logger =
|
|
57569
|
+
this.logger = createLogger2("", "scheduler");
|
|
57570
57570
|
this.pending = [];
|
|
57571
57571
|
this.running = [];
|
|
57572
57572
|
this.logger(`Constructed, concurrency=%s`, concurrency);
|
|
@@ -59886,7 +59886,7 @@ var init_version4 = __esm({
|
|
|
59886
59886
|
});
|
|
59887
59887
|
|
|
59888
59888
|
// ../../../node_modules/.pnpm/@octokit+core@6.1.6/node_modules/@octokit/core/dist-src/index.js
|
|
59889
|
-
function
|
|
59889
|
+
function createLogger3(logger4 = {}) {
|
|
59890
59890
|
if (typeof logger4.debug !== "function") {
|
|
59891
59891
|
logger4.debug = noop3;
|
|
59892
59892
|
}
|
|
@@ -59982,7 +59982,7 @@ var init_dist_src2 = __esm({
|
|
|
59982
59982
|
}
|
|
59983
59983
|
this.request = request2.defaults(requestDefaults);
|
|
59984
59984
|
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
|
59985
|
-
this.log =
|
|
59985
|
+
this.log = createLogger3(options2.log);
|
|
59986
59986
|
this.hook = hook8;
|
|
59987
59987
|
if (!options2.authStrategy) {
|
|
59988
59988
|
if (!options2.auth) {
|
|
@@ -66343,7 +66343,7 @@ function removeListener(state, webhookNameOrNames, handler3) {
|
|
|
66343
66343
|
function createEventHandler(options2) {
|
|
66344
66344
|
const state = {
|
|
66345
66345
|
hooks: {},
|
|
66346
|
-
log:
|
|
66346
|
+
log: createLogger4(options2 && options2.log)
|
|
66347
66347
|
};
|
|
66348
66348
|
if (options2 && options2.transform) {
|
|
66349
66349
|
state.transform = options2.transform;
|
|
@@ -66385,13 +66385,13 @@ async function verifyAndReceive(state, event) {
|
|
|
66385
66385
|
payload
|
|
66386
66386
|
});
|
|
66387
66387
|
}
|
|
66388
|
-
var
|
|
66388
|
+
var createLogger4, emitterEventNames, textDecoder, decode, Webhooks;
|
|
66389
66389
|
var init_dist_bundle13 = __esm({
|
|
66390
66390
|
"../../../node_modules/.pnpm/@octokit+webhooks@13.9.1/node_modules/@octokit/webhooks/dist-bundle/index.js"() {
|
|
66391
66391
|
"use strict";
|
|
66392
66392
|
init_dist_node4();
|
|
66393
66393
|
init_dist_node4();
|
|
66394
|
-
|
|
66394
|
+
createLogger4 = (logger4 = {}) => {
|
|
66395
66395
|
if (typeof logger4.debug !== "function") {
|
|
66396
66396
|
logger4.debug = () => {
|
|
66397
66397
|
};
|
|
@@ -66746,7 +66746,7 @@ var init_dist_bundle13 = __esm({
|
|
|
66746
66746
|
secret: options2.secret,
|
|
66747
66747
|
additionalSecrets: options2.additionalSecrets,
|
|
66748
66748
|
hooks: {},
|
|
66749
|
-
log:
|
|
66749
|
+
log: createLogger4(options2.log)
|
|
66750
66750
|
};
|
|
66751
66751
|
this.sign = sign.bind(null, options2.secret);
|
|
66752
66752
|
this.verify = verify.bind(null, options2.secret);
|
|
@@ -80661,7 +80661,7 @@ var require_errors2 = __commonJS({
|
|
|
80661
80661
|
"use strict";
|
|
80662
80662
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
80663
80663
|
exports2.keyword$DataError = exports2.keywordError = void 0;
|
|
80664
|
-
exports2.reportError =
|
|
80664
|
+
exports2.reportError = reportError3;
|
|
80665
80665
|
exports2.reportExtraError = reportExtraError;
|
|
80666
80666
|
exports2.resetErrorsCount = resetErrorsCount;
|
|
80667
80667
|
exports2.extendErrors = extendErrors;
|
|
@@ -80674,7 +80674,7 @@ var require_errors2 = __commonJS({
|
|
|
80674
80674
|
exports2.keyword$DataError = {
|
|
80675
80675
|
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
|
|
80676
80676
|
};
|
|
80677
|
-
function
|
|
80677
|
+
function reportError3(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
|
|
80678
80678
|
const { it: it13 } = cxt;
|
|
80679
80679
|
const { gen, compositeRule, allErrors } = it13;
|
|
80680
80680
|
const errObj = errorObjectCode(cxt, error50, errorPaths);
|
|
@@ -485174,6 +485174,222 @@ function commandGroup(cli, name2, description, subcommands) {
|
|
|
485174
485174
|
});
|
|
485175
485175
|
}
|
|
485176
485176
|
|
|
485177
|
+
// ../task-context/lib/CliError.js
|
|
485178
|
+
var CliError = class _CliError extends Error {
|
|
485179
|
+
code;
|
|
485180
|
+
docsLink;
|
|
485181
|
+
constructor({ message, code: code5, docsLink }) {
|
|
485182
|
+
super(message);
|
|
485183
|
+
Object.setPrototypeOf(this, _CliError.prototype);
|
|
485184
|
+
this.code = code5;
|
|
485185
|
+
this.docsLink = docsLink;
|
|
485186
|
+
}
|
|
485187
|
+
static authRequired(message) {
|
|
485188
|
+
return new _CliError({
|
|
485189
|
+
message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
|
|
485190
|
+
code: _CliError.Code.AuthError
|
|
485191
|
+
});
|
|
485192
|
+
}
|
|
485193
|
+
static unauthorized(message) {
|
|
485194
|
+
return new _CliError({
|
|
485195
|
+
message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
|
|
485196
|
+
code: _CliError.Code.AuthError
|
|
485197
|
+
});
|
|
485198
|
+
}
|
|
485199
|
+
static notFound(message) {
|
|
485200
|
+
return new _CliError({ message, code: _CliError.Code.ConfigError });
|
|
485201
|
+
}
|
|
485202
|
+
static badRequest(message) {
|
|
485203
|
+
return new _CliError({ message, code: _CliError.Code.NetworkError });
|
|
485204
|
+
}
|
|
485205
|
+
static validationError(message) {
|
|
485206
|
+
return new _CliError({ message, code: _CliError.Code.ValidationError });
|
|
485207
|
+
}
|
|
485208
|
+
static internalError(message) {
|
|
485209
|
+
return new _CliError({ message, code: _CliError.Code.InternalError });
|
|
485210
|
+
}
|
|
485211
|
+
};
|
|
485212
|
+
(function(CliError4) {
|
|
485213
|
+
CliError4.Code = {
|
|
485214
|
+
InternalError: "INTERNAL_ERROR",
|
|
485215
|
+
ResolutionError: "RESOLUTION_ERROR",
|
|
485216
|
+
IrConversionError: "IR_CONVERSION_ERROR",
|
|
485217
|
+
ContainerError: "CONTAINER_ERROR",
|
|
485218
|
+
VersionError: "VERSION_ERROR",
|
|
485219
|
+
ParseError: "PARSE_ERROR",
|
|
485220
|
+
EnvironmentError: "ENVIRONMENT_ERROR",
|
|
485221
|
+
ReferenceError: "REFERENCE_ERROR",
|
|
485222
|
+
ValidationError: "VALIDATION_ERROR",
|
|
485223
|
+
NetworkError: "NETWORK_ERROR",
|
|
485224
|
+
AuthError: "AUTH_ERROR",
|
|
485225
|
+
ConfigError: "CONFIG_ERROR"
|
|
485226
|
+
};
|
|
485227
|
+
})(CliError || (CliError = {}));
|
|
485228
|
+
var SENTRY_REPORTABLE = {
|
|
485229
|
+
[CliError.Code.InternalError]: true,
|
|
485230
|
+
[CliError.Code.ResolutionError]: true,
|
|
485231
|
+
[CliError.Code.IrConversionError]: true,
|
|
485232
|
+
[CliError.Code.ContainerError]: true,
|
|
485233
|
+
[CliError.Code.VersionError]: true,
|
|
485234
|
+
[CliError.Code.ParseError]: false,
|
|
485235
|
+
[CliError.Code.EnvironmentError]: false,
|
|
485236
|
+
[CliError.Code.ReferenceError]: false,
|
|
485237
|
+
[CliError.Code.ValidationError]: false,
|
|
485238
|
+
[CliError.Code.NetworkError]: false,
|
|
485239
|
+
[CliError.Code.AuthError]: false,
|
|
485240
|
+
[CliError.Code.ConfigError]: false
|
|
485241
|
+
};
|
|
485242
|
+
function shouldReportToSentry(code5) {
|
|
485243
|
+
return SENTRY_REPORTABLE[code5];
|
|
485244
|
+
}
|
|
485245
|
+
function isSchemaValidationError(error50) {
|
|
485246
|
+
return error50 instanceof Error && (error50.constructor.name === "ParseError" || error50.constructor.name === "JsonError");
|
|
485247
|
+
}
|
|
485248
|
+
function isNodeVersionError(error50) {
|
|
485249
|
+
return error50 instanceof Error && error50.message.includes("globalThis");
|
|
485250
|
+
}
|
|
485251
|
+
function resolveErrorCode(error50, explicitCode) {
|
|
485252
|
+
if (explicitCode != null) {
|
|
485253
|
+
return explicitCode;
|
|
485254
|
+
}
|
|
485255
|
+
if (error50 instanceof CliError) {
|
|
485256
|
+
return error50.code;
|
|
485257
|
+
}
|
|
485258
|
+
if (isSchemaValidationError(error50)) {
|
|
485259
|
+
return CliError.Code.ParseError;
|
|
485260
|
+
}
|
|
485261
|
+
if (isNodeVersionError(error50)) {
|
|
485262
|
+
return CliError.Code.EnvironmentError;
|
|
485263
|
+
}
|
|
485264
|
+
return CliError.Code.InternalError;
|
|
485265
|
+
}
|
|
485266
|
+
|
|
485267
|
+
// ../logger/lib/LogLevel.js
|
|
485268
|
+
var LogLevel = {
|
|
485269
|
+
Trace: "trace",
|
|
485270
|
+
Debug: "debug",
|
|
485271
|
+
Info: "info",
|
|
485272
|
+
Warn: "warn",
|
|
485273
|
+
Error: "error"
|
|
485274
|
+
};
|
|
485275
|
+
var LOG_LEVELS = Object.values(LogLevel);
|
|
485276
|
+
|
|
485277
|
+
// ../logger/lib/createLogger.js
|
|
485278
|
+
var LoggerImpl = class {
|
|
485279
|
+
log;
|
|
485280
|
+
enabled;
|
|
485281
|
+
constructor(log4, enabled = true) {
|
|
485282
|
+
this.log = log4;
|
|
485283
|
+
this.enabled = enabled;
|
|
485284
|
+
}
|
|
485285
|
+
disable() {
|
|
485286
|
+
this.enabled = false;
|
|
485287
|
+
}
|
|
485288
|
+
enable() {
|
|
485289
|
+
this.enabled = true;
|
|
485290
|
+
}
|
|
485291
|
+
debug(...args) {
|
|
485292
|
+
if (this.enabled) {
|
|
485293
|
+
this.log(LogLevel.Debug, ...args);
|
|
485294
|
+
}
|
|
485295
|
+
}
|
|
485296
|
+
info(...args) {
|
|
485297
|
+
if (this.enabled) {
|
|
485298
|
+
this.log(LogLevel.Info, ...args);
|
|
485299
|
+
}
|
|
485300
|
+
}
|
|
485301
|
+
warn(...args) {
|
|
485302
|
+
if (this.enabled) {
|
|
485303
|
+
this.log(LogLevel.Warn, ...args);
|
|
485304
|
+
}
|
|
485305
|
+
}
|
|
485306
|
+
error(...args) {
|
|
485307
|
+
if (this.enabled) {
|
|
485308
|
+
this.log(LogLevel.Error, ...args);
|
|
485309
|
+
}
|
|
485310
|
+
}
|
|
485311
|
+
trace(...args) {
|
|
485312
|
+
if (this.enabled) {
|
|
485313
|
+
this.log(LogLevel.Trace, ...args);
|
|
485314
|
+
}
|
|
485315
|
+
}
|
|
485316
|
+
};
|
|
485317
|
+
function createLogger(log4) {
|
|
485318
|
+
return new LoggerImpl(log4);
|
|
485319
|
+
}
|
|
485320
|
+
|
|
485321
|
+
// ../logger/lib/console.js
|
|
485322
|
+
var CONSOLE_LOGGER = Object.freeze(createLogger(log3));
|
|
485323
|
+
function log3(level, ...args) {
|
|
485324
|
+
const consoleLogger = getConsoleLoggerForLevel(level);
|
|
485325
|
+
consoleLogger(...args);
|
|
485326
|
+
}
|
|
485327
|
+
function getConsoleLoggerForLevel(level) {
|
|
485328
|
+
switch (level) {
|
|
485329
|
+
case LogLevel.Trace:
|
|
485330
|
+
return console.trace;
|
|
485331
|
+
case LogLevel.Debug:
|
|
485332
|
+
return console.debug;
|
|
485333
|
+
case LogLevel.Info:
|
|
485334
|
+
return console.info;
|
|
485335
|
+
case LogLevel.Warn:
|
|
485336
|
+
return console.warn;
|
|
485337
|
+
case LogLevel.Error:
|
|
485338
|
+
return console.error;
|
|
485339
|
+
}
|
|
485340
|
+
}
|
|
485341
|
+
|
|
485342
|
+
// ../task-context/lib/TaskAbortSignal.js
|
|
485343
|
+
var TaskAbortSignal = class {
|
|
485344
|
+
__brand = "TaskAbortSignal";
|
|
485345
|
+
};
|
|
485346
|
+
|
|
485347
|
+
// ../task-context/lib/TaskContext.js
|
|
485348
|
+
var TaskResult;
|
|
485349
|
+
(function(TaskResult2) {
|
|
485350
|
+
TaskResult2[TaskResult2["Success"] = 0] = "Success";
|
|
485351
|
+
TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
|
|
485352
|
+
})(TaskResult || (TaskResult = {}));
|
|
485353
|
+
|
|
485354
|
+
// ../task-context/lib/MockTaskContext.js
|
|
485355
|
+
function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
485356
|
+
const context3 = {
|
|
485357
|
+
logger: logger4,
|
|
485358
|
+
takeOverTerminal: () => {
|
|
485359
|
+
throw new Error("Not implemented");
|
|
485360
|
+
},
|
|
485361
|
+
failAndThrow: (message, error50, _options) => {
|
|
485362
|
+
const parts = [];
|
|
485363
|
+
if (message != null) {
|
|
485364
|
+
parts.push(message);
|
|
485365
|
+
}
|
|
485366
|
+
if (error50 != null) {
|
|
485367
|
+
parts.push(JSON.stringify(error50));
|
|
485368
|
+
}
|
|
485369
|
+
if (parts.length > 0) {
|
|
485370
|
+
context3.logger.error(...parts);
|
|
485371
|
+
}
|
|
485372
|
+
throw new TaskAbortSignal();
|
|
485373
|
+
},
|
|
485374
|
+
failWithoutThrowing: (message, error50, _options) => {
|
|
485375
|
+
context3.failAndThrow(message, error50);
|
|
485376
|
+
},
|
|
485377
|
+
captureException: () => {
|
|
485378
|
+
},
|
|
485379
|
+
getResult: () => TaskResult.Success,
|
|
485380
|
+
addInteractiveTask: () => {
|
|
485381
|
+
throw new Error("Not implemented");
|
|
485382
|
+
},
|
|
485383
|
+
runInteractiveTask: () => {
|
|
485384
|
+
throw new Error("Not implemented");
|
|
485385
|
+
},
|
|
485386
|
+
instrumentPostHogEvent: () => {
|
|
485387
|
+
throw new Error("Not implemented");
|
|
485388
|
+
}
|
|
485389
|
+
};
|
|
485390
|
+
return context3;
|
|
485391
|
+
}
|
|
485392
|
+
|
|
485177
485393
|
// ../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
485178
485394
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
485179
485395
|
var wrapAnsi16 = (offset2 = 0) => (code5) => `\x1B[${code5 + offset2}m`;
|
|
@@ -518729,17 +518945,17 @@ var FernDocsConfigTimeoutError = class extends Error {
|
|
|
518729
518945
|
};
|
|
518730
518946
|
|
|
518731
518947
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/logger.js
|
|
518732
|
-
var
|
|
518948
|
+
var LogLevel2 = {
|
|
518733
518949
|
Debug: "debug",
|
|
518734
518950
|
Info: "info",
|
|
518735
518951
|
Warn: "warn",
|
|
518736
518952
|
Error: "error"
|
|
518737
518953
|
};
|
|
518738
518954
|
var logLevelMap2 = {
|
|
518739
|
-
[
|
|
518740
|
-
[
|
|
518741
|
-
[
|
|
518742
|
-
[
|
|
518955
|
+
[LogLevel2.Debug]: 1,
|
|
518956
|
+
[LogLevel2.Info]: 2,
|
|
518957
|
+
[LogLevel2.Warn]: 3,
|
|
518958
|
+
[LogLevel2.Error]: 4
|
|
518743
518959
|
};
|
|
518744
518960
|
var ConsoleLogger = class {
|
|
518745
518961
|
debug(message, ...args) {
|
|
@@ -518781,7 +518997,7 @@ var Logger = class {
|
|
|
518781
518997
|
* @returns True if debug logs should be output
|
|
518782
518998
|
*/
|
|
518783
518999
|
isDebug() {
|
|
518784
|
-
return this.shouldLog(
|
|
519000
|
+
return this.shouldLog(LogLevel2.Debug);
|
|
518785
519001
|
}
|
|
518786
519002
|
/**
|
|
518787
519003
|
* Logs a debug message if debug logging is enabled.
|
|
@@ -518798,7 +519014,7 @@ var Logger = class {
|
|
|
518798
519014
|
* @returns True if info logs should be output
|
|
518799
519015
|
*/
|
|
518800
519016
|
isInfo() {
|
|
518801
|
-
return this.shouldLog(
|
|
519017
|
+
return this.shouldLog(LogLevel2.Info);
|
|
518802
519018
|
}
|
|
518803
519019
|
/**
|
|
518804
519020
|
* Logs an info message if info logging is enabled.
|
|
@@ -518815,7 +519031,7 @@ var Logger = class {
|
|
|
518815
519031
|
* @returns True if warning logs should be output
|
|
518816
519032
|
*/
|
|
518817
519033
|
isWarn() {
|
|
518818
|
-
return this.shouldLog(
|
|
519034
|
+
return this.shouldLog(LogLevel2.Warn);
|
|
518819
519035
|
}
|
|
518820
519036
|
/**
|
|
518821
519037
|
* Logs a warning message if warning logging is enabled.
|
|
@@ -518832,7 +519048,7 @@ var Logger = class {
|
|
|
518832
519048
|
* @returns True if error logs should be output
|
|
518833
519049
|
*/
|
|
518834
519050
|
isError() {
|
|
518835
|
-
return this.shouldLog(
|
|
519051
|
+
return this.shouldLog(LogLevel2.Error);
|
|
518836
519052
|
}
|
|
518837
519053
|
/**
|
|
518838
519054
|
* Logs an error message if error logging is enabled.
|
|
@@ -518846,7 +519062,7 @@ var Logger = class {
|
|
|
518846
519062
|
}
|
|
518847
519063
|
};
|
|
518848
519064
|
var defaultLogger = new Logger({
|
|
518849
|
-
level:
|
|
519065
|
+
level: LogLevel2.Info,
|
|
518850
519066
|
logger: new ConsoleLogger(),
|
|
518851
519067
|
silent: true
|
|
518852
519068
|
});
|
|
@@ -518854,7 +519070,7 @@ var defaultLogger = new Logger({
|
|
|
518854
519070
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/exports.js
|
|
518855
519071
|
var logging;
|
|
518856
519072
|
(function(logging2) {
|
|
518857
|
-
logging2.LogLevel =
|
|
519073
|
+
logging2.LogLevel = LogLevel2;
|
|
518858
519074
|
logging2.ConsoleLogger = ConsoleLogger;
|
|
518859
519075
|
})(logging || (logging = {}));
|
|
518860
519076
|
|
|
@@ -555047,142 +555263,6 @@ function joinZodPath(arr) {
|
|
|
555047
555263
|
|
|
555048
555264
|
// ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
|
|
555049
555265
|
init_lib6();
|
|
555050
|
-
|
|
555051
|
-
// ../task-context/lib/LoggableFernCliError.js
|
|
555052
|
-
var LoggableFernCliError = class _LoggableFernCliError extends Error {
|
|
555053
|
-
log;
|
|
555054
|
-
constructor(log4) {
|
|
555055
|
-
super();
|
|
555056
|
-
this.log = log4;
|
|
555057
|
-
Object.setPrototypeOf(this, _LoggableFernCliError.prototype);
|
|
555058
|
-
}
|
|
555059
|
-
};
|
|
555060
|
-
|
|
555061
|
-
// ../logger/lib/LogLevel.js
|
|
555062
|
-
var LogLevel2 = {
|
|
555063
|
-
Trace: "trace",
|
|
555064
|
-
Debug: "debug",
|
|
555065
|
-
Info: "info",
|
|
555066
|
-
Warn: "warn",
|
|
555067
|
-
Error: "error"
|
|
555068
|
-
};
|
|
555069
|
-
var LOG_LEVELS = Object.values(LogLevel2);
|
|
555070
|
-
|
|
555071
|
-
// ../logger/lib/createLogger.js
|
|
555072
|
-
var LoggerImpl = class {
|
|
555073
|
-
log;
|
|
555074
|
-
enabled;
|
|
555075
|
-
constructor(log4, enabled = true) {
|
|
555076
|
-
this.log = log4;
|
|
555077
|
-
this.enabled = enabled;
|
|
555078
|
-
}
|
|
555079
|
-
disable() {
|
|
555080
|
-
this.enabled = false;
|
|
555081
|
-
}
|
|
555082
|
-
enable() {
|
|
555083
|
-
this.enabled = true;
|
|
555084
|
-
}
|
|
555085
|
-
debug(...args) {
|
|
555086
|
-
if (this.enabled) {
|
|
555087
|
-
this.log(LogLevel2.Debug, ...args);
|
|
555088
|
-
}
|
|
555089
|
-
}
|
|
555090
|
-
info(...args) {
|
|
555091
|
-
if (this.enabled) {
|
|
555092
|
-
this.log(LogLevel2.Info, ...args);
|
|
555093
|
-
}
|
|
555094
|
-
}
|
|
555095
|
-
warn(...args) {
|
|
555096
|
-
if (this.enabled) {
|
|
555097
|
-
this.log(LogLevel2.Warn, ...args);
|
|
555098
|
-
}
|
|
555099
|
-
}
|
|
555100
|
-
error(...args) {
|
|
555101
|
-
if (this.enabled) {
|
|
555102
|
-
this.log(LogLevel2.Error, ...args);
|
|
555103
|
-
}
|
|
555104
|
-
}
|
|
555105
|
-
trace(...args) {
|
|
555106
|
-
if (this.enabled) {
|
|
555107
|
-
this.log(LogLevel2.Trace, ...args);
|
|
555108
|
-
}
|
|
555109
|
-
}
|
|
555110
|
-
};
|
|
555111
|
-
function createLogger4(log4) {
|
|
555112
|
-
return new LoggerImpl(log4);
|
|
555113
|
-
}
|
|
555114
|
-
|
|
555115
|
-
// ../logger/lib/console.js
|
|
555116
|
-
var CONSOLE_LOGGER = Object.freeze(createLogger4(log3));
|
|
555117
|
-
function log3(level, ...args) {
|
|
555118
|
-
const consoleLogger = getConsoleLoggerForLevel(level);
|
|
555119
|
-
consoleLogger(...args);
|
|
555120
|
-
}
|
|
555121
|
-
function getConsoleLoggerForLevel(level) {
|
|
555122
|
-
switch (level) {
|
|
555123
|
-
case LogLevel2.Trace:
|
|
555124
|
-
return console.trace;
|
|
555125
|
-
case LogLevel2.Debug:
|
|
555126
|
-
return console.debug;
|
|
555127
|
-
case LogLevel2.Info:
|
|
555128
|
-
return console.info;
|
|
555129
|
-
case LogLevel2.Warn:
|
|
555130
|
-
return console.warn;
|
|
555131
|
-
case LogLevel2.Error:
|
|
555132
|
-
return console.error;
|
|
555133
|
-
}
|
|
555134
|
-
}
|
|
555135
|
-
|
|
555136
|
-
// ../task-context/lib/TaskAbortSignal.js
|
|
555137
|
-
var TaskAbortSignal = class {
|
|
555138
|
-
__brand = "TaskAbortSignal";
|
|
555139
|
-
};
|
|
555140
|
-
|
|
555141
|
-
// ../task-context/lib/TaskContext.js
|
|
555142
|
-
var TaskResult;
|
|
555143
|
-
(function(TaskResult2) {
|
|
555144
|
-
TaskResult2[TaskResult2["Success"] = 0] = "Success";
|
|
555145
|
-
TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
|
|
555146
|
-
})(TaskResult || (TaskResult = {}));
|
|
555147
|
-
|
|
555148
|
-
// ../task-context/lib/MockTaskContext.js
|
|
555149
|
-
function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
555150
|
-
const context3 = {
|
|
555151
|
-
logger: logger4,
|
|
555152
|
-
takeOverTerminal: () => {
|
|
555153
|
-
throw new Error("Not implemented");
|
|
555154
|
-
},
|
|
555155
|
-
failAndThrow: (message, error50) => {
|
|
555156
|
-
const parts = [];
|
|
555157
|
-
if (message != null) {
|
|
555158
|
-
parts.push(message);
|
|
555159
|
-
}
|
|
555160
|
-
if (error50 != null) {
|
|
555161
|
-
parts.push(JSON.stringify(error50));
|
|
555162
|
-
}
|
|
555163
|
-
if (parts.length > 0) {
|
|
555164
|
-
context3.logger.error(...parts);
|
|
555165
|
-
}
|
|
555166
|
-
throw new TaskAbortSignal();
|
|
555167
|
-
},
|
|
555168
|
-
failWithoutThrowing: (message, error50) => {
|
|
555169
|
-
context3.failAndThrow(message, error50);
|
|
555170
|
-
},
|
|
555171
|
-
getResult: () => TaskResult.Success,
|
|
555172
|
-
addInteractiveTask: () => {
|
|
555173
|
-
throw new Error("Not implemented");
|
|
555174
|
-
},
|
|
555175
|
-
runInteractiveTask: () => {
|
|
555176
|
-
throw new Error("Not implemented");
|
|
555177
|
-
},
|
|
555178
|
-
instrumentPostHogEvent: () => {
|
|
555179
|
-
throw new Error("Not implemented");
|
|
555180
|
-
}
|
|
555181
|
-
};
|
|
555182
|
-
return context3;
|
|
555183
|
-
}
|
|
555184
|
-
|
|
555185
|
-
// ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
|
|
555186
555266
|
var import_path21 = __toESM(require("path"), 1);
|
|
555187
555267
|
var EMPTY_DEPENDENCIES_CONFIGURATION = {
|
|
555188
555268
|
dependencies: {}
|
|
@@ -571169,7 +571249,7 @@ function getInline2(typeDeclaration2) {
|
|
|
571169
571249
|
function getTypeDeclaration(typeId, types4) {
|
|
571170
571250
|
const maybeTypeDeclaration = types4[typeId];
|
|
571171
571251
|
if (maybeTypeDeclaration == null) {
|
|
571172
|
-
throw
|
|
571252
|
+
throw CliError.internalError(`Failed to load type declaration for type ${typeId}`);
|
|
571173
571253
|
}
|
|
571174
571254
|
return maybeTypeDeclaration;
|
|
571175
571255
|
}
|
|
@@ -571231,7 +571311,7 @@ function getObjectTypeDeclarationFromTypeId(typeId, ir15) {
|
|
|
571231
571311
|
}
|
|
571232
571312
|
}
|
|
571233
571313
|
}
|
|
571234
|
-
throw
|
|
571314
|
+
throw CliError.internalError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
|
|
571235
571315
|
}
|
|
571236
571316
|
function getAllPropertiesForObject2({ objectTypeDeclaration, ir: ir15 }) {
|
|
571237
571317
|
const extendedProperties = objectTypeDeclaration.extends.flatMap((extended) => {
|
|
@@ -579493,7 +579573,8 @@ function formatLog({ breadcrumbs = [], title: title3, subtitle }) {
|
|
|
579493
579573
|
}
|
|
579494
579574
|
|
|
579495
579575
|
// ../cli-logger/lib/logErrorMessage.js
|
|
579496
|
-
|
|
579576
|
+
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
579577
|
+
function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel.Error }) {
|
|
579497
579578
|
if (message != null) {
|
|
579498
579579
|
logger4.log(logLevel, message);
|
|
579499
579580
|
} else if (error50 == null) {
|
|
@@ -579518,6 +579599,9 @@ function convertErrorToString(error50) {
|
|
|
579518
579599
|
return error50;
|
|
579519
579600
|
}
|
|
579520
579601
|
if (error50 instanceof Error) {
|
|
579602
|
+
if (error50?.message?.includes("globalThis")) {
|
|
579603
|
+
return USE_NODE_18_OR_ABOVE_MESSAGE;
|
|
579604
|
+
}
|
|
579521
579605
|
return error50.message;
|
|
579522
579606
|
}
|
|
579523
579607
|
return void 0;
|
|
@@ -580301,13 +580385,13 @@ function formatLog2(log4, { includeDebugInfo }) {
|
|
|
580301
580385
|
}
|
|
580302
580386
|
content5 += "\n";
|
|
580303
580387
|
switch (log4.level) {
|
|
580304
|
-
case
|
|
580388
|
+
case LogLevel.Error:
|
|
580305
580389
|
return source_default.red(content5);
|
|
580306
|
-
case
|
|
580390
|
+
case LogLevel.Warn:
|
|
580307
580391
|
return source_default.hex("FFA500")(content5);
|
|
580308
|
-
case
|
|
580309
|
-
case
|
|
580310
|
-
case
|
|
580392
|
+
case LogLevel.Trace:
|
|
580393
|
+
case LogLevel.Debug:
|
|
580394
|
+
case LogLevel.Info:
|
|
580311
580395
|
return content5;
|
|
580312
580396
|
}
|
|
580313
580397
|
}
|
|
@@ -580317,15 +580401,15 @@ function getDebugPrefix(log4) {
|
|
|
580317
580401
|
}
|
|
580318
580402
|
function getLogLevelAsString(logLevel) {
|
|
580319
580403
|
switch (logLevel) {
|
|
580320
|
-
case
|
|
580404
|
+
case LogLevel.Trace:
|
|
580321
580405
|
return "TRACE";
|
|
580322
|
-
case
|
|
580406
|
+
case LogLevel.Debug:
|
|
580323
580407
|
return "DEBUG";
|
|
580324
|
-
case
|
|
580408
|
+
case LogLevel.Info:
|
|
580325
580409
|
return "INFO";
|
|
580326
|
-
case
|
|
580410
|
+
case LogLevel.Warn:
|
|
580327
580411
|
return "WARN";
|
|
580328
|
-
case
|
|
580412
|
+
case LogLevel.Error:
|
|
580329
580413
|
return "ERROR";
|
|
580330
580414
|
default:
|
|
580331
580415
|
assertNever(logLevel);
|
|
@@ -606050,22 +606134,22 @@ var ErrorCollector2 = class {
|
|
|
606050
606134
|
}
|
|
606051
606135
|
switch (level) {
|
|
606052
606136
|
case APIErrorLevel.ERROR:
|
|
606053
|
-
this.logger.log(
|
|
606137
|
+
this.logger.log(LogLevel.Debug, error50.message);
|
|
606054
606138
|
if (error50.path && error50.path.length > 0) {
|
|
606055
606139
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606056
606140
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606057
|
-
this.logger.log(
|
|
606141
|
+
this.logger.log(LogLevel.Debug, ` - at location (${locationInfo})`);
|
|
606058
606142
|
}
|
|
606059
606143
|
break;
|
|
606060
606144
|
case APIErrorLevel.WARNING:
|
|
606061
|
-
this.logger.log(
|
|
606145
|
+
this.logger.log(LogLevel.Warn, error50.message);
|
|
606062
606146
|
if (error50.path && error50.path.length > 0) {
|
|
606063
606147
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606064
606148
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606065
|
-
this.logger.log(
|
|
606149
|
+
this.logger.log(LogLevel.Warn, ` - at location (${locationInfo})`);
|
|
606066
606150
|
}
|
|
606067
606151
|
if (error50.resolution) {
|
|
606068
|
-
this.logger.log(
|
|
606152
|
+
this.logger.log(LogLevel.Warn, ` - resolution: ${error50.resolution}`);
|
|
606069
606153
|
}
|
|
606070
606154
|
break;
|
|
606071
606155
|
}
|
|
@@ -606094,7 +606178,7 @@ var BreadcrumbToLineNumber = class {
|
|
|
606094
606178
|
jsYaml.load(fileContent, { listener: this.map.listen() });
|
|
606095
606179
|
this.initialized = true;
|
|
606096
606180
|
} catch (error50) {
|
|
606097
|
-
this.logger.log(
|
|
606181
|
+
this.logger.log(LogLevel.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
|
|
606098
606182
|
}
|
|
606099
606183
|
}
|
|
606100
606184
|
/**
|
|
@@ -619363,851 +619447,16 @@ async function runRulesOnOSSWorkspace({ workspace, context: context3, rules }) {
|
|
|
619363
619447
|
return ruleResults.flat();
|
|
619364
619448
|
}
|
|
619365
619449
|
|
|
619366
|
-
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
619367
|
-
var TaskContextLogger = class {
|
|
619368
|
-
context;
|
|
619369
|
-
task;
|
|
619370
|
-
logLevel;
|
|
619371
|
-
enabled = true;
|
|
619372
|
-
collectedErrors = [];
|
|
619373
|
-
constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
|
|
619374
|
-
this.context = context3;
|
|
619375
|
-
this.task = task;
|
|
619376
|
-
this.logLevel = logLevel;
|
|
619377
|
-
}
|
|
619378
|
-
disable() {
|
|
619379
|
-
this.enabled = false;
|
|
619380
|
-
}
|
|
619381
|
-
enable() {
|
|
619382
|
-
this.enabled = true;
|
|
619383
|
-
}
|
|
619384
|
-
trace(..._args) {
|
|
619385
|
-
}
|
|
619386
|
-
debug(...args) {
|
|
619387
|
-
const message = args.join(" ");
|
|
619388
|
-
this.writeLog({ level: LogLevel2.Debug, message });
|
|
619389
|
-
if (this.shouldLogToTask(LogLevel2.Debug)) {
|
|
619390
|
-
if (this.task.logs == null) {
|
|
619391
|
-
this.task.logs = [];
|
|
619392
|
-
}
|
|
619393
|
-
this.task.logs.push({ level: "debug", message });
|
|
619394
|
-
}
|
|
619395
|
-
}
|
|
619396
|
-
info(...args) {
|
|
619397
|
-
const message = args.join(" ");
|
|
619398
|
-
this.writeLog({ level: LogLevel2.Info, message });
|
|
619399
|
-
if (this.shouldLogToTask(LogLevel2.Info)) {
|
|
619400
|
-
if (this.task.logs == null) {
|
|
619401
|
-
this.task.logs = [];
|
|
619402
|
-
}
|
|
619403
|
-
this.task.logs.push({ level: "debug", message });
|
|
619404
|
-
}
|
|
619405
|
-
}
|
|
619406
|
-
warn(...args) {
|
|
619407
|
-
const message = args.join(" ");
|
|
619408
|
-
this.writeLog({ level: LogLevel2.Warn, message });
|
|
619409
|
-
if (this.shouldLogToTask(LogLevel2.Warn)) {
|
|
619410
|
-
if (this.task.logs == null) {
|
|
619411
|
-
this.task.logs = [];
|
|
619412
|
-
}
|
|
619413
|
-
this.task.logs.push({ level: "warn", message });
|
|
619414
|
-
}
|
|
619415
|
-
}
|
|
619416
|
-
error(...args) {
|
|
619417
|
-
const message = args.join(" ");
|
|
619418
|
-
this.writeLog({ level: LogLevel2.Error, message });
|
|
619419
|
-
if (this.shouldLogToTask(LogLevel2.Error)) {
|
|
619420
|
-
this.collectedErrors.push(message);
|
|
619421
|
-
if (this.task.logs == null) {
|
|
619422
|
-
this.task.logs = [];
|
|
619423
|
-
}
|
|
619424
|
-
this.task.logs.push({ level: "error", message });
|
|
619425
|
-
}
|
|
619426
|
-
}
|
|
619427
|
-
log(level, ...args) {
|
|
619428
|
-
switch (level) {
|
|
619429
|
-
case LogLevel2.Debug:
|
|
619430
|
-
this.debug(...args);
|
|
619431
|
-
break;
|
|
619432
|
-
case LogLevel2.Info:
|
|
619433
|
-
this.info(...args);
|
|
619434
|
-
break;
|
|
619435
|
-
case LogLevel2.Warn:
|
|
619436
|
-
this.warn(...args);
|
|
619437
|
-
break;
|
|
619438
|
-
case LogLevel2.Error:
|
|
619439
|
-
this.error(...args);
|
|
619440
|
-
break;
|
|
619441
|
-
}
|
|
619442
|
-
}
|
|
619443
|
-
/**
|
|
619444
|
-
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
619445
|
-
* also write directly to stderr so logs are visible in CI runner output.
|
|
619446
|
-
*/
|
|
619447
|
-
writeLog({ level, message }) {
|
|
619448
|
-
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
619449
|
-
if (this.context.isTTY) {
|
|
619450
|
-
return;
|
|
619451
|
-
}
|
|
619452
|
-
if (!this.enabled) {
|
|
619453
|
-
return;
|
|
619454
|
-
}
|
|
619455
|
-
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
619456
|
-
switch (level) {
|
|
619457
|
-
case LogLevel2.Warn:
|
|
619458
|
-
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
619459
|
-
`);
|
|
619460
|
-
break;
|
|
619461
|
-
case LogLevel2.Error:
|
|
619462
|
-
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
619463
|
-
`);
|
|
619464
|
-
break;
|
|
619465
|
-
default:
|
|
619466
|
-
process.stderr.write(`${prefix2}: ${message}
|
|
619467
|
-
`);
|
|
619468
|
-
break;
|
|
619469
|
-
}
|
|
619470
|
-
}
|
|
619471
|
-
/**
|
|
619472
|
-
* Check if a message at the given level should be logged to the task's UI.
|
|
619473
|
-
*/
|
|
619474
|
-
shouldLogToTask(level) {
|
|
619475
|
-
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
619476
|
-
}
|
|
619477
|
-
};
|
|
619478
|
-
|
|
619479
|
-
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
619480
|
-
var TaskContextAdapter = class {
|
|
619481
|
-
result = TaskResult.Success;
|
|
619482
|
-
logger;
|
|
619483
|
-
constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
|
|
619484
|
-
if (task != null) {
|
|
619485
|
-
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
619486
|
-
} else {
|
|
619487
|
-
this.logger = createLogger4((level, ...args) => {
|
|
619488
|
-
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
619489
|
-
context3.stderr.log(level, ...args);
|
|
619490
|
-
}
|
|
619491
|
-
});
|
|
619492
|
-
}
|
|
619493
|
-
}
|
|
619494
|
-
async takeOverTerminal(run) {
|
|
619495
|
-
await run();
|
|
619496
|
-
}
|
|
619497
|
-
failAndThrow(message, error50) {
|
|
619498
|
-
this.failWithoutThrowing(message, error50);
|
|
619499
|
-
throw new TaskAbortSignal();
|
|
619500
|
-
}
|
|
619501
|
-
failWithoutThrowing(message, error50) {
|
|
619502
|
-
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
619503
|
-
if (fullMessage != null) {
|
|
619504
|
-
this.logger.error(fullMessage);
|
|
619505
|
-
}
|
|
619506
|
-
this.result = TaskResult.Failure;
|
|
619507
|
-
}
|
|
619508
|
-
getFullErrorMessage(message, error50) {
|
|
619509
|
-
const errorDetails = this.formatError(error50);
|
|
619510
|
-
if (message != null && errorDetails != null) {
|
|
619511
|
-
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
619512
|
-
}
|
|
619513
|
-
return message ?? errorDetails;
|
|
619514
|
-
}
|
|
619515
|
-
getResult() {
|
|
619516
|
-
return this.result;
|
|
619517
|
-
}
|
|
619518
|
-
addInteractiveTask(_params) {
|
|
619519
|
-
const subtask = {
|
|
619520
|
-
logger: this.logger,
|
|
619521
|
-
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
619522
|
-
failAndThrow: this.failAndThrow.bind(this),
|
|
619523
|
-
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
619524
|
-
getResult: () => this.result,
|
|
619525
|
-
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
619526
|
-
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
619527
|
-
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
619528
|
-
setSubtitle: (_subtitle) => {
|
|
619529
|
-
},
|
|
619530
|
-
start: () => {
|
|
619531
|
-
return subtask;
|
|
619532
|
-
},
|
|
619533
|
-
isStarted: () => true,
|
|
619534
|
-
finish: () => {
|
|
619535
|
-
},
|
|
619536
|
-
isFinished: () => true
|
|
619537
|
-
};
|
|
619538
|
-
return subtask;
|
|
619539
|
-
}
|
|
619540
|
-
async runInteractiveTask(params2, run) {
|
|
619541
|
-
const subtask = this.addInteractiveTask(params2).start();
|
|
619542
|
-
try {
|
|
619543
|
-
await run(subtask);
|
|
619544
|
-
return true;
|
|
619545
|
-
} catch {
|
|
619546
|
-
return false;
|
|
619547
|
-
}
|
|
619548
|
-
}
|
|
619549
|
-
instrumentPostHogEvent(_event) {
|
|
619550
|
-
}
|
|
619551
|
-
formatError(error50) {
|
|
619552
|
-
if (error50 == null) {
|
|
619553
|
-
return void 0;
|
|
619554
|
-
}
|
|
619555
|
-
if (error50 instanceof Error) {
|
|
619556
|
-
return error50.message;
|
|
619557
|
-
}
|
|
619558
|
-
if (typeof error50 === "string") {
|
|
619559
|
-
return error50;
|
|
619560
|
-
}
|
|
619561
|
-
if (typeof error50 === "object") {
|
|
619562
|
-
const message = this.extractErrorMessage(error50);
|
|
619563
|
-
if (message != null) {
|
|
619564
|
-
return message;
|
|
619565
|
-
}
|
|
619566
|
-
}
|
|
619567
|
-
try {
|
|
619568
|
-
return JSON.stringify(error50);
|
|
619569
|
-
} catch {
|
|
619570
|
-
return String(error50);
|
|
619571
|
-
}
|
|
619572
|
-
}
|
|
619573
|
-
/**
|
|
619574
|
-
* Attempts to extract a human-readable message from a structured error object.
|
|
619575
|
-
*
|
|
619576
|
-
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
619577
|
-
* { content: { body: { message: "..." } } }
|
|
619578
|
-
* { body: { message: "..." } }
|
|
619579
|
-
* { message: "..." }
|
|
619580
|
-
*/
|
|
619581
|
-
extractErrorMessage(error50) {
|
|
619582
|
-
const record21 = error50;
|
|
619583
|
-
if (typeof record21.message === "string") {
|
|
619584
|
-
return record21.message;
|
|
619585
|
-
}
|
|
619586
|
-
if (record21.body != null && typeof record21.body === "object") {
|
|
619587
|
-
const body = record21.body;
|
|
619588
|
-
if (typeof body.message === "string") {
|
|
619589
|
-
return body.message;
|
|
619590
|
-
}
|
|
619591
|
-
}
|
|
619592
|
-
if (record21.content != null && typeof record21.content === "object") {
|
|
619593
|
-
return this.extractErrorMessage(record21.content);
|
|
619594
|
-
}
|
|
619595
|
-
return void 0;
|
|
619596
|
-
}
|
|
619597
|
-
};
|
|
619598
|
-
|
|
619599
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
619600
|
-
init_lib6();
|
|
619601
|
-
|
|
619602
|
-
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
619603
|
-
function isOpenRpcSpec(spec) {
|
|
619604
|
-
return "openrpc" in spec;
|
|
619605
|
-
}
|
|
619606
|
-
|
|
619607
|
-
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
619608
|
-
function isProtobufSpec(spec) {
|
|
619609
|
-
return "proto" in spec;
|
|
619610
|
-
}
|
|
619611
|
-
|
|
619612
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
619613
|
-
var LegacyApiSpecAdapter = class {
|
|
619614
|
-
context;
|
|
619615
|
-
constructor(config5) {
|
|
619616
|
-
this.context = config5.context;
|
|
619617
|
-
}
|
|
619618
|
-
adapt(spec) {
|
|
619619
|
-
if (isOpenApiSpec(spec)) {
|
|
619620
|
-
return this.adaptOpenApiSpec(spec);
|
|
619621
|
-
}
|
|
619622
|
-
if (isAsyncApiSpec(spec)) {
|
|
619623
|
-
return this.adaptAsyncApiSpec(spec);
|
|
619624
|
-
}
|
|
619625
|
-
if (isProtobufSpec(spec)) {
|
|
619626
|
-
return this.adaptProtobufSpec(spec);
|
|
619627
|
-
}
|
|
619628
|
-
if (isOpenRpcSpec(spec)) {
|
|
619629
|
-
return this.adaptOpenRpcSpec(spec);
|
|
619630
|
-
}
|
|
619631
|
-
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
619632
|
-
}
|
|
619633
|
-
convertAll(specs) {
|
|
619634
|
-
return specs.map((spec) => this.adapt(spec));
|
|
619635
|
-
}
|
|
619636
|
-
adaptOpenApiSpec(spec) {
|
|
619637
|
-
return {
|
|
619638
|
-
type: "openapi",
|
|
619639
|
-
absoluteFilepath: spec.openapi,
|
|
619640
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619641
|
-
absoluteFilepathToOverlays: spec.overlays,
|
|
619642
|
-
namespace: spec.namespace,
|
|
619643
|
-
source: {
|
|
619644
|
-
type: "openapi",
|
|
619645
|
-
file: spec.openapi
|
|
619646
|
-
},
|
|
619647
|
-
settings: this.adaptOpenApiSettings(spec.settings)
|
|
619648
|
-
};
|
|
619649
|
-
}
|
|
619650
|
-
adaptAsyncApiSpec(spec) {
|
|
619651
|
-
return {
|
|
619652
|
-
type: "openapi",
|
|
619653
|
-
absoluteFilepath: spec.asyncapi,
|
|
619654
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619655
|
-
absoluteFilepathToOverlays: void 0,
|
|
619656
|
-
namespace: spec.namespace,
|
|
619657
|
-
source: {
|
|
619658
|
-
type: "asyncapi",
|
|
619659
|
-
file: spec.asyncapi
|
|
619660
|
-
},
|
|
619661
|
-
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
619662
|
-
};
|
|
619663
|
-
}
|
|
619664
|
-
adaptProtobufSpec(spec) {
|
|
619665
|
-
const proto3 = spec.proto;
|
|
619666
|
-
return {
|
|
619667
|
-
type: "protobuf",
|
|
619668
|
-
absoluteFilepathToProtobufRoot: proto3.root,
|
|
619669
|
-
absoluteFilepathToProtobufTarget: proto3.target,
|
|
619670
|
-
absoluteFilepathToOverrides: proto3.overrides,
|
|
619671
|
-
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
619672
|
-
generateLocally: proto3.localGeneration ?? false,
|
|
619673
|
-
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
619674
|
-
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
619675
|
-
settings: void 0
|
|
619676
|
-
};
|
|
619677
|
-
}
|
|
619678
|
-
adaptOpenRpcSpec(spec) {
|
|
619679
|
-
return {
|
|
619680
|
-
type: "openrpc",
|
|
619681
|
-
absoluteFilepath: spec.openrpc,
|
|
619682
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619683
|
-
namespace: void 0
|
|
619684
|
-
};
|
|
619685
|
-
}
|
|
619686
|
-
adaptOpenApiSettings(settings) {
|
|
619687
|
-
if (settings == null) {
|
|
619688
|
-
return void 0;
|
|
619689
|
-
}
|
|
619690
|
-
const result = {
|
|
619691
|
-
// Base API settings
|
|
619692
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
619693
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
619694
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
619695
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
619696
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
619697
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
619698
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
619699
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
619700
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
619701
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
619702
|
-
// OpenAPI-specific settings
|
|
619703
|
-
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
619704
|
-
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
619705
|
-
inlinePathParameters: settings.inlinePathParameters,
|
|
619706
|
-
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
619707
|
-
objectQueryParameters: settings.objectQueryParameters,
|
|
619708
|
-
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
619709
|
-
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
619710
|
-
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
619711
|
-
filter: settings.filter,
|
|
619712
|
-
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
619713
|
-
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
619714
|
-
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
619715
|
-
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
619716
|
-
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
619717
|
-
resolveAliases: settings.resolveAliases,
|
|
619718
|
-
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
619719
|
-
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
619720
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
619721
|
-
};
|
|
619722
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
619723
|
-
return hasSettings ? result : void 0;
|
|
619724
|
-
}
|
|
619725
|
-
adaptAsyncApiSettings(settings) {
|
|
619726
|
-
if (settings == null) {
|
|
619727
|
-
return void 0;
|
|
619728
|
-
}
|
|
619729
|
-
const result = {
|
|
619730
|
-
// Base API settings (shared)
|
|
619731
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
619732
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
619733
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
619734
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
619735
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
619736
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
619737
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
619738
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
619739
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
619740
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
619741
|
-
// AsyncAPI-specific settings
|
|
619742
|
-
asyncApiNaming: settings.messageNaming,
|
|
619743
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
619744
|
-
};
|
|
619745
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
619746
|
-
return hasSettings ? result : void 0;
|
|
619747
|
-
}
|
|
619748
|
-
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
619749
|
-
if (value == null) {
|
|
619750
|
-
return void 0;
|
|
619751
|
-
}
|
|
619752
|
-
switch (value) {
|
|
619753
|
-
case "always":
|
|
619754
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
619755
|
-
case "never":
|
|
619756
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
619757
|
-
default:
|
|
619758
|
-
return void 0;
|
|
619759
|
-
}
|
|
619760
|
-
}
|
|
619761
|
-
adaptPathParameterOrder(value) {
|
|
619762
|
-
if (value == null) {
|
|
619763
|
-
return void 0;
|
|
619764
|
-
}
|
|
619765
|
-
switch (value) {
|
|
619766
|
-
case "urlOrder":
|
|
619767
|
-
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
619768
|
-
case "specOrder":
|
|
619769
|
-
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
619770
|
-
default:
|
|
619771
|
-
return void 0;
|
|
619772
|
-
}
|
|
619773
|
-
}
|
|
619774
|
-
adaptDefaultIntegerFormat(value) {
|
|
619775
|
-
if (value == null) {
|
|
619776
|
-
return void 0;
|
|
619777
|
-
}
|
|
619778
|
-
switch (value) {
|
|
619779
|
-
case "int32":
|
|
619780
|
-
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
619781
|
-
case "int64":
|
|
619782
|
-
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
619783
|
-
case "uint32":
|
|
619784
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
619785
|
-
case "uint64":
|
|
619786
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
619787
|
-
default:
|
|
619788
|
-
return void 0;
|
|
619789
|
-
}
|
|
619790
|
-
}
|
|
619791
|
-
adaptExampleGeneration(value) {
|
|
619792
|
-
if (value == null) {
|
|
619793
|
-
return void 0;
|
|
619794
|
-
}
|
|
619795
|
-
const result = {};
|
|
619796
|
-
if (value.request != null) {
|
|
619797
|
-
result.request = { "max-depth": value.request.maxDepth };
|
|
619798
|
-
}
|
|
619799
|
-
if (value.response != null) {
|
|
619800
|
-
result.response = { "max-depth": value.response.maxDepth };
|
|
619801
|
-
}
|
|
619802
|
-
return result;
|
|
619803
|
-
}
|
|
619804
|
-
};
|
|
619805
|
-
|
|
619806
|
-
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
619807
|
-
function isConjureSpec(spec) {
|
|
619808
|
-
return "conjure" in spec;
|
|
619809
|
-
}
|
|
619810
|
-
|
|
619811
|
-
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
619812
|
-
var ApiDefinitionValidator = class {
|
|
619813
|
-
context;
|
|
619814
|
-
taskContext;
|
|
619815
|
-
cliVersion;
|
|
619816
|
-
constructor(config5) {
|
|
619817
|
-
this.context = config5.context;
|
|
619818
|
-
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
619819
|
-
this.cliVersion = config5.cliVersion;
|
|
619820
|
-
}
|
|
619821
|
-
/**
|
|
619822
|
-
* Validate an ApiDefinition.
|
|
619823
|
-
*
|
|
619824
|
-
* Runs both Fern definition validation and OSS workspace validation
|
|
619825
|
-
* to ensure the API definition is valid before generation.
|
|
619826
|
-
*/
|
|
619827
|
-
async validate(definition3) {
|
|
619828
|
-
const startTime = performance.now();
|
|
619829
|
-
const violations = [];
|
|
619830
|
-
const fernSpec = definition3.specs.find(isFernSpec);
|
|
619831
|
-
if (fernSpec != null) {
|
|
619832
|
-
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
619833
|
-
violations.push(...fernViolations);
|
|
619834
|
-
return {
|
|
619835
|
-
violations,
|
|
619836
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619837
|
-
workspaceRoot: fernSpec.fern,
|
|
619838
|
-
elapsedMillis: performance.now() - startTime
|
|
619839
|
-
};
|
|
619840
|
-
}
|
|
619841
|
-
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
619842
|
-
if (conjureSpec != null) {
|
|
619843
|
-
return {
|
|
619844
|
-
violations: [],
|
|
619845
|
-
hasErrors: false,
|
|
619846
|
-
workspaceRoot: this.context.cwd,
|
|
619847
|
-
elapsedMillis: performance.now() - startTime
|
|
619848
|
-
};
|
|
619849
|
-
}
|
|
619850
|
-
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
619851
|
-
violations.push(...ossViolations);
|
|
619852
|
-
return {
|
|
619853
|
-
violations,
|
|
619854
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619855
|
-
workspaceRoot: this.context.cwd,
|
|
619856
|
-
elapsedMillis: performance.now() - startTime
|
|
619857
|
-
};
|
|
619858
|
-
}
|
|
619859
|
-
async validateFernSpec(spec) {
|
|
619860
|
-
const violations = [];
|
|
619861
|
-
const lazyWorkspace = new LazyFernWorkspace({
|
|
619862
|
-
absoluteFilePath: dirname6(spec.fern),
|
|
619863
|
-
context: this.taskContext,
|
|
619864
|
-
cliVersion: this.cliVersion,
|
|
619865
|
-
generatorsConfiguration: void 0,
|
|
619866
|
-
workspaceName: void 0,
|
|
619867
|
-
changelog: void 0
|
|
619868
|
-
});
|
|
619869
|
-
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
619870
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
619871
|
-
violations.push(...fernViolations);
|
|
619872
|
-
return violations;
|
|
619873
|
-
}
|
|
619874
|
-
async validateOssSpecs(specs) {
|
|
619875
|
-
const violations = [];
|
|
619876
|
-
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
619877
|
-
if (ossSpecs.length === 0) {
|
|
619878
|
-
return violations;
|
|
619879
|
-
}
|
|
619880
|
-
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
619881
|
-
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
619882
|
-
const filteredSpecs = v1Specs.filter((spec) => {
|
|
619883
|
-
if (spec.type === "openrpc") {
|
|
619884
|
-
return false;
|
|
619885
|
-
}
|
|
619886
|
-
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
619887
|
-
return false;
|
|
619888
|
-
}
|
|
619889
|
-
return true;
|
|
619890
|
-
});
|
|
619891
|
-
const allSpecs = v1Specs.filter((spec) => {
|
|
619892
|
-
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
619893
|
-
return false;
|
|
619894
|
-
}
|
|
619895
|
-
return true;
|
|
619896
|
-
});
|
|
619897
|
-
const ossWorkspace = new OSSWorkspace({
|
|
619898
|
-
specs: filteredSpecs,
|
|
619899
|
-
allSpecs,
|
|
619900
|
-
absoluteFilePath: this.context.cwd,
|
|
619901
|
-
cliVersion: this.cliVersion,
|
|
619902
|
-
changelog: void 0,
|
|
619903
|
-
generatorsConfiguration: void 0,
|
|
619904
|
-
workspaceName: void 0
|
|
619905
|
-
});
|
|
619906
|
-
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
619907
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
619908
|
-
violations.push(...fernViolations);
|
|
619909
|
-
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
619910
|
-
violations.push(...ossViolations);
|
|
619911
|
-
return violations;
|
|
619912
|
-
}
|
|
619913
|
-
};
|
|
619914
|
-
|
|
619915
|
-
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
619916
|
-
var ApiChecker = class {
|
|
619917
|
-
context;
|
|
619918
|
-
cliVersion;
|
|
619919
|
-
task;
|
|
619920
|
-
constructor(config5) {
|
|
619921
|
-
this.context = config5.context;
|
|
619922
|
-
this.cliVersion = config5.cliVersion;
|
|
619923
|
-
this.task = config5.task;
|
|
619924
|
-
}
|
|
619925
|
-
/**
|
|
619926
|
-
* Check APIs in the workspace and display results.
|
|
619927
|
-
*
|
|
619928
|
-
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
619929
|
-
* only show errors but still report warning count in summary.
|
|
619930
|
-
*/
|
|
619931
|
-
async check({ workspace, apiNames, strict = false }) {
|
|
619932
|
-
const startTime = performance.now();
|
|
619933
|
-
const validApis = /* @__PURE__ */ new Set();
|
|
619934
|
-
const invalidApis = /* @__PURE__ */ new Set();
|
|
619935
|
-
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
619936
|
-
if (apisToCheck.length === 0) {
|
|
619937
|
-
return {
|
|
619938
|
-
validApis,
|
|
619939
|
-
invalidApis,
|
|
619940
|
-
violations: [],
|
|
619941
|
-
errorCount: 0,
|
|
619942
|
-
warningCount: 0,
|
|
619943
|
-
elapsedMillis: performance.now() - startTime
|
|
619944
|
-
};
|
|
619945
|
-
}
|
|
619946
|
-
const validator = new ApiDefinitionValidator({
|
|
619947
|
-
context: this.context,
|
|
619948
|
-
cliVersion: this.cliVersion,
|
|
619949
|
-
task: this.task
|
|
619950
|
-
});
|
|
619951
|
-
const allViolations = [];
|
|
619952
|
-
for (const apiName of apisToCheck) {
|
|
619953
|
-
const apiDefinition = workspace.apis[apiName];
|
|
619954
|
-
if (apiDefinition == null) {
|
|
619955
|
-
invalidApis.add(apiName);
|
|
619956
|
-
continue;
|
|
619957
|
-
}
|
|
619958
|
-
const result = await validator.validate(apiDefinition);
|
|
619959
|
-
if (result.hasErrors) {
|
|
619960
|
-
invalidApis.add(apiName);
|
|
619961
|
-
} else {
|
|
619962
|
-
validApis.add(apiName);
|
|
619963
|
-
}
|
|
619964
|
-
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
619965
|
-
const resolvedViolations = this.resolveViolationPaths({
|
|
619966
|
-
workspaceRoot: result.workspaceRoot,
|
|
619967
|
-
apiName,
|
|
619968
|
-
apiSpecType,
|
|
619969
|
-
apiDefinition,
|
|
619970
|
-
violations: result.violations
|
|
619971
|
-
});
|
|
619972
|
-
allViolations.push(...resolvedViolations);
|
|
619973
|
-
}
|
|
619974
|
-
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
619975
|
-
return {
|
|
619976
|
-
...this.countViolations(dedupedViolations),
|
|
619977
|
-
validApis,
|
|
619978
|
-
invalidApis,
|
|
619979
|
-
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619980
|
-
elapsedMillis: performance.now() - startTime
|
|
619981
|
-
};
|
|
619982
|
-
}
|
|
619983
|
-
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
619984
|
-
return violations.map((violation) => {
|
|
619985
|
-
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
619986
|
-
return {
|
|
619987
|
-
...violation,
|
|
619988
|
-
message,
|
|
619989
|
-
displayRelativeFilepath: this.resolveDisplayPath({
|
|
619990
|
-
workspaceRoot,
|
|
619991
|
-
apiDefinition,
|
|
619992
|
-
apiSpecType,
|
|
619993
|
-
violation
|
|
619994
|
-
}),
|
|
619995
|
-
apiSpecType,
|
|
619996
|
-
apiName,
|
|
619997
|
-
// We don't actually surface valuable line/column information yet, but
|
|
619998
|
-
// this at least points to the correct file.
|
|
619999
|
-
line: 1,
|
|
620000
|
-
column: 1
|
|
620001
|
-
};
|
|
620002
|
-
});
|
|
620003
|
-
}
|
|
620004
|
-
/**
|
|
620005
|
-
* Format a violation message for non-Fern (OSS) specs.
|
|
620006
|
-
*
|
|
620007
|
-
* Prepends a human-readable node path so users can locate the endpoint,
|
|
620008
|
-
* then strips synthetic file paths from the body of the message.
|
|
620009
|
-
*/
|
|
620010
|
-
formatOssMessage(violation) {
|
|
620011
|
-
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
620012
|
-
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
620013
|
-
if (nodePathPrefix.length === 0) {
|
|
620014
|
-
return strippedMessage;
|
|
620015
|
-
}
|
|
620016
|
-
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
620017
|
-
}
|
|
620018
|
-
/**
|
|
620019
|
-
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
620020
|
-
*
|
|
620021
|
-
* Skips the leading "service" segment since it's implicit.
|
|
620022
|
-
*/
|
|
620023
|
-
formatNodePath(nodePath) {
|
|
620024
|
-
const parts = [];
|
|
620025
|
-
for (const item of nodePath) {
|
|
620026
|
-
if (typeof item === "string") {
|
|
620027
|
-
parts.push(item);
|
|
620028
|
-
} else {
|
|
620029
|
-
parts.push(item.key);
|
|
620030
|
-
}
|
|
620031
|
-
}
|
|
620032
|
-
if (parts[0] === "service") {
|
|
620033
|
-
parts.shift();
|
|
620034
|
-
}
|
|
620035
|
-
return parts.join(" -> ");
|
|
620036
|
-
}
|
|
620037
|
-
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
620038
|
-
if (apiSpecType === "fern") {
|
|
620039
|
-
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
620040
|
-
return relativize(this.context.cwd, absolutePath);
|
|
620041
|
-
}
|
|
620042
|
-
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
620043
|
-
}
|
|
620044
|
-
resolveOssDisplayPath(apiDefinition, violation) {
|
|
620045
|
-
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
620046
|
-
if (ossSpecs.length === 0) {
|
|
620047
|
-
return violation.relativeFilepath;
|
|
620048
|
-
}
|
|
620049
|
-
if (ossSpecs.length > 1) {
|
|
620050
|
-
for (const spec of ossSpecs) {
|
|
620051
|
-
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
620052
|
-
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
620053
|
-
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
620054
|
-
return relativize(this.context.cwd, filePath2);
|
|
620055
|
-
}
|
|
620056
|
-
}
|
|
620057
|
-
}
|
|
620058
|
-
const firstSpec = ossSpecs[0];
|
|
620059
|
-
if (firstSpec == null) {
|
|
620060
|
-
return violation.relativeFilepath;
|
|
620061
|
-
}
|
|
620062
|
-
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
620063
|
-
return relativize(this.context.cwd, filePath);
|
|
620064
|
-
}
|
|
620065
|
-
deduplicateViolations(violations) {
|
|
620066
|
-
const seen = /* @__PURE__ */ new Set();
|
|
620067
|
-
return violations.filter((v23) => {
|
|
620068
|
-
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
620069
|
-
if (seen.has(key2)) {
|
|
620070
|
-
return false;
|
|
620071
|
-
}
|
|
620072
|
-
seen.add(key2);
|
|
620073
|
-
return true;
|
|
620074
|
-
});
|
|
620075
|
-
}
|
|
620076
|
-
/**
|
|
620077
|
-
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
620078
|
-
*
|
|
620079
|
-
* The validator produces messages like:
|
|
620080
|
-
* "- pet.yml -> getPetById /pet/{petId}"
|
|
620081
|
-
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
620082
|
-
* so we strip them to produce:
|
|
620083
|
-
* "- getPetById /pet/{petId}"
|
|
620084
|
-
*/
|
|
620085
|
-
stripSyntheticFilePaths(message) {
|
|
620086
|
-
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
620087
|
-
}
|
|
620088
|
-
countViolations(violations) {
|
|
620089
|
-
let errorCount = 0;
|
|
620090
|
-
let warningCount = 0;
|
|
620091
|
-
for (const violation of violations) {
|
|
620092
|
-
switch (violation.severity) {
|
|
620093
|
-
case "fatal":
|
|
620094
|
-
case "error":
|
|
620095
|
-
errorCount++;
|
|
620096
|
-
break;
|
|
620097
|
-
case "warning":
|
|
620098
|
-
warningCount++;
|
|
620099
|
-
break;
|
|
620100
|
-
default:
|
|
620101
|
-
assertNever(violation.severity);
|
|
620102
|
-
}
|
|
620103
|
-
}
|
|
620104
|
-
return { errorCount, warningCount };
|
|
620105
|
-
}
|
|
620106
|
-
};
|
|
620107
|
-
|
|
620108
|
-
// ../cli-v2/lib/errors/CliError.js
|
|
620109
|
-
var CliError = class _CliError extends Error {
|
|
620110
|
-
code;
|
|
620111
|
-
docsLink;
|
|
620112
|
-
constructor({ message, code: code5, docsLink }) {
|
|
620113
|
-
super(message);
|
|
620114
|
-
this.code = code5;
|
|
620115
|
-
this.docsLink = docsLink;
|
|
620116
|
-
}
|
|
620117
|
-
static authRequired(message) {
|
|
620118
|
-
return new _CliError({
|
|
620119
|
-
message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
|
|
620120
|
-
code: "AUTH_REQUIRED"
|
|
620121
|
-
});
|
|
620122
|
-
}
|
|
620123
|
-
static generationFailed(message) {
|
|
620124
|
-
return new _CliError({
|
|
620125
|
-
message: message ?? "Generation failed. Please check the logs for more information.",
|
|
620126
|
-
code: "GENERATION_FAILED"
|
|
620127
|
-
});
|
|
620128
|
-
}
|
|
620129
|
-
static badRequest(message) {
|
|
620130
|
-
return new _CliError({ message, code: "BAD_REQUEST_ERROR" });
|
|
620131
|
-
}
|
|
620132
|
-
static notFound(message) {
|
|
620133
|
-
return new _CliError({ message, code: "NOT_FOUND_ERROR" });
|
|
620134
|
-
}
|
|
620135
|
-
static unauthorized(message) {
|
|
620136
|
-
return new _CliError({
|
|
620137
|
-
message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
|
|
620138
|
-
code: "UNAUTHORIZED_ERROR"
|
|
620139
|
-
});
|
|
620140
|
-
}
|
|
620141
|
-
static validationError(message) {
|
|
620142
|
-
return new _CliError({ message, code: "VALIDATION_ERROR" });
|
|
620143
|
-
}
|
|
620144
|
-
static internalError(message) {
|
|
620145
|
-
return new _CliError({ message, code: "INTERNAL_ERROR" });
|
|
620146
|
-
}
|
|
620147
|
-
/**
|
|
620148
|
-
* A sentinel error that causes the CLI to exit with a non-zero exit code, but no message. This
|
|
620149
|
-
* is useful when a command handles the failure message itself.
|
|
620150
|
-
*/
|
|
620151
|
-
static exit() {
|
|
620152
|
-
return new _CliError({
|
|
620153
|
-
message: "",
|
|
620154
|
-
code: "EXIT"
|
|
620155
|
-
});
|
|
620156
|
-
}
|
|
620157
|
-
};
|
|
620158
|
-
|
|
620159
|
-
// ../cli-v2/lib/ui/format.js
|
|
620160
|
-
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
620161
|
-
if (text9 == null) {
|
|
620162
|
-
return "";
|
|
620163
|
-
}
|
|
620164
|
-
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
620165
|
-
if (lines.length === 0) {
|
|
620166
|
-
return "";
|
|
620167
|
-
}
|
|
620168
|
-
const baseIndentStr = " ".repeat(baseIndent);
|
|
620169
|
-
const contIndentStr = " ".repeat(continuationIndent);
|
|
620170
|
-
if (icon != null) {
|
|
620171
|
-
const [first3, ...rest] = lines;
|
|
620172
|
-
const firstLine = `
|
|
620173
|
-
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
620174
|
-
const restLines = rest.map((line) => `
|
|
620175
|
-
${contIndentStr}${colorFn(line)}`).join("");
|
|
620176
|
-
return firstLine + restLines;
|
|
620177
|
-
}
|
|
620178
|
-
return lines.map((line) => `
|
|
620179
|
-
${baseIndentStr}${colorFn(line)}`).join("");
|
|
620180
|
-
}
|
|
620181
|
-
var Icons = {
|
|
620182
|
-
error: source_default.red("\u2717"),
|
|
620183
|
-
warning: source_default.yellow("\u26A0"),
|
|
620184
|
-
success: source_default.green("\u2713"),
|
|
620185
|
-
info: source_default.cyan("\u25C6")
|
|
620186
|
-
};
|
|
620187
|
-
var Colors = {
|
|
620188
|
-
error: source_default.red.bind(source_default),
|
|
620189
|
-
warning: source_default.yellow.bind(source_default),
|
|
620190
|
-
success: source_default.green.bind(source_default),
|
|
620191
|
-
info: source_default.cyan.bind(source_default),
|
|
620192
|
-
dim: source_default.dim.bind(source_default)
|
|
620193
|
-
};
|
|
620194
|
-
function formatBytes(bytes) {
|
|
620195
|
-
if (bytes === 0) {
|
|
620196
|
-
return "0 B";
|
|
620197
|
-
}
|
|
620198
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
620199
|
-
const base4 = 1024;
|
|
620200
|
-
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
620201
|
-
const value = bytes / Math.pow(base4, index3);
|
|
620202
|
-
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
620203
|
-
}
|
|
620204
|
-
|
|
620205
619450
|
// ../cli-v2/lib/auth/errors/KeyringUnavailableError.js
|
|
620206
|
-
var KeyringUnavailableError = class extends
|
|
619451
|
+
var KeyringUnavailableError = class _KeyringUnavailableError extends CliError {
|
|
620207
619452
|
platform;
|
|
620208
619453
|
cause;
|
|
620209
619454
|
constructor(platform3, cause) {
|
|
620210
|
-
super(
|
|
619455
|
+
super({
|
|
619456
|
+
message: getKeyringErrorMessage(platform3),
|
|
619457
|
+
code: CliError.Code.AuthError
|
|
619458
|
+
});
|
|
619459
|
+
Object.setPrototypeOf(this, _KeyringUnavailableError.prototype);
|
|
620211
619460
|
this.platform = platform3;
|
|
620212
619461
|
this.cause = cause;
|
|
620213
619462
|
}
|
|
@@ -620264,23 +619513,77 @@ If running in a headless environment, use FERN_TOKEN instead:
|
|
|
620264
619513
|
}
|
|
620265
619514
|
|
|
620266
619515
|
// ../cli-v2/lib/errors/SourcedValidationError.js
|
|
620267
|
-
var SourcedValidationError = class extends
|
|
619516
|
+
var SourcedValidationError = class _SourcedValidationError extends CliError {
|
|
620268
619517
|
issues;
|
|
620269
619518
|
constructor(issues) {
|
|
620270
|
-
super(
|
|
619519
|
+
super({
|
|
619520
|
+
message: issues.map((issue2) => issue2.toString()).join("\n"),
|
|
619521
|
+
code: CliError.Code.ValidationError
|
|
619522
|
+
});
|
|
619523
|
+
Object.setPrototypeOf(this, _SourcedValidationError.prototype);
|
|
620271
619524
|
this.issues = issues;
|
|
620272
619525
|
}
|
|
620273
619526
|
};
|
|
620274
619527
|
|
|
620275
619528
|
// ../cli-v2/lib/errors/ValidationError.js
|
|
620276
|
-
var ValidationError = class extends
|
|
619529
|
+
var ValidationError = class _ValidationError extends CliError {
|
|
620277
619530
|
violations;
|
|
620278
619531
|
constructor(violations) {
|
|
620279
|
-
super(
|
|
619532
|
+
super({
|
|
619533
|
+
message: violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"),
|
|
619534
|
+
code: CliError.Code.ValidationError
|
|
619535
|
+
});
|
|
619536
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
620280
619537
|
this.violations = violations;
|
|
620281
619538
|
}
|
|
620282
619539
|
};
|
|
620283
619540
|
|
|
619541
|
+
// ../cli-v2/lib/ui/format.js
|
|
619542
|
+
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
619543
|
+
if (text9 == null) {
|
|
619544
|
+
return "";
|
|
619545
|
+
}
|
|
619546
|
+
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
619547
|
+
if (lines.length === 0) {
|
|
619548
|
+
return "";
|
|
619549
|
+
}
|
|
619550
|
+
const baseIndentStr = " ".repeat(baseIndent);
|
|
619551
|
+
const contIndentStr = " ".repeat(continuationIndent);
|
|
619552
|
+
if (icon != null) {
|
|
619553
|
+
const [first3, ...rest] = lines;
|
|
619554
|
+
const firstLine = `
|
|
619555
|
+
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
619556
|
+
const restLines = rest.map((line) => `
|
|
619557
|
+
${contIndentStr}${colorFn(line)}`).join("");
|
|
619558
|
+
return firstLine + restLines;
|
|
619559
|
+
}
|
|
619560
|
+
return lines.map((line) => `
|
|
619561
|
+
${baseIndentStr}${colorFn(line)}`).join("");
|
|
619562
|
+
}
|
|
619563
|
+
var Icons = {
|
|
619564
|
+
error: source_default.red("\u2717"),
|
|
619565
|
+
warning: source_default.yellow("\u26A0"),
|
|
619566
|
+
success: source_default.green("\u2713"),
|
|
619567
|
+
info: source_default.cyan("\u25C6")
|
|
619568
|
+
};
|
|
619569
|
+
var Colors = {
|
|
619570
|
+
error: source_default.red.bind(source_default),
|
|
619571
|
+
warning: source_default.yellow.bind(source_default),
|
|
619572
|
+
success: source_default.green.bind(source_default),
|
|
619573
|
+
info: source_default.cyan.bind(source_default),
|
|
619574
|
+
dim: source_default.dim.bind(source_default)
|
|
619575
|
+
};
|
|
619576
|
+
function formatBytes(bytes) {
|
|
619577
|
+
if (bytes === 0) {
|
|
619578
|
+
return "0 B";
|
|
619579
|
+
}
|
|
619580
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
619581
|
+
const base4 = 1024;
|
|
619582
|
+
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
619583
|
+
const value = bytes / Math.pow(base4, index3);
|
|
619584
|
+
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
619585
|
+
}
|
|
619586
|
+
|
|
620284
619587
|
// ../auth/lib/orgs/checkOrganizationMembership.js
|
|
620285
619588
|
async function checkOrganizationMembership({ organization, token }) {
|
|
620286
619589
|
const venus = createVenusService({ token: token.value });
|
|
@@ -627700,7 +627003,7 @@ var AccessTokenPosthogManager = class {
|
|
|
627700
627003
|
properties: {
|
|
627701
627004
|
...event,
|
|
627702
627005
|
...event.properties,
|
|
627703
|
-
version: "4.68.
|
|
627006
|
+
version: "4.68.3-1-g429be56b56f",
|
|
627704
627007
|
usingAccessToken: true
|
|
627705
627008
|
}
|
|
627706
627009
|
});
|
|
@@ -627754,7 +627057,7 @@ var UserPosthogManager = class {
|
|
|
627754
627057
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
627755
627058
|
event: "CLI",
|
|
627756
627059
|
properties: {
|
|
627757
|
-
version: "4.68.
|
|
627060
|
+
version: "4.68.3-1-g429be56b56f",
|
|
627758
627061
|
...event,
|
|
627759
627062
|
...event.properties,
|
|
627760
627063
|
usingAccessToken: false,
|
|
@@ -631266,7 +630569,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631266
630569
|
* The caller is responsible for deciding which errors are worth reporting
|
|
631267
630570
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
631268
630571
|
*/
|
|
631269
|
-
captureException(error50) {
|
|
630572
|
+
captureException(error50, { errorCode }) {
|
|
631270
630573
|
if (this.sentry === void 0) {
|
|
631271
630574
|
return;
|
|
631272
630575
|
}
|
|
@@ -631274,7 +630577,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631274
630577
|
this.sentry.captureException(error50, {
|
|
631275
630578
|
captureContext: {
|
|
631276
630579
|
user: { id: this.distinctId },
|
|
631277
|
-
tags: { ...this.baseTags, ...this.accumulatedTags }
|
|
630580
|
+
tags: { ...this.baseTags, ...this.accumulatedTags, "error.code": errorCode }
|
|
631278
630581
|
}
|
|
631279
630582
|
});
|
|
631280
630583
|
} catch {
|
|
@@ -632174,6 +631477,7 @@ var Context = class _Context {
|
|
|
632174
631477
|
shutdownCallbacks = [];
|
|
632175
631478
|
isShuttingDown = false;
|
|
632176
631479
|
logFilePathPrinted = false;
|
|
631480
|
+
createdAt = Date.now();
|
|
632177
631481
|
cwd;
|
|
632178
631482
|
logLevel;
|
|
632179
631483
|
info;
|
|
@@ -632191,10 +631495,10 @@ var Context = class _Context {
|
|
|
632191
631495
|
}
|
|
632192
631496
|
constructor({ cwd: cwd2, logLevel, ttyAwareLogger, telemetry }) {
|
|
632193
631497
|
this.cwd = cwd2 ?? AbsoluteFilePath2.of(process.cwd());
|
|
632194
|
-
this.logLevel = logLevel ??
|
|
631498
|
+
this.logLevel = logLevel ?? LogLevel.Info;
|
|
632195
631499
|
this.info = parseCommandInfo(process.argv);
|
|
632196
|
-
this.stdout =
|
|
632197
|
-
this.stderr =
|
|
631500
|
+
this.stdout = createLogger((level, ...args) => this.log(level, ...args));
|
|
631501
|
+
this.stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
632198
631502
|
this.cache = new Cache({ logger: this.stderr });
|
|
632199
631503
|
this.logs = new LogFileWriter(this.cache.logs.absoluteFilePath);
|
|
632200
631504
|
this.ttyAwareLogger = ttyAwareLogger;
|
|
@@ -632252,7 +631556,7 @@ var Context = class _Context {
|
|
|
632252
631556
|
this.stderr.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
632253
631557
|
this.stderr.info("");
|
|
632254
631558
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632255
|
-
throw CliError.
|
|
631559
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632256
631560
|
}
|
|
632257
631561
|
return await this.promptAndLogin();
|
|
632258
631562
|
}
|
|
@@ -632262,7 +631566,7 @@ var Context = class _Context {
|
|
|
632262
631566
|
this.stderr.error(`${Icons.error} Your access token has expired.`);
|
|
632263
631567
|
this.stderr.info("");
|
|
632264
631568
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632265
|
-
throw CliError.
|
|
631569
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632266
631570
|
}
|
|
632267
631571
|
return await this.promptAndLogin();
|
|
632268
631572
|
}
|
|
@@ -632278,7 +631582,7 @@ var Context = class _Context {
|
|
|
632278
631582
|
}
|
|
632279
631583
|
]);
|
|
632280
631584
|
if (!confirm) {
|
|
632281
|
-
throw CliError.
|
|
631585
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632282
631586
|
}
|
|
632283
631587
|
this.stderr.info(`${Icons.info} Opening browser to log in to Fern...`);
|
|
632284
631588
|
this.stderr.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
@@ -632290,12 +631594,12 @@ var Context = class _Context {
|
|
|
632290
631594
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
632291
631595
|
if (payload == null) {
|
|
632292
631596
|
this.stderr.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
632293
|
-
throw CliError.
|
|
631597
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632294
631598
|
}
|
|
632295
631599
|
const email3 = payload.email;
|
|
632296
631600
|
if (email3 == null) {
|
|
632297
631601
|
this.stderr.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
632298
|
-
throw CliError.
|
|
631602
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632299
631603
|
}
|
|
632300
631604
|
await this.tokenService.login(email3, accessToken);
|
|
632301
631605
|
this.stderr.info(`${Icons.success} Logged in as ${source_default.bold(email3)}`);
|
|
@@ -632426,7 +631730,7 @@ ${source_default.dim(`Logs written to: ${this.logs.absoluteFilePath}`)}
|
|
|
632426
631730
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
632427
631731
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
632428
631732
|
this.ttyAwareLogger.log(filtered, {
|
|
632429
|
-
includeDebugInfo: this.logLevel ===
|
|
631733
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
632430
631734
|
stderr
|
|
632431
631735
|
});
|
|
632432
631736
|
}
|
|
@@ -632439,28 +631743,19 @@ var SIGTERM_EXIT_CODE = SIGNAL_EXIT_CODE_BASE + 15;
|
|
|
632439
631743
|
function withContext(handler3) {
|
|
632440
631744
|
return async (args) => {
|
|
632441
631745
|
const context3 = await createContext(args);
|
|
632442
|
-
const startTime = Date.now();
|
|
632443
631746
|
setupSignalHandler(context3);
|
|
632444
631747
|
try {
|
|
632445
631748
|
await handler3(context3, args);
|
|
632446
631749
|
context3.telemetry.sendLifecycleEvent({
|
|
632447
631750
|
command: context3.info.command,
|
|
632448
631751
|
status: "success",
|
|
632449
|
-
durationMs: Date.now() -
|
|
631752
|
+
durationMs: Date.now() - context3.createdAt
|
|
632450
631753
|
});
|
|
632451
631754
|
await context3.telemetry.flush();
|
|
632452
631755
|
context3.finish();
|
|
632453
631756
|
await exitGracefully(0);
|
|
632454
631757
|
} catch (error50) {
|
|
632455
|
-
|
|
632456
|
-
context3.telemetry.captureException(error50);
|
|
632457
|
-
}
|
|
632458
|
-
context3.telemetry.sendLifecycleEvent({
|
|
632459
|
-
command: context3.info.command,
|
|
632460
|
-
status: "error",
|
|
632461
|
-
durationMs: Date.now() - startTime,
|
|
632462
|
-
errorCode: extractErrorCode(error50)
|
|
632463
|
-
});
|
|
631758
|
+
reportError(context3, error50);
|
|
632464
631759
|
await context3.telemetry.flush();
|
|
632465
631760
|
handleError(context3, error50);
|
|
632466
631761
|
context3.finish();
|
|
@@ -632500,7 +631795,7 @@ function handleError(context3, error50) {
|
|
|
632500
631795
|
return;
|
|
632501
631796
|
}
|
|
632502
631797
|
if (error50 instanceof CliError) {
|
|
632503
|
-
if (error50.message.length > 0) {
|
|
631798
|
+
if (error50.message && error50.message.length > 0) {
|
|
632504
631799
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632505
631800
|
`);
|
|
632506
631801
|
}
|
|
@@ -632509,7 +631804,7 @@ function handleError(context3, error50) {
|
|
|
632509
631804
|
if (error50 instanceof Error) {
|
|
632510
631805
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632511
631806
|
`);
|
|
632512
|
-
if (error50.stack != null && context3.logLevel ===
|
|
631807
|
+
if (error50.stack != null && context3.logLevel === LogLevel.Debug) {
|
|
632513
631808
|
process.stderr.write(`${source_default.dim(error50.stack)}
|
|
632514
631809
|
`);
|
|
632515
631810
|
}
|
|
@@ -632518,29 +631813,23 @@ function handleError(context3, error50) {
|
|
|
632518
631813
|
process.stderr.write(`${source_default.red(String(error50))}
|
|
632519
631814
|
`);
|
|
632520
631815
|
}
|
|
632521
|
-
function
|
|
631816
|
+
function reportError(context3, error50, options2) {
|
|
632522
631817
|
if (error50 instanceof TaskAbortSignal) {
|
|
632523
|
-
return
|
|
632524
|
-
}
|
|
632525
|
-
if (error50 instanceof CliError) {
|
|
632526
|
-
return error50.code === "INTERNAL_ERROR";
|
|
632527
|
-
}
|
|
632528
|
-
if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError || error50 instanceof KeyringUnavailableError) {
|
|
632529
|
-
return false;
|
|
632530
|
-
}
|
|
632531
|
-
return true;
|
|
632532
|
-
}
|
|
632533
|
-
function extractErrorCode(error50) {
|
|
632534
|
-
if (error50 instanceof CliError && error50.code != null) {
|
|
632535
|
-
return error50.code;
|
|
632536
|
-
}
|
|
632537
|
-
if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError) {
|
|
632538
|
-
return "VALIDATION_ERROR";
|
|
631818
|
+
return;
|
|
632539
631819
|
}
|
|
632540
|
-
|
|
632541
|
-
|
|
631820
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
631821
|
+
const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
|
|
631822
|
+
if (shouldReportToSentry(code5)) {
|
|
631823
|
+
context3.telemetry.captureException(capturable, {
|
|
631824
|
+
errorCode: code5
|
|
631825
|
+
});
|
|
632542
631826
|
}
|
|
632543
|
-
|
|
631827
|
+
context3.telemetry.sendLifecycleEvent({
|
|
631828
|
+
status: "error",
|
|
631829
|
+
command: context3.info.command,
|
|
631830
|
+
durationMs: Date.now() - context3.createdAt,
|
|
631831
|
+
errorCode: code5
|
|
631832
|
+
});
|
|
632544
631833
|
}
|
|
632545
631834
|
function setupSignalHandler(context3) {
|
|
632546
631835
|
const onSignal = (exitCode) => {
|
|
@@ -632565,18 +631854,771 @@ function exitGracefully(code5) {
|
|
|
632565
631854
|
function parseLogLevel(level) {
|
|
632566
631855
|
switch (level.toLowerCase()) {
|
|
632567
631856
|
case "debug":
|
|
632568
|
-
return
|
|
631857
|
+
return LogLevel.Debug;
|
|
632569
631858
|
case "info":
|
|
632570
|
-
return
|
|
631859
|
+
return LogLevel.Info;
|
|
632571
631860
|
case "warn":
|
|
632572
|
-
return
|
|
631861
|
+
return LogLevel.Warn;
|
|
632573
631862
|
case "error":
|
|
632574
|
-
return
|
|
631863
|
+
return LogLevel.Error;
|
|
632575
631864
|
default:
|
|
632576
|
-
return
|
|
631865
|
+
return LogLevel.Info;
|
|
632577
631866
|
}
|
|
632578
631867
|
}
|
|
632579
631868
|
|
|
631869
|
+
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
631870
|
+
var TaskContextLogger = class {
|
|
631871
|
+
context;
|
|
631872
|
+
task;
|
|
631873
|
+
logLevel;
|
|
631874
|
+
enabled = true;
|
|
631875
|
+
collectedErrors = [];
|
|
631876
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631877
|
+
this.context = context3;
|
|
631878
|
+
this.task = task;
|
|
631879
|
+
this.logLevel = logLevel;
|
|
631880
|
+
}
|
|
631881
|
+
disable() {
|
|
631882
|
+
this.enabled = false;
|
|
631883
|
+
}
|
|
631884
|
+
enable() {
|
|
631885
|
+
this.enabled = true;
|
|
631886
|
+
}
|
|
631887
|
+
trace(..._args) {
|
|
631888
|
+
}
|
|
631889
|
+
debug(...args) {
|
|
631890
|
+
const message = args.join(" ");
|
|
631891
|
+
this.writeLog({ level: LogLevel.Debug, message });
|
|
631892
|
+
if (this.shouldLogToTask(LogLevel.Debug)) {
|
|
631893
|
+
if (this.task.logs == null) {
|
|
631894
|
+
this.task.logs = [];
|
|
631895
|
+
}
|
|
631896
|
+
this.task.logs.push({ level: "debug", message });
|
|
631897
|
+
}
|
|
631898
|
+
}
|
|
631899
|
+
info(...args) {
|
|
631900
|
+
const message = args.join(" ");
|
|
631901
|
+
this.writeLog({ level: LogLevel.Info, message });
|
|
631902
|
+
if (this.shouldLogToTask(LogLevel.Info)) {
|
|
631903
|
+
if (this.task.logs == null) {
|
|
631904
|
+
this.task.logs = [];
|
|
631905
|
+
}
|
|
631906
|
+
this.task.logs.push({ level: "debug", message });
|
|
631907
|
+
}
|
|
631908
|
+
}
|
|
631909
|
+
warn(...args) {
|
|
631910
|
+
const message = args.join(" ");
|
|
631911
|
+
this.writeLog({ level: LogLevel.Warn, message });
|
|
631912
|
+
if (this.shouldLogToTask(LogLevel.Warn)) {
|
|
631913
|
+
if (this.task.logs == null) {
|
|
631914
|
+
this.task.logs = [];
|
|
631915
|
+
}
|
|
631916
|
+
this.task.logs.push({ level: "warn", message });
|
|
631917
|
+
}
|
|
631918
|
+
}
|
|
631919
|
+
error(...args) {
|
|
631920
|
+
const message = args.join(" ");
|
|
631921
|
+
this.writeLog({ level: LogLevel.Error, message });
|
|
631922
|
+
if (this.shouldLogToTask(LogLevel.Error)) {
|
|
631923
|
+
this.collectedErrors.push(message);
|
|
631924
|
+
if (this.task.logs == null) {
|
|
631925
|
+
this.task.logs = [];
|
|
631926
|
+
}
|
|
631927
|
+
this.task.logs.push({ level: "error", message });
|
|
631928
|
+
}
|
|
631929
|
+
}
|
|
631930
|
+
log(level, ...args) {
|
|
631931
|
+
switch (level) {
|
|
631932
|
+
case LogLevel.Debug:
|
|
631933
|
+
this.debug(...args);
|
|
631934
|
+
break;
|
|
631935
|
+
case LogLevel.Info:
|
|
631936
|
+
this.info(...args);
|
|
631937
|
+
break;
|
|
631938
|
+
case LogLevel.Warn:
|
|
631939
|
+
this.warn(...args);
|
|
631940
|
+
break;
|
|
631941
|
+
case LogLevel.Error:
|
|
631942
|
+
this.error(...args);
|
|
631943
|
+
break;
|
|
631944
|
+
}
|
|
631945
|
+
}
|
|
631946
|
+
/**
|
|
631947
|
+
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
631948
|
+
* also write directly to stderr so logs are visible in CI runner output.
|
|
631949
|
+
*/
|
|
631950
|
+
writeLog({ level, message }) {
|
|
631951
|
+
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
631952
|
+
if (this.context.isTTY) {
|
|
631953
|
+
return;
|
|
631954
|
+
}
|
|
631955
|
+
if (!this.enabled) {
|
|
631956
|
+
return;
|
|
631957
|
+
}
|
|
631958
|
+
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
631959
|
+
switch (level) {
|
|
631960
|
+
case LogLevel.Warn:
|
|
631961
|
+
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
631962
|
+
`);
|
|
631963
|
+
break;
|
|
631964
|
+
case LogLevel.Error:
|
|
631965
|
+
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
631966
|
+
`);
|
|
631967
|
+
break;
|
|
631968
|
+
default:
|
|
631969
|
+
process.stderr.write(`${prefix2}: ${message}
|
|
631970
|
+
`);
|
|
631971
|
+
break;
|
|
631972
|
+
}
|
|
631973
|
+
}
|
|
631974
|
+
/**
|
|
631975
|
+
* Check if a message at the given level should be logged to the task's UI.
|
|
631976
|
+
*/
|
|
631977
|
+
shouldLogToTask(level) {
|
|
631978
|
+
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
631979
|
+
}
|
|
631980
|
+
};
|
|
631981
|
+
|
|
631982
|
+
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
631983
|
+
var TaskContextAdapter = class {
|
|
631984
|
+
result = TaskResult.Success;
|
|
631985
|
+
context;
|
|
631986
|
+
logger;
|
|
631987
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631988
|
+
this.context = context3;
|
|
631989
|
+
if (task != null) {
|
|
631990
|
+
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
631991
|
+
} else {
|
|
631992
|
+
this.logger = createLogger((level, ...args) => {
|
|
631993
|
+
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
631994
|
+
context3.stderr.log(level, ...args);
|
|
631995
|
+
}
|
|
631996
|
+
});
|
|
631997
|
+
}
|
|
631998
|
+
}
|
|
631999
|
+
async takeOverTerminal(run) {
|
|
632000
|
+
await run();
|
|
632001
|
+
}
|
|
632002
|
+
failAndThrow(message, error50, options2) {
|
|
632003
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
632004
|
+
throw new TaskAbortSignal();
|
|
632005
|
+
}
|
|
632006
|
+
failWithoutThrowing(message, error50, options2) {
|
|
632007
|
+
this.result = TaskResult.Failure;
|
|
632008
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
632009
|
+
return;
|
|
632010
|
+
}
|
|
632011
|
+
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
632012
|
+
if (fullMessage != null) {
|
|
632013
|
+
this.logger.error(fullMessage);
|
|
632014
|
+
}
|
|
632015
|
+
reportError(this.context, error50, { ...options2, message });
|
|
632016
|
+
}
|
|
632017
|
+
captureException(error50, code5) {
|
|
632018
|
+
const errorCode = resolveErrorCode(error50, code5);
|
|
632019
|
+
this.context.telemetry.captureException(error50, { errorCode });
|
|
632020
|
+
}
|
|
632021
|
+
getFullErrorMessage(message, error50) {
|
|
632022
|
+
const errorDetails = this.formatError(error50);
|
|
632023
|
+
if (message != null && errorDetails != null) {
|
|
632024
|
+
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
632025
|
+
}
|
|
632026
|
+
return message ?? errorDetails;
|
|
632027
|
+
}
|
|
632028
|
+
getResult() {
|
|
632029
|
+
return this.result;
|
|
632030
|
+
}
|
|
632031
|
+
addInteractiveTask(_params) {
|
|
632032
|
+
const subtask = {
|
|
632033
|
+
logger: this.logger,
|
|
632034
|
+
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
632035
|
+
failAndThrow: this.failAndThrow.bind(this),
|
|
632036
|
+
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
632037
|
+
captureException: this.captureException.bind(this),
|
|
632038
|
+
getResult: () => this.result,
|
|
632039
|
+
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
632040
|
+
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
632041
|
+
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
632042
|
+
setSubtitle: (_subtitle) => {
|
|
632043
|
+
},
|
|
632044
|
+
start: () => {
|
|
632045
|
+
return subtask;
|
|
632046
|
+
},
|
|
632047
|
+
isStarted: () => true,
|
|
632048
|
+
finish: () => {
|
|
632049
|
+
},
|
|
632050
|
+
isFinished: () => true
|
|
632051
|
+
};
|
|
632052
|
+
return subtask;
|
|
632053
|
+
}
|
|
632054
|
+
async runInteractiveTask(params2, run) {
|
|
632055
|
+
const subtask = this.addInteractiveTask(params2).start();
|
|
632056
|
+
try {
|
|
632057
|
+
await run(subtask);
|
|
632058
|
+
return true;
|
|
632059
|
+
} catch {
|
|
632060
|
+
return false;
|
|
632061
|
+
}
|
|
632062
|
+
}
|
|
632063
|
+
instrumentPostHogEvent(_event) {
|
|
632064
|
+
}
|
|
632065
|
+
formatError(error50) {
|
|
632066
|
+
if (error50 == null) {
|
|
632067
|
+
return void 0;
|
|
632068
|
+
}
|
|
632069
|
+
if (error50 instanceof Error) {
|
|
632070
|
+
return error50.message;
|
|
632071
|
+
}
|
|
632072
|
+
if (typeof error50 === "string") {
|
|
632073
|
+
return error50;
|
|
632074
|
+
}
|
|
632075
|
+
if (typeof error50 === "object") {
|
|
632076
|
+
const message = this.extractErrorMessage(error50);
|
|
632077
|
+
if (message != null) {
|
|
632078
|
+
return message;
|
|
632079
|
+
}
|
|
632080
|
+
}
|
|
632081
|
+
try {
|
|
632082
|
+
return JSON.stringify(error50);
|
|
632083
|
+
} catch {
|
|
632084
|
+
return String(error50);
|
|
632085
|
+
}
|
|
632086
|
+
}
|
|
632087
|
+
/**
|
|
632088
|
+
* Attempts to extract a human-readable message from a structured error object.
|
|
632089
|
+
*
|
|
632090
|
+
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
632091
|
+
* { content: { body: { message: "..." } } }
|
|
632092
|
+
* { body: { message: "..." } }
|
|
632093
|
+
* { message: "..." }
|
|
632094
|
+
*/
|
|
632095
|
+
extractErrorMessage(error50) {
|
|
632096
|
+
const record21 = error50;
|
|
632097
|
+
if (typeof record21.message === "string") {
|
|
632098
|
+
return record21.message;
|
|
632099
|
+
}
|
|
632100
|
+
if (record21.body != null && typeof record21.body === "object") {
|
|
632101
|
+
const body = record21.body;
|
|
632102
|
+
if (typeof body.message === "string") {
|
|
632103
|
+
return body.message;
|
|
632104
|
+
}
|
|
632105
|
+
}
|
|
632106
|
+
if (record21.content != null && typeof record21.content === "object") {
|
|
632107
|
+
return this.extractErrorMessage(record21.content);
|
|
632108
|
+
}
|
|
632109
|
+
return void 0;
|
|
632110
|
+
}
|
|
632111
|
+
};
|
|
632112
|
+
|
|
632113
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632114
|
+
init_lib6();
|
|
632115
|
+
|
|
632116
|
+
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
632117
|
+
function isOpenRpcSpec(spec) {
|
|
632118
|
+
return "openrpc" in spec;
|
|
632119
|
+
}
|
|
632120
|
+
|
|
632121
|
+
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
632122
|
+
function isProtobufSpec(spec) {
|
|
632123
|
+
return "proto" in spec;
|
|
632124
|
+
}
|
|
632125
|
+
|
|
632126
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632127
|
+
var LegacyApiSpecAdapter = class {
|
|
632128
|
+
context;
|
|
632129
|
+
constructor(config5) {
|
|
632130
|
+
this.context = config5.context;
|
|
632131
|
+
}
|
|
632132
|
+
adapt(spec) {
|
|
632133
|
+
if (isOpenApiSpec(spec)) {
|
|
632134
|
+
return this.adaptOpenApiSpec(spec);
|
|
632135
|
+
}
|
|
632136
|
+
if (isAsyncApiSpec(spec)) {
|
|
632137
|
+
return this.adaptAsyncApiSpec(spec);
|
|
632138
|
+
}
|
|
632139
|
+
if (isProtobufSpec(spec)) {
|
|
632140
|
+
return this.adaptProtobufSpec(spec);
|
|
632141
|
+
}
|
|
632142
|
+
if (isOpenRpcSpec(spec)) {
|
|
632143
|
+
return this.adaptOpenRpcSpec(spec);
|
|
632144
|
+
}
|
|
632145
|
+
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
632146
|
+
}
|
|
632147
|
+
convertAll(specs) {
|
|
632148
|
+
return specs.map((spec) => this.adapt(spec));
|
|
632149
|
+
}
|
|
632150
|
+
adaptOpenApiSpec(spec) {
|
|
632151
|
+
return {
|
|
632152
|
+
type: "openapi",
|
|
632153
|
+
absoluteFilepath: spec.openapi,
|
|
632154
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632155
|
+
absoluteFilepathToOverlays: spec.overlays,
|
|
632156
|
+
namespace: spec.namespace,
|
|
632157
|
+
source: {
|
|
632158
|
+
type: "openapi",
|
|
632159
|
+
file: spec.openapi
|
|
632160
|
+
},
|
|
632161
|
+
settings: this.adaptOpenApiSettings(spec.settings)
|
|
632162
|
+
};
|
|
632163
|
+
}
|
|
632164
|
+
adaptAsyncApiSpec(spec) {
|
|
632165
|
+
return {
|
|
632166
|
+
type: "openapi",
|
|
632167
|
+
absoluteFilepath: spec.asyncapi,
|
|
632168
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632169
|
+
absoluteFilepathToOverlays: void 0,
|
|
632170
|
+
namespace: spec.namespace,
|
|
632171
|
+
source: {
|
|
632172
|
+
type: "asyncapi",
|
|
632173
|
+
file: spec.asyncapi
|
|
632174
|
+
},
|
|
632175
|
+
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
632176
|
+
};
|
|
632177
|
+
}
|
|
632178
|
+
adaptProtobufSpec(spec) {
|
|
632179
|
+
const proto3 = spec.proto;
|
|
632180
|
+
return {
|
|
632181
|
+
type: "protobuf",
|
|
632182
|
+
absoluteFilepathToProtobufRoot: proto3.root,
|
|
632183
|
+
absoluteFilepathToProtobufTarget: proto3.target,
|
|
632184
|
+
absoluteFilepathToOverrides: proto3.overrides,
|
|
632185
|
+
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
632186
|
+
generateLocally: proto3.localGeneration ?? false,
|
|
632187
|
+
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
632188
|
+
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
632189
|
+
settings: void 0
|
|
632190
|
+
};
|
|
632191
|
+
}
|
|
632192
|
+
adaptOpenRpcSpec(spec) {
|
|
632193
|
+
return {
|
|
632194
|
+
type: "openrpc",
|
|
632195
|
+
absoluteFilepath: spec.openrpc,
|
|
632196
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632197
|
+
namespace: void 0
|
|
632198
|
+
};
|
|
632199
|
+
}
|
|
632200
|
+
adaptOpenApiSettings(settings) {
|
|
632201
|
+
if (settings == null) {
|
|
632202
|
+
return void 0;
|
|
632203
|
+
}
|
|
632204
|
+
const result = {
|
|
632205
|
+
// Base API settings
|
|
632206
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632207
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632208
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632209
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632210
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632211
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632212
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632213
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632214
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632215
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632216
|
+
// OpenAPI-specific settings
|
|
632217
|
+
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
632218
|
+
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
632219
|
+
inlinePathParameters: settings.inlinePathParameters,
|
|
632220
|
+
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
632221
|
+
objectQueryParameters: settings.objectQueryParameters,
|
|
632222
|
+
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
632223
|
+
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
632224
|
+
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
632225
|
+
filter: settings.filter,
|
|
632226
|
+
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
632227
|
+
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
632228
|
+
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
632229
|
+
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
632230
|
+
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
632231
|
+
resolveAliases: settings.resolveAliases,
|
|
632232
|
+
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
632233
|
+
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
632234
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632235
|
+
};
|
|
632236
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632237
|
+
return hasSettings ? result : void 0;
|
|
632238
|
+
}
|
|
632239
|
+
adaptAsyncApiSettings(settings) {
|
|
632240
|
+
if (settings == null) {
|
|
632241
|
+
return void 0;
|
|
632242
|
+
}
|
|
632243
|
+
const result = {
|
|
632244
|
+
// Base API settings (shared)
|
|
632245
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632246
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632247
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632248
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632249
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632250
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632251
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632252
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632253
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632254
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632255
|
+
// AsyncAPI-specific settings
|
|
632256
|
+
asyncApiNaming: settings.messageNaming,
|
|
632257
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632258
|
+
};
|
|
632259
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632260
|
+
return hasSettings ? result : void 0;
|
|
632261
|
+
}
|
|
632262
|
+
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
632263
|
+
if (value == null) {
|
|
632264
|
+
return void 0;
|
|
632265
|
+
}
|
|
632266
|
+
switch (value) {
|
|
632267
|
+
case "always":
|
|
632268
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
632269
|
+
case "never":
|
|
632270
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
632271
|
+
default:
|
|
632272
|
+
return void 0;
|
|
632273
|
+
}
|
|
632274
|
+
}
|
|
632275
|
+
adaptPathParameterOrder(value) {
|
|
632276
|
+
if (value == null) {
|
|
632277
|
+
return void 0;
|
|
632278
|
+
}
|
|
632279
|
+
switch (value) {
|
|
632280
|
+
case "urlOrder":
|
|
632281
|
+
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
632282
|
+
case "specOrder":
|
|
632283
|
+
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
632284
|
+
default:
|
|
632285
|
+
return void 0;
|
|
632286
|
+
}
|
|
632287
|
+
}
|
|
632288
|
+
adaptDefaultIntegerFormat(value) {
|
|
632289
|
+
if (value == null) {
|
|
632290
|
+
return void 0;
|
|
632291
|
+
}
|
|
632292
|
+
switch (value) {
|
|
632293
|
+
case "int32":
|
|
632294
|
+
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
632295
|
+
case "int64":
|
|
632296
|
+
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
632297
|
+
case "uint32":
|
|
632298
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
632299
|
+
case "uint64":
|
|
632300
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
632301
|
+
default:
|
|
632302
|
+
return void 0;
|
|
632303
|
+
}
|
|
632304
|
+
}
|
|
632305
|
+
adaptExampleGeneration(value) {
|
|
632306
|
+
if (value == null) {
|
|
632307
|
+
return void 0;
|
|
632308
|
+
}
|
|
632309
|
+
const result = {};
|
|
632310
|
+
if (value.request != null) {
|
|
632311
|
+
result.request = { "max-depth": value.request.maxDepth };
|
|
632312
|
+
}
|
|
632313
|
+
if (value.response != null) {
|
|
632314
|
+
result.response = { "max-depth": value.response.maxDepth };
|
|
632315
|
+
}
|
|
632316
|
+
return result;
|
|
632317
|
+
}
|
|
632318
|
+
};
|
|
632319
|
+
|
|
632320
|
+
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
632321
|
+
function isConjureSpec(spec) {
|
|
632322
|
+
return "conjure" in spec;
|
|
632323
|
+
}
|
|
632324
|
+
|
|
632325
|
+
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
632326
|
+
var ApiDefinitionValidator = class {
|
|
632327
|
+
context;
|
|
632328
|
+
taskContext;
|
|
632329
|
+
cliVersion;
|
|
632330
|
+
constructor(config5) {
|
|
632331
|
+
this.context = config5.context;
|
|
632332
|
+
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
632333
|
+
this.cliVersion = config5.cliVersion;
|
|
632334
|
+
}
|
|
632335
|
+
/**
|
|
632336
|
+
* Validate an ApiDefinition.
|
|
632337
|
+
*
|
|
632338
|
+
* Runs both Fern definition validation and OSS workspace validation
|
|
632339
|
+
* to ensure the API definition is valid before generation.
|
|
632340
|
+
*/
|
|
632341
|
+
async validate(definition3) {
|
|
632342
|
+
const startTime = performance.now();
|
|
632343
|
+
const violations = [];
|
|
632344
|
+
const fernSpec = definition3.specs.find(isFernSpec);
|
|
632345
|
+
if (fernSpec != null) {
|
|
632346
|
+
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
632347
|
+
violations.push(...fernViolations);
|
|
632348
|
+
return {
|
|
632349
|
+
violations,
|
|
632350
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632351
|
+
workspaceRoot: fernSpec.fern,
|
|
632352
|
+
elapsedMillis: performance.now() - startTime
|
|
632353
|
+
};
|
|
632354
|
+
}
|
|
632355
|
+
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
632356
|
+
if (conjureSpec != null) {
|
|
632357
|
+
return {
|
|
632358
|
+
violations: [],
|
|
632359
|
+
hasErrors: false,
|
|
632360
|
+
workspaceRoot: this.context.cwd,
|
|
632361
|
+
elapsedMillis: performance.now() - startTime
|
|
632362
|
+
};
|
|
632363
|
+
}
|
|
632364
|
+
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
632365
|
+
violations.push(...ossViolations);
|
|
632366
|
+
return {
|
|
632367
|
+
violations,
|
|
632368
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632369
|
+
workspaceRoot: this.context.cwd,
|
|
632370
|
+
elapsedMillis: performance.now() - startTime
|
|
632371
|
+
};
|
|
632372
|
+
}
|
|
632373
|
+
async validateFernSpec(spec) {
|
|
632374
|
+
const violations = [];
|
|
632375
|
+
const lazyWorkspace = new LazyFernWorkspace({
|
|
632376
|
+
absoluteFilePath: dirname6(spec.fern),
|
|
632377
|
+
context: this.taskContext,
|
|
632378
|
+
cliVersion: this.cliVersion,
|
|
632379
|
+
generatorsConfiguration: void 0,
|
|
632380
|
+
workspaceName: void 0,
|
|
632381
|
+
changelog: void 0
|
|
632382
|
+
});
|
|
632383
|
+
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632384
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632385
|
+
violations.push(...fernViolations);
|
|
632386
|
+
return violations;
|
|
632387
|
+
}
|
|
632388
|
+
async validateOssSpecs(specs) {
|
|
632389
|
+
const violations = [];
|
|
632390
|
+
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
632391
|
+
if (ossSpecs.length === 0) {
|
|
632392
|
+
return violations;
|
|
632393
|
+
}
|
|
632394
|
+
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
632395
|
+
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
632396
|
+
const filteredSpecs = v1Specs.filter((spec) => {
|
|
632397
|
+
if (spec.type === "openrpc") {
|
|
632398
|
+
return false;
|
|
632399
|
+
}
|
|
632400
|
+
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
632401
|
+
return false;
|
|
632402
|
+
}
|
|
632403
|
+
return true;
|
|
632404
|
+
});
|
|
632405
|
+
const allSpecs = v1Specs.filter((spec) => {
|
|
632406
|
+
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
632407
|
+
return false;
|
|
632408
|
+
}
|
|
632409
|
+
return true;
|
|
632410
|
+
});
|
|
632411
|
+
const ossWorkspace = new OSSWorkspace({
|
|
632412
|
+
specs: filteredSpecs,
|
|
632413
|
+
allSpecs,
|
|
632414
|
+
absoluteFilePath: this.context.cwd,
|
|
632415
|
+
cliVersion: this.cliVersion,
|
|
632416
|
+
changelog: void 0,
|
|
632417
|
+
generatorsConfiguration: void 0,
|
|
632418
|
+
workspaceName: void 0
|
|
632419
|
+
});
|
|
632420
|
+
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632421
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632422
|
+
violations.push(...fernViolations);
|
|
632423
|
+
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
632424
|
+
violations.push(...ossViolations);
|
|
632425
|
+
return violations;
|
|
632426
|
+
}
|
|
632427
|
+
};
|
|
632428
|
+
|
|
632429
|
+
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
632430
|
+
var ApiChecker = class {
|
|
632431
|
+
context;
|
|
632432
|
+
cliVersion;
|
|
632433
|
+
task;
|
|
632434
|
+
constructor(config5) {
|
|
632435
|
+
this.context = config5.context;
|
|
632436
|
+
this.cliVersion = config5.cliVersion;
|
|
632437
|
+
this.task = config5.task;
|
|
632438
|
+
}
|
|
632439
|
+
/**
|
|
632440
|
+
* Check APIs in the workspace and display results.
|
|
632441
|
+
*
|
|
632442
|
+
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
632443
|
+
* only show errors but still report warning count in summary.
|
|
632444
|
+
*/
|
|
632445
|
+
async check({ workspace, apiNames, strict = false }) {
|
|
632446
|
+
const startTime = performance.now();
|
|
632447
|
+
const validApis = /* @__PURE__ */ new Set();
|
|
632448
|
+
const invalidApis = /* @__PURE__ */ new Set();
|
|
632449
|
+
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
632450
|
+
if (apisToCheck.length === 0) {
|
|
632451
|
+
return {
|
|
632452
|
+
validApis,
|
|
632453
|
+
invalidApis,
|
|
632454
|
+
violations: [],
|
|
632455
|
+
errorCount: 0,
|
|
632456
|
+
warningCount: 0,
|
|
632457
|
+
elapsedMillis: performance.now() - startTime
|
|
632458
|
+
};
|
|
632459
|
+
}
|
|
632460
|
+
const validator = new ApiDefinitionValidator({
|
|
632461
|
+
context: this.context,
|
|
632462
|
+
cliVersion: this.cliVersion,
|
|
632463
|
+
task: this.task
|
|
632464
|
+
});
|
|
632465
|
+
const allViolations = [];
|
|
632466
|
+
for (const apiName of apisToCheck) {
|
|
632467
|
+
const apiDefinition = workspace.apis[apiName];
|
|
632468
|
+
if (apiDefinition == null) {
|
|
632469
|
+
invalidApis.add(apiName);
|
|
632470
|
+
continue;
|
|
632471
|
+
}
|
|
632472
|
+
const result = await validator.validate(apiDefinition);
|
|
632473
|
+
if (result.hasErrors) {
|
|
632474
|
+
invalidApis.add(apiName);
|
|
632475
|
+
} else {
|
|
632476
|
+
validApis.add(apiName);
|
|
632477
|
+
}
|
|
632478
|
+
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
632479
|
+
const resolvedViolations = this.resolveViolationPaths({
|
|
632480
|
+
workspaceRoot: result.workspaceRoot,
|
|
632481
|
+
apiName,
|
|
632482
|
+
apiSpecType,
|
|
632483
|
+
apiDefinition,
|
|
632484
|
+
violations: result.violations
|
|
632485
|
+
});
|
|
632486
|
+
allViolations.push(...resolvedViolations);
|
|
632487
|
+
}
|
|
632488
|
+
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
632489
|
+
return {
|
|
632490
|
+
...this.countViolations(dedupedViolations),
|
|
632491
|
+
validApis,
|
|
632492
|
+
invalidApis,
|
|
632493
|
+
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632494
|
+
elapsedMillis: performance.now() - startTime
|
|
632495
|
+
};
|
|
632496
|
+
}
|
|
632497
|
+
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
632498
|
+
return violations.map((violation) => {
|
|
632499
|
+
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
632500
|
+
return {
|
|
632501
|
+
...violation,
|
|
632502
|
+
message,
|
|
632503
|
+
displayRelativeFilepath: this.resolveDisplayPath({
|
|
632504
|
+
workspaceRoot,
|
|
632505
|
+
apiDefinition,
|
|
632506
|
+
apiSpecType,
|
|
632507
|
+
violation
|
|
632508
|
+
}),
|
|
632509
|
+
apiSpecType,
|
|
632510
|
+
apiName,
|
|
632511
|
+
// We don't actually surface valuable line/column information yet, but
|
|
632512
|
+
// this at least points to the correct file.
|
|
632513
|
+
line: 1,
|
|
632514
|
+
column: 1
|
|
632515
|
+
};
|
|
632516
|
+
});
|
|
632517
|
+
}
|
|
632518
|
+
/**
|
|
632519
|
+
* Format a violation message for non-Fern (OSS) specs.
|
|
632520
|
+
*
|
|
632521
|
+
* Prepends a human-readable node path so users can locate the endpoint,
|
|
632522
|
+
* then strips synthetic file paths from the body of the message.
|
|
632523
|
+
*/
|
|
632524
|
+
formatOssMessage(violation) {
|
|
632525
|
+
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
632526
|
+
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
632527
|
+
if (nodePathPrefix.length === 0) {
|
|
632528
|
+
return strippedMessage;
|
|
632529
|
+
}
|
|
632530
|
+
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
632531
|
+
}
|
|
632532
|
+
/**
|
|
632533
|
+
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
632534
|
+
*
|
|
632535
|
+
* Skips the leading "service" segment since it's implicit.
|
|
632536
|
+
*/
|
|
632537
|
+
formatNodePath(nodePath) {
|
|
632538
|
+
const parts = [];
|
|
632539
|
+
for (const item of nodePath) {
|
|
632540
|
+
if (typeof item === "string") {
|
|
632541
|
+
parts.push(item);
|
|
632542
|
+
} else {
|
|
632543
|
+
parts.push(item.key);
|
|
632544
|
+
}
|
|
632545
|
+
}
|
|
632546
|
+
if (parts[0] === "service") {
|
|
632547
|
+
parts.shift();
|
|
632548
|
+
}
|
|
632549
|
+
return parts.join(" -> ");
|
|
632550
|
+
}
|
|
632551
|
+
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
632552
|
+
if (apiSpecType === "fern") {
|
|
632553
|
+
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
632554
|
+
return relativize(this.context.cwd, absolutePath);
|
|
632555
|
+
}
|
|
632556
|
+
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
632557
|
+
}
|
|
632558
|
+
resolveOssDisplayPath(apiDefinition, violation) {
|
|
632559
|
+
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
632560
|
+
if (ossSpecs.length === 0) {
|
|
632561
|
+
return violation.relativeFilepath;
|
|
632562
|
+
}
|
|
632563
|
+
if (ossSpecs.length > 1) {
|
|
632564
|
+
for (const spec of ossSpecs) {
|
|
632565
|
+
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
632566
|
+
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
632567
|
+
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
632568
|
+
return relativize(this.context.cwd, filePath2);
|
|
632569
|
+
}
|
|
632570
|
+
}
|
|
632571
|
+
}
|
|
632572
|
+
const firstSpec = ossSpecs[0];
|
|
632573
|
+
if (firstSpec == null) {
|
|
632574
|
+
return violation.relativeFilepath;
|
|
632575
|
+
}
|
|
632576
|
+
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
632577
|
+
return relativize(this.context.cwd, filePath);
|
|
632578
|
+
}
|
|
632579
|
+
deduplicateViolations(violations) {
|
|
632580
|
+
const seen = /* @__PURE__ */ new Set();
|
|
632581
|
+
return violations.filter((v23) => {
|
|
632582
|
+
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
632583
|
+
if (seen.has(key2)) {
|
|
632584
|
+
return false;
|
|
632585
|
+
}
|
|
632586
|
+
seen.add(key2);
|
|
632587
|
+
return true;
|
|
632588
|
+
});
|
|
632589
|
+
}
|
|
632590
|
+
/**
|
|
632591
|
+
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
632592
|
+
*
|
|
632593
|
+
* The validator produces messages like:
|
|
632594
|
+
* "- pet.yml -> getPetById /pet/{petId}"
|
|
632595
|
+
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
632596
|
+
* so we strip them to produce:
|
|
632597
|
+
* "- getPetById /pet/{petId}"
|
|
632598
|
+
*/
|
|
632599
|
+
stripSyntheticFilePaths(message) {
|
|
632600
|
+
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
632601
|
+
}
|
|
632602
|
+
countViolations(violations) {
|
|
632603
|
+
let errorCount = 0;
|
|
632604
|
+
let warningCount = 0;
|
|
632605
|
+
for (const violation of violations) {
|
|
632606
|
+
switch (violation.severity) {
|
|
632607
|
+
case "fatal":
|
|
632608
|
+
case "error":
|
|
632609
|
+
errorCount++;
|
|
632610
|
+
break;
|
|
632611
|
+
case "warning":
|
|
632612
|
+
warningCount++;
|
|
632613
|
+
break;
|
|
632614
|
+
default:
|
|
632615
|
+
assertNever(violation.severity);
|
|
632616
|
+
}
|
|
632617
|
+
}
|
|
632618
|
+
return { errorCount, warningCount };
|
|
632619
|
+
}
|
|
632620
|
+
};
|
|
632621
|
+
|
|
632580
632622
|
// ../cli-v2/lib/commands/_internal/command.js
|
|
632581
632623
|
function command2(cli, name2, description, handler3, builder) {
|
|
632582
632624
|
cli.command(name2, description, (yargs) => {
|
|
@@ -632620,7 +632662,8 @@ var CheckCommand = class {
|
|
|
632620
632662
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
632621
632663
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
632622
632664
|
throw new CliError({
|
|
632623
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
632665
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
632666
|
+
code: CliError.Code.ConfigError
|
|
632624
632667
|
});
|
|
632625
632668
|
}
|
|
632626
632669
|
const checker = new ApiChecker({ context: context3, cliVersion: workspace.cliVersion });
|
|
@@ -632634,7 +632677,7 @@ var CheckCommand = class {
|
|
|
632634
632677
|
const response = this.buildJsonResponse({ apiCheckResult: result, hasErrors });
|
|
632635
632678
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
632636
632679
|
if (hasErrors) {
|
|
632637
|
-
throw CliError.
|
|
632680
|
+
throw CliError.validationError();
|
|
632638
632681
|
}
|
|
632639
632682
|
return;
|
|
632640
632683
|
}
|
|
@@ -632646,7 +632689,7 @@ var CheckCommand = class {
|
|
|
632646
632689
|
}
|
|
632647
632690
|
}
|
|
632648
632691
|
if (hasErrors) {
|
|
632649
|
-
throw CliError.
|
|
632692
|
+
throw CliError.validationError();
|
|
632650
632693
|
}
|
|
632651
632694
|
if (result.warningCount > 0) {
|
|
632652
632695
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -759321,7 +759364,8 @@ var CompileCommand = class {
|
|
|
759321
759364
|
if (definition3 == null) {
|
|
759322
759365
|
const available2 = apiNames.join(", ");
|
|
759323
759366
|
throw new CliError({
|
|
759324
|
-
message: `API '${args.api}' not found. Available APIs: ${available2}
|
|
759367
|
+
message: `API '${args.api}' not found. Available APIs: ${available2}`,
|
|
759368
|
+
code: CliError.Code.ConfigError
|
|
759325
759369
|
});
|
|
759326
759370
|
}
|
|
759327
759371
|
return { apiName: args.api, definition: definition3 };
|
|
@@ -759330,20 +759374,23 @@ var CompileCommand = class {
|
|
|
759330
759374
|
const apiName = apiNames[0];
|
|
759331
759375
|
if (apiName == null) {
|
|
759332
759376
|
throw new CliError({
|
|
759333
|
-
message: "Internal error; no APIs found in workspace"
|
|
759377
|
+
message: "Internal error; no APIs found in workspace",
|
|
759378
|
+
code: CliError.Code.InternalError
|
|
759334
759379
|
});
|
|
759335
759380
|
}
|
|
759336
759381
|
const definition3 = workspace.apis[apiName];
|
|
759337
759382
|
if (definition3 == null) {
|
|
759338
759383
|
throw new CliError({
|
|
759339
|
-
message: `Internal error; API '${apiName}' not found in workspace
|
|
759384
|
+
message: `Internal error; API '${apiName}' not found in workspace`,
|
|
759385
|
+
code: CliError.Code.InternalError
|
|
759340
759386
|
});
|
|
759341
759387
|
}
|
|
759342
759388
|
return { apiName, definition: definition3 };
|
|
759343
759389
|
}
|
|
759344
759390
|
const available = apiNames.join(", ");
|
|
759345
759391
|
throw new CliError({
|
|
759346
|
-
message: `Multiple APIs found: ${available}. Use --api to select one
|
|
759392
|
+
message: `Multiple APIs found: ${available}. Use --api to select one.`,
|
|
759393
|
+
code: CliError.Code.ConfigError
|
|
759347
759394
|
});
|
|
759348
759395
|
}
|
|
759349
759396
|
async checkOrThrow({ context: context3, workspace, apiName }) {
|
|
@@ -759353,7 +759400,7 @@ var CompileCommand = class {
|
|
|
759353
759400
|
for (const violation of result.violations) {
|
|
759354
759401
|
context3.stderr.error(`${violation.displayRelativeFilepath}:${violation.line}:${violation.column}: ${violation.message}`);
|
|
759355
759402
|
}
|
|
759356
|
-
throw CliError.
|
|
759403
|
+
throw CliError.validationError(`API '${apiName}' has ${result.violations.length} validation errors`);
|
|
759357
759404
|
}
|
|
759358
759405
|
}
|
|
759359
759406
|
async writeOutput(context3, args, object21) {
|
|
@@ -759445,7 +759492,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759445
759492
|
const doc = document4.toJS();
|
|
759446
759493
|
if (doc == null || typeof doc !== "object") {
|
|
759447
759494
|
throw new CliError({
|
|
759448
|
-
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file
|
|
759495
|
+
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`,
|
|
759496
|
+
code: CliError.Code.ParseError
|
|
759449
759497
|
});
|
|
759450
759498
|
}
|
|
759451
759499
|
return new _FernYmlEditor(document4, config5.fernYmlPath);
|
|
@@ -759647,7 +759695,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759647
759695
|
const resolvedPath = join8(dirname6(this.rootFilePath), RelativeFilePath2.of(refPath));
|
|
759648
759696
|
if (!await doesPathExist(resolvedPath)) {
|
|
759649
759697
|
throw new CliError({
|
|
759650
|
-
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist
|
|
759698
|
+
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`,
|
|
759699
|
+
code: CliError.Code.ConfigError
|
|
759651
759700
|
});
|
|
759652
759701
|
}
|
|
759653
759702
|
const refContent = await (0, import_promises50.readFile)(resolvedPath, "utf-8");
|
|
@@ -759674,7 +759723,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759674
759723
|
const existing = section.document.getIn([...section.basePath, name2]);
|
|
759675
759724
|
if (existing == null) {
|
|
759676
759725
|
throw new CliError({
|
|
759677
|
-
message: `Target '${name2}' not found in SDK configuration
|
|
759726
|
+
message: `Target '${name2}' not found in SDK configuration.`,
|
|
759727
|
+
code: CliError.Code.ConfigError
|
|
759678
759728
|
});
|
|
759679
759729
|
}
|
|
759680
759730
|
}
|
|
@@ -760002,9 +760052,9 @@ async function loadSpec(filepath) {
|
|
|
760002
760052
|
contents = await (0, import_promises51.readFile)(filepath, "utf8");
|
|
760003
760053
|
} catch (error50) {
|
|
760004
760054
|
if (isEnoentError(error50)) {
|
|
760005
|
-
throw new CliError({ message: `File does not exist: ${filepath}
|
|
760055
|
+
throw new CliError({ message: `File does not exist: ${filepath}`, code: CliError.Code.ConfigError });
|
|
760006
760056
|
}
|
|
760007
|
-
throw new CliError({ message: `Failed to read file: ${filepath}
|
|
760057
|
+
throw new CliError({ message: `Failed to read file: ${filepath}`, code: CliError.Code.ParseError });
|
|
760008
760058
|
}
|
|
760009
760059
|
return parseSpec(contents, filepath);
|
|
760010
760060
|
}
|
|
@@ -760015,7 +760065,10 @@ function parseSpec(contents, filepath) {
|
|
|
760015
760065
|
try {
|
|
760016
760066
|
return jsYaml.load(contents);
|
|
760017
760067
|
} catch {
|
|
760018
|
-
throw new CliError({
|
|
760068
|
+
throw new CliError({
|
|
760069
|
+
message: `Failed to parse file as JSON or YAML: ${filepath}`,
|
|
760070
|
+
code: CliError.Code.ParseError
|
|
760071
|
+
});
|
|
760019
760072
|
}
|
|
760020
760073
|
}
|
|
760021
760074
|
}
|
|
@@ -760034,7 +760087,7 @@ var MergeCommand = class {
|
|
|
760034
760087
|
async handle(context3, args) {
|
|
760035
760088
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760036
760089
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760037
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760090
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
760038
760091
|
}
|
|
760039
760092
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760040
760093
|
if (entries22.length === 0) {
|
|
@@ -760046,7 +760099,8 @@ var MergeCommand = class {
|
|
|
760046
760099
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760047
760100
|
if (fernYmlPath == null) {
|
|
760048
760101
|
throw new CliError({
|
|
760049
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760102
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760103
|
+
code: CliError.Code.ConfigError
|
|
760050
760104
|
});
|
|
760051
760105
|
}
|
|
760052
760106
|
editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760181,7 +760235,7 @@ var SplitCommand = class {
|
|
|
760181
760235
|
async handle(context3, args) {
|
|
760182
760236
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760183
760237
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760184
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760238
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
760185
760239
|
}
|
|
760186
760240
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760187
760241
|
if (entries22.length === 0) {
|
|
@@ -760192,7 +760246,8 @@ var SplitCommand = class {
|
|
|
760192
760246
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760193
760247
|
if (fernYmlPath == null) {
|
|
760194
760248
|
throw new CliError({
|
|
760195
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760249
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760250
|
+
code: CliError.Code.ConfigError
|
|
760196
760251
|
});
|
|
760197
760252
|
}
|
|
760198
760253
|
const editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760313,7 +760368,8 @@ var SplitCommand = class {
|
|
|
760313
760368
|
const detail = extractErrorMessage(error50);
|
|
760314
760369
|
throw new CliError({
|
|
760315
760370
|
message: `Failed to get file from git HEAD: ${absolutePath}. Is the file tracked by git and has at least one commit?
|
|
760316
|
-
Cause: ${detail}
|
|
760371
|
+
Cause: ${detail}`,
|
|
760372
|
+
code: CliError.Code.ParseError
|
|
760317
760373
|
});
|
|
760318
760374
|
}
|
|
760319
760375
|
}
|
|
@@ -760328,7 +760384,10 @@ var SplitCommand = class {
|
|
|
760328
760384
|
function resolvePathOrThrow(context3, outputPath) {
|
|
760329
760385
|
const resolved = context3.resolveOutputFilePath(outputPath);
|
|
760330
760386
|
if (resolved == null) {
|
|
760331
|
-
throw new CliError({
|
|
760387
|
+
throw new CliError({
|
|
760388
|
+
message: `Could not resolve output path: ${outputPath}`,
|
|
760389
|
+
code: CliError.Code.ConfigError
|
|
760390
|
+
});
|
|
760332
760391
|
}
|
|
760333
760392
|
return resolved;
|
|
760334
760393
|
}
|
|
@@ -760372,7 +760431,7 @@ var LoginCommand = class {
|
|
|
760372
760431
|
context3.stdout.info("Opening browser to log in to Fern...");
|
|
760373
760432
|
context3.stdout.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
760374
760433
|
}
|
|
760375
|
-
const taskContext = new TaskContextAdapter({ context: context3, logLevel:
|
|
760434
|
+
const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel.Info });
|
|
760376
760435
|
const tokenResponse = await getTokenFromAuth0(taskContext, {
|
|
760377
760436
|
useDeviceCodeFlow,
|
|
760378
760437
|
forceReauth: true
|
|
@@ -760384,12 +760443,12 @@ var LoginCommand = class {
|
|
|
760384
760443
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
760385
760444
|
if (payload == null) {
|
|
760386
760445
|
context3.stdout.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
760387
|
-
throw CliError.
|
|
760446
|
+
throw CliError.internalError();
|
|
760388
760447
|
}
|
|
760389
760448
|
const email3 = payload.email;
|
|
760390
760449
|
if (email3 == null) {
|
|
760391
760450
|
context3.stdout.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
760392
|
-
throw CliError.
|
|
760451
|
+
throw CliError.internalError();
|
|
760393
760452
|
}
|
|
760394
760453
|
const { isNew, totalAccounts } = await context3.tokenService.login(email3, accessToken);
|
|
760395
760454
|
if (isNew) {
|
|
@@ -760455,7 +760514,7 @@ var LogoutCommand = class {
|
|
|
760455
760514
|
context3.stdout.info("");
|
|
760456
760515
|
if (!context3.isTTY) {
|
|
760457
760516
|
context3.stdout.error(`${Icons.error} Use --force to skip confirmation in non-interactive mode`);
|
|
760458
|
-
throw CliError.
|
|
760517
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
760459
760518
|
}
|
|
760460
760519
|
const { confirmed } = await lib_default4.prompt([
|
|
760461
760520
|
{
|
|
@@ -760476,7 +760535,9 @@ var LogoutCommand = class {
|
|
|
760476
760535
|
const { removed, newActive } = await context3.tokenService.logout(user);
|
|
760477
760536
|
if (!removed) {
|
|
760478
760537
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760479
|
-
throw CliError
|
|
760538
|
+
throw new CliError({
|
|
760539
|
+
code: CliError.Code.EnvironmentError
|
|
760540
|
+
});
|
|
760480
760541
|
}
|
|
760481
760542
|
context3.stdout.info(`${Icons.success} Logged out of ${source_default.bold(user)}`);
|
|
760482
760543
|
if (newActive != null) {
|
|
@@ -760486,7 +760547,9 @@ var LogoutCommand = class {
|
|
|
760486
760547
|
async handleLogoutInteractive(context3, accounts) {
|
|
760487
760548
|
if (!context3.isTTY) {
|
|
760488
760549
|
context3.stdout.error(`${Icons.error} Multiple accounts found. Use --user or --all in non-interactive mode.`);
|
|
760489
|
-
throw CliError
|
|
760550
|
+
throw new CliError({
|
|
760551
|
+
code: CliError.Code.EnvironmentError
|
|
760552
|
+
});
|
|
760490
760553
|
}
|
|
760491
760554
|
const choices = accounts.map((account) => ({
|
|
760492
760555
|
name: account.isActive ? `${account.user} ${source_default.dim("(active)")}` : account.user,
|
|
@@ -760642,13 +760705,15 @@ var SwitchCommand = class {
|
|
|
760642
760705
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760643
760706
|
context3.stdout.info("");
|
|
760644
760707
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760645
|
-
throw CliError
|
|
760708
|
+
throw new CliError({
|
|
760709
|
+
code: CliError.Code.ConfigError
|
|
760710
|
+
});
|
|
760646
760711
|
}
|
|
760647
760712
|
if (accounts.length === 1) {
|
|
760648
760713
|
const account = accounts[0];
|
|
760649
760714
|
if (account == null) {
|
|
760650
760715
|
context3.stdout.error(`${Icons.error} Internal error; no accounts found`);
|
|
760651
|
-
throw CliError.
|
|
760716
|
+
throw CliError.internalError();
|
|
760652
760717
|
}
|
|
760653
760718
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You only have one account logged in: ${source_default.bold(account.user)}`);
|
|
760654
760719
|
context3.stdout.info("");
|
|
@@ -760671,7 +760736,9 @@ var SwitchCommand = class {
|
|
|
760671
760736
|
async handleInteractiveSwitch(context3, accounts) {
|
|
760672
760737
|
if (!context3.isTTY) {
|
|
760673
760738
|
context3.stdout.error(`${Icons.error} Use --user to specify account in non-interactive mode`);
|
|
760674
|
-
throw CliError
|
|
760739
|
+
throw new CliError({
|
|
760740
|
+
code: CliError.Code.EnvironmentError
|
|
760741
|
+
});
|
|
760675
760742
|
}
|
|
760676
760743
|
const choices = accounts.map((account) => ({
|
|
760677
760744
|
name: account.isActive ? `${account.user} ${source_default.dim("(current)")}` : account.user,
|
|
@@ -760692,7 +760759,9 @@ var SwitchCommand = class {
|
|
|
760692
760759
|
const success2 = await context3.tokenService.switchAccount(user);
|
|
760693
760760
|
if (!success2) {
|
|
760694
760761
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760695
|
-
throw CliError
|
|
760762
|
+
throw new CliError({
|
|
760763
|
+
code: CliError.Code.EnvironmentError
|
|
760764
|
+
});
|
|
760696
760765
|
}
|
|
760697
760766
|
context3.stdout.info(`${Icons.success} Switched to ${source_default.bold(user)}`);
|
|
760698
760767
|
}
|
|
@@ -760729,24 +760798,32 @@ var TokenCommand = class {
|
|
|
760729
760798
|
organizationNotFoundError: () => {
|
|
760730
760799
|
process.stderr.write(`${Icons.error} Organization "${orgId}" was not found.
|
|
760731
760800
|
`);
|
|
760732
|
-
throw CliError
|
|
760801
|
+
throw new CliError({
|
|
760802
|
+
code: CliError.Code.ConfigError
|
|
760803
|
+
});
|
|
760733
760804
|
},
|
|
760734
760805
|
unauthorizedError: () => {
|
|
760735
760806
|
process.stderr.write(`${Icons.error} You do not have access to organization "${orgId}".
|
|
760736
760807
|
`);
|
|
760737
|
-
throw CliError
|
|
760808
|
+
throw new CliError({
|
|
760809
|
+
code: CliError.Code.AuthError
|
|
760810
|
+
});
|
|
760738
760811
|
},
|
|
760739
760812
|
missingOrgPermissionsError: () => {
|
|
760740
760813
|
process.stderr.write(`${Icons.error} You do not have the required permissions in organization "${orgId}".
|
|
760741
760814
|
`);
|
|
760742
|
-
throw CliError
|
|
760815
|
+
throw new CliError({
|
|
760816
|
+
code: CliError.Code.AuthError
|
|
760817
|
+
});
|
|
760743
760818
|
},
|
|
760744
760819
|
_other: () => {
|
|
760745
760820
|
process.stderr.write(`${Icons.error} Failed to generate token.
|
|
760746
760821
|
|
|
760747
760822
|
Please contact support@buildwithfern.com for assistance.
|
|
760748
760823
|
`);
|
|
760749
|
-
throw CliError
|
|
760824
|
+
throw new CliError({
|
|
760825
|
+
code: CliError.Code.InternalError
|
|
760826
|
+
});
|
|
760750
760827
|
}
|
|
760751
760828
|
});
|
|
760752
760829
|
}
|
|
@@ -760762,7 +760839,7 @@ var TokenCommand = class {
|
|
|
760762
760839
|
|
|
760763
760840
|
Run fern init or specify an organization with --org, then run this command again.
|
|
760764
760841
|
`);
|
|
760765
|
-
throw CliError.
|
|
760842
|
+
throw new CliError({ code: CliError.Code.ConfigError });
|
|
760766
760843
|
}
|
|
760767
760844
|
}
|
|
760768
760845
|
};
|
|
@@ -760782,7 +760859,7 @@ var WhoamiCommand = class {
|
|
|
760782
760859
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760783
760860
|
context3.stdout.info("");
|
|
760784
760861
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760785
|
-
throw CliError.
|
|
760862
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
760786
760863
|
}
|
|
760787
760864
|
if (args.json) {
|
|
760788
760865
|
context3.stdout.info(JSON.stringify({ email: activeAccount.user }, null, 2));
|
|
@@ -817768,7 +817845,7 @@ function checkMissingRedirects(removedSlugs, redirects, basePath) {
|
|
|
817768
817845
|
}
|
|
817769
817846
|
|
|
817770
817847
|
// ../yaml/docs-validator/lib/rules/missing-redirects/missing-redirects.js
|
|
817771
|
-
var NOOP_CONTEXT = createMockTaskContext({ logger:
|
|
817848
|
+
var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger(noop2) });
|
|
817772
817849
|
async function fetchMarkdownEntries(fdrOrigin, domain3, basepath, authToken) {
|
|
817773
817850
|
try {
|
|
817774
817851
|
const response = await fetch(`${fdrOrigin}/slugs/markdowns`, {
|
|
@@ -839280,7 +839357,7 @@ function collectPathnamesToCheck(content5, { absoluteFilepath, instanceUrls }) {
|
|
|
839280
839357
|
}
|
|
839281
839358
|
|
|
839282
839359
|
// ../yaml/docs-validator/lib/rules/valid-markdown-link/valid-markdown-link.js
|
|
839283
|
-
var NOOP_CONTEXT2 = createMockTaskContext({ logger:
|
|
839360
|
+
var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger(noop2) });
|
|
839284
839361
|
var ValidMarkdownLinks = {
|
|
839285
839362
|
name: "valid-markdown-links",
|
|
839286
839363
|
create: async ({ workspace, apiWorkspaces, ossWorkspaces }) => {
|
|
@@ -840349,7 +840426,8 @@ var DocsChecker = class {
|
|
|
840349
840426
|
const docsWorkspace = project.docsWorkspaces;
|
|
840350
840427
|
if (docsWorkspace == null) {
|
|
840351
840428
|
throw new CliError({
|
|
840352
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
840429
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
840430
|
+
code: CliError.Code.ConfigError
|
|
840353
840431
|
});
|
|
840354
840432
|
}
|
|
840355
840433
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -840620,12 +840698,12 @@ var CheckCommand2 = class {
|
|
|
840620
840698
|
const response = this.buildJsonResponse({ apiCheckResult, sdkCheckResult, docsCheckResult, hasErrors });
|
|
840621
840699
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
840622
840700
|
if (hasErrors) {
|
|
840623
|
-
throw CliError.
|
|
840701
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840624
840702
|
}
|
|
840625
840703
|
return;
|
|
840626
840704
|
}
|
|
840627
840705
|
if (hasErrors) {
|
|
840628
|
-
throw CliError.
|
|
840706
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840629
840707
|
}
|
|
840630
840708
|
if (totalWarnings > 0) {
|
|
840631
840709
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${totalWarnings} warnings`)}`);
|
|
@@ -840680,7 +840758,8 @@ var CheckCommand2 = class {
|
|
|
840680
840758
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
840681
840759
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
840682
840760
|
throw new CliError({
|
|
840683
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
840761
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
840762
|
+
code: CliError.Code.ConfigError
|
|
840684
840763
|
});
|
|
840685
840764
|
}
|
|
840686
840765
|
}
|
|
@@ -842143,7 +842222,7 @@ var MigrateCommand = class {
|
|
|
842143
842222
|
}
|
|
842144
842223
|
return;
|
|
842145
842224
|
}
|
|
842146
|
-
throw new CliError({ message: "Migration failed" });
|
|
842225
|
+
throw new CliError({ message: "Migration failed", code: CliError.Code.ConfigError });
|
|
842147
842226
|
}
|
|
842148
842227
|
};
|
|
842149
842228
|
function addMigrateCommand(cli) {
|
|
@@ -842166,7 +842245,8 @@ var CheckCommand3 = class {
|
|
|
842166
842245
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
842167
842246
|
if (workspace.docs == null) {
|
|
842168
842247
|
throw new CliError({
|
|
842169
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
842248
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
842249
|
+
code: CliError.Code.ConfigError
|
|
842170
842250
|
});
|
|
842171
842251
|
}
|
|
842172
842252
|
const checker = new DocsChecker({ context: context3 });
|
|
@@ -842176,7 +842256,7 @@ var CheckCommand3 = class {
|
|
|
842176
842256
|
const response = this.buildJsonResponse({ result, hasErrors });
|
|
842177
842257
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
842178
842258
|
if (hasErrors) {
|
|
842179
|
-
throw CliError.
|
|
842259
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842180
842260
|
}
|
|
842181
842261
|
return;
|
|
842182
842262
|
}
|
|
@@ -842188,7 +842268,7 @@ var CheckCommand3 = class {
|
|
|
842188
842268
|
}
|
|
842189
842269
|
}
|
|
842190
842270
|
if (hasErrors) {
|
|
842191
|
-
throw CliError.
|
|
842271
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842192
842272
|
}
|
|
842193
842273
|
if (result.warningCount > 0) {
|
|
842194
842274
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -844029,7 +844109,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
844029
844109
|
var LOGS_FOLDER_NAME = "logs";
|
|
844030
844110
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
844031
844111
|
function getCliSource() {
|
|
844032
|
-
const version7 = "4.68.
|
|
844112
|
+
const version7 = "4.68.3-1-g429be56b56f";
|
|
844033
844113
|
return `cli@${version7}`;
|
|
844034
844114
|
}
|
|
844035
844115
|
var DebugLogger = class {
|
|
@@ -846011,7 +846091,8 @@ var DevCommand = class {
|
|
|
846011
846091
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
846012
846092
|
if (workspace.docs == null) {
|
|
846013
846093
|
throw new CliError({
|
|
846014
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
846094
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
846095
|
+
code: CliError.Code.ConfigError
|
|
846015
846096
|
});
|
|
846016
846097
|
}
|
|
846017
846098
|
const backendPort = args["backend-port"] ?? await getPorts();
|
|
@@ -846021,7 +846102,7 @@ var DevCommand = class {
|
|
|
846021
846102
|
backendPort,
|
|
846022
846103
|
forceDownload: args["force-download"],
|
|
846023
846104
|
bundlePath: args["bundle-path"],
|
|
846024
|
-
logLevel:
|
|
846105
|
+
logLevel: LogLevel.Info
|
|
846025
846106
|
});
|
|
846026
846107
|
}
|
|
846027
846108
|
};
|
|
@@ -846332,11 +846413,11 @@ function getSeverityForViolations(violations) {
|
|
|
846332
846413
|
function getLogLevelForSeverity(severity) {
|
|
846333
846414
|
switch (severity) {
|
|
846334
846415
|
case "fatal":
|
|
846335
|
-
return
|
|
846416
|
+
return LogLevel.Error;
|
|
846336
846417
|
case "error":
|
|
846337
|
-
return
|
|
846418
|
+
return LogLevel.Error;
|
|
846338
846419
|
case "warning":
|
|
846339
|
-
return
|
|
846420
|
+
return LogLevel.Warn;
|
|
846340
846421
|
default:
|
|
846341
846422
|
assertNever(severity);
|
|
846342
846423
|
}
|
|
@@ -853622,15 +853703,15 @@ async function makeWritableRecursive(dirPath) {
|
|
|
853622
853703
|
function convertLogLevel(logLevel) {
|
|
853623
853704
|
switch (logLevel) {
|
|
853624
853705
|
case "DEBUG":
|
|
853625
|
-
return
|
|
853706
|
+
return LogLevel.Debug;
|
|
853626
853707
|
case "INFO":
|
|
853627
|
-
return
|
|
853708
|
+
return LogLevel.Info;
|
|
853628
853709
|
case "WARN":
|
|
853629
|
-
return
|
|
853710
|
+
return LogLevel.Warn;
|
|
853630
853711
|
case "ERROR":
|
|
853631
|
-
return
|
|
853712
|
+
return LogLevel.Error;
|
|
853632
853713
|
default:
|
|
853633
|
-
return
|
|
853714
|
+
return LogLevel.Info;
|
|
853634
853715
|
}
|
|
853635
853716
|
}
|
|
853636
853717
|
async function checkFernIgnorePresent(absolutePathToLocalOutput) {
|
|
@@ -855278,7 +855359,7 @@ var LegacyDocsPublisher = class {
|
|
|
855278
855359
|
previewId,
|
|
855279
855360
|
disableTemplates: void 0,
|
|
855280
855361
|
skipUpload,
|
|
855281
|
-
cliVersion: "4.68.
|
|
855362
|
+
cliVersion: "4.68.3-1-g429be56b56f"
|
|
855282
855363
|
});
|
|
855283
855364
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
855284
855365
|
return { success: false };
|
|
@@ -855871,7 +855952,8 @@ var PublishCommand = class {
|
|
|
855871
855952
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
855872
855953
|
if (workspace.docs == null) {
|
|
855873
855954
|
throw new CliError({
|
|
855874
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855955
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855956
|
+
code: CliError.Code.ConfigError
|
|
855875
855957
|
});
|
|
855876
855958
|
}
|
|
855877
855959
|
const instanceUrl = this.resolveInstanceUrl({
|
|
@@ -855890,7 +855972,8 @@ var PublishCommand = class {
|
|
|
855890
855972
|
const docsWorkspace = project.docsWorkspaces;
|
|
855891
855973
|
if (docsWorkspace == null) {
|
|
855892
855974
|
throw new CliError({
|
|
855893
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855975
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855976
|
+
code: CliError.Code.ConfigError
|
|
855894
855977
|
});
|
|
855895
855978
|
}
|
|
855896
855979
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -855905,7 +855988,10 @@ var PublishCommand = class {
|
|
|
855905
855988
|
});
|
|
855906
855989
|
const docsTask = taskGroup.getTask("publish");
|
|
855907
855990
|
if (docsTask == null) {
|
|
855908
|
-
throw new CliError({
|
|
855991
|
+
throw new CliError({
|
|
855992
|
+
message: "Internal error; task 'publish' not found",
|
|
855993
|
+
code: CliError.Code.InternalError
|
|
855994
|
+
});
|
|
855909
855995
|
}
|
|
855910
855996
|
docsTask.start();
|
|
855911
855997
|
docsTask.stage.validation.start();
|
|
@@ -855949,13 +856035,14 @@ var PublishCommand = class {
|
|
|
855949
856035
|
errorMessage: labels.error
|
|
855950
856036
|
});
|
|
855951
856037
|
if (summary.failedCount > 0) {
|
|
855952
|
-
throw CliError.
|
|
856038
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
855953
856039
|
}
|
|
855954
856040
|
}
|
|
855955
856041
|
resolveInstanceUrl({ instances: instances2, instance }) {
|
|
855956
856042
|
if (instances2.length === 0) {
|
|
855957
856043
|
throw new CliError({
|
|
855958
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856044
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856045
|
+
code: CliError.Code.ConfigError
|
|
855959
856046
|
});
|
|
855960
856047
|
}
|
|
855961
856048
|
if (instance != null) {
|
|
@@ -855968,7 +856055,8 @@ var PublishCommand = class {
|
|
|
855968
856055
|
Available instances:
|
|
855969
856056
|
${available}
|
|
855970
856057
|
|
|
855971
|
-
Use --instance <url> with one of the URLs above
|
|
856058
|
+
Use --instance <url> with one of the URLs above.`,
|
|
856059
|
+
code: CliError.Code.ConfigError
|
|
855972
856060
|
});
|
|
855973
856061
|
}
|
|
855974
856062
|
return match3.url;
|
|
@@ -855981,13 +856069,15 @@ ${available}
|
|
|
855981
856069
|
Available instances:
|
|
855982
856070
|
${available}
|
|
855983
856071
|
|
|
855984
|
-
Use --instance <url> to select one
|
|
856072
|
+
Use --instance <url> to select one.`,
|
|
856073
|
+
code: CliError.Code.ConfigError
|
|
855985
856074
|
});
|
|
855986
856075
|
}
|
|
855987
856076
|
const first3 = instances2[0];
|
|
855988
856077
|
if (first3 == null) {
|
|
855989
856078
|
throw new CliError({
|
|
855990
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856079
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856080
|
+
code: CliError.Code.ConfigError
|
|
855991
856081
|
});
|
|
855992
856082
|
}
|
|
855993
856083
|
return first3.url;
|
|
@@ -856021,7 +856111,8 @@ ${available}
|
|
|
856021
856111
|
const fernToken = process.env["FERN_TOKEN"];
|
|
856022
856112
|
if (fernToken == null) {
|
|
856023
856113
|
throw new CliError({
|
|
856024
|
-
message: "No organization token found. Please set the FERN_TOKEN environment variable."
|
|
856114
|
+
message: "No organization token found. Please set the FERN_TOKEN environment variable.",
|
|
856115
|
+
code: CliError.Code.AuthError
|
|
856025
856116
|
});
|
|
856026
856117
|
}
|
|
856027
856118
|
return Promise.resolve({ type: "organization", value: fernToken });
|
|
@@ -856033,7 +856124,10 @@ function addPublishCommand(cli) {
|
|
|
856033
856124
|
const cmd = new PublishCommand();
|
|
856034
856125
|
command2(cli, "publish", "Publish your documentation site", async (context3, args) => {
|
|
856035
856126
|
const timeout4 = new Promise((_16, reject) => {
|
|
856036
|
-
setTimeout(() => reject(new CliError({
|
|
856127
|
+
setTimeout(() => reject(new CliError({
|
|
856128
|
+
message: "Docs publish timed out after 10 minutes.",
|
|
856129
|
+
code: CliError.Code.NetworkError
|
|
856130
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856037
856131
|
});
|
|
856038
856132
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856039
856133
|
}, (yargs) => yargs.option("force", {
|
|
@@ -856062,7 +856156,8 @@ var DeleteCommand = class {
|
|
|
856062
856156
|
if (!this.isPreviewUrl(args.url)) {
|
|
856063
856157
|
throw new CliError({
|
|
856064
856158
|
message: `Invalid preview URL: ${args.url}
|
|
856065
|
-
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
856159
|
+
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`,
|
|
856160
|
+
code: CliError.Code.ConfigError
|
|
856066
856161
|
});
|
|
856067
856162
|
}
|
|
856068
856163
|
const token = await context3.getTokenOrPrompt();
|
|
@@ -856079,7 +856174,8 @@ var DeleteCommand = class {
|
|
|
856079
856174
|
throw CliError.notFound(`Preview site not found: ${args.url}`);
|
|
856080
856175
|
default:
|
|
856081
856176
|
throw new CliError({
|
|
856082
|
-
message: `Failed to delete preview site: ${args.url}
|
|
856177
|
+
message: `Failed to delete preview site: ${args.url}`,
|
|
856178
|
+
code: CliError.Code.InternalError
|
|
856083
856179
|
});
|
|
856084
856180
|
}
|
|
856085
856181
|
}
|
|
@@ -856126,7 +856222,10 @@ function addPreviewCommand(cli) {
|
|
|
856126
856222
|
const cmd = new PreviewCommand();
|
|
856127
856223
|
commandWithSubcommands(cli, "preview", "Generate a preview of your documentation site", async (context3, args) => {
|
|
856128
856224
|
const timeout4 = new Promise((_16, reject) => {
|
|
856129
|
-
setTimeout(() => reject(new CliError({
|
|
856225
|
+
setTimeout(() => reject(new CliError({
|
|
856226
|
+
message: "Docs preview timed out after 10 minutes.",
|
|
856227
|
+
code: CliError.Code.NetworkError
|
|
856228
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856130
856229
|
});
|
|
856131
856230
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856132
856231
|
}, (yargs) => yargs.option("instance", {
|
|
@@ -856513,7 +856612,7 @@ var Wizard = class {
|
|
|
856513
856612
|
return void 0;
|
|
856514
856613
|
}
|
|
856515
856614
|
this.context.stderr.info(` ${Icons.info} Opening browser to log in to Fern...`);
|
|
856516
|
-
const taskContext = new TaskContextAdapter({ context: this.context, logLevel:
|
|
856615
|
+
const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel.Info });
|
|
856517
856616
|
const { accessToken, idToken } = await getTokenFromAuth0(taskContext, {
|
|
856518
856617
|
useDeviceCodeFlow: false,
|
|
856519
856618
|
forceReauth: false
|
|
@@ -857093,7 +857192,8 @@ var InitCommand = class {
|
|
|
857093
857192
|
async validateArgs({ context: context3, fernYmlPath, args }) {
|
|
857094
857193
|
if (await doesPathExist(fernYmlPath)) {
|
|
857095
857194
|
throw new CliError({
|
|
857096
|
-
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}
|
|
857195
|
+
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`,
|
|
857196
|
+
code: CliError.Code.ConfigError
|
|
857097
857197
|
});
|
|
857098
857198
|
}
|
|
857099
857199
|
if (args.api != null) {
|
|
@@ -857101,13 +857201,14 @@ var InitCommand = class {
|
|
|
857101
857201
|
if (!api.startsWith("http://") && !api.startsWith("https://")) {
|
|
857102
857202
|
const resolved = import_path59.default.resolve(context3.cwd, api);
|
|
857103
857203
|
if (!await doesPathExist(AbsoluteFilePath2.of(resolved))) {
|
|
857104
|
-
throw new CliError({ message: `File not found: ${api}
|
|
857204
|
+
throw new CliError({ message: `File not found: ${api}`, code: CliError.Code.ConfigError });
|
|
857105
857205
|
}
|
|
857106
857206
|
}
|
|
857107
857207
|
}
|
|
857108
857208
|
if (!context3.isTTY && !args.yes) {
|
|
857109
857209
|
throw new CliError({
|
|
857110
|
-
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
|
|
857210
|
+
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults.",
|
|
857211
|
+
code: CliError.Code.ConfigError
|
|
857111
857212
|
});
|
|
857112
857213
|
}
|
|
857113
857214
|
}
|
|
@@ -857133,7 +857234,7 @@ var CreateCommand = class {
|
|
|
857133
857234
|
const token = await context3.getTokenOrPrompt();
|
|
857134
857235
|
if (token.type === "organization") {
|
|
857135
857236
|
context3.stderr.error(`${Icons.error} Organization tokens cannot create organizations. Unset the FERN_TOKEN environment variable and run 'fern auth login' to create an organization.`);
|
|
857136
|
-
throw CliError.
|
|
857237
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857137
857238
|
}
|
|
857138
857239
|
const validationError = getOrganizationNameValidationError(args.name);
|
|
857139
857240
|
if (validationError != null) {
|
|
@@ -857170,7 +857271,7 @@ var ListCommand = class {
|
|
|
857170
857271
|
const token = await context3.getTokenOrPrompt();
|
|
857171
857272
|
if (token.type === "organization") {
|
|
857172
857273
|
context3.stderr.error(`${Icons.error} Organization tokens cannot list organizations. Unset the FERN_TOKEN environment variable and run 'fern auth login' to list your organizations.`);
|
|
857173
|
-
throw CliError.
|
|
857274
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857174
857275
|
}
|
|
857175
857276
|
const venus = createVenusService({ token: token.value });
|
|
857176
857277
|
const firstPage = await this.fetchPage({ venus, pageId: 1 });
|
|
@@ -857314,13 +857415,14 @@ var AddCommand = class {
|
|
|
857314
857415
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
857315
857416
|
if (fernYmlPath == null) {
|
|
857316
857417
|
throw new CliError({
|
|
857317
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
857418
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
857419
|
+
code: CliError.Code.ConfigError
|
|
857318
857420
|
});
|
|
857319
857421
|
}
|
|
857320
857422
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
857321
857423
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
857322
857424
|
if (sdkCheckResult.errorCount > 0) {
|
|
857323
|
-
throw CliError.
|
|
857425
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857324
857426
|
}
|
|
857325
857427
|
const existingTargets = workspace.sdks?.targets ?? [];
|
|
857326
857428
|
if (!context3.isTTY || args.yes) {
|
|
@@ -857333,7 +857435,8 @@ var AddCommand = class {
|
|
|
857333
857435
|
throw new CliError({
|
|
857334
857436
|
message: `Missing required flags:
|
|
857335
857437
|
|
|
857336
|
-
--target <language> SDK language (e.g. typescript, python, go)
|
|
857438
|
+
--target <language> SDK language (e.g. typescript, python, go)`,
|
|
857439
|
+
code: CliError.Code.ConfigError
|
|
857337
857440
|
});
|
|
857338
857441
|
}
|
|
857339
857442
|
const language = this.parseLanguage(args.target);
|
|
@@ -857379,7 +857482,8 @@ var AddCommand = class {
|
|
|
857379
857482
|
message: `"${value}" looks like a remote reference but is not a recognized git URL.
|
|
857380
857483
|
|
|
857381
857484
|
Please specify a local path (e.g. ./sdks/my-sdk) or a git URL:
|
|
857382
|
-
https://github.com/owner/repo
|
|
857485
|
+
https://github.com/owner/repo`,
|
|
857486
|
+
code: CliError.Code.ConfigError
|
|
857383
857487
|
});
|
|
857384
857488
|
}
|
|
857385
857489
|
return { path: value };
|
|
@@ -857401,7 +857505,8 @@ var AddCommand = class {
|
|
|
857401
857505
|
checkForDuplicate({ existingTargets, language }) {
|
|
857402
857506
|
if (existingTargets.some((t3) => t3.name === language)) {
|
|
857403
857507
|
throw new CliError({
|
|
857404
|
-
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}
|
|
857508
|
+
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`,
|
|
857509
|
+
code: CliError.Code.ConfigError
|
|
857405
857510
|
});
|
|
857406
857511
|
}
|
|
857407
857512
|
}
|
|
@@ -857453,7 +857558,8 @@ var AddCommand = class {
|
|
|
857453
857558
|
return lang;
|
|
857454
857559
|
}
|
|
857455
857560
|
throw new CliError({
|
|
857456
|
-
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}
|
|
857561
|
+
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`,
|
|
857562
|
+
code: CliError.Code.ConfigError
|
|
857457
857563
|
});
|
|
857458
857564
|
}
|
|
857459
857565
|
};
|
|
@@ -857490,7 +857596,7 @@ var CheckCommand4 = class {
|
|
|
857490
857596
|
const response = this.buildJsonResponse({ sdkCheckResult: result, hasErrors });
|
|
857491
857597
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
857492
857598
|
if (hasErrors) {
|
|
857493
|
-
throw CliError.
|
|
857599
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857494
857600
|
}
|
|
857495
857601
|
return;
|
|
857496
857602
|
}
|
|
@@ -857502,7 +857608,7 @@ var CheckCommand4 = class {
|
|
|
857502
857608
|
}
|
|
857503
857609
|
}
|
|
857504
857610
|
if (hasErrors) {
|
|
857505
|
-
throw CliError.
|
|
857611
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857506
857612
|
}
|
|
857507
857613
|
if (result.warningCount > 0) {
|
|
857508
857614
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -907911,8 +908017,6 @@ var GenerationRunner = class {
|
|
|
907911
908017
|
}
|
|
907912
908018
|
} catch (error50) {
|
|
907913
908019
|
if (error50 instanceof TaskAbortSignal) {
|
|
907914
|
-
} else if (error50 instanceof LoggableFernCliError) {
|
|
907915
|
-
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50.log}`, error50);
|
|
907916
908020
|
} else {
|
|
907917
908021
|
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
|
|
907918
908022
|
}
|
|
@@ -908345,7 +908449,7 @@ var LegacyLocalGenerationRunner = class {
|
|
|
908345
908449
|
const taskContext = new TaskContextAdapter({
|
|
908346
908450
|
context: this.context,
|
|
908347
908451
|
task: args.task,
|
|
908348
|
-
logLevel:
|
|
908452
|
+
logLevel: LogLevel.Info
|
|
908349
908453
|
});
|
|
908350
908454
|
try {
|
|
908351
908455
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908484,7 +908588,7 @@ var LegacyRemoteGenerationRunner = class {
|
|
|
908484
908588
|
const taskContext = new TaskContextAdapter({
|
|
908485
908589
|
context: this.context,
|
|
908486
908590
|
task: args.task,
|
|
908487
|
-
logLevel:
|
|
908591
|
+
logLevel: LogLevel.Info
|
|
908488
908592
|
});
|
|
908489
908593
|
try {
|
|
908490
908594
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908624,7 +908728,8 @@ var GeneratorPipeline = class {
|
|
|
908624
908728
|
}
|
|
908625
908729
|
if (args.target.registry != null) {
|
|
908626
908730
|
throw new CliError({
|
|
908627
|
-
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry
|
|
908731
|
+
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`,
|
|
908732
|
+
code: CliError.Code.ConfigError
|
|
908628
908733
|
});
|
|
908629
908734
|
}
|
|
908630
908735
|
return await this.runRemoteGeneration(args);
|
|
@@ -908936,7 +909041,8 @@ var GenerateCommand = class {
|
|
|
908936
909041
|
throw new CliError({
|
|
908937
909042
|
message: `No fern.yml found, either run 'fern init' or specify all of the required flags:
|
|
908938
909043
|
|
|
908939
|
-
` + missingFlags.map((flag) => ` ${flag}`).join("\n")
|
|
909044
|
+
` + missingFlags.map((flag) => ` ${flag}`).join("\n"),
|
|
909045
|
+
code: CliError.Code.ConfigError
|
|
908940
909046
|
});
|
|
908941
909047
|
}
|
|
908942
909048
|
const api = args.api;
|
|
@@ -908987,12 +909093,12 @@ var GenerateCommand = class {
|
|
|
908987
909093
|
}
|
|
908988
909094
|
}
|
|
908989
909095
|
if (sdkCheckResult.errorCount > 0) {
|
|
908990
|
-
throw CliError.
|
|
909096
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908991
909097
|
}
|
|
908992
909098
|
}
|
|
908993
909099
|
const validTargets = targets2.filter((t3) => checkResult.validApis.has(t3.api));
|
|
908994
909100
|
if (validTargets.length === 0) {
|
|
908995
|
-
throw CliError.
|
|
909101
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908996
909102
|
}
|
|
908997
909103
|
const pipeline5 = new GeneratorPipeline({
|
|
908998
909104
|
context: context3,
|
|
@@ -909020,7 +909126,7 @@ var GenerateCommand = class {
|
|
|
909020
909126
|
if (outputPath != null) {
|
|
909021
909127
|
const { shouldProceed } = await this.checkOutputDirectory({ context: context3, args, outputPath });
|
|
909022
909128
|
if (!shouldProceed) {
|
|
909023
|
-
throw new CliError({ message: "Generation cancelled." });
|
|
909129
|
+
throw new CliError({ message: "Generation cancelled.", code: CliError.Code.ConfigError });
|
|
909024
909130
|
}
|
|
909025
909131
|
}
|
|
909026
909132
|
}
|
|
@@ -909038,7 +909144,10 @@ var GenerateCommand = class {
|
|
|
909038
909144
|
await Promise.all(targets2.map(async (target) => {
|
|
909039
909145
|
const task = taskGroup.getTask(target.name);
|
|
909040
909146
|
if (task == null) {
|
|
909041
|
-
throw new CliError({
|
|
909147
|
+
throw new CliError({
|
|
909148
|
+
message: `Internal error; task '${target.name}' not found`,
|
|
909149
|
+
code: CliError.Code.InternalError
|
|
909150
|
+
});
|
|
909042
909151
|
}
|
|
909043
909152
|
task.start();
|
|
909044
909153
|
task.stage.validation.start();
|
|
@@ -909084,22 +909193,32 @@ var GenerateCommand = class {
|
|
|
909084
909193
|
errorMessage: `Failed to generate ${sdkInitialism}`
|
|
909085
909194
|
});
|
|
909086
909195
|
if (summary.failedCount > 0) {
|
|
909087
|
-
throw CliError.
|
|
909196
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
909088
909197
|
}
|
|
909089
909198
|
}
|
|
909090
909199
|
validateArgs({ workspace, args, targets: targets2 }) {
|
|
909091
909200
|
if (args["container-engine"] != null && !args.local) {
|
|
909092
|
-
throw new CliError({
|
|
909201
|
+
throw new CliError({
|
|
909202
|
+
message: "The --container-engine flag can only be used with --local",
|
|
909203
|
+
code: CliError.Code.ConfigError
|
|
909204
|
+
});
|
|
909093
909205
|
}
|
|
909094
909206
|
if (args.group != null && args.target != null) {
|
|
909095
|
-
throw new CliError({
|
|
909207
|
+
throw new CliError({
|
|
909208
|
+
message: "The --group and --target flags cannot be used together",
|
|
909209
|
+
code: CliError.Code.ConfigError
|
|
909210
|
+
});
|
|
909096
909211
|
}
|
|
909097
909212
|
if (targets2.length > 1 && args.output != null) {
|
|
909098
|
-
throw new CliError({
|
|
909213
|
+
throw new CliError({
|
|
909214
|
+
message: "The --output flag can only be used when generating a single target",
|
|
909215
|
+
code: CliError.Code.ConfigError
|
|
909216
|
+
});
|
|
909099
909217
|
}
|
|
909100
909218
|
if (args["skip-fernignore"] && args.fernignore != null) {
|
|
909101
909219
|
throw new CliError({
|
|
909102
|
-
message: "The --skip-fernignore and --fernignore flags cannot be used together."
|
|
909220
|
+
message: "The --skip-fernignore and --fernignore flags cannot be used together.",
|
|
909221
|
+
code: CliError.Code.ConfigError
|
|
909103
909222
|
});
|
|
909104
909223
|
}
|
|
909105
909224
|
const issues = [];
|
|
@@ -909151,7 +909270,8 @@ Example:
|
|
|
909151
909270
|
throw new CliError({
|
|
909152
909271
|
message: `Remote generation is not supported with a git URL for --output
|
|
909153
909272
|
|
|
909154
|
-
Use --local or specify a local filesystem path for --output
|
|
909273
|
+
Use --local or specify a local filesystem path for --output`,
|
|
909274
|
+
code: CliError.Code.ConfigError
|
|
909155
909275
|
});
|
|
909156
909276
|
}
|
|
909157
909277
|
const token = process.env.GITHUB_TOKEN ?? process.env.GIT_TOKEN;
|
|
@@ -909163,7 +909283,8 @@ Example:
|
|
|
909163
909283
|
export GITHUB_TOKEN=ghp_xxx
|
|
909164
909284
|
|
|
909165
909285
|
Or use a local path:
|
|
909166
|
-
--output ./my-sdk
|
|
909286
|
+
--output ./my-sdk`,
|
|
909287
|
+
code: CliError.Code.AuthError
|
|
909167
909288
|
});
|
|
909168
909289
|
}
|
|
909169
909290
|
return {
|
|
@@ -909285,7 +909406,10 @@ function addGenerateCommand(cli) {
|
|
|
909285
909406
|
const cmd = new GenerateCommand();
|
|
909286
909407
|
command2(cli, "generate", "Generate SDKs from fern.yml or directly from an API spec", async (context3, args) => {
|
|
909287
909408
|
const timeout4 = new Promise((_16, reject) => {
|
|
909288
|
-
setTimeout(() => reject(new CliError({
|
|
909409
|
+
setTimeout(() => reject(new CliError({
|
|
909410
|
+
message: "Generation timed out after 10 minutes.",
|
|
909411
|
+
code: CliError.Code.NetworkError
|
|
909412
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909289
909413
|
});
|
|
909290
909414
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909291
909415
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909364,7 +909488,10 @@ function addPreviewCommand2(cli) {
|
|
|
909364
909488
|
const cmd = new PreviewCommand2();
|
|
909365
909489
|
command2(cli, "preview", "Generate a preview of an SDK", async (context3, args) => {
|
|
909366
909490
|
const timeout4 = new Promise((_16, reject) => {
|
|
909367
|
-
setTimeout(() => reject(new CliError({
|
|
909491
|
+
setTimeout(() => reject(new CliError({
|
|
909492
|
+
message: "Preview generation timed out after 10 minutes.",
|
|
909493
|
+
code: CliError.Code.NetworkError
|
|
909494
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909368
909495
|
});
|
|
909369
909496
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909370
909497
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909816,13 +909943,14 @@ var UpdateCommand = class {
|
|
|
909816
909943
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
909817
909944
|
if (fernYmlPath == null) {
|
|
909818
909945
|
throw new CliError({
|
|
909819
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
909946
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
909947
|
+
code: CliError.Code.ConfigError
|
|
909820
909948
|
});
|
|
909821
909949
|
}
|
|
909822
909950
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
909823
909951
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
909824
909952
|
if (sdkCheckResult.errorCount > 0) {
|
|
909825
|
-
throw CliError.
|
|
909953
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
909826
909954
|
}
|
|
909827
909955
|
const targets2 = workspace.sdks?.targets;
|
|
909828
909956
|
if (targets2 == null || targets2.length === 0) {
|
|
@@ -909838,7 +909966,8 @@ var UpdateCommand = class {
|
|
|
909838
909966
|
});
|
|
909839
909967
|
if (updates.length === 0 && upToDate.length === 0 && args.target != null) {
|
|
909840
909968
|
throw new CliError({
|
|
909841
|
-
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}
|
|
909969
|
+
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`,
|
|
909970
|
+
code: CliError.Code.ConfigError
|
|
909842
909971
|
});
|
|
909843
909972
|
}
|
|
909844
909973
|
if (updates.length === 0) {
|
|
@@ -924819,19 +924948,19 @@ var Logger4 = class {
|
|
|
924819
924948
|
this.enabled = true;
|
|
924820
924949
|
}
|
|
924821
924950
|
trace(...args) {
|
|
924822
|
-
this.write(
|
|
924951
|
+
this.write(LogLevel.Trace, ...args);
|
|
924823
924952
|
}
|
|
924824
924953
|
debug(...args) {
|
|
924825
|
-
this.write(
|
|
924954
|
+
this.write(LogLevel.Debug, ...args);
|
|
924826
924955
|
}
|
|
924827
924956
|
info(...args) {
|
|
924828
|
-
this.write(
|
|
924957
|
+
this.write(LogLevel.Info, ...args);
|
|
924829
924958
|
}
|
|
924830
924959
|
warn(...args) {
|
|
924831
|
-
this.write(
|
|
924960
|
+
this.write(LogLevel.Warn, ...args);
|
|
924832
924961
|
}
|
|
924833
924962
|
error(...args) {
|
|
924834
|
-
this.write(
|
|
924963
|
+
this.write(LogLevel.Error, ...args);
|
|
924835
924964
|
}
|
|
924836
924965
|
log(level, ...args) {
|
|
924837
924966
|
this.write(level, ...args);
|
|
@@ -928446,6 +928575,24 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
928446
928575
|
// src/cli-context/CliContext.ts
|
|
928447
928576
|
init_lodash();
|
|
928448
928577
|
|
|
928578
|
+
// src/telemetry/reportError.ts
|
|
928579
|
+
function reportError2(reporter, error50, options2) {
|
|
928580
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928581
|
+
return;
|
|
928582
|
+
}
|
|
928583
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
928584
|
+
reporter.instrumentPostHogEvent({
|
|
928585
|
+
command: process.argv.join(" "),
|
|
928586
|
+
properties: {
|
|
928587
|
+
failed: true,
|
|
928588
|
+
errorCode: code5
|
|
928589
|
+
}
|
|
928590
|
+
});
|
|
928591
|
+
if (shouldReportToSentry(code5)) {
|
|
928592
|
+
reporter.captureException(error50 ?? new CliError({ message: options2?.message ?? "", code: code5 }), code5);
|
|
928593
|
+
}
|
|
928594
|
+
}
|
|
928595
|
+
|
|
928449
928596
|
// src/telemetry/SentryClient.ts
|
|
928450
928597
|
var SentryClient = class {
|
|
928451
928598
|
sentry;
|
|
@@ -928468,12 +928615,15 @@ var SentryClient = class {
|
|
|
928468
928615
|
setSentryRunIdTags();
|
|
928469
928616
|
}
|
|
928470
928617
|
}
|
|
928471
|
-
|
|
928618
|
+
captureException(error50, code5) {
|
|
928472
928619
|
if (this.sentry == null) {
|
|
928473
928620
|
return;
|
|
928474
928621
|
}
|
|
928475
928622
|
try {
|
|
928476
|
-
this.sentry.captureException(
|
|
928623
|
+
this.sentry.captureException(
|
|
928624
|
+
error50,
|
|
928625
|
+
code5 != null ? { captureContext: { tags: { "error.code": code5 } } } : void 0
|
|
928626
|
+
);
|
|
928477
928627
|
} catch {
|
|
928478
928628
|
}
|
|
928479
928629
|
}
|
|
@@ -928531,13 +928681,15 @@ var TaskContextImpl = class {
|
|
|
928531
928681
|
status = "notStarted";
|
|
928532
928682
|
onResult;
|
|
928533
928683
|
instrumentPostHogEventImpl;
|
|
928684
|
+
captureExceptionImpl;
|
|
928534
928685
|
constructor({
|
|
928535
928686
|
logImmediately,
|
|
928536
928687
|
logPrefix,
|
|
928537
928688
|
takeOverTerminal,
|
|
928538
928689
|
onResult,
|
|
928539
928690
|
shouldBufferLogs,
|
|
928540
|
-
instrumentPostHogEvent
|
|
928691
|
+
instrumentPostHogEvent,
|
|
928692
|
+
captureException: captureException2
|
|
928541
928693
|
}) {
|
|
928542
928694
|
this.logImmediately = logImmediately;
|
|
928543
928695
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -928545,6 +928697,7 @@ var TaskContextImpl = class {
|
|
|
928545
928697
|
this.onResult = onResult;
|
|
928546
928698
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
928547
928699
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
928700
|
+
this.captureExceptionImpl = captureException2;
|
|
928548
928701
|
}
|
|
928549
928702
|
start() {
|
|
928550
928703
|
this.status = "running";
|
|
@@ -928562,14 +928715,21 @@ var TaskContextImpl = class {
|
|
|
928562
928715
|
return this.status === "finished";
|
|
928563
928716
|
}
|
|
928564
928717
|
takeOverTerminal;
|
|
928565
|
-
failAndThrow(message, error50) {
|
|
928566
|
-
this.failWithoutThrowing(message, error50);
|
|
928718
|
+
failAndThrow(message, error50, options2) {
|
|
928719
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
928567
928720
|
this.finish();
|
|
928568
928721
|
throw new TaskAbortSignal();
|
|
928569
928722
|
}
|
|
928570
|
-
failWithoutThrowing(message, error50) {
|
|
928571
|
-
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928723
|
+
failWithoutThrowing(message, error50, options2) {
|
|
928572
928724
|
this.result = TaskResult.Failure;
|
|
928725
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928726
|
+
return;
|
|
928727
|
+
}
|
|
928728
|
+
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928729
|
+
reportError2(this, error50, { ...options2, message });
|
|
928730
|
+
}
|
|
928731
|
+
captureException(error50, code5) {
|
|
928732
|
+
this.captureExceptionImpl?.(error50, code5);
|
|
928573
928733
|
}
|
|
928574
928734
|
getResult() {
|
|
928575
928735
|
return this.result;
|
|
@@ -928601,7 +928761,7 @@ var TaskContextImpl = class {
|
|
|
928601
928761
|
this.logImmediately(this.bufferedLogs);
|
|
928602
928762
|
this.bufferedLogs = [];
|
|
928603
928763
|
}
|
|
928604
|
-
logger =
|
|
928764
|
+
logger = createLogger(this.logAtLevel.bind(this));
|
|
928605
928765
|
addInteractiveTask({ name: name2, subtitle }) {
|
|
928606
928766
|
const subtask = new InteractiveTaskContextImpl({
|
|
928607
928767
|
name: name2,
|
|
@@ -928611,7 +928771,8 @@ var TaskContextImpl = class {
|
|
|
928611
928771
|
takeOverTerminal: this.takeOverTerminal,
|
|
928612
928772
|
onResult: this.onResult,
|
|
928613
928773
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
928614
|
-
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
|
|
928774
|
+
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
|
|
928775
|
+
captureException: this.captureExceptionImpl
|
|
928615
928776
|
});
|
|
928616
928777
|
this.subtasks.push(subtask);
|
|
928617
928778
|
return subtask;
|
|
@@ -928641,7 +928802,7 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928641
928802
|
}
|
|
928642
928803
|
start() {
|
|
928643
928804
|
super.start();
|
|
928644
|
-
this.logAtLevelWithOverrides(
|
|
928805
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Started."], {
|
|
928645
928806
|
omitOnTTY: true
|
|
928646
928807
|
});
|
|
928647
928808
|
this.flushLogs();
|
|
@@ -928652,11 +928813,11 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928652
928813
|
}
|
|
928653
928814
|
finish() {
|
|
928654
928815
|
if (this.result === TaskResult.Success) {
|
|
928655
|
-
this.logAtLevelWithOverrides(
|
|
928816
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Finished."], {
|
|
928656
928817
|
omitOnTTY: true
|
|
928657
928818
|
});
|
|
928658
928819
|
} else {
|
|
928659
|
-
this.logAtLevelWithOverrides(
|
|
928820
|
+
this.logAtLevelWithOverrides(LogLevel.Error, ["Failed."], {
|
|
928660
928821
|
omitOnTTY: true
|
|
928661
928822
|
});
|
|
928662
928823
|
}
|
|
@@ -928984,7 +929145,7 @@ var CliContext = class _CliContext {
|
|
|
928984
929145
|
didSucceed = true;
|
|
928985
929146
|
numTasks = 0;
|
|
928986
929147
|
ttyAwareLogger;
|
|
928987
|
-
logLevel =
|
|
929148
|
+
logLevel = LogLevel.Info;
|
|
928988
929149
|
isLocal;
|
|
928989
929150
|
stdoutRedirector = new StdoutRedirector();
|
|
928990
929151
|
jsonMode = false;
|
|
@@ -929019,7 +929180,7 @@ var CliContext = class _CliContext {
|
|
|
929019
929180
|
if (false) {
|
|
929020
929181
|
this.logger.error("CLI_VERSION is not defined");
|
|
929021
929182
|
}
|
|
929022
|
-
return "4.68.
|
|
929183
|
+
return "4.68.3-1-g429be56b56f";
|
|
929023
929184
|
}
|
|
929024
929185
|
getCliName() {
|
|
929025
929186
|
if (false) {
|
|
@@ -929035,13 +929196,17 @@ var CliContext = class _CliContext {
|
|
|
929035
929196
|
`Running ${source_default.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`
|
|
929036
929197
|
);
|
|
929037
929198
|
}
|
|
929038
|
-
failAndThrow(message, error50) {
|
|
929039
|
-
this.failWithoutThrowing(message, error50);
|
|
929199
|
+
failAndThrow(message, error50, options2) {
|
|
929200
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
929040
929201
|
throw new TaskAbortSignal();
|
|
929041
929202
|
}
|
|
929042
|
-
failWithoutThrowing(message, error50) {
|
|
929203
|
+
failWithoutThrowing(message, error50, options2) {
|
|
929043
929204
|
this.didSucceed = false;
|
|
929205
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
929206
|
+
return;
|
|
929207
|
+
}
|
|
929044
929208
|
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
929209
|
+
reportError2(this, error50, { ...options2, message });
|
|
929045
929210
|
}
|
|
929046
929211
|
/**
|
|
929047
929212
|
* Activate JSON-output mode: all logger output is forced to stderr
|
|
@@ -929144,15 +929309,7 @@ var CliContext = class _CliContext {
|
|
|
929144
929309
|
try {
|
|
929145
929310
|
result = await run(context3);
|
|
929146
929311
|
} catch (error50) {
|
|
929147
|
-
|
|
929148
|
-
throw error50;
|
|
929149
|
-
}
|
|
929150
|
-
if (error50.message.includes("globalThis")) {
|
|
929151
|
-
context3.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE);
|
|
929152
|
-
context3.failWithoutThrowing();
|
|
929153
|
-
} else {
|
|
929154
|
-
context3.failWithoutThrowing(void 0, error50);
|
|
929155
|
-
}
|
|
929312
|
+
context3.failWithoutThrowing(void 0, error50);
|
|
929156
929313
|
throw new TaskAbortSignal();
|
|
929157
929314
|
} finally {
|
|
929158
929315
|
context3.finish();
|
|
@@ -929164,11 +929321,11 @@ var CliContext = class _CliContext {
|
|
|
929164
929321
|
this.posthogManager.sendEvent(event);
|
|
929165
929322
|
}
|
|
929166
929323
|
}
|
|
929167
|
-
|
|
929168
|
-
|
|
929324
|
+
captureException(error50, code5) {
|
|
929325
|
+
this.sentryClient.captureException(error50, code5);
|
|
929169
929326
|
}
|
|
929170
|
-
logger =
|
|
929171
|
-
stderr =
|
|
929327
|
+
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
929328
|
+
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
929172
929329
|
constructTaskInitForWorkspace(workspace) {
|
|
929173
929330
|
const prefixWithoutPadding = wrapWorkspaceNameForPrefix(
|
|
929174
929331
|
workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api"
|
|
@@ -929194,7 +929351,10 @@ var CliContext = class _CliContext {
|
|
|
929194
929351
|
instrumentPostHogEvent: (event) => {
|
|
929195
929352
|
this.instrumentPostHogEvent(event);
|
|
929196
929353
|
},
|
|
929197
|
-
shouldBufferLogs: false
|
|
929354
|
+
shouldBufferLogs: false,
|
|
929355
|
+
captureException: (error50, code5) => {
|
|
929356
|
+
this.sentryClient.captureException(error50, code5);
|
|
929357
|
+
}
|
|
929198
929358
|
};
|
|
929199
929359
|
}
|
|
929200
929360
|
log(level, ...parts) {
|
|
@@ -929221,7 +929381,7 @@ var CliContext = class _CliContext {
|
|
|
929221
929381
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
929222
929382
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
929223
929383
|
this.ttyAwareLogger.log(filtered, {
|
|
929224
|
-
includeDebugInfo: this.logLevel ===
|
|
929384
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
929225
929385
|
stderr: stderr || this.jsonMode
|
|
929226
929386
|
});
|
|
929227
929387
|
}
|
|
@@ -947195,7 +947355,6 @@ function evaluateRuntime4() {
|
|
|
947195
947355
|
|
|
947196
947356
|
// src/cli.ts
|
|
947197
947357
|
void runCli();
|
|
947198
|
-
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
947199
947358
|
async function runCli() {
|
|
947200
947359
|
getOrCreateFernRunId();
|
|
947201
947360
|
const isLocal = process.argv.includes("--local");
|
|
@@ -947233,24 +947392,7 @@ async function runCli() {
|
|
|
947233
947392
|
});
|
|
947234
947393
|
}
|
|
947235
947394
|
} catch (error50) {
|
|
947236
|
-
cliContext.
|
|
947237
|
-
command: process.argv.join(" "),
|
|
947238
|
-
properties: {
|
|
947239
|
-
failed: true,
|
|
947240
|
-
error: error50
|
|
947241
|
-
}
|
|
947242
|
-
});
|
|
947243
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
947244
|
-
cliContext.failWithoutThrowing();
|
|
947245
|
-
} else if (error50?.message.includes("globalThis")) {
|
|
947246
|
-
cliContext.logger.error(USE_NODE_18_OR_ABOVE_MESSAGE);
|
|
947247
|
-
cliContext.failWithoutThrowing();
|
|
947248
|
-
} else if (error50 instanceof LoggableFernCliError) {
|
|
947249
|
-
cliContext.logger.error(`Failed. ${error50.log}`);
|
|
947250
|
-
} else {
|
|
947251
|
-
await cliContext.captureException(error50);
|
|
947252
|
-
cliContext.failWithoutThrowing("Failed.", error50);
|
|
947253
|
-
}
|
|
947395
|
+
cliContext.failWithoutThrowing(void 0, error50);
|
|
947254
947396
|
}
|
|
947255
947397
|
await exit3();
|
|
947256
947398
|
}
|
|
@@ -947281,7 +947423,7 @@ async function tryRunCli(cliContext) {
|
|
|
947281
947423
|
}
|
|
947282
947424
|
}
|
|
947283
947425
|
).option("log-level", {
|
|
947284
|
-
default:
|
|
947426
|
+
default: LogLevel.Info,
|
|
947285
947427
|
choices: LOG_LEVELS
|
|
947286
947428
|
}).demandCommand().recommendCommands();
|
|
947287
947429
|
addDiffCommand(cli, cliContext);
|