@fern-api/fern-api-dev 5.81.0 → 5.82.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 +556 -55
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -102386,6 +102386,7 @@ var init_latest_version = __esm({
|
|
|
102386
102386
|
"../../../node_modules/.pnpm/latest-version@9.0.0/node_modules/latest-version/index.js"() {
|
|
102387
102387
|
"use strict";
|
|
102388
102388
|
init_package_json();
|
|
102389
|
+
init_package_json();
|
|
102389
102390
|
}
|
|
102390
102391
|
});
|
|
102391
102392
|
|
|
@@ -311806,23 +311807,6 @@ var init_lib26 = __esm({
|
|
|
311806
311807
|
}
|
|
311807
311808
|
});
|
|
311808
311809
|
|
|
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
311810
|
// ../semver-utils/lib/parseVersion.js
|
|
311827
311811
|
function parseVersion(versionString) {
|
|
311828
311812
|
const alphaMatch = versionString.match(ALPHA_VERSION_REGEX);
|
|
@@ -311958,6 +311942,39 @@ var init_parseVersion = __esm({
|
|
|
311958
311942
|
}
|
|
311959
311943
|
});
|
|
311960
311944
|
|
|
311945
|
+
// ../semver-utils/lib/isValidVersion.js
|
|
311946
|
+
function isValidVersion(versionString) {
|
|
311947
|
+
try {
|
|
311948
|
+
parseVersion(versionString);
|
|
311949
|
+
return true;
|
|
311950
|
+
} catch {
|
|
311951
|
+
return false;
|
|
311952
|
+
}
|
|
311953
|
+
}
|
|
311954
|
+
var init_isValidVersion = __esm({
|
|
311955
|
+
"../semver-utils/lib/isValidVersion.js"() {
|
|
311956
|
+
"use strict";
|
|
311957
|
+
init_parseVersion();
|
|
311958
|
+
}
|
|
311959
|
+
});
|
|
311960
|
+
|
|
311961
|
+
// ../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js
|
|
311962
|
+
function semverDiff(versionA, versionB) {
|
|
311963
|
+
versionA = import_semver11.default.parse(versionA);
|
|
311964
|
+
versionB = import_semver11.default.parse(versionB);
|
|
311965
|
+
if (import_semver11.default.compareBuild(versionA, versionB) >= 0) {
|
|
311966
|
+
return;
|
|
311967
|
+
}
|
|
311968
|
+
return import_semver11.default.diff(versionA, versionB) || "build";
|
|
311969
|
+
}
|
|
311970
|
+
var import_semver11;
|
|
311971
|
+
var init_semver_diff = __esm({
|
|
311972
|
+
"../../../node_modules/.pnpm/semver-diff@4.0.0/node_modules/semver-diff/index.js"() {
|
|
311973
|
+
"use strict";
|
|
311974
|
+
import_semver11 = __toESM(require_semver2(), 1);
|
|
311975
|
+
}
|
|
311976
|
+
});
|
|
311977
|
+
|
|
311961
311978
|
// ../semver-utils/lib/isVersionAhead.js
|
|
311962
311979
|
function isVersionAhead(a3, b5) {
|
|
311963
311980
|
if (a3 === b5) {
|
|
@@ -312046,6 +312063,7 @@ var init_isVersionAhead = __esm({
|
|
|
312046
312063
|
var init_lib27 = __esm({
|
|
312047
312064
|
"../semver-utils/lib/index.js"() {
|
|
312048
312065
|
"use strict";
|
|
312066
|
+
init_isValidVersion();
|
|
312049
312067
|
init_isVersionAhead();
|
|
312050
312068
|
init_parseVersion();
|
|
312051
312069
|
}
|
|
@@ -692006,7 +692024,7 @@ var AccessTokenPosthogManager = class {
|
|
|
692006
692024
|
properties: {
|
|
692007
692025
|
...event,
|
|
692008
692026
|
...event.properties,
|
|
692009
|
-
version: "5.
|
|
692027
|
+
version: "5.82.0",
|
|
692010
692028
|
usingAccessToken: true,
|
|
692011
692029
|
...getRunIdProperties()
|
|
692012
692030
|
}
|
|
@@ -692072,7 +692090,7 @@ var UserPosthogManager = class {
|
|
|
692072
692090
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
692073
692091
|
event: "CLI",
|
|
692074
692092
|
properties: {
|
|
692075
|
-
version: "5.
|
|
692093
|
+
version: "5.82.0",
|
|
692076
692094
|
...event,
|
|
692077
692095
|
...event.properties,
|
|
692078
692096
|
usingAccessToken: false,
|
|
@@ -873178,7 +873196,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
873178
873196
|
var LOGS_FOLDER_NAME = "logs";
|
|
873179
873197
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
873180
873198
|
function getCliSource() {
|
|
873181
|
-
const version7 = "5.
|
|
873199
|
+
const version7 = "5.82.0";
|
|
873182
873200
|
return `cli@${version7}`;
|
|
873183
873201
|
}
|
|
873184
873202
|
var DebugLogger = class {
|
|
@@ -905874,7 +905892,7 @@ var LegacyDocsPublisher = class {
|
|
|
905874
905892
|
previewId,
|
|
905875
905893
|
disableTemplates: void 0,
|
|
905876
905894
|
skipUpload,
|
|
905877
|
-
cliVersion: "5.
|
|
905895
|
+
cliVersion: "5.82.0",
|
|
905878
905896
|
loginCommand: "fern auth login"
|
|
905879
905897
|
});
|
|
905880
905898
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -972739,7 +972757,7 @@ function getAutomationContextFromEnv() {
|
|
|
972739
972757
|
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
972740
972758
|
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
972741
972759
|
trigger: process.env.GITHUB_EVENT_NAME,
|
|
972742
|
-
cli_version: "5.
|
|
972760
|
+
cli_version: "5.82.0"
|
|
972743
972761
|
};
|
|
972744
972762
|
}
|
|
972745
972763
|
function isAutomationMode() {
|
|
@@ -973571,7 +973589,7 @@ var CliContext = class _CliContext {
|
|
|
973571
973589
|
if (false) {
|
|
973572
973590
|
this.logger.error("CLI_VERSION is not defined");
|
|
973573
973591
|
}
|
|
973574
|
-
return "5.
|
|
973592
|
+
return "5.82.0";
|
|
973575
973593
|
}
|
|
973576
973594
|
getCliName() {
|
|
973577
973595
|
if (false) {
|
|
@@ -980960,6 +980978,341 @@ async function rerunFernCliAtVersion({
|
|
|
980960
980978
|
}
|
|
980961
980979
|
}
|
|
980962
980980
|
|
|
980981
|
+
// src/commands/org/orgConfig.ts
|
|
980982
|
+
init_lib19();
|
|
980983
|
+
init_lib27();
|
|
980984
|
+
init_lib6();
|
|
980985
|
+
init_source();
|
|
980986
|
+
init_latest_version();
|
|
980987
|
+
|
|
980988
|
+
// src/commands/docs-theme/themeOrigin.ts
|
|
980989
|
+
var FDR_ORIGIN = process.env.OVERRIDE_FDR_ORIGIN ?? "https://registry-dev2.buildwithfern.com" ?? "https://registry.buildwithfern.com";
|
|
980990
|
+
function describeFetchError(error50) {
|
|
980991
|
+
if (!(error50 instanceof Error)) {
|
|
980992
|
+
return String(error50);
|
|
980993
|
+
}
|
|
980994
|
+
const cause = error50.cause;
|
|
980995
|
+
if (cause instanceof Error) {
|
|
980996
|
+
return cause.message;
|
|
980997
|
+
}
|
|
980998
|
+
return error50.message;
|
|
980999
|
+
}
|
|
981000
|
+
function parseErrorDetail(body) {
|
|
981001
|
+
try {
|
|
981002
|
+
const parsed = JSON.parse(body);
|
|
981003
|
+
const message = parsed.message ?? parsed.error?.message;
|
|
981004
|
+
if (typeof message === "string") {
|
|
981005
|
+
return message;
|
|
981006
|
+
}
|
|
981007
|
+
} catch {
|
|
981008
|
+
}
|
|
981009
|
+
return void 0;
|
|
981010
|
+
}
|
|
981011
|
+
|
|
981012
|
+
// src/commands/org/orgConfig.ts
|
|
981013
|
+
function clampVersionToOrgBounds(intendedVersion, { min, max }) {
|
|
981014
|
+
const isPinned = min != null && max != null && min === max;
|
|
981015
|
+
if (min != null && isVersionAhead(min, intendedVersion)) {
|
|
981016
|
+
return { version: min, reason: isPinned ? "pin" : "floor" };
|
|
981017
|
+
}
|
|
981018
|
+
if (max != null && isVersionAhead(intendedVersion, max)) {
|
|
981019
|
+
return { version: max, reason: isPinned ? "pin" : "ceiling" };
|
|
981020
|
+
}
|
|
981021
|
+
return { version: intendedVersion };
|
|
981022
|
+
}
|
|
981023
|
+
async function getAuthToken(cliContext) {
|
|
981024
|
+
const token = await cliContext.runTask(async (context3) => {
|
|
981025
|
+
return askToLogin(context3);
|
|
981026
|
+
});
|
|
981027
|
+
if (token == null) {
|
|
981028
|
+
return cliContext.failAndThrow("Failed to authenticate. Please run 'fern login' first.", void 0, {
|
|
981029
|
+
code: CliError.Code.AuthError
|
|
981030
|
+
});
|
|
981031
|
+
}
|
|
981032
|
+
return token;
|
|
981033
|
+
}
|
|
981034
|
+
async function resolveOrgId(cliContext, orgOverride) {
|
|
981035
|
+
if (orgOverride != null) {
|
|
981036
|
+
return orgOverride;
|
|
981037
|
+
}
|
|
981038
|
+
const fernDirectory = await getFernDirectory();
|
|
981039
|
+
if (fernDirectory == null) {
|
|
981040
|
+
return cliContext.failAndThrow(
|
|
981041
|
+
`Directory "${FERN_DIRECTORY}" not found. Run from a Fern project or pass --org.`,
|
|
981042
|
+
void 0,
|
|
981043
|
+
{ code: CliError.Code.ConfigError }
|
|
981044
|
+
);
|
|
981045
|
+
}
|
|
981046
|
+
const projectConfig = await cliContext.runTask(
|
|
981047
|
+
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
981048
|
+
);
|
|
981049
|
+
return projectConfig.organization;
|
|
981050
|
+
}
|
|
981051
|
+
async function orgConfigRequest(context3, orgId, init3, actionLabel) {
|
|
981052
|
+
let res;
|
|
981053
|
+
try {
|
|
981054
|
+
res = await fetch(`${FDR_ORIGIN}/v2/registry/org-config/${orgId}`, init3);
|
|
981055
|
+
} catch (err) {
|
|
981056
|
+
return context3.failAndThrow(`Failed to reach FDR: ${describeFetchError(err)}`, void 0, {
|
|
981057
|
+
code: CliError.Code.NetworkError
|
|
981058
|
+
});
|
|
981059
|
+
}
|
|
981060
|
+
if (!res.ok) {
|
|
981061
|
+
const body = await res.text();
|
|
981062
|
+
const detail = parseErrorDetail(body) ?? body;
|
|
981063
|
+
return context3.failAndThrow(`Failed to ${actionLabel}: HTTP ${res.status} \u2014 ${detail}`, void 0, {
|
|
981064
|
+
code: CliError.Code.NetworkError
|
|
981065
|
+
});
|
|
981066
|
+
}
|
|
981067
|
+
return res;
|
|
981068
|
+
}
|
|
981069
|
+
async function getOrgConfig({
|
|
981070
|
+
cliContext,
|
|
981071
|
+
org,
|
|
981072
|
+
json: json2
|
|
981073
|
+
}) {
|
|
981074
|
+
const token = await getAuthToken(cliContext);
|
|
981075
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981076
|
+
await cliContext.runTask(async (context3) => {
|
|
981077
|
+
const res = await orgConfigRequest(
|
|
981078
|
+
context3,
|
|
981079
|
+
orgId,
|
|
981080
|
+
{ headers: { Authorization: `Bearer ${token.value}` } },
|
|
981081
|
+
"get org config"
|
|
981082
|
+
);
|
|
981083
|
+
const data2 = await res.json();
|
|
981084
|
+
if (json2) {
|
|
981085
|
+
process.stdout.write(JSON.stringify(data2, null, 2) + "\n");
|
|
981086
|
+
return;
|
|
981087
|
+
}
|
|
981088
|
+
if (data2.cliVersionMin == null && data2.cliVersionMax == null) {
|
|
981089
|
+
context3.logger.info(`No org-level CLI config set for "${orgId}".`);
|
|
981090
|
+
return;
|
|
981091
|
+
}
|
|
981092
|
+
const { cliVersionMin, cliVersionMax } = data2;
|
|
981093
|
+
if (cliVersionMin != null && cliVersionMin === cliVersionMax) {
|
|
981094
|
+
context3.logger.info(`Fern CLI pinned to ${source_default.green(cliVersionMin)}`);
|
|
981095
|
+
} else if (cliVersionMin != null && cliVersionMax != null) {
|
|
981096
|
+
context3.logger.info(
|
|
981097
|
+
`Fern CLI must be between ${source_default.green(cliVersionMin)} and ${source_default.green(cliVersionMax)}`
|
|
981098
|
+
);
|
|
981099
|
+
} else if (cliVersionMin != null) {
|
|
981100
|
+
context3.logger.info(`Fern CLI must be at least ${source_default.green(cliVersionMin)}`);
|
|
981101
|
+
} else if (cliVersionMax != null) {
|
|
981102
|
+
context3.logger.info(`Fern CLI must be at most ${source_default.green(cliVersionMax)}`);
|
|
981103
|
+
}
|
|
981104
|
+
});
|
|
981105
|
+
}
|
|
981106
|
+
var FERN_CLI_PACKAGE_NAME = "fern-api";
|
|
981107
|
+
async function assertCliVersionIsPublished(cliContext, version7) {
|
|
981108
|
+
try {
|
|
981109
|
+
await latestVersion(FERN_CLI_PACKAGE_NAME, { version: version7 });
|
|
981110
|
+
} catch (err) {
|
|
981111
|
+
if (err instanceof VersionNotFoundError) {
|
|
981112
|
+
cliContext.failAndThrow(
|
|
981113
|
+
`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.`,
|
|
981114
|
+
void 0,
|
|
981115
|
+
{ code: CliError.Code.ConfigError }
|
|
981116
|
+
);
|
|
981117
|
+
return;
|
|
981118
|
+
}
|
|
981119
|
+
cliContext.logger.debug(`Could not verify Fern CLI version "${version7}" exists on npm: ${String(err)}`);
|
|
981120
|
+
}
|
|
981121
|
+
}
|
|
981122
|
+
async function setOrgCliVersion({
|
|
981123
|
+
cliContext,
|
|
981124
|
+
min,
|
|
981125
|
+
max,
|
|
981126
|
+
org
|
|
981127
|
+
}) {
|
|
981128
|
+
for (const version7 of [min, max]) {
|
|
981129
|
+
if (version7 != null && !isValidVersion(version7)) {
|
|
981130
|
+
cliContext.failAndThrow(
|
|
981131
|
+
`"${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.`,
|
|
981132
|
+
void 0,
|
|
981133
|
+
{ code: CliError.Code.ConfigError }
|
|
981134
|
+
);
|
|
981135
|
+
return;
|
|
981136
|
+
}
|
|
981137
|
+
}
|
|
981138
|
+
if (min != null && max != null && isVersionAhead(min, max)) {
|
|
981139
|
+
cliContext.failAndThrow(`Minimum version ${min} must not be greater than maximum version ${max}.`, void 0, {
|
|
981140
|
+
code: CliError.Code.ConfigError
|
|
981141
|
+
});
|
|
981142
|
+
return;
|
|
981143
|
+
}
|
|
981144
|
+
for (const version7 of [min, max]) {
|
|
981145
|
+
if (version7 != null) {
|
|
981146
|
+
await assertCliVersionIsPublished(cliContext, version7);
|
|
981147
|
+
}
|
|
981148
|
+
}
|
|
981149
|
+
const token = await getAuthToken(cliContext);
|
|
981150
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981151
|
+
const requestBody = {};
|
|
981152
|
+
if (min != null) {
|
|
981153
|
+
requestBody.cliVersionMin = min;
|
|
981154
|
+
}
|
|
981155
|
+
if (max != null) {
|
|
981156
|
+
requestBody.cliVersionMax = max;
|
|
981157
|
+
}
|
|
981158
|
+
await cliContext.runTask(async (context3) => {
|
|
981159
|
+
await orgConfigRequest(
|
|
981160
|
+
context3,
|
|
981161
|
+
orgId,
|
|
981162
|
+
{
|
|
981163
|
+
method: "PUT",
|
|
981164
|
+
headers: {
|
|
981165
|
+
Authorization: `Bearer ${token.value}`,
|
|
981166
|
+
"Content-Type": "application/json"
|
|
981167
|
+
},
|
|
981168
|
+
body: JSON.stringify(requestBody)
|
|
981169
|
+
},
|
|
981170
|
+
"set org config"
|
|
981171
|
+
);
|
|
981172
|
+
if (min != null && max != null && min === max) {
|
|
981173
|
+
context3.logger.info(`Pinned CLI version to ${source_default.green(min)} for org "${orgId}".`);
|
|
981174
|
+
} else if (min != null && max != null) {
|
|
981175
|
+
context3.logger.info(`Set CLI version range to ${source_default.green(`${min} \u2013 ${max}`)} for org "${orgId}".`);
|
|
981176
|
+
} else if (min != null) {
|
|
981177
|
+
context3.logger.info(`Set minimum CLI version to ${source_default.green(min)} for org "${orgId}".`);
|
|
981178
|
+
} else if (max != null) {
|
|
981179
|
+
context3.logger.info(`Set maximum CLI version to ${source_default.green(max)} for org "${orgId}".`);
|
|
981180
|
+
}
|
|
981181
|
+
});
|
|
981182
|
+
}
|
|
981183
|
+
async function unsetOrgCliVersion({
|
|
981184
|
+
cliContext,
|
|
981185
|
+
org,
|
|
981186
|
+
field: field5
|
|
981187
|
+
}) {
|
|
981188
|
+
const token = await getAuthToken(cliContext);
|
|
981189
|
+
const orgId = await resolveOrgId(cliContext, org);
|
|
981190
|
+
await cliContext.runTask(async (context3) => {
|
|
981191
|
+
const init3 = field5 === "all" ? { method: "DELETE", headers: { Authorization: `Bearer ${token.value}` } } : {
|
|
981192
|
+
method: "PUT",
|
|
981193
|
+
headers: {
|
|
981194
|
+
Authorization: `Bearer ${token.value}`,
|
|
981195
|
+
"Content-Type": "application/json"
|
|
981196
|
+
},
|
|
981197
|
+
body: JSON.stringify(field5 === "min" ? { cliVersionMin: null } : { cliVersionMax: null })
|
|
981198
|
+
};
|
|
981199
|
+
await orgConfigRequest(context3, orgId, init3, "unset org config");
|
|
981200
|
+
const label = field5 === "min" ? "minimum" : field5 === "max" ? "maximum" : "minimum and maximum";
|
|
981201
|
+
context3.logger.info(`Removed ${label} CLI version for org "${orgId}".`);
|
|
981202
|
+
});
|
|
981203
|
+
}
|
|
981204
|
+
function sanitizeBound(version7) {
|
|
981205
|
+
return version7 != null && isValidVersion(version7) ? version7 : void 0;
|
|
981206
|
+
}
|
|
981207
|
+
async function fetchOrgCliVersionBounds({
|
|
981208
|
+
cliContext,
|
|
981209
|
+
orgId,
|
|
981210
|
+
token,
|
|
981211
|
+
timeoutMs
|
|
981212
|
+
}) {
|
|
981213
|
+
try {
|
|
981214
|
+
const res = await fetch(`${FDR_ORIGIN}/v2/registry/org-config/${orgId}`, {
|
|
981215
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
981216
|
+
signal: timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0
|
|
981217
|
+
});
|
|
981218
|
+
if (!res.ok) {
|
|
981219
|
+
cliContext.logger.debug(`Failed to fetch org config: HTTP ${res.status}`);
|
|
981220
|
+
return { ok: false };
|
|
981221
|
+
}
|
|
981222
|
+
const data2 = await res.json();
|
|
981223
|
+
return {
|
|
981224
|
+
ok: true,
|
|
981225
|
+
bounds: { min: sanitizeBound(data2.cliVersionMin), max: sanitizeBound(data2.cliVersionMax) }
|
|
981226
|
+
};
|
|
981227
|
+
} catch (err) {
|
|
981228
|
+
cliContext.logger.debug(`Failed to fetch org config: ${describeFetchError(err)}`);
|
|
981229
|
+
return { ok: false };
|
|
981230
|
+
}
|
|
981231
|
+
}
|
|
981232
|
+
var ORG_BOUNDS_FETCH_TIMEOUT_MS = 2500;
|
|
981233
|
+
async function getOrgCliVersionBounds({
|
|
981234
|
+
cliContext,
|
|
981235
|
+
orgId
|
|
981236
|
+
}) {
|
|
981237
|
+
if (process.env.FERN_IGNORE_ORG_VERSION_BOUNDS === "true" || process.env.FERN_IGNORE_ORG_VERSION_FLOOR === "true") {
|
|
981238
|
+
return {};
|
|
981239
|
+
}
|
|
981240
|
+
try {
|
|
981241
|
+
const token = await getToken2();
|
|
981242
|
+
if (token == null) {
|
|
981243
|
+
return {};
|
|
981244
|
+
}
|
|
981245
|
+
const result = await fetchOrgCliVersionBounds({
|
|
981246
|
+
cliContext,
|
|
981247
|
+
orgId,
|
|
981248
|
+
token: token.value,
|
|
981249
|
+
timeoutMs: ORG_BOUNDS_FETCH_TIMEOUT_MS
|
|
981250
|
+
});
|
|
981251
|
+
if (!result.ok) {
|
|
981252
|
+
return {};
|
|
981253
|
+
}
|
|
981254
|
+
return result.bounds;
|
|
981255
|
+
} catch (err) {
|
|
981256
|
+
cliContext.logger.debug(`Failed to resolve org CLI version bounds: ${String(err)}`);
|
|
981257
|
+
return {};
|
|
981258
|
+
}
|
|
981259
|
+
}
|
|
981260
|
+
async function resolveClampedVersionForOrg({
|
|
981261
|
+
cliContext,
|
|
981262
|
+
orgId,
|
|
981263
|
+
version: version7
|
|
981264
|
+
}) {
|
|
981265
|
+
const bounds = await getOrgCliVersionBounds({ cliContext, orgId });
|
|
981266
|
+
try {
|
|
981267
|
+
return { ...clampVersionToOrgBounds(version7, bounds), bounds };
|
|
981268
|
+
} catch {
|
|
981269
|
+
return { version: version7, bounds };
|
|
981270
|
+
}
|
|
981271
|
+
}
|
|
981272
|
+
function describeOrgBounds(orgId, { min, max }, color3) {
|
|
981273
|
+
if (min != null && max != null && min === max) {
|
|
981274
|
+
return `Org "${orgId}" pins Fern CLI to ${color3(min)}`;
|
|
981275
|
+
}
|
|
981276
|
+
if (min != null && max != null) {
|
|
981277
|
+
return `Org "${orgId}" requires Fern CLI between ${color3(min)} and ${color3(max)}`;
|
|
981278
|
+
}
|
|
981279
|
+
if (min != null) {
|
|
981280
|
+
return `Org "${orgId}" requires Fern CLI ${color3(`>= ${min}`)}`;
|
|
981281
|
+
}
|
|
981282
|
+
if (max != null) {
|
|
981283
|
+
return `Org "${orgId}" caps Fern CLI at ${color3(`<= ${max}`)}`;
|
|
981284
|
+
}
|
|
981285
|
+
return `Org "${orgId}"`;
|
|
981286
|
+
}
|
|
981287
|
+
async function applyOrgBoundsToVersion({
|
|
981288
|
+
cliContext,
|
|
981289
|
+
orgId,
|
|
981290
|
+
intendedVersion
|
|
981291
|
+
}) {
|
|
981292
|
+
const { version: version7, reason, bounds } = await resolveClampedVersionForOrg({
|
|
981293
|
+
cliContext,
|
|
981294
|
+
orgId,
|
|
981295
|
+
version: intendedVersion
|
|
981296
|
+
});
|
|
981297
|
+
if (reason != null) {
|
|
981298
|
+
cliContext.logger.info(`${describeOrgBounds(orgId, bounds, source_default.green)} \u2014 running ${source_default.green(version7)}.`);
|
|
981299
|
+
}
|
|
981300
|
+
return version7;
|
|
981301
|
+
}
|
|
981302
|
+
async function warnIfVersionOutsideOrgBounds({
|
|
981303
|
+
cliContext,
|
|
981304
|
+
orgId,
|
|
981305
|
+
currentVersion
|
|
981306
|
+
}) {
|
|
981307
|
+
const { reason, bounds } = await resolveClampedVersionForOrg({ cliContext, orgId, version: currentVersion });
|
|
981308
|
+
if (reason != null) {
|
|
981309
|
+
const suffix = reason === "ceiling" ? "was not downgraded" : reason === "floor" ? "was not upgraded" : "was not changed";
|
|
981310
|
+
cliContext.logger.warn(
|
|
981311
|
+
`${describeOrgBounds(orgId, bounds, source_default.yellow)}, but this CLI is ${source_default.yellow(currentVersion)}. Version redirection is disabled, so it ${suffix}.`
|
|
981312
|
+
);
|
|
981313
|
+
}
|
|
981314
|
+
}
|
|
981315
|
+
|
|
980963
981316
|
// src/commands/upgrade/upgrade.ts
|
|
980964
981317
|
var PREVIOUS_VERSION_ENV_VAR = "FERN_PRE_UPGRADE_VERSION";
|
|
980965
981318
|
function ensureFinalNewline(content5) {
|
|
@@ -981190,6 +981543,19 @@ async function upgrade({
|
|
|
981190
981543
|
}
|
|
981191
981544
|
}
|
|
981192
981545
|
}
|
|
981546
|
+
if (resolvedTargetVersion == null) {
|
|
981547
|
+
cliContext.logger.info("No upgrade available.");
|
|
981548
|
+
return;
|
|
981549
|
+
}
|
|
981550
|
+
if (!isLocalDev) {
|
|
981551
|
+
try {
|
|
981552
|
+
resolvedTargetVersion = await applyOrgVersionBounds({
|
|
981553
|
+
cliContext,
|
|
981554
|
+
resolvedTargetVersion
|
|
981555
|
+
});
|
|
981556
|
+
} catch {
|
|
981557
|
+
}
|
|
981558
|
+
}
|
|
981193
981559
|
if (cliContext.environment.packageVersion === resolvedTargetVersion || isLocalDev) {
|
|
981194
981560
|
const fernDirectory2 = await getFernDirectory();
|
|
981195
981561
|
if (fernDirectory2 == null) {
|
|
@@ -981287,6 +981653,56 @@ async function upgrade({
|
|
|
981287
981653
|
throw error50;
|
|
981288
981654
|
}
|
|
981289
981655
|
}
|
|
981656
|
+
async function applyOrgVersionBounds({
|
|
981657
|
+
cliContext,
|
|
981658
|
+
resolvedTargetVersion
|
|
981659
|
+
}) {
|
|
981660
|
+
const fernDirectory = await getFernDirectory();
|
|
981661
|
+
if (fernDirectory == null) {
|
|
981662
|
+
return resolvedTargetVersion;
|
|
981663
|
+
}
|
|
981664
|
+
let orgId;
|
|
981665
|
+
try {
|
|
981666
|
+
const projectConfig = await cliContext.runTask(
|
|
981667
|
+
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
981668
|
+
);
|
|
981669
|
+
orgId = projectConfig.organization;
|
|
981670
|
+
} catch {
|
|
981671
|
+
return resolvedTargetVersion;
|
|
981672
|
+
}
|
|
981673
|
+
const token = await getToken2();
|
|
981674
|
+
if (token == null) {
|
|
981675
|
+
return resolvedTargetVersion;
|
|
981676
|
+
}
|
|
981677
|
+
const result = await fetchOrgCliVersionBounds({
|
|
981678
|
+
cliContext,
|
|
981679
|
+
orgId,
|
|
981680
|
+
token: token.value,
|
|
981681
|
+
timeoutMs: ORG_BOUNDS_FETCH_TIMEOUT_MS
|
|
981682
|
+
});
|
|
981683
|
+
if (!result.ok) {
|
|
981684
|
+
return resolvedTargetVersion;
|
|
981685
|
+
}
|
|
981686
|
+
const { min, max } = result.bounds;
|
|
981687
|
+
if (min == null && max == null) {
|
|
981688
|
+
return resolvedTargetVersion;
|
|
981689
|
+
}
|
|
981690
|
+
try {
|
|
981691
|
+
const { version: version7, reason } = clampVersionToOrgBounds(resolvedTargetVersion, { min, max });
|
|
981692
|
+
if (reason === "floor") {
|
|
981693
|
+
cliContext.logger.info(
|
|
981694
|
+
`Org "${orgId}" requires minimum CLI version ${source_default.green(version7)} (resolved ${resolvedTargetVersion}).`
|
|
981695
|
+
);
|
|
981696
|
+
} else if (reason === "ceiling") {
|
|
981697
|
+
cliContext.logger.info(
|
|
981698
|
+
`Org "${orgId}" caps CLI version at ${source_default.green(version7)} (resolved ${resolvedTargetVersion}).`
|
|
981699
|
+
);
|
|
981700
|
+
}
|
|
981701
|
+
return version7;
|
|
981702
|
+
} catch {
|
|
981703
|
+
return resolvedTargetVersion;
|
|
981704
|
+
}
|
|
981705
|
+
}
|
|
981290
981706
|
|
|
981291
981707
|
// src/commands/automations/upgrade/executeAutomationsUpgrade.ts
|
|
981292
981708
|
var CHANGELOG_BASE2 = "https://buildwithfern.com/learn/sdks/generators";
|
|
@@ -982531,32 +982947,6 @@ Found ${previewDeployments.length} preview deployment(s):
|
|
|
982531
982947
|
// src/commands/docs-theme/deleteDocsTheme.ts
|
|
982532
982948
|
var import_node_readline6 = require("readline");
|
|
982533
982949
|
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
982950
|
async function confirmDeletion(themeName) {
|
|
982561
982951
|
const rl = (0, import_node_readline6.createInterface)({ input: process.stdin, output: process.stderr });
|
|
982562
982952
|
return new Promise((resolve15) => {
|
|
@@ -989031,6 +989421,31 @@ function installProcessHandlers(cliContext, { isLocal }) {
|
|
|
989031
989421
|
});
|
|
989032
989422
|
}
|
|
989033
989423
|
|
|
989424
|
+
// src/utils/versionRedirection.ts
|
|
989425
|
+
init_helpers();
|
|
989426
|
+
var VERSION_REDIRECTION_EXEMPT_COMMANDS = /* @__PURE__ */ new Set(["org"]);
|
|
989427
|
+
function isVersionRedirectionExempt(argv) {
|
|
989428
|
+
const command3 = getInvokedCommandName(argv);
|
|
989429
|
+
return command3 != null && VERSION_REDIRECTION_EXEMPT_COMMANDS.has(command3);
|
|
989430
|
+
}
|
|
989431
|
+
function getInvokedCommandName(argv) {
|
|
989432
|
+
const args = hideBin(argv);
|
|
989433
|
+
for (let i5 = 0; i5 < args.length; i5++) {
|
|
989434
|
+
const arg = args[i5];
|
|
989435
|
+
if (arg == null) {
|
|
989436
|
+
continue;
|
|
989437
|
+
}
|
|
989438
|
+
if (arg.startsWith("-")) {
|
|
989439
|
+
if (arg === "--log-level") {
|
|
989440
|
+
i5++;
|
|
989441
|
+
}
|
|
989442
|
+
continue;
|
|
989443
|
+
}
|
|
989444
|
+
return arg;
|
|
989445
|
+
}
|
|
989446
|
+
return void 0;
|
|
989447
|
+
}
|
|
989448
|
+
|
|
989034
989449
|
// src/cli.ts
|
|
989035
989450
|
if (process.platform === "linux" && parseInt(process.versions.node.split(".")[0] ?? "0", 10) >= 26 && process.env.UV_USE_IO_URING !== "0") {
|
|
989036
989451
|
const result = (0, import_node_child_process14.spawnSync)(process.execPath, process.argv.slice(1), {
|
|
@@ -989077,7 +989492,7 @@ async function runCli() {
|
|
|
989077
989492
|
if (cwd2 != null) {
|
|
989078
989493
|
process.chdir(cwd2);
|
|
989079
989494
|
}
|
|
989080
|
-
if (isCompletion) {
|
|
989495
|
+
if (isCompletion || isVersionRedirectionExempt(process.argv)) {
|
|
989081
989496
|
await tryRunCli(cliContext);
|
|
989082
989497
|
} else {
|
|
989083
989498
|
const versionOfCliToRun = await getIntendedVersionOfCli(cliContext);
|
|
@@ -989167,6 +989582,7 @@ async function tryRunCli(cliContext) {
|
|
|
989167
989582
|
addAutomationsCommand(cli, cliContext);
|
|
989168
989583
|
addGetOrganizationCommand(cli, cliContext);
|
|
989169
989584
|
addGeneratorCommands(cli, cliContext);
|
|
989585
|
+
addOrgCommand2(cli, cliContext);
|
|
989170
989586
|
addProtocGenFernCommand(cli, cliContext);
|
|
989171
989587
|
addInstallDependenciesCommand(cli, cliContext);
|
|
989172
989588
|
cli.middleware(async (argv) => {
|
|
@@ -989180,6 +989596,14 @@ async function tryRunCli(cliContext) {
|
|
|
989180
989596
|
}
|
|
989181
989597
|
async function getIntendedVersionOfCli(cliContext) {
|
|
989182
989598
|
if (process.env.FERN_NO_VERSION_REDIRECTION === "true") {
|
|
989599
|
+
const orgId = await getOrganization2(cliContext);
|
|
989600
|
+
if (orgId != null) {
|
|
989601
|
+
await warnIfVersionOutsideOrgBounds({
|
|
989602
|
+
cliContext,
|
|
989603
|
+
orgId,
|
|
989604
|
+
currentVersion: cliContext.environment.packageVersion
|
|
989605
|
+
});
|
|
989606
|
+
}
|
|
989183
989607
|
return cliContext.environment.packageVersion;
|
|
989184
989608
|
}
|
|
989185
989609
|
const fernDirectory = await getFernDirectory();
|
|
@@ -989187,13 +989611,19 @@ async function getIntendedVersionOfCli(cliContext) {
|
|
|
989187
989611
|
const projectConfig = await cliContext.runTask(
|
|
989188
989612
|
(context3) => loadProjectConfig({ directory: fernDirectory, context: context3 })
|
|
989189
989613
|
);
|
|
989614
|
+
let intendedVersion;
|
|
989190
989615
|
if (projectConfig.version === "*") {
|
|
989191
|
-
|
|
989192
|
-
}
|
|
989193
|
-
|
|
989194
|
-
|
|
989616
|
+
intendedVersion = cliContext.environment.packageVersion;
|
|
989617
|
+
} else if (projectConfig.version === "latest") {
|
|
989618
|
+
intendedVersion = await getLatestVersionOfCli({ cliEnvironment: cliContext.environment });
|
|
989619
|
+
} else {
|
|
989620
|
+
intendedVersion = projectConfig.version;
|
|
989195
989621
|
}
|
|
989196
|
-
return
|
|
989622
|
+
return await applyOrgBoundsToVersion({
|
|
989623
|
+
cliContext,
|
|
989624
|
+
orgId: projectConfig.organization,
|
|
989625
|
+
intendedVersion
|
|
989626
|
+
});
|
|
989197
989627
|
}
|
|
989198
989628
|
return getLatestVersionOfCli({ cliEnvironment: cliContext.environment });
|
|
989199
989629
|
}
|
|
@@ -992004,6 +992434,77 @@ Remove ${matched.length} patch(es)? [y/N] `, resolvePrompt);
|
|
|
992004
992434
|
}
|
|
992005
992435
|
);
|
|
992006
992436
|
}
|
|
992437
|
+
function addOrgCommand2(cli, cliContext) {
|
|
992438
|
+
cli.command("org", "Manage org-level configuration", (yargs) => {
|
|
992439
|
+
yargs.command(
|
|
992440
|
+
"set",
|
|
992441
|
+
"Set an org-level config value (admin only)",
|
|
992442
|
+
(setYargs) => setYargs.command(
|
|
992443
|
+
"cli-version [version]",
|
|
992444
|
+
"Set the org's Fern CLI version policy: pin an exact version, or set a min/max range",
|
|
992445
|
+
(y4) => y4.positional("version", {
|
|
992446
|
+
type: "string",
|
|
992447
|
+
description: "Pin to an exact version (sets both the floor and ceiling)"
|
|
992448
|
+
}).option("min", {
|
|
992449
|
+
type: "string",
|
|
992450
|
+
description: "Minimum allowed CLI version (floor)"
|
|
992451
|
+
}).option("max", {
|
|
992452
|
+
type: "string",
|
|
992453
|
+
description: "Maximum allowed CLI version (ceiling)"
|
|
992454
|
+
}).option("org", { type: "string", description: "Override org ID" }),
|
|
992455
|
+
async (argv) => {
|
|
992456
|
+
cliContext.instrumentPostHogEvent({ command: "fern org set cli-version" });
|
|
992457
|
+
const { version: version7, min, max } = argv;
|
|
992458
|
+
if (version7 != null && (min != null || max != null)) {
|
|
992459
|
+
cliContext.failAndThrow(
|
|
992460
|
+
"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."
|
|
992461
|
+
);
|
|
992462
|
+
return;
|
|
992463
|
+
}
|
|
992464
|
+
if (version7 == null && min == null && max == null) {
|
|
992465
|
+
cliContext.failAndThrow(
|
|
992466
|
+
"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."
|
|
992467
|
+
);
|
|
992468
|
+
return;
|
|
992469
|
+
}
|
|
992470
|
+
if (version7 != null) {
|
|
992471
|
+
await setOrgCliVersion({ cliContext, min: version7, max: version7, org: argv.org });
|
|
992472
|
+
} else {
|
|
992473
|
+
await setOrgCliVersion({ cliContext, min, max, org: argv.org });
|
|
992474
|
+
}
|
|
992475
|
+
}
|
|
992476
|
+
).demandCommand(1, "Specify what to set, e.g. `fern org set cli-version 5.45.0`."),
|
|
992477
|
+
() => {
|
|
992478
|
+
}
|
|
992479
|
+
);
|
|
992480
|
+
yargs.command(
|
|
992481
|
+
"get",
|
|
992482
|
+
"View org-level config",
|
|
992483
|
+
(y4) => y4.option("org", { type: "string", description: "Override org ID" }).option("json", { type: "boolean", description: "Output as JSON" }),
|
|
992484
|
+
async (argv) => {
|
|
992485
|
+
cliContext.instrumentPostHogEvent({ command: "fern org get" });
|
|
992486
|
+
await getOrgConfig({ cliContext, org: argv.org, json: argv.json });
|
|
992487
|
+
}
|
|
992488
|
+
);
|
|
992489
|
+
yargs.command(
|
|
992490
|
+
"unset",
|
|
992491
|
+
"Remove an org-level config value (admin only)",
|
|
992492
|
+
(unsetYargs) => unsetYargs.command(
|
|
992493
|
+
"cli-version",
|
|
992494
|
+
"Clear the org's Fern CLI version policy (both bounds by default, or --min/--max for one end)",
|
|
992495
|
+
(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" }),
|
|
992496
|
+
async (argv) => {
|
|
992497
|
+
cliContext.instrumentPostHogEvent({ command: "fern org unset cli-version" });
|
|
992498
|
+
const field5 = argv.min && !argv.max ? "min" : argv.max && !argv.min ? "max" : "all";
|
|
992499
|
+
await unsetOrgCliVersion({ cliContext, org: argv.org, field: field5 });
|
|
992500
|
+
}
|
|
992501
|
+
).demandCommand(1, "Specify what to unset, e.g. `fern org unset cli-version`."),
|
|
992502
|
+
() => {
|
|
992503
|
+
}
|
|
992504
|
+
);
|
|
992505
|
+
return yargs;
|
|
992506
|
+
});
|
|
992507
|
+
}
|
|
992007
992508
|
function parseOwnerRepo(githubRepo) {
|
|
992008
992509
|
const cleaned = githubRepo.replace(/^https?:\/\//, "").replace(/\.git$/, "").replace(/^github\.com\//, "");
|
|
992009
992510
|
const parts = cleaned.split("/");
|
package/package.json
CHANGED