@fern-api/generator-cli 0.6.5 → 0.6.7
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/api.js +12 -3
- package/dist/cli.js +37 -21
- package/package.json +2 -2
package/dist/api.js
CHANGED
|
@@ -5541,6 +5541,10 @@ var ClonedRepository = class _ClonedRepository {
|
|
|
5541
5541
|
await this.git.push("origin", branch, { "--set-upstream": null });
|
|
5542
5542
|
}
|
|
5543
5543
|
}
|
|
5544
|
+
async fetch(args) {
|
|
5545
|
+
await this.git.cwd(this.clonePath);
|
|
5546
|
+
await this.git.fetch(args);
|
|
5547
|
+
}
|
|
5544
5548
|
async pull(branch) {
|
|
5545
5549
|
await this.git.cwd(this.clonePath);
|
|
5546
5550
|
await this.git.pull("origin", branch);
|
|
@@ -5666,12 +5670,13 @@ var ClonedRepository = class _ClonedRepository {
|
|
|
5666
5670
|
await this.git.push("origin", branch, { "--set-upstream": null });
|
|
5667
5671
|
}
|
|
5668
5672
|
// Only used by replay's PR mode to push synthetic divergent commits to a fern-bot/ branch.
|
|
5669
|
-
//
|
|
5670
|
-
//
|
|
5673
|
+
// These branches are exclusively owned by the pipeline — no human pushes to them.
|
|
5674
|
+
// Uses --force (not --force-with-lease) because the lease check fails after
|
|
5675
|
+
// git fetch --unshallow updates remote refs. Never targets main or user branches.
|
|
5671
5676
|
async forcePush() {
|
|
5672
5677
|
await this.git.cwd(this.clonePath);
|
|
5673
5678
|
const currentBranch = await this.getCurrentBranch();
|
|
5674
|
-
await this.git.push("origin", currentBranch, ["--force
|
|
5679
|
+
await this.git.push("origin", currentBranch, ["--force"]);
|
|
5675
5680
|
}
|
|
5676
5681
|
async createBranchFromHead(branchName) {
|
|
5677
5682
|
await this.git.cwd(this.clonePath);
|
|
@@ -10034,6 +10039,10 @@ var GithubStep = class extends BaseStep {
|
|
|
10034
10039
|
try {
|
|
10035
10040
|
this.logger.debug("Starting GitHub self-hosted flow in directory: " + this.outputDir);
|
|
10036
10041
|
const repository = ClonedRepository.createAtPath(this.outputDir);
|
|
10042
|
+
try {
|
|
10043
|
+
await repository.fetch(["--unshallow"]);
|
|
10044
|
+
} catch {
|
|
10045
|
+
}
|
|
10037
10046
|
const now = /* @__PURE__ */ new Date();
|
|
10038
10047
|
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
|
|
10039
10048
|
const newPrBranch = `fern-bot/${formattedDate}`;
|
package/dist/cli.js
CHANGED
|
@@ -19327,7 +19327,7 @@ var init_diff3 = __esm({
|
|
|
19327
19327
|
}
|
|
19328
19328
|
});
|
|
19329
19329
|
|
|
19330
|
-
// ../../node_modules/.pnpm/@fern-api+replay@0.6.
|
|
19330
|
+
// ../../node_modules/.pnpm/@fern-api+replay@0.6.2/node_modules/@fern-api/replay/dist/index.js
|
|
19331
19331
|
var dist_exports = {};
|
|
19332
19332
|
__export(dist_exports, {
|
|
19333
19333
|
FERN_BOT_EMAIL: () => FERN_BOT_EMAIL2,
|
|
@@ -19686,7 +19686,7 @@ function status(outputDir) {
|
|
|
19686
19686
|
}
|
|
19687
19687
|
var import_fs6, import_path8, import_yaml, import_crypto, import_promises4, import_os, import_path9, import_fs7, import_path10, import_crypto2, import_fs8, import_path11, import_yaml2, import_crypto3, import_fs9, import_path12, import_fs10, __defProp3, __getOwnPropNames3, __esm3, __export3, GitClient_exports, GitClient, init_GitClient, FERN_BOT_NAME2, FERN_BOT_EMAIL2, FERN_BOT_LOGIN2, FERN_SUPPORT_NAMES, LOCKFILE_HEADER, LockfileManager, INFRASTRUCTURE_FILES, ReplayDetector, BINARY_EXTENSIONS, ReplayApplicator, ReplayCommitter, ReplayService, FernignoreMigrator, REPLAY_FERNIGNORE_ENTRIES;
|
|
19688
19688
|
var init_dist = __esm({
|
|
19689
|
-
"../../node_modules/.pnpm/@fern-api+replay@0.6.
|
|
19689
|
+
"../../node_modules/.pnpm/@fern-api+replay@0.6.2/node_modules/@fern-api/replay/dist/index.js"() {
|
|
19690
19690
|
"use strict";
|
|
19691
19691
|
init_esm4();
|
|
19692
19692
|
import_fs6 = require("fs");
|
|
@@ -20560,12 +20560,12 @@ CLI Version: ${options.cliVersion}`;
|
|
|
20560
20560
|
await this.git.exec(["commit", "-m", fullMessage]);
|
|
20561
20561
|
return (await this.git.exec(["rev-parse", "HEAD"])).trim();
|
|
20562
20562
|
}
|
|
20563
|
-
async commitReplay(
|
|
20563
|
+
async commitReplay(_patchCount, patches) {
|
|
20564
20564
|
await this.stageAll();
|
|
20565
20565
|
if (!await this.hasStagedChanges()) {
|
|
20566
20566
|
return (await this.git.exec(["rev-parse", "HEAD"])).trim();
|
|
20567
20567
|
}
|
|
20568
|
-
let fullMessage = `[fern-replay] Applied
|
|
20568
|
+
let fullMessage = `[fern-replay] Applied customizations`;
|
|
20569
20569
|
if (patches && patches.length > 0) {
|
|
20570
20570
|
fullMessage += "\n\nPatches replayed:";
|
|
20571
20571
|
for (const patch of patches) {
|
|
@@ -22992,6 +22992,10 @@ var ClonedRepository = class _ClonedRepository {
|
|
|
22992
22992
|
await this.git.push("origin", branch, { "--set-upstream": null });
|
|
22993
22993
|
}
|
|
22994
22994
|
}
|
|
22995
|
+
async fetch(args) {
|
|
22996
|
+
await this.git.cwd(this.clonePath);
|
|
22997
|
+
await this.git.fetch(args);
|
|
22998
|
+
}
|
|
22995
22999
|
async pull(branch) {
|
|
22996
23000
|
await this.git.cwd(this.clonePath);
|
|
22997
23001
|
await this.git.pull("origin", branch);
|
|
@@ -23117,12 +23121,13 @@ var ClonedRepository = class _ClonedRepository {
|
|
|
23117
23121
|
await this.git.push("origin", branch, { "--set-upstream": null });
|
|
23118
23122
|
}
|
|
23119
23123
|
// Only used by replay's PR mode to push synthetic divergent commits to a fern-bot/ branch.
|
|
23120
|
-
//
|
|
23121
|
-
//
|
|
23124
|
+
// These branches are exclusively owned by the pipeline — no human pushes to them.
|
|
23125
|
+
// Uses --force (not --force-with-lease) because the lease check fails after
|
|
23126
|
+
// git fetch --unshallow updates remote refs. Never targets main or user branches.
|
|
23122
23127
|
async forcePush() {
|
|
23123
23128
|
await this.git.cwd(this.clonePath);
|
|
23124
23129
|
const currentBranch = await this.getCurrentBranch();
|
|
23125
|
-
await this.git.push("origin", currentBranch, ["--force
|
|
23130
|
+
await this.git.push("origin", currentBranch, ["--force"]);
|
|
23126
23131
|
}
|
|
23127
23132
|
async createBranchFromHead(branchName) {
|
|
23128
23133
|
await this.git.cwd(this.clonePath);
|
|
@@ -31161,6 +31166,10 @@ var GithubStep = class extends BaseStep {
|
|
|
31161
31166
|
try {
|
|
31162
31167
|
this.logger.debug("Starting GitHub self-hosted flow in directory: " + this.outputDir);
|
|
31163
31168
|
const repository = ClonedRepository.createAtPath(this.outputDir);
|
|
31169
|
+
try {
|
|
31170
|
+
await repository.fetch(["--unshallow"]);
|
|
31171
|
+
} catch {
|
|
31172
|
+
}
|
|
31164
31173
|
const now = /* @__PURE__ */ new Date();
|
|
31165
31174
|
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
|
|
31166
31175
|
const newPrBranch = `fern-bot/${formattedDate}`;
|
|
@@ -32102,6 +32111,7 @@ async function loadReferenceConfig({
|
|
|
32102
32111
|
}
|
|
32103
32112
|
|
|
32104
32113
|
// src/cli.ts
|
|
32114
|
+
var STDIN_MARKER = "-";
|
|
32105
32115
|
void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "generator-cli").strict().command(
|
|
32106
32116
|
"generate readme",
|
|
32107
32117
|
"Generate a README.md using the provided configuration file.",
|
|
@@ -32235,15 +32245,11 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
32235
32245
|
return subYargs.option("config", {
|
|
32236
32246
|
string: true,
|
|
32237
32247
|
required: true,
|
|
32238
|
-
description: "
|
|
32248
|
+
description: "The file or data to use for pipeline configuration"
|
|
32239
32249
|
}).option("output-dir", {
|
|
32240
32250
|
string: true,
|
|
32241
32251
|
required: true,
|
|
32242
32252
|
description: "Path to SDK output directory"
|
|
32243
|
-
}).option("result-file", {
|
|
32244
|
-
string: true,
|
|
32245
|
-
required: false,
|
|
32246
|
-
description: "Path to write result JSON"
|
|
32247
32253
|
});
|
|
32248
32254
|
},
|
|
32249
32255
|
async (argv) => {
|
|
@@ -32255,16 +32261,18 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
32255
32261
|
}
|
|
32256
32262
|
try {
|
|
32257
32263
|
const wd = cwd();
|
|
32258
|
-
const
|
|
32259
|
-
const
|
|
32264
|
+
const configValue = argv.config;
|
|
32265
|
+
const configContent = configValue === STDIN_MARKER ? await readStdin() : configValue.trimStart().startsWith("{") ? configValue : await (0, import_promises9.readFile)(resolve(wd, configValue), "utf-8");
|
|
32266
|
+
let config;
|
|
32267
|
+
try {
|
|
32268
|
+
config = JSON.parse(configContent);
|
|
32269
|
+
} catch (parseError) {
|
|
32270
|
+
const parseMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
32271
|
+
throw new Error(`Failed to parse pipeline config as JSON: ${parseMessage}`);
|
|
32272
|
+
}
|
|
32260
32273
|
config.outputDir = resolve(wd, argv["output-dir"]);
|
|
32261
32274
|
const pipeline = new PostGenerationPipeline(config);
|
|
32262
32275
|
const result = await pipeline.run();
|
|
32263
|
-
if (argv["result-file"] != null) {
|
|
32264
|
-
const resultPath = resolve(wd, argv["result-file"]);
|
|
32265
|
-
await (0, import_promises9.mkdir)(import_path16.default.dirname(resultPath), { recursive: true });
|
|
32266
|
-
await import_fs14.default.promises.writeFile(resultPath, JSON.stringify(result, null, 2));
|
|
32267
|
-
}
|
|
32268
32276
|
process.stderr.write(`Pipeline ${result.success ? "succeeded" : "failed"}
|
|
32269
32277
|
`);
|
|
32270
32278
|
if (result.steps.replay != null) {
|
|
@@ -32290,12 +32298,13 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
32290
32298
|
${result.errors.map((e) => ` - ${e}`).join("\n")}
|
|
32291
32299
|
`);
|
|
32292
32300
|
}
|
|
32293
|
-
process.
|
|
32301
|
+
process.stdout.write(JSON.stringify(result) + "\n");
|
|
32302
|
+
process.exitCode = result.success ? 0 : 1;
|
|
32294
32303
|
} catch (error) {
|
|
32295
32304
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
32296
32305
|
process.stderr.write(`Pipeline failed: ${errorMessage}
|
|
32297
32306
|
`);
|
|
32298
|
-
process.
|
|
32307
|
+
process.exitCode = 1;
|
|
32299
32308
|
}
|
|
32300
32309
|
}
|
|
32301
32310
|
).demandCommand();
|
|
@@ -32464,6 +32473,13 @@ Bootstrap complete! Lockfile saved to ${outputDir}/.fern/replay.lock
|
|
|
32464
32473
|
handler: () => {
|
|
32465
32474
|
}
|
|
32466
32475
|
}).demandCommand().showHelpOnFail(true).parse();
|
|
32476
|
+
async function readStdin() {
|
|
32477
|
+
const chunks = [];
|
|
32478
|
+
for await (const chunk of process.stdin) {
|
|
32479
|
+
chunks.push(chunk);
|
|
32480
|
+
}
|
|
32481
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
32482
|
+
}
|
|
32467
32483
|
async function createWriteStream(outputPath) {
|
|
32468
32484
|
return outputPath != null ? await createWriteStreamFromFile(resolve(cwd(), outputPath)) : process.stdout;
|
|
32469
32485
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/generator-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/fern-api/fern.git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"**"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@fern-api/replay": "^0.6.
|
|
25
|
+
"@fern-api/replay": "^0.6.2",
|
|
26
26
|
"@octokit/rest": "^22.0.1",
|
|
27
27
|
"es-toolkit": "^1.39.10",
|
|
28
28
|
"tmp-promise": "^3.0.3"
|