@fern-api/fern-api-dev 4.68.3-3-g2b499fcba0f → 4.68.3
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 +1242 -1397
- 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 reportError(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 = reportError;
|
|
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 createLogger(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 createLogger2(label, verbose, initialStep, infoDebugger = createLog())
|
|
|
54552
54552
|
function sibling2(name2, initial) {
|
|
54553
54553
|
return append(
|
|
54554
54554
|
spawned,
|
|
54555
|
-
|
|
54555
|
+
createLogger(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 = createLogger(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 = createLogger("", "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 createLogger2(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 = createLogger2(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: createLogger3(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 createLogger3, 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
|
+
createLogger3 = (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: createLogger3(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 = reportError;
|
|
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 reportError(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,224 +485174,6 @@ 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
|
-
Unclassified: "UNCLASSIFIED"
|
|
485227
|
-
};
|
|
485228
|
-
})(CliError || (CliError = {}));
|
|
485229
|
-
var SENTRY_REPORTABLE = {
|
|
485230
|
-
[CliError.Code.InternalError]: true,
|
|
485231
|
-
[CliError.Code.ResolutionError]: true,
|
|
485232
|
-
[CliError.Code.IrConversionError]: true,
|
|
485233
|
-
[CliError.Code.ContainerError]: true,
|
|
485234
|
-
[CliError.Code.VersionError]: true,
|
|
485235
|
-
[CliError.Code.ParseError]: false,
|
|
485236
|
-
[CliError.Code.EnvironmentError]: false,
|
|
485237
|
-
[CliError.Code.ReferenceError]: false,
|
|
485238
|
-
[CliError.Code.ValidationError]: false,
|
|
485239
|
-
[CliError.Code.NetworkError]: false,
|
|
485240
|
-
[CliError.Code.AuthError]: false,
|
|
485241
|
-
[CliError.Code.ConfigError]: false,
|
|
485242
|
-
[CliError.Code.Unclassified]: false
|
|
485243
|
-
};
|
|
485244
|
-
function shouldReportToSentry(code5) {
|
|
485245
|
-
return SENTRY_REPORTABLE[code5];
|
|
485246
|
-
}
|
|
485247
|
-
function isSchemaValidationError(error50) {
|
|
485248
|
-
return error50 instanceof Error && (error50.constructor.name === "ParseError" || error50.constructor.name === "JsonError");
|
|
485249
|
-
}
|
|
485250
|
-
function isNodeVersionError(error50) {
|
|
485251
|
-
return error50 instanceof Error && error50.message.includes("globalThis");
|
|
485252
|
-
}
|
|
485253
|
-
function resolveErrorCode(error50, explicitCode) {
|
|
485254
|
-
if (explicitCode != null) {
|
|
485255
|
-
return explicitCode;
|
|
485256
|
-
}
|
|
485257
|
-
if (error50 instanceof CliError) {
|
|
485258
|
-
return error50.code;
|
|
485259
|
-
}
|
|
485260
|
-
if (isSchemaValidationError(error50)) {
|
|
485261
|
-
return CliError.Code.ParseError;
|
|
485262
|
-
}
|
|
485263
|
-
if (isNodeVersionError(error50)) {
|
|
485264
|
-
return CliError.Code.EnvironmentError;
|
|
485265
|
-
}
|
|
485266
|
-
return CliError.Code.Unclassified;
|
|
485267
|
-
}
|
|
485268
|
-
|
|
485269
|
-
// ../logger/lib/LogLevel.js
|
|
485270
|
-
var LogLevel = {
|
|
485271
|
-
Trace: "trace",
|
|
485272
|
-
Debug: "debug",
|
|
485273
|
-
Info: "info",
|
|
485274
|
-
Warn: "warn",
|
|
485275
|
-
Error: "error"
|
|
485276
|
-
};
|
|
485277
|
-
var LOG_LEVELS = Object.values(LogLevel);
|
|
485278
|
-
|
|
485279
|
-
// ../logger/lib/createLogger.js
|
|
485280
|
-
var LoggerImpl = class {
|
|
485281
|
-
log;
|
|
485282
|
-
enabled;
|
|
485283
|
-
constructor(log4, enabled = true) {
|
|
485284
|
-
this.log = log4;
|
|
485285
|
-
this.enabled = enabled;
|
|
485286
|
-
}
|
|
485287
|
-
disable() {
|
|
485288
|
-
this.enabled = false;
|
|
485289
|
-
}
|
|
485290
|
-
enable() {
|
|
485291
|
-
this.enabled = true;
|
|
485292
|
-
}
|
|
485293
|
-
debug(...args) {
|
|
485294
|
-
if (this.enabled) {
|
|
485295
|
-
this.log(LogLevel.Debug, ...args);
|
|
485296
|
-
}
|
|
485297
|
-
}
|
|
485298
|
-
info(...args) {
|
|
485299
|
-
if (this.enabled) {
|
|
485300
|
-
this.log(LogLevel.Info, ...args);
|
|
485301
|
-
}
|
|
485302
|
-
}
|
|
485303
|
-
warn(...args) {
|
|
485304
|
-
if (this.enabled) {
|
|
485305
|
-
this.log(LogLevel.Warn, ...args);
|
|
485306
|
-
}
|
|
485307
|
-
}
|
|
485308
|
-
error(...args) {
|
|
485309
|
-
if (this.enabled) {
|
|
485310
|
-
this.log(LogLevel.Error, ...args);
|
|
485311
|
-
}
|
|
485312
|
-
}
|
|
485313
|
-
trace(...args) {
|
|
485314
|
-
if (this.enabled) {
|
|
485315
|
-
this.log(LogLevel.Trace, ...args);
|
|
485316
|
-
}
|
|
485317
|
-
}
|
|
485318
|
-
};
|
|
485319
|
-
function createLogger(log4) {
|
|
485320
|
-
return new LoggerImpl(log4);
|
|
485321
|
-
}
|
|
485322
|
-
|
|
485323
|
-
// ../logger/lib/console.js
|
|
485324
|
-
var CONSOLE_LOGGER = Object.freeze(createLogger(log3));
|
|
485325
|
-
function log3(level, ...args) {
|
|
485326
|
-
const consoleLogger = getConsoleLoggerForLevel(level);
|
|
485327
|
-
consoleLogger(...args);
|
|
485328
|
-
}
|
|
485329
|
-
function getConsoleLoggerForLevel(level) {
|
|
485330
|
-
switch (level) {
|
|
485331
|
-
case LogLevel.Trace:
|
|
485332
|
-
return console.trace;
|
|
485333
|
-
case LogLevel.Debug:
|
|
485334
|
-
return console.debug;
|
|
485335
|
-
case LogLevel.Info:
|
|
485336
|
-
return console.info;
|
|
485337
|
-
case LogLevel.Warn:
|
|
485338
|
-
return console.warn;
|
|
485339
|
-
case LogLevel.Error:
|
|
485340
|
-
return console.error;
|
|
485341
|
-
}
|
|
485342
|
-
}
|
|
485343
|
-
|
|
485344
|
-
// ../task-context/lib/TaskAbortSignal.js
|
|
485345
|
-
var TaskAbortSignal = class {
|
|
485346
|
-
__brand = "TaskAbortSignal";
|
|
485347
|
-
};
|
|
485348
|
-
|
|
485349
|
-
// ../task-context/lib/TaskContext.js
|
|
485350
|
-
var TaskResult;
|
|
485351
|
-
(function(TaskResult2) {
|
|
485352
|
-
TaskResult2[TaskResult2["Success"] = 0] = "Success";
|
|
485353
|
-
TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
|
|
485354
|
-
})(TaskResult || (TaskResult = {}));
|
|
485355
|
-
|
|
485356
|
-
// ../task-context/lib/MockTaskContext.js
|
|
485357
|
-
function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
485358
|
-
const context3 = {
|
|
485359
|
-
logger: logger4,
|
|
485360
|
-
takeOverTerminal: () => {
|
|
485361
|
-
throw new Error("Not implemented");
|
|
485362
|
-
},
|
|
485363
|
-
failAndThrow: (message, error50, _options) => {
|
|
485364
|
-
const parts = [];
|
|
485365
|
-
if (message != null) {
|
|
485366
|
-
parts.push(message);
|
|
485367
|
-
}
|
|
485368
|
-
if (error50 != null) {
|
|
485369
|
-
parts.push(JSON.stringify(error50));
|
|
485370
|
-
}
|
|
485371
|
-
if (parts.length > 0) {
|
|
485372
|
-
context3.logger.error(...parts);
|
|
485373
|
-
}
|
|
485374
|
-
throw new TaskAbortSignal();
|
|
485375
|
-
},
|
|
485376
|
-
failWithoutThrowing: (message, error50, _options) => {
|
|
485377
|
-
context3.failAndThrow(message, error50);
|
|
485378
|
-
},
|
|
485379
|
-
captureException: () => {
|
|
485380
|
-
},
|
|
485381
|
-
getResult: () => TaskResult.Success,
|
|
485382
|
-
addInteractiveTask: () => {
|
|
485383
|
-
throw new Error("Not implemented");
|
|
485384
|
-
},
|
|
485385
|
-
runInteractiveTask: () => {
|
|
485386
|
-
throw new Error("Not implemented");
|
|
485387
|
-
},
|
|
485388
|
-
instrumentPostHogEvent: () => {
|
|
485389
|
-
throw new Error("Not implemented");
|
|
485390
|
-
}
|
|
485391
|
-
};
|
|
485392
|
-
return context3;
|
|
485393
|
-
}
|
|
485394
|
-
|
|
485395
485177
|
// ../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
485396
485178
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
485397
485179
|
var wrapAnsi16 = (offset2 = 0) => (code5) => `\x1B[${code5 + offset2}m`;
|
|
@@ -518947,17 +518729,17 @@ var FernDocsConfigTimeoutError = class extends Error {
|
|
|
518947
518729
|
};
|
|
518948
518730
|
|
|
518949
518731
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/logger.js
|
|
518950
|
-
var
|
|
518732
|
+
var LogLevel = {
|
|
518951
518733
|
Debug: "debug",
|
|
518952
518734
|
Info: "info",
|
|
518953
518735
|
Warn: "warn",
|
|
518954
518736
|
Error: "error"
|
|
518955
518737
|
};
|
|
518956
518738
|
var logLevelMap2 = {
|
|
518957
|
-
[
|
|
518958
|
-
[
|
|
518959
|
-
[
|
|
518960
|
-
[
|
|
518739
|
+
[LogLevel.Debug]: 1,
|
|
518740
|
+
[LogLevel.Info]: 2,
|
|
518741
|
+
[LogLevel.Warn]: 3,
|
|
518742
|
+
[LogLevel.Error]: 4
|
|
518961
518743
|
};
|
|
518962
518744
|
var ConsoleLogger = class {
|
|
518963
518745
|
debug(message, ...args) {
|
|
@@ -518999,7 +518781,7 @@ var Logger = class {
|
|
|
518999
518781
|
* @returns True if debug logs should be output
|
|
519000
518782
|
*/
|
|
519001
518783
|
isDebug() {
|
|
519002
|
-
return this.shouldLog(
|
|
518784
|
+
return this.shouldLog(LogLevel.Debug);
|
|
519003
518785
|
}
|
|
519004
518786
|
/**
|
|
519005
518787
|
* Logs a debug message if debug logging is enabled.
|
|
@@ -519016,7 +518798,7 @@ var Logger = class {
|
|
|
519016
518798
|
* @returns True if info logs should be output
|
|
519017
518799
|
*/
|
|
519018
518800
|
isInfo() {
|
|
519019
|
-
return this.shouldLog(
|
|
518801
|
+
return this.shouldLog(LogLevel.Info);
|
|
519020
518802
|
}
|
|
519021
518803
|
/**
|
|
519022
518804
|
* Logs an info message if info logging is enabled.
|
|
@@ -519033,7 +518815,7 @@ var Logger = class {
|
|
|
519033
518815
|
* @returns True if warning logs should be output
|
|
519034
518816
|
*/
|
|
519035
518817
|
isWarn() {
|
|
519036
|
-
return this.shouldLog(
|
|
518818
|
+
return this.shouldLog(LogLevel.Warn);
|
|
519037
518819
|
}
|
|
519038
518820
|
/**
|
|
519039
518821
|
* Logs a warning message if warning logging is enabled.
|
|
@@ -519050,7 +518832,7 @@ var Logger = class {
|
|
|
519050
518832
|
* @returns True if error logs should be output
|
|
519051
518833
|
*/
|
|
519052
518834
|
isError() {
|
|
519053
|
-
return this.shouldLog(
|
|
518835
|
+
return this.shouldLog(LogLevel.Error);
|
|
519054
518836
|
}
|
|
519055
518837
|
/**
|
|
519056
518838
|
* Logs an error message if error logging is enabled.
|
|
@@ -519064,7 +518846,7 @@ var Logger = class {
|
|
|
519064
518846
|
}
|
|
519065
518847
|
};
|
|
519066
518848
|
var defaultLogger = new Logger({
|
|
519067
|
-
level:
|
|
518849
|
+
level: LogLevel.Info,
|
|
519068
518850
|
logger: new ConsoleLogger(),
|
|
519069
518851
|
silent: true
|
|
519070
518852
|
});
|
|
@@ -519072,7 +518854,7 @@ var defaultLogger = new Logger({
|
|
|
519072
518854
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/exports.js
|
|
519073
518855
|
var logging;
|
|
519074
518856
|
(function(logging2) {
|
|
519075
|
-
logging2.LogLevel =
|
|
518857
|
+
logging2.LogLevel = LogLevel;
|
|
519076
518858
|
logging2.ConsoleLogger = ConsoleLogger;
|
|
519077
518859
|
})(logging || (logging = {}));
|
|
519078
518860
|
|
|
@@ -555265,6 +555047,142 @@ function joinZodPath(arr) {
|
|
|
555265
555047
|
|
|
555266
555048
|
// ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
|
|
555267
555049
|
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
|
|
555268
555186
|
var import_path21 = __toESM(require("path"), 1);
|
|
555269
555187
|
var EMPTY_DEPENDENCIES_CONFIGURATION = {
|
|
555270
555188
|
dependencies: {}
|
|
@@ -564395,7 +564313,7 @@ function mergeIntermediateRepresentation(ir1, ir23, casingsGenerator) {
|
|
|
564395
564313
|
schemes: ir23.auth?.schemes?.length != null && ir23.auth.schemes.length > (ir1.auth?.schemes?.length ?? 0) ? ir23.auth.schemes : ir1.auth?.schemes ?? [],
|
|
564396
564314
|
docs: ir1.auth?.docs ?? ir23.auth?.docs
|
|
564397
564315
|
},
|
|
564398
|
-
headers:
|
|
564316
|
+
headers: [...ir1.headers ?? [], ...ir23.headers ?? []],
|
|
564399
564317
|
environments: environments2,
|
|
564400
564318
|
types: {
|
|
564401
564319
|
...ir1.types ?? {},
|
|
@@ -564433,7 +564351,7 @@ function mergeIntermediateRepresentation(ir1, ir23, casingsGenerator) {
|
|
|
564433
564351
|
},
|
|
564434
564352
|
fdrApiDefinitionId: ir1.fdrApiDefinitionId ?? ir23.fdrApiDefinitionId,
|
|
564435
564353
|
apiVersion: ir1.apiVersion ?? ir23.apiVersion,
|
|
564436
|
-
idempotencyHeaders:
|
|
564354
|
+
idempotencyHeaders: [...ir1.idempotencyHeaders ?? [], ...ir23.idempotencyHeaders ?? []],
|
|
564437
564355
|
pathParameters: [...ir1.pathParameters ?? [], ...ir23.pathParameters ?? []],
|
|
564438
564356
|
errorDiscriminationStrategy: ir1.errorDiscriminationStrategy ?? ir23.errorDiscriminationStrategy,
|
|
564439
564357
|
variables: [...ir1.variables ?? [], ...ir23.variables ?? []],
|
|
@@ -564765,17 +564683,6 @@ function isWebsocketEnvironment(environment2) {
|
|
|
564765
564683
|
}
|
|
564766
564684
|
return false;
|
|
564767
564685
|
}
|
|
564768
|
-
function deduplicateHeaders(headers2) {
|
|
564769
|
-
const seen = /* @__PURE__ */ new Set();
|
|
564770
|
-
return headers2.filter((header) => {
|
|
564771
|
-
const wireValue = getWireValue(header.name).toLowerCase();
|
|
564772
|
-
if (seen.has(wireValue)) {
|
|
564773
|
-
return false;
|
|
564774
|
-
}
|
|
564775
|
-
seen.add(wireValue);
|
|
564776
|
-
return true;
|
|
564777
|
-
});
|
|
564778
|
-
}
|
|
564779
564686
|
function generateUniqueName(id2, existingIds) {
|
|
564780
564687
|
let uniqueName = id2;
|
|
564781
564688
|
let suffix = 1;
|
|
@@ -571262,7 +571169,7 @@ function getInline2(typeDeclaration2) {
|
|
|
571262
571169
|
function getTypeDeclaration(typeId, types4) {
|
|
571263
571170
|
const maybeTypeDeclaration = types4[typeId];
|
|
571264
571171
|
if (maybeTypeDeclaration == null) {
|
|
571265
|
-
throw
|
|
571172
|
+
throw new LoggableFernCliError(`Illegal Error: Failed to load type declaration for type ${typeId}`);
|
|
571266
571173
|
}
|
|
571267
571174
|
return maybeTypeDeclaration;
|
|
571268
571175
|
}
|
|
@@ -571324,7 +571231,7 @@ function getObjectTypeDeclarationFromTypeId(typeId, ir15) {
|
|
|
571324
571231
|
}
|
|
571325
571232
|
}
|
|
571326
571233
|
}
|
|
571327
|
-
throw
|
|
571234
|
+
throw new LoggableFernCliError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
|
|
571328
571235
|
}
|
|
571329
571236
|
function getAllPropertiesForObject2({ objectTypeDeclaration, ir: ir15 }) {
|
|
571330
571237
|
const extendedProperties = objectTypeDeclaration.extends.flatMap((extended) => {
|
|
@@ -579586,8 +579493,7 @@ function formatLog({ breadcrumbs = [], title: title3, subtitle }) {
|
|
|
579586
579493
|
}
|
|
579587
579494
|
|
|
579588
579495
|
// ../cli-logger/lib/logErrorMessage.js
|
|
579589
|
-
|
|
579590
|
-
function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel.Error }) {
|
|
579496
|
+
function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel2.Error }) {
|
|
579591
579497
|
if (message != null) {
|
|
579592
579498
|
logger4.log(logLevel, message);
|
|
579593
579499
|
} else if (error50 == null) {
|
|
@@ -579612,9 +579518,6 @@ function convertErrorToString(error50) {
|
|
|
579612
579518
|
return error50;
|
|
579613
579519
|
}
|
|
579614
579520
|
if (error50 instanceof Error) {
|
|
579615
|
-
if (error50?.message?.includes("globalThis")) {
|
|
579616
|
-
return USE_NODE_18_OR_ABOVE_MESSAGE;
|
|
579617
|
-
}
|
|
579618
579521
|
return error50.message;
|
|
579619
579522
|
}
|
|
579620
579523
|
return void 0;
|
|
@@ -580398,13 +580301,13 @@ function formatLog2(log4, { includeDebugInfo }) {
|
|
|
580398
580301
|
}
|
|
580399
580302
|
content5 += "\n";
|
|
580400
580303
|
switch (log4.level) {
|
|
580401
|
-
case
|
|
580304
|
+
case LogLevel2.Error:
|
|
580402
580305
|
return source_default.red(content5);
|
|
580403
|
-
case
|
|
580306
|
+
case LogLevel2.Warn:
|
|
580404
580307
|
return source_default.hex("FFA500")(content5);
|
|
580405
|
-
case
|
|
580406
|
-
case
|
|
580407
|
-
case
|
|
580308
|
+
case LogLevel2.Trace:
|
|
580309
|
+
case LogLevel2.Debug:
|
|
580310
|
+
case LogLevel2.Info:
|
|
580408
580311
|
return content5;
|
|
580409
580312
|
}
|
|
580410
580313
|
}
|
|
@@ -580414,15 +580317,15 @@ function getDebugPrefix(log4) {
|
|
|
580414
580317
|
}
|
|
580415
580318
|
function getLogLevelAsString(logLevel) {
|
|
580416
580319
|
switch (logLevel) {
|
|
580417
|
-
case
|
|
580320
|
+
case LogLevel2.Trace:
|
|
580418
580321
|
return "TRACE";
|
|
580419
|
-
case
|
|
580322
|
+
case LogLevel2.Debug:
|
|
580420
580323
|
return "DEBUG";
|
|
580421
|
-
case
|
|
580324
|
+
case LogLevel2.Info:
|
|
580422
580325
|
return "INFO";
|
|
580423
|
-
case
|
|
580326
|
+
case LogLevel2.Warn:
|
|
580424
580327
|
return "WARN";
|
|
580425
|
-
case
|
|
580328
|
+
case LogLevel2.Error:
|
|
580426
580329
|
return "ERROR";
|
|
580427
580330
|
default:
|
|
580428
580331
|
assertNever(logLevel);
|
|
@@ -606147,22 +606050,22 @@ var ErrorCollector2 = class {
|
|
|
606147
606050
|
}
|
|
606148
606051
|
switch (level) {
|
|
606149
606052
|
case APIErrorLevel.ERROR:
|
|
606150
|
-
this.logger.log(
|
|
606053
|
+
this.logger.log(LogLevel2.Debug, error50.message);
|
|
606151
606054
|
if (error50.path && error50.path.length > 0) {
|
|
606152
606055
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606153
606056
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606154
|
-
this.logger.log(
|
|
606057
|
+
this.logger.log(LogLevel2.Debug, ` - at location (${locationInfo})`);
|
|
606155
606058
|
}
|
|
606156
606059
|
break;
|
|
606157
606060
|
case APIErrorLevel.WARNING:
|
|
606158
|
-
this.logger.log(
|
|
606061
|
+
this.logger.log(LogLevel2.Warn, error50.message);
|
|
606159
606062
|
if (error50.path && error50.path.length > 0) {
|
|
606160
606063
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606161
606064
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606162
|
-
this.logger.log(
|
|
606065
|
+
this.logger.log(LogLevel2.Warn, ` - at location (${locationInfo})`);
|
|
606163
606066
|
}
|
|
606164
606067
|
if (error50.resolution) {
|
|
606165
|
-
this.logger.log(
|
|
606068
|
+
this.logger.log(LogLevel2.Warn, ` - resolution: ${error50.resolution}`);
|
|
606166
606069
|
}
|
|
606167
606070
|
break;
|
|
606168
606071
|
}
|
|
@@ -606191,7 +606094,7 @@ var BreadcrumbToLineNumber = class {
|
|
|
606191
606094
|
jsYaml.load(fileContent, { listener: this.map.listen() });
|
|
606192
606095
|
this.initialized = true;
|
|
606193
606096
|
} catch (error50) {
|
|
606194
|
-
this.logger.log(
|
|
606097
|
+
this.logger.log(LogLevel2.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
|
|
606195
606098
|
}
|
|
606196
606099
|
}
|
|
606197
606100
|
/**
|
|
@@ -619460,16 +619363,851 @@ async function runRulesOnOSSWorkspace({ workspace, context: context3, rules }) {
|
|
|
619460
619363
|
return ruleResults.flat();
|
|
619461
619364
|
}
|
|
619462
619365
|
|
|
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
|
+
|
|
619463
620205
|
// ../cli-v2/lib/auth/errors/KeyringUnavailableError.js
|
|
619464
|
-
var KeyringUnavailableError = class
|
|
620206
|
+
var KeyringUnavailableError = class extends Error {
|
|
619465
620207
|
platform;
|
|
619466
620208
|
cause;
|
|
619467
620209
|
constructor(platform3, cause) {
|
|
619468
|
-
super(
|
|
619469
|
-
message: getKeyringErrorMessage(platform3),
|
|
619470
|
-
code: CliError.Code.AuthError
|
|
619471
|
-
});
|
|
619472
|
-
Object.setPrototypeOf(this, _KeyringUnavailableError.prototype);
|
|
620210
|
+
super(getKeyringErrorMessage(platform3));
|
|
619473
620211
|
this.platform = platform3;
|
|
619474
620212
|
this.cause = cause;
|
|
619475
620213
|
}
|
|
@@ -619526,77 +620264,23 @@ If running in a headless environment, use FERN_TOKEN instead:
|
|
|
619526
620264
|
}
|
|
619527
620265
|
|
|
619528
620266
|
// ../cli-v2/lib/errors/SourcedValidationError.js
|
|
619529
|
-
var SourcedValidationError = class
|
|
620267
|
+
var SourcedValidationError = class extends Error {
|
|
619530
620268
|
issues;
|
|
619531
620269
|
constructor(issues) {
|
|
619532
|
-
super(
|
|
619533
|
-
message: issues.map((issue2) => issue2.toString()).join("\n"),
|
|
619534
|
-
code: CliError.Code.ValidationError
|
|
619535
|
-
});
|
|
619536
|
-
Object.setPrototypeOf(this, _SourcedValidationError.prototype);
|
|
620270
|
+
super(issues.map((issue2) => issue2.toString()).join("\n"));
|
|
619537
620271
|
this.issues = issues;
|
|
619538
620272
|
}
|
|
619539
620273
|
};
|
|
619540
620274
|
|
|
619541
620275
|
// ../cli-v2/lib/errors/ValidationError.js
|
|
619542
|
-
var ValidationError = class
|
|
620276
|
+
var ValidationError = class extends Error {
|
|
619543
620277
|
violations;
|
|
619544
620278
|
constructor(violations) {
|
|
619545
|
-
super({
|
|
619546
|
-
message: violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"),
|
|
619547
|
-
code: CliError.Code.ValidationError
|
|
619548
|
-
});
|
|
619549
|
-
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
620279
|
+
super(violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"));
|
|
619550
620280
|
this.violations = violations;
|
|
619551
620281
|
}
|
|
619552
620282
|
};
|
|
619553
620283
|
|
|
619554
|
-
// ../cli-v2/lib/ui/format.js
|
|
619555
|
-
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
619556
|
-
if (text9 == null) {
|
|
619557
|
-
return "";
|
|
619558
|
-
}
|
|
619559
|
-
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
619560
|
-
if (lines.length === 0) {
|
|
619561
|
-
return "";
|
|
619562
|
-
}
|
|
619563
|
-
const baseIndentStr = " ".repeat(baseIndent);
|
|
619564
|
-
const contIndentStr = " ".repeat(continuationIndent);
|
|
619565
|
-
if (icon != null) {
|
|
619566
|
-
const [first3, ...rest] = lines;
|
|
619567
|
-
const firstLine = `
|
|
619568
|
-
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
619569
|
-
const restLines = rest.map((line) => `
|
|
619570
|
-
${contIndentStr}${colorFn(line)}`).join("");
|
|
619571
|
-
return firstLine + restLines;
|
|
619572
|
-
}
|
|
619573
|
-
return lines.map((line) => `
|
|
619574
|
-
${baseIndentStr}${colorFn(line)}`).join("");
|
|
619575
|
-
}
|
|
619576
|
-
var Icons = {
|
|
619577
|
-
error: source_default.red("\u2717"),
|
|
619578
|
-
warning: source_default.yellow("\u26A0"),
|
|
619579
|
-
success: source_default.green("\u2713"),
|
|
619580
|
-
info: source_default.cyan("\u25C6")
|
|
619581
|
-
};
|
|
619582
|
-
var Colors = {
|
|
619583
|
-
error: source_default.red.bind(source_default),
|
|
619584
|
-
warning: source_default.yellow.bind(source_default),
|
|
619585
|
-
success: source_default.green.bind(source_default),
|
|
619586
|
-
info: source_default.cyan.bind(source_default),
|
|
619587
|
-
dim: source_default.dim.bind(source_default)
|
|
619588
|
-
};
|
|
619589
|
-
function formatBytes(bytes) {
|
|
619590
|
-
if (bytes === 0) {
|
|
619591
|
-
return "0 B";
|
|
619592
|
-
}
|
|
619593
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
619594
|
-
const base4 = 1024;
|
|
619595
|
-
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
619596
|
-
const value = bytes / Math.pow(base4, index3);
|
|
619597
|
-
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
619598
|
-
}
|
|
619599
|
-
|
|
619600
620284
|
// ../auth/lib/orgs/checkOrganizationMembership.js
|
|
619601
620285
|
async function checkOrganizationMembership({ organization, token }) {
|
|
619602
620286
|
const venus = createVenusService({ token: token.value });
|
|
@@ -627016,7 +627700,7 @@ var AccessTokenPosthogManager = class {
|
|
|
627016
627700
|
properties: {
|
|
627017
627701
|
...event,
|
|
627018
627702
|
...event.properties,
|
|
627019
|
-
version: "4.68.3
|
|
627703
|
+
version: "4.68.3",
|
|
627020
627704
|
usingAccessToken: true
|
|
627021
627705
|
}
|
|
627022
627706
|
});
|
|
@@ -627070,7 +627754,7 @@ var UserPosthogManager = class {
|
|
|
627070
627754
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
627071
627755
|
event: "CLI",
|
|
627072
627756
|
properties: {
|
|
627073
|
-
version: "4.68.3
|
|
627757
|
+
version: "4.68.3",
|
|
627074
627758
|
...event,
|
|
627075
627759
|
...event.properties,
|
|
627076
627760
|
usingAccessToken: false,
|
|
@@ -630582,7 +631266,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
630582
631266
|
* The caller is responsible for deciding which errors are worth reporting
|
|
630583
631267
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
630584
631268
|
*/
|
|
630585
|
-
captureException(error50
|
|
631269
|
+
captureException(error50) {
|
|
630586
631270
|
if (this.sentry === void 0) {
|
|
630587
631271
|
return;
|
|
630588
631272
|
}
|
|
@@ -630590,7 +631274,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
630590
631274
|
this.sentry.captureException(error50, {
|
|
630591
631275
|
captureContext: {
|
|
630592
631276
|
user: { id: this.distinctId },
|
|
630593
|
-
tags: { ...this.baseTags, ...this.accumulatedTags
|
|
631277
|
+
tags: { ...this.baseTags, ...this.accumulatedTags }
|
|
630594
631278
|
}
|
|
630595
631279
|
});
|
|
630596
631280
|
} catch {
|
|
@@ -631490,7 +632174,6 @@ var Context = class _Context {
|
|
|
631490
632174
|
shutdownCallbacks = [];
|
|
631491
632175
|
isShuttingDown = false;
|
|
631492
632176
|
logFilePathPrinted = false;
|
|
631493
|
-
createdAt = Date.now();
|
|
631494
632177
|
cwd;
|
|
631495
632178
|
logLevel;
|
|
631496
632179
|
info;
|
|
@@ -631508,10 +632191,10 @@ var Context = class _Context {
|
|
|
631508
632191
|
}
|
|
631509
632192
|
constructor({ cwd: cwd2, logLevel, ttyAwareLogger, telemetry }) {
|
|
631510
632193
|
this.cwd = cwd2 ?? AbsoluteFilePath2.of(process.cwd());
|
|
631511
|
-
this.logLevel = logLevel ??
|
|
632194
|
+
this.logLevel = logLevel ?? LogLevel2.Info;
|
|
631512
632195
|
this.info = parseCommandInfo(process.argv);
|
|
631513
|
-
this.stdout =
|
|
631514
|
-
this.stderr =
|
|
632196
|
+
this.stdout = createLogger4((level, ...args) => this.log(level, ...args));
|
|
632197
|
+
this.stderr = createLogger4((level, ...args) => this.logStderr(level, ...args));
|
|
631515
632198
|
this.cache = new Cache({ logger: this.stderr });
|
|
631516
632199
|
this.logs = new LogFileWriter(this.cache.logs.absoluteFilePath);
|
|
631517
632200
|
this.ttyAwareLogger = ttyAwareLogger;
|
|
@@ -631569,7 +632252,7 @@ var Context = class _Context {
|
|
|
631569
632252
|
this.stderr.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
631570
632253
|
this.stderr.info("");
|
|
631571
632254
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
631572
|
-
throw
|
|
632255
|
+
throw CliError.exit();
|
|
631573
632256
|
}
|
|
631574
632257
|
return await this.promptAndLogin();
|
|
631575
632258
|
}
|
|
@@ -631579,7 +632262,7 @@ var Context = class _Context {
|
|
|
631579
632262
|
this.stderr.error(`${Icons.error} Your access token has expired.`);
|
|
631580
632263
|
this.stderr.info("");
|
|
631581
632264
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
631582
|
-
throw
|
|
632265
|
+
throw CliError.exit();
|
|
631583
632266
|
}
|
|
631584
632267
|
return await this.promptAndLogin();
|
|
631585
632268
|
}
|
|
@@ -631595,7 +632278,7 @@ var Context = class _Context {
|
|
|
631595
632278
|
}
|
|
631596
632279
|
]);
|
|
631597
632280
|
if (!confirm) {
|
|
631598
|
-
throw
|
|
632281
|
+
throw CliError.exit();
|
|
631599
632282
|
}
|
|
631600
632283
|
this.stderr.info(`${Icons.info} Opening browser to log in to Fern...`);
|
|
631601
632284
|
this.stderr.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
@@ -631607,12 +632290,12 @@ var Context = class _Context {
|
|
|
631607
632290
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
631608
632291
|
if (payload == null) {
|
|
631609
632292
|
this.stderr.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
631610
|
-
throw
|
|
632293
|
+
throw CliError.exit();
|
|
631611
632294
|
}
|
|
631612
632295
|
const email3 = payload.email;
|
|
631613
632296
|
if (email3 == null) {
|
|
631614
632297
|
this.stderr.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
631615
|
-
throw
|
|
632298
|
+
throw CliError.exit();
|
|
631616
632299
|
}
|
|
631617
632300
|
await this.tokenService.login(email3, accessToken);
|
|
631618
632301
|
this.stderr.info(`${Icons.success} Logged in as ${source_default.bold(email3)}`);
|
|
@@ -631743,7 +632426,7 @@ ${source_default.dim(`Logs written to: ${this.logs.absoluteFilePath}`)}
|
|
|
631743
632426
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
631744
632427
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
631745
632428
|
this.ttyAwareLogger.log(filtered, {
|
|
631746
|
-
includeDebugInfo: this.logLevel ===
|
|
632429
|
+
includeDebugInfo: this.logLevel === LogLevel2.Debug,
|
|
631747
632430
|
stderr
|
|
631748
632431
|
});
|
|
631749
632432
|
}
|
|
@@ -631756,19 +632439,28 @@ var SIGTERM_EXIT_CODE = SIGNAL_EXIT_CODE_BASE + 15;
|
|
|
631756
632439
|
function withContext(handler3) {
|
|
631757
632440
|
return async (args) => {
|
|
631758
632441
|
const context3 = await createContext(args);
|
|
632442
|
+
const startTime = Date.now();
|
|
631759
632443
|
setupSignalHandler(context3);
|
|
631760
632444
|
try {
|
|
631761
632445
|
await handler3(context3, args);
|
|
631762
632446
|
context3.telemetry.sendLifecycleEvent({
|
|
631763
632447
|
command: context3.info.command,
|
|
631764
632448
|
status: "success",
|
|
631765
|
-
durationMs: Date.now() -
|
|
632449
|
+
durationMs: Date.now() - startTime
|
|
631766
632450
|
});
|
|
631767
632451
|
await context3.telemetry.flush();
|
|
631768
632452
|
context3.finish();
|
|
631769
632453
|
await exitGracefully(0);
|
|
631770
632454
|
} catch (error50) {
|
|
631771
|
-
|
|
632455
|
+
if (shouldReportToSentry(error50)) {
|
|
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
|
+
});
|
|
631772
632464
|
await context3.telemetry.flush();
|
|
631773
632465
|
handleError(context3, error50);
|
|
631774
632466
|
context3.finish();
|
|
@@ -631808,7 +632500,7 @@ function handleError(context3, error50) {
|
|
|
631808
632500
|
return;
|
|
631809
632501
|
}
|
|
631810
632502
|
if (error50 instanceof CliError) {
|
|
631811
|
-
if (error50.message
|
|
632503
|
+
if (error50.message.length > 0) {
|
|
631812
632504
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
631813
632505
|
`);
|
|
631814
632506
|
}
|
|
@@ -631817,7 +632509,7 @@ function handleError(context3, error50) {
|
|
|
631817
632509
|
if (error50 instanceof Error) {
|
|
631818
632510
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
631819
632511
|
`);
|
|
631820
|
-
if (error50.stack != null && context3.logLevel ===
|
|
632512
|
+
if (error50.stack != null && context3.logLevel === LogLevel2.Debug) {
|
|
631821
632513
|
process.stderr.write(`${source_default.dim(error50.stack)}
|
|
631822
632514
|
`);
|
|
631823
632515
|
}
|
|
@@ -631826,23 +632518,29 @@ function handleError(context3, error50) {
|
|
|
631826
632518
|
process.stderr.write(`${source_default.red(String(error50))}
|
|
631827
632519
|
`);
|
|
631828
632520
|
}
|
|
631829
|
-
function
|
|
632521
|
+
function shouldReportToSentry(error50) {
|
|
631830
632522
|
if (error50 instanceof TaskAbortSignal) {
|
|
631831
|
-
return;
|
|
632523
|
+
return false;
|
|
631832
632524
|
}
|
|
631833
|
-
|
|
631834
|
-
|
|
631835
|
-
if (shouldReportToSentry(code5)) {
|
|
631836
|
-
context3.telemetry.captureException(capturable, {
|
|
631837
|
-
errorCode: code5
|
|
631838
|
-
});
|
|
632525
|
+
if (error50 instanceof CliError) {
|
|
632526
|
+
return error50.code === "INTERNAL_ERROR";
|
|
631839
632527
|
}
|
|
631840
|
-
|
|
631841
|
-
|
|
631842
|
-
|
|
631843
|
-
|
|
631844
|
-
|
|
631845
|
-
|
|
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";
|
|
632539
|
+
}
|
|
632540
|
+
if (error50 instanceof KeyringUnavailableError) {
|
|
632541
|
+
return "UNAUTHORIZED_ERROR";
|
|
632542
|
+
}
|
|
632543
|
+
return "INTERNAL_ERROR";
|
|
631846
632544
|
}
|
|
631847
632545
|
function setupSignalHandler(context3) {
|
|
631848
632546
|
const onSignal = (exitCode) => {
|
|
@@ -631867,771 +632565,18 @@ function exitGracefully(code5) {
|
|
|
631867
632565
|
function parseLogLevel(level) {
|
|
631868
632566
|
switch (level.toLowerCase()) {
|
|
631869
632567
|
case "debug":
|
|
631870
|
-
return
|
|
632568
|
+
return LogLevel2.Debug;
|
|
631871
632569
|
case "info":
|
|
631872
|
-
return
|
|
632570
|
+
return LogLevel2.Info;
|
|
631873
632571
|
case "warn":
|
|
631874
|
-
return
|
|
632572
|
+
return LogLevel2.Warn;
|
|
631875
632573
|
case "error":
|
|
631876
|
-
return
|
|
632574
|
+
return LogLevel2.Error;
|
|
631877
632575
|
default:
|
|
631878
|
-
return
|
|
632576
|
+
return LogLevel2.Info;
|
|
631879
632577
|
}
|
|
631880
632578
|
}
|
|
631881
632579
|
|
|
631882
|
-
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
631883
|
-
var TaskContextLogger = class {
|
|
631884
|
-
context;
|
|
631885
|
-
task;
|
|
631886
|
-
logLevel;
|
|
631887
|
-
enabled = true;
|
|
631888
|
-
collectedErrors = [];
|
|
631889
|
-
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631890
|
-
this.context = context3;
|
|
631891
|
-
this.task = task;
|
|
631892
|
-
this.logLevel = logLevel;
|
|
631893
|
-
}
|
|
631894
|
-
disable() {
|
|
631895
|
-
this.enabled = false;
|
|
631896
|
-
}
|
|
631897
|
-
enable() {
|
|
631898
|
-
this.enabled = true;
|
|
631899
|
-
}
|
|
631900
|
-
trace(..._args) {
|
|
631901
|
-
}
|
|
631902
|
-
debug(...args) {
|
|
631903
|
-
const message = args.join(" ");
|
|
631904
|
-
this.writeLog({ level: LogLevel.Debug, message });
|
|
631905
|
-
if (this.shouldLogToTask(LogLevel.Debug)) {
|
|
631906
|
-
if (this.task.logs == null) {
|
|
631907
|
-
this.task.logs = [];
|
|
631908
|
-
}
|
|
631909
|
-
this.task.logs.push({ level: "debug", message });
|
|
631910
|
-
}
|
|
631911
|
-
}
|
|
631912
|
-
info(...args) {
|
|
631913
|
-
const message = args.join(" ");
|
|
631914
|
-
this.writeLog({ level: LogLevel.Info, message });
|
|
631915
|
-
if (this.shouldLogToTask(LogLevel.Info)) {
|
|
631916
|
-
if (this.task.logs == null) {
|
|
631917
|
-
this.task.logs = [];
|
|
631918
|
-
}
|
|
631919
|
-
this.task.logs.push({ level: "debug", message });
|
|
631920
|
-
}
|
|
631921
|
-
}
|
|
631922
|
-
warn(...args) {
|
|
631923
|
-
const message = args.join(" ");
|
|
631924
|
-
this.writeLog({ level: LogLevel.Warn, message });
|
|
631925
|
-
if (this.shouldLogToTask(LogLevel.Warn)) {
|
|
631926
|
-
if (this.task.logs == null) {
|
|
631927
|
-
this.task.logs = [];
|
|
631928
|
-
}
|
|
631929
|
-
this.task.logs.push({ level: "warn", message });
|
|
631930
|
-
}
|
|
631931
|
-
}
|
|
631932
|
-
error(...args) {
|
|
631933
|
-
const message = args.join(" ");
|
|
631934
|
-
this.writeLog({ level: LogLevel.Error, message });
|
|
631935
|
-
if (this.shouldLogToTask(LogLevel.Error)) {
|
|
631936
|
-
this.collectedErrors.push(message);
|
|
631937
|
-
if (this.task.logs == null) {
|
|
631938
|
-
this.task.logs = [];
|
|
631939
|
-
}
|
|
631940
|
-
this.task.logs.push({ level: "error", message });
|
|
631941
|
-
}
|
|
631942
|
-
}
|
|
631943
|
-
log(level, ...args) {
|
|
631944
|
-
switch (level) {
|
|
631945
|
-
case LogLevel.Debug:
|
|
631946
|
-
this.debug(...args);
|
|
631947
|
-
break;
|
|
631948
|
-
case LogLevel.Info:
|
|
631949
|
-
this.info(...args);
|
|
631950
|
-
break;
|
|
631951
|
-
case LogLevel.Warn:
|
|
631952
|
-
this.warn(...args);
|
|
631953
|
-
break;
|
|
631954
|
-
case LogLevel.Error:
|
|
631955
|
-
this.error(...args);
|
|
631956
|
-
break;
|
|
631957
|
-
}
|
|
631958
|
-
}
|
|
631959
|
-
/**
|
|
631960
|
-
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
631961
|
-
* also write directly to stderr so logs are visible in CI runner output.
|
|
631962
|
-
*/
|
|
631963
|
-
writeLog({ level, message }) {
|
|
631964
|
-
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
631965
|
-
if (this.context.isTTY) {
|
|
631966
|
-
return;
|
|
631967
|
-
}
|
|
631968
|
-
if (!this.enabled) {
|
|
631969
|
-
return;
|
|
631970
|
-
}
|
|
631971
|
-
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
631972
|
-
switch (level) {
|
|
631973
|
-
case LogLevel.Warn:
|
|
631974
|
-
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
631975
|
-
`);
|
|
631976
|
-
break;
|
|
631977
|
-
case LogLevel.Error:
|
|
631978
|
-
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
631979
|
-
`);
|
|
631980
|
-
break;
|
|
631981
|
-
default:
|
|
631982
|
-
process.stderr.write(`${prefix2}: ${message}
|
|
631983
|
-
`);
|
|
631984
|
-
break;
|
|
631985
|
-
}
|
|
631986
|
-
}
|
|
631987
|
-
/**
|
|
631988
|
-
* Check if a message at the given level should be logged to the task's UI.
|
|
631989
|
-
*/
|
|
631990
|
-
shouldLogToTask(level) {
|
|
631991
|
-
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
631992
|
-
}
|
|
631993
|
-
};
|
|
631994
|
-
|
|
631995
|
-
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
631996
|
-
var TaskContextAdapter = class {
|
|
631997
|
-
result = TaskResult.Success;
|
|
631998
|
-
context;
|
|
631999
|
-
logger;
|
|
632000
|
-
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
632001
|
-
this.context = context3;
|
|
632002
|
-
if (task != null) {
|
|
632003
|
-
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
632004
|
-
} else {
|
|
632005
|
-
this.logger = createLogger((level, ...args) => {
|
|
632006
|
-
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
632007
|
-
context3.stderr.log(level, ...args);
|
|
632008
|
-
}
|
|
632009
|
-
});
|
|
632010
|
-
}
|
|
632011
|
-
}
|
|
632012
|
-
async takeOverTerminal(run) {
|
|
632013
|
-
await run();
|
|
632014
|
-
}
|
|
632015
|
-
failAndThrow(message, error50, options2) {
|
|
632016
|
-
this.failWithoutThrowing(message, error50, options2);
|
|
632017
|
-
throw new TaskAbortSignal();
|
|
632018
|
-
}
|
|
632019
|
-
failWithoutThrowing(message, error50, options2) {
|
|
632020
|
-
this.result = TaskResult.Failure;
|
|
632021
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
632022
|
-
return;
|
|
632023
|
-
}
|
|
632024
|
-
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
632025
|
-
if (fullMessage != null) {
|
|
632026
|
-
this.logger.error(fullMessage);
|
|
632027
|
-
}
|
|
632028
|
-
reportError(this.context, error50, { ...options2, message });
|
|
632029
|
-
}
|
|
632030
|
-
captureException(error50, code5) {
|
|
632031
|
-
const errorCode = resolveErrorCode(error50, code5);
|
|
632032
|
-
this.context.telemetry.captureException(error50, { errorCode });
|
|
632033
|
-
}
|
|
632034
|
-
getFullErrorMessage(message, error50) {
|
|
632035
|
-
const errorDetails = this.formatError(error50);
|
|
632036
|
-
if (message != null && errorDetails != null) {
|
|
632037
|
-
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
632038
|
-
}
|
|
632039
|
-
return message ?? errorDetails;
|
|
632040
|
-
}
|
|
632041
|
-
getResult() {
|
|
632042
|
-
return this.result;
|
|
632043
|
-
}
|
|
632044
|
-
addInteractiveTask(_params) {
|
|
632045
|
-
const subtask = {
|
|
632046
|
-
logger: this.logger,
|
|
632047
|
-
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
632048
|
-
failAndThrow: this.failAndThrow.bind(this),
|
|
632049
|
-
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
632050
|
-
captureException: this.captureException.bind(this),
|
|
632051
|
-
getResult: () => this.result,
|
|
632052
|
-
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
632053
|
-
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
632054
|
-
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
632055
|
-
setSubtitle: (_subtitle) => {
|
|
632056
|
-
},
|
|
632057
|
-
start: () => {
|
|
632058
|
-
return subtask;
|
|
632059
|
-
},
|
|
632060
|
-
isStarted: () => true,
|
|
632061
|
-
finish: () => {
|
|
632062
|
-
},
|
|
632063
|
-
isFinished: () => true
|
|
632064
|
-
};
|
|
632065
|
-
return subtask;
|
|
632066
|
-
}
|
|
632067
|
-
async runInteractiveTask(params2, run) {
|
|
632068
|
-
const subtask = this.addInteractiveTask(params2).start();
|
|
632069
|
-
try {
|
|
632070
|
-
await run(subtask);
|
|
632071
|
-
return true;
|
|
632072
|
-
} catch {
|
|
632073
|
-
return false;
|
|
632074
|
-
}
|
|
632075
|
-
}
|
|
632076
|
-
instrumentPostHogEvent(_event) {
|
|
632077
|
-
}
|
|
632078
|
-
formatError(error50) {
|
|
632079
|
-
if (error50 == null) {
|
|
632080
|
-
return void 0;
|
|
632081
|
-
}
|
|
632082
|
-
if (error50 instanceof Error) {
|
|
632083
|
-
return error50.message;
|
|
632084
|
-
}
|
|
632085
|
-
if (typeof error50 === "string") {
|
|
632086
|
-
return error50;
|
|
632087
|
-
}
|
|
632088
|
-
if (typeof error50 === "object") {
|
|
632089
|
-
const message = this.extractErrorMessage(error50);
|
|
632090
|
-
if (message != null) {
|
|
632091
|
-
return message;
|
|
632092
|
-
}
|
|
632093
|
-
}
|
|
632094
|
-
try {
|
|
632095
|
-
return JSON.stringify(error50);
|
|
632096
|
-
} catch {
|
|
632097
|
-
return String(error50);
|
|
632098
|
-
}
|
|
632099
|
-
}
|
|
632100
|
-
/**
|
|
632101
|
-
* Attempts to extract a human-readable message from a structured error object.
|
|
632102
|
-
*
|
|
632103
|
-
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
632104
|
-
* { content: { body: { message: "..." } } }
|
|
632105
|
-
* { body: { message: "..." } }
|
|
632106
|
-
* { message: "..." }
|
|
632107
|
-
*/
|
|
632108
|
-
extractErrorMessage(error50) {
|
|
632109
|
-
const record21 = error50;
|
|
632110
|
-
if (typeof record21.message === "string") {
|
|
632111
|
-
return record21.message;
|
|
632112
|
-
}
|
|
632113
|
-
if (record21.body != null && typeof record21.body === "object") {
|
|
632114
|
-
const body = record21.body;
|
|
632115
|
-
if (typeof body.message === "string") {
|
|
632116
|
-
return body.message;
|
|
632117
|
-
}
|
|
632118
|
-
}
|
|
632119
|
-
if (record21.content != null && typeof record21.content === "object") {
|
|
632120
|
-
return this.extractErrorMessage(record21.content);
|
|
632121
|
-
}
|
|
632122
|
-
return void 0;
|
|
632123
|
-
}
|
|
632124
|
-
};
|
|
632125
|
-
|
|
632126
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632127
|
-
init_lib6();
|
|
632128
|
-
|
|
632129
|
-
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
632130
|
-
function isOpenRpcSpec(spec) {
|
|
632131
|
-
return "openrpc" in spec;
|
|
632132
|
-
}
|
|
632133
|
-
|
|
632134
|
-
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
632135
|
-
function isProtobufSpec(spec) {
|
|
632136
|
-
return "proto" in spec;
|
|
632137
|
-
}
|
|
632138
|
-
|
|
632139
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632140
|
-
var LegacyApiSpecAdapter = class {
|
|
632141
|
-
context;
|
|
632142
|
-
constructor(config5) {
|
|
632143
|
-
this.context = config5.context;
|
|
632144
|
-
}
|
|
632145
|
-
adapt(spec) {
|
|
632146
|
-
if (isOpenApiSpec(spec)) {
|
|
632147
|
-
return this.adaptOpenApiSpec(spec);
|
|
632148
|
-
}
|
|
632149
|
-
if (isAsyncApiSpec(spec)) {
|
|
632150
|
-
return this.adaptAsyncApiSpec(spec);
|
|
632151
|
-
}
|
|
632152
|
-
if (isProtobufSpec(spec)) {
|
|
632153
|
-
return this.adaptProtobufSpec(spec);
|
|
632154
|
-
}
|
|
632155
|
-
if (isOpenRpcSpec(spec)) {
|
|
632156
|
-
return this.adaptOpenRpcSpec(spec);
|
|
632157
|
-
}
|
|
632158
|
-
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
632159
|
-
}
|
|
632160
|
-
convertAll(specs) {
|
|
632161
|
-
return specs.map((spec) => this.adapt(spec));
|
|
632162
|
-
}
|
|
632163
|
-
adaptOpenApiSpec(spec) {
|
|
632164
|
-
return {
|
|
632165
|
-
type: "openapi",
|
|
632166
|
-
absoluteFilepath: spec.openapi,
|
|
632167
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
632168
|
-
absoluteFilepathToOverlays: spec.overlays,
|
|
632169
|
-
namespace: spec.namespace,
|
|
632170
|
-
source: {
|
|
632171
|
-
type: "openapi",
|
|
632172
|
-
file: spec.openapi
|
|
632173
|
-
},
|
|
632174
|
-
settings: this.adaptOpenApiSettings(spec.settings)
|
|
632175
|
-
};
|
|
632176
|
-
}
|
|
632177
|
-
adaptAsyncApiSpec(spec) {
|
|
632178
|
-
return {
|
|
632179
|
-
type: "openapi",
|
|
632180
|
-
absoluteFilepath: spec.asyncapi,
|
|
632181
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
632182
|
-
absoluteFilepathToOverlays: void 0,
|
|
632183
|
-
namespace: spec.namespace,
|
|
632184
|
-
source: {
|
|
632185
|
-
type: "asyncapi",
|
|
632186
|
-
file: spec.asyncapi
|
|
632187
|
-
},
|
|
632188
|
-
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
632189
|
-
};
|
|
632190
|
-
}
|
|
632191
|
-
adaptProtobufSpec(spec) {
|
|
632192
|
-
const proto3 = spec.proto;
|
|
632193
|
-
return {
|
|
632194
|
-
type: "protobuf",
|
|
632195
|
-
absoluteFilepathToProtobufRoot: proto3.root,
|
|
632196
|
-
absoluteFilepathToProtobufTarget: proto3.target,
|
|
632197
|
-
absoluteFilepathToOverrides: proto3.overrides,
|
|
632198
|
-
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
632199
|
-
generateLocally: proto3.localGeneration ?? false,
|
|
632200
|
-
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
632201
|
-
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
632202
|
-
settings: void 0
|
|
632203
|
-
};
|
|
632204
|
-
}
|
|
632205
|
-
adaptOpenRpcSpec(spec) {
|
|
632206
|
-
return {
|
|
632207
|
-
type: "openrpc",
|
|
632208
|
-
absoluteFilepath: spec.openrpc,
|
|
632209
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
632210
|
-
namespace: void 0
|
|
632211
|
-
};
|
|
632212
|
-
}
|
|
632213
|
-
adaptOpenApiSettings(settings) {
|
|
632214
|
-
if (settings == null) {
|
|
632215
|
-
return void 0;
|
|
632216
|
-
}
|
|
632217
|
-
const result = {
|
|
632218
|
-
// Base API settings
|
|
632219
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632220
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632221
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632222
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
632223
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632224
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632225
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632226
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632227
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632228
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632229
|
-
// OpenAPI-specific settings
|
|
632230
|
-
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
632231
|
-
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
632232
|
-
inlinePathParameters: settings.inlinePathParameters,
|
|
632233
|
-
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
632234
|
-
objectQueryParameters: settings.objectQueryParameters,
|
|
632235
|
-
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
632236
|
-
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
632237
|
-
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
632238
|
-
filter: settings.filter,
|
|
632239
|
-
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
632240
|
-
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
632241
|
-
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
632242
|
-
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
632243
|
-
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
632244
|
-
resolveAliases: settings.resolveAliases,
|
|
632245
|
-
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
632246
|
-
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
632247
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
632248
|
-
};
|
|
632249
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632250
|
-
return hasSettings ? result : void 0;
|
|
632251
|
-
}
|
|
632252
|
-
adaptAsyncApiSettings(settings) {
|
|
632253
|
-
if (settings == null) {
|
|
632254
|
-
return void 0;
|
|
632255
|
-
}
|
|
632256
|
-
const result = {
|
|
632257
|
-
// Base API settings (shared)
|
|
632258
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632259
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632260
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632261
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
632262
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632263
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632264
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632265
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632266
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632267
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632268
|
-
// AsyncAPI-specific settings
|
|
632269
|
-
asyncApiNaming: settings.messageNaming,
|
|
632270
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
632271
|
-
};
|
|
632272
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632273
|
-
return hasSettings ? result : void 0;
|
|
632274
|
-
}
|
|
632275
|
-
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
632276
|
-
if (value == null) {
|
|
632277
|
-
return void 0;
|
|
632278
|
-
}
|
|
632279
|
-
switch (value) {
|
|
632280
|
-
case "always":
|
|
632281
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
632282
|
-
case "never":
|
|
632283
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
632284
|
-
default:
|
|
632285
|
-
return void 0;
|
|
632286
|
-
}
|
|
632287
|
-
}
|
|
632288
|
-
adaptPathParameterOrder(value) {
|
|
632289
|
-
if (value == null) {
|
|
632290
|
-
return void 0;
|
|
632291
|
-
}
|
|
632292
|
-
switch (value) {
|
|
632293
|
-
case "urlOrder":
|
|
632294
|
-
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
632295
|
-
case "specOrder":
|
|
632296
|
-
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
632297
|
-
default:
|
|
632298
|
-
return void 0;
|
|
632299
|
-
}
|
|
632300
|
-
}
|
|
632301
|
-
adaptDefaultIntegerFormat(value) {
|
|
632302
|
-
if (value == null) {
|
|
632303
|
-
return void 0;
|
|
632304
|
-
}
|
|
632305
|
-
switch (value) {
|
|
632306
|
-
case "int32":
|
|
632307
|
-
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
632308
|
-
case "int64":
|
|
632309
|
-
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
632310
|
-
case "uint32":
|
|
632311
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
632312
|
-
case "uint64":
|
|
632313
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
632314
|
-
default:
|
|
632315
|
-
return void 0;
|
|
632316
|
-
}
|
|
632317
|
-
}
|
|
632318
|
-
adaptExampleGeneration(value) {
|
|
632319
|
-
if (value == null) {
|
|
632320
|
-
return void 0;
|
|
632321
|
-
}
|
|
632322
|
-
const result = {};
|
|
632323
|
-
if (value.request != null) {
|
|
632324
|
-
result.request = { "max-depth": value.request.maxDepth };
|
|
632325
|
-
}
|
|
632326
|
-
if (value.response != null) {
|
|
632327
|
-
result.response = { "max-depth": value.response.maxDepth };
|
|
632328
|
-
}
|
|
632329
|
-
return result;
|
|
632330
|
-
}
|
|
632331
|
-
};
|
|
632332
|
-
|
|
632333
|
-
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
632334
|
-
function isConjureSpec(spec) {
|
|
632335
|
-
return "conjure" in spec;
|
|
632336
|
-
}
|
|
632337
|
-
|
|
632338
|
-
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
632339
|
-
var ApiDefinitionValidator = class {
|
|
632340
|
-
context;
|
|
632341
|
-
taskContext;
|
|
632342
|
-
cliVersion;
|
|
632343
|
-
constructor(config5) {
|
|
632344
|
-
this.context = config5.context;
|
|
632345
|
-
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
632346
|
-
this.cliVersion = config5.cliVersion;
|
|
632347
|
-
}
|
|
632348
|
-
/**
|
|
632349
|
-
* Validate an ApiDefinition.
|
|
632350
|
-
*
|
|
632351
|
-
* Runs both Fern definition validation and OSS workspace validation
|
|
632352
|
-
* to ensure the API definition is valid before generation.
|
|
632353
|
-
*/
|
|
632354
|
-
async validate(definition3) {
|
|
632355
|
-
const startTime = performance.now();
|
|
632356
|
-
const violations = [];
|
|
632357
|
-
const fernSpec = definition3.specs.find(isFernSpec);
|
|
632358
|
-
if (fernSpec != null) {
|
|
632359
|
-
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
632360
|
-
violations.push(...fernViolations);
|
|
632361
|
-
return {
|
|
632362
|
-
violations,
|
|
632363
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632364
|
-
workspaceRoot: fernSpec.fern,
|
|
632365
|
-
elapsedMillis: performance.now() - startTime
|
|
632366
|
-
};
|
|
632367
|
-
}
|
|
632368
|
-
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
632369
|
-
if (conjureSpec != null) {
|
|
632370
|
-
return {
|
|
632371
|
-
violations: [],
|
|
632372
|
-
hasErrors: false,
|
|
632373
|
-
workspaceRoot: this.context.cwd,
|
|
632374
|
-
elapsedMillis: performance.now() - startTime
|
|
632375
|
-
};
|
|
632376
|
-
}
|
|
632377
|
-
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
632378
|
-
violations.push(...ossViolations);
|
|
632379
|
-
return {
|
|
632380
|
-
violations,
|
|
632381
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632382
|
-
workspaceRoot: this.context.cwd,
|
|
632383
|
-
elapsedMillis: performance.now() - startTime
|
|
632384
|
-
};
|
|
632385
|
-
}
|
|
632386
|
-
async validateFernSpec(spec) {
|
|
632387
|
-
const violations = [];
|
|
632388
|
-
const lazyWorkspace = new LazyFernWorkspace({
|
|
632389
|
-
absoluteFilePath: dirname6(spec.fern),
|
|
632390
|
-
context: this.taskContext,
|
|
632391
|
-
cliVersion: this.cliVersion,
|
|
632392
|
-
generatorsConfiguration: void 0,
|
|
632393
|
-
workspaceName: void 0,
|
|
632394
|
-
changelog: void 0
|
|
632395
|
-
});
|
|
632396
|
-
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632397
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632398
|
-
violations.push(...fernViolations);
|
|
632399
|
-
return violations;
|
|
632400
|
-
}
|
|
632401
|
-
async validateOssSpecs(specs) {
|
|
632402
|
-
const violations = [];
|
|
632403
|
-
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
632404
|
-
if (ossSpecs.length === 0) {
|
|
632405
|
-
return violations;
|
|
632406
|
-
}
|
|
632407
|
-
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
632408
|
-
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
632409
|
-
const filteredSpecs = v1Specs.filter((spec) => {
|
|
632410
|
-
if (spec.type === "openrpc") {
|
|
632411
|
-
return false;
|
|
632412
|
-
}
|
|
632413
|
-
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
632414
|
-
return false;
|
|
632415
|
-
}
|
|
632416
|
-
return true;
|
|
632417
|
-
});
|
|
632418
|
-
const allSpecs = v1Specs.filter((spec) => {
|
|
632419
|
-
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
632420
|
-
return false;
|
|
632421
|
-
}
|
|
632422
|
-
return true;
|
|
632423
|
-
});
|
|
632424
|
-
const ossWorkspace = new OSSWorkspace({
|
|
632425
|
-
specs: filteredSpecs,
|
|
632426
|
-
allSpecs,
|
|
632427
|
-
absoluteFilePath: this.context.cwd,
|
|
632428
|
-
cliVersion: this.cliVersion,
|
|
632429
|
-
changelog: void 0,
|
|
632430
|
-
generatorsConfiguration: void 0,
|
|
632431
|
-
workspaceName: void 0
|
|
632432
|
-
});
|
|
632433
|
-
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632434
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632435
|
-
violations.push(...fernViolations);
|
|
632436
|
-
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
632437
|
-
violations.push(...ossViolations);
|
|
632438
|
-
return violations;
|
|
632439
|
-
}
|
|
632440
|
-
};
|
|
632441
|
-
|
|
632442
|
-
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
632443
|
-
var ApiChecker = class {
|
|
632444
|
-
context;
|
|
632445
|
-
cliVersion;
|
|
632446
|
-
task;
|
|
632447
|
-
constructor(config5) {
|
|
632448
|
-
this.context = config5.context;
|
|
632449
|
-
this.cliVersion = config5.cliVersion;
|
|
632450
|
-
this.task = config5.task;
|
|
632451
|
-
}
|
|
632452
|
-
/**
|
|
632453
|
-
* Check APIs in the workspace and display results.
|
|
632454
|
-
*
|
|
632455
|
-
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
632456
|
-
* only show errors but still report warning count in summary.
|
|
632457
|
-
*/
|
|
632458
|
-
async check({ workspace, apiNames, strict = false }) {
|
|
632459
|
-
const startTime = performance.now();
|
|
632460
|
-
const validApis = /* @__PURE__ */ new Set();
|
|
632461
|
-
const invalidApis = /* @__PURE__ */ new Set();
|
|
632462
|
-
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
632463
|
-
if (apisToCheck.length === 0) {
|
|
632464
|
-
return {
|
|
632465
|
-
validApis,
|
|
632466
|
-
invalidApis,
|
|
632467
|
-
violations: [],
|
|
632468
|
-
errorCount: 0,
|
|
632469
|
-
warningCount: 0,
|
|
632470
|
-
elapsedMillis: performance.now() - startTime
|
|
632471
|
-
};
|
|
632472
|
-
}
|
|
632473
|
-
const validator = new ApiDefinitionValidator({
|
|
632474
|
-
context: this.context,
|
|
632475
|
-
cliVersion: this.cliVersion,
|
|
632476
|
-
task: this.task
|
|
632477
|
-
});
|
|
632478
|
-
const allViolations = [];
|
|
632479
|
-
for (const apiName of apisToCheck) {
|
|
632480
|
-
const apiDefinition = workspace.apis[apiName];
|
|
632481
|
-
if (apiDefinition == null) {
|
|
632482
|
-
invalidApis.add(apiName);
|
|
632483
|
-
continue;
|
|
632484
|
-
}
|
|
632485
|
-
const result = await validator.validate(apiDefinition);
|
|
632486
|
-
if (result.hasErrors) {
|
|
632487
|
-
invalidApis.add(apiName);
|
|
632488
|
-
} else {
|
|
632489
|
-
validApis.add(apiName);
|
|
632490
|
-
}
|
|
632491
|
-
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
632492
|
-
const resolvedViolations = this.resolveViolationPaths({
|
|
632493
|
-
workspaceRoot: result.workspaceRoot,
|
|
632494
|
-
apiName,
|
|
632495
|
-
apiSpecType,
|
|
632496
|
-
apiDefinition,
|
|
632497
|
-
violations: result.violations
|
|
632498
|
-
});
|
|
632499
|
-
allViolations.push(...resolvedViolations);
|
|
632500
|
-
}
|
|
632501
|
-
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
632502
|
-
return {
|
|
632503
|
-
...this.countViolations(dedupedViolations),
|
|
632504
|
-
validApis,
|
|
632505
|
-
invalidApis,
|
|
632506
|
-
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632507
|
-
elapsedMillis: performance.now() - startTime
|
|
632508
|
-
};
|
|
632509
|
-
}
|
|
632510
|
-
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
632511
|
-
return violations.map((violation) => {
|
|
632512
|
-
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
632513
|
-
return {
|
|
632514
|
-
...violation,
|
|
632515
|
-
message,
|
|
632516
|
-
displayRelativeFilepath: this.resolveDisplayPath({
|
|
632517
|
-
workspaceRoot,
|
|
632518
|
-
apiDefinition,
|
|
632519
|
-
apiSpecType,
|
|
632520
|
-
violation
|
|
632521
|
-
}),
|
|
632522
|
-
apiSpecType,
|
|
632523
|
-
apiName,
|
|
632524
|
-
// We don't actually surface valuable line/column information yet, but
|
|
632525
|
-
// this at least points to the correct file.
|
|
632526
|
-
line: 1,
|
|
632527
|
-
column: 1
|
|
632528
|
-
};
|
|
632529
|
-
});
|
|
632530
|
-
}
|
|
632531
|
-
/**
|
|
632532
|
-
* Format a violation message for non-Fern (OSS) specs.
|
|
632533
|
-
*
|
|
632534
|
-
* Prepends a human-readable node path so users can locate the endpoint,
|
|
632535
|
-
* then strips synthetic file paths from the body of the message.
|
|
632536
|
-
*/
|
|
632537
|
-
formatOssMessage(violation) {
|
|
632538
|
-
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
632539
|
-
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
632540
|
-
if (nodePathPrefix.length === 0) {
|
|
632541
|
-
return strippedMessage;
|
|
632542
|
-
}
|
|
632543
|
-
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
632544
|
-
}
|
|
632545
|
-
/**
|
|
632546
|
-
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
632547
|
-
*
|
|
632548
|
-
* Skips the leading "service" segment since it's implicit.
|
|
632549
|
-
*/
|
|
632550
|
-
formatNodePath(nodePath) {
|
|
632551
|
-
const parts = [];
|
|
632552
|
-
for (const item of nodePath) {
|
|
632553
|
-
if (typeof item === "string") {
|
|
632554
|
-
parts.push(item);
|
|
632555
|
-
} else {
|
|
632556
|
-
parts.push(item.key);
|
|
632557
|
-
}
|
|
632558
|
-
}
|
|
632559
|
-
if (parts[0] === "service") {
|
|
632560
|
-
parts.shift();
|
|
632561
|
-
}
|
|
632562
|
-
return parts.join(" -> ");
|
|
632563
|
-
}
|
|
632564
|
-
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
632565
|
-
if (apiSpecType === "fern") {
|
|
632566
|
-
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
632567
|
-
return relativize(this.context.cwd, absolutePath);
|
|
632568
|
-
}
|
|
632569
|
-
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
632570
|
-
}
|
|
632571
|
-
resolveOssDisplayPath(apiDefinition, violation) {
|
|
632572
|
-
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
632573
|
-
if (ossSpecs.length === 0) {
|
|
632574
|
-
return violation.relativeFilepath;
|
|
632575
|
-
}
|
|
632576
|
-
if (ossSpecs.length > 1) {
|
|
632577
|
-
for (const spec of ossSpecs) {
|
|
632578
|
-
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
632579
|
-
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
632580
|
-
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
632581
|
-
return relativize(this.context.cwd, filePath2);
|
|
632582
|
-
}
|
|
632583
|
-
}
|
|
632584
|
-
}
|
|
632585
|
-
const firstSpec = ossSpecs[0];
|
|
632586
|
-
if (firstSpec == null) {
|
|
632587
|
-
return violation.relativeFilepath;
|
|
632588
|
-
}
|
|
632589
|
-
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
632590
|
-
return relativize(this.context.cwd, filePath);
|
|
632591
|
-
}
|
|
632592
|
-
deduplicateViolations(violations) {
|
|
632593
|
-
const seen = /* @__PURE__ */ new Set();
|
|
632594
|
-
return violations.filter((v23) => {
|
|
632595
|
-
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
632596
|
-
if (seen.has(key2)) {
|
|
632597
|
-
return false;
|
|
632598
|
-
}
|
|
632599
|
-
seen.add(key2);
|
|
632600
|
-
return true;
|
|
632601
|
-
});
|
|
632602
|
-
}
|
|
632603
|
-
/**
|
|
632604
|
-
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
632605
|
-
*
|
|
632606
|
-
* The validator produces messages like:
|
|
632607
|
-
* "- pet.yml -> getPetById /pet/{petId}"
|
|
632608
|
-
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
632609
|
-
* so we strip them to produce:
|
|
632610
|
-
* "- getPetById /pet/{petId}"
|
|
632611
|
-
*/
|
|
632612
|
-
stripSyntheticFilePaths(message) {
|
|
632613
|
-
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
632614
|
-
}
|
|
632615
|
-
countViolations(violations) {
|
|
632616
|
-
let errorCount = 0;
|
|
632617
|
-
let warningCount = 0;
|
|
632618
|
-
for (const violation of violations) {
|
|
632619
|
-
switch (violation.severity) {
|
|
632620
|
-
case "fatal":
|
|
632621
|
-
case "error":
|
|
632622
|
-
errorCount++;
|
|
632623
|
-
break;
|
|
632624
|
-
case "warning":
|
|
632625
|
-
warningCount++;
|
|
632626
|
-
break;
|
|
632627
|
-
default:
|
|
632628
|
-
assertNever(violation.severity);
|
|
632629
|
-
}
|
|
632630
|
-
}
|
|
632631
|
-
return { errorCount, warningCount };
|
|
632632
|
-
}
|
|
632633
|
-
};
|
|
632634
|
-
|
|
632635
632580
|
// ../cli-v2/lib/commands/_internal/command.js
|
|
632636
632581
|
function command2(cli, name2, description, handler3, builder) {
|
|
632637
632582
|
cli.command(name2, description, (yargs) => {
|
|
@@ -632675,8 +632620,7 @@ var CheckCommand = class {
|
|
|
632675
632620
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
632676
632621
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
632677
632622
|
throw new CliError({
|
|
632678
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
632679
|
-
code: CliError.Code.ConfigError
|
|
632623
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`
|
|
632680
632624
|
});
|
|
632681
632625
|
}
|
|
632682
632626
|
const checker = new ApiChecker({ context: context3, cliVersion: workspace.cliVersion });
|
|
@@ -632690,7 +632634,7 @@ var CheckCommand = class {
|
|
|
632690
632634
|
const response = this.buildJsonResponse({ apiCheckResult: result, hasErrors });
|
|
632691
632635
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
632692
632636
|
if (hasErrors) {
|
|
632693
|
-
throw CliError.
|
|
632637
|
+
throw CliError.exit();
|
|
632694
632638
|
}
|
|
632695
632639
|
return;
|
|
632696
632640
|
}
|
|
@@ -632702,7 +632646,7 @@ var CheckCommand = class {
|
|
|
632702
632646
|
}
|
|
632703
632647
|
}
|
|
632704
632648
|
if (hasErrors) {
|
|
632705
|
-
throw CliError.
|
|
632649
|
+
throw CliError.exit();
|
|
632706
632650
|
}
|
|
632707
632651
|
if (result.warningCount > 0) {
|
|
632708
632652
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -759377,8 +759321,7 @@ var CompileCommand = class {
|
|
|
759377
759321
|
if (definition3 == null) {
|
|
759378
759322
|
const available2 = apiNames.join(", ");
|
|
759379
759323
|
throw new CliError({
|
|
759380
|
-
message: `API '${args.api}' not found. Available APIs: ${available2}
|
|
759381
|
-
code: CliError.Code.ConfigError
|
|
759324
|
+
message: `API '${args.api}' not found. Available APIs: ${available2}`
|
|
759382
759325
|
});
|
|
759383
759326
|
}
|
|
759384
759327
|
return { apiName: args.api, definition: definition3 };
|
|
@@ -759387,23 +759330,20 @@ var CompileCommand = class {
|
|
|
759387
759330
|
const apiName = apiNames[0];
|
|
759388
759331
|
if (apiName == null) {
|
|
759389
759332
|
throw new CliError({
|
|
759390
|
-
message: "Internal error; no APIs found in workspace"
|
|
759391
|
-
code: CliError.Code.InternalError
|
|
759333
|
+
message: "Internal error; no APIs found in workspace"
|
|
759392
759334
|
});
|
|
759393
759335
|
}
|
|
759394
759336
|
const definition3 = workspace.apis[apiName];
|
|
759395
759337
|
if (definition3 == null) {
|
|
759396
759338
|
throw new CliError({
|
|
759397
|
-
message: `Internal error; API '${apiName}' not found in workspace
|
|
759398
|
-
code: CliError.Code.InternalError
|
|
759339
|
+
message: `Internal error; API '${apiName}' not found in workspace`
|
|
759399
759340
|
});
|
|
759400
759341
|
}
|
|
759401
759342
|
return { apiName, definition: definition3 };
|
|
759402
759343
|
}
|
|
759403
759344
|
const available = apiNames.join(", ");
|
|
759404
759345
|
throw new CliError({
|
|
759405
|
-
message: `Multiple APIs found: ${available}. Use --api to select one
|
|
759406
|
-
code: CliError.Code.ConfigError
|
|
759346
|
+
message: `Multiple APIs found: ${available}. Use --api to select one.`
|
|
759407
759347
|
});
|
|
759408
759348
|
}
|
|
759409
759349
|
async checkOrThrow({ context: context3, workspace, apiName }) {
|
|
@@ -759413,7 +759353,7 @@ var CompileCommand = class {
|
|
|
759413
759353
|
for (const violation of result.violations) {
|
|
759414
759354
|
context3.stderr.error(`${violation.displayRelativeFilepath}:${violation.line}:${violation.column}: ${violation.message}`);
|
|
759415
759355
|
}
|
|
759416
|
-
throw CliError.
|
|
759356
|
+
throw CliError.exit();
|
|
759417
759357
|
}
|
|
759418
759358
|
}
|
|
759419
759359
|
async writeOutput(context3, args, object21) {
|
|
@@ -759505,8 +759445,7 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759505
759445
|
const doc = document4.toJS();
|
|
759506
759446
|
if (doc == null || typeof doc !== "object") {
|
|
759507
759447
|
throw new CliError({
|
|
759508
|
-
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file
|
|
759509
|
-
code: CliError.Code.ParseError
|
|
759448
|
+
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`
|
|
759510
759449
|
});
|
|
759511
759450
|
}
|
|
759512
759451
|
return new _FernYmlEditor(document4, config5.fernYmlPath);
|
|
@@ -759708,8 +759647,7 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759708
759647
|
const resolvedPath = join8(dirname6(this.rootFilePath), RelativeFilePath2.of(refPath));
|
|
759709
759648
|
if (!await doesPathExist(resolvedPath)) {
|
|
759710
759649
|
throw new CliError({
|
|
759711
|
-
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist
|
|
759712
|
-
code: CliError.Code.ConfigError
|
|
759650
|
+
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`
|
|
759713
759651
|
});
|
|
759714
759652
|
}
|
|
759715
759653
|
const refContent = await (0, import_promises50.readFile)(resolvedPath, "utf-8");
|
|
@@ -759736,8 +759674,7 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759736
759674
|
const existing = section.document.getIn([...section.basePath, name2]);
|
|
759737
759675
|
if (existing == null) {
|
|
759738
759676
|
throw new CliError({
|
|
759739
|
-
message: `Target '${name2}' not found in SDK configuration
|
|
759740
|
-
code: CliError.Code.ConfigError
|
|
759677
|
+
message: `Target '${name2}' not found in SDK configuration.`
|
|
759741
759678
|
});
|
|
759742
759679
|
}
|
|
759743
759680
|
}
|
|
@@ -760065,9 +760002,9 @@ async function loadSpec(filepath) {
|
|
|
760065
760002
|
contents = await (0, import_promises51.readFile)(filepath, "utf8");
|
|
760066
760003
|
} catch (error50) {
|
|
760067
760004
|
if (isEnoentError(error50)) {
|
|
760068
|
-
throw new CliError({ message: `File does not exist: ${filepath}
|
|
760005
|
+
throw new CliError({ message: `File does not exist: ${filepath}` });
|
|
760069
760006
|
}
|
|
760070
|
-
throw new CliError({ message: `Failed to read file: ${filepath}
|
|
760007
|
+
throw new CliError({ message: `Failed to read file: ${filepath}` });
|
|
760071
760008
|
}
|
|
760072
760009
|
return parseSpec(contents, filepath);
|
|
760073
760010
|
}
|
|
@@ -760078,10 +760015,7 @@ function parseSpec(contents, filepath) {
|
|
|
760078
760015
|
try {
|
|
760079
760016
|
return jsYaml.load(contents);
|
|
760080
760017
|
} catch {
|
|
760081
|
-
throw new CliError({
|
|
760082
|
-
message: `Failed to parse file as JSON or YAML: ${filepath}`,
|
|
760083
|
-
code: CliError.Code.ParseError
|
|
760084
|
-
});
|
|
760018
|
+
throw new CliError({ message: `Failed to parse file as JSON or YAML: ${filepath}` });
|
|
760085
760019
|
}
|
|
760086
760020
|
}
|
|
760087
760021
|
}
|
|
@@ -760100,7 +760034,7 @@ var MergeCommand = class {
|
|
|
760100
760034
|
async handle(context3, args) {
|
|
760101
760035
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760102
760036
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760103
|
-
throw new CliError({ message: "No APIs found in workspace."
|
|
760037
|
+
throw new CliError({ message: "No APIs found in workspace." });
|
|
760104
760038
|
}
|
|
760105
760039
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760106
760040
|
if (entries22.length === 0) {
|
|
@@ -760112,8 +760046,7 @@ var MergeCommand = class {
|
|
|
760112
760046
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760113
760047
|
if (fernYmlPath == null) {
|
|
760114
760048
|
throw new CliError({
|
|
760115
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760116
|
-
code: CliError.Code.ConfigError
|
|
760049
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
|
|
760117
760050
|
});
|
|
760118
760051
|
}
|
|
760119
760052
|
editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760248,7 +760181,7 @@ var SplitCommand = class {
|
|
|
760248
760181
|
async handle(context3, args) {
|
|
760249
760182
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760250
760183
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760251
|
-
throw new CliError({ message: "No APIs found in workspace."
|
|
760184
|
+
throw new CliError({ message: "No APIs found in workspace." });
|
|
760252
760185
|
}
|
|
760253
760186
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760254
760187
|
if (entries22.length === 0) {
|
|
@@ -760259,8 +760192,7 @@ var SplitCommand = class {
|
|
|
760259
760192
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760260
760193
|
if (fernYmlPath == null) {
|
|
760261
760194
|
throw new CliError({
|
|
760262
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760263
|
-
code: CliError.Code.ConfigError
|
|
760195
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
|
|
760264
760196
|
});
|
|
760265
760197
|
}
|
|
760266
760198
|
const editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760381,8 +760313,7 @@ var SplitCommand = class {
|
|
|
760381
760313
|
const detail = extractErrorMessage(error50);
|
|
760382
760314
|
throw new CliError({
|
|
760383
760315
|
message: `Failed to get file from git HEAD: ${absolutePath}. Is the file tracked by git and has at least one commit?
|
|
760384
|
-
Cause: ${detail}
|
|
760385
|
-
code: CliError.Code.ParseError
|
|
760316
|
+
Cause: ${detail}`
|
|
760386
760317
|
});
|
|
760387
760318
|
}
|
|
760388
760319
|
}
|
|
@@ -760397,10 +760328,7 @@ var SplitCommand = class {
|
|
|
760397
760328
|
function resolvePathOrThrow(context3, outputPath) {
|
|
760398
760329
|
const resolved = context3.resolveOutputFilePath(outputPath);
|
|
760399
760330
|
if (resolved == null) {
|
|
760400
|
-
throw new CliError({
|
|
760401
|
-
message: `Could not resolve output path: ${outputPath}`,
|
|
760402
|
-
code: CliError.Code.ConfigError
|
|
760403
|
-
});
|
|
760331
|
+
throw new CliError({ message: `Could not resolve output path: ${outputPath}` });
|
|
760404
760332
|
}
|
|
760405
760333
|
return resolved;
|
|
760406
760334
|
}
|
|
@@ -760444,7 +760372,7 @@ var LoginCommand = class {
|
|
|
760444
760372
|
context3.stdout.info("Opening browser to log in to Fern...");
|
|
760445
760373
|
context3.stdout.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
760446
760374
|
}
|
|
760447
|
-
const taskContext = new TaskContextAdapter({ context: context3, logLevel:
|
|
760375
|
+
const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel2.Info });
|
|
760448
760376
|
const tokenResponse = await getTokenFromAuth0(taskContext, {
|
|
760449
760377
|
useDeviceCodeFlow,
|
|
760450
760378
|
forceReauth: true
|
|
@@ -760456,12 +760384,12 @@ var LoginCommand = class {
|
|
|
760456
760384
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
760457
760385
|
if (payload == null) {
|
|
760458
760386
|
context3.stdout.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
760459
|
-
throw CliError.
|
|
760387
|
+
throw CliError.exit();
|
|
760460
760388
|
}
|
|
760461
760389
|
const email3 = payload.email;
|
|
760462
760390
|
if (email3 == null) {
|
|
760463
760391
|
context3.stdout.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
760464
|
-
throw CliError.
|
|
760392
|
+
throw CliError.exit();
|
|
760465
760393
|
}
|
|
760466
760394
|
const { isNew, totalAccounts } = await context3.tokenService.login(email3, accessToken);
|
|
760467
760395
|
if (isNew) {
|
|
@@ -760527,7 +760455,7 @@ var LogoutCommand = class {
|
|
|
760527
760455
|
context3.stdout.info("");
|
|
760528
760456
|
if (!context3.isTTY) {
|
|
760529
760457
|
context3.stdout.error(`${Icons.error} Use --force to skip confirmation in non-interactive mode`);
|
|
760530
|
-
throw
|
|
760458
|
+
throw CliError.exit();
|
|
760531
760459
|
}
|
|
760532
760460
|
const { confirmed } = await lib_default4.prompt([
|
|
760533
760461
|
{
|
|
@@ -760548,9 +760476,7 @@ var LogoutCommand = class {
|
|
|
760548
760476
|
const { removed, newActive } = await context3.tokenService.logout(user);
|
|
760549
760477
|
if (!removed) {
|
|
760550
760478
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760551
|
-
throw
|
|
760552
|
-
code: CliError.Code.EnvironmentError
|
|
760553
|
-
});
|
|
760479
|
+
throw CliError.exit();
|
|
760554
760480
|
}
|
|
760555
760481
|
context3.stdout.info(`${Icons.success} Logged out of ${source_default.bold(user)}`);
|
|
760556
760482
|
if (newActive != null) {
|
|
@@ -760560,9 +760486,7 @@ var LogoutCommand = class {
|
|
|
760560
760486
|
async handleLogoutInteractive(context3, accounts) {
|
|
760561
760487
|
if (!context3.isTTY) {
|
|
760562
760488
|
context3.stdout.error(`${Icons.error} Multiple accounts found. Use --user or --all in non-interactive mode.`);
|
|
760563
|
-
throw
|
|
760564
|
-
code: CliError.Code.EnvironmentError
|
|
760565
|
-
});
|
|
760489
|
+
throw CliError.exit();
|
|
760566
760490
|
}
|
|
760567
760491
|
const choices = accounts.map((account) => ({
|
|
760568
760492
|
name: account.isActive ? `${account.user} ${source_default.dim("(active)")}` : account.user,
|
|
@@ -760718,15 +760642,13 @@ var SwitchCommand = class {
|
|
|
760718
760642
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760719
760643
|
context3.stdout.info("");
|
|
760720
760644
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760721
|
-
throw
|
|
760722
|
-
code: CliError.Code.ConfigError
|
|
760723
|
-
});
|
|
760645
|
+
throw CliError.exit();
|
|
760724
760646
|
}
|
|
760725
760647
|
if (accounts.length === 1) {
|
|
760726
760648
|
const account = accounts[0];
|
|
760727
760649
|
if (account == null) {
|
|
760728
760650
|
context3.stdout.error(`${Icons.error} Internal error; no accounts found`);
|
|
760729
|
-
throw CliError.
|
|
760651
|
+
throw CliError.exit();
|
|
760730
760652
|
}
|
|
760731
760653
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You only have one account logged in: ${source_default.bold(account.user)}`);
|
|
760732
760654
|
context3.stdout.info("");
|
|
@@ -760749,9 +760671,7 @@ var SwitchCommand = class {
|
|
|
760749
760671
|
async handleInteractiveSwitch(context3, accounts) {
|
|
760750
760672
|
if (!context3.isTTY) {
|
|
760751
760673
|
context3.stdout.error(`${Icons.error} Use --user to specify account in non-interactive mode`);
|
|
760752
|
-
throw
|
|
760753
|
-
code: CliError.Code.EnvironmentError
|
|
760754
|
-
});
|
|
760674
|
+
throw CliError.exit();
|
|
760755
760675
|
}
|
|
760756
760676
|
const choices = accounts.map((account) => ({
|
|
760757
760677
|
name: account.isActive ? `${account.user} ${source_default.dim("(current)")}` : account.user,
|
|
@@ -760772,9 +760692,7 @@ var SwitchCommand = class {
|
|
|
760772
760692
|
const success2 = await context3.tokenService.switchAccount(user);
|
|
760773
760693
|
if (!success2) {
|
|
760774
760694
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760775
|
-
throw
|
|
760776
|
-
code: CliError.Code.EnvironmentError
|
|
760777
|
-
});
|
|
760695
|
+
throw CliError.exit();
|
|
760778
760696
|
}
|
|
760779
760697
|
context3.stdout.info(`${Icons.success} Switched to ${source_default.bold(user)}`);
|
|
760780
760698
|
}
|
|
@@ -760811,32 +760729,24 @@ var TokenCommand = class {
|
|
|
760811
760729
|
organizationNotFoundError: () => {
|
|
760812
760730
|
process.stderr.write(`${Icons.error} Organization "${orgId}" was not found.
|
|
760813
760731
|
`);
|
|
760814
|
-
throw
|
|
760815
|
-
code: CliError.Code.ConfigError
|
|
760816
|
-
});
|
|
760732
|
+
throw CliError.exit();
|
|
760817
760733
|
},
|
|
760818
760734
|
unauthorizedError: () => {
|
|
760819
760735
|
process.stderr.write(`${Icons.error} You do not have access to organization "${orgId}".
|
|
760820
760736
|
`);
|
|
760821
|
-
throw
|
|
760822
|
-
code: CliError.Code.AuthError
|
|
760823
|
-
});
|
|
760737
|
+
throw CliError.exit();
|
|
760824
760738
|
},
|
|
760825
760739
|
missingOrgPermissionsError: () => {
|
|
760826
760740
|
process.stderr.write(`${Icons.error} You do not have the required permissions in organization "${orgId}".
|
|
760827
760741
|
`);
|
|
760828
|
-
throw
|
|
760829
|
-
code: CliError.Code.AuthError
|
|
760830
|
-
});
|
|
760742
|
+
throw CliError.exit();
|
|
760831
760743
|
},
|
|
760832
760744
|
_other: () => {
|
|
760833
760745
|
process.stderr.write(`${Icons.error} Failed to generate token.
|
|
760834
760746
|
|
|
760835
760747
|
Please contact support@buildwithfern.com for assistance.
|
|
760836
760748
|
`);
|
|
760837
|
-
throw
|
|
760838
|
-
code: CliError.Code.InternalError
|
|
760839
|
-
});
|
|
760749
|
+
throw CliError.exit();
|
|
760840
760750
|
}
|
|
760841
760751
|
});
|
|
760842
760752
|
}
|
|
@@ -760852,7 +760762,7 @@ var TokenCommand = class {
|
|
|
760852
760762
|
|
|
760853
760763
|
Run fern init or specify an organization with --org, then run this command again.
|
|
760854
760764
|
`);
|
|
760855
|
-
throw
|
|
760765
|
+
throw CliError.exit();
|
|
760856
760766
|
}
|
|
760857
760767
|
}
|
|
760858
760768
|
};
|
|
@@ -760872,7 +760782,7 @@ var WhoamiCommand = class {
|
|
|
760872
760782
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760873
760783
|
context3.stdout.info("");
|
|
760874
760784
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760875
|
-
throw
|
|
760785
|
+
throw CliError.exit();
|
|
760876
760786
|
}
|
|
760877
760787
|
if (args.json) {
|
|
760878
760788
|
context3.stdout.info(JSON.stringify({ email: activeAccount.user }, null, 2));
|
|
@@ -817858,7 +817768,7 @@ function checkMissingRedirects(removedSlugs, redirects, basePath) {
|
|
|
817858
817768
|
}
|
|
817859
817769
|
|
|
817860
817770
|
// ../yaml/docs-validator/lib/rules/missing-redirects/missing-redirects.js
|
|
817861
|
-
var NOOP_CONTEXT = createMockTaskContext({ logger:
|
|
817771
|
+
var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger4(noop2) });
|
|
817862
817772
|
async function fetchMarkdownEntries(fdrOrigin, domain3, basepath, authToken) {
|
|
817863
817773
|
try {
|
|
817864
817774
|
const response = await fetch(`${fdrOrigin}/slugs/markdowns`, {
|
|
@@ -839370,7 +839280,7 @@ function collectPathnamesToCheck(content5, { absoluteFilepath, instanceUrls }) {
|
|
|
839370
839280
|
}
|
|
839371
839281
|
|
|
839372
839282
|
// ../yaml/docs-validator/lib/rules/valid-markdown-link/valid-markdown-link.js
|
|
839373
|
-
var NOOP_CONTEXT2 = createMockTaskContext({ logger:
|
|
839283
|
+
var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger4(noop2) });
|
|
839374
839284
|
var ValidMarkdownLinks = {
|
|
839375
839285
|
name: "valid-markdown-links",
|
|
839376
839286
|
create: async ({ workspace, apiWorkspaces, ossWorkspaces }) => {
|
|
@@ -840439,8 +840349,7 @@ var DocsChecker = class {
|
|
|
840439
840349
|
const docsWorkspace = project.docsWorkspaces;
|
|
840440
840350
|
if (docsWorkspace == null) {
|
|
840441
840351
|
throw new CliError({
|
|
840442
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
840443
|
-
code: CliError.Code.ConfigError
|
|
840352
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
840444
840353
|
});
|
|
840445
840354
|
}
|
|
840446
840355
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -840711,12 +840620,12 @@ var CheckCommand2 = class {
|
|
|
840711
840620
|
const response = this.buildJsonResponse({ apiCheckResult, sdkCheckResult, docsCheckResult, hasErrors });
|
|
840712
840621
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
840713
840622
|
if (hasErrors) {
|
|
840714
|
-
throw
|
|
840623
|
+
throw CliError.exit();
|
|
840715
840624
|
}
|
|
840716
840625
|
return;
|
|
840717
840626
|
}
|
|
840718
840627
|
if (hasErrors) {
|
|
840719
|
-
throw
|
|
840628
|
+
throw CliError.exit();
|
|
840720
840629
|
}
|
|
840721
840630
|
if (totalWarnings > 0) {
|
|
840722
840631
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${totalWarnings} warnings`)}`);
|
|
@@ -840771,8 +840680,7 @@ var CheckCommand2 = class {
|
|
|
840771
840680
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
840772
840681
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
840773
840682
|
throw new CliError({
|
|
840774
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
840775
|
-
code: CliError.Code.ConfigError
|
|
840683
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`
|
|
840776
840684
|
});
|
|
840777
840685
|
}
|
|
840778
840686
|
}
|
|
@@ -842235,7 +842143,7 @@ var MigrateCommand = class {
|
|
|
842235
842143
|
}
|
|
842236
842144
|
return;
|
|
842237
842145
|
}
|
|
842238
|
-
throw new CliError({ message: "Migration failed"
|
|
842146
|
+
throw new CliError({ message: "Migration failed" });
|
|
842239
842147
|
}
|
|
842240
842148
|
};
|
|
842241
842149
|
function addMigrateCommand(cli) {
|
|
@@ -842258,8 +842166,7 @@ var CheckCommand3 = class {
|
|
|
842258
842166
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
842259
842167
|
if (workspace.docs == null) {
|
|
842260
842168
|
throw new CliError({
|
|
842261
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
842262
|
-
code: CliError.Code.ConfigError
|
|
842169
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
842263
842170
|
});
|
|
842264
842171
|
}
|
|
842265
842172
|
const checker = new DocsChecker({ context: context3 });
|
|
@@ -842269,7 +842176,7 @@ var CheckCommand3 = class {
|
|
|
842269
842176
|
const response = this.buildJsonResponse({ result, hasErrors });
|
|
842270
842177
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
842271
842178
|
if (hasErrors) {
|
|
842272
|
-
throw
|
|
842179
|
+
throw CliError.exit();
|
|
842273
842180
|
}
|
|
842274
842181
|
return;
|
|
842275
842182
|
}
|
|
@@ -842281,7 +842188,7 @@ var CheckCommand3 = class {
|
|
|
842281
842188
|
}
|
|
842282
842189
|
}
|
|
842283
842190
|
if (hasErrors) {
|
|
842284
|
-
throw
|
|
842191
|
+
throw CliError.exit();
|
|
842285
842192
|
}
|
|
842286
842193
|
if (result.warningCount > 0) {
|
|
842287
842194
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -844122,7 +844029,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
844122
844029
|
var LOGS_FOLDER_NAME = "logs";
|
|
844123
844030
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
844124
844031
|
function getCliSource() {
|
|
844125
|
-
const version7 = "4.68.3
|
|
844032
|
+
const version7 = "4.68.3";
|
|
844126
844033
|
return `cli@${version7}`;
|
|
844127
844034
|
}
|
|
844128
844035
|
var DebugLogger = class {
|
|
@@ -846104,8 +846011,7 @@ var DevCommand = class {
|
|
|
846104
846011
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
846105
846012
|
if (workspace.docs == null) {
|
|
846106
846013
|
throw new CliError({
|
|
846107
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
846108
|
-
code: CliError.Code.ConfigError
|
|
846014
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
846109
846015
|
});
|
|
846110
846016
|
}
|
|
846111
846017
|
const backendPort = args["backend-port"] ?? await getPorts();
|
|
@@ -846115,7 +846021,7 @@ var DevCommand = class {
|
|
|
846115
846021
|
backendPort,
|
|
846116
846022
|
forceDownload: args["force-download"],
|
|
846117
846023
|
bundlePath: args["bundle-path"],
|
|
846118
|
-
logLevel:
|
|
846024
|
+
logLevel: LogLevel2.Info
|
|
846119
846025
|
});
|
|
846120
846026
|
}
|
|
846121
846027
|
};
|
|
@@ -846426,11 +846332,11 @@ function getSeverityForViolations(violations) {
|
|
|
846426
846332
|
function getLogLevelForSeverity(severity) {
|
|
846427
846333
|
switch (severity) {
|
|
846428
846334
|
case "fatal":
|
|
846429
|
-
return
|
|
846335
|
+
return LogLevel2.Error;
|
|
846430
846336
|
case "error":
|
|
846431
|
-
return
|
|
846337
|
+
return LogLevel2.Error;
|
|
846432
846338
|
case "warning":
|
|
846433
|
-
return
|
|
846339
|
+
return LogLevel2.Warn;
|
|
846434
846340
|
default:
|
|
846435
846341
|
assertNever(severity);
|
|
846436
846342
|
}
|
|
@@ -853716,15 +853622,15 @@ async function makeWritableRecursive(dirPath) {
|
|
|
853716
853622
|
function convertLogLevel(logLevel) {
|
|
853717
853623
|
switch (logLevel) {
|
|
853718
853624
|
case "DEBUG":
|
|
853719
|
-
return
|
|
853625
|
+
return LogLevel2.Debug;
|
|
853720
853626
|
case "INFO":
|
|
853721
|
-
return
|
|
853627
|
+
return LogLevel2.Info;
|
|
853722
853628
|
case "WARN":
|
|
853723
|
-
return
|
|
853629
|
+
return LogLevel2.Warn;
|
|
853724
853630
|
case "ERROR":
|
|
853725
|
-
return
|
|
853631
|
+
return LogLevel2.Error;
|
|
853726
853632
|
default:
|
|
853727
|
-
return
|
|
853633
|
+
return LogLevel2.Info;
|
|
853728
853634
|
}
|
|
853729
853635
|
}
|
|
853730
853636
|
async function checkFernIgnorePresent(absolutePathToLocalOutput) {
|
|
@@ -855372,7 +855278,7 @@ var LegacyDocsPublisher = class {
|
|
|
855372
855278
|
previewId,
|
|
855373
855279
|
disableTemplates: void 0,
|
|
855374
855280
|
skipUpload,
|
|
855375
|
-
cliVersion: "4.68.3
|
|
855281
|
+
cliVersion: "4.68.3"
|
|
855376
855282
|
});
|
|
855377
855283
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
855378
855284
|
return { success: false };
|
|
@@ -855965,8 +855871,7 @@ var PublishCommand = class {
|
|
|
855965
855871
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
855966
855872
|
if (workspace.docs == null) {
|
|
855967
855873
|
throw new CliError({
|
|
855968
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855969
|
-
code: CliError.Code.ConfigError
|
|
855874
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855970
855875
|
});
|
|
855971
855876
|
}
|
|
855972
855877
|
const instanceUrl = this.resolveInstanceUrl({
|
|
@@ -855985,8 +855890,7 @@ var PublishCommand = class {
|
|
|
855985
855890
|
const docsWorkspace = project.docsWorkspaces;
|
|
855986
855891
|
if (docsWorkspace == null) {
|
|
855987
855892
|
throw new CliError({
|
|
855988
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855989
|
-
code: CliError.Code.ConfigError
|
|
855893
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855990
855894
|
});
|
|
855991
855895
|
}
|
|
855992
855896
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -856001,10 +855905,7 @@ var PublishCommand = class {
|
|
|
856001
855905
|
});
|
|
856002
855906
|
const docsTask = taskGroup.getTask("publish");
|
|
856003
855907
|
if (docsTask == null) {
|
|
856004
|
-
throw new CliError({
|
|
856005
|
-
message: "Internal error; task 'publish' not found",
|
|
856006
|
-
code: CliError.Code.InternalError
|
|
856007
|
-
});
|
|
855908
|
+
throw new CliError({ message: "Internal error; task 'publish' not found" });
|
|
856008
855909
|
}
|
|
856009
855910
|
docsTask.start();
|
|
856010
855911
|
docsTask.stage.validation.start();
|
|
@@ -856048,14 +855949,13 @@ var PublishCommand = class {
|
|
|
856048
855949
|
errorMessage: labels.error
|
|
856049
855950
|
});
|
|
856050
855951
|
if (summary.failedCount > 0) {
|
|
856051
|
-
throw
|
|
855952
|
+
throw CliError.exit();
|
|
856052
855953
|
}
|
|
856053
855954
|
}
|
|
856054
855955
|
resolveInstanceUrl({ instances: instances2, instance }) {
|
|
856055
855956
|
if (instances2.length === 0) {
|
|
856056
855957
|
throw new CliError({
|
|
856057
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856058
|
-
code: CliError.Code.ConfigError
|
|
855958
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856059
855959
|
});
|
|
856060
855960
|
}
|
|
856061
855961
|
if (instance != null) {
|
|
@@ -856068,8 +855968,7 @@ var PublishCommand = class {
|
|
|
856068
855968
|
Available instances:
|
|
856069
855969
|
${available}
|
|
856070
855970
|
|
|
856071
|
-
Use --instance <url> with one of the URLs above
|
|
856072
|
-
code: CliError.Code.ConfigError
|
|
855971
|
+
Use --instance <url> with one of the URLs above.`
|
|
856073
855972
|
});
|
|
856074
855973
|
}
|
|
856075
855974
|
return match3.url;
|
|
@@ -856082,15 +855981,13 @@ ${available}
|
|
|
856082
855981
|
Available instances:
|
|
856083
855982
|
${available}
|
|
856084
855983
|
|
|
856085
|
-
Use --instance <url> to select one
|
|
856086
|
-
code: CliError.Code.ConfigError
|
|
855984
|
+
Use --instance <url> to select one.`
|
|
856087
855985
|
});
|
|
856088
855986
|
}
|
|
856089
855987
|
const first3 = instances2[0];
|
|
856090
855988
|
if (first3 == null) {
|
|
856091
855989
|
throw new CliError({
|
|
856092
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856093
|
-
code: CliError.Code.ConfigError
|
|
855990
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856094
855991
|
});
|
|
856095
855992
|
}
|
|
856096
855993
|
return first3.url;
|
|
@@ -856124,8 +856021,7 @@ ${available}
|
|
|
856124
856021
|
const fernToken = process.env["FERN_TOKEN"];
|
|
856125
856022
|
if (fernToken == null) {
|
|
856126
856023
|
throw new CliError({
|
|
856127
|
-
message: "No organization token found. Please set the FERN_TOKEN environment variable."
|
|
856128
|
-
code: CliError.Code.AuthError
|
|
856024
|
+
message: "No organization token found. Please set the FERN_TOKEN environment variable."
|
|
856129
856025
|
});
|
|
856130
856026
|
}
|
|
856131
856027
|
return Promise.resolve({ type: "organization", value: fernToken });
|
|
@@ -856137,10 +856033,7 @@ function addPublishCommand(cli) {
|
|
|
856137
856033
|
const cmd = new PublishCommand();
|
|
856138
856034
|
command2(cli, "publish", "Publish your documentation site", async (context3, args) => {
|
|
856139
856035
|
const timeout4 = new Promise((_16, reject) => {
|
|
856140
|
-
setTimeout(() => reject(new CliError({
|
|
856141
|
-
message: "Docs publish timed out after 10 minutes.",
|
|
856142
|
-
code: CliError.Code.NetworkError
|
|
856143
|
-
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856036
|
+
setTimeout(() => reject(new CliError({ message: "Docs publish timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856144
856037
|
});
|
|
856145
856038
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856146
856039
|
}, (yargs) => yargs.option("force", {
|
|
@@ -856169,8 +856062,7 @@ var DeleteCommand = class {
|
|
|
856169
856062
|
if (!this.isPreviewUrl(args.url)) {
|
|
856170
856063
|
throw new CliError({
|
|
856171
856064
|
message: `Invalid preview URL: ${args.url}
|
|
856172
|
-
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
856173
|
-
code: CliError.Code.ConfigError
|
|
856065
|
+
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`
|
|
856174
856066
|
});
|
|
856175
856067
|
}
|
|
856176
856068
|
const token = await context3.getTokenOrPrompt();
|
|
@@ -856187,8 +856079,7 @@ var DeleteCommand = class {
|
|
|
856187
856079
|
throw CliError.notFound(`Preview site not found: ${args.url}`);
|
|
856188
856080
|
default:
|
|
856189
856081
|
throw new CliError({
|
|
856190
|
-
message: `Failed to delete preview site: ${args.url}
|
|
856191
|
-
code: CliError.Code.InternalError
|
|
856082
|
+
message: `Failed to delete preview site: ${args.url}`
|
|
856192
856083
|
});
|
|
856193
856084
|
}
|
|
856194
856085
|
}
|
|
@@ -856235,10 +856126,7 @@ function addPreviewCommand(cli) {
|
|
|
856235
856126
|
const cmd = new PreviewCommand();
|
|
856236
856127
|
commandWithSubcommands(cli, "preview", "Generate a preview of your documentation site", async (context3, args) => {
|
|
856237
856128
|
const timeout4 = new Promise((_16, reject) => {
|
|
856238
|
-
setTimeout(() => reject(new CliError({
|
|
856239
|
-
message: "Docs preview timed out after 10 minutes.",
|
|
856240
|
-
code: CliError.Code.NetworkError
|
|
856241
|
-
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856129
|
+
setTimeout(() => reject(new CliError({ message: "Docs preview timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856242
856130
|
});
|
|
856243
856131
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856244
856132
|
}, (yargs) => yargs.option("instance", {
|
|
@@ -856625,7 +856513,7 @@ var Wizard = class {
|
|
|
856625
856513
|
return void 0;
|
|
856626
856514
|
}
|
|
856627
856515
|
this.context.stderr.info(` ${Icons.info} Opening browser to log in to Fern...`);
|
|
856628
|
-
const taskContext = new TaskContextAdapter({ context: this.context, logLevel:
|
|
856516
|
+
const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel2.Info });
|
|
856629
856517
|
const { accessToken, idToken } = await getTokenFromAuth0(taskContext, {
|
|
856630
856518
|
useDeviceCodeFlow: false,
|
|
856631
856519
|
forceReauth: false
|
|
@@ -857205,8 +857093,7 @@ var InitCommand = class {
|
|
|
857205
857093
|
async validateArgs({ context: context3, fernYmlPath, args }) {
|
|
857206
857094
|
if (await doesPathExist(fernYmlPath)) {
|
|
857207
857095
|
throw new CliError({
|
|
857208
|
-
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}
|
|
857209
|
-
code: CliError.Code.ConfigError
|
|
857096
|
+
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`
|
|
857210
857097
|
});
|
|
857211
857098
|
}
|
|
857212
857099
|
if (args.api != null) {
|
|
@@ -857214,14 +857101,13 @@ var InitCommand = class {
|
|
|
857214
857101
|
if (!api.startsWith("http://") && !api.startsWith("https://")) {
|
|
857215
857102
|
const resolved = import_path59.default.resolve(context3.cwd, api);
|
|
857216
857103
|
if (!await doesPathExist(AbsoluteFilePath2.of(resolved))) {
|
|
857217
|
-
throw new CliError({ message: `File not found: ${api}
|
|
857104
|
+
throw new CliError({ message: `File not found: ${api}` });
|
|
857218
857105
|
}
|
|
857219
857106
|
}
|
|
857220
857107
|
}
|
|
857221
857108
|
if (!context3.isTTY && !args.yes) {
|
|
857222
857109
|
throw new CliError({
|
|
857223
|
-
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
|
|
857224
|
-
code: CliError.Code.ConfigError
|
|
857110
|
+
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
|
|
857225
857111
|
});
|
|
857226
857112
|
}
|
|
857227
857113
|
}
|
|
@@ -857247,7 +857133,7 @@ var CreateCommand = class {
|
|
|
857247
857133
|
const token = await context3.getTokenOrPrompt();
|
|
857248
857134
|
if (token.type === "organization") {
|
|
857249
857135
|
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.`);
|
|
857250
|
-
throw
|
|
857136
|
+
throw CliError.exit();
|
|
857251
857137
|
}
|
|
857252
857138
|
const validationError = getOrganizationNameValidationError(args.name);
|
|
857253
857139
|
if (validationError != null) {
|
|
@@ -857284,7 +857170,7 @@ var ListCommand = class {
|
|
|
857284
857170
|
const token = await context3.getTokenOrPrompt();
|
|
857285
857171
|
if (token.type === "organization") {
|
|
857286
857172
|
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.`);
|
|
857287
|
-
throw
|
|
857173
|
+
throw CliError.exit();
|
|
857288
857174
|
}
|
|
857289
857175
|
const venus = createVenusService({ token: token.value });
|
|
857290
857176
|
const firstPage = await this.fetchPage({ venus, pageId: 1 });
|
|
@@ -857428,14 +857314,13 @@ var AddCommand = class {
|
|
|
857428
857314
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
857429
857315
|
if (fernYmlPath == null) {
|
|
857430
857316
|
throw new CliError({
|
|
857431
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
857432
|
-
code: CliError.Code.ConfigError
|
|
857317
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
|
|
857433
857318
|
});
|
|
857434
857319
|
}
|
|
857435
857320
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
857436
857321
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
857437
857322
|
if (sdkCheckResult.errorCount > 0) {
|
|
857438
|
-
throw
|
|
857323
|
+
throw CliError.exit();
|
|
857439
857324
|
}
|
|
857440
857325
|
const existingTargets = workspace.sdks?.targets ?? [];
|
|
857441
857326
|
if (!context3.isTTY || args.yes) {
|
|
@@ -857448,8 +857333,7 @@ var AddCommand = class {
|
|
|
857448
857333
|
throw new CliError({
|
|
857449
857334
|
message: `Missing required flags:
|
|
857450
857335
|
|
|
857451
|
-
--target <language> SDK language (e.g. typescript, python, go)
|
|
857452
|
-
code: CliError.Code.ConfigError
|
|
857336
|
+
--target <language> SDK language (e.g. typescript, python, go)`
|
|
857453
857337
|
});
|
|
857454
857338
|
}
|
|
857455
857339
|
const language = this.parseLanguage(args.target);
|
|
@@ -857495,8 +857379,7 @@ var AddCommand = class {
|
|
|
857495
857379
|
message: `"${value}" looks like a remote reference but is not a recognized git URL.
|
|
857496
857380
|
|
|
857497
857381
|
Please specify a local path (e.g. ./sdks/my-sdk) or a git URL:
|
|
857498
|
-
https://github.com/owner/repo
|
|
857499
|
-
code: CliError.Code.ConfigError
|
|
857382
|
+
https://github.com/owner/repo`
|
|
857500
857383
|
});
|
|
857501
857384
|
}
|
|
857502
857385
|
return { path: value };
|
|
@@ -857518,8 +857401,7 @@ var AddCommand = class {
|
|
|
857518
857401
|
checkForDuplicate({ existingTargets, language }) {
|
|
857519
857402
|
if (existingTargets.some((t3) => t3.name === language)) {
|
|
857520
857403
|
throw new CliError({
|
|
857521
|
-
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}
|
|
857522
|
-
code: CliError.Code.ConfigError
|
|
857404
|
+
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`
|
|
857523
857405
|
});
|
|
857524
857406
|
}
|
|
857525
857407
|
}
|
|
@@ -857571,8 +857453,7 @@ var AddCommand = class {
|
|
|
857571
857453
|
return lang;
|
|
857572
857454
|
}
|
|
857573
857455
|
throw new CliError({
|
|
857574
|
-
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}
|
|
857575
|
-
code: CliError.Code.ConfigError
|
|
857456
|
+
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`
|
|
857576
857457
|
});
|
|
857577
857458
|
}
|
|
857578
857459
|
};
|
|
@@ -857609,7 +857490,7 @@ var CheckCommand4 = class {
|
|
|
857609
857490
|
const response = this.buildJsonResponse({ sdkCheckResult: result, hasErrors });
|
|
857610
857491
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
857611
857492
|
if (hasErrors) {
|
|
857612
|
-
throw
|
|
857493
|
+
throw CliError.exit();
|
|
857613
857494
|
}
|
|
857614
857495
|
return;
|
|
857615
857496
|
}
|
|
@@ -857621,7 +857502,7 @@ var CheckCommand4 = class {
|
|
|
857621
857502
|
}
|
|
857622
857503
|
}
|
|
857623
857504
|
if (hasErrors) {
|
|
857624
|
-
throw
|
|
857505
|
+
throw CliError.exit();
|
|
857625
857506
|
}
|
|
857626
857507
|
if (result.warningCount > 0) {
|
|
857627
857508
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -908030,6 +907911,8 @@ var GenerationRunner = class {
|
|
|
908030
907911
|
}
|
|
908031
907912
|
} catch (error50) {
|
|
908032
907913
|
if (error50 instanceof TaskAbortSignal) {
|
|
907914
|
+
} else if (error50 instanceof LoggableFernCliError) {
|
|
907915
|
+
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50.log}`, error50);
|
|
908033
907916
|
} else {
|
|
908034
907917
|
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
|
|
908035
907918
|
}
|
|
@@ -908462,7 +908345,7 @@ var LegacyLocalGenerationRunner = class {
|
|
|
908462
908345
|
const taskContext = new TaskContextAdapter({
|
|
908463
908346
|
context: this.context,
|
|
908464
908347
|
task: args.task,
|
|
908465
|
-
logLevel:
|
|
908348
|
+
logLevel: LogLevel2.Info
|
|
908466
908349
|
});
|
|
908467
908350
|
try {
|
|
908468
908351
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908601,7 +908484,7 @@ var LegacyRemoteGenerationRunner = class {
|
|
|
908601
908484
|
const taskContext = new TaskContextAdapter({
|
|
908602
908485
|
context: this.context,
|
|
908603
908486
|
task: args.task,
|
|
908604
|
-
logLevel:
|
|
908487
|
+
logLevel: LogLevel2.Info
|
|
908605
908488
|
});
|
|
908606
908489
|
try {
|
|
908607
908490
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908741,8 +908624,7 @@ var GeneratorPipeline = class {
|
|
|
908741
908624
|
}
|
|
908742
908625
|
if (args.target.registry != null) {
|
|
908743
908626
|
throw new CliError({
|
|
908744
|
-
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry
|
|
908745
|
-
code: CliError.Code.ConfigError
|
|
908627
|
+
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`
|
|
908746
908628
|
});
|
|
908747
908629
|
}
|
|
908748
908630
|
return await this.runRemoteGeneration(args);
|
|
@@ -909054,8 +908936,7 @@ var GenerateCommand = class {
|
|
|
909054
908936
|
throw new CliError({
|
|
909055
908937
|
message: `No fern.yml found, either run 'fern init' or specify all of the required flags:
|
|
909056
908938
|
|
|
909057
|
-
` + missingFlags.map((flag) => ` ${flag}`).join("\n")
|
|
909058
|
-
code: CliError.Code.ConfigError
|
|
908939
|
+
` + missingFlags.map((flag) => ` ${flag}`).join("\n")
|
|
909059
908940
|
});
|
|
909060
908941
|
}
|
|
909061
908942
|
const api = args.api;
|
|
@@ -909106,12 +908987,12 @@ var GenerateCommand = class {
|
|
|
909106
908987
|
}
|
|
909107
908988
|
}
|
|
909108
908989
|
if (sdkCheckResult.errorCount > 0) {
|
|
909109
|
-
throw
|
|
908990
|
+
throw CliError.exit();
|
|
909110
908991
|
}
|
|
909111
908992
|
}
|
|
909112
908993
|
const validTargets = targets2.filter((t3) => checkResult.validApis.has(t3.api));
|
|
909113
908994
|
if (validTargets.length === 0) {
|
|
909114
|
-
throw
|
|
908995
|
+
throw CliError.exit();
|
|
909115
908996
|
}
|
|
909116
908997
|
const pipeline5 = new GeneratorPipeline({
|
|
909117
908998
|
context: context3,
|
|
@@ -909139,7 +909020,7 @@ var GenerateCommand = class {
|
|
|
909139
909020
|
if (outputPath != null) {
|
|
909140
909021
|
const { shouldProceed } = await this.checkOutputDirectory({ context: context3, args, outputPath });
|
|
909141
909022
|
if (!shouldProceed) {
|
|
909142
|
-
throw new CliError({ message: "Generation cancelled."
|
|
909023
|
+
throw new CliError({ message: "Generation cancelled." });
|
|
909143
909024
|
}
|
|
909144
909025
|
}
|
|
909145
909026
|
}
|
|
@@ -909157,10 +909038,7 @@ var GenerateCommand = class {
|
|
|
909157
909038
|
await Promise.all(targets2.map(async (target) => {
|
|
909158
909039
|
const task = taskGroup.getTask(target.name);
|
|
909159
909040
|
if (task == null) {
|
|
909160
|
-
throw new CliError({
|
|
909161
|
-
message: `Internal error; task '${target.name}' not found`,
|
|
909162
|
-
code: CliError.Code.InternalError
|
|
909163
|
-
});
|
|
909041
|
+
throw new CliError({ message: `Internal error; task '${target.name}' not found` });
|
|
909164
909042
|
}
|
|
909165
909043
|
task.start();
|
|
909166
909044
|
task.stage.validation.start();
|
|
@@ -909206,32 +909084,22 @@ var GenerateCommand = class {
|
|
|
909206
909084
|
errorMessage: `Failed to generate ${sdkInitialism}`
|
|
909207
909085
|
});
|
|
909208
909086
|
if (summary.failedCount > 0) {
|
|
909209
|
-
throw
|
|
909087
|
+
throw CliError.exit();
|
|
909210
909088
|
}
|
|
909211
909089
|
}
|
|
909212
909090
|
validateArgs({ workspace, args, targets: targets2 }) {
|
|
909213
909091
|
if (args["container-engine"] != null && !args.local) {
|
|
909214
|
-
throw new CliError({
|
|
909215
|
-
message: "The --container-engine flag can only be used with --local",
|
|
909216
|
-
code: CliError.Code.ConfigError
|
|
909217
|
-
});
|
|
909092
|
+
throw new CliError({ message: "The --container-engine flag can only be used with --local" });
|
|
909218
909093
|
}
|
|
909219
909094
|
if (args.group != null && args.target != null) {
|
|
909220
|
-
throw new CliError({
|
|
909221
|
-
message: "The --group and --target flags cannot be used together",
|
|
909222
|
-
code: CliError.Code.ConfigError
|
|
909223
|
-
});
|
|
909095
|
+
throw new CliError({ message: "The --group and --target flags cannot be used together" });
|
|
909224
909096
|
}
|
|
909225
909097
|
if (targets2.length > 1 && args.output != null) {
|
|
909226
|
-
throw new CliError({
|
|
909227
|
-
message: "The --output flag can only be used when generating a single target",
|
|
909228
|
-
code: CliError.Code.ConfigError
|
|
909229
|
-
});
|
|
909098
|
+
throw new CliError({ message: "The --output flag can only be used when generating a single target" });
|
|
909230
909099
|
}
|
|
909231
909100
|
if (args["skip-fernignore"] && args.fernignore != null) {
|
|
909232
909101
|
throw new CliError({
|
|
909233
|
-
message: "The --skip-fernignore and --fernignore flags cannot be used together."
|
|
909234
|
-
code: CliError.Code.ConfigError
|
|
909102
|
+
message: "The --skip-fernignore and --fernignore flags cannot be used together."
|
|
909235
909103
|
});
|
|
909236
909104
|
}
|
|
909237
909105
|
const issues = [];
|
|
@@ -909283,8 +909151,7 @@ Example:
|
|
|
909283
909151
|
throw new CliError({
|
|
909284
909152
|
message: `Remote generation is not supported with a git URL for --output
|
|
909285
909153
|
|
|
909286
|
-
Use --local or specify a local filesystem path for --output
|
|
909287
|
-
code: CliError.Code.ConfigError
|
|
909154
|
+
Use --local or specify a local filesystem path for --output`
|
|
909288
909155
|
});
|
|
909289
909156
|
}
|
|
909290
909157
|
const token = process.env.GITHUB_TOKEN ?? process.env.GIT_TOKEN;
|
|
@@ -909296,8 +909163,7 @@ Example:
|
|
|
909296
909163
|
export GITHUB_TOKEN=ghp_xxx
|
|
909297
909164
|
|
|
909298
909165
|
Or use a local path:
|
|
909299
|
-
--output ./my-sdk
|
|
909300
|
-
code: CliError.Code.AuthError
|
|
909166
|
+
--output ./my-sdk`
|
|
909301
909167
|
});
|
|
909302
909168
|
}
|
|
909303
909169
|
return {
|
|
@@ -909419,10 +909285,7 @@ function addGenerateCommand(cli) {
|
|
|
909419
909285
|
const cmd = new GenerateCommand();
|
|
909420
909286
|
command2(cli, "generate", "Generate SDKs from fern.yml or directly from an API spec", async (context3, args) => {
|
|
909421
909287
|
const timeout4 = new Promise((_16, reject) => {
|
|
909422
|
-
setTimeout(() => reject(new CliError({
|
|
909423
|
-
message: "Generation timed out after 10 minutes.",
|
|
909424
|
-
code: CliError.Code.NetworkError
|
|
909425
|
-
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909288
|
+
setTimeout(() => reject(new CliError({ message: "Generation timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909426
909289
|
});
|
|
909427
909290
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909428
909291
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909501,10 +909364,7 @@ function addPreviewCommand2(cli) {
|
|
|
909501
909364
|
const cmd = new PreviewCommand2();
|
|
909502
909365
|
command2(cli, "preview", "Generate a preview of an SDK", async (context3, args) => {
|
|
909503
909366
|
const timeout4 = new Promise((_16, reject) => {
|
|
909504
|
-
setTimeout(() => reject(new CliError({
|
|
909505
|
-
message: "Preview generation timed out after 10 minutes.",
|
|
909506
|
-
code: CliError.Code.NetworkError
|
|
909507
|
-
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909367
|
+
setTimeout(() => reject(new CliError({ message: "Preview generation timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909508
909368
|
});
|
|
909509
909369
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909510
909370
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909956,14 +909816,13 @@ var UpdateCommand = class {
|
|
|
909956
909816
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
909957
909817
|
if (fernYmlPath == null) {
|
|
909958
909818
|
throw new CliError({
|
|
909959
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
909960
|
-
code: CliError.Code.ConfigError
|
|
909819
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
|
|
909961
909820
|
});
|
|
909962
909821
|
}
|
|
909963
909822
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
909964
909823
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
909965
909824
|
if (sdkCheckResult.errorCount > 0) {
|
|
909966
|
-
throw
|
|
909825
|
+
throw CliError.exit();
|
|
909967
909826
|
}
|
|
909968
909827
|
const targets2 = workspace.sdks?.targets;
|
|
909969
909828
|
if (targets2 == null || targets2.length === 0) {
|
|
@@ -909979,8 +909838,7 @@ var UpdateCommand = class {
|
|
|
909979
909838
|
});
|
|
909980
909839
|
if (updates.length === 0 && upToDate.length === 0 && args.target != null) {
|
|
909981
909840
|
throw new CliError({
|
|
909982
|
-
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}
|
|
909983
|
-
code: CliError.Code.ConfigError
|
|
909841
|
+
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`
|
|
909984
909842
|
});
|
|
909985
909843
|
}
|
|
909986
909844
|
if (updates.length === 0) {
|
|
@@ -924961,19 +924819,19 @@ var Logger4 = class {
|
|
|
924961
924819
|
this.enabled = true;
|
|
924962
924820
|
}
|
|
924963
924821
|
trace(...args) {
|
|
924964
|
-
this.write(
|
|
924822
|
+
this.write(LogLevel2.Trace, ...args);
|
|
924965
924823
|
}
|
|
924966
924824
|
debug(...args) {
|
|
924967
|
-
this.write(
|
|
924825
|
+
this.write(LogLevel2.Debug, ...args);
|
|
924968
924826
|
}
|
|
924969
924827
|
info(...args) {
|
|
924970
|
-
this.write(
|
|
924828
|
+
this.write(LogLevel2.Info, ...args);
|
|
924971
924829
|
}
|
|
924972
924830
|
warn(...args) {
|
|
924973
|
-
this.write(
|
|
924831
|
+
this.write(LogLevel2.Warn, ...args);
|
|
924974
924832
|
}
|
|
924975
924833
|
error(...args) {
|
|
924976
|
-
this.write(
|
|
924834
|
+
this.write(LogLevel2.Error, ...args);
|
|
924977
924835
|
}
|
|
924978
924836
|
log(level, ...args) {
|
|
924979
924837
|
this.write(level, ...args);
|
|
@@ -928588,24 +928446,6 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
928588
928446
|
// src/cli-context/CliContext.ts
|
|
928589
928447
|
init_lodash();
|
|
928590
928448
|
|
|
928591
|
-
// src/telemetry/reportError.ts
|
|
928592
|
-
function reportError2(reporter, error50, options2) {
|
|
928593
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
928594
|
-
return;
|
|
928595
|
-
}
|
|
928596
|
-
const code5 = resolveErrorCode(error50, options2?.code);
|
|
928597
|
-
reporter.instrumentPostHogEvent({
|
|
928598
|
-
command: process.argv.join(" "),
|
|
928599
|
-
properties: {
|
|
928600
|
-
failed: true,
|
|
928601
|
-
errorCode: code5
|
|
928602
|
-
}
|
|
928603
|
-
});
|
|
928604
|
-
if (shouldReportToSentry(code5)) {
|
|
928605
|
-
reporter.captureException(error50 ?? new CliError({ message: options2?.message ?? "", code: code5 }), code5);
|
|
928606
|
-
}
|
|
928607
|
-
}
|
|
928608
|
-
|
|
928609
928449
|
// src/telemetry/SentryClient.ts
|
|
928610
928450
|
var SentryClient = class {
|
|
928611
928451
|
sentry;
|
|
@@ -928628,15 +928468,12 @@ var SentryClient = class {
|
|
|
928628
928468
|
setSentryRunIdTags();
|
|
928629
928469
|
}
|
|
928630
928470
|
}
|
|
928631
|
-
captureException(error50
|
|
928471
|
+
async captureException(error50) {
|
|
928632
928472
|
if (this.sentry == null) {
|
|
928633
928473
|
return;
|
|
928634
928474
|
}
|
|
928635
928475
|
try {
|
|
928636
|
-
this.sentry.captureException(
|
|
928637
|
-
error50,
|
|
928638
|
-
code5 != null ? { captureContext: { tags: { "error.code": code5 } } } : void 0
|
|
928639
|
-
);
|
|
928476
|
+
this.sentry.captureException(error50);
|
|
928640
928477
|
} catch {
|
|
928641
928478
|
}
|
|
928642
928479
|
}
|
|
@@ -928694,15 +928531,13 @@ var TaskContextImpl = class {
|
|
|
928694
928531
|
status = "notStarted";
|
|
928695
928532
|
onResult;
|
|
928696
928533
|
instrumentPostHogEventImpl;
|
|
928697
|
-
captureExceptionImpl;
|
|
928698
928534
|
constructor({
|
|
928699
928535
|
logImmediately,
|
|
928700
928536
|
logPrefix,
|
|
928701
928537
|
takeOverTerminal,
|
|
928702
928538
|
onResult,
|
|
928703
928539
|
shouldBufferLogs,
|
|
928704
|
-
instrumentPostHogEvent
|
|
928705
|
-
captureException: captureException2
|
|
928540
|
+
instrumentPostHogEvent
|
|
928706
928541
|
}) {
|
|
928707
928542
|
this.logImmediately = logImmediately;
|
|
928708
928543
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -928710,7 +928545,6 @@ var TaskContextImpl = class {
|
|
|
928710
928545
|
this.onResult = onResult;
|
|
928711
928546
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
928712
928547
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
928713
|
-
this.captureExceptionImpl = captureException2;
|
|
928714
928548
|
}
|
|
928715
928549
|
start() {
|
|
928716
928550
|
this.status = "running";
|
|
@@ -928728,21 +928562,14 @@ var TaskContextImpl = class {
|
|
|
928728
928562
|
return this.status === "finished";
|
|
928729
928563
|
}
|
|
928730
928564
|
takeOverTerminal;
|
|
928731
|
-
failAndThrow(message, error50
|
|
928732
|
-
this.failWithoutThrowing(message, error50
|
|
928565
|
+
failAndThrow(message, error50) {
|
|
928566
|
+
this.failWithoutThrowing(message, error50);
|
|
928733
928567
|
this.finish();
|
|
928734
928568
|
throw new TaskAbortSignal();
|
|
928735
928569
|
}
|
|
928736
|
-
failWithoutThrowing(message, error50
|
|
928737
|
-
this.result = TaskResult.Failure;
|
|
928738
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
928739
|
-
return;
|
|
928740
|
-
}
|
|
928570
|
+
failWithoutThrowing(message, error50) {
|
|
928741
928571
|
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928742
|
-
|
|
928743
|
-
}
|
|
928744
|
-
captureException(error50, code5) {
|
|
928745
|
-
this.captureExceptionImpl?.(error50, code5);
|
|
928572
|
+
this.result = TaskResult.Failure;
|
|
928746
928573
|
}
|
|
928747
928574
|
getResult() {
|
|
928748
928575
|
return this.result;
|
|
@@ -928774,7 +928601,7 @@ var TaskContextImpl = class {
|
|
|
928774
928601
|
this.logImmediately(this.bufferedLogs);
|
|
928775
928602
|
this.bufferedLogs = [];
|
|
928776
928603
|
}
|
|
928777
|
-
logger =
|
|
928604
|
+
logger = createLogger4(this.logAtLevel.bind(this));
|
|
928778
928605
|
addInteractiveTask({ name: name2, subtitle }) {
|
|
928779
928606
|
const subtask = new InteractiveTaskContextImpl({
|
|
928780
928607
|
name: name2,
|
|
@@ -928784,8 +928611,7 @@ var TaskContextImpl = class {
|
|
|
928784
928611
|
takeOverTerminal: this.takeOverTerminal,
|
|
928785
928612
|
onResult: this.onResult,
|
|
928786
928613
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
928787
|
-
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
|
|
928788
|
-
captureException: this.captureExceptionImpl
|
|
928614
|
+
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
|
|
928789
928615
|
});
|
|
928790
928616
|
this.subtasks.push(subtask);
|
|
928791
928617
|
return subtask;
|
|
@@ -928815,7 +928641,7 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928815
928641
|
}
|
|
928816
928642
|
start() {
|
|
928817
928643
|
super.start();
|
|
928818
|
-
this.logAtLevelWithOverrides(
|
|
928644
|
+
this.logAtLevelWithOverrides(LogLevel2.Info, ["Started."], {
|
|
928819
928645
|
omitOnTTY: true
|
|
928820
928646
|
});
|
|
928821
928647
|
this.flushLogs();
|
|
@@ -928826,11 +928652,11 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928826
928652
|
}
|
|
928827
928653
|
finish() {
|
|
928828
928654
|
if (this.result === TaskResult.Success) {
|
|
928829
|
-
this.logAtLevelWithOverrides(
|
|
928655
|
+
this.logAtLevelWithOverrides(LogLevel2.Info, ["Finished."], {
|
|
928830
928656
|
omitOnTTY: true
|
|
928831
928657
|
});
|
|
928832
928658
|
} else {
|
|
928833
|
-
this.logAtLevelWithOverrides(
|
|
928659
|
+
this.logAtLevelWithOverrides(LogLevel2.Error, ["Failed."], {
|
|
928834
928660
|
omitOnTTY: true
|
|
928835
928661
|
});
|
|
928836
928662
|
}
|
|
@@ -929158,7 +928984,7 @@ var CliContext = class _CliContext {
|
|
|
929158
928984
|
didSucceed = true;
|
|
929159
928985
|
numTasks = 0;
|
|
929160
928986
|
ttyAwareLogger;
|
|
929161
|
-
logLevel =
|
|
928987
|
+
logLevel = LogLevel2.Info;
|
|
929162
928988
|
isLocal;
|
|
929163
928989
|
stdoutRedirector = new StdoutRedirector();
|
|
929164
928990
|
jsonMode = false;
|
|
@@ -929193,7 +929019,7 @@ var CliContext = class _CliContext {
|
|
|
929193
929019
|
if (false) {
|
|
929194
929020
|
this.logger.error("CLI_VERSION is not defined");
|
|
929195
929021
|
}
|
|
929196
|
-
return "4.68.3
|
|
929022
|
+
return "4.68.3";
|
|
929197
929023
|
}
|
|
929198
929024
|
getCliName() {
|
|
929199
929025
|
if (false) {
|
|
@@ -929209,17 +929035,13 @@ var CliContext = class _CliContext {
|
|
|
929209
929035
|
`Running ${source_default.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`
|
|
929210
929036
|
);
|
|
929211
929037
|
}
|
|
929212
|
-
failAndThrow(message, error50
|
|
929213
|
-
this.failWithoutThrowing(message, error50
|
|
929038
|
+
failAndThrow(message, error50) {
|
|
929039
|
+
this.failWithoutThrowing(message, error50);
|
|
929214
929040
|
throw new TaskAbortSignal();
|
|
929215
929041
|
}
|
|
929216
|
-
failWithoutThrowing(message, error50
|
|
929042
|
+
failWithoutThrowing(message, error50) {
|
|
929217
929043
|
this.didSucceed = false;
|
|
929218
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
929219
|
-
return;
|
|
929220
|
-
}
|
|
929221
929044
|
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
929222
|
-
reportError2(this, error50, { ...options2, message });
|
|
929223
929045
|
}
|
|
929224
929046
|
/**
|
|
929225
929047
|
* Activate JSON-output mode: all logger output is forced to stderr
|
|
@@ -929322,7 +929144,15 @@ var CliContext = class _CliContext {
|
|
|
929322
929144
|
try {
|
|
929323
929145
|
result = await run(context3);
|
|
929324
929146
|
} catch (error50) {
|
|
929325
|
-
|
|
929147
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
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
|
+
}
|
|
929326
929156
|
throw new TaskAbortSignal();
|
|
929327
929157
|
} finally {
|
|
929328
929158
|
context3.finish();
|
|
@@ -929334,11 +929164,11 @@ var CliContext = class _CliContext {
|
|
|
929334
929164
|
this.posthogManager.sendEvent(event);
|
|
929335
929165
|
}
|
|
929336
929166
|
}
|
|
929337
|
-
captureException(error50
|
|
929338
|
-
this.sentryClient.captureException(error50
|
|
929167
|
+
async captureException(error50) {
|
|
929168
|
+
await this.sentryClient.captureException(error50);
|
|
929339
929169
|
}
|
|
929340
|
-
logger =
|
|
929341
|
-
stderr =
|
|
929170
|
+
logger = createLogger4((level, ...args) => this.log(level, ...args));
|
|
929171
|
+
stderr = createLogger4((level, ...args) => this.logStderr(level, ...args));
|
|
929342
929172
|
constructTaskInitForWorkspace(workspace) {
|
|
929343
929173
|
const prefixWithoutPadding = wrapWorkspaceNameForPrefix(
|
|
929344
929174
|
workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api"
|
|
@@ -929364,10 +929194,7 @@ var CliContext = class _CliContext {
|
|
|
929364
929194
|
instrumentPostHogEvent: (event) => {
|
|
929365
929195
|
this.instrumentPostHogEvent(event);
|
|
929366
929196
|
},
|
|
929367
|
-
shouldBufferLogs: false
|
|
929368
|
-
captureException: (error50, code5) => {
|
|
929369
|
-
this.sentryClient.captureException(error50, code5);
|
|
929370
|
-
}
|
|
929197
|
+
shouldBufferLogs: false
|
|
929371
929198
|
};
|
|
929372
929199
|
}
|
|
929373
929200
|
log(level, ...parts) {
|
|
@@ -929394,7 +929221,7 @@ var CliContext = class _CliContext {
|
|
|
929394
929221
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
929395
929222
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
929396
929223
|
this.ttyAwareLogger.log(filtered, {
|
|
929397
|
-
includeDebugInfo: this.logLevel ===
|
|
929224
|
+
includeDebugInfo: this.logLevel === LogLevel2.Debug,
|
|
929398
929225
|
stderr: stderr || this.jsonMode
|
|
929399
929226
|
});
|
|
929400
929227
|
}
|
|
@@ -947368,6 +947195,7 @@ function evaluateRuntime4() {
|
|
|
947368
947195
|
|
|
947369
947196
|
// src/cli.ts
|
|
947370
947197
|
void runCli();
|
|
947198
|
+
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
947371
947199
|
async function runCli() {
|
|
947372
947200
|
getOrCreateFernRunId();
|
|
947373
947201
|
const isLocal = process.argv.includes("--local");
|
|
@@ -947405,7 +947233,24 @@ async function runCli() {
|
|
|
947405
947233
|
});
|
|
947406
947234
|
}
|
|
947407
947235
|
} catch (error50) {
|
|
947408
|
-
cliContext.
|
|
947236
|
+
cliContext.instrumentPostHogEvent({
|
|
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
|
+
}
|
|
947409
947254
|
}
|
|
947410
947255
|
await exit3();
|
|
947411
947256
|
}
|
|
@@ -947436,7 +947281,7 @@ async function tryRunCli(cliContext) {
|
|
|
947436
947281
|
}
|
|
947437
947282
|
}
|
|
947438
947283
|
).option("log-level", {
|
|
947439
|
-
default:
|
|
947284
|
+
default: LogLevel2.Info,
|
|
947440
947285
|
choices: LOG_LEVELS
|
|
947441
947286
|
}).demandCommand().recommendCommands();
|
|
947442
947287
|
addDiffCommand(cli, cliContext);
|