@fern-api/fern-api-dev 4.65.3-6-gfc20f801ab1 → 4.66.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 +431 -56
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -58630,6 +58630,24 @@ var init_ClonedRepository = __esm({
|
|
|
58630
58630
|
const result = await this.git.raw(["rev-parse", `${commitSha}^{tree}`]);
|
|
58631
58631
|
return result.trim();
|
|
58632
58632
|
}
|
|
58633
|
+
/**
|
|
58634
|
+
* Returns true if the working tree has uncommitted changes (staged or unstaged).
|
|
58635
|
+
*/
|
|
58636
|
+
async hasChanges() {
|
|
58637
|
+
await this.git.cwd(this.clonePath);
|
|
58638
|
+
const status = await this.git.status();
|
|
58639
|
+
return !status.isClean();
|
|
58640
|
+
}
|
|
58641
|
+
/**
|
|
58642
|
+
* Compares the tree hash of HEAD against a ref (e.g. `origin/main`).
|
|
58643
|
+
* Returns true if the trees are identical (no content difference).
|
|
58644
|
+
* Useful for detecting no-diff after committing — if trees match, the commit is a no-op.
|
|
58645
|
+
*/
|
|
58646
|
+
async treeHashEquals(ref2) {
|
|
58647
|
+
const headTree = await this.getHeadTreeHash();
|
|
58648
|
+
const refTree = await this.getCommitTreeHash(ref2);
|
|
58649
|
+
return headTree === refTree;
|
|
58650
|
+
}
|
|
58633
58651
|
// This tag is a moving pointer (fern-generation-base--<generator>) that tracks the latest
|
|
58634
58652
|
// clean generation SHA. --force is required because: (1) the tag is intentionally overwritten
|
|
58635
58653
|
// each generation, and (2) --force-with-lease doesn't work for tags since git tag -f overwrites
|
|
@@ -357485,6 +357503,9 @@ var require_GithubStep = __commonJS({
|
|
|
357485
357503
|
"use strict";
|
|
357486
357504
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
357487
357505
|
exports2.GithubStep = void 0;
|
|
357506
|
+
exports2.enrichPrBodyForAutomation = enrichPrBodyForAutomation;
|
|
357507
|
+
exports2.shouldEnableAutomerge = shouldEnableAutomerge;
|
|
357508
|
+
exports2.resolveBranchAction = resolveBranchAction;
|
|
357488
357509
|
var core_utils_1 = (init_lib4(), __toCommonJS(lib_exports));
|
|
357489
357510
|
var github_1 = (init_lib7(), __toCommonJS(lib_exports3));
|
|
357490
357511
|
var rest_1 = (init_dist_src9(), __toCommonJS(dist_src_exports));
|
|
@@ -357541,26 +357562,39 @@ var require_GithubStep = __commonJS({
|
|
|
357541
357562
|
const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
|
|
357542
357563
|
const octokit = new rest_1.Octokit({ auth: this.config.token });
|
|
357543
357564
|
const { owner, repo } = (0, github_1.parseRepository)(this.config.uri);
|
|
357544
|
-
const existingPR = await (0, findExistingUpdatablePR_1.findExistingUpdatablePR)(octokit, owner, repo, baseBranch, this.logger);
|
|
357545
357565
|
let prBranch;
|
|
357546
357566
|
let isUpdatingExistingPR = false;
|
|
357547
357567
|
let generationBaseSha;
|
|
357568
|
+
let existingPR;
|
|
357569
|
+
if (!this.config.automationMode) {
|
|
357570
|
+
existingPR = await (0, findExistingUpdatablePR_1.findExistingUpdatablePR)(octokit, owner, repo, baseBranch, this.logger);
|
|
357571
|
+
}
|
|
357548
357572
|
if (existingPR != null) {
|
|
357549
357573
|
this.logger.info(`Found existing updatable PR #${existingPR.number}, will update branch ${existingPR.headBranch}`);
|
|
357550
357574
|
prBranch = existingPR.headBranch;
|
|
357551
357575
|
isUpdatingExistingPR = true;
|
|
357552
|
-
if (skipCommit) {
|
|
357553
|
-
generationBaseSha = await (0, createReplayBranch_1.createReplayBranch)(repository, prBranch, this.config.commitMessage, replayConflictInfo, this.logger);
|
|
357554
|
-
} else {
|
|
357555
|
-
await repository.checkoutRemoteBranch(prBranch);
|
|
357556
|
-
}
|
|
357557
357576
|
} else {
|
|
357558
|
-
this.logger.debug(`No existing updatable PR found, creating new branch ${newPrBranch}`);
|
|
357577
|
+
this.logger.debug(this.config.automationMode ? `Automation mode: creating new branch ${newPrBranch}` : `No existing updatable PR found, creating new branch ${newPrBranch}`);
|
|
357559
357578
|
prBranch = newPrBranch;
|
|
357560
|
-
|
|
357579
|
+
}
|
|
357580
|
+
const branchAction = resolveBranchAction({
|
|
357581
|
+
automationMode: this.config.automationMode === true,
|
|
357582
|
+
skipCommit,
|
|
357583
|
+
existingPR
|
|
357584
|
+
});
|
|
357585
|
+
switch (branchAction) {
|
|
357586
|
+
case "replay-branch":
|
|
357561
357587
|
generationBaseSha = await (0, createReplayBranch_1.createReplayBranch)(repository, prBranch, this.config.commitMessage, replayConflictInfo, this.logger);
|
|
357562
|
-
|
|
357563
|
-
|
|
357588
|
+
break;
|
|
357589
|
+
case "create-from-head":
|
|
357590
|
+
await repository.createBranchFromHead(prBranch);
|
|
357591
|
+
break;
|
|
357592
|
+
case "checkout-remote":
|
|
357593
|
+
await repository.checkoutRemoteBranch(prBranch);
|
|
357594
|
+
break;
|
|
357595
|
+
default: {
|
|
357596
|
+
const _exhaustive = branchAction;
|
|
357597
|
+
throw new Error(`Unexpected branch action: ${String(_exhaustive)}`);
|
|
357564
357598
|
}
|
|
357565
357599
|
}
|
|
357566
357600
|
if (!skipCommit) {
|
|
@@ -357570,6 +357604,13 @@ var require_GithubStep = __commonJS({
|
|
|
357570
357604
|
await repository.commitAllChanges(finalCommitMessage2);
|
|
357571
357605
|
this.logger.debug(`Committed changes to local copy of GitHub repository at ${this.outputDir}`);
|
|
357572
357606
|
}
|
|
357607
|
+
if (this.config.automationMode) {
|
|
357608
|
+
const noDiff = await repository.treeHashEquals(`origin/${baseBranch}`);
|
|
357609
|
+
if (noDiff) {
|
|
357610
|
+
this.logger.info("No changes detected after generation \u2014 skipping PR creation");
|
|
357611
|
+
return { executed: true, success: true, skippedNoDiff: true };
|
|
357612
|
+
}
|
|
357613
|
+
}
|
|
357573
357614
|
const result = {
|
|
357574
357615
|
executed: true,
|
|
357575
357616
|
success: true,
|
|
@@ -357599,7 +357640,8 @@ var require_GithubStep = __commonJS({
|
|
|
357599
357640
|
const finalCommitMessage = this.config.commitMessage ?? "SDK Generation";
|
|
357600
357641
|
const { prTitle, prBody } = (0, parseCommitMessage_1.parseCommitMessageForPR)(finalCommitMessage, this.config.changelogEntry, this.config.prDescription, this.config.versionBumpReason);
|
|
357601
357642
|
const replaySection = (0, replay_summary_1.formatReplayPrBody)(replayResult, { branchName: prBranch, repoUri: this.config.uri });
|
|
357602
|
-
|
|
357643
|
+
let enrichedBody = replaySection != null ? prBody + "\n\n---\n\n" + replaySection : prBody;
|
|
357644
|
+
enrichedBody = enrichPrBodyForAutomation(enrichedBody, this.config);
|
|
357603
357645
|
if (isUpdatingExistingPR && existingPR != null) {
|
|
357604
357646
|
this.logger.info(`Updated existing pull request: ${existingPR.htmlUrl}`);
|
|
357605
357647
|
result.prUrl = existingPR.htmlUrl;
|
|
@@ -357630,6 +357672,20 @@ var require_GithubStep = __commonJS({
|
|
|
357630
357672
|
this.logger.info(`Created pull request: ${pullRequest.html_url}`);
|
|
357631
357673
|
result.prUrl = pullRequest.html_url;
|
|
357632
357674
|
result.prNumber = pullRequest.number;
|
|
357675
|
+
if (shouldEnableAutomerge(this.config) && pullRequest.node_id) {
|
|
357676
|
+
try {
|
|
357677
|
+
await octokit.graphql(`mutation($pullRequestId: ID!) {
|
|
357678
|
+
enablePullRequestAutoMerge(input: {
|
|
357679
|
+
pullRequestId: $pullRequestId,
|
|
357680
|
+
mergeMethod: SQUASH
|
|
357681
|
+
}) { clientMutationId }
|
|
357682
|
+
}`, { pullRequestId: pullRequest.node_id });
|
|
357683
|
+
this.logger.info(`Enabled automerge on PR #${pullRequest.number}`);
|
|
357684
|
+
result.autoMergeEnabled = true;
|
|
357685
|
+
} catch (autoMergeError) {
|
|
357686
|
+
this.logger.warn(`Could not enable automerge: ${(0, core_utils_1.extractErrorMessage)(autoMergeError)}`);
|
|
357687
|
+
}
|
|
357688
|
+
}
|
|
357633
357689
|
} catch (error50) {
|
|
357634
357690
|
const message = (0, core_utils_1.extractErrorMessage)(error50);
|
|
357635
357691
|
if (message.includes("A pull request already exists for")) {
|
|
@@ -357642,6 +357698,7 @@ var require_GithubStep = __commonJS({
|
|
|
357642
357698
|
return result;
|
|
357643
357699
|
}
|
|
357644
357700
|
async executePushMode(repository) {
|
|
357701
|
+
const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
|
|
357645
357702
|
if (this.config.branch != null) {
|
|
357646
357703
|
this.logger.debug(`Checking out branch ${this.config.branch}`);
|
|
357647
357704
|
await repository.checkout(this.config.branch);
|
|
@@ -357651,6 +357708,13 @@ var require_GithubStep = __commonJS({
|
|
|
357651
357708
|
const finalCommitMessage = this.config.commitMessage ?? "SDK Generation";
|
|
357652
357709
|
await repository.commitAllChanges(finalCommitMessage);
|
|
357653
357710
|
this.logger.debug(`Committed changes to local copy of GitHub repository at ${this.outputDir}`);
|
|
357711
|
+
if (this.config.automationMode) {
|
|
357712
|
+
const noDiff = await repository.treeHashEquals(`origin/${baseBranch}`);
|
|
357713
|
+
if (noDiff) {
|
|
357714
|
+
this.logger.info("No changes detected after generation \u2014 skipping push");
|
|
357715
|
+
return { executed: true, success: true, skippedNoDiff: true };
|
|
357716
|
+
}
|
|
357717
|
+
}
|
|
357654
357718
|
const result = {
|
|
357655
357719
|
executed: true,
|
|
357656
357720
|
success: true
|
|
@@ -357696,6 +357760,38 @@ var require_GithubStep = __commonJS({
|
|
|
357696
357760
|
}
|
|
357697
357761
|
};
|
|
357698
357762
|
exports2.GithubStep = GithubStep;
|
|
357763
|
+
function enrichPrBodyForAutomation(body, config5) {
|
|
357764
|
+
if (!config5.automationMode) {
|
|
357765
|
+
return body;
|
|
357766
|
+
}
|
|
357767
|
+
let result = body;
|
|
357768
|
+
if (config5.hasBreakingChanges && config5.breakingChangesSummary) {
|
|
357769
|
+
result += "\n\n---\n\n## \u26A0\uFE0F Breaking Changes\n\nThis release contains breaking changes that require manual review:\n\n" + config5.breakingChangesSummary;
|
|
357770
|
+
}
|
|
357771
|
+
if (config5.runId) {
|
|
357772
|
+
result += `
|
|
357773
|
+
|
|
357774
|
+
---
|
|
357775
|
+
|
|
357776
|
+
_Fern Run ID: \`${config5.runId}\`_`;
|
|
357777
|
+
}
|
|
357778
|
+
return result;
|
|
357779
|
+
}
|
|
357780
|
+
function shouldEnableAutomerge(config5) {
|
|
357781
|
+
return config5.automationMode === true && config5.autoMerge === true && config5.hasBreakingChanges !== true;
|
|
357782
|
+
}
|
|
357783
|
+
function resolveBranchAction({ automationMode, skipCommit, existingPR }) {
|
|
357784
|
+
if (skipCommit) {
|
|
357785
|
+
return "replay-branch";
|
|
357786
|
+
}
|
|
357787
|
+
if (automationMode) {
|
|
357788
|
+
return "create-from-head";
|
|
357789
|
+
}
|
|
357790
|
+
if (existingPR != null) {
|
|
357791
|
+
return "checkout-remote";
|
|
357792
|
+
}
|
|
357793
|
+
return "create-from-head";
|
|
357794
|
+
}
|
|
357699
357795
|
}
|
|
357700
357796
|
});
|
|
357701
357797
|
|
|
@@ -521452,6 +521548,7 @@ __export(generators_yml_exports, {
|
|
|
521452
521548
|
RemoveDiscriminantsFromSchemas: () => RemoveDiscriminantsFromSchemas,
|
|
521453
521549
|
UnionSettingsSchema: () => UnionSettingsSchema,
|
|
521454
521550
|
ai: () => ai_exports,
|
|
521551
|
+
automation: () => automation_exports,
|
|
521455
521552
|
fernDefinition: () => fernDefinition_exports,
|
|
521456
521553
|
generators: () => generators_exports,
|
|
521457
521554
|
getPackageName: () => getPackageName,
|
|
@@ -521467,6 +521564,7 @@ __export(generators_yml_exports, {
|
|
|
521467
521564
|
isRawProtobufAPIDefinitionSchema: () => isRawProtobufAPIDefinitionSchema,
|
|
521468
521565
|
license: () => license_exports,
|
|
521469
521566
|
replay: () => replay_exports,
|
|
521567
|
+
resolveAutomationConfig: () => resolveAutomationConfig,
|
|
521470
521568
|
reviewers: () => reviewers_exports,
|
|
521471
521569
|
serialization: () => serialization_exports4
|
|
521472
521570
|
});
|
|
@@ -521530,6 +521628,22 @@ function isRawProtobufAPIDefinitionSchema(rawApiConfiguration) {
|
|
|
521530
521628
|
return typeof rawApiConfiguration !== "string" && "proto" in rawApiConfiguration;
|
|
521531
521629
|
}
|
|
521532
521630
|
|
|
521631
|
+
// ../configuration/lib/generators-yml/resolveAutomationConfig.js
|
|
521632
|
+
var DEFAULT_AUTOMATION_CONFIG = {
|
|
521633
|
+
generate: true,
|
|
521634
|
+
upgrade: true,
|
|
521635
|
+
preview: true,
|
|
521636
|
+
verify: true
|
|
521637
|
+
};
|
|
521638
|
+
function resolveAutomationConfig({ rootAutomation, groupAutomation, generatorAutomation }) {
|
|
521639
|
+
return {
|
|
521640
|
+
generate: generatorAutomation?.generate ?? groupAutomation?.generate ?? rootAutomation?.generate ?? DEFAULT_AUTOMATION_CONFIG.generate,
|
|
521641
|
+
upgrade: generatorAutomation?.upgrade ?? groupAutomation?.upgrade ?? rootAutomation?.upgrade ?? DEFAULT_AUTOMATION_CONFIG.upgrade,
|
|
521642
|
+
preview: generatorAutomation?.preview ?? groupAutomation?.preview ?? rootAutomation?.preview ?? DEFAULT_AUTOMATION_CONFIG.preview,
|
|
521643
|
+
verify: generatorAutomation?.verify ?? groupAutomation?.verify ?? rootAutomation?.verify ?? DEFAULT_AUTOMATION_CONFIG.verify
|
|
521644
|
+
};
|
|
521645
|
+
}
|
|
521646
|
+
|
|
521533
521647
|
// ../configuration/lib/generators-yml/schemas/api/resources/ai/index.js
|
|
521534
521648
|
var ai_exports = {};
|
|
521535
521649
|
__export(ai_exports, {
|
|
@@ -521543,6 +521657,9 @@ var ModelProvider = {
|
|
|
521543
521657
|
Bedrock: "bedrock"
|
|
521544
521658
|
};
|
|
521545
521659
|
|
|
521660
|
+
// ../configuration/lib/generators-yml/schemas/api/resources/automation/index.js
|
|
521661
|
+
var automation_exports = {};
|
|
521662
|
+
|
|
521546
521663
|
// ../configuration/lib/generators-yml/schemas/api/resources/fernDefinition/index.js
|
|
521547
521664
|
var fernDefinition_exports = {};
|
|
521548
521665
|
__export(fernDefinition_exports, {
|
|
@@ -521726,6 +521843,7 @@ __export(serialization_exports4, {
|
|
|
521726
521843
|
ApiDefinitionWithOverridesSchema: () => ApiDefinitionWithOverridesSchema,
|
|
521727
521844
|
AsyncApiSettingsSchema: () => AsyncApiSettingsSchema,
|
|
521728
521845
|
AsyncApiSpecSchema: () => AsyncApiSpecSchema,
|
|
521846
|
+
AutomationSchema: () => AutomationSchema,
|
|
521729
521847
|
BaseApiSettingsSchema: () => BaseApiSettingsSchema,
|
|
521730
521848
|
BaseGeneratorInvocationSchema: () => BaseGeneratorInvocationSchema,
|
|
521731
521849
|
CoerceConstsTo: () => CoerceConstsTo2,
|
|
@@ -521799,6 +521917,7 @@ __export(serialization_exports4, {
|
|
|
521799
521917
|
WhitelabelConfigurationSchema: () => WhitelabelConfigurationSchema,
|
|
521800
521918
|
WhitelabelGithubConfigurationSchema: () => WhitelabelGithubConfigurationSchema,
|
|
521801
521919
|
ai: () => ai_exports2,
|
|
521920
|
+
automation: () => automation_exports2,
|
|
521802
521921
|
fernDefinition: () => fernDefinition_exports2,
|
|
521803
521922
|
generators: () => generators_exports2,
|
|
521804
521923
|
group: () => group_exports2,
|
|
@@ -523238,6 +523357,20 @@ var AiServicesSchema = schemas_exports8.object({
|
|
|
523238
523357
|
model: ModelName
|
|
523239
523358
|
});
|
|
523240
523359
|
|
|
523360
|
+
// ../configuration/lib/generators-yml/schemas/serialization/resources/automation/index.js
|
|
523361
|
+
var automation_exports2 = {};
|
|
523362
|
+
__export(automation_exports2, {
|
|
523363
|
+
AutomationSchema: () => AutomationSchema
|
|
523364
|
+
});
|
|
523365
|
+
|
|
523366
|
+
// ../configuration/lib/generators-yml/schemas/serialization/resources/automation/types/AutomationSchema.js
|
|
523367
|
+
var AutomationSchema = schemas_exports8.object({
|
|
523368
|
+
generate: schemas_exports8.boolean().optional(),
|
|
523369
|
+
upgrade: schemas_exports8.boolean().optional(),
|
|
523370
|
+
preview: schemas_exports8.boolean().optional(),
|
|
523371
|
+
verify: schemas_exports8.boolean().optional()
|
|
523372
|
+
});
|
|
523373
|
+
|
|
523241
523374
|
// ../configuration/lib/generators-yml/schemas/serialization/resources/fernDefinition/index.js
|
|
523242
523375
|
var fernDefinition_exports2 = {};
|
|
523243
523376
|
__export(fernDefinition_exports2, {
|
|
@@ -524198,7 +524331,8 @@ var BaseGeneratorInvocationSchema = schemas_exports8.object({
|
|
|
524198
524331
|
api: GeneratorApiSettingsSchema.optional(),
|
|
524199
524332
|
"disable-examples": schemas_exports8.boolean().optional(),
|
|
524200
524333
|
"publish-metadata": GeneratorPublishMetadataSchema.optional(),
|
|
524201
|
-
autorelease: schemas_exports8.boolean().optional()
|
|
524334
|
+
autorelease: schemas_exports8.boolean().optional(),
|
|
524335
|
+
automation: AutomationSchema.optional()
|
|
524202
524336
|
});
|
|
524203
524337
|
|
|
524204
524338
|
// ../configuration/lib/generators-yml/schemas/serialization/resources/group/types/CustomGeneratorInvocationSchema.js
|
|
@@ -524219,7 +524353,8 @@ var GeneratorGroupSchema = schemas_exports8.object({
|
|
|
524219
524353
|
audiences: schemas_exports8.list(schemas_exports8.string()).optional(),
|
|
524220
524354
|
generators: schemas_exports8.list(GeneratorInvocationSchema),
|
|
524221
524355
|
metadata: OutputMetadataSchema.optional(),
|
|
524222
|
-
reviewers: ReviewersSchema.optional()
|
|
524356
|
+
reviewers: ReviewersSchema.optional(),
|
|
524357
|
+
automation: AutomationSchema.optional()
|
|
524223
524358
|
});
|
|
524224
524359
|
|
|
524225
524360
|
// ../configuration/lib/generators-yml/schemas/serialization/resources/replay/types/ReplayConfigSchema.js
|
|
@@ -524298,6 +524433,7 @@ var GeneratorsConfigurationSchema = schemas_exports8.object({
|
|
|
524298
524433
|
replay: ReplayConfigSchema.optional(),
|
|
524299
524434
|
ai: AiServicesSchema.optional(),
|
|
524300
524435
|
autorelease: schemas_exports8.boolean().optional(),
|
|
524436
|
+
automation: AutomationSchema.optional(),
|
|
524301
524437
|
openapi: GeneratorsOpenApiSchema.optional(),
|
|
524302
524438
|
"openapi-overrides": schemas_exports8.string().optional(),
|
|
524303
524439
|
"spec-origin": schemas_exports8.string().optional(),
|
|
@@ -557180,6 +557316,7 @@ async function convertGeneratorsConfiguration({ absolutePathToGeneratorsConfigur
|
|
|
557180
557316
|
group,
|
|
557181
557317
|
maybeTopLevelMetadata,
|
|
557182
557318
|
maybeTopLevelReviewers: rawGeneratorsConfiguration.reviewers,
|
|
557319
|
+
maybeRootAutomation: rawGeneratorsConfiguration.automation,
|
|
557183
557320
|
readme,
|
|
557184
557321
|
context: context3
|
|
557185
557322
|
}))) : [],
|
|
@@ -557545,7 +557682,7 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
|
|
|
557545
557682
|
definitions: await parseAPIConfigurationToApiLocations(apiConfiguration, rawGeneratorsConfiguration, emptySettings)
|
|
557546
557683
|
};
|
|
557547
557684
|
}
|
|
557548
|
-
async function convertGroup({ absolutePathToGeneratorsConfiguration, groupName, group, maybeTopLevelMetadata, maybeTopLevelReviewers, readme, context: context3 }) {
|
|
557685
|
+
async function convertGroup({ absolutePathToGeneratorsConfiguration, groupName, group, maybeTopLevelMetadata, maybeTopLevelReviewers, maybeRootAutomation, readme, context: context3 }) {
|
|
557549
557686
|
const maybeGroupLevelMetadata = getOutputMetadata(group.metadata);
|
|
557550
557687
|
return {
|
|
557551
557688
|
groupName,
|
|
@@ -557558,6 +557695,8 @@ async function convertGroup({ absolutePathToGeneratorsConfiguration, groupName,
|
|
|
557558
557695
|
maybeGroupLevelMetadata,
|
|
557559
557696
|
maybeTopLevelReviewers,
|
|
557560
557697
|
maybeGroupLevelReviewers: group.reviewers,
|
|
557698
|
+
maybeRootAutomation,
|
|
557699
|
+
maybeGroupAutomation: group.automation,
|
|
557561
557700
|
readme,
|
|
557562
557701
|
context: context3
|
|
557563
557702
|
})))
|
|
@@ -557579,10 +557718,15 @@ function getGeneratorNameAndImage(generator, context3) {
|
|
|
557579
557718
|
containerImage: void 0
|
|
557580
557719
|
};
|
|
557581
557720
|
}
|
|
557582
|
-
async function convertGenerator({ absolutePathToGeneratorsConfiguration, generator, maybeGroupLevelMetadata, maybeTopLevelMetadata, maybeGroupLevelReviewers, maybeTopLevelReviewers, readme, context: context3 }) {
|
|
557721
|
+
async function convertGenerator({ absolutePathToGeneratorsConfiguration, generator, maybeGroupLevelMetadata, maybeTopLevelMetadata, maybeGroupLevelReviewers, maybeTopLevelReviewers, maybeRootAutomation, maybeGroupAutomation, readme, context: context3 }) {
|
|
557583
557722
|
const { normalizedName, containerImage } = getGeneratorNameAndImage(generator, context3);
|
|
557584
557723
|
return {
|
|
557585
557724
|
raw: generator,
|
|
557725
|
+
automation: generators_yml_exports.resolveAutomationConfig({
|
|
557726
|
+
rootAutomation: maybeRootAutomation,
|
|
557727
|
+
groupAutomation: maybeGroupAutomation,
|
|
557728
|
+
generatorAutomation: generator.automation
|
|
557729
|
+
}),
|
|
557586
557730
|
name: normalizedName,
|
|
557587
557731
|
containerImage,
|
|
557588
557732
|
version: generator.version,
|
|
@@ -627388,7 +627532,7 @@ var AccessTokenPosthogManager = class {
|
|
|
627388
627532
|
properties: {
|
|
627389
627533
|
...event,
|
|
627390
627534
|
...event.properties,
|
|
627391
|
-
version: "4.
|
|
627535
|
+
version: "4.66.0",
|
|
627392
627536
|
usingAccessToken: true
|
|
627393
627537
|
}
|
|
627394
627538
|
});
|
|
@@ -627439,7 +627583,7 @@ var UserPosthogManager = class {
|
|
|
627439
627583
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
627440
627584
|
event: "CLI",
|
|
627441
627585
|
properties: {
|
|
627442
|
-
version: "4.
|
|
627586
|
+
version: "4.66.0",
|
|
627443
627587
|
...event,
|
|
627444
627588
|
...event.properties,
|
|
627445
627589
|
usingAccessToken: false,
|
|
@@ -843668,7 +843812,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
843668
843812
|
var LOGS_FOLDER_NAME = "logs";
|
|
843669
843813
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
843670
843814
|
function getCliSource() {
|
|
843671
|
-
const version7 = "4.
|
|
843815
|
+
const version7 = "4.66.0";
|
|
843672
843816
|
return `cli@${version7}`;
|
|
843673
843817
|
}
|
|
843674
843818
|
var DebugLogger = class {
|
|
@@ -846076,6 +846220,7 @@ async function visitGeneratorsYamlAst(contents, cliVersion, visitor) {
|
|
|
846076
846220
|
ai: noop2,
|
|
846077
846221
|
autorelease: noop2,
|
|
846078
846222
|
replay: noop2,
|
|
846223
|
+
automation: noop2,
|
|
846079
846224
|
groups: async (groups2) => {
|
|
846080
846225
|
await visitGeneratorGroups({ groups: groups2, visitor, nodePath: ["groups"], cliVersion });
|
|
846081
846226
|
}
|
|
@@ -852784,7 +852929,7 @@ async function retryWithRateLimit({ fn: fn5, retryRateLimited, logger: logger4,
|
|
|
852784
852929
|
|
|
852785
852930
|
// ../generation/remote-generation/remote-workspace-runner/lib/createAndStartJob.js
|
|
852786
852931
|
var gzipAsync = (0, import_util19.promisify)(import_zlib5.gzip);
|
|
852787
|
-
async function createAndStartJob({ projectConfig, workspace, organization, intermediateRepresentation, generatorInvocation, version: version7, context: context3, shouldLogS3Url, token, whitelabel, irVersionOverride, absolutePathToPreview, fernignorePath, skipFernignore, retryRateLimited }) {
|
|
852932
|
+
async function createAndStartJob({ projectConfig, workspace, organization, intermediateRepresentation, generatorInvocation, version: version7, context: context3, shouldLogS3Url, token, whitelabel, irVersionOverride, absolutePathToPreview, fernignorePath, skipFernignore, retryRateLimited, automationMode, autoMerge }) {
|
|
852788
852933
|
let fernignoreContents;
|
|
852789
852934
|
if (skipFernignore) {
|
|
852790
852935
|
fernignoreContents = "";
|
|
@@ -852807,7 +852952,9 @@ async function createAndStartJob({ projectConfig, workspace, organization, inter
|
|
|
852807
852952
|
token,
|
|
852808
852953
|
whitelabel,
|
|
852809
852954
|
absolutePathToPreview,
|
|
852810
|
-
fernignoreContents
|
|
852955
|
+
fernignoreContents,
|
|
852956
|
+
automationMode,
|
|
852957
|
+
autoMerge
|
|
852811
852958
|
}),
|
|
852812
852959
|
retryRateLimited,
|
|
852813
852960
|
logger: context3.logger,
|
|
@@ -852839,6 +852986,12 @@ async function createJob({ projectConfig, workspace, organization, generatorInvo
|
|
|
852839
852986
|
whitelabel,
|
|
852840
852987
|
preview: absolutePathToPreview != null,
|
|
852841
852988
|
fernignoreContents
|
|
852989
|
+
// TODO(FER-9671): Pass automation flags to Fiddle once its API is updated:
|
|
852990
|
+
// automationMode,
|
|
852991
|
+
// autoMerge,
|
|
852992
|
+
// runId: process.env.FERN_RUN_ID
|
|
852993
|
+
// Fiddle will use these for server-side no-diff detection, separate PRs,
|
|
852994
|
+
// automerge, run_id correlation, and breaking change handling.
|
|
852842
852995
|
});
|
|
852843
852996
|
if (!createResponse.ok) {
|
|
852844
852997
|
const rawError = createResponse.error;
|
|
@@ -853417,7 +853570,7 @@ var SourceUploader = class {
|
|
|
853417
853570
|
};
|
|
853418
853571
|
|
|
853419
853572
|
// ../generation/remote-generation/remote-workspace-runner/lib/runRemoteGenerationForGenerator.js
|
|
853420
|
-
async function runRemoteGenerationForGenerator({ projectConfig, organization, workspace, interactiveTaskContext, generatorInvocation, version: version7, audiences, shouldLogS3Url, token, whitelabel, irVersionOverride, absolutePathToPreview, readme, fernignorePath, skipFernignore, dynamicIrOnly, retryRateLimited, requireEnvVars }) {
|
|
853573
|
+
async function runRemoteGenerationForGenerator({ projectConfig, organization, workspace, interactiveTaskContext, generatorInvocation, version: version7, audiences, shouldLogS3Url, token, whitelabel, irVersionOverride, absolutePathToPreview, readme, fernignorePath, skipFernignore, dynamicIrOnly, retryRateLimited, requireEnvVars, automationMode, autoMerge }) {
|
|
853421
853574
|
const fdr = createFdrService({ token: token.value });
|
|
853422
853575
|
const fdrOrigin = "https://registry-dev2.buildwithfern.com";
|
|
853423
853576
|
const isAirGapped = await detectAirGappedMode(`${fdrOrigin}/health`, interactiveTaskContext.logger);
|
|
@@ -853582,7 +853735,9 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
|
|
|
853582
853735
|
absolutePathToPreview,
|
|
853583
853736
|
fernignorePath,
|
|
853584
853737
|
skipFernignore,
|
|
853585
|
-
retryRateLimited
|
|
853738
|
+
retryRateLimited,
|
|
853739
|
+
automationMode,
|
|
853740
|
+
autoMerge
|
|
853586
853741
|
});
|
|
853587
853742
|
interactiveTaskContext.logger.debug(`Job ID: ${job.jobId}`);
|
|
853588
853743
|
const taskId = job.taskIds[0];
|
|
@@ -853717,7 +853872,7 @@ async function uploadDynamicIRForSdkGeneration({ fdr, organization, version: ver
|
|
|
853717
853872
|
}
|
|
853718
853873
|
|
|
853719
853874
|
// ../generation/remote-generation/remote-workspace-runner/lib/runRemoteGenerationForAPIWorkspace.js
|
|
853720
|
-
async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization, workspace, context: context3, generatorGroup, version: version7, shouldLogS3Url, token, whitelabel, absolutePathToPreview, mode, fernignorePath, skipFernignore, dynamicIrOnly, validateWorkspace, retryRateLimited, requireEnvVars }) {
|
|
853875
|
+
async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization, workspace, context: context3, generatorGroup, version: version7, shouldLogS3Url, token, whitelabel, absolutePathToPreview, mode, fernignorePath, skipFernignore, dynamicIrOnly, validateWorkspace, retryRateLimited, requireEnvVars, automationMode, autoMerge }) {
|
|
853721
853876
|
if (generatorGroup.generators.length === 0) {
|
|
853722
853877
|
context3.logger.warn("No generators specified.");
|
|
853723
853878
|
return null;
|
|
@@ -853777,7 +853932,9 @@ async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization,
|
|
|
853777
853932
|
skipFernignore,
|
|
853778
853933
|
dynamicIrOnly,
|
|
853779
853934
|
retryRateLimited,
|
|
853780
|
-
requireEnvVars
|
|
853935
|
+
requireEnvVars,
|
|
853936
|
+
automationMode,
|
|
853937
|
+
autoMerge
|
|
853781
853938
|
});
|
|
853782
853939
|
if (remoteTaskHandlerResponse != null && remoteTaskHandlerResponse.createdSnippets) {
|
|
853783
853940
|
snippetsProducedBy.push(generatorInvocation);
|
|
@@ -854866,7 +855023,7 @@ var LegacyDocsPublisher = class {
|
|
|
854866
855023
|
previewId,
|
|
854867
855024
|
disableTemplates: void 0,
|
|
854868
855025
|
skipUpload,
|
|
854869
|
-
cliVersion: "4.
|
|
855026
|
+
cliVersion: "4.66.0"
|
|
854870
855027
|
});
|
|
854871
855028
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
854872
855029
|
return { success: false };
|
|
@@ -906235,7 +906392,8 @@ var LocalTaskHandler = class {
|
|
|
906235
906392
|
autoVersioningCommitMessage: autoVersionResult.commitMessage,
|
|
906236
906393
|
autoVersioningChangelogEntry: autoVersionResult.changelogEntry,
|
|
906237
906394
|
autoVersioningPrDescription: autoVersionResult.prDescription,
|
|
906238
|
-
autoVersioningVersionBumpReason: autoVersionResult.versionBumpReason
|
|
906395
|
+
autoVersioningVersionBumpReason: autoVersionResult.versionBumpReason,
|
|
906396
|
+
autoVersioningVersionBump: autoVersionResult.versionBump
|
|
906239
906397
|
};
|
|
906240
906398
|
}
|
|
906241
906399
|
return { shouldCommit: true, autoVersioningCommitMessage: void 0 };
|
|
@@ -906394,7 +906552,8 @@ var LocalTaskHandler = class {
|
|
|
906394
906552
|
commitMessage,
|
|
906395
906553
|
changelogEntry,
|
|
906396
906554
|
prDescription,
|
|
906397
|
-
versionBumpReason
|
|
906555
|
+
versionBumpReason,
|
|
906556
|
+
versionBump: finalBump
|
|
906398
906557
|
};
|
|
906399
906558
|
} catch (error50) {
|
|
906400
906559
|
if (error50 instanceof AutoVersioningException) {
|
|
@@ -906897,7 +907056,7 @@ function getGeneratorOutputSubfolder(generatorName) {
|
|
|
906897
907056
|
}
|
|
906898
907057
|
|
|
906899
907058
|
// ../generation/local-generation/local-workspace-runner/lib/runLocalGenerationForWorkspace.js
|
|
906900
|
-
async function runLocalGenerationForWorkspace({ token, projectConfig, workspace, generatorGroup, version: version7, keepDocker, inspect: inspect6, context: context3, absolutePathToPreview, runner, ai: ai7, replay, noReplay, validateWorkspace, requireEnvVars, skipFernignore, publishToRegistry, isPreview: isPreviewOverride }) {
|
|
907059
|
+
async function runLocalGenerationForWorkspace({ token, projectConfig, workspace, generatorGroup, version: version7, keepDocker, inspect: inspect6, context: context3, absolutePathToPreview, runner, ai: ai7, replay, noReplay, validateWorkspace, requireEnvVars, skipFernignore, publishToRegistry, isPreview: isPreviewOverride, automationMode, autoMerge }) {
|
|
906901
907060
|
const userProvidedVersion = version7;
|
|
906902
907061
|
if (userProvidedVersion != null) {
|
|
906903
907062
|
if (absolutePathToPreview != null) {
|
|
@@ -907062,7 +907221,7 @@ generators:
|
|
|
907062
907221
|
absolutePathToLocalSnippetJSON = AbsoluteFilePath2.of((await getWorkspaceTempDir()).path + "/snippet.json");
|
|
907063
907222
|
}
|
|
907064
907223
|
const workspaceTempDir = await getWorkspaceTempDir();
|
|
907065
|
-
const { shouldCommit, autoVersioningCommitMessage, autoVersioningChangelogEntry, autoVersioningPrDescription, autoVersioningVersionBumpReason } = await writeFilesToDiskAndRunGenerator({
|
|
907224
|
+
const { shouldCommit, autoVersioningCommitMessage, autoVersioningChangelogEntry, autoVersioningPrDescription, autoVersioningVersionBumpReason, autoVersioningVersionBump } = await writeFilesToDiskAndRunGenerator({
|
|
907066
907225
|
organization: projectConfig.organization,
|
|
907067
907226
|
absolutePathToFernConfig: workspace.generatorsConfiguration?.absolutePathToConfiguration ?? projectConfig._absolutePath,
|
|
907068
907227
|
workspace: fernWorkspace,
|
|
@@ -907101,6 +907260,7 @@ generators:
|
|
|
907101
907260
|
warn: (msg) => interactiveTaskContext.logger.warn(msg),
|
|
907102
907261
|
error: (msg) => interactiveTaskContext.logger.error(msg)
|
|
907103
907262
|
};
|
|
907263
|
+
const hasBreakingChanges = autoVersioningVersionBump === "MAJOR";
|
|
907104
907264
|
const pipeline5 = new import_generator_cli.PostGenerationPipeline({
|
|
907105
907265
|
outputDir: absolutePathToLocalOutput,
|
|
907106
907266
|
replay: { enabled: replay?.enabled === true, skipApplication: noReplay, stageOnly: false },
|
|
@@ -907115,7 +907275,12 @@ generators:
|
|
|
907115
907275
|
prDescription: autoVersioningPrDescription,
|
|
907116
907276
|
versionBumpReason: autoVersioningVersionBumpReason,
|
|
907117
907277
|
previewMode: selfhostedGithubConfig.previewMode,
|
|
907118
|
-
generatorName: generatorInvocation.name
|
|
907278
|
+
generatorName: generatorInvocation.name,
|
|
907279
|
+
automationMode,
|
|
907280
|
+
autoMerge,
|
|
907281
|
+
hasBreakingChanges,
|
|
907282
|
+
breakingChangesSummary: hasBreakingChanges ? autoVersioningPrDescription : void 0,
|
|
907283
|
+
runId: process.env.FERN_RUN_ID
|
|
907119
907284
|
},
|
|
907120
907285
|
cliVersion: workspace.cliVersion ?? "unknown",
|
|
907121
907286
|
generatorVersions: {
|
|
@@ -907132,6 +907297,12 @@ generators:
|
|
|
907132
907297
|
error: (msg) => interactiveTaskContext.logger.error(source_default.red(msg))
|
|
907133
907298
|
});
|
|
907134
907299
|
}
|
|
907300
|
+
if (pipelineResult.steps.github?.skippedNoDiff) {
|
|
907301
|
+
interactiveTaskContext.logger.info(source_default.green("No changes detected \u2014 skipping PR creation"));
|
|
907302
|
+
}
|
|
907303
|
+
if (pipelineResult.steps.github?.autoMergeEnabled) {
|
|
907304
|
+
interactiveTaskContext.logger.info(source_default.green("Automerge enabled on PR"));
|
|
907305
|
+
}
|
|
907135
907306
|
if (!pipelineResult.success) {
|
|
907136
907307
|
interactiveTaskContext.failAndThrow(`Post-generation pipeline failed: ${pipelineResult.errors?.join(", ")}`);
|
|
907137
907308
|
}
|
|
@@ -907447,7 +907618,13 @@ var LegacyGeneratorInvocationAdapter = class {
|
|
|
907447
907618
|
irVersionOverride: void 0,
|
|
907448
907619
|
keywords: void 0,
|
|
907449
907620
|
publishMetadata: void 0,
|
|
907450
|
-
settings: void 0
|
|
907621
|
+
settings: void 0,
|
|
907622
|
+
automation: {
|
|
907623
|
+
generate: true,
|
|
907624
|
+
upgrade: true,
|
|
907625
|
+
preview: true,
|
|
907626
|
+
verify: true
|
|
907627
|
+
}
|
|
907451
907628
|
};
|
|
907452
907629
|
}
|
|
907453
907630
|
buildRaw(target) {
|
|
@@ -928442,7 +928619,7 @@ var CliContext = class {
|
|
|
928442
928619
|
if (false) {
|
|
928443
928620
|
this.logger.error("CLI_VERSION is not defined");
|
|
928444
928621
|
}
|
|
928445
|
-
return "4.
|
|
928622
|
+
return "4.66.0";
|
|
928446
928623
|
}
|
|
928447
928624
|
getCliName() {
|
|
928448
928625
|
if (false) {
|
|
@@ -937561,6 +937738,47 @@ async function formatWorkspaces({
|
|
|
937561
937738
|
);
|
|
937562
937739
|
}
|
|
937563
937740
|
|
|
937741
|
+
// src/commands/generate/filterGenerators.ts
|
|
937742
|
+
function parseGeneratorArg(generatorArg) {
|
|
937743
|
+
if (generatorArg == null) {
|
|
937744
|
+
return { generatorName: void 0, generatorIndex: void 0 };
|
|
937745
|
+
}
|
|
937746
|
+
const parsed = generatorArg.length > 0 ? Number(generatorArg) : Number.NaN;
|
|
937747
|
+
if (!Number.isNaN(parsed) && Number.isInteger(parsed) && parsed >= 0) {
|
|
937748
|
+
return { generatorName: void 0, generatorIndex: parsed };
|
|
937749
|
+
}
|
|
937750
|
+
return { generatorName: generatorArg, generatorIndex: void 0 };
|
|
937751
|
+
}
|
|
937752
|
+
function filterGenerators({
|
|
937753
|
+
generators,
|
|
937754
|
+
generatorIndex,
|
|
937755
|
+
generatorName,
|
|
937756
|
+
groupName
|
|
937757
|
+
}) {
|
|
937758
|
+
if (generatorIndex != null) {
|
|
937759
|
+
const generator = generators[generatorIndex];
|
|
937760
|
+
if (generator == null) {
|
|
937761
|
+
return {
|
|
937762
|
+
ok: false,
|
|
937763
|
+
error: `Generator index ${generatorIndex} is out of bounds in group '${groupName}' (${generators.length} generators available)`
|
|
937764
|
+
};
|
|
937765
|
+
}
|
|
937766
|
+
return { ok: true, generators: [generator] };
|
|
937767
|
+
}
|
|
937768
|
+
if (generatorName != null) {
|
|
937769
|
+
const filtered = generators.filter((gen) => gen.name === generatorName);
|
|
937770
|
+
if (filtered.length === 0) {
|
|
937771
|
+
const available = generators.map((gen) => gen.name);
|
|
937772
|
+
return {
|
|
937773
|
+
ok: false,
|
|
937774
|
+
error: `Generator '${generatorName}' not found in group '${groupName}'. Available generators: ${available.join(", ")}`
|
|
937775
|
+
};
|
|
937776
|
+
}
|
|
937777
|
+
return { ok: true, generators: filtered };
|
|
937778
|
+
}
|
|
937779
|
+
return { ok: true, generators };
|
|
937780
|
+
}
|
|
937781
|
+
|
|
937564
937782
|
// src/commands/generate/generateAPIWorkspaces.ts
|
|
937565
937783
|
init_lib6();
|
|
937566
937784
|
|
|
@@ -937660,6 +937878,7 @@ async function generateWorkspace({
|
|
|
937660
937878
|
context: context3,
|
|
937661
937879
|
groupName,
|
|
937662
937880
|
generatorName,
|
|
937881
|
+
generatorIndex,
|
|
937663
937882
|
version: version7,
|
|
937664
937883
|
shouldLogS3Url,
|
|
937665
937884
|
token,
|
|
@@ -937675,7 +937894,9 @@ async function generateWorkspace({
|
|
|
937675
937894
|
dynamicIrOnly,
|
|
937676
937895
|
noReplay,
|
|
937677
937896
|
retryRateLimited,
|
|
937678
|
-
requireEnvVars
|
|
937897
|
+
requireEnvVars,
|
|
937898
|
+
automationMode,
|
|
937899
|
+
autoMerge
|
|
937679
937900
|
}) {
|
|
937680
937901
|
if (workspace.generatorsConfiguration == null) {
|
|
937681
937902
|
context3.logger.warn("This workspaces has no generators.yml");
|
|
@@ -937720,16 +937941,16 @@ async function generateWorkspace({
|
|
|
937720
937941
|
if (group == null) {
|
|
937721
937942
|
return context3.failAndThrow(`Group '${resolvedGroupName}' does not exist.`);
|
|
937722
937943
|
}
|
|
937723
|
-
|
|
937724
|
-
|
|
937725
|
-
|
|
937726
|
-
|
|
937727
|
-
|
|
937728
|
-
|
|
937729
|
-
|
|
937730
|
-
|
|
937731
|
-
group = { ...group, generators: filteredGenerators };
|
|
937944
|
+
const filterResult = filterGenerators({
|
|
937945
|
+
generators: group.generators,
|
|
937946
|
+
generatorIndex,
|
|
937947
|
+
generatorName,
|
|
937948
|
+
groupName: resolvedGroupName
|
|
937949
|
+
});
|
|
937950
|
+
if (!filterResult.ok) {
|
|
937951
|
+
return context3.failAndThrow(filterResult.error);
|
|
937732
937952
|
}
|
|
937953
|
+
group = { ...group, generators: filterResult.generators };
|
|
937733
937954
|
if (lfsOverride != null) {
|
|
937734
937955
|
group = applyLfsOverride(group, lfsOverride, context3);
|
|
937735
937956
|
}
|
|
@@ -937753,7 +937974,9 @@ async function generateWorkspace({
|
|
|
937753
937974
|
noReplay,
|
|
937754
937975
|
validateWorkspace: true,
|
|
937755
937976
|
requireEnvVars,
|
|
937756
|
-
skipFernignore
|
|
937977
|
+
skipFernignore,
|
|
937978
|
+
automationMode,
|
|
937979
|
+
autoMerge
|
|
937757
937980
|
});
|
|
937758
937981
|
} else if (token != null) {
|
|
937759
937982
|
const customImageGenerators = group.generators.filter((g19) => g19.containerImage != null);
|
|
@@ -937780,7 +938003,9 @@ async function generateWorkspace({
|
|
|
937780
938003
|
dynamicIrOnly,
|
|
937781
938004
|
validateWorkspace: true,
|
|
937782
938005
|
retryRateLimited,
|
|
937783
|
-
requireEnvVars
|
|
938006
|
+
requireEnvVars,
|
|
938007
|
+
automationMode,
|
|
938008
|
+
autoMerge
|
|
937784
938009
|
});
|
|
937785
938010
|
}
|
|
937786
938011
|
})
|
|
@@ -937882,6 +938107,7 @@ async function generateAPIWorkspaces({
|
|
|
937882
938107
|
version: version7,
|
|
937883
938108
|
groupName,
|
|
937884
938109
|
generatorName,
|
|
938110
|
+
generatorIndex,
|
|
937885
938111
|
shouldLogS3Url,
|
|
937886
938112
|
keepDocker,
|
|
937887
938113
|
useLocalDocker,
|
|
@@ -937897,7 +938123,9 @@ async function generateAPIWorkspaces({
|
|
|
937897
938123
|
outputDir,
|
|
937898
938124
|
noReplay,
|
|
937899
938125
|
retryRateLimited,
|
|
937900
|
-
requireEnvVars
|
|
938126
|
+
requireEnvVars,
|
|
938127
|
+
automationMode,
|
|
938128
|
+
autoMerge
|
|
937901
938129
|
}) {
|
|
937902
938130
|
let token = void 0;
|
|
937903
938131
|
if (!useLocalDocker) {
|
|
@@ -937917,14 +938145,27 @@ async function generateAPIWorkspaces({
|
|
|
937917
938145
|
}
|
|
937918
938146
|
for (const workspace of project.apiWorkspaces) {
|
|
937919
938147
|
const resolvedGroupNames = resolveGroupNamesForWorkspace(groupName, workspace.generatorsConfiguration);
|
|
937920
|
-
for (const
|
|
937921
|
-
|
|
937922
|
-
|
|
937923
|
-
|
|
937924
|
-
|
|
937925
|
-
|
|
937926
|
-
|
|
937927
|
-
|
|
938148
|
+
for (const group of workspace.generatorsConfiguration?.groups.filter(
|
|
938149
|
+
(group2) => resolvedGroupNames == null || resolvedGroupNames.includes(group2.groupName)
|
|
938150
|
+
) ?? []) {
|
|
938151
|
+
const filterResult = filterGenerators({
|
|
938152
|
+
generators: group.generators,
|
|
938153
|
+
generatorIndex,
|
|
938154
|
+
generatorName,
|
|
938155
|
+
groupName: group.groupName
|
|
938156
|
+
});
|
|
938157
|
+
if (!filterResult.ok) {
|
|
938158
|
+
continue;
|
|
938159
|
+
}
|
|
938160
|
+
for (const generator of filterResult.generators) {
|
|
938161
|
+
const { shouldProceed } = await checkOutputDirectory(
|
|
938162
|
+
generator.absolutePathToLocalOutput,
|
|
938163
|
+
cliContext,
|
|
938164
|
+
force
|
|
938165
|
+
);
|
|
938166
|
+
if (!shouldProceed) {
|
|
938167
|
+
cliContext.failAndThrow("Generation cancelled");
|
|
938168
|
+
}
|
|
937928
938169
|
}
|
|
937929
938170
|
}
|
|
937930
938171
|
}
|
|
@@ -937966,6 +938207,7 @@ async function generateAPIWorkspaces({
|
|
|
937966
938207
|
version: version7,
|
|
937967
938208
|
groupName,
|
|
937968
938209
|
generatorName,
|
|
938210
|
+
generatorIndex,
|
|
937969
938211
|
shouldLogS3Url,
|
|
937970
938212
|
token,
|
|
937971
938213
|
useLocalDocker,
|
|
@@ -937980,7 +938222,9 @@ async function generateAPIWorkspaces({
|
|
|
937980
938222
|
dynamicIrOnly,
|
|
937981
938223
|
noReplay,
|
|
937982
938224
|
retryRateLimited,
|
|
937983
|
-
requireEnvVars
|
|
938225
|
+
requireEnvVars,
|
|
938226
|
+
automationMode,
|
|
938227
|
+
autoMerge
|
|
937984
938228
|
});
|
|
937985
938229
|
});
|
|
937986
938230
|
})
|
|
@@ -946557,6 +946801,7 @@ async function tryRunCli(cliContext) {
|
|
|
946557
946801
|
addReplayCommand(cli, cliContext);
|
|
946558
946802
|
addBetaCommand(cli, cliContext);
|
|
946559
946803
|
addSdkCommand2(cli, cliContext);
|
|
946804
|
+
addAutomationsCommand(cli, cliContext);
|
|
946560
946805
|
addGetOrganizationCommand(cli, cliContext);
|
|
946561
946806
|
addGeneratorCommands(cli, cliContext);
|
|
946562
946807
|
addProtocGenFernCommand(cli, cliContext);
|
|
@@ -947029,6 +947274,7 @@ function addGenerateCommand2(cli, cliContext) {
|
|
|
947029
947274
|
return cliContext.failWithoutThrowing("The --output flag is not supported for docs generation.");
|
|
947030
947275
|
}
|
|
947031
947276
|
const correctedGeneratorFilter = argv.generator != null ? warnAndCorrectIncorrectDockerOrg(argv.generator, cliContext) : void 0;
|
|
947277
|
+
const { generatorName, generatorIndex } = parseGeneratorArg(correctedGeneratorFilter);
|
|
947032
947278
|
if (argv.api != null) {
|
|
947033
947279
|
return await generateAPIWorkspaces({
|
|
947034
947280
|
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
@@ -947038,7 +947284,8 @@ function addGenerateCommand2(cli, cliContext) {
|
|
|
947038
947284
|
cliContext,
|
|
947039
947285
|
version: argv.version,
|
|
947040
947286
|
groupName: argv.group,
|
|
947041
|
-
generatorName
|
|
947287
|
+
generatorName,
|
|
947288
|
+
generatorIndex,
|
|
947042
947289
|
shouldLogS3Url: argv.printZipUrl,
|
|
947043
947290
|
keepDocker: argv.keepDocker,
|
|
947044
947291
|
useLocalDocker: argv.local || argv.runner != null,
|
|
@@ -947096,7 +947343,8 @@ function addGenerateCommand2(cli, cliContext) {
|
|
|
947096
947343
|
cliContext,
|
|
947097
947344
|
version: argv.version,
|
|
947098
947345
|
groupName: argv.group,
|
|
947099
|
-
generatorName
|
|
947346
|
+
generatorName,
|
|
947347
|
+
generatorIndex,
|
|
947100
947348
|
shouldLogS3Url: argv.printZipUrl,
|
|
947101
947349
|
keepDocker: argv.keepDocker,
|
|
947102
947350
|
useLocalDocker: argv.local,
|
|
@@ -948202,6 +948450,133 @@ function addSdkCommand2(cli, cliContext) {
|
|
|
948202
948450
|
return yargs.demandCommand();
|
|
948203
948451
|
});
|
|
948204
948452
|
}
|
|
948453
|
+
function addAutomationsCommand(cli, cliContext) {
|
|
948454
|
+
cli.command("automations", false, (yargs) => {
|
|
948455
|
+
addAutomationsListCommand(yargs, cliContext);
|
|
948456
|
+
addAutomationsGenerateCommand(yargs, cliContext);
|
|
948457
|
+
return yargs.demandCommand();
|
|
948458
|
+
});
|
|
948459
|
+
}
|
|
948460
|
+
function addAutomationsListCommand(cli, cliContext) {
|
|
948461
|
+
cli.command("list", false, (yargs) => {
|
|
948462
|
+
addAutomationsListGenerateCommand(yargs, cliContext);
|
|
948463
|
+
return yargs.demandCommand();
|
|
948464
|
+
});
|
|
948465
|
+
}
|
|
948466
|
+
function addAutomationsListGenerateCommand(cli, cliContext) {
|
|
948467
|
+
cli.command(
|
|
948468
|
+
"generate",
|
|
948469
|
+
false,
|
|
948470
|
+
// hidden
|
|
948471
|
+
(yargs) => yargs.option("group", {
|
|
948472
|
+
type: "string",
|
|
948473
|
+
description: "Filter to a specific generator group (e.g. 'sdk'). Omit to list all groups."
|
|
948474
|
+
}).option("api", {
|
|
948475
|
+
type: "string",
|
|
948476
|
+
description: "Filter to a specific API in a multi-API repo (e.g. 'foo' for fern/apis/foo/). Omit to list all APIs."
|
|
948477
|
+
}).option("version", {
|
|
948478
|
+
type: "string",
|
|
948479
|
+
description: "Version string to include in generated commands (e.g. 'AUTO' for AI-based versioning)"
|
|
948480
|
+
}).option("auto-merge", {
|
|
948481
|
+
boolean: true,
|
|
948482
|
+
default: false,
|
|
948483
|
+
description: "Include --auto-merge flag in generated commands"
|
|
948484
|
+
}),
|
|
948485
|
+
async (argv) => {
|
|
948486
|
+
const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
948487
|
+
commandLineApiWorkspace: argv.api,
|
|
948488
|
+
defaultToAllApiWorkspaces: true
|
|
948489
|
+
});
|
|
948490
|
+
const commands = [];
|
|
948491
|
+
for (const workspace of project.apiWorkspaces) {
|
|
948492
|
+
const groups2 = workspace.generatorsConfiguration?.groups ?? [];
|
|
948493
|
+
for (const group of groups2) {
|
|
948494
|
+
if (argv.group != null && group.groupName !== argv.group) {
|
|
948495
|
+
continue;
|
|
948496
|
+
}
|
|
948497
|
+
for (let i11 = 0; i11 < group.generators.length; i11++) {
|
|
948498
|
+
const generator = group.generators[i11];
|
|
948499
|
+
if (generator == null || !generator.automation.generate) {
|
|
948500
|
+
continue;
|
|
948501
|
+
}
|
|
948502
|
+
const parts = ["fern", "automations", "generate"];
|
|
948503
|
+
if (workspace.workspaceName != null) {
|
|
948504
|
+
parts.push("--api", workspace.workspaceName);
|
|
948505
|
+
}
|
|
948506
|
+
parts.push("--group", group.groupName);
|
|
948507
|
+
parts.push("--generator", String(i11));
|
|
948508
|
+
if (argv.version != null) {
|
|
948509
|
+
parts.push("--version", argv.version);
|
|
948510
|
+
}
|
|
948511
|
+
if (argv["auto-merge"]) {
|
|
948512
|
+
parts.push("--auto-merge");
|
|
948513
|
+
}
|
|
948514
|
+
commands.push(parts.join(" "));
|
|
948515
|
+
}
|
|
948516
|
+
}
|
|
948517
|
+
}
|
|
948518
|
+
process.stdout.write(JSON.stringify(commands));
|
|
948519
|
+
}
|
|
948520
|
+
);
|
|
948521
|
+
}
|
|
948522
|
+
function addAutomationsGenerateCommand(cli, cliContext) {
|
|
948523
|
+
cli.command(
|
|
948524
|
+
"generate",
|
|
948525
|
+
false,
|
|
948526
|
+
// hidden
|
|
948527
|
+
(yargs) => yargs.option("api", {
|
|
948528
|
+
type: "string",
|
|
948529
|
+
description: "Target a specific API in a multi-API repo (e.g. 'foo' for fern/apis/foo/). Required when the project has multiple APIs."
|
|
948530
|
+
}).option("group", {
|
|
948531
|
+
type: "string",
|
|
948532
|
+
description: "The generator group to run (e.g. 'sdk'). Falls back to default-group in generators.yml if omitted."
|
|
948533
|
+
}).option("generator", {
|
|
948534
|
+
type: "string",
|
|
948535
|
+
description: "Target a specific generator by 0-based index (e.g. '0', '1') or by name. Index is preferred for deterministic targeting when duplicate names exist."
|
|
948536
|
+
}).option("version", {
|
|
948537
|
+
type: "string",
|
|
948538
|
+
description: "Version for generated packages. Use 'AUTO' for AI-based semantic versioning that analyzes the diff and determines MAJOR/MINOR/PATCH automatically."
|
|
948539
|
+
}).option("auto-merge", {
|
|
948540
|
+
boolean: true,
|
|
948541
|
+
default: false,
|
|
948542
|
+
description: "Enable GitHub automerge on generated PRs. Automerge is skipped when breaking changes (MAJOR bump) are detected, regardless of this flag."
|
|
948543
|
+
}),
|
|
948544
|
+
async (argv) => {
|
|
948545
|
+
const { generatorName: genName, generatorIndex: genIndex } = parseGeneratorArg(argv.generator);
|
|
948546
|
+
await cliContext.runTask(async () => {
|
|
948547
|
+
await generateAPIWorkspaces({
|
|
948548
|
+
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
948549
|
+
commandLineApiWorkspace: argv.api,
|
|
948550
|
+
defaultToAllApiWorkspaces: false
|
|
948551
|
+
}),
|
|
948552
|
+
cliContext,
|
|
948553
|
+
version: argv.version,
|
|
948554
|
+
groupName: argv.group,
|
|
948555
|
+
generatorName: genName,
|
|
948556
|
+
generatorIndex: genIndex,
|
|
948557
|
+
shouldLogS3Url: false,
|
|
948558
|
+
keepDocker: false,
|
|
948559
|
+
useLocalDocker: false,
|
|
948560
|
+
preview: false,
|
|
948561
|
+
mode: void 0,
|
|
948562
|
+
force: true,
|
|
948563
|
+
runner: void 0,
|
|
948564
|
+
inspect: false,
|
|
948565
|
+
lfsOverride: void 0,
|
|
948566
|
+
fernignorePath: void 0,
|
|
948567
|
+
skipFernignore: false,
|
|
948568
|
+
dynamicIrOnly: false,
|
|
948569
|
+
outputDir: void 0,
|
|
948570
|
+
noReplay: false,
|
|
948571
|
+
retryRateLimited: false,
|
|
948572
|
+
requireEnvVars: false,
|
|
948573
|
+
automationMode: true,
|
|
948574
|
+
autoMerge: argv["auto-merge"]
|
|
948575
|
+
});
|
|
948576
|
+
});
|
|
948577
|
+
}
|
|
948578
|
+
);
|
|
948579
|
+
}
|
|
948205
948580
|
function addSdkPreviewCommand(cli, cliContext) {
|
|
948206
948581
|
cli.command(
|
|
948207
948582
|
"preview",
|
package/package.json
CHANGED