@fern-api/generator-cli 0.11.0 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +99 -36
  2. 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 = error instanceof Error ? error.message : String(error);
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 init_lib = __esm({
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
- // ../commons/core-utils/lib/extractErrorMessage.js
30422
- function extractErrorMessage(e) {
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
@@ -42874,7 +42919,7 @@ ${body}` : `${COMMIT_MARKER} ${subject}`;
42874
42919
  if (this.config.ai == null) {
42875
42920
  throw new Error("AutoVersionStep: ai config is missing. Set autoVersion.ai to a BAML provider+model pair.");
42876
42921
  }
42877
- const { loadBamlDependencies: loadBamlDependencies2, VersionBump: VersionBump4 } = await Promise.resolve().then(() => (init_lib(), lib_exports));
42922
+ const { loadBamlDependencies: loadBamlDependencies2, VersionBump: VersionBump4 } = await Promise.resolve().then(() => (init_lib2(), lib_exports));
42878
42923
  const { BamlClient, configureBamlClient: configureBamlClient2 } = await loadBamlDependencies2();
42879
42924
  const registry = configureBamlClient2(this.config.ai);
42880
42925
  return {
@@ -43160,6 +43205,7 @@ function tryRevParse(cwd2, rev) {
43160
43205
  }
43161
43206
 
43162
43207
  // src/pipeline/steps/GithubStep.ts
43208
+ init_lib();
43163
43209
  var import_promises17 = require("fs/promises");
43164
43210
  var import_path25 = require("path");
43165
43211
 
@@ -43188,6 +43234,7 @@ async function createReplayBranch(repository, branchName, commitMessage, replayC
43188
43234
  }
43189
43235
 
43190
43236
  // src/pipeline/github/findExistingUpdatablePR.ts
43237
+ init_lib();
43191
43238
  async function findExistingUpdatablePR(octokit, owner, repo, baseBranch, logger) {
43192
43239
  try {
43193
43240
  const { data: pulls } = await octokit.pulls.list({
@@ -43299,6 +43346,7 @@ ${prBody}`;
43299
43346
  }
43300
43347
 
43301
43348
  // src/pipeline/github/pushSignedCommit.ts
43349
+ init_lib();
43302
43350
  var MAX_CONCURRENT_PUSH_RETRIES = 3;
43303
43351
  var MAX_SIGNED_CHAIN_LENGTH = 20;
43304
43352
  var PAT_TOKEN_PREFIXES = ["ghp_", "github_pat_"];
@@ -43775,6 +43823,9 @@ var GithubStep = class extends BaseStep {
43775
43823
  } catch (error) {
43776
43824
  this.logger.debug(`Failed to update PR title/body: ${extractErrorMessage(error)}`);
43777
43825
  }
43826
+ if (shouldEnableAutomerge(this.config, resolved)) {
43827
+ await this.tryEnableAutomerge(octokit, existingPR.nodeId, existingPR.number, result);
43828
+ }
43778
43829
  } else {
43779
43830
  const head = `${owner}:${prBranch}`;
43780
43831
  try {
@@ -43790,21 +43841,7 @@ var GithubStep = class extends BaseStep {
43790
43841
  result.prUrl = pullRequest.html_url;
43791
43842
  result.prNumber = pullRequest.number;
43792
43843
  if (shouldEnableAutomerge(this.config, resolved) && pullRequest.node_id) {
43793
- try {
43794
- await octokit.graphql(
43795
- `mutation($pullRequestId: ID!) {
43796
- enablePullRequestAutoMerge(input: {
43797
- pullRequestId: $pullRequestId,
43798
- mergeMethod: SQUASH
43799
- }) { clientMutationId }
43800
- }`,
43801
- { pullRequestId: pullRequest.node_id }
43802
- );
43803
- this.logger.info(`Enabled automerge on PR #${pullRequest.number}`);
43804
- result.autoMergeEnabled = true;
43805
- } catch (autoMergeError) {
43806
- this.logger.warn(`Could not enable automerge: ${extractErrorMessage(autoMergeError)}`);
43807
- }
43844
+ await this.tryEnableAutomerge(octokit, pullRequest.node_id, pullRequest.number, result);
43808
43845
  }
43809
43846
  } catch (error) {
43810
43847
  const message = extractErrorMessage(error);
@@ -43817,6 +43854,28 @@ var GithubStep = class extends BaseStep {
43817
43854
  }
43818
43855
  return result;
43819
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
+ }
43820
43879
  async executePushMode(repository, resolved) {
43821
43880
  const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
43822
43881
  if (this.config.branch != null) {
@@ -44057,7 +44116,7 @@ _Fern Run ID: \`${config.runId}\`_`;
44057
44116
  function shouldEnableAutomerge(config, breaking = {}) {
44058
44117
  const hasBreakingChanges = breaking.hasBreakingChanges ?? config.hasBreakingChanges;
44059
44118
  const analysisUnavailable = breaking.analysisWarning != null && breaking.analysisWarning.length > 0;
44060
- return config.automationMode === true && config.autoMerge === true && hasBreakingChanges !== true && !analysisUnavailable;
44119
+ return config.autoMerge === true && hasBreakingChanges !== true && !analysisUnavailable;
44061
44120
  }
44062
44121
  function shouldCheckNoDiff(config) {
44063
44122
  return config.skipIfNoDiff === true;
@@ -44255,6 +44314,9 @@ var ReplayStep = class extends BaseStep {
44255
44314
  }
44256
44315
  };
44257
44316
 
44317
+ // src/pipeline/steps/VerificationStep.ts
44318
+ init_lib();
44319
+
44258
44320
  // ../cli/generation/local-generation/docker-utils/lib/dockerHubOatLogin.js
44259
44321
  var DOCKERHUB_OAT_ENV_VAR = "DOCKERHUB_OAT";
44260
44322
  var DOCKERHUB_OAT_USERNAME_ENV_VAR = "DOCKERHUB_OAT_USERNAME";
@@ -44320,6 +44382,7 @@ var import_promises18 = require("fs/promises");
44320
44382
  var import_tmp_promise3 = __toESM(require_tmp_promise(), 1);
44321
44383
 
44322
44384
  // ../cli/generation/local-generation/docker-utils/lib/buildContainerEnvVars.js
44385
+ init_lib();
44323
44386
  var FORWARDED_ENV_VARS = ["FERN_STACK_TRACK", FERN_JAVA_SKIP_FORMATTING_ENV_VAR];
44324
44387
  function buildContainerEnvVars({ envVars, processEnv }) {
44325
44388
  const forwardedEntries = FORWARDED_ENV_VARS.filter((name) => envVars[name] == null).map((name) => [name, processEnv[name]]).filter((entry) => entry[1] != null && entry[1] !== "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",