@fern-api/generator-cli 0.10.5 → 0.12.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/dist/cli.js +101 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -41,6 +41,52 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
41
41
|
mod
|
|
42
42
|
));
|
|
43
43
|
|
|
44
|
+
// ../commons/core-utils/lib/errorMessageOrString.js
|
|
45
|
+
function errorMessageOrString(error) {
|
|
46
|
+
return error instanceof Error ? error.message : String(error);
|
|
47
|
+
}
|
|
48
|
+
var init_errorMessageOrString = __esm({
|
|
49
|
+
"../commons/core-utils/lib/errorMessageOrString.js"() {
|
|
50
|
+
"use strict";
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// ../commons/core-utils/lib/examples.js
|
|
55
|
+
var init_examples = __esm({
|
|
56
|
+
"../commons/core-utils/lib/examples.js"() {
|
|
57
|
+
"use strict";
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// ../commons/core-utils/lib/extractErrorMessage.js
|
|
62
|
+
function extractErrorMessage(e) {
|
|
63
|
+
if (typeof e === "string") {
|
|
64
|
+
return e.length > 0 ? e : "Unknown error";
|
|
65
|
+
}
|
|
66
|
+
if (e instanceof Error) {
|
|
67
|
+
return e.message.length > 0 ? e.message : "Unknown error";
|
|
68
|
+
}
|
|
69
|
+
if (typeof e === "object" && e !== null && "message" in e && typeof e["message"] === "string") {
|
|
70
|
+
return e["message"].length > 0 ? e["message"] : "Unknown error";
|
|
71
|
+
}
|
|
72
|
+
const stringified = String(e);
|
|
73
|
+
return stringified.length > 0 ? stringified : "Unknown error";
|
|
74
|
+
}
|
|
75
|
+
var init_extractErrorMessage = __esm({
|
|
76
|
+
"../commons/core-utils/lib/extractErrorMessage.js"() {
|
|
77
|
+
"use strict";
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// ../commons/core-utils/lib/fernEnvVars.js
|
|
82
|
+
var FERN_JAVA_SKIP_FORMATTING_ENV_VAR;
|
|
83
|
+
var init_fernEnvVars = __esm({
|
|
84
|
+
"../commons/core-utils/lib/fernEnvVars.js"() {
|
|
85
|
+
"use strict";
|
|
86
|
+
FERN_JAVA_SKIP_FORMATTING_ENV_VAR = "FERN_JAVA_SKIP_FORMATTING";
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
44
90
|
// ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/constants.js
|
|
45
91
|
var require_constants = __commonJS({
|
|
46
92
|
"../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/constants.js"(exports2, module2) {
|
|
@@ -2034,6 +2080,17 @@ var require_semver2 = __commonJS({
|
|
|
2034
2080
|
}
|
|
2035
2081
|
});
|
|
2036
2082
|
|
|
2083
|
+
// ../commons/core-utils/lib/index.js
|
|
2084
|
+
var init_lib = __esm({
|
|
2085
|
+
"../commons/core-utils/lib/index.js"() {
|
|
2086
|
+
"use strict";
|
|
2087
|
+
init_errorMessageOrString();
|
|
2088
|
+
init_examples();
|
|
2089
|
+
init_extractErrorMessage();
|
|
2090
|
+
init_fernEnvVars();
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
|
|
2037
2094
|
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
2038
2095
|
var balanced, maybeMatch, range;
|
|
2039
2096
|
var init_esm = __esm({
|
|
@@ -30376,7 +30433,7 @@ async function loadBamlDependencies() {
|
|
|
30376
30433
|
configureBamlClient: config.configureBamlClient
|
|
30377
30434
|
};
|
|
30378
30435
|
} catch (error) {
|
|
30379
|
-
const original =
|
|
30436
|
+
const original = errorMessageOrString(error);
|
|
30380
30437
|
throw new Error(`${INSTALL_MESSAGE}
|
|
30381
30438
|
|
|
30382
30439
|
Original error: ${original}`);
|
|
@@ -30386,6 +30443,7 @@ var INSTALL_MESSAGE;
|
|
|
30386
30443
|
var init_loader = __esm({
|
|
30387
30444
|
"../cli/ai/lib/loader.js"() {
|
|
30388
30445
|
"use strict";
|
|
30446
|
+
init_lib();
|
|
30389
30447
|
INSTALL_MESSAGE = "@boundaryml/baml is required for AI features (auto-versioning, sdk-diff).\nInstall it with:\n npm install @boundaryml/baml\n pnpm add @boundaryml/baml";
|
|
30390
30448
|
}
|
|
30391
30449
|
});
|
|
@@ -30410,7 +30468,7 @@ __export(lib_exports, {
|
|
|
30410
30468
|
VersionBump: () => VersionBump3,
|
|
30411
30469
|
loadBamlDependencies: () => loadBamlDependencies
|
|
30412
30470
|
});
|
|
30413
|
-
var
|
|
30471
|
+
var init_lib2 = __esm({
|
|
30414
30472
|
"../cli/ai/lib/index.js"() {
|
|
30415
30473
|
"use strict";
|
|
30416
30474
|
init_loader();
|
|
@@ -30418,23 +30476,8 @@ var init_lib = __esm({
|
|
|
30418
30476
|
}
|
|
30419
30477
|
});
|
|
30420
30478
|
|
|
30421
|
-
//
|
|
30422
|
-
|
|
30423
|
-
if (typeof e === "string") {
|
|
30424
|
-
return e.length > 0 ? e : "Unknown error";
|
|
30425
|
-
}
|
|
30426
|
-
if (e instanceof Error) {
|
|
30427
|
-
return e.message.length > 0 ? e.message : "Unknown error";
|
|
30428
|
-
}
|
|
30429
|
-
if (typeof e === "object" && e !== null && "message" in e && typeof e["message"] === "string") {
|
|
30430
|
-
return e["message"].length > 0 ? e["message"] : "Unknown error";
|
|
30431
|
-
}
|
|
30432
|
-
const stringified = String(e);
|
|
30433
|
-
return stringified.length > 0 ? stringified : "Unknown error";
|
|
30434
|
-
}
|
|
30435
|
-
|
|
30436
|
-
// ../commons/core-utils/lib/fernEnvVars.js
|
|
30437
|
-
var FERN_JAVA_SKIP_FORMATTING_ENV_VAR = "FERN_JAVA_SKIP_FORMATTING";
|
|
30479
|
+
// src/cli.ts
|
|
30480
|
+
init_lib();
|
|
30438
30481
|
|
|
30439
30482
|
// ../commons/path-utils/lib/convertToOsPath.js
|
|
30440
30483
|
function convertToOsPath(path5) {
|
|
@@ -32448,6 +32491,7 @@ async function doesPathExist2(filepath) {
|
|
|
32448
32491
|
}
|
|
32449
32492
|
|
|
32450
32493
|
// ../commons/github/lib/cloneRepository.js
|
|
32494
|
+
init_lib();
|
|
32451
32495
|
var import_child_process2 = require("child_process");
|
|
32452
32496
|
init_esm4();
|
|
32453
32497
|
var import_tmp_promise = __toESM(require_tmp_promise(), 1);
|
|
@@ -40606,6 +40650,7 @@ var consolePipelineLogger = {
|
|
|
40606
40650
|
};
|
|
40607
40651
|
|
|
40608
40652
|
// src/pipeline/PostGenerationPipeline.ts
|
|
40653
|
+
init_lib();
|
|
40609
40654
|
var import_child_process8 = require("child_process");
|
|
40610
40655
|
|
|
40611
40656
|
// src/pipeline/github/constants.ts
|
|
@@ -42830,7 +42875,8 @@ ${body}` : `${COMMIT_MARKER} ${subject}`;
|
|
|
42830
42875
|
method: "POST",
|
|
42831
42876
|
headers: {
|
|
42832
42877
|
Authorization: `Bearer ${this.config.fernToken}`,
|
|
42833
|
-
"Content-Type": "application/json"
|
|
42878
|
+
"Content-Type": "application/json",
|
|
42879
|
+
...this.config.faiOrgId != null ? { "X-Fern-Org-Id": this.config.faiOrgId } : {}
|
|
42834
42880
|
},
|
|
42835
42881
|
body: JSON.stringify({
|
|
42836
42882
|
diff: cleanedDiff,
|
|
@@ -42873,7 +42919,7 @@ ${body}` : `${COMMIT_MARKER} ${subject}`;
|
|
|
42873
42919
|
if (this.config.ai == null) {
|
|
42874
42920
|
throw new Error("AutoVersionStep: ai config is missing. Set autoVersion.ai to a BAML provider+model pair.");
|
|
42875
42921
|
}
|
|
42876
|
-
const { loadBamlDependencies: loadBamlDependencies2, VersionBump: VersionBump4 } = await Promise.resolve().then(() => (
|
|
42922
|
+
const { loadBamlDependencies: loadBamlDependencies2, VersionBump: VersionBump4 } = await Promise.resolve().then(() => (init_lib2(), lib_exports));
|
|
42877
42923
|
const { BamlClient, configureBamlClient: configureBamlClient2 } = await loadBamlDependencies2();
|
|
42878
42924
|
const registry = configureBamlClient2(this.config.ai);
|
|
42879
42925
|
return {
|
|
@@ -43159,6 +43205,7 @@ function tryRevParse(cwd2, rev) {
|
|
|
43159
43205
|
}
|
|
43160
43206
|
|
|
43161
43207
|
// src/pipeline/steps/GithubStep.ts
|
|
43208
|
+
init_lib();
|
|
43162
43209
|
var import_promises17 = require("fs/promises");
|
|
43163
43210
|
var import_path25 = require("path");
|
|
43164
43211
|
|
|
@@ -43187,6 +43234,7 @@ async function createReplayBranch(repository, branchName, commitMessage, replayC
|
|
|
43187
43234
|
}
|
|
43188
43235
|
|
|
43189
43236
|
// src/pipeline/github/findExistingUpdatablePR.ts
|
|
43237
|
+
init_lib();
|
|
43190
43238
|
async function findExistingUpdatablePR(octokit, owner, repo, baseBranch, logger) {
|
|
43191
43239
|
try {
|
|
43192
43240
|
const { data: pulls } = await octokit.pulls.list({
|
|
@@ -43298,6 +43346,7 @@ ${prBody}`;
|
|
|
43298
43346
|
}
|
|
43299
43347
|
|
|
43300
43348
|
// src/pipeline/github/pushSignedCommit.ts
|
|
43349
|
+
init_lib();
|
|
43301
43350
|
var MAX_CONCURRENT_PUSH_RETRIES = 3;
|
|
43302
43351
|
var MAX_SIGNED_CHAIN_LENGTH = 20;
|
|
43303
43352
|
var PAT_TOKEN_PREFIXES = ["ghp_", "github_pat_"];
|
|
@@ -43774,6 +43823,9 @@ var GithubStep = class extends BaseStep {
|
|
|
43774
43823
|
} catch (error) {
|
|
43775
43824
|
this.logger.debug(`Failed to update PR title/body: ${extractErrorMessage(error)}`);
|
|
43776
43825
|
}
|
|
43826
|
+
if (shouldEnableAutomerge(this.config, resolved)) {
|
|
43827
|
+
await this.tryEnableAutomerge(octokit, existingPR.nodeId, existingPR.number, result);
|
|
43828
|
+
}
|
|
43777
43829
|
} else {
|
|
43778
43830
|
const head = `${owner}:${prBranch}`;
|
|
43779
43831
|
try {
|
|
@@ -43789,21 +43841,7 @@ var GithubStep = class extends BaseStep {
|
|
|
43789
43841
|
result.prUrl = pullRequest.html_url;
|
|
43790
43842
|
result.prNumber = pullRequest.number;
|
|
43791
43843
|
if (shouldEnableAutomerge(this.config, resolved) && pullRequest.node_id) {
|
|
43792
|
-
|
|
43793
|
-
await octokit.graphql(
|
|
43794
|
-
`mutation($pullRequestId: ID!) {
|
|
43795
|
-
enablePullRequestAutoMerge(input: {
|
|
43796
|
-
pullRequestId: $pullRequestId,
|
|
43797
|
-
mergeMethod: SQUASH
|
|
43798
|
-
}) { clientMutationId }
|
|
43799
|
-
}`,
|
|
43800
|
-
{ pullRequestId: pullRequest.node_id }
|
|
43801
|
-
);
|
|
43802
|
-
this.logger.info(`Enabled automerge on PR #${pullRequest.number}`);
|
|
43803
|
-
result.autoMergeEnabled = true;
|
|
43804
|
-
} catch (autoMergeError) {
|
|
43805
|
-
this.logger.warn(`Could not enable automerge: ${extractErrorMessage(autoMergeError)}`);
|
|
43806
|
-
}
|
|
43844
|
+
await this.tryEnableAutomerge(octokit, pullRequest.node_id, pullRequest.number, result);
|
|
43807
43845
|
}
|
|
43808
43846
|
} catch (error) {
|
|
43809
43847
|
const message = extractErrorMessage(error);
|
|
@@ -43816,6 +43854,28 @@ var GithubStep = class extends BaseStep {
|
|
|
43816
43854
|
}
|
|
43817
43855
|
return result;
|
|
43818
43856
|
}
|
|
43857
|
+
/**
|
|
43858
|
+
* Enables GitHub automerge on a non-breaking PR (newly created or updated) via the built-in
|
|
43859
|
+
* octokit.graphql() from @octokit/core. The SDK repo's own branch protection rules govern
|
|
43860
|
+
* whether the PR actually merges.
|
|
43861
|
+
*/
|
|
43862
|
+
async tryEnableAutomerge(octokit, pullRequestNodeId, pullRequestNumber, result) {
|
|
43863
|
+
try {
|
|
43864
|
+
await octokit.graphql(
|
|
43865
|
+
`mutation($pullRequestId: ID!) {
|
|
43866
|
+
enablePullRequestAutoMerge(input: {
|
|
43867
|
+
pullRequestId: $pullRequestId,
|
|
43868
|
+
mergeMethod: SQUASH
|
|
43869
|
+
}) { clientMutationId }
|
|
43870
|
+
}`,
|
|
43871
|
+
{ pullRequestId: pullRequestNodeId }
|
|
43872
|
+
);
|
|
43873
|
+
this.logger.info(`Enabled automerge on PR #${pullRequestNumber}`);
|
|
43874
|
+
result.autoMergeEnabled = true;
|
|
43875
|
+
} catch (autoMergeError) {
|
|
43876
|
+
this.logger.warn(`Could not enable automerge: ${extractErrorMessage(autoMergeError)}`);
|
|
43877
|
+
}
|
|
43878
|
+
}
|
|
43819
43879
|
async executePushMode(repository, resolved) {
|
|
43820
43880
|
const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
|
|
43821
43881
|
if (this.config.branch != null) {
|
|
@@ -44056,7 +44116,7 @@ _Fern Run ID: \`${config.runId}\`_`;
|
|
|
44056
44116
|
function shouldEnableAutomerge(config, breaking = {}) {
|
|
44057
44117
|
const hasBreakingChanges = breaking.hasBreakingChanges ?? config.hasBreakingChanges;
|
|
44058
44118
|
const analysisUnavailable = breaking.analysisWarning != null && breaking.analysisWarning.length > 0;
|
|
44059
|
-
return config.
|
|
44119
|
+
return config.autoMerge === true && hasBreakingChanges !== true && !analysisUnavailable;
|
|
44060
44120
|
}
|
|
44061
44121
|
function shouldCheckNoDiff(config) {
|
|
44062
44122
|
return config.skipIfNoDiff === true;
|
|
@@ -44254,6 +44314,9 @@ var ReplayStep = class extends BaseStep {
|
|
|
44254
44314
|
}
|
|
44255
44315
|
};
|
|
44256
44316
|
|
|
44317
|
+
// src/pipeline/steps/VerificationStep.ts
|
|
44318
|
+
init_lib();
|
|
44319
|
+
|
|
44257
44320
|
// ../cli/generation/local-generation/docker-utils/lib/dockerHubOatLogin.js
|
|
44258
44321
|
var DOCKERHUB_OAT_ENV_VAR = "DOCKERHUB_OAT";
|
|
44259
44322
|
var DOCKERHUB_OAT_USERNAME_ENV_VAR = "DOCKERHUB_OAT_USERNAME";
|
|
@@ -44319,6 +44382,7 @@ var import_promises18 = require("fs/promises");
|
|
|
44319
44382
|
var import_tmp_promise3 = __toESM(require_tmp_promise(), 1);
|
|
44320
44383
|
|
|
44321
44384
|
// ../cli/generation/local-generation/docker-utils/lib/buildContainerEnvVars.js
|
|
44385
|
+
init_lib();
|
|
44322
44386
|
var FORWARDED_ENV_VARS = ["FERN_STACK_TRACK", FERN_JAVA_SKIP_FORMATTING_ENV_VAR];
|
|
44323
44387
|
function buildContainerEnvVars({ envVars, processEnv }) {
|
|
44324
44388
|
const forwardedEntries = FORWARDED_ENV_VARS.filter((name) => envVars[name] == null).map((name) => [name, processEnv[name]]).filter((entry) => entry[1] != null && entry[1] !== "");
|