@fern-api/fern-api-dev 5.81.0 → 5.83.0
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 +566 -55
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -73646,6 +73646,7 @@ var init_OAuthAuthorizationCode2 = __esm({
|
|
|
73646
73646
|
tokenUrl: schemas_exports3.string(),
|
|
73647
73647
|
refreshUrl: schemas_exports3.string().optional(),
|
|
73648
73648
|
redirectUri: schemas_exports3.string().optional(),
|
|
73649
|
+
redirectUriBackupPorts: schemas_exports3.list(schemas_exports3.number()).optional(),
|
|
73649
73650
|
scopes: schemas_exports3.list(schemas_exports3.string()).optional(),
|
|
73650
73651
|
pkce: OAuthPkceConfiguration,
|
|
73651
73652
|
authorizationParameters: schemas_exports3.record(schemas_exports3.string(), schemas_exports3.string()).optional(),
|
|
@@ -102386,6 +102387,7 @@ var init_latest_version = __esm({
|
|
|
102386
102387
|
"../../../node_modules/.pnpm/latest-version@9.0.0/node_modules/latest-version/index.js"() {
|
|
102387
102388
|
"use strict";
|
|
102388
102389
|
init_package_json();
|
|
102390
|
+
init_package_json();
|
|
102389
102391
|
}
|
|
102390
102392
|
});
|
|
102391
102393
|
|
|
@@ -311806,23 +311808,6 @@ var init_lib26 = __esm({
|
|
|
311806
311808
|
}
|
|
311807
311809
|
});
|
|
311808
311810
|
|
|
311809
|
-
// ../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js
|
|
311810
|
-
function semverDiff(versionA, versionB) {
|
|
311811
|
-
versionA = import_semver11.default.parse(versionA);
|
|
311812
|
-
versionB = import_semver11.default.parse(versionB);
|
|
311813
|
-
if (import_semver11.default.compareBuild(versionA, versionB) >= 0) {
|
|
311814
|
-
return;
|
|
311815
|
-
}
|
|
311816
|
-
return import_semver11.default.diff(versionA, versionB) || "build";
|
|
311817
|
-
}
|
|
311818
|
-
var import_semver11;
|
|
311819
|
-
var init_semver_diff = __esm({
|
|
311820
|
-
"../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js"() {
|
|
311821
|
-
"use strict";
|
|
311822
|
-
import_semver11 = __toESM(require_semver2(), 1);
|
|
311823
|
-
}
|
|
311824
|
-
});
|
|
311825
|
-
|
|
311826
311811
|
// ../semver-utils/lib/parseVersion.js
|
|
311827
311812
|
function parseVersion(versionString) {
|
|
311828
311813
|
const alphaMatch = versionString.match(ALPHA_VERSION_REGEX);
|
|
@@ -311958,6 +311943,39 @@ var init_parseVersion = __esm({
|
|
|
311958
311943
|
}
|
|
311959
311944
|
});
|
|
311960
311945
|
|
|
311946
|
+
// ../semver-utils/lib/isValidVersion.js
|
|
311947
|
+
function isValidVersion(versionString) {
|
|
311948
|
+
try {
|
|
311949
|
+
parseVersion(versionString);
|
|
311950
|
+
return true;
|
|
311951
|
+
} catch {
|
|
311952
|
+
return false;
|
|
311953
|
+
}
|
|
311954
|
+
}
|
|
311955
|
+
var init_isValidVersion = __esm({
|
|
311956
|
+
"../semver-utils/lib/isValidVersion.js"() {
|
|
311957
|
+
"use strict";
|
|
311958
|
+
init_parseVersion();
|
|
311959
|
+
}
|
|
311960
|
+
});
|
|
311961
|
+
|
|
311962
|
+
// ../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js
|
|
311963
|
+
function semverDiff(versionA, versionB) {
|
|
311964
|
+
versionA = import_semver11.default.parse(versionA);
|
|
311965
|
+
versionB = import_semver11.default.parse(versionB);
|
|
311966
|
+
if (import_semver11.default.compareBuild(versionA, versionB) >= 0) {
|
|
311967
|
+
return;
|
|
311968
|
+
}
|
|
311969
|
+
return import_semver11.default.diff(versionA, versionB) || "build";
|
|
311970
|
+
}
|
|
311971
|
+
var import_semver11;
|
|
311972
|
+
var init_semver_diff = __esm({
|
|
311973
|
+
"../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js"() {
|
|
311974
|
+
"use strict";
|
|
311975
|
+
import_semver11 = __toESM(require_semver2(), 1);
|
|
311976
|
+
}
|
|
311977
|
+
});
|
|
311978
|
+
|
|
311961
311979
|
// ../semver-utils/lib/isVersionAhead.js
|
|
311962
311980
|
function isVersionAhead(a3, b5) {
|
|
311963
311981
|
if (a3 === b5) {
|
|
@@ -312046,6 +312064,7 @@ var init_isVersionAhead = __esm({
|
|
|
312046
312064
|
var init_lib27 = __esm({
|
|
312047
312065
|
"../semver-utils/lib/index.js"() {
|
|
312048
312066
|
"use strict";
|
|
312067
|
+
init_isValidVersion();
|
|
312049
312068
|
init_isVersionAhead();
|
|
312050
312069
|
init_parseVersion();
|
|
312051
312070
|
}
|
|
@@ -692006,7 +692025,7 @@ var AccessTokenPosthogManager = class {
|
|
|
692006
692025
|
properties: {
|
|
692007
692026
|
...event,
|
|
692008
692027
|
...event.properties,
|
|
692009
|
-
version: "5.
|
|
692028
|
+
version: "5.83.0",
|
|
692010
692029
|
usingAccessToken: true,
|
|
692011
692030
|
...getRunIdProperties()
|
|
692012
692031
|
}
|
|
@@ -692072,7 +692091,7 @@ var UserPosthogManager = class {
|
|
|
692072
692091
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
692073
692092
|
event: "CLI",
|
|
692074
692093
|
properties: {
|
|
692075
|
-
version: "5.
|
|
692094
|
+
version: "5.83.0",
|
|
692076
692095
|
...event,
|
|
692077
692096
|
...event.properties,
|
|
692078
692097
|
usingAccessToken: false,
|
|
@@ -873178,7 +873197,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
873178
873197
|
var LOGS_FOLDER_NAME = "logs";
|
|
873179
873198
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
873180
873199
|
function getCliSource() {
|
|
873181
|
-
const version7 = "5.
|
|
873200
|
+
const version7 = "5.83.0";
|
|
873182
873201
|
return `cli@${version7}`;
|
|
873183
873202
|
}
|
|
873184
873203
|
var DebugLogger = class {
|
|
@@ -905874,7 +905893,7 @@ var LegacyDocsPublisher = class {
|
|
|
905874
905893
|
previewId,
|
|
905875
905894
|
disableTemplates: void 0,
|
|
905876
905895
|
skipUpload,
|
|
905877
|
-
cliVersion: "5.
|
|
905896
|
+
cliVersion: "5.83.0",
|
|
905878
905897
|
loginCommand: "fern auth login"
|
|
905879
905898
|
});
|
|
905880
905899
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -956414,6 +956433,15 @@ var TypescriptCustomConfigSchema = external_exports2.strictObject({
|
|
|
956414
956433
|
customPagerName: external_exports2.optional(external_exports2.string()),
|
|
956415
956434
|
resolveQueryParameterNameConflicts: external_exports2.optional(external_exports2.boolean()),
|
|
956416
956435
|
alwaysSendAuth: external_exports2.optional(external_exports2.boolean()),
|
|
956436
|
+
// When true, makes client auth parameters optional even when the spec
|
|
956437
|
+
// mandates auth on all endpoints (isAuthMandatory=true), and sends requests
|
|
956438
|
+
// unauthenticated instead of throwing when no credentials are supplied.
|
|
956439
|
+
// Useful for hand-maintained wrapper clients that authenticate via external
|
|
956440
|
+
// means. Orthogonal to `alwaysSendAuth`, which decides which endpoints get
|
|
956441
|
+
// auth headers: with both enabled, endpoints that don't require auth still
|
|
956442
|
+
// get auth headers when credentials are supplied, and no endpoint gets them
|
|
956443
|
+
// when credentials are absent.
|
|
956444
|
+
"optional-auth": external_exports2.optional(external_exports2.boolean()),
|
|
956417
956445
|
generateReactQueryHooks: external_exports2.optional(external_exports2.boolean()),
|
|
956418
956446
|
// beta (not in docs)
|
|
956419
956447
|
includeContentHeadersOnFileDownloadResponse: external_exports2.optional(external_exports2.boolean()),
|
|
@@ -972739,7 +972767,7 @@ function getAutomationContextFromEnv() {
|
|
|
972739
972767
|
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
972740
972768
|
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
972741
972769
|
trigger: process.env.GITHUB_EVENT_NAME,
|
|
972742
|
-
cli_version: "5.
|
|
972770
|
+
cli_version: "5.83.0"
|
|
972743
972771
|
};
|
|
972744
972772
|
}
|
|
972745
972773
|
function isAutomationMode() {
|
|
@@ -973571,7 +973599,7 @@ var CliContext = class _CliContext {
|
|
|
973571
973599
|
if (false) {
|
|
973572
973600
|
this.logger.error("CLI_VERSION is not defined");
|
|
973573
973601
|
}
|
|
973574
|
-
return "5.
|
|
973602
|
+
return "5.83.0";
|
|
973575
973603
|
}
|
|
973576
973604
|
getCliName() {
|
|
973577
973605
|
if (false) {
|
|
@@ -980960,6 +980988,341 @@ async function rerunFernCliAtVersion({
|
|
|
980960
980988
|
}
|
|
980961
980989
|
}
|
|
980962
980990
|
|
|
980991
|
+
// src/commands/org/orgConfig.ts
|
|
980992
|
+
init_lib19();
|
|
980993
|
+
init_lib27();
|
|
980994
|
+
init_lib6();
|
|
980995
|
+
init_source();
|
|
980996
|
+
init_latest_version();
|
|
980997
|
+
|
|
980998
|
+
// src/commands/docs-theme/themeOrigin.ts
|
|
980999
|
+
var FDR_ORIGIN = process.env.OVERRIDE_FDR_ORIGIN ?? "https://registry-dev2.buildwithfern.com" ?? "https://registry.buildwithfern.com";
|
|
981000
|
+
function describeFetchError(error50) {
|
|
981001
|
+
if (!(error50 instanceof Error)) {
|
|
981002
|
+
return String(error50);
|
|
981003
|
+
}
|
|
981004
|
+
const cause = error50.cause;
|
|
981005
|
+
if (cause instanceof Error) {
|
|
981006
|
+
return cause.message;
|
|
981007
|
+
}
|
|
981008
|
+
return error50.message;
|
|
981009
|
+
}
|
|
981010
|
+
function parseErrorDetail(body) {
|
|
981011
|
+
try {
|
|
981012
|
+
const parsed = JSON.parse(body);
|
|
981013
|
+
const message = parsed.message ?? parsed.error?.message;
|
|
981014
|
+
if (typeof message === "string") {
|
|
981015
|
+
return message;
|
|
981016
|
+
}
|
|
981017
|
+
} catch {
|
|
981018
|
+
}
|
|
981019
|
+
return void 0;
|
|
981020
|
+
}
|
|
981021
|
+
|
|
981022
|
+
// src/commands/org/orgConfig.ts
|
|
981023
|
+
function clampVersionToOrgBounds(intendedVersion, { min, max }) {
|
|
981024
|
+
const isPinned = min != null && max != null && min === max;
|
|
981025
|
+
if (min != null && isVersionAhead(min, intendedVersion)) {
|
|
981026
|
+
return { version: min, reason: isPinned ? "pin" : "floor" };
|
|
981027
|
+
}
|
|
981028
|
+
if (max != null && isVersionAhead(intendedVersion, max)) {
|
|
981029
|
+
return { version: max, reason: isPinned ? "pin" : "ceiling" };
|
|
981030
|
+
}
|
|
981031
|
+
return { version: intendedVersion };
|
|
981032
|
+
}
|
|
981033
|
+
async function getAuthToken(cliContext) {
|
|
981034
|
+
const token = await cliContext.runTask(async (context3) => {
|
|
981035
|
+
return askToLogin(context3);
|
|
981036
|
+
});
|
|
981037
|
+
if (token == null) {
|
|
981038
|
+
return cliContext.failAndThrow("Failed to authenticate. Please run 'fern login' first.", void 0, {
|
|
981039
|
+
code: CliError.Code.AuthError
|
|
981040
|
+
});
|
|
981041
|
+
}
|
|
981042
|
+
return token;
|
|
981043
|
+
}
|
|
981044
|
+
async function resolveOrgId(cliContext, orgOverride) {
|
|
981045
|
+
if (orgOverride != null) {
|
|
981046
|
+
return orgOverride;
|
|
981047
|
+
}
|
|
981048
|
+
const fernDirectory = await getFernDirectory();
|
|
981049
|
+
if (fernDirectory == null) {
|
|
981050
|
+
return cliContext.failAndThrow(
|
|
981051
|
+
`Directory "${FERN_DIRECTORY}" not found. Run from a Fern project or pass --org.`,
|
|
981052
|
+
void 0,
|
|
981053
|
+
{ code: CliError.Code.ConfigError }
|
|
981054
|
+
);
|
|
981055
|
+
}
|
|
981056
|
+
const projectConfig = await cliContext.runTask(
|
|
981057
|
+
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
981058
|
+
);
|
|
981059
|
+
return projectConfig.organization;
|
|
981060
|
+
}
|
|
981061
|
+
async function orgConfigRequest(context3, orgId, init3, actionLabel) {
|
|
981062
|
+
let res;
|
|
981063
|
+
try {
|
|
981064
|
+
res = await fetch(`${FDR_ORIGIN}/v2/registry/org-config/${orgId}`, init3);
|
|
981065
|
+
} catch (err) {
|
|
981066
|
+
return context3.failAndThrow(`Failed to reach FDR: ${describeFetchError(err)}`, void 0, {
|
|
981067
|
+
code: CliError.Code.NetworkError
|
|
981068
|
+
});
|
|
981069
|
+
}
|
|
981070
|
+
if (!res.ok) {
|
|
981071
|
+
const body = await res.text();
|
|
981072
|
+
const detail = parseErrorDetail(body) ?? body;
|
|
981073
|
+
return context3.failAndThrow(`Failed to ${actionLabel}: HTTP ${res.status} \u2014 ${detail}`, void 0, {
|
|
981074
|
+
code: CliError.Code.NetworkError
|
|
981075
|
+
});
|
|
981076
|
+
}
|
|
981077
|
+
return res;
|
|
981078
|
+
}
|
|
981079
|
+
async function getOrgConfig({
|
|
981080
|
+
cliContext,
|
|
981081
|
+
org,
|
|
981082
|
+
json: json2
|
|
981083
|
+
}) {
|
|
981084
|
+
const token = await getAuthToken(cliContext);
|
|
981085
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981086
|
+
await cliContext.runTask(async (context3) => {
|
|
981087
|
+
const res = await orgConfigRequest(
|
|
981088
|
+
context3,
|
|
981089
|
+
orgId,
|
|
981090
|
+
{ headers: { Authorization: `Bearer ${token.value}` } },
|
|
981091
|
+
"get org config"
|
|
981092
|
+
);
|
|
981093
|
+
const data2 = await res.json();
|
|
981094
|
+
if (json2) {
|
|
981095
|
+
process.stdout.write(JSON.stringify(data2, null, 2) + "\n");
|
|
981096
|
+
return;
|
|
981097
|
+
}
|
|
981098
|
+
if (data2.cliVersionMin == null && data2.cliVersionMax == null) {
|
|
981099
|
+
context3.logger.info(`No org-level CLI config set for "${orgId}".`);
|
|
981100
|
+
return;
|
|
981101
|
+
}
|
|
981102
|
+
const { cliVersionMin, cliVersionMax } = data2;
|
|
981103
|
+
if (cliVersionMin != null && cliVersionMin === cliVersionMax) {
|
|
981104
|
+
context3.logger.info(`Fern CLI pinned to ${source_default.green(cliVersionMin)}`);
|
|
981105
|
+
} else if (cliVersionMin != null && cliVersionMax != null) {
|
|
981106
|
+
context3.logger.info(
|
|
981107
|
+
`Fern CLI must be between ${source_default.green(cliVersionMin)} and ${source_default.green(cliVersionMax)}`
|
|
981108
|
+
);
|
|
981109
|
+
} else if (cliVersionMin != null) {
|
|
981110
|
+
context3.logger.info(`Fern CLI must be at least ${source_default.green(cliVersionMin)}`);
|
|
981111
|
+
} else if (cliVersionMax != null) {
|
|
981112
|
+
context3.logger.info(`Fern CLI must be at most ${source_default.green(cliVersionMax)}`);
|
|
981113
|
+
}
|
|
981114
|
+
});
|
|
981115
|
+
}
|
|
981116
|
+
var FERN_CLI_PACKAGE_NAME = "fern-api";
|
|
981117
|
+
async function assertCliVersionIsPublished(cliContext, version7) {
|
|
981118
|
+
try {
|
|
981119
|
+
await latestVersion(FERN_CLI_PACKAGE_NAME, { version: version7 });
|
|
981120
|
+
} catch (err) {
|
|
981121
|
+
if (err instanceof VersionNotFoundError) {
|
|
981122
|
+
cliContext.failAndThrow(
|
|
981123
|
+
`Fern CLI version "${version7}" was not found on npm. Set a published version \u2014 see https://www.npmjs.com/package/${FERN_CLI_PACKAGE_NAME}?activeTab=versions.`,
|
|
981124
|
+
void 0,
|
|
981125
|
+
{ code: CliError.Code.ConfigError }
|
|
981126
|
+
);
|
|
981127
|
+
return;
|
|
981128
|
+
}
|
|
981129
|
+
cliContext.logger.debug(`Could not verify Fern CLI version "${version7}" exists on npm: ${String(err)}`);
|
|
981130
|
+
}
|
|
981131
|
+
}
|
|
981132
|
+
async function setOrgCliVersion({
|
|
981133
|
+
cliContext,
|
|
981134
|
+
min,
|
|
981135
|
+
max,
|
|
981136
|
+
org
|
|
981137
|
+
}) {
|
|
981138
|
+
for (const version7 of [min, max]) {
|
|
981139
|
+
if (version7 != null && !isValidVersion(version7)) {
|
|
981140
|
+
cliContext.failAndThrow(
|
|
981141
|
+
`"${version7}" isn't a valid version. Pass an exact published version like 5.45.0 (or a prerelease like 5.45.0-rc0) \u2014 see https://www.npmjs.com/package/${FERN_CLI_PACKAGE_NAME}?activeTab=versions.`,
|
|
981142
|
+
void 0,
|
|
981143
|
+
{ code: CliError.Code.ConfigError }
|
|
981144
|
+
);
|
|
981145
|
+
return;
|
|
981146
|
+
}
|
|
981147
|
+
}
|
|
981148
|
+
if (min != null && max != null && isVersionAhead(min, max)) {
|
|
981149
|
+
cliContext.failAndThrow(`Minimum version ${min} must not be greater than maximum version ${max}.`, void 0, {
|
|
981150
|
+
code: CliError.Code.ConfigError
|
|
981151
|
+
});
|
|
981152
|
+
return;
|
|
981153
|
+
}
|
|
981154
|
+
for (const version7 of [min, max]) {
|
|
981155
|
+
if (version7 != null) {
|
|
981156
|
+
await assertCliVersionIsPublished(cliContext, version7);
|
|
981157
|
+
}
|
|
981158
|
+
}
|
|
981159
|
+
const token = await getAuthToken(cliContext);
|
|
981160
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981161
|
+
const requestBody = {};
|
|
981162
|
+
if (min != null) {
|
|
981163
|
+
requestBody.cliVersionMin = min;
|
|
981164
|
+
}
|
|
981165
|
+
if (max != null) {
|
|
981166
|
+
requestBody.cliVersionMax = max;
|
|
981167
|
+
}
|
|
981168
|
+
await cliContext.runTask(async (context3) => {
|
|
981169
|
+
await orgConfigRequest(
|
|
981170
|
+
context3,
|
|
981171
|
+
orgId,
|
|
981172
|
+
{
|
|
981173
|
+
method: "PUT",
|
|
981174
|
+
headers: {
|
|
981175
|
+
Authorization: `Bearer ${token.value}`,
|
|
981176
|
+
"Content-Type": "application/json"
|
|
981177
|
+
},
|
|
981178
|
+
body: JSON.stringify(requestBody)
|
|
981179
|
+
},
|
|
981180
|
+
"set org config"
|
|
981181
|
+
);
|
|
981182
|
+
if (min != null && max != null && min === max) {
|
|
981183
|
+
context3.logger.info(`Pinned CLI version to ${source_default.green(min)} for org "${orgId}".`);
|
|
981184
|
+
} else if (min != null && max != null) {
|
|
981185
|
+
context3.logger.info(`Set CLI version range to ${source_default.green(`${min} \u2013 ${max}`)} for org "${orgId}".`);
|
|
981186
|
+
} else if (min != null) {
|
|
981187
|
+
context3.logger.info(`Set minimum CLI version to ${source_default.green(min)} for org "${orgId}".`);
|
|
981188
|
+
} else if (max != null) {
|
|
981189
|
+
context3.logger.info(`Set maximum CLI version to ${source_default.green(max)} for org "${orgId}".`);
|
|
981190
|
+
}
|
|
981191
|
+
});
|
|
981192
|
+
}
|
|
981193
|
+
async function unsetOrgCliVersion({
|
|
981194
|
+
cliContext,
|
|
981195
|
+
org,
|
|
981196
|
+
field: field5
|
|
981197
|
+
}) {
|
|
981198
|
+
const token = await getAuthToken(cliContext);
|
|
981199
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981200
|
+
await cliContext.runTask(async (context3) => {
|
|
981201
|
+
const init3 = field5 === "all" ? { method: "DELETE", headers: { Authorization: `Bearer ${token.value}` } } : {
|
|
981202
|
+
method: "PUT",
|
|
981203
|
+
headers: {
|
|
981204
|
+
Authorization: `Bearer ${token.value}`,
|
|
981205
|
+
"Content-Type": "application/json"
|
|
981206
|
+
},
|
|
981207
|
+
body: JSON.stringify(field5 === "min" ? { cliVersionMin: null } : { cliVersionMax: null })
|
|
981208
|
+
};
|
|
981209
|
+
await orgConfigRequest(context3, orgId, init3, "unset org config");
|
|
981210
|
+
const label = field5 === "min" ? "minimum" : field5 === "max" ? "maximum" : "minimum and maximum";
|
|
981211
|
+
context3.logger.info(`Removed ${label} CLI version for org "${orgId}".`);
|
|
981212
|
+
});
|
|
981213
|
+
}
|
|
981214
|
+
function sanitizeBound(version7) {
|
|
981215
|
+
return version7 != null && isValidVersion(version7) ? version7 : void 0;
|
|
981216
|
+
}
|
|
981217
|
+
async function fetchOrgCliVersionBounds({
|
|
981218
|
+
cliContext,
|
|
981219
|
+
orgId,
|
|
981220
|
+
token,
|
|
981221
|
+
timeoutMs
|
|
981222
|
+
}) {
|
|
981223
|
+
try {
|
|
981224
|
+
const res = await fetch(`${FDR_ORIGIN}/v2/registry/org-config/${orgId}`, {
|
|
981225
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
981226
|
+
signal: timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0
|
|
981227
|
+
});
|
|
981228
|
+
if (!res.ok) {
|
|
981229
|
+
cliContext.logger.debug(`Failed to fetch org config: HTTP ${res.status}`);
|
|
981230
|
+
return { ok: false };
|
|
981231
|
+
}
|
|
981232
|
+
const data2 = await res.json();
|
|
981233
|
+
return {
|
|
981234
|
+
ok: true,
|
|
981235
|
+
bounds: { min: sanitizeBound(data2.cliVersionMin), max: sanitizeBound(data2.cliVersionMax) }
|
|
981236
|
+
};
|
|
981237
|
+
} catch (err) {
|
|
981238
|
+
cliContext.logger.debug(`Failed to fetch org config: ${describeFetchError(err)}`);
|
|
981239
|
+
return { ok: false };
|
|
981240
|
+
}
|
|
981241
|
+
}
|
|
981242
|
+
var ORG_BOUNDS_FETCH_TIMEOUT_MS = 2500;
|
|
981243
|
+
async function getOrgCliVersionBounds({
|
|
981244
|
+
cliContext,
|
|
981245
|
+
orgId
|
|
981246
|
+
}) {
|
|
981247
|
+
if (process.env.FERN_IGNORE_ORG_VERSION_BOUNDS === "true" || process.env.FERN_IGNORE_ORG_VERSION_FLOOR === "true") {
|
|
981248
|
+
return {};
|
|
981249
|
+
}
|
|
981250
|
+
try {
|
|
981251
|
+
const token = await getToken2();
|
|
981252
|
+
if (token == null) {
|
|
981253
|
+
return {};
|
|
981254
|
+
}
|
|
981255
|
+
const result = await fetchOrgCliVersionBounds({
|
|
981256
|
+
cliContext,
|
|
981257
|
+
orgId,
|
|
981258
|
+
token: token.value,
|
|
981259
|
+
timeoutMs: ORG_BOUNDS_FETCH_TIMEOUT_MS
|
|
981260
|
+
});
|
|
981261
|
+
if (!result.ok) {
|
|
981262
|
+
return {};
|
|
981263
|
+
}
|
|
981264
|
+
return result.bounds;
|
|
981265
|
+
} catch (err) {
|
|
981266
|
+
cliContext.logger.debug(`Failed to resolve org CLI version bounds: ${String(err)}`);
|
|
981267
|
+
return {};
|
|
981268
|
+
}
|
|
981269
|
+
}
|
|
981270
|
+
async function resolveClampedVersionForOrg({
|
|
981271
|
+
cliContext,
|
|
981272
|
+
orgId,
|
|
981273
|
+
version: version7
|
|
981274
|
+
}) {
|
|
981275
|
+
const bounds = await getOrgCliVersionBounds({ cliContext, orgId });
|
|
981276
|
+
try {
|
|
981277
|
+
return { ...clampVersionToOrgBounds(version7, bounds), bounds };
|
|
981278
|
+
} catch {
|
|
981279
|
+
return { version: version7, bounds };
|
|
981280
|
+
}
|
|
981281
|
+
}
|
|
981282
|
+
function describeOrgBounds(orgId, { min, max }, color3) {
|
|
981283
|
+
if (min != null && max != null && min === max) {
|
|
981284
|
+
return `Org "${orgId}" pins Fern CLI to ${color3(min)}`;
|
|
981285
|
+
}
|
|
981286
|
+
if (min != null && max != null) {
|
|
981287
|
+
return `Org "${orgId}" requires Fern CLI between ${color3(min)} and ${color3(max)}`;
|
|
981288
|
+
}
|
|
981289
|
+
if (min != null) {
|
|
981290
|
+
return `Org "${orgId}" requires Fern CLI ${color3(`>= ${min}`)}`;
|
|
981291
|
+
}
|
|
981292
|
+
if (max != null) {
|
|
981293
|
+
return `Org "${orgId}" caps Fern CLI at ${color3(`<= ${max}`)}`;
|
|
981294
|
+
}
|
|
981295
|
+
return `Org "${orgId}"`;
|
|
981296
|
+
}
|
|
981297
|
+
async function applyOrgBoundsToVersion({
|
|
981298
|
+
cliContext,
|
|
981299
|
+
orgId,
|
|
981300
|
+
intendedVersion
|
|
981301
|
+
}) {
|
|
981302
|
+
const { version: version7, reason, bounds } = await resolveClampedVersionForOrg({
|
|
981303
|
+
cliContext,
|
|
981304
|
+
orgId,
|
|
981305
|
+
version: intendedVersion
|
|
981306
|
+
});
|
|
981307
|
+
if (reason != null) {
|
|
981308
|
+
cliContext.logger.info(`${describeOrgBounds(orgId, bounds, source_default.green)} \u2014 running ${source_default.green(version7)}.`);
|
|
981309
|
+
}
|
|
981310
|
+
return version7;
|
|
981311
|
+
}
|
|
981312
|
+
async function warnIfVersionOutsideOrgBounds({
|
|
981313
|
+
cliContext,
|
|
981314
|
+
orgId,
|
|
981315
|
+
currentVersion
|
|
981316
|
+
}) {
|
|
981317
|
+
const { reason, bounds } = await resolveClampedVersionForOrg({ cliContext, orgId, version: currentVersion });
|
|
981318
|
+
if (reason != null) {
|
|
981319
|
+
const suffix = reason === "ceiling" ? "was not downgraded" : reason === "floor" ? "was not upgraded" : "was not changed";
|
|
981320
|
+
cliContext.logger.warn(
|
|
981321
|
+
`${describeOrgBounds(orgId, bounds, source_default.yellow)}, but this CLI is ${source_default.yellow(currentVersion)}. Version redirection is disabled, so it ${suffix}.`
|
|
981322
|
+
);
|
|
981323
|
+
}
|
|
981324
|
+
}
|
|
981325
|
+
|
|
980963
981326
|
// src/commands/upgrade/upgrade.ts
|
|
980964
981327
|
var PREVIOUS_VERSION_ENV_VAR = "FERN_PRE_UPGRADE_VERSION";
|
|
980965
981328
|
function ensureFinalNewline(content5) {
|
|
@@ -981190,6 +981553,19 @@ async function upgrade({
|
|
|
981190
981553
|
}
|
|
981191
981554
|
}
|
|
981192
981555
|
}
|
|
981556
|
+
if (resolvedTargetVersion == null) {
|
|
981557
|
+
cliContext.logger.info("No upgrade available.");
|
|
981558
|
+
return;
|
|
981559
|
+
}
|
|
981560
|
+
if (!isLocalDev) {
|
|
981561
|
+
try {
|
|
981562
|
+
resolvedTargetVersion = await applyOrgVersionBounds({
|
|
981563
|
+
cliContext,
|
|
981564
|
+
resolvedTargetVersion
|
|
981565
|
+
});
|
|
981566
|
+
} catch {
|
|
981567
|
+
}
|
|
981568
|
+
}
|
|
981193
981569
|
if (cliContext.environment.packageVersion === resolvedTargetVersion || isLocalDev) {
|
|
981194
981570
|
const fernDirectory2 = await getFernDirectory();
|
|
981195
981571
|
if (fernDirectory2 == null) {
|
|
@@ -981287,6 +981663,56 @@ async function upgrade({
|
|
|
981287
981663
|
throw error50;
|
|
981288
981664
|
}
|
|
981289
981665
|
}
|
|
981666
|
+
async function applyOrgVersionBounds({
|
|
981667
|
+
cliContext,
|
|
981668
|
+
resolvedTargetVersion
|
|
981669
|
+
}) {
|
|
981670
|
+
const fernDirectory = await getFernDirectory();
|
|
981671
|
+
if (fernDirectory == null) {
|
|
981672
|
+
return resolvedTargetVersion;
|
|
981673
|
+
}
|
|
981674
|
+
let orgId;
|
|
981675
|
+
try {
|
|
981676
|
+
const projectConfig = await cliContext.runTask(
|
|
981677
|
+
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
981678
|
+
);
|
|
981679
|
+
orgId = projectConfig.organization;
|
|
981680
|
+
} catch {
|
|
981681
|
+
return resolvedTargetVersion;
|
|
981682
|
+
}
|
|
981683
|
+
const token = await getToken2();
|
|
981684
|
+
if (token == null) {
|
|
981685
|
+
return resolvedTargetVersion;
|
|
981686
|
+
}
|
|
981687
|
+
const result = await fetchOrgCliVersionBounds({
|
|
981688
|
+
cliContext,
|
|
981689
|
+
orgId,
|
|
981690
|
+
token: token.value,
|
|
981691
|
+
timeoutMs: ORG_BOUNDS_FETCH_TIMEOUT_MS
|
|
981692
|
+
});
|
|
981693
|
+
if (!result.ok) {
|
|
981694
|
+
return resolvedTargetVersion;
|
|
981695
|
+
}
|
|
981696
|
+
const { min, max } = result.bounds;
|
|
981697
|
+
if (min == null && max == null) {
|
|
981698
|
+
return resolvedTargetVersion;
|
|
981699
|
+
}
|
|
981700
|
+
try {
|
|
981701
|
+
const { version: version7, reason } = clampVersionToOrgBounds(resolvedTargetVersion, { min, max });
|
|
981702
|
+
if (reason === "floor") {
|
|
981703
|
+
cliContext.logger.info(
|
|
981704
|
+
`Org "${orgId}" requires minimum CLI version ${source_default.green(version7)} (resolved ${resolvedTargetVersion}).`
|
|
981705
|
+
);
|
|
981706
|
+
} else if (reason === "ceiling") {
|
|
981707
|
+
cliContext.logger.info(
|
|
981708
|
+
`Org "${orgId}" caps CLI version at ${source_default.green(version7)} (resolved ${resolvedTargetVersion}).`
|
|
981709
|
+
);
|
|
981710
|
+
}
|
|
981711
|
+
return version7;
|
|
981712
|
+
} catch {
|
|
981713
|
+
return resolvedTargetVersion;
|
|
981714
|
+
}
|
|
981715
|
+
}
|
|
981290
981716
|
|
|
981291
981717
|
// src/commands/automations/upgrade/executeAutomationsUpgrade.ts
|
|
981292
981718
|
var CHANGELOG_BASE2 = "https://buildwithfern.com/learn/sdks/generators";
|
|
@@ -982531,32 +982957,6 @@ Found ${previewDeployments.length} preview deployment(s):
|
|
|
982531
982957
|
// src/commands/docs-theme/deleteDocsTheme.ts
|
|
982532
982958
|
var import_node_readline6 = require("readline");
|
|
982533
982959
|
init_lib6();
|
|
982534
|
-
|
|
982535
|
-
// src/commands/docs-theme/themeOrigin.ts
|
|
982536
|
-
var FDR_ORIGIN = process.env.OVERRIDE_FDR_ORIGIN ?? "https://registry-dev2.buildwithfern.com" ?? "https://registry.buildwithfern.com";
|
|
982537
|
-
function describeFetchError(error50) {
|
|
982538
|
-
if (!(error50 instanceof Error)) {
|
|
982539
|
-
return String(error50);
|
|
982540
|
-
}
|
|
982541
|
-
const cause = error50.cause;
|
|
982542
|
-
if (cause instanceof Error) {
|
|
982543
|
-
return cause.message;
|
|
982544
|
-
}
|
|
982545
|
-
return error50.message;
|
|
982546
|
-
}
|
|
982547
|
-
function parseErrorDetail(body) {
|
|
982548
|
-
try {
|
|
982549
|
-
const parsed = JSON.parse(body);
|
|
982550
|
-
const message = parsed.message ?? parsed.error?.message;
|
|
982551
|
-
if (typeof message === "string") {
|
|
982552
|
-
return message;
|
|
982553
|
-
}
|
|
982554
|
-
} catch {
|
|
982555
|
-
}
|
|
982556
|
-
return void 0;
|
|
982557
|
-
}
|
|
982558
|
-
|
|
982559
|
-
// src/commands/docs-theme/deleteDocsTheme.ts
|
|
982560
982960
|
async function confirmDeletion(themeName) {
|
|
982561
982961
|
const rl = (0, import_node_readline6.createInterface)({ input: process.stdin, output: process.stderr });
|
|
982562
982962
|
return new Promise((resolve15) => {
|
|
@@ -989031,6 +989431,31 @@ function installProcessHandlers(cliContext, { isLocal }) {
|
|
|
989031
989431
|
});
|
|
989032
989432
|
}
|
|
989033
989433
|
|
|
989434
|
+
// src/utils/versionRedirection.ts
|
|
989435
|
+
init_helpers();
|
|
989436
|
+
var VERSION_REDIRECTION_EXEMPT_COMMANDS = /* @__PURE__ */ new Set(["org"]);
|
|
989437
|
+
function isVersionRedirectionExempt(argv) {
|
|
989438
|
+
const command3 = getInvokedCommandName(argv);
|
|
989439
|
+
return command3 != null && VERSION_REDIRECTION_EXEMPT_COMMANDS.has(command3);
|
|
989440
|
+
}
|
|
989441
|
+
function getInvokedCommandName(argv) {
|
|
989442
|
+
const args = hideBin(argv);
|
|
989443
|
+
for (let i5 = 0; i5 < args.length; i5++) {
|
|
989444
|
+
const arg = args[i5];
|
|
989445
|
+
if (arg == null) {
|
|
989446
|
+
continue;
|
|
989447
|
+
}
|
|
989448
|
+
if (arg.startsWith("-")) {
|
|
989449
|
+
if (arg === "--log-level") {
|
|
989450
|
+
i5++;
|
|
989451
|
+
}
|
|
989452
|
+
continue;
|
|
989453
|
+
}
|
|
989454
|
+
return arg;
|
|
989455
|
+
}
|
|
989456
|
+
return void 0;
|
|
989457
|
+
}
|
|
989458
|
+
|
|
989034
989459
|
// src/cli.ts
|
|
989035
989460
|
if (process.platform === "linux" && parseInt(process.versions.node.split(".")[0] ?? "0", 10) >= 26 && process.env.UV_USE_IO_URING !== "0") {
|
|
989036
989461
|
const result = (0, import_node_child_process14.spawnSync)(process.execPath, process.argv.slice(1), {
|
|
@@ -989077,7 +989502,7 @@ async function runCli() {
|
|
|
989077
989502
|
if (cwd2 != null) {
|
|
989078
989503
|
process.chdir(cwd2);
|
|
989079
989504
|
}
|
|
989080
|
-
if (isCompletion) {
|
|
989505
|
+
if (isCompletion || isVersionRedirectionExempt(process.argv)) {
|
|
989081
989506
|
await tryRunCli(cliContext);
|
|
989082
989507
|
} else {
|
|
989083
989508
|
const versionOfCliToRun = await getIntendedVersionOfCli(cliContext);
|
|
@@ -989167,6 +989592,7 @@ async function tryRunCli(cliContext) {
|
|
|
989167
989592
|
addAutomationsCommand(cli, cliContext);
|
|
989168
989593
|
addGetOrganizationCommand(cli, cliContext);
|
|
989169
989594
|
addGeneratorCommands(cli, cliContext);
|
|
989595
|
+
addOrgCommand2(cli, cliContext);
|
|
989170
989596
|
addProtocGenFernCommand(cli, cliContext);
|
|
989171
989597
|
addInstallDependenciesCommand(cli, cliContext);
|
|
989172
989598
|
cli.middleware(async (argv) => {
|
|
@@ -989180,6 +989606,14 @@ async function tryRunCli(cliContext) {
|
|
|
989180
989606
|
}
|
|
989181
989607
|
async function getIntendedVersionOfCli(cliContext) {
|
|
989182
989608
|
if (process.env.FERN_NO_VERSION_REDIRECTION === "true") {
|
|
989609
|
+
const orgId = await getOrganization2(cliContext);
|
|
989610
|
+
if (orgId != null) {
|
|
989611
|
+
await warnIfVersionOutsideOrgBounds({
|
|
989612
|
+
cliContext,
|
|
989613
|
+
orgId,
|
|
989614
|
+
currentVersion: cliContext.environment.packageVersion
|
|
989615
|
+
});
|
|
989616
|
+
}
|
|
989183
989617
|
return cliContext.environment.packageVersion;
|
|
989184
989618
|
}
|
|
989185
989619
|
const fernDirectory = await getFernDirectory();
|
|
@@ -989187,13 +989621,19 @@ async function getIntendedVersionOfCli(cliContext) {
|
|
|
989187
989621
|
const projectConfig = await cliContext.runTask(
|
|
989188
989622
|
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
989189
989623
|
);
|
|
989624
|
+
let intendedVersion;
|
|
989190
989625
|
if (projectConfig.version === "*") {
|
|
989191
|
-
|
|
989192
|
-
}
|
|
989193
|
-
|
|
989194
|
-
|
|
989626
|
+
intendedVersion = cliContext.environment.packageVersion;
|
|
989627
|
+
} else if (projectConfig.version === "latest") {
|
|
989628
|
+
intendedVersion = await getLatestVersionOfCli({ cliEnvironment: cliContext.environment });
|
|
989629
|
+
} else {
|
|
989630
|
+
intendedVersion = projectConfig.version;
|
|
989195
989631
|
}
|
|
989196
|
-
return
|
|
989632
|
+
return await applyOrgBoundsToVersion({
|
|
989633
|
+
cliContext,
|
|
989634
|
+
orgId: projectConfig.organization,
|
|
989635
|
+
intendedVersion
|
|
989636
|
+
});
|
|
989197
989637
|
}
|
|
989198
989638
|
return getLatestVersionOfCli({ cliEnvironment: cliContext.environment });
|
|
989199
989639
|
}
|
|
@@ -992004,6 +992444,77 @@ Remove ${matched.length} patch(es)? [y/N] `, resolvePrompt);
|
|
|
992004
992444
|
}
|
|
992005
992445
|
);
|
|
992006
992446
|
}
|
|
992447
|
+
function addOrgCommand2(cli, cliContext) {
|
|
992448
|
+
cli.command("org", "Manage org-level configuration", (yargs) => {
|
|
992449
|
+
yargs.command(
|
|
992450
|
+
"set",
|
|
992451
|
+
"Set an org-level config value (admin only)",
|
|
992452
|
+
(setYargs) => setYargs.command(
|
|
992453
|
+
"cli-version [version]",
|
|
992454
|
+
"Set the org's Fern CLI version policy: pin an exact version, or set a min/max range",
|
|
992455
|
+
(y4) => y4.positional("version", {
|
|
992456
|
+
type: "string",
|
|
992457
|
+
description: "Pin to an exact version (sets both the floor and ceiling)"
|
|
992458
|
+
}).option("min", {
|
|
992459
|
+
type: "string",
|
|
992460
|
+
description: "Minimum allowed CLI version (floor)"
|
|
992461
|
+
}).option("max", {
|
|
992462
|
+
type: "string",
|
|
992463
|
+
description: "Maximum allowed CLI version (ceiling)"
|
|
992464
|
+
}).option("org", { type: "string", description: "Override org ID" }),
|
|
992465
|
+
async (argv) => {
|
|
992466
|
+
cliContext.instrumentPostHogEvent({ command: "fern org set cli-version" });
|
|
992467
|
+
const { version: version7, min, max } = argv;
|
|
992468
|
+
if (version7 != null && (min != null || max != null)) {
|
|
992469
|
+
cliContext.failAndThrow(
|
|
992470
|
+
"Pass either an exact version to pin (e.g. `fern org set cli-version 5.45.0`) or --min/--max to set a range, not both."
|
|
992471
|
+
);
|
|
992472
|
+
return;
|
|
992473
|
+
}
|
|
992474
|
+
if (version7 == null && min == null && max == null) {
|
|
992475
|
+
cliContext.failAndThrow(
|
|
992476
|
+
"Nothing to set. Pass a version to pin (e.g. `fern org set cli-version 5.45.0`) or --min/--max to set a range."
|
|
992477
|
+
);
|
|
992478
|
+
return;
|
|
992479
|
+
}
|
|
992480
|
+
if (version7 != null) {
|
|
992481
|
+
await setOrgCliVersion({ cliContext, min: version7, max: version7, org: argv.org });
|
|
992482
|
+
} else {
|
|
992483
|
+
await setOrgCliVersion({ cliContext, min, max, org: argv.org });
|
|
992484
|
+
}
|
|
992485
|
+
}
|
|
992486
|
+
).demandCommand(1, "Specify what to set, e.g. `fern org set cli-version 5.45.0`."),
|
|
992487
|
+
() => {
|
|
992488
|
+
}
|
|
992489
|
+
);
|
|
992490
|
+
yargs.command(
|
|
992491
|
+
"get",
|
|
992492
|
+
"View org-level config",
|
|
992493
|
+
(y4) => y4.option("org", { type: "string", description: "Override org ID" }).option("json", { type: "boolean", description: "Output as JSON" }),
|
|
992494
|
+
async (argv) => {
|
|
992495
|
+
cliContext.instrumentPostHogEvent({ command: "fern org get" });
|
|
992496
|
+
await getOrgConfig({ cliContext, org: argv.org, json: argv.json });
|
|
992497
|
+
}
|
|
992498
|
+
);
|
|
992499
|
+
yargs.command(
|
|
992500
|
+
"unset",
|
|
992501
|
+
"Remove an org-level config value (admin only)",
|
|
992502
|
+
(unsetYargs) => unsetYargs.command(
|
|
992503
|
+
"cli-version",
|
|
992504
|
+
"Clear the org's Fern CLI version policy (both bounds by default, or --min/--max for one end)",
|
|
992505
|
+
(y4) => y4.option("min", { type: "boolean", description: "Clear only the floor" }).option("max", { type: "boolean", description: "Clear only the ceiling" }).option("org", { type: "string", description: "Override org ID" }),
|
|
992506
|
+
async (argv) => {
|
|
992507
|
+
cliContext.instrumentPostHogEvent({ command: "fern org unset cli-version" });
|
|
992508
|
+
const field5 = argv.min && !argv.max ? "min" : argv.max && !argv.min ? "max" : "all";
|
|
992509
|
+
await unsetOrgCliVersion({ cliContext, org: argv.org, field: field5 });
|
|
992510
|
+
}
|
|
992511
|
+
).demandCommand(1, "Specify what to unset, e.g. `fern org unset cli-version`."),
|
|
992512
|
+
() => {
|
|
992513
|
+
}
|
|
992514
|
+
);
|
|
992515
|
+
return yargs;
|
|
992516
|
+
});
|
|
992517
|
+
}
|
|
992007
992518
|
function parseOwnerRepo(githubRepo) {
|
|
992008
992519
|
const cleaned = githubRepo.replace(/^https?:\/\//, "").replace(/\.git$/, "").replace(/^github\.com\//, "");
|
|
992009
992520
|
const parts = cleaned.split("/");
|
package/package.json
CHANGED