@fern-api/fern-api-dev 4.80.4-1-gc11eebc7322 → 4.80.4-4-g3da138c98f4
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 +1332 -792
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -68378,8 +68378,8 @@ var require_graceful_fs = __commonJS({
|
|
|
68378
68378
|
}
|
|
68379
68379
|
}
|
|
68380
68380
|
var fs$writeFile = fs28.writeFile;
|
|
68381
|
-
fs28.writeFile =
|
|
68382
|
-
function
|
|
68381
|
+
fs28.writeFile = writeFile91;
|
|
68382
|
+
function writeFile91(path99, data2, options2, cb) {
|
|
68383
68383
|
if (typeof options2 === "function")
|
|
68384
68384
|
cb = options2, options2 = null;
|
|
68385
68385
|
return go$writeFile(path99, data2, options2, cb);
|
|
@@ -68396,8 +68396,8 @@ var require_graceful_fs = __commonJS({
|
|
|
68396
68396
|
}
|
|
68397
68397
|
var fs$appendFile = fs28.appendFile;
|
|
68398
68398
|
if (fs$appendFile)
|
|
68399
|
-
fs28.appendFile =
|
|
68400
|
-
function
|
|
68399
|
+
fs28.appendFile = appendFile3;
|
|
68400
|
+
function appendFile3(path99, data2, options2, cb) {
|
|
68401
68401
|
if (typeof options2 === "function")
|
|
68402
68402
|
cb = options2, options2 = null;
|
|
68403
68403
|
return go$appendFile(path99, data2, options2, cb);
|
|
@@ -290012,8 +290012,8 @@ var require_graceful_fs2 = __commonJS({
|
|
|
290012
290012
|
}
|
|
290013
290013
|
}
|
|
290014
290014
|
var fs$writeFile = fs28.writeFile;
|
|
290015
|
-
fs28.writeFile =
|
|
290016
|
-
function
|
|
290015
|
+
fs28.writeFile = writeFile91;
|
|
290016
|
+
function writeFile91(path99, data2, options2, cb) {
|
|
290017
290017
|
if (typeof options2 === "function")
|
|
290018
290018
|
cb = options2, options2 = null;
|
|
290019
290019
|
return go$writeFile(path99, data2, options2, cb);
|
|
@@ -290030,8 +290030,8 @@ var require_graceful_fs2 = __commonJS({
|
|
|
290030
290030
|
}
|
|
290031
290031
|
var fs$appendFile = fs28.appendFile;
|
|
290032
290032
|
if (fs$appendFile)
|
|
290033
|
-
fs28.appendFile =
|
|
290034
|
-
function
|
|
290033
|
+
fs28.appendFile = appendFile3;
|
|
290034
|
+
function appendFile3(path99, data2, options2, cb) {
|
|
290035
290035
|
if (typeof options2 === "function")
|
|
290036
290036
|
cb = options2, options2 = null;
|
|
290037
290037
|
return go$appendFile(path99, data2, options2, cb);
|
|
@@ -337996,7 +337996,7 @@ var require_dist14 = __commonJS({
|
|
|
337996
337996
|
}
|
|
337997
337997
|
return result;
|
|
337998
337998
|
}
|
|
337999
|
-
var
|
|
337999
|
+
var import_promises185 = require("fs/promises");
|
|
338000
338000
|
var import_node_os15 = require("os");
|
|
338001
338001
|
var import_node_path210 = require("path");
|
|
338002
338002
|
var import_minimatch8 = require_commonjs3();
|
|
@@ -338209,9 +338209,9 @@ var require_dist14 = __commonJS({
|
|
|
338209
338209
|
if (laterFiles.has(fileResult.file) || laterFiles.has(originalPath)) {
|
|
338210
338210
|
const filePath = (0, import_node_path210.join)(this.outputDir, fileResult.file);
|
|
338211
338211
|
try {
|
|
338212
|
-
const content5 = await (0,
|
|
338212
|
+
const content5 = await (0, import_promises185.readFile)(filePath, "utf-8");
|
|
338213
338213
|
const stripped = stripConflictMarkers(content5);
|
|
338214
|
-
await (0,
|
|
338214
|
+
await (0, import_promises185.writeFile)(filePath, stripped);
|
|
338215
338215
|
} catch {
|
|
338216
338216
|
}
|
|
338217
338217
|
}
|
|
@@ -338223,7 +338223,7 @@ var require_dist14 = __commonJS({
|
|
|
338223
338223
|
/** Populate accumulator after git apply succeeds. */
|
|
338224
338224
|
async populateAccumulatorForPatch(patch5, baseGen, currentTreeHash) {
|
|
338225
338225
|
if (!baseGen) return;
|
|
338226
|
-
const tempDir2 = await (0,
|
|
338226
|
+
const tempDir2 = await (0, import_promises185.mkdtemp)((0, import_node_path210.join)((0, import_node_os15.tmpdir)(), "replay-acc-"));
|
|
338227
338227
|
const { GitClient: GitClient2 } = await Promise.resolve().then(() => (init_GitClient(), GitClient_exports));
|
|
338228
338228
|
const tempGit = new GitClient2(tempDir2);
|
|
338229
338229
|
await tempGit.exec(["init"]);
|
|
@@ -338235,7 +338235,7 @@ var require_dist14 = __commonJS({
|
|
|
338235
338235
|
const resolvedPath = await this.resolveFilePath(filePath, baseGen.tree_hash, currentTreeHash);
|
|
338236
338236
|
const base4 = await this.git.showFile(baseGen.tree_hash, filePath);
|
|
338237
338237
|
const theirs = await this.applyPatchToContent(base4, patch5.patch_content, filePath, tempGit, tempDir2);
|
|
338238
|
-
const effectiveTheirs = theirs ?? await (0,
|
|
338238
|
+
const effectiveTheirs = theirs ?? await (0, import_promises185.readFile)((0, import_node_path210.join)(this.outputDir, resolvedPath), "utf-8").catch(() => null);
|
|
338239
338239
|
if (effectiveTheirs != null) {
|
|
338240
338240
|
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
338241
338241
|
content: effectiveTheirs,
|
|
@@ -338244,7 +338244,7 @@ var require_dist14 = __commonJS({
|
|
|
338244
338244
|
}
|
|
338245
338245
|
}
|
|
338246
338246
|
} finally {
|
|
338247
|
-
await (0,
|
|
338247
|
+
await (0, import_promises185.rm)(tempDir2, { recursive: true }).catch(() => {
|
|
338248
338248
|
});
|
|
338249
338249
|
}
|
|
338250
338250
|
}
|
|
@@ -338273,7 +338273,7 @@ var require_dist14 = __commonJS({
|
|
|
338273
338273
|
const snapshots = /* @__PURE__ */ new Map();
|
|
338274
338274
|
for (const filePath of patch5.files) {
|
|
338275
338275
|
const fullPath = (0, import_node_path210.join)(this.outputDir, filePath);
|
|
338276
|
-
snapshots.set(filePath, await (0,
|
|
338276
|
+
snapshots.set(filePath, await (0, import_promises185.readFile)(fullPath, "utf-8").catch(() => null));
|
|
338277
338277
|
}
|
|
338278
338278
|
try {
|
|
338279
338279
|
await this.git.execWithInput(["apply", "--3way"], patch5.patch_content);
|
|
@@ -338288,9 +338288,9 @@ var require_dist14 = __commonJS({
|
|
|
338288
338288
|
for (const [filePath, content5] of snapshots) {
|
|
338289
338289
|
const fullPath = (0, import_node_path210.join)(this.outputDir, filePath);
|
|
338290
338290
|
if (content5 != null) {
|
|
338291
|
-
await (0,
|
|
338291
|
+
await (0, import_promises185.writeFile)(fullPath, content5);
|
|
338292
338292
|
} else {
|
|
338293
|
-
await (0,
|
|
338293
|
+
await (0, import_promises185.unlink)(fullPath).catch(() => {
|
|
338294
338294
|
});
|
|
338295
338295
|
}
|
|
338296
338296
|
}
|
|
@@ -338301,7 +338301,7 @@ var require_dist14 = __commonJS({
|
|
|
338301
338301
|
async applyWithThreeWayMerge(patch5) {
|
|
338302
338302
|
const fileResults = [];
|
|
338303
338303
|
const resolvedFiles = {};
|
|
338304
|
-
const tempDir2 = await (0,
|
|
338304
|
+
const tempDir2 = await (0, import_promises185.mkdtemp)((0, import_node_path210.join)((0, import_node_os15.tmpdir)(), "replay-"));
|
|
338305
338305
|
const { GitClient: GitClient2 } = await Promise.resolve().then(() => (init_GitClient(), GitClient_exports));
|
|
338306
338306
|
const tempGit = new GitClient2(tempDir2);
|
|
338307
338307
|
await tempGit.exec(["init"]);
|
|
@@ -338324,7 +338324,7 @@ var require_dist14 = __commonJS({
|
|
|
338324
338324
|
fileResults.push(result);
|
|
338325
338325
|
}
|
|
338326
338326
|
} finally {
|
|
338327
|
-
await (0,
|
|
338327
|
+
await (0, import_promises185.rm)(tempDir2, { recursive: true }).catch(() => {
|
|
338328
338328
|
});
|
|
338329
338329
|
}
|
|
338330
338330
|
const conflictFiles = fileResults.filter((r5) => r5.status === "conflict");
|
|
@@ -338365,7 +338365,7 @@ var require_dist14 = __commonJS({
|
|
|
338365
338365
|
}
|
|
338366
338366
|
}
|
|
338367
338367
|
const oursPath = (0, import_node_path210.join)(this.outputDir, resolvedPath);
|
|
338368
|
-
const ours = await (0,
|
|
338368
|
+
const ours = await (0, import_promises185.readFile)(oursPath, "utf-8").catch(() => null);
|
|
338369
338369
|
let ghostReconstructed = false;
|
|
338370
338370
|
let theirs = null;
|
|
338371
338371
|
if (!base4 && ours && !renameSourcePath) {
|
|
@@ -338462,15 +338462,15 @@ var require_dist14 = __commonJS({
|
|
|
338462
338462
|
baseGeneration: patch5.base_generation
|
|
338463
338463
|
});
|
|
338464
338464
|
const outDir2 = (0, import_node_path210.dirname)(oursPath);
|
|
338465
|
-
await (0,
|
|
338466
|
-
await (0,
|
|
338465
|
+
await (0, import_promises185.mkdir)(outDir2, { recursive: true });
|
|
338466
|
+
await (0, import_promises185.writeFile)(oursPath, effective_theirs);
|
|
338467
338467
|
return { file: resolvedPath, status: "merged", reason: "new-file" };
|
|
338468
338468
|
}
|
|
338469
338469
|
if (base4 == null && ours != null && effective_theirs != null && !useAccumulatorAsMergeBase) {
|
|
338470
338470
|
const merged2 = threeWayMerge("", ours, effective_theirs);
|
|
338471
338471
|
const outDir2 = (0, import_node_path210.dirname)(oursPath);
|
|
338472
|
-
await (0,
|
|
338473
|
-
await (0,
|
|
338472
|
+
await (0, import_promises185.mkdir)(outDir2, { recursive: true });
|
|
338473
|
+
await (0, import_promises185.writeFile)(oursPath, merged2.content);
|
|
338474
338474
|
if (merged2.hasConflicts) {
|
|
338475
338475
|
return {
|
|
338476
338476
|
file: resolvedPath,
|
|
@@ -338510,8 +338510,8 @@ var require_dist14 = __commonJS({
|
|
|
338510
338510
|
}
|
|
338511
338511
|
const merged = threeWayMerge(mergeBase, ours, effective_theirs);
|
|
338512
338512
|
const outDir = (0, import_node_path210.dirname)(oursPath);
|
|
338513
|
-
await (0,
|
|
338514
|
-
await (0,
|
|
338513
|
+
await (0, import_promises185.mkdir)(outDir, { recursive: true });
|
|
338514
|
+
await (0, import_promises185.writeFile)(oursPath, merged.content);
|
|
338515
338515
|
if (effective_theirs != null && !merged.hasConflicts) {
|
|
338516
338516
|
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
338517
338517
|
content: effective_theirs,
|
|
@@ -338586,8 +338586,8 @@ var require_dist14 = __commonJS({
|
|
|
338586
338586
|
try {
|
|
338587
338587
|
if (sourceFilePath) {
|
|
338588
338588
|
const tempSourcePath = (0, import_node_path210.join)(tempDir2, sourceFilePath);
|
|
338589
|
-
await (0,
|
|
338590
|
-
await (0,
|
|
338589
|
+
await (0, import_promises185.mkdir)((0, import_node_path210.dirname)(tempSourcePath), { recursive: true });
|
|
338590
|
+
await (0, import_promises185.writeFile)(tempSourcePath, base4);
|
|
338591
338591
|
await tempGit.exec(["add", sourceFilePath]);
|
|
338592
338592
|
await tempGit.exec([
|
|
338593
338593
|
"commit",
|
|
@@ -338597,15 +338597,15 @@ var require_dist14 = __commonJS({
|
|
|
338597
338597
|
]);
|
|
338598
338598
|
await tempGit.execWithInput(["apply", "--allow-empty"], fileDiff);
|
|
338599
338599
|
const tempTargetPath = (0, import_node_path210.join)(tempDir2, filePath);
|
|
338600
|
-
return await (0,
|
|
338600
|
+
return await (0, import_promises185.readFile)(tempTargetPath, "utf-8");
|
|
338601
338601
|
}
|
|
338602
338602
|
const tempFilePath = (0, import_node_path210.join)(tempDir2, filePath);
|
|
338603
|
-
await (0,
|
|
338604
|
-
await (0,
|
|
338603
|
+
await (0, import_promises185.mkdir)((0, import_node_path210.dirname)(tempFilePath), { recursive: true });
|
|
338604
|
+
await (0, import_promises185.writeFile)(tempFilePath, base4);
|
|
338605
338605
|
await tempGit.exec(["add", filePath]);
|
|
338606
338606
|
await tempGit.exec(["commit", "-m", `base for ${filePath}`, "--allow-empty"]);
|
|
338607
338607
|
await tempGit.execWithInput(["apply", "--allow-empty"], fileDiff);
|
|
338608
|
-
return await (0,
|
|
338608
|
+
return await (0, import_promises185.readFile)(tempFilePath, "utf-8");
|
|
338609
338609
|
} catch {
|
|
338610
338610
|
return null;
|
|
338611
338611
|
}
|
|
@@ -338622,8 +338622,8 @@ var require_dist14 = __commonJS({
|
|
|
338622
338622
|
if (!fileDiff) return false;
|
|
338623
338623
|
try {
|
|
338624
338624
|
const tempFilePath = (0, import_node_path210.join)(tempDir2, filePath);
|
|
338625
|
-
await (0,
|
|
338626
|
-
await (0,
|
|
338625
|
+
await (0, import_promises185.mkdir)((0, import_node_path210.dirname)(tempFilePath), { recursive: true });
|
|
338626
|
+
await (0, import_promises185.writeFile)(tempFilePath, content5);
|
|
338627
338627
|
await tempGit.exec(["add", filePath]);
|
|
338628
338628
|
await tempGit.exec(["commit", "-m", `check already-applied ${filePath}`, "--allow-empty"]);
|
|
338629
338629
|
await tempGit.execWithInput(["apply", "--reverse", "--check", "--allow-empty"], fileDiff);
|
|
@@ -352442,8 +352442,8 @@ var require_jsonfile = __commonJS({
|
|
|
352442
352442
|
const str3 = stringify5(obj, options2);
|
|
352443
352443
|
await universalify.fromCallback(fs27.writeFile)(file4, str3, options2);
|
|
352444
352444
|
}
|
|
352445
|
-
var
|
|
352446
|
-
function
|
|
352445
|
+
var writeFile91 = universalify.fromPromise(_writeFile);
|
|
352446
|
+
function writeFileSync9(file4, obj, options2 = {}) {
|
|
352447
352447
|
const fs27 = options2.fs || _fs;
|
|
352448
352448
|
const str3 = stringify5(obj, options2);
|
|
352449
352449
|
return fs27.writeFileSync(file4, str3, options2);
|
|
@@ -352451,8 +352451,8 @@ var require_jsonfile = __commonJS({
|
|
|
352451
352451
|
module4.exports = {
|
|
352452
352452
|
readFile: readFile104,
|
|
352453
352453
|
readFileSync: readFileSync19,
|
|
352454
|
-
writeFile:
|
|
352455
|
-
writeFileSync:
|
|
352454
|
+
writeFile: writeFile91,
|
|
352455
|
+
writeFileSync: writeFileSync9
|
|
352456
352456
|
};
|
|
352457
352457
|
}
|
|
352458
352458
|
});
|
|
@@ -567266,25 +567266,28 @@ var TtyAwareLogger = class {
|
|
|
567266
567266
|
}
|
|
567267
567267
|
paint() {
|
|
567268
567268
|
const spinnerFrame = this.spinner.frame();
|
|
567269
|
-
const
|
|
567269
|
+
const frames = [];
|
|
567270
567270
|
for (const task of this.tasks) {
|
|
567271
|
-
const
|
|
567272
|
-
if (
|
|
567273
|
-
|
|
567271
|
+
const body = task.printInteractiveTasks({ spinner: spinnerFrame });
|
|
567272
|
+
if (body.length > 0) {
|
|
567273
|
+
frames.push({ title: task.title, body });
|
|
567274
567274
|
}
|
|
567275
567275
|
}
|
|
567276
|
-
if (
|
|
567276
|
+
if (frames.length === 0) {
|
|
567277
567277
|
return "";
|
|
567278
567278
|
}
|
|
567279
567279
|
const spinnerStatus = process.env.FERN_SPINNER_STATUS;
|
|
567280
|
-
if (spinnerStatus
|
|
567281
|
-
|
|
567280
|
+
if (spinnerStatus) {
|
|
567281
|
+
const first3 = frames[0];
|
|
567282
|
+
if (first3 != null) {
|
|
567283
|
+
first3.body = `${first3.body} - ${spinnerStatus}`;
|
|
567284
|
+
}
|
|
567282
567285
|
}
|
|
567283
|
-
const paint = [
|
|
567284
|
-
"\u250C\u2500",
|
|
567285
|
-
|
|
567286
|
+
const paint = frames.map(({ title: title3, body }) => [
|
|
567287
|
+
title3 != null ? `\u250C\u2500 ${title3} \u2500` : "\u250C\u2500",
|
|
567288
|
+
addPrefixToString({ content: body, prefix: "\u2502 ", includePrefixOnAllLines: true }),
|
|
567286
567289
|
"\u2514\u2500"
|
|
567287
|
-
].join("\n") + "\n";
|
|
567290
|
+
].join("\n")).join("\n") + "\n";
|
|
567288
567291
|
this.lastPaint = paint;
|
|
567289
567292
|
return paint;
|
|
567290
567293
|
}
|
|
@@ -614331,7 +614334,7 @@ var AccessTokenPosthogManager = class {
|
|
|
614331
614334
|
properties: {
|
|
614332
614335
|
...event,
|
|
614333
614336
|
...event.properties,
|
|
614334
|
-
version: "4.80.4-
|
|
614337
|
+
version: "4.80.4-4-g3da138c98f4",
|
|
614335
614338
|
usingAccessToken: true
|
|
614336
614339
|
}
|
|
614337
614340
|
});
|
|
@@ -614385,7 +614388,7 @@ var UserPosthogManager = class {
|
|
|
614385
614388
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
614386
614389
|
event: "CLI",
|
|
614387
614390
|
properties: {
|
|
614388
|
-
version: "4.80.4-
|
|
614391
|
+
version: "4.80.4-4-g3da138c98f4",
|
|
614389
614392
|
...event,
|
|
614390
614393
|
...event.properties,
|
|
614391
614394
|
usingAccessToken: false,
|
|
@@ -788501,13 +788504,13 @@ async function removeInvalidAiExamples({ sourceFilePath, context: context3 }) {
|
|
|
788501
788504
|
}
|
|
788502
788505
|
}
|
|
788503
788506
|
}
|
|
788504
|
-
const { writeFile:
|
|
788507
|
+
const { writeFile: writeFile91 } = await import("fs/promises");
|
|
788505
788508
|
const yamlContent = jsYaml.dump(parsed, {
|
|
788506
788509
|
indent: 2,
|
|
788507
788510
|
lineWidth: -1,
|
|
788508
788511
|
noRefs: true
|
|
788509
788512
|
});
|
|
788510
|
-
await
|
|
788513
|
+
await writeFile91(overrideFilePath, yamlContent, "utf-8");
|
|
788511
788514
|
context3.logger.info(`Removed ${validationResult.invalidCount} invalid AI examples from ai_examples_override.yml`);
|
|
788512
788515
|
return {
|
|
788513
788516
|
removedCount: validationResult.invalidCount,
|
|
@@ -831666,7 +831669,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
831666
831669
|
var LOGS_FOLDER_NAME = "logs";
|
|
831667
831670
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
831668
831671
|
function getCliSource() {
|
|
831669
|
-
const version7 = "4.80.4-
|
|
831672
|
+
const version7 = "4.80.4-4-g3da138c98f4";
|
|
831670
831673
|
return `cli@${version7}`;
|
|
831671
831674
|
}
|
|
831672
831675
|
var DebugLogger = class {
|
|
@@ -834541,6 +834544,9 @@ async function validateAPIWorkspaceAndLogIssues({ workspace, context: context3,
|
|
|
834541
834544
|
}
|
|
834542
834545
|
}
|
|
834543
834546
|
|
|
834547
|
+
// ../generation/remote-generation/remote-workspace-runner/lib/runRemoteGenerationForAPIWorkspace.js
|
|
834548
|
+
init_lib4();
|
|
834549
|
+
|
|
834544
834550
|
// ../workspace/loader/lib/handleFailedWorkspaceParserResult.js
|
|
834545
834551
|
init_lib4();
|
|
834546
834552
|
init_zod();
|
|
@@ -842030,14 +842036,51 @@ async function uploadDynamicIRForSdkGeneration({ fdr, organization, version: ver
|
|
|
842030
842036
|
}
|
|
842031
842037
|
|
|
842032
842038
|
// ../generation/remote-generation/remote-workspace-runner/lib/runRemoteGenerationForAPIWorkspace.js
|
|
842033
|
-
async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization, workspace, context: context3, generatorGroup, version: version7, shouldLogS3Url, token, whitelabel, absolutePathToPreview, isPreview, fiddlePreview, pushPreviewBranch, mode, fernignorePath, skipFernignore, dynamicIrOnly, validateWorkspace, retryRateLimited, requireEnvVars, automationMode, autoMerge }) {
|
|
842039
|
+
async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization, workspace, context: context3, generatorGroup, version: version7, shouldLogS3Url, token, whitelabel, absolutePathToPreview, isPreview, fiddlePreview, pushPreviewBranch, mode, fernignorePath, skipFernignore, dynamicIrOnly, validateWorkspace, retryRateLimited, requireEnvVars, automationMode, autoMerge, automation }) {
|
|
842034
842040
|
if (generatorGroup.generators.length === 0) {
|
|
842035
842041
|
context3.logger.warn("No generators specified.");
|
|
842036
842042
|
return null;
|
|
842037
842043
|
}
|
|
842038
|
-
const interactiveTasks = [];
|
|
842039
842044
|
const snippetsProducedBy = [];
|
|
842040
|
-
|
|
842045
|
+
const results = await Promise.all(generatorGroup.generators.map((generatorInvocation) => context3.runInteractiveTask({ name: generatorInvocation.name }, (interactiveTaskContext) => generateOne({
|
|
842046
|
+
generatorInvocation,
|
|
842047
|
+
interactiveTaskContext,
|
|
842048
|
+
// Closed-over state + params passed through to the per-generator worker.
|
|
842049
|
+
projectConfig,
|
|
842050
|
+
organization,
|
|
842051
|
+
workspace,
|
|
842052
|
+
context: context3,
|
|
842053
|
+
generatorGroup,
|
|
842054
|
+
version: version7,
|
|
842055
|
+
shouldLogS3Url,
|
|
842056
|
+
token,
|
|
842057
|
+
whitelabel,
|
|
842058
|
+
absolutePathToPreview,
|
|
842059
|
+
isPreview,
|
|
842060
|
+
fiddlePreview,
|
|
842061
|
+
pushPreviewBranch,
|
|
842062
|
+
mode,
|
|
842063
|
+
fernignorePath,
|
|
842064
|
+
skipFernignore,
|
|
842065
|
+
dynamicIrOnly,
|
|
842066
|
+
validateWorkspace,
|
|
842067
|
+
retryRateLimited,
|
|
842068
|
+
requireEnvVars,
|
|
842069
|
+
automationMode,
|
|
842070
|
+
autoMerge,
|
|
842071
|
+
automation,
|
|
842072
|
+
onSnippetsProduced: (invocation) => snippetsProducedBy.push(invocation)
|
|
842073
|
+
}))));
|
|
842074
|
+
if (automation == null && results.some((didSucceed) => !didSucceed)) {
|
|
842075
|
+
context3.failAndThrow();
|
|
842076
|
+
}
|
|
842077
|
+
return {
|
|
842078
|
+
snippetsProducedBy
|
|
842079
|
+
};
|
|
842080
|
+
}
|
|
842081
|
+
async function generateOne({ generatorInvocation, interactiveTaskContext, projectConfig, organization, workspace, context: context3, generatorGroup, version: version7, shouldLogS3Url, token, whitelabel, absolutePathToPreview, isPreview, fiddlePreview, pushPreviewBranch, mode, fernignorePath, skipFernignore, dynamicIrOnly, validateWorkspace, retryRateLimited, requireEnvVars, automationMode, autoMerge, automation, onSnippetsProduced }) {
|
|
842082
|
+
const startedAt = Date.now();
|
|
842083
|
+
try {
|
|
842041
842084
|
const settings = getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation(generatorInvocation);
|
|
842042
842085
|
const fernWorkspace = await workspace.toFernWorkspace({ context: context3 }, settings, generatorInvocation.apiOverride?.specs);
|
|
842043
842086
|
if (validateWorkspace) {
|
|
@@ -842097,8 +842140,8 @@ async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization,
|
|
|
842097
842140
|
automationMode,
|
|
842098
842141
|
autoMerge
|
|
842099
842142
|
});
|
|
842100
|
-
if (remoteTaskHandlerResponse
|
|
842101
|
-
|
|
842143
|
+
if (remoteTaskHandlerResponse?.createdSnippets) {
|
|
842144
|
+
onSnippetsProduced(generatorInvocation);
|
|
842102
842145
|
if (generatorInvocation.absolutePathToLocalSnippets != null && remoteTaskHandlerResponse.snippetsS3PreSignedReadUrl != null) {
|
|
842103
842146
|
await downloadSnippetsForTask({
|
|
842104
842147
|
snippetsS3PreSignedReadUrl: remoteTaskHandlerResponse.snippetsS3PreSignedReadUrl,
|
|
@@ -842107,14 +842150,27 @@ async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization,
|
|
|
842107
842150
|
});
|
|
842108
842151
|
}
|
|
842109
842152
|
}
|
|
842110
|
-
|
|
842111
|
-
|
|
842112
|
-
|
|
842113
|
-
|
|
842153
|
+
automation?.recorder.recordSuccess({
|
|
842154
|
+
apiName: workspace.workspaceName,
|
|
842155
|
+
groupName: generatorGroup.groupName,
|
|
842156
|
+
generatorName: generatorInvocation.name,
|
|
842157
|
+
version: remoteTaskHandlerResponse?.actualVersion ?? null,
|
|
842158
|
+
durationMs: Date.now() - startedAt
|
|
842159
|
+
});
|
|
842160
|
+
} catch (error50) {
|
|
842161
|
+
if (automation == null) {
|
|
842162
|
+
throw error50;
|
|
842163
|
+
}
|
|
842164
|
+
const message = extractErrorMessage(error50);
|
|
842165
|
+
automation.recorder.recordFailure({
|
|
842166
|
+
apiName: workspace.workspaceName,
|
|
842167
|
+
groupName: generatorGroup.groupName,
|
|
842168
|
+
generatorName: generatorInvocation.name,
|
|
842169
|
+
errorMessage: message,
|
|
842170
|
+
durationMs: Date.now() - startedAt
|
|
842171
|
+
});
|
|
842172
|
+
interactiveTaskContext.failWithoutThrowing(message);
|
|
842114
842173
|
}
|
|
842115
|
-
return {
|
|
842116
|
-
snippetsProducedBy
|
|
842117
|
-
};
|
|
842118
842174
|
}
|
|
842119
842175
|
|
|
842120
842176
|
// ../generation/remote-generation/remote-workspace-runner/lib/runRemoteGenerationForDocsWorkspace.js
|
|
@@ -843180,7 +843236,7 @@ var LegacyDocsPublisher = class {
|
|
|
843180
843236
|
previewId,
|
|
843181
843237
|
disableTemplates: void 0,
|
|
843182
843238
|
skipUpload,
|
|
843183
|
-
cliVersion: "4.80.4-
|
|
843239
|
+
cliVersion: "4.80.4-4-g3da138c98f4"
|
|
843184
843240
|
});
|
|
843185
843241
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
843186
843242
|
return { success: false };
|
|
@@ -917757,6 +917813,7 @@ var TaskContextImpl = class {
|
|
|
917757
917813
|
result = TaskResult.Success;
|
|
917758
917814
|
logImmediately;
|
|
917759
917815
|
logPrefix;
|
|
917816
|
+
title;
|
|
917760
917817
|
subtasks = [];
|
|
917761
917818
|
shouldBufferLogs;
|
|
917762
917819
|
bufferedLogs = [];
|
|
@@ -917767,6 +917824,7 @@ var TaskContextImpl = class {
|
|
|
917767
917824
|
constructor({
|
|
917768
917825
|
logImmediately,
|
|
917769
917826
|
logPrefix,
|
|
917827
|
+
title: title3,
|
|
917770
917828
|
takeOverTerminal,
|
|
917771
917829
|
onResult,
|
|
917772
917830
|
shouldBufferLogs,
|
|
@@ -917775,6 +917833,7 @@ var TaskContextImpl = class {
|
|
|
917775
917833
|
}) {
|
|
917776
917834
|
this.logImmediately = logImmediately;
|
|
917777
917835
|
this.logPrefix = logPrefix ?? "";
|
|
917836
|
+
this.title = title3;
|
|
917778
917837
|
this.takeOverTerminal = takeOverTerminal;
|
|
917779
917838
|
this.onResult = onResult;
|
|
917780
917839
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
@@ -917915,25 +917974,34 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
917915
917974
|
}
|
|
917916
917975
|
lines.push(...this.subtasks.map((subtask) => subtask.print({ spinner })));
|
|
917917
917976
|
return addPrefixToString({
|
|
917918
|
-
prefix:
|
|
917977
|
+
prefix: this.getIcon({ spinner }),
|
|
917919
917978
|
content: lines.join("\n")
|
|
917920
917979
|
});
|
|
917921
917980
|
}
|
|
917922
917981
|
printInteractiveTasks({ spinner }) {
|
|
917923
917982
|
return this.print({ spinner });
|
|
917924
917983
|
}
|
|
917984
|
+
/**
|
|
917985
|
+
* Tasks with subtasks (e.g. a generator group whose children are individual generators)
|
|
917986
|
+
* render with a disclosure-triangle glyph instead of the leaf check/x/spinner, so the
|
|
917987
|
+
* tree shape is legible at a glance. Leaves keep the existing per-status glyphs.
|
|
917988
|
+
*
|
|
917989
|
+
* Every branch returns a string ending in a trailing space so the caller doesn't need
|
|
917990
|
+
* to pad — `spinner` from ora already includes one, and static glyphs add one explicitly.
|
|
917991
|
+
*/
|
|
917925
917992
|
getIcon({ spinner }) {
|
|
917993
|
+
const hasChildren2 = this.subtasks.length > 0;
|
|
917926
917994
|
switch (this.status) {
|
|
917927
917995
|
case "notStarted":
|
|
917928
|
-
return source_default.dim("\u25E6");
|
|
917996
|
+
return hasChildren2 ? source_default.dim("\u25B8 ") : source_default.dim("\u25E6 ");
|
|
917929
917997
|
case "running":
|
|
917930
|
-
return spinner;
|
|
917998
|
+
return hasChildren2 ? source_default.cyan("\u25BE ") : spinner;
|
|
917931
917999
|
case "finished":
|
|
917932
918000
|
switch (this.getResult()) {
|
|
917933
918001
|
case TaskResult.Success:
|
|
917934
|
-
return source_default.green("\u2713");
|
|
918002
|
+
return hasChildren2 ? source_default.green("\u25BE ") : source_default.green("\u2713 ");
|
|
917935
918003
|
case TaskResult.Failure:
|
|
917936
|
-
return source_default.red("x");
|
|
918004
|
+
return hasChildren2 ? source_default.red("\u25BE ") : source_default.red("x ");
|
|
917937
918005
|
}
|
|
917938
918006
|
}
|
|
917939
918007
|
}
|
|
@@ -918269,7 +918337,7 @@ var CliContext = class _CliContext {
|
|
|
918269
918337
|
if (false) {
|
|
918270
918338
|
this.logger.error("CLI_VERSION is not defined");
|
|
918271
918339
|
}
|
|
918272
|
-
return "4.80.4-
|
|
918340
|
+
return "4.80.4-4-g3da138c98f4";
|
|
918273
918341
|
}
|
|
918274
918342
|
getCliName() {
|
|
918275
918343
|
if (false) {
|
|
@@ -918416,16 +918484,16 @@ var CliContext = class _CliContext {
|
|
|
918416
918484
|
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
918417
918485
|
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
918418
918486
|
constructTaskInitForWorkspace(workspace) {
|
|
918419
|
-
const
|
|
918420
|
-
|
|
918421
|
-
);
|
|
918487
|
+
const workspaceName = workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api";
|
|
918488
|
+
const prefixWithoutPadding = wrapWorkspaceNameForPrefix(workspaceName);
|
|
918422
918489
|
const minLengthForPrefix = 1 + (this.longestWorkspaceName != null ? wrapWorkspaceNameForPrefix(this.longestWorkspaceName) : prefixWithoutPadding).length;
|
|
918423
918490
|
const prefix2 = prefixWithoutPadding.padEnd(minLengthForPrefix);
|
|
918424
918491
|
const colorForWorkspace = WORKSPACE_NAME_COLORS[this.numTasks++ % WORKSPACE_NAME_COLORS.length];
|
|
918425
918492
|
const prefixWithColor = source_default.hex(colorForWorkspace)(prefix2);
|
|
918426
918493
|
return {
|
|
918427
918494
|
...this.constructTaskInit(),
|
|
918428
|
-
logPrefix: prefixWithColor
|
|
918495
|
+
logPrefix: prefixWithColor,
|
|
918496
|
+
title: source_default.hex(colorForWorkspace).bold(workspaceName)
|
|
918429
918497
|
};
|
|
918430
918498
|
}
|
|
918431
918499
|
constructTaskInit() {
|
|
@@ -919855,6 +919923,1007 @@ async function addGeneratorToWorkspaces({
|
|
|
919855
919923
|
);
|
|
919856
919924
|
}
|
|
919857
919925
|
|
|
919926
|
+
// src/commands/generate/filterGenerators.ts
|
|
919927
|
+
function parseGeneratorArg(generatorArg) {
|
|
919928
|
+
if (generatorArg == null) {
|
|
919929
|
+
return { generatorName: void 0, generatorIndex: void 0 };
|
|
919930
|
+
}
|
|
919931
|
+
const parsed = generatorArg.length > 0 ? Number(generatorArg) : Number.NaN;
|
|
919932
|
+
if (!Number.isNaN(parsed) && Number.isInteger(parsed) && parsed >= 0) {
|
|
919933
|
+
return { generatorName: void 0, generatorIndex: parsed };
|
|
919934
|
+
}
|
|
919935
|
+
return { generatorName: generatorArg, generatorIndex: void 0 };
|
|
919936
|
+
}
|
|
919937
|
+
function filterGenerators({
|
|
919938
|
+
generators,
|
|
919939
|
+
generatorIndex,
|
|
919940
|
+
generatorName,
|
|
919941
|
+
groupName
|
|
919942
|
+
}) {
|
|
919943
|
+
if (generatorIndex != null) {
|
|
919944
|
+
const generator = generators[generatorIndex];
|
|
919945
|
+
if (generator == null) {
|
|
919946
|
+
return {
|
|
919947
|
+
ok: false,
|
|
919948
|
+
error: `Generator index ${generatorIndex} is out of bounds in group '${groupName}' (${generators.length} generators available)`
|
|
919949
|
+
};
|
|
919950
|
+
}
|
|
919951
|
+
return { ok: true, generators: [generator] };
|
|
919952
|
+
}
|
|
919953
|
+
if (generatorName != null) {
|
|
919954
|
+
const filtered = generators.filter((gen) => gen.name === generatorName);
|
|
919955
|
+
if (filtered.length === 0) {
|
|
919956
|
+
const available = generators.map((gen) => gen.name);
|
|
919957
|
+
return {
|
|
919958
|
+
ok: false,
|
|
919959
|
+
error: `Generator '${generatorName}' not found in group '${groupName}'. Available generators: ${available.join(", ")}`
|
|
919960
|
+
};
|
|
919961
|
+
}
|
|
919962
|
+
return { ok: true, generators: filtered };
|
|
919963
|
+
}
|
|
919964
|
+
return { ok: true, generators };
|
|
919965
|
+
}
|
|
919966
|
+
|
|
919967
|
+
// src/commands/generate/generateAPIWorkspaces.ts
|
|
919968
|
+
init_lib6();
|
|
919969
|
+
|
|
919970
|
+
// src/constants.ts
|
|
919971
|
+
var API_CLI_OPTION = "api";
|
|
919972
|
+
var GROUP_CLI_OPTION = "group";
|
|
919973
|
+
var PREVIEW_DIRECTORY = ".preview";
|
|
919974
|
+
var APPROVED_DIRECTORIES_FILENAME = "approved-output-directories";
|
|
919975
|
+
var LOCAL_STORAGE_FOLDER6 = ".fern-dev";
|
|
919976
|
+
|
|
919977
|
+
// src/commands/generate/checkOutputDirectory.ts
|
|
919978
|
+
init_lib6();
|
|
919979
|
+
var import_promises136 = require("fs/promises");
|
|
919980
|
+
|
|
919981
|
+
// src/persistence/output-directories/getOutputDirectories.ts
|
|
919982
|
+
init_lib6();
|
|
919983
|
+
var import_promises134 = require("fs/promises");
|
|
919984
|
+
|
|
919985
|
+
// src/persistence/output-directories/getPathToOutputDirectoriesFile.ts
|
|
919986
|
+
init_lib6();
|
|
919987
|
+
var import_os16 = require("os");
|
|
919988
|
+
function getPathToOutputDirectoriesFile() {
|
|
919989
|
+
return join8(
|
|
919990
|
+
AbsoluteFilePath2.of((0, import_os16.homedir)()),
|
|
919991
|
+
RelativeFilePath2.of(LOCAL_STORAGE_FOLDER6),
|
|
919992
|
+
RelativeFilePath2.of(APPROVED_DIRECTORIES_FILENAME)
|
|
919993
|
+
);
|
|
919994
|
+
}
|
|
919995
|
+
|
|
919996
|
+
// src/persistence/output-directories/getOutputDirectories.ts
|
|
919997
|
+
async function getOutputDirectories() {
|
|
919998
|
+
const pathToOutputDirectoriesFile = getPathToOutputDirectoriesFile();
|
|
919999
|
+
const doesOutputDirectoriesFileExist = await doesPathExist(pathToOutputDirectoriesFile);
|
|
920000
|
+
if (!doesOutputDirectoriesFileExist) {
|
|
920001
|
+
return [];
|
|
920002
|
+
}
|
|
920003
|
+
const outputDirectoriesFileContents = await (0, import_promises134.readFile)(pathToOutputDirectoriesFile, { encoding: "utf-8" });
|
|
920004
|
+
const outputDirectories = JSON.parse(outputDirectoriesFileContents);
|
|
920005
|
+
return outputDirectories;
|
|
920006
|
+
}
|
|
920007
|
+
|
|
920008
|
+
// src/persistence/output-directories/storeOutputDirectories.ts
|
|
920009
|
+
var import_promises135 = require("fs/promises");
|
|
920010
|
+
var import_path85 = __toESM(require("path"), 1);
|
|
920011
|
+
async function storeOutputDirectories(outputDirectories) {
|
|
920012
|
+
await (0, import_promises135.mkdir)(import_path85.default.dirname(getPathToOutputDirectoriesFile()), { recursive: true });
|
|
920013
|
+
await (0, import_promises135.writeFile)(getPathToOutputDirectoriesFile(), JSON.stringify(outputDirectories, null, 2));
|
|
920014
|
+
}
|
|
920015
|
+
|
|
920016
|
+
// src/commands/generate/checkOutputDirectory.ts
|
|
920017
|
+
async function checkOutputDirectory(outputPath, cliContext, force) {
|
|
920018
|
+
if (!outputPath || isCI() || force) {
|
|
920019
|
+
return {
|
|
920020
|
+
shouldProceed: true
|
|
920021
|
+
};
|
|
920022
|
+
}
|
|
920023
|
+
const savedDirectories = await getOutputDirectories();
|
|
920024
|
+
if (savedDirectories?.includes(outputPath)) {
|
|
920025
|
+
return {
|
|
920026
|
+
shouldProceed: true
|
|
920027
|
+
};
|
|
920028
|
+
}
|
|
920029
|
+
const doesExist = await doesPathExist(outputPath);
|
|
920030
|
+
if (!doesExist) {
|
|
920031
|
+
return {
|
|
920032
|
+
shouldProceed: true
|
|
920033
|
+
};
|
|
920034
|
+
}
|
|
920035
|
+
const files = await (0, import_promises136.readdir)(outputPath);
|
|
920036
|
+
if (files.length === 0) {
|
|
920037
|
+
return {
|
|
920038
|
+
shouldProceed: true
|
|
920039
|
+
};
|
|
920040
|
+
}
|
|
920041
|
+
const shouldOverwrite = await cliContext.confirmPrompt(
|
|
920042
|
+
`Directory ${outputPath} contains existing files that may be overwritten. Continue?`,
|
|
920043
|
+
false
|
|
920044
|
+
);
|
|
920045
|
+
if (!shouldOverwrite) {
|
|
920046
|
+
return {
|
|
920047
|
+
shouldProceed: false
|
|
920048
|
+
};
|
|
920049
|
+
}
|
|
920050
|
+
await storeOutputDirectories([...savedDirectories ?? [], outputPath]);
|
|
920051
|
+
return {
|
|
920052
|
+
shouldProceed: true
|
|
920053
|
+
};
|
|
920054
|
+
}
|
|
920055
|
+
|
|
920056
|
+
// src/commands/generate/generateAPIWorkspace.ts
|
|
920057
|
+
init_lib6();
|
|
920058
|
+
|
|
920059
|
+
// src/commands/generate/resolveGroupAlias.ts
|
|
920060
|
+
function resolveGroupAlias({
|
|
920061
|
+
name: name2,
|
|
920062
|
+
groupAliases,
|
|
920063
|
+
availableGroupNames
|
|
920064
|
+
}) {
|
|
920065
|
+
const aliasTargets = groupAliases[name2];
|
|
920066
|
+
if (aliasTargets != null) {
|
|
920067
|
+
for (const target of aliasTargets) {
|
|
920068
|
+
if (!availableGroupNames.includes(target)) {
|
|
920069
|
+
return {
|
|
920070
|
+
type: "alias-references-missing-group",
|
|
920071
|
+
alias: name2,
|
|
920072
|
+
missingGroupName: target,
|
|
920073
|
+
availableGroupNames
|
|
920074
|
+
};
|
|
920075
|
+
}
|
|
920076
|
+
}
|
|
920077
|
+
return { type: "resolved", groupNames: aliasTargets };
|
|
920078
|
+
}
|
|
920079
|
+
if (availableGroupNames.includes(name2)) {
|
|
920080
|
+
return { type: "resolved", groupNames: [name2] };
|
|
920081
|
+
}
|
|
920082
|
+
return {
|
|
920083
|
+
type: "unknown",
|
|
920084
|
+
name: name2,
|
|
920085
|
+
availableGroupNames,
|
|
920086
|
+
availableAliasNames: Object.keys(groupAliases)
|
|
920087
|
+
};
|
|
920088
|
+
}
|
|
920089
|
+
|
|
920090
|
+
// src/commands/generate/resolveGroupNamesForGeneration.ts
|
|
920091
|
+
function resolveGroupNamesForGeneration({
|
|
920092
|
+
groupName,
|
|
920093
|
+
generatorsConfiguration,
|
|
920094
|
+
isAutomation
|
|
920095
|
+
}) {
|
|
920096
|
+
if (isAutomation && groupName == null) {
|
|
920097
|
+
return {
|
|
920098
|
+
type: "fan-out",
|
|
920099
|
+
groupNames: generatorsConfiguration.groups.map((g8) => g8.groupName)
|
|
920100
|
+
};
|
|
920101
|
+
}
|
|
920102
|
+
const effective = groupName ?? generatorsConfiguration.defaultGroup;
|
|
920103
|
+
if (effective == null) {
|
|
920104
|
+
return {
|
|
920105
|
+
type: "missing-group",
|
|
920106
|
+
availableGroupNames: generatorsConfiguration.groups.map((g8) => g8.groupName)
|
|
920107
|
+
};
|
|
920108
|
+
}
|
|
920109
|
+
return {
|
|
920110
|
+
type: "targeted",
|
|
920111
|
+
groupName: effective,
|
|
920112
|
+
fromDefaultGroup: groupName == null
|
|
920113
|
+
};
|
|
920114
|
+
}
|
|
920115
|
+
|
|
920116
|
+
// src/commands/generate/describeSkipReason.ts
|
|
920117
|
+
function describeSkipReason(generator, rootAutorelease) {
|
|
920118
|
+
if (!generator.automation.generate) {
|
|
920119
|
+
return "automations.generate is false";
|
|
920120
|
+
}
|
|
920121
|
+
if (generator.absolutePathToLocalOutput != null) {
|
|
920122
|
+
return "output is configured for local-file-system (cannot run remotely)";
|
|
920123
|
+
}
|
|
920124
|
+
if (generator.raw?.autorelease === false) {
|
|
920125
|
+
return "autorelease is false";
|
|
920126
|
+
}
|
|
920127
|
+
if (generator.raw?.autorelease == null && rootAutorelease === false) {
|
|
920128
|
+
return "autorelease is false at the root of generators.yml";
|
|
920129
|
+
}
|
|
920130
|
+
return null;
|
|
920131
|
+
}
|
|
920132
|
+
|
|
920133
|
+
// src/commands/generate/shouldSkipGenerator.ts
|
|
920134
|
+
function shouldSkipGenerator({
|
|
920135
|
+
generator,
|
|
920136
|
+
rootAutorelease
|
|
920137
|
+
}) {
|
|
920138
|
+
return describeSkipReason(generator, rootAutorelease) != null;
|
|
920139
|
+
}
|
|
920140
|
+
|
|
920141
|
+
// src/commands/generate/selectGeneratorsForAutomation.ts
|
|
920142
|
+
function buildAutomationTargeting({
|
|
920143
|
+
generatorIndex,
|
|
920144
|
+
generatorName
|
|
920145
|
+
}) {
|
|
920146
|
+
if (generatorIndex != null) {
|
|
920147
|
+
return { type: "index", index: generatorIndex };
|
|
920148
|
+
}
|
|
920149
|
+
if (generatorName != null) {
|
|
920150
|
+
return { type: "name", name: generatorName };
|
|
920151
|
+
}
|
|
920152
|
+
return { type: "none" };
|
|
920153
|
+
}
|
|
920154
|
+
function selectGeneratorsForAutomation({
|
|
920155
|
+
generators,
|
|
920156
|
+
rootAutorelease,
|
|
920157
|
+
targeting
|
|
920158
|
+
}) {
|
|
920159
|
+
if (targeting.type === "index") {
|
|
920160
|
+
for (const g8 of generators) {
|
|
920161
|
+
const reason = describeSkipReason(g8, rootAutorelease);
|
|
920162
|
+
if (reason != null) {
|
|
920163
|
+
return { type: "reject-opted-out", generatorName: g8.name, index: targeting.index, reason };
|
|
920164
|
+
}
|
|
920165
|
+
}
|
|
920166
|
+
return { type: "run", generators };
|
|
920167
|
+
}
|
|
920168
|
+
const eligible = generators.filter((g8) => !shouldSkipGenerator({ generator: g8, rootAutorelease }));
|
|
920169
|
+
if (eligible.length === 0) {
|
|
920170
|
+
return { type: "empty-after-skip" };
|
|
920171
|
+
}
|
|
920172
|
+
return { type: "run", generators: eligible };
|
|
920173
|
+
}
|
|
920174
|
+
|
|
920175
|
+
// src/commands/generate/shouldSkipMissingGenerator.ts
|
|
920176
|
+
function shouldSkipMissingGenerator({
|
|
920177
|
+
automation,
|
|
920178
|
+
generatorName,
|
|
920179
|
+
generatorIndex
|
|
920180
|
+
}) {
|
|
920181
|
+
return automation != null && generatorName != null && generatorIndex == null;
|
|
920182
|
+
}
|
|
920183
|
+
|
|
920184
|
+
// src/commands/generate/generateAPIWorkspace.ts
|
|
920185
|
+
async function generateWorkspace({
|
|
920186
|
+
organization,
|
|
920187
|
+
workspace,
|
|
920188
|
+
projectConfig,
|
|
920189
|
+
context: context3,
|
|
920190
|
+
groupName,
|
|
920191
|
+
generatorName,
|
|
920192
|
+
generatorIndex,
|
|
920193
|
+
version: version7,
|
|
920194
|
+
shouldLogS3Url,
|
|
920195
|
+
token,
|
|
920196
|
+
useLocalDocker,
|
|
920197
|
+
keepDocker,
|
|
920198
|
+
absolutePathToPreview,
|
|
920199
|
+
mode,
|
|
920200
|
+
runner,
|
|
920201
|
+
inspect: inspect6,
|
|
920202
|
+
lfsOverride,
|
|
920203
|
+
fernignorePath,
|
|
920204
|
+
skipFernignore,
|
|
920205
|
+
dynamicIrOnly,
|
|
920206
|
+
noReplay,
|
|
920207
|
+
retryRateLimited,
|
|
920208
|
+
requireEnvVars,
|
|
920209
|
+
automationMode,
|
|
920210
|
+
autoMerge,
|
|
920211
|
+
automation
|
|
920212
|
+
}) {
|
|
920213
|
+
if (workspace.generatorsConfiguration == null) {
|
|
920214
|
+
context3.logger.warn("This workspaces has no generators.yml");
|
|
920215
|
+
return;
|
|
920216
|
+
}
|
|
920217
|
+
if (workspace.generatorsConfiguration.groups.length === 0) {
|
|
920218
|
+
context3.logger.warn(`This workspace has no groups specified in ${GENERATORS_CONFIGURATION_FILENAME}`);
|
|
920219
|
+
return;
|
|
920220
|
+
}
|
|
920221
|
+
const resolvedGroupNames = resolveGroupsOrFail({
|
|
920222
|
+
groupName,
|
|
920223
|
+
generatorsConfiguration: workspace.generatorsConfiguration,
|
|
920224
|
+
isAutomation: automation != null,
|
|
920225
|
+
context: context3
|
|
920226
|
+
});
|
|
920227
|
+
const { ai: ai10, replay } = workspace.generatorsConfiguration;
|
|
920228
|
+
if (!useLocalDocker && !token) {
|
|
920229
|
+
return context3.failAndThrow("Please run fern login", void 0, { code: CliError.Code.AuthError });
|
|
920230
|
+
}
|
|
920231
|
+
const runnableGroups = resolvedGroupNames.flatMap((resolvedGroupName) => {
|
|
920232
|
+
const runnable = resolveRunnableGroup({
|
|
920233
|
+
resolvedGroupName,
|
|
920234
|
+
workspace,
|
|
920235
|
+
generatorIndex,
|
|
920236
|
+
generatorName,
|
|
920237
|
+
automation,
|
|
920238
|
+
lfsOverride,
|
|
920239
|
+
context: context3,
|
|
920240
|
+
useLocalDocker,
|
|
920241
|
+
token
|
|
920242
|
+
});
|
|
920243
|
+
return runnable != null ? [{ resolvedGroupName, group: runnable }] : [];
|
|
920244
|
+
});
|
|
920245
|
+
await Promise.all(
|
|
920246
|
+
runnableGroups.map(
|
|
920247
|
+
({ resolvedGroupName, group }) => context3.runInteractiveTask({ name: resolvedGroupName }, async (groupContext) => {
|
|
920248
|
+
if (useLocalDocker) {
|
|
920249
|
+
await runLocalGenerationForWorkspace({
|
|
920250
|
+
token,
|
|
920251
|
+
projectConfig,
|
|
920252
|
+
workspace,
|
|
920253
|
+
generatorGroup: group,
|
|
920254
|
+
version: version7,
|
|
920255
|
+
keepDocker,
|
|
920256
|
+
context: groupContext,
|
|
920257
|
+
runner,
|
|
920258
|
+
absolutePathToPreview,
|
|
920259
|
+
inspect: inspect6,
|
|
920260
|
+
ai: ai10,
|
|
920261
|
+
replay,
|
|
920262
|
+
noReplay,
|
|
920263
|
+
validateWorkspace: true,
|
|
920264
|
+
requireEnvVars,
|
|
920265
|
+
skipFernignore,
|
|
920266
|
+
automationMode,
|
|
920267
|
+
autoMerge
|
|
920268
|
+
});
|
|
920269
|
+
} else if (token != null) {
|
|
920270
|
+
await runRemoteGenerationForAPIWorkspace({
|
|
920271
|
+
projectConfig,
|
|
920272
|
+
organization,
|
|
920273
|
+
workspace,
|
|
920274
|
+
context: groupContext,
|
|
920275
|
+
generatorGroup: group,
|
|
920276
|
+
version: version7,
|
|
920277
|
+
shouldLogS3Url,
|
|
920278
|
+
token,
|
|
920279
|
+
whitelabel: workspace.generatorsConfiguration?.whitelabel,
|
|
920280
|
+
absolutePathToPreview,
|
|
920281
|
+
mode,
|
|
920282
|
+
fernignorePath,
|
|
920283
|
+
skipFernignore,
|
|
920284
|
+
dynamicIrOnly,
|
|
920285
|
+
validateWorkspace: true,
|
|
920286
|
+
retryRateLimited,
|
|
920287
|
+
requireEnvVars,
|
|
920288
|
+
automationMode,
|
|
920289
|
+
autoMerge,
|
|
920290
|
+
automation
|
|
920291
|
+
});
|
|
920292
|
+
}
|
|
920293
|
+
})
|
|
920294
|
+
)
|
|
920295
|
+
);
|
|
920296
|
+
}
|
|
920297
|
+
function resolveRunnableGroup({
|
|
920298
|
+
resolvedGroupName,
|
|
920299
|
+
workspace,
|
|
920300
|
+
generatorIndex,
|
|
920301
|
+
generatorName,
|
|
920302
|
+
automation,
|
|
920303
|
+
lfsOverride,
|
|
920304
|
+
context: context3,
|
|
920305
|
+
useLocalDocker,
|
|
920306
|
+
token
|
|
920307
|
+
}) {
|
|
920308
|
+
let group = workspace.generatorsConfiguration?.groups.find(
|
|
920309
|
+
(otherGroup) => otherGroup.groupName === resolvedGroupName
|
|
920310
|
+
);
|
|
920311
|
+
if (group == null) {
|
|
920312
|
+
return context3.failAndThrow(`Group '${resolvedGroupName}' does not exist.`, void 0, {
|
|
920313
|
+
code: CliError.Code.ConfigError
|
|
920314
|
+
});
|
|
920315
|
+
}
|
|
920316
|
+
const filterResult = filterGenerators({
|
|
920317
|
+
generators: group.generators,
|
|
920318
|
+
generatorIndex,
|
|
920319
|
+
generatorName,
|
|
920320
|
+
groupName: resolvedGroupName
|
|
920321
|
+
});
|
|
920322
|
+
if (!filterResult.ok) {
|
|
920323
|
+
if (shouldSkipMissingGenerator({ automation, generatorName, generatorIndex })) {
|
|
920324
|
+
return null;
|
|
920325
|
+
}
|
|
920326
|
+
return context3.failAndThrow(filterResult.error, void 0, { code: CliError.Code.ConfigError });
|
|
920327
|
+
}
|
|
920328
|
+
let filteredGenerators = filterResult.generators;
|
|
920329
|
+
if (automation != null) {
|
|
920330
|
+
const selection = selectGeneratorsForAutomation({
|
|
920331
|
+
generators: filteredGenerators,
|
|
920332
|
+
rootAutorelease: workspace.generatorsConfiguration?.rawConfiguration.autorelease,
|
|
920333
|
+
targeting: buildAutomationTargeting({ generatorIndex, generatorName })
|
|
920334
|
+
});
|
|
920335
|
+
if (selection.type === "reject-opted-out") {
|
|
920336
|
+
return context3.failAndThrow(
|
|
920337
|
+
`Generator '${selection.generatorName}' at index ${selection.index} in group '${resolvedGroupName}' is excluded from automation: ${selection.reason}. Target by name instead to have opt-outs filtered silently, drop the --generator flag to fan out across eligible generators, or re-enable automation for this generator in generators.yml.`,
|
|
920338
|
+
void 0,
|
|
920339
|
+
{ code: CliError.Code.ConfigError }
|
|
920340
|
+
);
|
|
920341
|
+
}
|
|
920342
|
+
if (selection.type === "empty-after-skip") {
|
|
920343
|
+
return null;
|
|
920344
|
+
}
|
|
920345
|
+
filteredGenerators = selection.generators;
|
|
920346
|
+
}
|
|
920347
|
+
group = { ...group, generators: filteredGenerators };
|
|
920348
|
+
if (lfsOverride != null) {
|
|
920349
|
+
group = applyLfsOverride(group, lfsOverride, context3);
|
|
920350
|
+
}
|
|
920351
|
+
if (!useLocalDocker && token != null) {
|
|
920352
|
+
const customImageGenerators = group.generators.filter((g8) => g8.containerImage != null);
|
|
920353
|
+
if (customImageGenerators.length > 0) {
|
|
920354
|
+
const names2 = customImageGenerators.map((g8) => g8.name).join(", ");
|
|
920355
|
+
return context3.failAndThrow(
|
|
920356
|
+
`Custom image configurations are only supported with local generation (--local). The following generators use custom images: ${names2}`
|
|
920357
|
+
);
|
|
920358
|
+
}
|
|
920359
|
+
}
|
|
920360
|
+
return group;
|
|
920361
|
+
}
|
|
920362
|
+
function resolveGroupsOrFail({
|
|
920363
|
+
groupName,
|
|
920364
|
+
generatorsConfiguration,
|
|
920365
|
+
isAutomation,
|
|
920366
|
+
context: context3
|
|
920367
|
+
}) {
|
|
920368
|
+
const resolution = resolveGroupNamesForGeneration({ groupName, generatorsConfiguration, isAutomation });
|
|
920369
|
+
if (resolution.type === "fan-out") {
|
|
920370
|
+
return resolution.groupNames;
|
|
920371
|
+
}
|
|
920372
|
+
if (resolution.type === "missing-group") {
|
|
920373
|
+
const longestGroupName = Math.max(...resolution.availableGroupNames.map((name2) => name2.length));
|
|
920374
|
+
const currentArgs = process.argv.slice(2).join(" ");
|
|
920375
|
+
const suggestions = resolution.availableGroupNames.map((name2) => {
|
|
920376
|
+
const suggestedCommand = `fern ${currentArgs} --${GROUP_CLI_OPTION} ${name2}`;
|
|
920377
|
+
return ` \u203A ${source_default.bold(name2.padEnd(longestGroupName))} ${source_default.dim(suggestedCommand)}`;
|
|
920378
|
+
}).join("\n");
|
|
920379
|
+
context3.failAndThrow(
|
|
920380
|
+
`No group specified. Use the --${GROUP_CLI_OPTION} option, or set "${DEFAULT_GROUP_GENERATORS_CONFIG_KEY}" in ${GENERATORS_CONFIGURATION_FILENAME}:
|
|
920381
|
+
${suggestions}`,
|
|
920382
|
+
void 0,
|
|
920383
|
+
{ code: CliError.Code.NetworkError }
|
|
920384
|
+
);
|
|
920385
|
+
return [];
|
|
920386
|
+
}
|
|
920387
|
+
if (resolution.fromDefaultGroup) {
|
|
920388
|
+
context3.logger.info(
|
|
920389
|
+
source_default.dim(`Using default group '${resolution.groupName}' from ${GENERATORS_CONFIGURATION_FILENAME}`)
|
|
920390
|
+
);
|
|
920391
|
+
}
|
|
920392
|
+
const aliasResult = resolveGroupAlias({
|
|
920393
|
+
name: resolution.groupName,
|
|
920394
|
+
groupAliases: generatorsConfiguration.groupAliases,
|
|
920395
|
+
availableGroupNames: generatorsConfiguration.groups.map((g8) => g8.groupName)
|
|
920396
|
+
});
|
|
920397
|
+
if (aliasResult.type === "alias-references-missing-group") {
|
|
920398
|
+
context3.failAndThrow(
|
|
920399
|
+
`Group alias '${aliasResult.alias}' references non-existent group '${aliasResult.missingGroupName}'. Available groups: ${aliasResult.availableGroupNames.join(", ")}`,
|
|
920400
|
+
void 0,
|
|
920401
|
+
{ code: CliError.Code.NetworkError }
|
|
920402
|
+
);
|
|
920403
|
+
return [];
|
|
920404
|
+
}
|
|
920405
|
+
if (aliasResult.type === "unknown") {
|
|
920406
|
+
const aliasesSuffix = aliasResult.availableAliasNames.length > 0 ? `. Available aliases: ${aliasResult.availableAliasNames.join(", ")}` : "";
|
|
920407
|
+
context3.failAndThrow(
|
|
920408
|
+
`'${aliasResult.name}' is not a valid group or alias. Available groups: ${aliasResult.availableGroupNames.join(", ")}${aliasesSuffix}`,
|
|
920409
|
+
void 0,
|
|
920410
|
+
{ code: CliError.Code.NetworkError }
|
|
920411
|
+
);
|
|
920412
|
+
return [];
|
|
920413
|
+
}
|
|
920414
|
+
return aliasResult.groupNames;
|
|
920415
|
+
}
|
|
920416
|
+
function applyLfsOverride(group, lfsOverridePath, context3) {
|
|
920417
|
+
const baseAbsolutePath = AbsoluteFilePath2.of(resolve6(cwd(), lfsOverridePath));
|
|
920418
|
+
const languageCount = {};
|
|
920419
|
+
const modifiedGenerators = [];
|
|
920420
|
+
for (const generator of group.generators) {
|
|
920421
|
+
const language = generator.language ?? getLanguageFromGeneratorName3(generator.name);
|
|
920422
|
+
let outputPath;
|
|
920423
|
+
if (group.generators.length === 1) {
|
|
920424
|
+
outputPath = baseAbsolutePath;
|
|
920425
|
+
} else {
|
|
920426
|
+
const languageDir = language || "unknown";
|
|
920427
|
+
if (languageCount[languageDir] == null) {
|
|
920428
|
+
languageCount[languageDir] = 0;
|
|
920429
|
+
}
|
|
920430
|
+
languageCount[languageDir]++;
|
|
920431
|
+
const dirName = languageCount[languageDir] === 1 ? languageDir : `${languageDir}-${languageCount[languageDir]}`;
|
|
920432
|
+
outputPath = join8(baseAbsolutePath, RelativeFilePath2.of(dirName));
|
|
920433
|
+
}
|
|
920434
|
+
const modifiedGenerator = {
|
|
920435
|
+
...generator,
|
|
920436
|
+
outputMode: api_exports4.remoteGen.OutputMode.downloadFiles({}),
|
|
920437
|
+
absolutePathToLocalOutput: outputPath
|
|
920438
|
+
};
|
|
920439
|
+
modifiedGenerators.push(modifiedGenerator);
|
|
920440
|
+
context3.logger.info(
|
|
920441
|
+
`Overriding output for generator '${generator.name}' to local-file-system at: ${outputPath}`
|
|
920442
|
+
);
|
|
920443
|
+
}
|
|
920444
|
+
return {
|
|
920445
|
+
...group,
|
|
920446
|
+
generators: modifiedGenerators
|
|
920447
|
+
};
|
|
920448
|
+
}
|
|
920449
|
+
function getLanguageFromGeneratorName3(generatorName) {
|
|
920450
|
+
if (generatorName.includes("typescript") || generatorName.includes("ts")) {
|
|
920451
|
+
return "typescript";
|
|
920452
|
+
}
|
|
920453
|
+
if (generatorName.includes("python") || generatorName.includes("py")) {
|
|
920454
|
+
return "python";
|
|
920455
|
+
}
|
|
920456
|
+
if (generatorName.includes("java")) {
|
|
920457
|
+
return "java";
|
|
920458
|
+
}
|
|
920459
|
+
if (generatorName.includes("go")) {
|
|
920460
|
+
return "go";
|
|
920461
|
+
}
|
|
920462
|
+
if (generatorName.includes("ruby")) {
|
|
920463
|
+
return "ruby";
|
|
920464
|
+
}
|
|
920465
|
+
if (generatorName.includes("csharp") || generatorName.includes("c#")) {
|
|
920466
|
+
return "csharp";
|
|
920467
|
+
}
|
|
920468
|
+
if (generatorName.includes("swift")) {
|
|
920469
|
+
return "swift";
|
|
920470
|
+
}
|
|
920471
|
+
if (generatorName.includes("php")) {
|
|
920472
|
+
return "php";
|
|
920473
|
+
}
|
|
920474
|
+
if (generatorName.includes("rust")) {
|
|
920475
|
+
return "rust";
|
|
920476
|
+
}
|
|
920477
|
+
return generatorName.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
920478
|
+
}
|
|
920479
|
+
|
|
920480
|
+
// src/commands/generate/resolvePosthogCommandLabel.ts
|
|
920481
|
+
function resolvePosthogCommandLabel(automation) {
|
|
920482
|
+
return automation != null ? "fern automations generate" : "fern generate";
|
|
920483
|
+
}
|
|
920484
|
+
|
|
920485
|
+
// src/commands/generate/shouldPreflightGenerator.ts
|
|
920486
|
+
function shouldPreflightGenerator({
|
|
920487
|
+
generator,
|
|
920488
|
+
rootAutorelease,
|
|
920489
|
+
automation
|
|
920490
|
+
}) {
|
|
920491
|
+
if (automation == null) {
|
|
920492
|
+
return true;
|
|
920493
|
+
}
|
|
920494
|
+
return !shouldSkipGenerator({ generator, rootAutorelease });
|
|
920495
|
+
}
|
|
920496
|
+
|
|
920497
|
+
// src/commands/generate/generateAPIWorkspaces.ts
|
|
920498
|
+
var GenerationMode = {
|
|
920499
|
+
PullRequest: "pull-request"
|
|
920500
|
+
};
|
|
920501
|
+
async function generateAPIWorkspaces({
|
|
920502
|
+
project,
|
|
920503
|
+
cliContext,
|
|
920504
|
+
version: version7,
|
|
920505
|
+
groupName,
|
|
920506
|
+
generatorName,
|
|
920507
|
+
generatorIndex,
|
|
920508
|
+
shouldLogS3Url,
|
|
920509
|
+
keepDocker,
|
|
920510
|
+
useLocalDocker,
|
|
920511
|
+
preview,
|
|
920512
|
+
mode,
|
|
920513
|
+
force,
|
|
920514
|
+
runner,
|
|
920515
|
+
inspect: inspect6,
|
|
920516
|
+
lfsOverride,
|
|
920517
|
+
fernignorePath,
|
|
920518
|
+
skipFernignore,
|
|
920519
|
+
dynamicIrOnly,
|
|
920520
|
+
outputDir,
|
|
920521
|
+
noReplay,
|
|
920522
|
+
retryRateLimited,
|
|
920523
|
+
requireEnvVars,
|
|
920524
|
+
automationMode,
|
|
920525
|
+
autoMerge,
|
|
920526
|
+
automation
|
|
920527
|
+
}) {
|
|
920528
|
+
let token = void 0;
|
|
920529
|
+
if (!useLocalDocker) {
|
|
920530
|
+
const currentToken = await cliContext.runTask(async (context3) => {
|
|
920531
|
+
return askToLogin(context3);
|
|
920532
|
+
});
|
|
920533
|
+
if (currentToken.type === "user") {
|
|
920534
|
+
await cliContext.runTask(async (context3) => {
|
|
920535
|
+
await createOrganizationIfDoesNotExist({
|
|
920536
|
+
organization: project.config.organization,
|
|
920537
|
+
token: currentToken,
|
|
920538
|
+
context: context3
|
|
920539
|
+
});
|
|
920540
|
+
});
|
|
920541
|
+
}
|
|
920542
|
+
token = currentToken;
|
|
920543
|
+
}
|
|
920544
|
+
await confirmOutputDirectoriesForEligibleGenerators({
|
|
920545
|
+
project,
|
|
920546
|
+
groupName,
|
|
920547
|
+
generatorName,
|
|
920548
|
+
generatorIndex,
|
|
920549
|
+
automation,
|
|
920550
|
+
cliContext,
|
|
920551
|
+
force
|
|
920552
|
+
});
|
|
920553
|
+
cliContext.instrumentPostHogEvent({
|
|
920554
|
+
orgId: project.config.organization,
|
|
920555
|
+
command: resolvePosthogCommandLabel(automation),
|
|
920556
|
+
properties: {
|
|
920557
|
+
workspaces: buildPosthogWorkspaces({ project, groupName, generatorName })
|
|
920558
|
+
}
|
|
920559
|
+
});
|
|
920560
|
+
await Promise.all(
|
|
920561
|
+
project.apiWorkspaces.map(async (workspace) => {
|
|
920562
|
+
await cliContext.runTaskForWorkspace(workspace, async (context3) => {
|
|
920563
|
+
const absolutePathToPreview = preview ? outputDir != null ? AbsoluteFilePath2.of(resolve6(cwd(), outputDir)) : join8(workspace.absoluteFilePath, RelativeFilePath2.of(PREVIEW_DIRECTORY)) : void 0;
|
|
920564
|
+
if (absolutePathToPreview != null) {
|
|
920565
|
+
context3.logger.info(`Writing preview to ${absolutePathToPreview}`);
|
|
920566
|
+
}
|
|
920567
|
+
await generateWorkspace({
|
|
920568
|
+
organization: project.config.organization,
|
|
920569
|
+
workspace,
|
|
920570
|
+
projectConfig: project.config,
|
|
920571
|
+
context: context3,
|
|
920572
|
+
version: version7,
|
|
920573
|
+
groupName,
|
|
920574
|
+
generatorName,
|
|
920575
|
+
generatorIndex,
|
|
920576
|
+
shouldLogS3Url,
|
|
920577
|
+
token,
|
|
920578
|
+
useLocalDocker,
|
|
920579
|
+
keepDocker,
|
|
920580
|
+
absolutePathToPreview,
|
|
920581
|
+
mode,
|
|
920582
|
+
runner,
|
|
920583
|
+
inspect: inspect6,
|
|
920584
|
+
lfsOverride,
|
|
920585
|
+
fernignorePath,
|
|
920586
|
+
skipFernignore,
|
|
920587
|
+
dynamicIrOnly,
|
|
920588
|
+
noReplay,
|
|
920589
|
+
retryRateLimited,
|
|
920590
|
+
requireEnvVars,
|
|
920591
|
+
automationMode,
|
|
920592
|
+
autoMerge,
|
|
920593
|
+
automation
|
|
920594
|
+
});
|
|
920595
|
+
});
|
|
920596
|
+
})
|
|
920597
|
+
);
|
|
920598
|
+
}
|
|
920599
|
+
async function confirmOutputDirectoriesForEligibleGenerators({
|
|
920600
|
+
project,
|
|
920601
|
+
groupName,
|
|
920602
|
+
generatorName,
|
|
920603
|
+
generatorIndex,
|
|
920604
|
+
automation,
|
|
920605
|
+
cliContext,
|
|
920606
|
+
force
|
|
920607
|
+
}) {
|
|
920608
|
+
for (const workspace of project.apiWorkspaces) {
|
|
920609
|
+
const resolvedGroupNames = expandGroupFilter(groupName, workspace.generatorsConfiguration);
|
|
920610
|
+
const rootAutorelease = workspace.generatorsConfiguration?.rawConfiguration.autorelease;
|
|
920611
|
+
const groupsInScope = workspace.generatorsConfiguration?.groups.filter(
|
|
920612
|
+
(group) => resolvedGroupNames == null || resolvedGroupNames.includes(group.groupName)
|
|
920613
|
+
) ?? [];
|
|
920614
|
+
for (const group of groupsInScope) {
|
|
920615
|
+
const filterResult = filterGenerators({
|
|
920616
|
+
generators: group.generators,
|
|
920617
|
+
generatorIndex,
|
|
920618
|
+
generatorName,
|
|
920619
|
+
groupName: group.groupName
|
|
920620
|
+
});
|
|
920621
|
+
if (!filterResult.ok) {
|
|
920622
|
+
continue;
|
|
920623
|
+
}
|
|
920624
|
+
for (const generator of filterResult.generators) {
|
|
920625
|
+
if (!shouldPreflightGenerator({ generator, rootAutorelease, automation })) {
|
|
920626
|
+
continue;
|
|
920627
|
+
}
|
|
920628
|
+
const { shouldProceed } = await checkOutputDirectory(
|
|
920629
|
+
generator.absolutePathToLocalOutput,
|
|
920630
|
+
cliContext,
|
|
920631
|
+
force
|
|
920632
|
+
);
|
|
920633
|
+
if (!shouldProceed) {
|
|
920634
|
+
cliContext.failAndThrow("Generation cancelled", void 0, { code: CliError.Code.ConfigError });
|
|
920635
|
+
}
|
|
920636
|
+
}
|
|
920637
|
+
}
|
|
920638
|
+
}
|
|
920639
|
+
}
|
|
920640
|
+
function buildPosthogWorkspaces({
|
|
920641
|
+
project,
|
|
920642
|
+
groupName,
|
|
920643
|
+
generatorName
|
|
920644
|
+
}) {
|
|
920645
|
+
return project.apiWorkspaces.map((workspace) => {
|
|
920646
|
+
const resolvedGroupNames = expandGroupFilter(groupName, workspace.generatorsConfiguration);
|
|
920647
|
+
return {
|
|
920648
|
+
name: workspace.workspaceName,
|
|
920649
|
+
group: groupName,
|
|
920650
|
+
generators: workspace.generatorsConfiguration?.groups.filter((group) => resolvedGroupNames == null || resolvedGroupNames.includes(group.groupName)).map(
|
|
920651
|
+
(group) => group.generators.filter((generator) => generatorName == null || generator.name === generatorName).map((generator) => ({
|
|
920652
|
+
name: generator.name,
|
|
920653
|
+
version: generator.version,
|
|
920654
|
+
outputMode: generator.outputMode.type,
|
|
920655
|
+
config: generator.config
|
|
920656
|
+
}))
|
|
920657
|
+
)
|
|
920658
|
+
};
|
|
920659
|
+
});
|
|
920660
|
+
}
|
|
920661
|
+
function expandGroupFilter(groupName, generatorsConfiguration) {
|
|
920662
|
+
if (groupName == null) {
|
|
920663
|
+
return null;
|
|
920664
|
+
}
|
|
920665
|
+
if (generatorsConfiguration == null) {
|
|
920666
|
+
return [groupName];
|
|
920667
|
+
}
|
|
920668
|
+
const aliasGroups = generatorsConfiguration.groupAliases[groupName];
|
|
920669
|
+
if (aliasGroups != null) {
|
|
920670
|
+
return aliasGroups;
|
|
920671
|
+
}
|
|
920672
|
+
return [groupName];
|
|
920673
|
+
}
|
|
920674
|
+
|
|
920675
|
+
// src/commands/automations/generate/GeneratorRunResult.ts
|
|
920676
|
+
function countResults(results) {
|
|
920677
|
+
let succeeded = 0;
|
|
920678
|
+
let failed = 0;
|
|
920679
|
+
let skipped = 0;
|
|
920680
|
+
for (const r5 of results) {
|
|
920681
|
+
switch (r5.status) {
|
|
920682
|
+
case "success":
|
|
920683
|
+
succeeded++;
|
|
920684
|
+
break;
|
|
920685
|
+
case "failed":
|
|
920686
|
+
failed++;
|
|
920687
|
+
break;
|
|
920688
|
+
case "skipped_no_diff":
|
|
920689
|
+
skipped++;
|
|
920690
|
+
break;
|
|
920691
|
+
}
|
|
920692
|
+
}
|
|
920693
|
+
return { succeeded, failed, skipped };
|
|
920694
|
+
}
|
|
920695
|
+
var GeneratorRunCollector = class {
|
|
920696
|
+
#results = [];
|
|
920697
|
+
recordSuccess(args) {
|
|
920698
|
+
this.#results.push({
|
|
920699
|
+
apiName: args.apiName,
|
|
920700
|
+
groupName: args.groupName,
|
|
920701
|
+
generatorName: args.generatorName,
|
|
920702
|
+
status: "success",
|
|
920703
|
+
version: args.version,
|
|
920704
|
+
pullRequestUrl: null,
|
|
920705
|
+
errorMessage: null,
|
|
920706
|
+
durationMs: args.durationMs
|
|
920707
|
+
});
|
|
920708
|
+
}
|
|
920709
|
+
recordFailure(args) {
|
|
920710
|
+
this.#results.push({
|
|
920711
|
+
apiName: args.apiName,
|
|
920712
|
+
groupName: args.groupName,
|
|
920713
|
+
generatorName: args.generatorName,
|
|
920714
|
+
status: "failed",
|
|
920715
|
+
version: null,
|
|
920716
|
+
pullRequestUrl: null,
|
|
920717
|
+
errorMessage: args.errorMessage,
|
|
920718
|
+
durationMs: args.durationMs
|
|
920719
|
+
});
|
|
920720
|
+
}
|
|
920721
|
+
results() {
|
|
920722
|
+
return this.#results;
|
|
920723
|
+
}
|
|
920724
|
+
hasFailures() {
|
|
920725
|
+
return this.#results.some((r5) => r5.status === "failed");
|
|
920726
|
+
}
|
|
920727
|
+
counts() {
|
|
920728
|
+
return countResults(this.#results);
|
|
920729
|
+
}
|
|
920730
|
+
};
|
|
920731
|
+
|
|
920732
|
+
// src/commands/automations/generate/reportGenerateResults.ts
|
|
920733
|
+
var import_fs35 = require("fs");
|
|
920734
|
+
var import_promises137 = require("fs/promises");
|
|
920735
|
+
var JSON_SCHEMA_VERSION = 1;
|
|
920736
|
+
function renderStdoutSummary(results) {
|
|
920737
|
+
return formatCounts(countResults(results));
|
|
920738
|
+
}
|
|
920739
|
+
function renderMarkdownSummary(results) {
|
|
920740
|
+
const lines = [];
|
|
920741
|
+
lines.push("## Fern Automations \xB7 Generate");
|
|
920742
|
+
lines.push("");
|
|
920743
|
+
lines.push("| API | Group | Generator | Status | Version | PR |");
|
|
920744
|
+
lines.push("|-----|-------|-----------|--------|---------|----|");
|
|
920745
|
+
for (const result of results) {
|
|
920746
|
+
lines.push(
|
|
920747
|
+
`| ${mdCell(result.apiName)} | ${mdCell(result.groupName)} | ${mdCell(result.generatorName)} | ${statusCell(result)} | ${mdCell(result.version)} | ${prCell(result.pullRequestUrl)} |`
|
|
920748
|
+
);
|
|
920749
|
+
}
|
|
920750
|
+
lines.push("");
|
|
920751
|
+
lines.push(`**Summary:** ${formatCounts(countResults(results))}`);
|
|
920752
|
+
lines.push("");
|
|
920753
|
+
return lines.join("\n");
|
|
920754
|
+
}
|
|
920755
|
+
function renderJsonSummary(results) {
|
|
920756
|
+
return {
|
|
920757
|
+
version: JSON_SCHEMA_VERSION,
|
|
920758
|
+
generators: results.map((r5) => ({
|
|
920759
|
+
api: r5.apiName ?? null,
|
|
920760
|
+
group: r5.groupName,
|
|
920761
|
+
generatorName: r5.generatorName,
|
|
920762
|
+
status: r5.status,
|
|
920763
|
+
pullRequestUrl: r5.pullRequestUrl,
|
|
920764
|
+
version: r5.version,
|
|
920765
|
+
error: r5.errorMessage,
|
|
920766
|
+
durationMs: r5.durationMs
|
|
920767
|
+
})),
|
|
920768
|
+
summary: countResults(results)
|
|
920769
|
+
};
|
|
920770
|
+
}
|
|
920771
|
+
function formatCounts(counts) {
|
|
920772
|
+
return `${counts.succeeded} succeeded \xB7 ${counts.skipped} skipped \xB7 ${counts.failed} failed`;
|
|
920773
|
+
}
|
|
920774
|
+
async function writeResults({
|
|
920775
|
+
results,
|
|
920776
|
+
jsonOutputPath
|
|
920777
|
+
}) {
|
|
920778
|
+
const stepSummaryPath = getGithubStepSummaryPath();
|
|
920779
|
+
if (stepSummaryPath != null) {
|
|
920780
|
+
try {
|
|
920781
|
+
await (0, import_promises137.appendFile)(stepSummaryPath, renderMarkdownSummary(results), "utf8");
|
|
920782
|
+
} catch {
|
|
920783
|
+
}
|
|
920784
|
+
}
|
|
920785
|
+
if (jsonOutputPath != null) {
|
|
920786
|
+
await (0, import_promises137.writeFile)(jsonOutputPath, JSON.stringify(renderJsonSummary(results), null, 2), "utf8");
|
|
920787
|
+
}
|
|
920788
|
+
}
|
|
920789
|
+
function writeResultsSync({
|
|
920790
|
+
results,
|
|
920791
|
+
jsonOutputPath
|
|
920792
|
+
}) {
|
|
920793
|
+
const stepSummaryPath = getGithubStepSummaryPath();
|
|
920794
|
+
if (stepSummaryPath != null) {
|
|
920795
|
+
try {
|
|
920796
|
+
(0, import_fs35.appendFileSync)(stepSummaryPath, renderMarkdownSummary(results), "utf8");
|
|
920797
|
+
} catch {
|
|
920798
|
+
}
|
|
920799
|
+
}
|
|
920800
|
+
if (jsonOutputPath != null) {
|
|
920801
|
+
try {
|
|
920802
|
+
(0, import_fs35.writeFileSync)(jsonOutputPath, JSON.stringify(renderJsonSummary(results), null, 2), "utf8");
|
|
920803
|
+
} catch {
|
|
920804
|
+
}
|
|
920805
|
+
}
|
|
920806
|
+
}
|
|
920807
|
+
function getGithubStepSummaryPath() {
|
|
920808
|
+
const path99 = process.env.GITHUB_STEP_SUMMARY;
|
|
920809
|
+
return path99 != null && path99.length > 0 ? path99 : void 0;
|
|
920810
|
+
}
|
|
920811
|
+
function mdCell(value2) {
|
|
920812
|
+
if (value2 == null || value2.length === 0) {
|
|
920813
|
+
return "\u2014";
|
|
920814
|
+
}
|
|
920815
|
+
return value2.replace(/\|/g, "\\|");
|
|
920816
|
+
}
|
|
920817
|
+
function statusCell(result) {
|
|
920818
|
+
switch (result.status) {
|
|
920819
|
+
case "success":
|
|
920820
|
+
return "\u2705 success";
|
|
920821
|
+
case "failed":
|
|
920822
|
+
return "\u274C failed";
|
|
920823
|
+
case "skipped_no_diff":
|
|
920824
|
+
return "\u23ED\uFE0F skipped (no diff)";
|
|
920825
|
+
}
|
|
920826
|
+
}
|
|
920827
|
+
function prCell(url3) {
|
|
920828
|
+
if (url3 == null) {
|
|
920829
|
+
return "\u2014";
|
|
920830
|
+
}
|
|
920831
|
+
const match3 = url3.match(/\/pull\/(\d+)/);
|
|
920832
|
+
if (match3 != null) {
|
|
920833
|
+
return `[#${match3[1]}](${url3})`;
|
|
920834
|
+
}
|
|
920835
|
+
return `[link](${url3})`;
|
|
920836
|
+
}
|
|
920837
|
+
|
|
920838
|
+
// src/commands/automations/generate/executeAutomationsGenerate.ts
|
|
920839
|
+
async function executeAutomationsGenerate({
|
|
920840
|
+
cliContext,
|
|
920841
|
+
options: options2
|
|
920842
|
+
}) {
|
|
920843
|
+
const { generatorName, generatorIndex } = parseGeneratorArg(options2.generator);
|
|
920844
|
+
const collector = new GeneratorRunCollector();
|
|
920845
|
+
const { jsonOutputPath } = options2;
|
|
920846
|
+
let outputsFlushed = false;
|
|
920847
|
+
let taskAborted = false;
|
|
920848
|
+
const flushOnSignal = () => {
|
|
920849
|
+
if (outputsFlushed) {
|
|
920850
|
+
return;
|
|
920851
|
+
}
|
|
920852
|
+
outputsFlushed = true;
|
|
920853
|
+
writeResultsSync({ results: collector.results(), jsonOutputPath });
|
|
920854
|
+
};
|
|
920855
|
+
process.once("SIGINT", flushOnSignal);
|
|
920856
|
+
process.once("SIGTERM", flushOnSignal);
|
|
920857
|
+
try {
|
|
920858
|
+
await cliContext.runTask(async () => {
|
|
920859
|
+
await generateAPIWorkspaces({
|
|
920860
|
+
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
920861
|
+
commandLineApiWorkspace: options2.api,
|
|
920862
|
+
defaultToAllApiWorkspaces: true
|
|
920863
|
+
}),
|
|
920864
|
+
cliContext,
|
|
920865
|
+
version: options2.version,
|
|
920866
|
+
groupName: options2.group,
|
|
920867
|
+
generatorName,
|
|
920868
|
+
generatorIndex,
|
|
920869
|
+
shouldLogS3Url: false,
|
|
920870
|
+
keepDocker: false,
|
|
920871
|
+
useLocalDocker: false,
|
|
920872
|
+
preview: false,
|
|
920873
|
+
mode: void 0,
|
|
920874
|
+
force: true,
|
|
920875
|
+
runner: void 0,
|
|
920876
|
+
inspect: false,
|
|
920877
|
+
lfsOverride: void 0,
|
|
920878
|
+
fernignorePath: void 0,
|
|
920879
|
+
skipFernignore: false,
|
|
920880
|
+
dynamicIrOnly: false,
|
|
920881
|
+
outputDir: void 0,
|
|
920882
|
+
noReplay: false,
|
|
920883
|
+
retryRateLimited: false,
|
|
920884
|
+
requireEnvVars: false,
|
|
920885
|
+
automationMode: true,
|
|
920886
|
+
autoMerge: options2.autoMerge,
|
|
920887
|
+
automation: { recorder: collector }
|
|
920888
|
+
});
|
|
920889
|
+
});
|
|
920890
|
+
} catch (error50) {
|
|
920891
|
+
if (!(error50 instanceof TaskAbortSignal)) {
|
|
920892
|
+
throw error50;
|
|
920893
|
+
}
|
|
920894
|
+
taskAborted = true;
|
|
920895
|
+
} finally {
|
|
920896
|
+
process.off("SIGINT", flushOnSignal);
|
|
920897
|
+
process.off("SIGTERM", flushOnSignal);
|
|
920898
|
+
if (!outputsFlushed) {
|
|
920899
|
+
outputsFlushed = true;
|
|
920900
|
+
await reportFinalOutputs({ collector, jsonOutputPath, taskAborted });
|
|
920901
|
+
}
|
|
920902
|
+
if (collector.hasFailures()) {
|
|
920903
|
+
process.exitCode = 1;
|
|
920904
|
+
}
|
|
920905
|
+
}
|
|
920906
|
+
}
|
|
920907
|
+
async function reportFinalOutputs({
|
|
920908
|
+
collector,
|
|
920909
|
+
jsonOutputPath,
|
|
920910
|
+
taskAborted
|
|
920911
|
+
}) {
|
|
920912
|
+
const results = collector.results();
|
|
920913
|
+
if (results.length === 0) {
|
|
920914
|
+
if (taskAborted) {
|
|
920915
|
+
return;
|
|
920916
|
+
}
|
|
920917
|
+
process.stdout.write(
|
|
920918
|
+
"No eligible generators ran in the selected APIs and groups \u2014 every candidate either opts out via automations.generate / autorelease, uses local-file-system output, or did not match an explicit --group / --api filter.\n"
|
|
920919
|
+
);
|
|
920920
|
+
return;
|
|
920921
|
+
}
|
|
920922
|
+
await writeResults({ results, jsonOutputPath });
|
|
920923
|
+
process.stdout.write(`${renderStdoutSummary(results)}
|
|
920924
|
+
`);
|
|
920925
|
+
}
|
|
920926
|
+
|
|
919858
920927
|
// src/commands/sdk-preview/overrideOutputForPreview.ts
|
|
919859
920928
|
var PREVIEW_REGISTRY_URL = process.env.FERN_PREVIEW_REGISTRY_URL ?? "https://npm.buildwithfern.com";
|
|
919860
920929
|
var SUPPORTED_TYPESCRIPT_GENERATORS = /* @__PURE__ */ new Set([
|
|
@@ -920401,7 +921470,7 @@ async function previewDocsWorkspace({
|
|
|
920401
921470
|
|
|
920402
921471
|
// src/commands/docs-diff/docsDiff.ts
|
|
920403
921472
|
init_lib6();
|
|
920404
|
-
var
|
|
921473
|
+
var import_promises138 = require("fs/promises");
|
|
920405
921474
|
var import_pngjs = __toESM(require_png2(), 1);
|
|
920406
921475
|
async function getSlugForFiles({
|
|
920407
921476
|
previewUrl,
|
|
@@ -920624,8 +921693,8 @@ async function generateComparisons({
|
|
|
920624
921693
|
afterPath,
|
|
920625
921694
|
comparisonBasePath
|
|
920626
921695
|
}) {
|
|
920627
|
-
const beforePng = import_pngjs.PNG.sync.read(await (0,
|
|
920628
|
-
const afterPng = import_pngjs.PNG.sync.read(await (0,
|
|
921696
|
+
const beforePng = import_pngjs.PNG.sync.read(await (0, import_promises138.readFile)(beforePath));
|
|
921697
|
+
const afterPng = import_pngjs.PNG.sync.read(await (0, import_promises138.readFile)(afterPath));
|
|
920629
921698
|
const beforeOriginalHeight = beforePng.height;
|
|
920630
921699
|
const afterOriginalHeight = afterPng.height;
|
|
920631
921700
|
const width = Math.max(beforePng.width, afterPng.width);
|
|
@@ -920663,7 +921732,7 @@ async function generateComparisons({
|
|
|
920663
921732
|
const sideBySide = createSideBySideComparison(croppedBefore, croppedAfter, 20, true);
|
|
920664
921733
|
const outPath = `${base4}-region-${i9 + 1}.png`;
|
|
920665
921734
|
const pngBuffer = import_pngjs.PNG.sync.write(sideBySide);
|
|
920666
|
-
await (0,
|
|
921735
|
+
await (0, import_promises138.writeFile)(outPath, new Uint8Array(pngBuffer));
|
|
920667
921736
|
results.push({ changePercent, boundingBox, comparisonPath: outPath });
|
|
920668
921737
|
}
|
|
920669
921738
|
return results;
|
|
@@ -920742,7 +921811,7 @@ async function docsDiff({
|
|
|
920742
921811
|
outputDir.startsWith("/") ? outputDir : join8(cwd(), RelativeFilePath2.of(outputDir))
|
|
920743
921812
|
);
|
|
920744
921813
|
if (!await doesPathExist(outputPath)) {
|
|
920745
|
-
await (0,
|
|
921814
|
+
await (0, import_promises138.mkdir)(outputPath, { recursive: true });
|
|
920746
921815
|
}
|
|
920747
921816
|
const results = [];
|
|
920748
921817
|
await cliContext.runTask(async (context3) => {
|
|
@@ -924054,8 +925123,8 @@ function renderNamespacesIndexPage(nsPath, childEntries, nsTitle) {
|
|
|
924054
925123
|
}
|
|
924055
925124
|
|
|
924056
925125
|
// ../library-docs-generator/lib/src/writers/MdxFileWriter.js
|
|
924057
|
-
var
|
|
924058
|
-
var
|
|
925126
|
+
var import_fs36 = require("fs");
|
|
925127
|
+
var import_path86 = require("path");
|
|
924059
925128
|
var MdxFileWriter = class {
|
|
924060
925129
|
outputDir;
|
|
924061
925130
|
writtenFiles = [];
|
|
@@ -924071,9 +925140,9 @@ var MdxFileWriter = class {
|
|
|
924071
925140
|
* @returns Absolute path of the written file
|
|
924072
925141
|
*/
|
|
924073
925142
|
writePage(pageKey, content5) {
|
|
924074
|
-
const filePath = (0,
|
|
924075
|
-
(0,
|
|
924076
|
-
(0,
|
|
925143
|
+
const filePath = (0, import_path86.join)(this.outputDir, pageKey);
|
|
925144
|
+
(0, import_fs36.mkdirSync)((0, import_path86.dirname)(filePath), { recursive: true });
|
|
925145
|
+
(0, import_fs36.writeFileSync)(filePath, content5);
|
|
924077
925146
|
this.writtenFiles.push(filePath);
|
|
924078
925147
|
return filePath;
|
|
924079
925148
|
}
|
|
@@ -925080,8 +926149,8 @@ function renderModulePage(module4, ctx, parentPath = "") {
|
|
|
925080
926149
|
}
|
|
925081
926150
|
|
|
925082
926151
|
// ../library-docs-generator/lib/src/writers/NavigationBuilder.js
|
|
925083
|
-
var
|
|
925084
|
-
var
|
|
926152
|
+
var import_fs37 = require("fs");
|
|
926153
|
+
var import_path87 = require("path");
|
|
925085
926154
|
function buildNavigation(rootModule, baseSlug) {
|
|
925086
926155
|
return generateModuleNav(rootModule, "", baseSlug);
|
|
925087
926156
|
}
|
|
@@ -925115,9 +926184,9 @@ var NAVIGATION_FILENAME = "_navigation.yml";
|
|
|
925115
926184
|
function writeNavigation(outputDir, navigation2) {
|
|
925116
926185
|
const header = "# AUTO-GENERATED by `fern docs md generate` \u2014 DO NOT EDIT\n";
|
|
925117
926186
|
const yaml3 = jsYaml.dump(navigation2, { lineWidth: 120, noRefs: true });
|
|
925118
|
-
const filePath = (0,
|
|
925119
|
-
(0,
|
|
925120
|
-
(0,
|
|
926187
|
+
const filePath = (0, import_path87.join)(outputDir, NAVIGATION_FILENAME);
|
|
926188
|
+
(0, import_fs37.mkdirSync)((0, import_path87.dirname)(filePath), { recursive: true });
|
|
926189
|
+
(0, import_fs37.writeFileSync)(filePath, header + yaml3);
|
|
925121
926190
|
return filePath;
|
|
925122
926191
|
}
|
|
925123
926192
|
|
|
@@ -925155,7 +926224,7 @@ function renderModuleTree(module4, ctx, writer2, parentPath) {
|
|
|
925155
926224
|
}
|
|
925156
926225
|
|
|
925157
926226
|
// src/commands/docs-md-generate/generateLibraryDocs.ts
|
|
925158
|
-
var
|
|
926227
|
+
var import_promises139 = require("fs/promises");
|
|
925159
926228
|
function createLibraryDocsClient2({ token }) {
|
|
925160
926229
|
const defaultOrigin = "https://registry-dev2.buildwithfern.com";
|
|
925161
926230
|
const baseUrl = process.env.FERN_FDR_ORIGIN ?? process.env.OVERRIDE_FDR_ORIGIN ?? defaultOrigin;
|
|
@@ -925281,7 +926350,7 @@ async function generateSingleLibrary({
|
|
|
925281
926350
|
if (config5.lang === "cpp" && config5.config?.doxyfile != null) {
|
|
925282
926351
|
const doxyfilePath = resolve6(docsWorkspace.absoluteFilePath, config5.config.doxyfile);
|
|
925283
926352
|
try {
|
|
925284
|
-
doxyfileContent = await (0,
|
|
926353
|
+
doxyfileContent = await (0, import_promises139.readFile)(doxyfilePath, "utf-8");
|
|
925285
926354
|
} catch {
|
|
925286
926355
|
return interactiveTaskContext.failAndThrow(
|
|
925287
926356
|
`Library '${name2}': Could not read Doxyfile at '${config5.config.doxyfile}' (resolved to ${doxyfilePath})`,
|
|
@@ -925627,7 +926696,7 @@ Found ${previewDeployments.length} preview deployment(s):
|
|
|
925627
926696
|
}
|
|
925628
926697
|
|
|
925629
926698
|
// src/commands/downgrade/downgrade.ts
|
|
925630
|
-
var
|
|
926699
|
+
var import_promises140 = require("fs/promises");
|
|
925631
926700
|
|
|
925632
926701
|
// ../../../node_modules/.pnpm/immer@10.2.0/node_modules/immer/dist/immer.mjs
|
|
925633
926702
|
var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
|
|
@@ -926378,13 +927447,13 @@ async function downgrade({
|
|
|
926378
927447
|
const newProjectConfig = produce(projectConfig.rawConfig, (draft) => {
|
|
926379
927448
|
draft.version = targetVersion;
|
|
926380
927449
|
});
|
|
926381
|
-
await (0,
|
|
927450
|
+
await (0, import_promises140.writeFile)(projectConfig._absolutePath, ensureFinalNewline(JSON.stringify(newProjectConfig, void 0, 2)));
|
|
926382
927451
|
cliContext.logger.info(`Updated ${PROJECT_CONFIG_FILENAME} to version ${targetVersion}`);
|
|
926383
927452
|
}
|
|
926384
927453
|
|
|
926385
927454
|
// src/commands/export/generateOpenAPIForWorkspaces.ts
|
|
926386
927455
|
init_lib6();
|
|
926387
|
-
var
|
|
927456
|
+
var import_promises141 = require("fs/promises");
|
|
926388
927457
|
|
|
926389
927458
|
// src/commands/export/converters/servicesConverter.ts
|
|
926390
927459
|
init_lib4();
|
|
@@ -927767,8 +928836,8 @@ async function generateOpenAPIForWorkspaces({
|
|
|
927767
928836
|
ir: ir10,
|
|
927768
928837
|
mode: "openapi"
|
|
927769
928838
|
});
|
|
927770
|
-
await (0,
|
|
927771
|
-
await (0,
|
|
928839
|
+
await (0, import_promises141.mkdir)(dirname6(outputPath), { recursive: true });
|
|
928840
|
+
await (0, import_promises141.writeFile)(
|
|
927772
928841
|
outputPath,
|
|
927773
928842
|
outputPath.endsWith(".json") ? JSON.stringify(openapi, void 0, indent4) : jsYaml.dump(openapi, { indent: indent4 })
|
|
927774
928843
|
);
|
|
@@ -927799,517 +928868,6 @@ async function formatWorkspaces({
|
|
|
927799
928868
|
);
|
|
927800
928869
|
}
|
|
927801
928870
|
|
|
927802
|
-
// src/commands/generate/filterGenerators.ts
|
|
927803
|
-
function parseGeneratorArg(generatorArg) {
|
|
927804
|
-
if (generatorArg == null) {
|
|
927805
|
-
return { generatorName: void 0, generatorIndex: void 0 };
|
|
927806
|
-
}
|
|
927807
|
-
const parsed = generatorArg.length > 0 ? Number(generatorArg) : Number.NaN;
|
|
927808
|
-
if (!Number.isNaN(parsed) && Number.isInteger(parsed) && parsed >= 0) {
|
|
927809
|
-
return { generatorName: void 0, generatorIndex: parsed };
|
|
927810
|
-
}
|
|
927811
|
-
return { generatorName: generatorArg, generatorIndex: void 0 };
|
|
927812
|
-
}
|
|
927813
|
-
function filterGenerators({
|
|
927814
|
-
generators,
|
|
927815
|
-
generatorIndex,
|
|
927816
|
-
generatorName,
|
|
927817
|
-
groupName
|
|
927818
|
-
}) {
|
|
927819
|
-
if (generatorIndex != null) {
|
|
927820
|
-
const generator = generators[generatorIndex];
|
|
927821
|
-
if (generator == null) {
|
|
927822
|
-
return {
|
|
927823
|
-
ok: false,
|
|
927824
|
-
error: `Generator index ${generatorIndex} is out of bounds in group '${groupName}' (${generators.length} generators available)`
|
|
927825
|
-
};
|
|
927826
|
-
}
|
|
927827
|
-
return { ok: true, generators: [generator] };
|
|
927828
|
-
}
|
|
927829
|
-
if (generatorName != null) {
|
|
927830
|
-
const filtered = generators.filter((gen) => gen.name === generatorName);
|
|
927831
|
-
if (filtered.length === 0) {
|
|
927832
|
-
const available = generators.map((gen) => gen.name);
|
|
927833
|
-
return {
|
|
927834
|
-
ok: false,
|
|
927835
|
-
error: `Generator '${generatorName}' not found in group '${groupName}'. Available generators: ${available.join(", ")}`
|
|
927836
|
-
};
|
|
927837
|
-
}
|
|
927838
|
-
return { ok: true, generators: filtered };
|
|
927839
|
-
}
|
|
927840
|
-
return { ok: true, generators };
|
|
927841
|
-
}
|
|
927842
|
-
|
|
927843
|
-
// src/commands/generate/generateAPIWorkspaces.ts
|
|
927844
|
-
init_lib6();
|
|
927845
|
-
|
|
927846
|
-
// src/constants.ts
|
|
927847
|
-
var API_CLI_OPTION = "api";
|
|
927848
|
-
var GROUP_CLI_OPTION = "group";
|
|
927849
|
-
var PREVIEW_DIRECTORY = ".preview";
|
|
927850
|
-
var APPROVED_DIRECTORIES_FILENAME = "approved-output-directories";
|
|
927851
|
-
var LOCAL_STORAGE_FOLDER6 = ".fern-dev";
|
|
927852
|
-
|
|
927853
|
-
// src/commands/generate/checkOutputDirectory.ts
|
|
927854
|
-
init_lib6();
|
|
927855
|
-
var import_promises140 = require("fs/promises");
|
|
927856
|
-
|
|
927857
|
-
// src/persistence/output-directories/getOutputDirectories.ts
|
|
927858
|
-
init_lib6();
|
|
927859
|
-
var import_promises138 = require("fs/promises");
|
|
927860
|
-
|
|
927861
|
-
// src/persistence/output-directories/getPathToOutputDirectoriesFile.ts
|
|
927862
|
-
init_lib6();
|
|
927863
|
-
var import_os16 = require("os");
|
|
927864
|
-
function getPathToOutputDirectoriesFile() {
|
|
927865
|
-
return join8(
|
|
927866
|
-
AbsoluteFilePath2.of((0, import_os16.homedir)()),
|
|
927867
|
-
RelativeFilePath2.of(LOCAL_STORAGE_FOLDER6),
|
|
927868
|
-
RelativeFilePath2.of(APPROVED_DIRECTORIES_FILENAME)
|
|
927869
|
-
);
|
|
927870
|
-
}
|
|
927871
|
-
|
|
927872
|
-
// src/persistence/output-directories/getOutputDirectories.ts
|
|
927873
|
-
async function getOutputDirectories() {
|
|
927874
|
-
const pathToOutputDirectoriesFile = getPathToOutputDirectoriesFile();
|
|
927875
|
-
const doesOutputDirectoriesFileExist = await doesPathExist(pathToOutputDirectoriesFile);
|
|
927876
|
-
if (!doesOutputDirectoriesFileExist) {
|
|
927877
|
-
return [];
|
|
927878
|
-
}
|
|
927879
|
-
const outputDirectoriesFileContents = await (0, import_promises138.readFile)(pathToOutputDirectoriesFile, { encoding: "utf-8" });
|
|
927880
|
-
const outputDirectories = JSON.parse(outputDirectoriesFileContents);
|
|
927881
|
-
return outputDirectories;
|
|
927882
|
-
}
|
|
927883
|
-
|
|
927884
|
-
// src/persistence/output-directories/storeOutputDirectories.ts
|
|
927885
|
-
var import_promises139 = require("fs/promises");
|
|
927886
|
-
var import_path87 = __toESM(require("path"), 1);
|
|
927887
|
-
async function storeOutputDirectories(outputDirectories) {
|
|
927888
|
-
await (0, import_promises139.mkdir)(import_path87.default.dirname(getPathToOutputDirectoriesFile()), { recursive: true });
|
|
927889
|
-
await (0, import_promises139.writeFile)(getPathToOutputDirectoriesFile(), JSON.stringify(outputDirectories, null, 2));
|
|
927890
|
-
}
|
|
927891
|
-
|
|
927892
|
-
// src/commands/generate/checkOutputDirectory.ts
|
|
927893
|
-
async function checkOutputDirectory(outputPath, cliContext, force) {
|
|
927894
|
-
if (!outputPath || isCI() || force) {
|
|
927895
|
-
return {
|
|
927896
|
-
shouldProceed: true
|
|
927897
|
-
};
|
|
927898
|
-
}
|
|
927899
|
-
const savedDirectories = await getOutputDirectories();
|
|
927900
|
-
if (savedDirectories?.includes(outputPath)) {
|
|
927901
|
-
return {
|
|
927902
|
-
shouldProceed: true
|
|
927903
|
-
};
|
|
927904
|
-
}
|
|
927905
|
-
const doesExist = await doesPathExist(outputPath);
|
|
927906
|
-
if (!doesExist) {
|
|
927907
|
-
return {
|
|
927908
|
-
shouldProceed: true
|
|
927909
|
-
};
|
|
927910
|
-
}
|
|
927911
|
-
const files = await (0, import_promises140.readdir)(outputPath);
|
|
927912
|
-
if (files.length === 0) {
|
|
927913
|
-
return {
|
|
927914
|
-
shouldProceed: true
|
|
927915
|
-
};
|
|
927916
|
-
}
|
|
927917
|
-
const shouldOverwrite = await cliContext.confirmPrompt(
|
|
927918
|
-
`Directory ${outputPath} contains existing files that may be overwritten. Continue?`,
|
|
927919
|
-
false
|
|
927920
|
-
);
|
|
927921
|
-
if (!shouldOverwrite) {
|
|
927922
|
-
return {
|
|
927923
|
-
shouldProceed: false
|
|
927924
|
-
};
|
|
927925
|
-
}
|
|
927926
|
-
await storeOutputDirectories([...savedDirectories ?? [], outputPath]);
|
|
927927
|
-
return {
|
|
927928
|
-
shouldProceed: true
|
|
927929
|
-
};
|
|
927930
|
-
}
|
|
927931
|
-
|
|
927932
|
-
// src/commands/generate/generateAPIWorkspace.ts
|
|
927933
|
-
init_lib6();
|
|
927934
|
-
async function generateWorkspace({
|
|
927935
|
-
organization,
|
|
927936
|
-
workspace,
|
|
927937
|
-
projectConfig,
|
|
927938
|
-
context: context3,
|
|
927939
|
-
groupName,
|
|
927940
|
-
generatorName,
|
|
927941
|
-
generatorIndex,
|
|
927942
|
-
version: version7,
|
|
927943
|
-
shouldLogS3Url,
|
|
927944
|
-
token,
|
|
927945
|
-
useLocalDocker,
|
|
927946
|
-
keepDocker,
|
|
927947
|
-
absolutePathToPreview,
|
|
927948
|
-
mode,
|
|
927949
|
-
runner,
|
|
927950
|
-
inspect: inspect6,
|
|
927951
|
-
lfsOverride,
|
|
927952
|
-
fernignorePath,
|
|
927953
|
-
skipFernignore,
|
|
927954
|
-
dynamicIrOnly,
|
|
927955
|
-
noReplay,
|
|
927956
|
-
retryRateLimited,
|
|
927957
|
-
requireEnvVars,
|
|
927958
|
-
automationMode,
|
|
927959
|
-
autoMerge
|
|
927960
|
-
}) {
|
|
927961
|
-
if (workspace.generatorsConfiguration == null) {
|
|
927962
|
-
context3.logger.warn("This workspaces has no generators.yml");
|
|
927963
|
-
return;
|
|
927964
|
-
}
|
|
927965
|
-
if (workspace.generatorsConfiguration.groups.length === 0) {
|
|
927966
|
-
context3.logger.warn(`This workspace has no groups specified in ${GENERATORS_CONFIGURATION_FILENAME}`);
|
|
927967
|
-
return;
|
|
927968
|
-
}
|
|
927969
|
-
const groupNameOrDefault = groupName ?? workspace.generatorsConfiguration.defaultGroup;
|
|
927970
|
-
if (groupName == null && groupNameOrDefault != null) {
|
|
927971
|
-
context3.logger.info(
|
|
927972
|
-
source_default.dim(`Using default group '${groupNameOrDefault}' from ${GENERATORS_CONFIGURATION_FILENAME}`)
|
|
927973
|
-
);
|
|
927974
|
-
}
|
|
927975
|
-
if (groupNameOrDefault == null) {
|
|
927976
|
-
const groupNames = workspace.generatorsConfiguration.groups.map((g8) => g8.groupName);
|
|
927977
|
-
const longestGroupName = Math.max(...groupNames.map((name2) => name2.length));
|
|
927978
|
-
const currentArgs = process.argv.slice(2).join(" ");
|
|
927979
|
-
const message = `No group specified. Use the --${GROUP_CLI_OPTION} option, or set "${DEFAULT_GROUP_GENERATORS_CONFIG_KEY}" in ${GENERATORS_CONFIGURATION_FILENAME}:
|
|
927980
|
-
` + groupNames.map((name2) => {
|
|
927981
|
-
const suggestedCommand = `fern ${currentArgs} --${GROUP_CLI_OPTION} ${name2}`;
|
|
927982
|
-
return ` \u203A ${source_default.bold(name2.padEnd(longestGroupName))} ${source_default.dim(suggestedCommand)}`;
|
|
927983
|
-
}).join("\n");
|
|
927984
|
-
return context3.failAndThrow(message, void 0, { code: CliError.Code.NetworkError });
|
|
927985
|
-
}
|
|
927986
|
-
const resolvedGroupNames = resolveGroupAlias(
|
|
927987
|
-
groupNameOrDefault,
|
|
927988
|
-
workspace.generatorsConfiguration.groupAliases,
|
|
927989
|
-
workspace.generatorsConfiguration.groups.map((g8) => g8.groupName),
|
|
927990
|
-
context3
|
|
927991
|
-
);
|
|
927992
|
-
const { ai: ai10, replay } = workspace.generatorsConfiguration;
|
|
927993
|
-
if (!useLocalDocker && !token) {
|
|
927994
|
-
return context3.failAndThrow("Please run fern login", void 0, { code: CliError.Code.AuthError });
|
|
927995
|
-
}
|
|
927996
|
-
await Promise.all(
|
|
927997
|
-
resolvedGroupNames.map(async (resolvedGroupName) => {
|
|
927998
|
-
let group = workspace.generatorsConfiguration?.groups.find(
|
|
927999
|
-
(otherGroup) => otherGroup.groupName === resolvedGroupName
|
|
928000
|
-
);
|
|
928001
|
-
if (group == null) {
|
|
928002
|
-
return context3.failAndThrow(`Group '${resolvedGroupName}' does not exist.`, void 0, {
|
|
928003
|
-
code: CliError.Code.ConfigError
|
|
928004
|
-
});
|
|
928005
|
-
}
|
|
928006
|
-
const filterResult = filterGenerators({
|
|
928007
|
-
generators: group.generators,
|
|
928008
|
-
generatorIndex,
|
|
928009
|
-
generatorName,
|
|
928010
|
-
groupName: resolvedGroupName
|
|
928011
|
-
});
|
|
928012
|
-
if (!filterResult.ok) {
|
|
928013
|
-
return context3.failAndThrow(filterResult.error, void 0, { code: CliError.Code.ConfigError });
|
|
928014
|
-
}
|
|
928015
|
-
group = { ...group, generators: filterResult.generators };
|
|
928016
|
-
if (lfsOverride != null) {
|
|
928017
|
-
group = applyLfsOverride(group, lfsOverride, context3);
|
|
928018
|
-
}
|
|
928019
|
-
if (resolvedGroupNames.length > 1) {
|
|
928020
|
-
context3.logger.info(`Running generation for group '${resolvedGroupName}'...`);
|
|
928021
|
-
}
|
|
928022
|
-
if (useLocalDocker) {
|
|
928023
|
-
await runLocalGenerationForWorkspace({
|
|
928024
|
-
token,
|
|
928025
|
-
projectConfig,
|
|
928026
|
-
workspace,
|
|
928027
|
-
generatorGroup: group,
|
|
928028
|
-
version: version7,
|
|
928029
|
-
keepDocker,
|
|
928030
|
-
context: context3,
|
|
928031
|
-
runner,
|
|
928032
|
-
absolutePathToPreview,
|
|
928033
|
-
inspect: inspect6,
|
|
928034
|
-
ai: ai10,
|
|
928035
|
-
replay,
|
|
928036
|
-
noReplay,
|
|
928037
|
-
validateWorkspace: true,
|
|
928038
|
-
requireEnvVars,
|
|
928039
|
-
skipFernignore,
|
|
928040
|
-
automationMode,
|
|
928041
|
-
autoMerge
|
|
928042
|
-
});
|
|
928043
|
-
} else if (token != null) {
|
|
928044
|
-
const customImageGenerators = group.generators.filter((g8) => g8.containerImage != null);
|
|
928045
|
-
if (customImageGenerators.length > 0) {
|
|
928046
|
-
const names2 = customImageGenerators.map((g8) => g8.name).join(", ");
|
|
928047
|
-
return context3.failAndThrow(
|
|
928048
|
-
`Custom image configurations are only supported with local generation (--local). The following generators use custom images: ${names2}`
|
|
928049
|
-
);
|
|
928050
|
-
}
|
|
928051
|
-
await runRemoteGenerationForAPIWorkspace({
|
|
928052
|
-
projectConfig,
|
|
928053
|
-
organization,
|
|
928054
|
-
workspace,
|
|
928055
|
-
context: context3,
|
|
928056
|
-
generatorGroup: group,
|
|
928057
|
-
version: version7,
|
|
928058
|
-
shouldLogS3Url,
|
|
928059
|
-
token,
|
|
928060
|
-
whitelabel: workspace.generatorsConfiguration?.whitelabel,
|
|
928061
|
-
absolutePathToPreview,
|
|
928062
|
-
mode,
|
|
928063
|
-
fernignorePath,
|
|
928064
|
-
skipFernignore,
|
|
928065
|
-
dynamicIrOnly,
|
|
928066
|
-
validateWorkspace: true,
|
|
928067
|
-
retryRateLimited,
|
|
928068
|
-
requireEnvVars,
|
|
928069
|
-
automationMode,
|
|
928070
|
-
autoMerge
|
|
928071
|
-
});
|
|
928072
|
-
}
|
|
928073
|
-
})
|
|
928074
|
-
);
|
|
928075
|
-
}
|
|
928076
|
-
function resolveGroupAlias(groupNameOrAlias, groupAliases, availableGroups, context3) {
|
|
928077
|
-
const aliasGroups = groupAliases[groupNameOrAlias];
|
|
928078
|
-
if (aliasGroups != null) {
|
|
928079
|
-
for (const groupName of aliasGroups) {
|
|
928080
|
-
if (!availableGroups.includes(groupName)) {
|
|
928081
|
-
context3.failAndThrow(
|
|
928082
|
-
`Group alias '${groupNameOrAlias}' references non-existent group '${groupName}'. Available groups: ${availableGroups.join(", ")}`,
|
|
928083
|
-
void 0,
|
|
928084
|
-
{ code: CliError.Code.NetworkError }
|
|
928085
|
-
);
|
|
928086
|
-
}
|
|
928087
|
-
}
|
|
928088
|
-
return aliasGroups;
|
|
928089
|
-
}
|
|
928090
|
-
if (availableGroups.includes(groupNameOrAlias)) {
|
|
928091
|
-
return [groupNameOrAlias];
|
|
928092
|
-
}
|
|
928093
|
-
const availableAliases = Object.keys(groupAliases);
|
|
928094
|
-
const suggestions = [...availableGroups, ...availableAliases];
|
|
928095
|
-
context3.failAndThrow(
|
|
928096
|
-
`'${groupNameOrAlias}' is not a valid group or alias. Available groups: ${availableGroups.join(", ")}` + (availableAliases.length > 0 ? `. Available aliases: ${availableAliases.join(", ")}` : ""),
|
|
928097
|
-
void 0,
|
|
928098
|
-
{ code: CliError.Code.NetworkError }
|
|
928099
|
-
);
|
|
928100
|
-
return [];
|
|
928101
|
-
}
|
|
928102
|
-
function applyLfsOverride(group, lfsOverridePath, context3) {
|
|
928103
|
-
const baseAbsolutePath = AbsoluteFilePath2.of(resolve6(cwd(), lfsOverridePath));
|
|
928104
|
-
const languageCount = {};
|
|
928105
|
-
const modifiedGenerators = [];
|
|
928106
|
-
for (const generator of group.generators) {
|
|
928107
|
-
const language = generator.language ?? getLanguageFromGeneratorName3(generator.name);
|
|
928108
|
-
let outputPath;
|
|
928109
|
-
if (group.generators.length === 1) {
|
|
928110
|
-
outputPath = baseAbsolutePath;
|
|
928111
|
-
} else {
|
|
928112
|
-
const languageDir = language || "unknown";
|
|
928113
|
-
if (languageCount[languageDir] == null) {
|
|
928114
|
-
languageCount[languageDir] = 0;
|
|
928115
|
-
}
|
|
928116
|
-
languageCount[languageDir]++;
|
|
928117
|
-
const dirName = languageCount[languageDir] === 1 ? languageDir : `${languageDir}-${languageCount[languageDir]}`;
|
|
928118
|
-
outputPath = join8(baseAbsolutePath, RelativeFilePath2.of(dirName));
|
|
928119
|
-
}
|
|
928120
|
-
const modifiedGenerator = {
|
|
928121
|
-
...generator,
|
|
928122
|
-
outputMode: api_exports4.remoteGen.OutputMode.downloadFiles({}),
|
|
928123
|
-
absolutePathToLocalOutput: outputPath
|
|
928124
|
-
};
|
|
928125
|
-
modifiedGenerators.push(modifiedGenerator);
|
|
928126
|
-
context3.logger.info(
|
|
928127
|
-
`Overriding output for generator '${generator.name}' to local-file-system at: ${outputPath}`
|
|
928128
|
-
);
|
|
928129
|
-
}
|
|
928130
|
-
return {
|
|
928131
|
-
...group,
|
|
928132
|
-
generators: modifiedGenerators
|
|
928133
|
-
};
|
|
928134
|
-
}
|
|
928135
|
-
function getLanguageFromGeneratorName3(generatorName) {
|
|
928136
|
-
if (generatorName.includes("typescript") || generatorName.includes("ts")) {
|
|
928137
|
-
return "typescript";
|
|
928138
|
-
}
|
|
928139
|
-
if (generatorName.includes("python") || generatorName.includes("py")) {
|
|
928140
|
-
return "python";
|
|
928141
|
-
}
|
|
928142
|
-
if (generatorName.includes("java")) {
|
|
928143
|
-
return "java";
|
|
928144
|
-
}
|
|
928145
|
-
if (generatorName.includes("go")) {
|
|
928146
|
-
return "go";
|
|
928147
|
-
}
|
|
928148
|
-
if (generatorName.includes("ruby")) {
|
|
928149
|
-
return "ruby";
|
|
928150
|
-
}
|
|
928151
|
-
if (generatorName.includes("csharp") || generatorName.includes("c#")) {
|
|
928152
|
-
return "csharp";
|
|
928153
|
-
}
|
|
928154
|
-
if (generatorName.includes("swift")) {
|
|
928155
|
-
return "swift";
|
|
928156
|
-
}
|
|
928157
|
-
if (generatorName.includes("php")) {
|
|
928158
|
-
return "php";
|
|
928159
|
-
}
|
|
928160
|
-
if (generatorName.includes("rust")) {
|
|
928161
|
-
return "rust";
|
|
928162
|
-
}
|
|
928163
|
-
return generatorName.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
928164
|
-
}
|
|
928165
|
-
|
|
928166
|
-
// src/commands/generate/generateAPIWorkspaces.ts
|
|
928167
|
-
var GenerationMode = {
|
|
928168
|
-
PullRequest: "pull-request"
|
|
928169
|
-
};
|
|
928170
|
-
async function generateAPIWorkspaces({
|
|
928171
|
-
project,
|
|
928172
|
-
cliContext,
|
|
928173
|
-
version: version7,
|
|
928174
|
-
groupName,
|
|
928175
|
-
generatorName,
|
|
928176
|
-
generatorIndex,
|
|
928177
|
-
shouldLogS3Url,
|
|
928178
|
-
keepDocker,
|
|
928179
|
-
useLocalDocker,
|
|
928180
|
-
preview,
|
|
928181
|
-
mode,
|
|
928182
|
-
force,
|
|
928183
|
-
runner,
|
|
928184
|
-
inspect: inspect6,
|
|
928185
|
-
lfsOverride,
|
|
928186
|
-
fernignorePath,
|
|
928187
|
-
skipFernignore,
|
|
928188
|
-
dynamicIrOnly,
|
|
928189
|
-
outputDir,
|
|
928190
|
-
noReplay,
|
|
928191
|
-
retryRateLimited,
|
|
928192
|
-
requireEnvVars,
|
|
928193
|
-
automationMode,
|
|
928194
|
-
autoMerge
|
|
928195
|
-
}) {
|
|
928196
|
-
let token = void 0;
|
|
928197
|
-
if (!useLocalDocker) {
|
|
928198
|
-
const currentToken = await cliContext.runTask(async (context3) => {
|
|
928199
|
-
return askToLogin(context3);
|
|
928200
|
-
});
|
|
928201
|
-
if (currentToken.type === "user") {
|
|
928202
|
-
await cliContext.runTask(async (context3) => {
|
|
928203
|
-
await createOrganizationIfDoesNotExist({
|
|
928204
|
-
organization: project.config.organization,
|
|
928205
|
-
token: currentToken,
|
|
928206
|
-
context: context3
|
|
928207
|
-
});
|
|
928208
|
-
});
|
|
928209
|
-
}
|
|
928210
|
-
token = currentToken;
|
|
928211
|
-
}
|
|
928212
|
-
for (const workspace of project.apiWorkspaces) {
|
|
928213
|
-
const resolvedGroupNames = resolveGroupNamesForWorkspace(groupName, workspace.generatorsConfiguration);
|
|
928214
|
-
for (const group of workspace.generatorsConfiguration?.groups.filter(
|
|
928215
|
-
(group2) => resolvedGroupNames == null || resolvedGroupNames.includes(group2.groupName)
|
|
928216
|
-
) ?? []) {
|
|
928217
|
-
const filterResult = filterGenerators({
|
|
928218
|
-
generators: group.generators,
|
|
928219
|
-
generatorIndex,
|
|
928220
|
-
generatorName,
|
|
928221
|
-
groupName: group.groupName
|
|
928222
|
-
});
|
|
928223
|
-
if (!filterResult.ok) {
|
|
928224
|
-
continue;
|
|
928225
|
-
}
|
|
928226
|
-
for (const generator of filterResult.generators) {
|
|
928227
|
-
const { shouldProceed } = await checkOutputDirectory(
|
|
928228
|
-
generator.absolutePathToLocalOutput,
|
|
928229
|
-
cliContext,
|
|
928230
|
-
force
|
|
928231
|
-
);
|
|
928232
|
-
if (!shouldProceed) {
|
|
928233
|
-
cliContext.failAndThrow("Generation cancelled", void 0, { code: CliError.Code.ConfigError });
|
|
928234
|
-
}
|
|
928235
|
-
}
|
|
928236
|
-
}
|
|
928237
|
-
}
|
|
928238
|
-
cliContext.instrumentPostHogEvent({
|
|
928239
|
-
orgId: project.config.organization,
|
|
928240
|
-
command: "fern generate",
|
|
928241
|
-
properties: {
|
|
928242
|
-
workspaces: project.apiWorkspaces.map((workspace) => {
|
|
928243
|
-
const resolvedGroupNames = resolveGroupNamesForWorkspace(groupName, workspace.generatorsConfiguration);
|
|
928244
|
-
return {
|
|
928245
|
-
name: workspace.workspaceName,
|
|
928246
|
-
group: groupName,
|
|
928247
|
-
generators: workspace.generatorsConfiguration?.groups.filter((group) => resolvedGroupNames == null || resolvedGroupNames.includes(group.groupName)).map((group) => {
|
|
928248
|
-
return group.generators.filter((generator) => generatorName == null || generator.name === generatorName).map((generator) => {
|
|
928249
|
-
return {
|
|
928250
|
-
name: generator.name,
|
|
928251
|
-
version: generator.version,
|
|
928252
|
-
outputMode: generator.outputMode.type,
|
|
928253
|
-
config: generator.config
|
|
928254
|
-
};
|
|
928255
|
-
});
|
|
928256
|
-
})
|
|
928257
|
-
};
|
|
928258
|
-
})
|
|
928259
|
-
}
|
|
928260
|
-
});
|
|
928261
|
-
await Promise.all(
|
|
928262
|
-
project.apiWorkspaces.map(async (workspace) => {
|
|
928263
|
-
await cliContext.runTaskForWorkspace(workspace, async (context3) => {
|
|
928264
|
-
const absolutePathToPreview = preview ? outputDir != null ? AbsoluteFilePath2.of(resolve6(cwd(), outputDir)) : join8(workspace.absoluteFilePath, RelativeFilePath2.of(PREVIEW_DIRECTORY)) : void 0;
|
|
928265
|
-
if (absolutePathToPreview != null) {
|
|
928266
|
-
context3.logger.info(`Writing preview to ${absolutePathToPreview}`);
|
|
928267
|
-
}
|
|
928268
|
-
await generateWorkspace({
|
|
928269
|
-
organization: project.config.organization,
|
|
928270
|
-
workspace,
|
|
928271
|
-
projectConfig: project.config,
|
|
928272
|
-
context: context3,
|
|
928273
|
-
version: version7,
|
|
928274
|
-
groupName,
|
|
928275
|
-
generatorName,
|
|
928276
|
-
generatorIndex,
|
|
928277
|
-
shouldLogS3Url,
|
|
928278
|
-
token,
|
|
928279
|
-
useLocalDocker,
|
|
928280
|
-
keepDocker,
|
|
928281
|
-
absolutePathToPreview,
|
|
928282
|
-
mode,
|
|
928283
|
-
runner,
|
|
928284
|
-
inspect: inspect6,
|
|
928285
|
-
lfsOverride,
|
|
928286
|
-
fernignorePath,
|
|
928287
|
-
skipFernignore,
|
|
928288
|
-
dynamicIrOnly,
|
|
928289
|
-
noReplay,
|
|
928290
|
-
retryRateLimited,
|
|
928291
|
-
requireEnvVars,
|
|
928292
|
-
automationMode,
|
|
928293
|
-
autoMerge
|
|
928294
|
-
});
|
|
928295
|
-
});
|
|
928296
|
-
})
|
|
928297
|
-
);
|
|
928298
|
-
}
|
|
928299
|
-
function resolveGroupNamesForWorkspace(groupName, generatorsConfiguration) {
|
|
928300
|
-
if (groupName == null) {
|
|
928301
|
-
return null;
|
|
928302
|
-
}
|
|
928303
|
-
if (generatorsConfiguration == null) {
|
|
928304
|
-
return [groupName];
|
|
928305
|
-
}
|
|
928306
|
-
const aliasGroups = generatorsConfiguration.groupAliases[groupName];
|
|
928307
|
-
if (aliasGroups != null) {
|
|
928308
|
-
return aliasGroups;
|
|
928309
|
-
}
|
|
928310
|
-
return [groupName];
|
|
928311
|
-
}
|
|
928312
|
-
|
|
928313
928871
|
// src/commands/generate/generateDocsWorkspace.ts
|
|
928314
928872
|
init_js();
|
|
928315
928873
|
|
|
@@ -928830,7 +929388,7 @@ async function generateOpenAPIIrForWorkspaces({
|
|
|
928830
929388
|
|
|
928831
929389
|
// src/commands/generate-overrides/compareOpenAPISpecs.ts
|
|
928832
929390
|
init_lib6();
|
|
928833
|
-
var
|
|
929391
|
+
var import_promises142 = require("fs/promises");
|
|
928834
929392
|
async function compareOpenAPISpecs({
|
|
928835
929393
|
originalPath,
|
|
928836
929394
|
modifiedPath,
|
|
@@ -928871,12 +929429,12 @@ async function compareOpenAPISpecs({
|
|
|
928871
929429
|
}
|
|
928872
929430
|
outputPath = join8(dirname6(originalPath), RelativeFilePath2.of(overridesFilename));
|
|
928873
929431
|
}
|
|
928874
|
-
await (0,
|
|
929432
|
+
await (0, import_promises142.writeFile)(outputPath, jsYaml.dump(overrides, { lineWidth: -1, noRefs: true }));
|
|
928875
929433
|
context3.logger.info(`Overrides written to ${outputPath}`);
|
|
928876
929434
|
});
|
|
928877
929435
|
}
|
|
928878
929436
|
async function loadSpec2(filepath, context3) {
|
|
928879
|
-
const contents = await (0,
|
|
929437
|
+
const contents = await (0, import_promises142.readFile)(filepath, "utf8");
|
|
928880
929438
|
try {
|
|
928881
929439
|
return JSON.parse(contents);
|
|
928882
929440
|
} catch {
|
|
@@ -928980,7 +929538,7 @@ function deepEqual(a4, b7) {
|
|
|
928980
929538
|
|
|
928981
929539
|
// src/commands/generate-overrides/writeOverridesForWorkspaces.ts
|
|
928982
929540
|
init_lib6();
|
|
928983
|
-
var
|
|
929541
|
+
var import_promises143 = require("fs/promises");
|
|
928984
929542
|
async function writeOverridesForWorkspaces({
|
|
928985
929543
|
project,
|
|
928986
929544
|
includeModels,
|
|
@@ -929005,7 +929563,7 @@ async function writeOverridesForWorkspaces({
|
|
|
929005
929563
|
async function readExistingOverrides(overridesFilepath, context3) {
|
|
929006
929564
|
let parsedOverrides = null;
|
|
929007
929565
|
try {
|
|
929008
|
-
const contents = (await (0,
|
|
929566
|
+
const contents = (await (0, import_promises143.readFile)(overridesFilepath, "utf8")).toString();
|
|
929009
929567
|
try {
|
|
929010
929568
|
parsedOverrides = JSON.parse(contents);
|
|
929011
929569
|
} catch (err) {
|
|
@@ -929070,7 +929628,7 @@ async function writeDefinitionForOpenAPIWorkspace({
|
|
|
929070
929628
|
for (const overridesPath of overridesPaths) {
|
|
929071
929629
|
const existingOverrides = await readExistingOverrides(overridesPath, context3);
|
|
929072
929630
|
const content5 = generateOverridesContent({ ir: ir10, existingOverrides, includeModels, context: context3 });
|
|
929073
|
-
await (0,
|
|
929631
|
+
await (0, import_promises143.writeFile)(overridesPath, jsYaml.dump(content5));
|
|
929074
929632
|
}
|
|
929075
929633
|
} else {
|
|
929076
929634
|
const content5 = generateOverridesContent({ ir: ir10, existingOverrides: {}, includeModels, context: context3 });
|
|
@@ -929084,7 +929642,7 @@ async function writeDefinitionForOpenAPIWorkspace({
|
|
|
929084
929642
|
overridesFilename = `${nameWithoutExt}-overrides${extension4}`;
|
|
929085
929643
|
}
|
|
929086
929644
|
}
|
|
929087
|
-
await (0,
|
|
929645
|
+
await (0, import_promises143.writeFile)(
|
|
929088
929646
|
join8(dirname6(spec.absoluteFilepath), RelativeFilePath2.of(overridesFilename)),
|
|
929089
929647
|
jsYaml.dump(content5)
|
|
929090
929648
|
);
|
|
@@ -929500,7 +930058,7 @@ function convertIRtoJsonSchema(args) {
|
|
|
929500
930058
|
}
|
|
929501
930059
|
|
|
929502
930060
|
// src/commands/jsonschema/generateJsonschemaForWorkspace.ts
|
|
929503
|
-
var
|
|
930061
|
+
var import_promises144 = require("fs/promises");
|
|
929504
930062
|
async function generateJsonschemaForWorkspaces({
|
|
929505
930063
|
typeLocator,
|
|
929506
930064
|
project,
|
|
@@ -929548,9 +930106,9 @@ async function generateJsonschemaForWorkspaces({
|
|
|
929548
930106
|
context: context3
|
|
929549
930107
|
});
|
|
929550
930108
|
if (!await doesPathExist(dirname6(jsonschemaFilepath))) {
|
|
929551
|
-
await (0,
|
|
930109
|
+
await (0, import_promises144.mkdir)(dirname6(jsonschemaFilepath), { recursive: true });
|
|
929552
930110
|
}
|
|
929553
|
-
await (0,
|
|
930111
|
+
await (0, import_promises144.writeFile)(jsonschemaFilepath, JSON.stringify(jsonSchema, null, 2));
|
|
929554
930112
|
context3.logger.info(source_default.green(`Wrote JSON Schema to ${jsonschemaFilepath}`));
|
|
929555
930113
|
});
|
|
929556
930114
|
})
|
|
@@ -929559,7 +930117,7 @@ async function generateJsonschemaForWorkspaces({
|
|
|
929559
930117
|
|
|
929560
930118
|
// src/commands/merge/mergeOpenAPIWithOverrides.ts
|
|
929561
930119
|
init_lib6();
|
|
929562
|
-
var
|
|
930120
|
+
var import_promises145 = require("fs/promises");
|
|
929563
930121
|
var HTTP_METHODS2 = /* @__PURE__ */ new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
|
|
929564
930122
|
async function mergeOpenAPIWithOverrides({
|
|
929565
930123
|
openapiPath,
|
|
@@ -929584,12 +930142,12 @@ async function mergeOpenAPIWithOverrides({
|
|
|
929584
930142
|
const merged = mergeExamplesIntoSpec(openapi, overrides, context3);
|
|
929585
930143
|
const isJson = outputPath.endsWith(".json");
|
|
929586
930144
|
const output2 = isJson ? JSON.stringify(merged, null, 2) : jsYaml.dump(merged, { lineWidth: -1, noRefs: true });
|
|
929587
|
-
await (0,
|
|
930145
|
+
await (0, import_promises145.writeFile)(outputPath, output2);
|
|
929588
930146
|
context3.logger.info(`Merged output written to ${outputPath}`);
|
|
929589
930147
|
});
|
|
929590
930148
|
}
|
|
929591
930149
|
async function loadYamlOrJson(filepath, context3) {
|
|
929592
|
-
const contents = await (0,
|
|
930150
|
+
const contents = await (0, import_promises145.readFile)(filepath, "utf8");
|
|
929593
930151
|
try {
|
|
929594
930152
|
return JSON.parse(contents);
|
|
929595
930153
|
} catch {
|
|
@@ -930223,7 +930781,7 @@ async function mockServer({
|
|
|
930223
930781
|
}
|
|
930224
930782
|
|
|
930225
930783
|
// src/commands/register/registerWorkspacesV1.ts
|
|
930226
|
-
var
|
|
930784
|
+
var import_promises146 = require("fs/promises");
|
|
930227
930785
|
var import_path93 = __toESM(require("path"), 1);
|
|
930228
930786
|
var import_tmp_promise16 = __toESM(require_tmp_promise(), 1);
|
|
930229
930787
|
async function registerWorkspacesV1({
|
|
@@ -930276,7 +930834,7 @@ async function registerWorkspacesV1({
|
|
|
930276
930834
|
context3.logger.debug(`Compressing definition at ${tmpDir.path}`);
|
|
930277
930835
|
await Zn8({ file: tarPath, cwd: resolvedWorkspace.absoluteFilePath }, ["."]);
|
|
930278
930836
|
context3.logger.info("Uploading definition...");
|
|
930279
|
-
await axios_default.put(registerApiResponse.body.definitionS3UploadUrl, await (0,
|
|
930837
|
+
await axios_default.put(registerApiResponse.body.definitionS3UploadUrl, await (0, import_promises146.readFile)(tarPath));
|
|
930280
930838
|
context3.logger.info(
|
|
930281
930839
|
`Registered @${project.config.organization}/${resolvedWorkspace.definition.rootApiFile.contents.name}:${registerApiResponse.body.version}`
|
|
930282
930840
|
);
|
|
@@ -930518,7 +931076,7 @@ async function generateDiff({
|
|
|
930518
931076
|
|
|
930519
931077
|
// src/commands/sdk-preview/sdkPreview.ts
|
|
930520
931078
|
init_lib6();
|
|
930521
|
-
var
|
|
931079
|
+
var import_promises147 = __toESM(require("fs/promises"), 1);
|
|
930522
931080
|
|
|
930523
931081
|
// src/commands/sdk-preview/computePreviewVersion.ts
|
|
930524
931082
|
var BASE_VERSION = "0.0.1";
|
|
@@ -930638,7 +931196,7 @@ async function sdkPreview({
|
|
|
930638
931196
|
const firstPath = pathOutputs[0];
|
|
930639
931197
|
const absolutePathToOutput = firstPath != null ? AbsoluteFilePath2.of(resolve6(cwd(), firstPath)) : void 0;
|
|
930640
931198
|
if (absolutePathToOutput != null) {
|
|
930641
|
-
await
|
|
931199
|
+
await import_promises147.default.mkdir(absolutePathToOutput, { recursive: true });
|
|
930642
931200
|
}
|
|
930643
931201
|
for (const workspace of project.apiWorkspaces) {
|
|
930644
931202
|
if (workspace.generatorsConfiguration == null) {
|
|
@@ -930822,7 +931380,7 @@ async function sdkPreview({
|
|
|
930822
931380
|
}
|
|
930823
931381
|
|
|
930824
931382
|
// src/commands/self-update/selfUpdate.ts
|
|
930825
|
-
var
|
|
931383
|
+
var import_promises148 = require("fs/promises");
|
|
930826
931384
|
var import_path94 = require("path");
|
|
930827
931385
|
async function getPackageManagerBinDir(logger4, pm) {
|
|
930828
931386
|
let command3;
|
|
@@ -930868,7 +931426,7 @@ async function detectInstallationMethod(logger4) {
|
|
|
930868
931426
|
logger4.debug(`Found fern at: ${fernPath}`);
|
|
930869
931427
|
let resolvedPath;
|
|
930870
931428
|
try {
|
|
930871
|
-
resolvedPath = await (0,
|
|
931429
|
+
resolvedPath = await (0, import_promises148.realpath)(fernPath);
|
|
930872
931430
|
logger4.debug(`Resolved to: ${resolvedPath}`);
|
|
930873
931431
|
} catch (error50) {
|
|
930874
931432
|
logger4.debug(`Failed to resolve symlink: ${error50}`);
|
|
@@ -931171,21 +931729,21 @@ async function generateToken({
|
|
|
931171
931729
|
// src/commands/upgrade/updateApiSpec.ts
|
|
931172
931730
|
init_lib6();
|
|
931173
931731
|
var fs26 = __toESM(require("fs"), 1);
|
|
931174
|
-
var
|
|
931732
|
+
var import_promises149 = require("fs/promises");
|
|
931175
931733
|
init_graphql();
|
|
931176
931734
|
var import_stream16 = require("stream");
|
|
931177
|
-
var
|
|
931735
|
+
var import_promises150 = require("stream/promises");
|
|
931178
931736
|
async function fetchAndWriteFile(url3, path99, logger4, indent4) {
|
|
931179
931737
|
const resp = await fetch(url3);
|
|
931180
931738
|
if (resp.ok && resp.body) {
|
|
931181
931739
|
logger4.debug("Origin successfully fetched, writing to file");
|
|
931182
931740
|
const fileStream = fs26.createWriteStream(path99);
|
|
931183
|
-
await (0,
|
|
931184
|
-
const fileContents = await (0,
|
|
931741
|
+
await (0, import_promises150.finished)(import_stream16.Readable.fromWeb(resp.body).pipe(fileStream));
|
|
931742
|
+
const fileContents = await (0, import_promises149.readFile)(path99, "utf8");
|
|
931185
931743
|
try {
|
|
931186
|
-
await (0,
|
|
931744
|
+
await (0, import_promises149.writeFile)(path99, JSON.stringify(JSON.parse(fileContents), void 0, indent4), "utf8");
|
|
931187
931745
|
} catch (e5) {
|
|
931188
|
-
await (0,
|
|
931746
|
+
await (0, import_promises149.writeFile)(path99, jsYaml.dump(jsYaml.load(fileContents), { indent: indent4 }), "utf8");
|
|
931189
931747
|
}
|
|
931190
931748
|
logger4.debug("File written successfully");
|
|
931191
931749
|
}
|
|
@@ -931341,14 +931899,14 @@ async function tryDirectJSONFetch(url3, logger4) {
|
|
|
931341
931899
|
async function fetchGraphQLSchemaWithAutoDetection(url3, path99, logger4) {
|
|
931342
931900
|
const postResult = await tryGraphQLIntrospection(url3, logger4);
|
|
931343
931901
|
if (postResult.success) {
|
|
931344
|
-
await (0,
|
|
931902
|
+
await (0, import_promises149.writeFile)(path99, postResult.result, "utf8");
|
|
931345
931903
|
logger4.info("Successfully fetched GraphQL schema using POST introspection");
|
|
931346
931904
|
return;
|
|
931347
931905
|
}
|
|
931348
931906
|
logger4.debug(`POST introspection failed: ${postResult.error}`);
|
|
931349
931907
|
const getResult = await tryDirectJSONFetch(url3, logger4);
|
|
931350
931908
|
if (getResult.success) {
|
|
931351
|
-
await (0,
|
|
931909
|
+
await (0, import_promises149.writeFile)(path99, getResult.result, "utf8");
|
|
931352
931910
|
logger4.info("Successfully fetched GraphQL schema using direct JSON fetch");
|
|
931353
931911
|
return;
|
|
931354
931912
|
}
|
|
@@ -931457,7 +932015,7 @@ async function processDefinitions({
|
|
|
931457
932015
|
init_lib4();
|
|
931458
932016
|
|
|
931459
932017
|
// ../cli-migrations/lib/migrations/0.0.191/discriminant/migration.js
|
|
931460
|
-
var
|
|
932018
|
+
var import_promises151 = require("fs/promises");
|
|
931461
932019
|
|
|
931462
932020
|
// ../cli-migrations/lib/migrations/0.0.191/discriminant/getAllYamlFiles.js
|
|
931463
932021
|
init_lib6();
|
|
@@ -931493,7 +932051,7 @@ var migration = {
|
|
|
931493
932051
|
try {
|
|
931494
932052
|
const fileContents = await getFileContents(yamlFilepath);
|
|
931495
932053
|
const newContents = addDiscriminantToFile(fileContents);
|
|
931496
|
-
await (0,
|
|
932054
|
+
await (0, import_promises151.writeFile)(yamlFilepath, newContents);
|
|
931497
932055
|
} catch (error50) {
|
|
931498
932056
|
context3.failAndThrow("Failed to migrate " + yamlFilepath, error50);
|
|
931499
932057
|
}
|
|
@@ -931501,7 +932059,7 @@ var migration = {
|
|
|
931501
932059
|
}
|
|
931502
932060
|
};
|
|
931503
932061
|
async function getFileContents(filepath) {
|
|
931504
|
-
const buffer = await (0,
|
|
932062
|
+
const buffer = await (0, import_promises151.readFile)(filepath);
|
|
931505
932063
|
return buffer.toString();
|
|
931506
932064
|
}
|
|
931507
932065
|
var UNION_REGEX = /^(\s{2,})union:\s*$/gm;
|
|
@@ -931530,7 +932088,7 @@ var versionMigrations = {
|
|
|
931530
932088
|
var __default = versionMigrations;
|
|
931531
932089
|
|
|
931532
932090
|
// ../cli-migrations/lib/migrations/0.0.203/union-single-property-key/migration.js
|
|
931533
|
-
var
|
|
932091
|
+
var import_promises152 = require("fs/promises");
|
|
931534
932092
|
var import_yaml7 = __toESM(require_dist9(), 1);
|
|
931535
932093
|
|
|
931536
932094
|
// ../cli-migrations/lib/migrations/0.0.203/union-single-property-key/getAllYamlFiles.js
|
|
@@ -931573,7 +932131,7 @@ var migration2 = {
|
|
|
931573
932131
|
}
|
|
931574
932132
|
};
|
|
931575
932133
|
async function migrateFile(filepath, context3) {
|
|
931576
|
-
const contents = await (0,
|
|
932134
|
+
const contents = await (0, import_promises152.readFile)(filepath);
|
|
931577
932135
|
const parsedDocument = import_yaml7.default.parseDocument(contents.toString());
|
|
931578
932136
|
const types4 = parsedDocument.get("types");
|
|
931579
932137
|
if (types4 == null) {
|
|
@@ -931605,7 +932163,7 @@ async function migrateFile(filepath, context3) {
|
|
|
931605
932163
|
}
|
|
931606
932164
|
}
|
|
931607
932165
|
}
|
|
931608
|
-
await (0,
|
|
932166
|
+
await (0, import_promises152.writeFile)(filepath, parsedDocument.toString());
|
|
931609
932167
|
}
|
|
931610
932168
|
|
|
931611
932169
|
// ../cli-migrations/lib/migrations/0.0.203/index.js
|
|
@@ -931616,7 +932174,7 @@ var versionMigrations2 = {
|
|
|
931616
932174
|
var __default2 = versionMigrations2;
|
|
931617
932175
|
|
|
931618
932176
|
// ../cli-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/migration.js
|
|
931619
|
-
var
|
|
932177
|
+
var import_promises153 = require("fs/promises");
|
|
931620
932178
|
var import_yaml8 = __toESM(require_dist9(), 1);
|
|
931621
932179
|
|
|
931622
932180
|
// ../cli-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/getAllGeneratorYamlFiles.js
|
|
@@ -931659,7 +932217,7 @@ var migration3 = {
|
|
|
931659
932217
|
}
|
|
931660
932218
|
};
|
|
931661
932219
|
async function migrateGeneratorsYml(filepath, context3) {
|
|
931662
|
-
const contents = await (0,
|
|
932220
|
+
const contents = await (0, import_promises153.readFile)(filepath);
|
|
931663
932221
|
const parsedDocument = import_yaml8.default.parseDocument(contents.toString());
|
|
931664
932222
|
const draftGenerators = parsedDocument.get("draft");
|
|
931665
932223
|
if (draftGenerators == null) {
|
|
@@ -931686,7 +932244,7 @@ async function migrateGeneratorsYml(filepath, context3) {
|
|
|
931686
932244
|
draftGenerator.set("output-path", name2.value.includes("openapi") ? "./generated-openapi" : name2.value.includes("postman") ? "./generated-postman" : localOutput);
|
|
931687
932245
|
}
|
|
931688
932246
|
});
|
|
931689
|
-
await (0,
|
|
932247
|
+
await (0, import_promises153.writeFile)(filepath, parsedDocument.toString());
|
|
931690
932248
|
}
|
|
931691
932249
|
|
|
931692
932250
|
// ../cli-migrations/lib/migrations/0.0.207/index.js
|
|
@@ -931697,7 +932255,7 @@ var versionMigrations3 = {
|
|
|
931697
932255
|
var __default3 = versionMigrations3;
|
|
931698
932256
|
|
|
931699
932257
|
// ../cli-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/migration.js
|
|
931700
|
-
var
|
|
932258
|
+
var import_promises154 = require("fs/promises");
|
|
931701
932259
|
var import_yaml9 = __toESM(require_dist9(), 1);
|
|
931702
932260
|
|
|
931703
932261
|
// ../cli-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/getAllYamlFiles.js
|
|
@@ -931740,7 +932298,7 @@ var migration4 = {
|
|
|
931740
932298
|
}
|
|
931741
932299
|
};
|
|
931742
932300
|
async function migrateFile2(filepath, context3) {
|
|
931743
|
-
const contents = await (0,
|
|
932301
|
+
const contents = await (0, import_promises154.readFile)(filepath);
|
|
931744
932302
|
const parsedDocument = import_yaml9.default.parseDocument(contents.toString());
|
|
931745
932303
|
const addType = (typeName, typeDeclaration2) => {
|
|
931746
932304
|
const types4 = parsedDocument.get("types");
|
|
@@ -931784,7 +932342,7 @@ async function migrateFile2(filepath, context3) {
|
|
|
931784
932342
|
}
|
|
931785
932343
|
}
|
|
931786
932344
|
}
|
|
931787
|
-
await (0,
|
|
932345
|
+
await (0, import_promises154.writeFile)(filepath, parsedDocument.toString());
|
|
931788
932346
|
}
|
|
931789
932347
|
|
|
931790
932348
|
// ../cli-migrations/lib/migrations/0.0.210/index.js
|
|
@@ -931795,7 +932353,7 @@ var versionMigrations4 = {
|
|
|
931795
932353
|
var __default4 = versionMigrations4;
|
|
931796
932354
|
|
|
931797
932355
|
// ../cli-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/migration.js
|
|
931798
|
-
var
|
|
932356
|
+
var import_promises155 = require("fs/promises");
|
|
931799
932357
|
var import_yaml10 = __toESM(require_dist9(), 1);
|
|
931800
932358
|
|
|
931801
932359
|
// ../cli-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/getAllGeneratorYamlFiles.js
|
|
@@ -931838,7 +932396,7 @@ var migration5 = {
|
|
|
931838
932396
|
}
|
|
931839
932397
|
};
|
|
931840
932398
|
async function migrateGeneratorsYml2(filepath, context3) {
|
|
931841
|
-
const contents = await (0,
|
|
932399
|
+
const contents = await (0, import_promises155.readFile)(filepath);
|
|
931842
932400
|
const parsedDocument = import_yaml10.default.parseDocument(contents.toString());
|
|
931843
932401
|
const releaseGenerators = parsedDocument.get("release");
|
|
931844
932402
|
if (releaseGenerators == null) {
|
|
@@ -931876,7 +932434,7 @@ async function migrateGeneratorsYml2(filepath, context3) {
|
|
|
931876
932434
|
}
|
|
931877
932435
|
releaseGenerator.delete("outputs");
|
|
931878
932436
|
});
|
|
931879
|
-
await (0,
|
|
932437
|
+
await (0, import_promises155.writeFile)(filepath, parsedDocument.toString());
|
|
931880
932438
|
}
|
|
931881
932439
|
|
|
931882
932440
|
// ../cli-migrations/lib/migrations/0.0.212/index.js
|
|
@@ -931887,7 +932445,7 @@ var versionMigrations5 = {
|
|
|
931887
932445
|
var __default5 = versionMigrations5;
|
|
931888
932446
|
|
|
931889
932447
|
// ../cli-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/migration.js
|
|
931890
|
-
var
|
|
932448
|
+
var import_promises156 = require("fs/promises");
|
|
931891
932449
|
|
|
931892
932450
|
// ../cli-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/getAllYamlFiles.js
|
|
931893
932451
|
init_lib6();
|
|
@@ -931920,9 +932478,9 @@ var migration6 = {
|
|
|
931920
932478
|
run: async ({ context: context3 }) => {
|
|
931921
932479
|
const yamlFiles = await getAllYamlFiles4(context3);
|
|
931922
932480
|
for (const filepath of yamlFiles) {
|
|
931923
|
-
const contents = await (0,
|
|
932481
|
+
const contents = await (0, import_promises156.readFile)(filepath);
|
|
931924
932482
|
const newContents = contents.toString().replaceAll(" alias:", " type:");
|
|
931925
|
-
await (0,
|
|
932483
|
+
await (0, import_promises156.writeFile)(filepath, newContents);
|
|
931926
932484
|
}
|
|
931927
932485
|
}
|
|
931928
932486
|
};
|
|
@@ -931935,7 +932493,7 @@ var versionMigrations6 = {
|
|
|
931935
932493
|
var __default6 = versionMigrations6;
|
|
931936
932494
|
|
|
931937
932495
|
// ../cli-migrations/lib/migrations/0.0.221/add-error-discriminant/migration.js
|
|
931938
|
-
var
|
|
932496
|
+
var import_promises157 = require("fs/promises");
|
|
931939
932497
|
|
|
931940
932498
|
// ../cli-migrations/lib/migrations/0.0.221/add-error-discriminant/getAllRootApiYamlFiles.js
|
|
931941
932499
|
init_lib6();
|
|
@@ -931968,9 +932526,9 @@ var migration7 = {
|
|
|
931968
932526
|
run: async ({ context: context3 }) => {
|
|
931969
932527
|
const yamlFiles = await getAllRootApiYamlFiles(context3);
|
|
931970
932528
|
for (const filepath of yamlFiles) {
|
|
931971
|
-
const contents = await (0,
|
|
932529
|
+
const contents = await (0, import_promises157.readFile)(filepath);
|
|
931972
932530
|
const newContents = contents.toString() + "\nerror-discriminant: error";
|
|
931973
|
-
await (0,
|
|
932531
|
+
await (0, import_promises157.writeFile)(filepath, newContents);
|
|
931974
932532
|
}
|
|
931975
932533
|
}
|
|
931976
932534
|
};
|
|
@@ -931984,7 +932542,7 @@ var __default7 = versionMigrations7;
|
|
|
931984
932542
|
|
|
931985
932543
|
// ../cli-migrations/lib/migrations/0.0.241/add-generator-groups/migration.js
|
|
931986
932544
|
init_lib4();
|
|
931987
|
-
var
|
|
932545
|
+
var import_promises158 = require("fs/promises");
|
|
931988
932546
|
|
|
931989
932547
|
// ../cli-migrations/lib/migrations/0.0.241/add-generator-groups/getAllGeneratorYamlFiles.js
|
|
931990
932548
|
init_lib6();
|
|
@@ -932116,7 +932674,7 @@ var migration8 = {
|
|
|
932116
932674
|
}
|
|
932117
932675
|
};
|
|
932118
932676
|
async function migrateGeneratorsYml3(filepath) {
|
|
932119
|
-
const contentsStr = await (0,
|
|
932677
|
+
const contentsStr = await (0, import_promises158.readFile)(filepath);
|
|
932120
932678
|
const contents = jsYaml.load(contentsStr.toString());
|
|
932121
932679
|
const oldGeneratorsConfiguration = GeneratorsConfigurationSchema2.parse(contents);
|
|
932122
932680
|
let newGeneratorsConfiguration = {};
|
|
@@ -932134,7 +932692,7 @@ async function migrateGeneratorsYml3(filepath) {
|
|
|
932134
932692
|
generators: oldGeneratorsConfiguration.release.map((releaseGeneratorInvocation) => convertReleaseGeneratorInvocation(releaseGeneratorInvocation))
|
|
932135
932693
|
};
|
|
932136
932694
|
}
|
|
932137
|
-
await (0,
|
|
932695
|
+
await (0, import_promises158.writeFile)(filepath, jsYaml.dump(newGeneratorsConfiguration));
|
|
932138
932696
|
}
|
|
932139
932697
|
function convertDraftGeneratorInvocation(draftGeneratorInvocation) {
|
|
932140
932698
|
const newSchema = {
|
|
@@ -932209,7 +932767,7 @@ var versionMigrations8 = {
|
|
|
932209
932767
|
var __default8 = versionMigrations8;
|
|
932210
932768
|
|
|
932211
932769
|
// ../cli-migrations/lib/migrations/0.0.248/add-error-discrimination-config/migration.js
|
|
932212
|
-
var
|
|
932770
|
+
var import_promises159 = require("fs/promises");
|
|
932213
932771
|
var import_yaml11 = __toESM(require_dist9(), 1);
|
|
932214
932772
|
|
|
932215
932773
|
// ../cli-migrations/lib/migrations/0.0.248/add-error-discrimination-config/getAllRootApiYamlFiles.js
|
|
@@ -932252,7 +932810,7 @@ var migration9 = {
|
|
|
932252
932810
|
}
|
|
932253
932811
|
};
|
|
932254
932812
|
async function migrateRootApiFile(filepath) {
|
|
932255
|
-
const contents = await (0,
|
|
932813
|
+
const contents = await (0, import_promises159.readFile)(filepath);
|
|
932256
932814
|
const parsedDocument = import_yaml11.default.parseDocument(contents.toString());
|
|
932257
932815
|
const errorDiscriminant = parsedDocument.get("error-discriminant", true);
|
|
932258
932816
|
if (errorDiscriminant == null || !import_yaml11.default.isScalar(errorDiscriminant) || typeof errorDiscriminant.value !== "string") {
|
|
@@ -932263,7 +932821,7 @@ async function migrateRootApiFile(filepath) {
|
|
|
932263
932821
|
"property-name": errorDiscriminant.value
|
|
932264
932822
|
});
|
|
932265
932823
|
parsedDocument.delete("error-discriminant");
|
|
932266
|
-
await (0,
|
|
932824
|
+
await (0, import_promises159.writeFile)(filepath, parsedDocument.toString());
|
|
932267
932825
|
}
|
|
932268
932826
|
|
|
932269
932827
|
// ../cli-migrations/lib/migrations/0.0.248/index.js
|
|
@@ -932274,7 +932832,7 @@ var versionMigrations9 = {
|
|
|
932274
932832
|
var __default9 = versionMigrations9;
|
|
932275
932833
|
|
|
932276
932834
|
// ../cli-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/migration.js
|
|
932277
|
-
var
|
|
932835
|
+
var import_promises160 = require("fs/promises");
|
|
932278
932836
|
var import_yaml12 = __toESM(require_dist9(), 1);
|
|
932279
932837
|
|
|
932280
932838
|
// ../cli-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/getAllYamlFiles.js
|
|
@@ -932317,7 +932875,7 @@ var migration10 = {
|
|
|
932317
932875
|
}
|
|
932318
932876
|
};
|
|
932319
932877
|
async function migrateYamlFile(filepath, context3) {
|
|
932320
|
-
const contents = await (0,
|
|
932878
|
+
const contents = await (0, import_promises160.readFile)(filepath);
|
|
932321
932879
|
const parsedDocument = import_yaml12.default.parseDocument(contents.toString());
|
|
932322
932880
|
const services = parsedDocument.get("services");
|
|
932323
932881
|
if (services == null) {
|
|
@@ -932357,7 +932915,7 @@ async function migrateYamlFile(filepath, context3) {
|
|
|
932357
932915
|
context3.failWithoutThrowing("Failed to convert endpoint", e5);
|
|
932358
932916
|
}
|
|
932359
932917
|
}
|
|
932360
|
-
await (0,
|
|
932918
|
+
await (0, import_promises160.writeFile)(filepath, parsedDocument.toString());
|
|
932361
932919
|
}
|
|
932362
932920
|
}
|
|
932363
932921
|
function convertEndpoint4({ document: document4, endpoint: endpoint3 }) {
|
|
@@ -932436,7 +932994,7 @@ var versionMigrations10 = {
|
|
|
932436
932994
|
var __default10 = versionMigrations10;
|
|
932437
932995
|
|
|
932438
932996
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/migration.js
|
|
932439
|
-
var
|
|
932997
|
+
var import_promises161 = require("fs/promises");
|
|
932440
932998
|
var import_yaml13 = __toESM(require_dist9(), 1);
|
|
932441
932999
|
|
|
932442
933000
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/getAllYamlFiles.js
|
|
@@ -932479,7 +933037,7 @@ var migration11 = {
|
|
|
932479
933037
|
}
|
|
932480
933038
|
};
|
|
932481
933039
|
async function migrateYamlFile2(filepath, context3) {
|
|
932482
|
-
const contents = await (0,
|
|
933040
|
+
const contents = await (0, import_promises161.readFile)(filepath);
|
|
932483
933041
|
const parsedDocument = import_yaml13.default.parseDocument(contents.toString());
|
|
932484
933042
|
const types4 = parsedDocument.get("types");
|
|
932485
933043
|
if (types4 == null) {
|
|
@@ -932505,7 +933063,7 @@ async function migrateYamlFile2(filepath, context3) {
|
|
|
932505
933063
|
examples.set(i9, { value: value2 });
|
|
932506
933064
|
}
|
|
932507
933065
|
}
|
|
932508
|
-
await (0,
|
|
933066
|
+
await (0, import_promises161.writeFile)(filepath, parsedDocument.toString());
|
|
932509
933067
|
}
|
|
932510
933068
|
|
|
932511
933069
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/index.js
|
|
@@ -932516,7 +933074,7 @@ var versionMigrations11 = {
|
|
|
932516
933074
|
var __default11 = versionMigrations11;
|
|
932517
933075
|
|
|
932518
933076
|
// ../cli-migrations/lib/migrations/0.3.23/change-services-key-to-service/migration.js
|
|
932519
|
-
var
|
|
933077
|
+
var import_promises162 = require("fs/promises");
|
|
932520
933078
|
var import_yaml14 = __toESM(require_dist9(), 1);
|
|
932521
933079
|
|
|
932522
933080
|
// ../cli-migrations/lib/migrations/0.3.23/change-services-key-to-service/getAllYamlFiles.js
|
|
@@ -932559,7 +933117,7 @@ var migration12 = {
|
|
|
932559
933117
|
}
|
|
932560
933118
|
};
|
|
932561
933119
|
async function migrateYamlFile3(filepath, context3) {
|
|
932562
|
-
const contents = await (0,
|
|
933120
|
+
const contents = await (0, import_promises162.readFile)(filepath);
|
|
932563
933121
|
const parsedDocument = import_yaml14.default.parseDocument(contents.toString());
|
|
932564
933122
|
if (!import_yaml14.default.isMap(parsedDocument.contents)) {
|
|
932565
933123
|
return context3.failAndThrow("File is not a map");
|
|
@@ -932589,7 +933147,7 @@ async function migrateYamlFile3(filepath, context3) {
|
|
|
932589
933147
|
pair.value = firstService.value;
|
|
932590
933148
|
}
|
|
932591
933149
|
}
|
|
932592
|
-
await (0,
|
|
933150
|
+
await (0, import_promises162.writeFile)(filepath, parsedDocument.toString());
|
|
932593
933151
|
}
|
|
932594
933152
|
|
|
932595
933153
|
// ../cli-migrations/lib/migrations/0.3.23/index.js
|
|
@@ -932600,7 +933158,7 @@ var versionMigrations12 = {
|
|
|
932600
933158
|
var __default12 = versionMigrations12;
|
|
932601
933159
|
|
|
932602
933160
|
// ../cli-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/migration.js
|
|
932603
|
-
var
|
|
933161
|
+
var import_promises163 = require("fs/promises");
|
|
932604
933162
|
var import_yaml15 = __toESM(require_dist9(), 1);
|
|
932605
933163
|
|
|
932606
933164
|
// ../cli-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/getAllYamlFiles.js
|
|
@@ -932643,7 +933201,7 @@ var migration13 = {
|
|
|
932643
933201
|
}
|
|
932644
933202
|
};
|
|
932645
933203
|
async function migrateYamlFile4(filepath, context3) {
|
|
932646
|
-
const contents = await (0,
|
|
933204
|
+
const contents = await (0, import_promises163.readFile)(filepath);
|
|
932647
933205
|
const parsedDocument = import_yaml15.default.parseDocument(contents.toString());
|
|
932648
933206
|
if (!import_yaml15.default.isMap(parsedDocument.contents)) {
|
|
932649
933207
|
return context3.failAndThrow("File is not a map");
|
|
@@ -932662,7 +933220,7 @@ async function migrateYamlFile4(filepath, context3) {
|
|
|
932662
933220
|
}
|
|
932663
933221
|
service.items.splice(indexOfServiceDocsPair, 1);
|
|
932664
933222
|
parsedDocument.contents.items.unshift(docsPair);
|
|
932665
|
-
await (0,
|
|
933223
|
+
await (0, import_promises163.writeFile)(filepath, parsedDocument.toString());
|
|
932666
933224
|
}
|
|
932667
933225
|
|
|
932668
933226
|
// ../cli-migrations/lib/migrations/0.5.4/index.js
|
|
@@ -932673,7 +933231,7 @@ var versionMigrations13 = {
|
|
|
932673
933231
|
var __default13 = versionMigrations13;
|
|
932674
933232
|
|
|
932675
933233
|
// ../cli-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/migration.js
|
|
932676
|
-
var
|
|
933234
|
+
var import_promises164 = require("fs/promises");
|
|
932677
933235
|
|
|
932678
933236
|
// ../cli-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/getAllGeneratorYamlFiles.js
|
|
932679
933237
|
init_lib6();
|
|
@@ -932715,14 +933273,14 @@ var migration14 = {
|
|
|
932715
933273
|
}
|
|
932716
933274
|
};
|
|
932717
933275
|
async function migrateYamlFile5(filepath) {
|
|
932718
|
-
const contents = await (0,
|
|
933276
|
+
const contents = await (0, import_promises164.readFile)(filepath);
|
|
932719
933277
|
const domainSuffix = process.env.DOMAIN_SUFFIX ?? "docs.buildwithfern.com";
|
|
932720
933278
|
const regex5 = /(docs:\s*domain:\s*)"([^"]*)"/g;
|
|
932721
933279
|
const updatedSnapshot = contents.toString().replace(regex5, (_match, _prefix, domain3) => {
|
|
932722
933280
|
return `docs:
|
|
932723
933281
|
domain: "${domain3}.${domainSuffix}"`;
|
|
932724
933282
|
});
|
|
932725
|
-
await (0,
|
|
933283
|
+
await (0, import_promises164.writeFile)(filepath, updatedSnapshot.toString());
|
|
932726
933284
|
}
|
|
932727
933285
|
|
|
932728
933286
|
// ../cli-migrations/lib/migrations/0.9.10/index.js
|
|
@@ -932742,10 +933300,10 @@ var LegacyDocsSerializers = __toESM(require_serialization4(), 1);
|
|
|
932742
933300
|
|
|
932743
933301
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/loadRawDocsConfiguration.js
|
|
932744
933302
|
init_lib6();
|
|
932745
|
-
var
|
|
933303
|
+
var import_promises165 = require("fs/promises");
|
|
932746
933304
|
async function loadRawDocsConfiguration2({ absolutePathToWorkspace }) {
|
|
932747
933305
|
const filepath = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
932748
|
-
const contentsStr = await (0,
|
|
933306
|
+
const contentsStr = await (0, import_promises165.readFile)(filepath);
|
|
932749
933307
|
const contentsParsed = jsYaml.load(contentsStr.toString());
|
|
932750
933308
|
const result = await LegacyDocsSerializers.DocsConfiguration.parse(contentsParsed);
|
|
932751
933309
|
if (result.ok) {
|
|
@@ -932764,7 +933322,7 @@ function getAbsolutePathToDocsFolder({ absolutePathToWorkspace }) {
|
|
|
932764
933322
|
|
|
932765
933323
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndMultipleAPIs.js
|
|
932766
933324
|
init_lib6();
|
|
932767
|
-
var
|
|
933325
|
+
var import_promises167 = require("fs/promises");
|
|
932768
933326
|
|
|
932769
933327
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/convertLegacyDocsConfig.js
|
|
932770
933328
|
function convertLegacyDocsConfig({ docsConfiguration, docsURLs, apiName }) {
|
|
@@ -932972,10 +933530,10 @@ __export(legacy_exports, {
|
|
|
932972
933530
|
|
|
932973
933531
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/generators-configuration/loadRawGeneratorsConfiguration.js
|
|
932974
933532
|
init_lib6();
|
|
932975
|
-
var
|
|
933533
|
+
var import_promises166 = require("fs/promises");
|
|
932976
933534
|
async function loadRawGeneratorsConfiguration2({ absolutePathToWorkspace }) {
|
|
932977
933535
|
const filepath = getAbsolutePathToGeneratorsConfiguration({ absolutePathToWorkspace });
|
|
932978
|
-
const contentsStr = await (0,
|
|
933536
|
+
const contentsStr = await (0, import_promises166.readFile)(filepath);
|
|
932979
933537
|
const contentsParsed = jsYaml.load(contentsStr.toString());
|
|
932980
933538
|
const result = await legacy_exports.GeneratorsConfigurationSchema.safeParseAsync(contentsParsed);
|
|
932981
933539
|
if (result.success) {
|
|
@@ -933005,7 +933563,7 @@ function migrateDocsInstances(docsURLs) {
|
|
|
933005
933563
|
var APIS_DIRECTORY2 = "apis";
|
|
933006
933564
|
async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspaces, workspaceContainingDocs }) {
|
|
933007
933565
|
const absolutePathToApisDirectory = join8(absolutePathToFernDirectory, RelativeFilePath2.of(APIS_DIRECTORY2));
|
|
933008
|
-
await (0,
|
|
933566
|
+
await (0, import_promises167.mkdir)(absolutePathToApisDirectory);
|
|
933009
933567
|
for (const workspace of workspaces) {
|
|
933010
933568
|
const absolutePathToWorkspace = join8(absolutePathToFernDirectory, RelativeFilePath2.of(workspace));
|
|
933011
933569
|
const docsURLs = await migrateAndWriteGeneratorsYml({ absolutePathToWorkspace });
|
|
@@ -933013,11 +933571,11 @@ async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspa
|
|
|
933013
933571
|
await migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName: workspaceContainingDocs });
|
|
933014
933572
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
933015
933573
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
933016
|
-
await (0,
|
|
933574
|
+
await (0, import_promises167.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
933017
933575
|
}
|
|
933018
933576
|
const absolutePathToNestedWorkspace = join8(absolutePathToApisDirectory, RelativeFilePath2.of(workspace));
|
|
933019
933577
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
933020
|
-
await (0,
|
|
933578
|
+
await (0, import_promises167.rm)(absolutePathToWorkspace, { recursive: true });
|
|
933021
933579
|
}
|
|
933022
933580
|
}
|
|
933023
933581
|
async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
@@ -933030,7 +933588,7 @@ async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
|
933030
933588
|
generatorsConfiguration,
|
|
933031
933589
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
933032
933590
|
});
|
|
933033
|
-
await (0,
|
|
933591
|
+
await (0, import_promises167.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
933034
933592
|
return convertedResponse.docsURLs;
|
|
933035
933593
|
}
|
|
933036
933594
|
async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName }) {
|
|
@@ -933044,20 +933602,20 @@ async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiNa
|
|
|
933044
933602
|
apiName
|
|
933045
933603
|
});
|
|
933046
933604
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
933047
|
-
await (0,
|
|
933605
|
+
await (0, import_promises167.writeFile)(absolutePathToDocsConfig, jsYaml.dump(convertedDocsConfig));
|
|
933048
933606
|
}
|
|
933049
933607
|
|
|
933050
933608
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndSingleAPI.js
|
|
933051
933609
|
init_lib6();
|
|
933052
|
-
var
|
|
933610
|
+
var import_promises168 = require("fs/promises");
|
|
933053
933611
|
async function migrateDocsAndSingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
933054
933612
|
const docsURLs = await migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace });
|
|
933055
933613
|
await migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs });
|
|
933056
933614
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
933057
933615
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
933058
933616
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
933059
|
-
await (0,
|
|
933060
|
-
await (0,
|
|
933617
|
+
await (0, import_promises168.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
933618
|
+
await (0, import_promises168.rm)(absolutePathToWorkspace, { recursive: true });
|
|
933061
933619
|
}
|
|
933062
933620
|
async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
933063
933621
|
const docsConfiguration = await loadRawDocsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -933070,7 +933628,7 @@ async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
|
933070
933628
|
apiName: void 0
|
|
933071
933629
|
});
|
|
933072
933630
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
933073
|
-
await (0,
|
|
933631
|
+
await (0, import_promises168.writeFile)(absolutePathToDocsConfig, jsYaml.dump(convertedDocsConfig));
|
|
933074
933632
|
}
|
|
933075
933633
|
async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
933076
933634
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -933082,23 +933640,23 @@ async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
|
933082
933640
|
generatorsConfiguration,
|
|
933083
933641
|
pathModificationStrategy: "MoveUp"
|
|
933084
933642
|
});
|
|
933085
|
-
await (0,
|
|
933643
|
+
await (0, import_promises168.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
933086
933644
|
return convertedResponse.docsURLs;
|
|
933087
933645
|
}
|
|
933088
933646
|
|
|
933089
933647
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlyMultipleAPIs.js
|
|
933090
933648
|
init_lib6();
|
|
933091
|
-
var
|
|
933649
|
+
var import_promises169 = require("fs/promises");
|
|
933092
933650
|
var APIS_DIRECTORY3 = "apis";
|
|
933093
933651
|
async function migrateOnlyMultipleAPIs({ absolutePathToFernDirectory, workspaces }) {
|
|
933094
933652
|
const absolutePathToApisDirectory = join8(absolutePathToFernDirectory, RelativeFilePath2.of(APIS_DIRECTORY3));
|
|
933095
|
-
await (0,
|
|
933653
|
+
await (0, import_promises169.mkdir)(absolutePathToApisDirectory);
|
|
933096
933654
|
for (const workspace of workspaces) {
|
|
933097
933655
|
const absolutePathToWorkspace = join8(absolutePathToFernDirectory, RelativeFilePath2.of(workspace));
|
|
933098
933656
|
await migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace });
|
|
933099
933657
|
const absolutePathToNestedWorkspace = join8(absolutePathToApisDirectory, RelativeFilePath2.of(workspace));
|
|
933100
933658
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
933101
|
-
await (0,
|
|
933659
|
+
await (0, import_promises169.rm)(absolutePathToWorkspace, { recursive: true });
|
|
933102
933660
|
}
|
|
933103
933661
|
}
|
|
933104
933662
|
async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
@@ -933111,16 +933669,16 @@ async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
|
933111
933669
|
generatorsConfiguration,
|
|
933112
933670
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
933113
933671
|
});
|
|
933114
|
-
await (0,
|
|
933672
|
+
await (0, import_promises169.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
933115
933673
|
}
|
|
933116
933674
|
|
|
933117
933675
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlySingleAPI.js
|
|
933118
933676
|
init_lib6();
|
|
933119
|
-
var
|
|
933677
|
+
var import_promises170 = require("fs/promises");
|
|
933120
933678
|
async function migrateOnlySingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
933121
933679
|
await migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace });
|
|
933122
933680
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
933123
|
-
await (0,
|
|
933681
|
+
await (0, import_promises170.rm)(absolutePathToWorkspace, { recursive: true });
|
|
933124
933682
|
}
|
|
933125
933683
|
async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
933126
933684
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -933132,7 +933690,7 @@ async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
|
933132
933690
|
generatorsConfiguration,
|
|
933133
933691
|
pathModificationStrategy: "MoveUp"
|
|
933134
933692
|
});
|
|
933135
|
-
await (0,
|
|
933693
|
+
await (0, import_promises170.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
933136
933694
|
}
|
|
933137
933695
|
|
|
933138
933696
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migration.js
|
|
@@ -933210,7 +933768,7 @@ var __default15 = versionMigrations15;
|
|
|
933210
933768
|
|
|
933211
933769
|
// ../cli-migrations/lib/migrations/0.41.0-rc0/require-generators-yml/migration.js
|
|
933212
933770
|
init_lib6();
|
|
933213
|
-
var
|
|
933771
|
+
var import_promises171 = require("fs/promises");
|
|
933214
933772
|
var import_yaml16 = __toESM(require_dist9(), 1);
|
|
933215
933773
|
var migration16 = {
|
|
933216
933774
|
name: "require-generators-yml",
|
|
@@ -933253,7 +933811,7 @@ async function addApiConfigurationToSingleWorkspace({ absolutePathToFernDirector
|
|
|
933253
933811
|
if (existingGeneratorsYml == null) {
|
|
933254
933812
|
if (openapiDirectory != null && openapiDirectory.contents[0] != null) {
|
|
933255
933813
|
const absolutePathToGeneratorsYml = join8(absoluteFilepathToWorkspace, RelativeFilePath2.of("generators.yml"));
|
|
933256
|
-
await (0,
|
|
933814
|
+
await (0, import_promises171.writeFile)(absolutePathToGeneratorsYml, jsYaml.dump({
|
|
933257
933815
|
api: {
|
|
933258
933816
|
path: join8(relativize(absolutePathToFernDirectory, absoluteFilepathToWorkspace), RelativeFilePath2.of(openapiDirectory.name), RelativeFilePath2.of(openapiDirectory.contents[0]?.name))
|
|
933259
933817
|
}
|
|
@@ -933268,7 +933826,7 @@ async function addApiConfigurationToSingleWorkspace({ absolutePathToFernDirector
|
|
|
933268
933826
|
parsedDocument.set("api", {
|
|
933269
933827
|
path: join8(relativize(absolutePathToFernDirectory, absoluteFilepathToWorkspace), RelativeFilePath2.of(openapiDirectory.name), RelativeFilePath2.of(openapiDirectory.contents[0]?.name))
|
|
933270
933828
|
});
|
|
933271
|
-
await (0,
|
|
933829
|
+
await (0, import_promises171.writeFile)(existingGeneratorsYml.absolutePath, parsedDocument.toString());
|
|
933272
933830
|
context3.logger.info(source_default.green(`Updated ${existingGeneratorsYml.absolutePath}`));
|
|
933273
933831
|
}
|
|
933274
933832
|
}
|
|
@@ -933296,7 +933854,7 @@ var __default16 = versionMigrations16;
|
|
|
933296
933854
|
|
|
933297
933855
|
// ../cli-migrations/lib/migrations/0.54.0-rc0/use-generators-yml-specs/migration.js
|
|
933298
933856
|
init_lib6();
|
|
933299
|
-
var
|
|
933857
|
+
var import_promises172 = require("fs/promises");
|
|
933300
933858
|
var import_yaml17 = __toESM(require_dist9(), 1);
|
|
933301
933859
|
var migration17 = {
|
|
933302
933860
|
name: "generators-yml-use-api-specs",
|
|
@@ -933476,7 +934034,7 @@ async function addApiConfigurationToSingleWorkspace2({ absoluteFilepathToWorkspa
|
|
|
933476
934034
|
if (schemaComment && documentToWrite.indexOf(schemaComment) === -1) {
|
|
933477
934035
|
documentToWrite = `${schemaComment}${documentToWrite}`;
|
|
933478
934036
|
}
|
|
933479
|
-
await (0,
|
|
934037
|
+
await (0, import_promises172.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
933480
934038
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
933481
934039
|
}
|
|
933482
934040
|
async function parseApiSpec({ oldSpec, absoluteFilepathToWorkspace, files, directories, context: context3, namespace }) {
|
|
@@ -933523,7 +934081,7 @@ async function parseApiSpec({ oldSpec, absoluteFilepathToWorkspace, files, direc
|
|
|
933523
934081
|
}
|
|
933524
934082
|
let specContent;
|
|
933525
934083
|
try {
|
|
933526
|
-
const fileContents = await (0,
|
|
934084
|
+
const fileContents = await (0, import_promises172.readFile)(absoluteSpecPath, { encoding: "utf-8" });
|
|
933527
934085
|
specContent = jsYaml.load(fileContents);
|
|
933528
934086
|
} catch (e5) {
|
|
933529
934087
|
context3.logger.warn(`Failed to read API spec file ${spec.path}. Error: ${e5}. Skipping...`);
|
|
@@ -933627,7 +934185,7 @@ var __default17 = versionMigrations17;
|
|
|
933627
934185
|
|
|
933628
934186
|
// ../cli-migrations/lib/migrations/0.82.1/add-path-parameter-order-setting/migration.js
|
|
933629
934187
|
init_lib6();
|
|
933630
|
-
var
|
|
934188
|
+
var import_promises173 = require("fs/promises");
|
|
933631
934189
|
var migration18 = {
|
|
933632
934190
|
name: "add-path-parameter-order-setting",
|
|
933633
934191
|
summary: `Adds the 'path-parameter-order' setting to existing API configurations to maintain backwards compatibility.
|
|
@@ -933715,7 +934273,7 @@ async function updateGeneratorsYml({ context: context3, files }) {
|
|
|
933715
934273
|
documentToWrite = `${schemaComment}
|
|
933716
934274
|
${documentToWrite}`;
|
|
933717
934275
|
}
|
|
933718
|
-
await (0,
|
|
934276
|
+
await (0, import_promises173.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
933719
934277
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
933720
934278
|
}
|
|
933721
934279
|
async function getFilesAndDirectories3(absoluteFilepath) {
|
|
@@ -933752,7 +934310,7 @@ var __default18 = versionMigrations18;
|
|
|
933752
934310
|
|
|
933753
934311
|
// ../cli-migrations/lib/migrations/1.0.0/update-settings-defaults/migration.js
|
|
933754
934312
|
init_lib6();
|
|
933755
|
-
var
|
|
934313
|
+
var import_promises174 = require("fs/promises");
|
|
933756
934314
|
var migration19 = {
|
|
933757
934315
|
name: "update-1_0_0-defaults",
|
|
933758
934316
|
summary: `The defaults of the API spec settings have changed.
|
|
@@ -933927,7 +934485,7 @@ async function updateGeneratorsYml2({ context: context3, files }) {
|
|
|
933927
934485
|
documentToWrite = `${schemaComment}
|
|
933928
934486
|
${documentToWrite}`;
|
|
933929
934487
|
}
|
|
933930
|
-
await (0,
|
|
934488
|
+
await (0, import_promises174.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
933931
934489
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
933932
934490
|
}
|
|
933933
934491
|
async function getFilesAndDirectories4(absoluteFilepath) {
|
|
@@ -933997,7 +934555,7 @@ var __default19 = versionMigrations19;
|
|
|
933997
934555
|
|
|
933998
934556
|
// ../cli-migrations/lib/migrations/2.0.0-rc0/update-settings-defaults/migration.js
|
|
933999
934557
|
init_lib6();
|
|
934000
|
-
var
|
|
934558
|
+
var import_promises175 = require("fs/promises");
|
|
934001
934559
|
var migration20 = {
|
|
934002
934560
|
name: "update-2_0_0-defaults",
|
|
934003
934561
|
summary: `The default of 'coerce-enums-to-literals' has changed from true to false.
|
|
@@ -934172,7 +934730,7 @@ async function updateGeneratorsYml3({ context: context3, files }) {
|
|
|
934172
934730
|
documentToWrite = `${schemaComment}
|
|
934173
934731
|
${documentToWrite}`;
|
|
934174
934732
|
}
|
|
934175
|
-
await (0,
|
|
934733
|
+
await (0, import_promises175.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
934176
934734
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
934177
934735
|
}
|
|
934178
934736
|
async function getFilesAndDirectories5(absoluteFilepath) {
|
|
@@ -934219,7 +934777,7 @@ var __default20 = versionMigrations20;
|
|
|
934219
934777
|
|
|
934220
934778
|
// ../cli-migrations/lib/migrations/2.13.0/migrate-deprecated-generator-api-settings/migration.js
|
|
934221
934779
|
init_lib6();
|
|
934222
|
-
var
|
|
934780
|
+
var import_promises176 = require("fs/promises");
|
|
934223
934781
|
var migration21 = {
|
|
934224
934782
|
name: "migrate-deprecated-generator-api-settings",
|
|
934225
934783
|
summary: `Migrates deprecated generator-level API settings keys to their new equivalents:
|
|
@@ -934310,7 +934868,7 @@ async function updateGeneratorsYml4({ context: context3, files }) {
|
|
|
934310
934868
|
documentToWrite = `${schemaComment}
|
|
934311
934869
|
${documentToWrite}`;
|
|
934312
934870
|
}
|
|
934313
|
-
await (0,
|
|
934871
|
+
await (0, import_promises176.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
934314
934872
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
934315
934873
|
}
|
|
934316
934874
|
function migrateDeprecatedSettings(settings, context3) {
|
|
@@ -934357,7 +934915,7 @@ var __default21 = versionMigrations21;
|
|
|
934357
934915
|
|
|
934358
934916
|
// ../cli-migrations/lib/migrations/3.0.0/enable-smart-casing/migration.js
|
|
934359
934917
|
init_lib6();
|
|
934360
|
-
var
|
|
934918
|
+
var import_promises177 = require("fs/promises");
|
|
934361
934919
|
var migration22 = {
|
|
934362
934920
|
name: "enable-smart-casing",
|
|
934363
934921
|
summary: `Sets 'smart-casing: false' for existing generators to preserve backwards compatibility.
|
|
@@ -934441,7 +934999,7 @@ async function updateGeneratorsYml5({ context: context3, files }) {
|
|
|
934441
934999
|
documentToWrite = `${schemaComment}
|
|
934442
935000
|
${documentToWrite}`;
|
|
934443
935001
|
}
|
|
934444
|
-
await (0,
|
|
935002
|
+
await (0, import_promises177.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
934445
935003
|
context3.logger.info(source_default.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
934446
935004
|
}
|
|
934447
935005
|
function setSmartCasingFalseIfNotConfigured(generator, context3) {
|
|
@@ -934582,7 +935140,7 @@ ${source_default.dim(migration23.summary)}`
|
|
|
934582
935140
|
}
|
|
934583
935141
|
|
|
934584
935142
|
// src/commands/upgrade/upgrade.ts
|
|
934585
|
-
var
|
|
935143
|
+
var import_promises178 = require("fs/promises");
|
|
934586
935144
|
|
|
934587
935145
|
// src/cwd.ts
|
|
934588
935146
|
var FERN_CWD_ENV_VAR = "FERN_CWD";
|
|
@@ -934909,7 +935467,7 @@ async function upgrade({
|
|
|
934909
935467
|
const newProjectConfig = produce(projectConfig2.rawConfig, (draft) => {
|
|
934910
935468
|
draft.version = resolvedTargetVersion;
|
|
934911
935469
|
});
|
|
934912
|
-
await (0,
|
|
935470
|
+
await (0, import_promises178.writeFile)(
|
|
934913
935471
|
projectConfig2._absolutePath,
|
|
934914
935472
|
ensureFinalNewline2(JSON.stringify(newProjectConfig, void 0, 2))
|
|
934915
935473
|
);
|
|
@@ -935011,7 +935569,7 @@ async function validateDocsBrokenLinks({
|
|
|
935011
935569
|
}
|
|
935012
935570
|
|
|
935013
935571
|
// src/commands/validate/validateMdx.ts
|
|
935014
|
-
var
|
|
935572
|
+
var import_fs38 = require("fs");
|
|
935015
935573
|
var import_gray_matter10 = __toESM(require_gray_matter(), 1);
|
|
935016
935574
|
var import_path95 = __toESM(require("path"), 1);
|
|
935017
935575
|
function calculateVisualColumn(text9, charIndex, tabWidth = 4) {
|
|
@@ -935087,7 +935645,7 @@ async function validateMdxFiles({
|
|
|
935087
935645
|
});
|
|
935088
935646
|
const filesToCheck = Array.from(new Set(allPages));
|
|
935089
935647
|
for (const filepath of filesToCheck) {
|
|
935090
|
-
const content5 = (0,
|
|
935648
|
+
const content5 = (0, import_fs38.readFileSync)(filepath, "utf-8");
|
|
935091
935649
|
try {
|
|
935092
935650
|
parseMarkdownToTree(content5);
|
|
935093
935651
|
} catch (error50) {
|
|
@@ -935534,7 +936092,7 @@ async function validateWorkspaces({
|
|
|
935534
936092
|
|
|
935535
936093
|
// src/commands/write-definition/writeDefinitionForWorkspaces.ts
|
|
935536
936094
|
init_lib6();
|
|
935537
|
-
var
|
|
936095
|
+
var import_promises179 = require("fs/promises");
|
|
935538
936096
|
var import_path96 = __toESM(require("path"), 1);
|
|
935539
936097
|
async function writeDefinitionForWorkspaces({
|
|
935540
936098
|
project,
|
|
@@ -935615,28 +936173,28 @@ async function writeFernDefinition({
|
|
|
935615
936173
|
return a4.localeCompare(b7);
|
|
935616
936174
|
};
|
|
935617
936175
|
if (await doesPathExist(absolutePathToOutputDirectory)) {
|
|
935618
|
-
await (0,
|
|
936176
|
+
await (0, import_promises179.rm)(absolutePathToOutputDirectory, { recursive: true });
|
|
935619
936177
|
}
|
|
935620
|
-
await (0,
|
|
935621
|
-
await (0,
|
|
936178
|
+
await (0, import_promises179.mkdir)(absolutePathToOutputDirectory, { recursive: true });
|
|
936179
|
+
await (0, import_promises179.writeFile)(
|
|
935622
936180
|
join8(absolutePathToOutputDirectory, RelativeFilePath2.of(ROOT_API_FILENAME)),
|
|
935623
936181
|
jsYaml.dump(definition3.rootApiFile.contents, { sortKeys })
|
|
935624
936182
|
);
|
|
935625
936183
|
for (const [relativePath, packageMarker] of Object.entries(definition3.packageMarkers)) {
|
|
935626
936184
|
const absoluteFilepath = join8(absolutePathToOutputDirectory, RelativeFilePath2.of(relativePath));
|
|
935627
|
-
await (0,
|
|
935628
|
-
await (0,
|
|
936185
|
+
await (0, import_promises179.mkdir)(dirname6(absoluteFilepath), { recursive: true });
|
|
936186
|
+
await (0, import_promises179.writeFile)(absoluteFilepath, jsYaml.dump(packageMarker.contents, { sortKeys }));
|
|
935629
936187
|
}
|
|
935630
936188
|
for (const [relativePath, definitionFile] of Object.entries(definition3.namedDefinitionFiles)) {
|
|
935631
936189
|
const absoluteFilepath = join8(absolutePathToOutputDirectory, RelativeFilePath2.of(relativePath));
|
|
935632
|
-
await (0,
|
|
935633
|
-
await (0,
|
|
936190
|
+
await (0, import_promises179.mkdir)(dirname6(absoluteFilepath), { recursive: true });
|
|
936191
|
+
await (0, import_promises179.writeFile)(absoluteFilepath, jsYaml.dump(definitionFile.contents, { sortKeys }));
|
|
935634
936192
|
}
|
|
935635
936193
|
}
|
|
935636
936194
|
|
|
935637
936195
|
// src/commands/write-docs-definition/writeDocsDefinitionForProject.ts
|
|
935638
936196
|
init_lib6();
|
|
935639
|
-
var
|
|
936197
|
+
var import_promises180 = require("fs/promises");
|
|
935640
936198
|
async function writeDocsDefinitionForProject({
|
|
935641
936199
|
project,
|
|
935642
936200
|
outputPath,
|
|
@@ -935668,7 +936226,7 @@ async function writeDocsDefinitionForProject({
|
|
|
935668
936226
|
targetAudiences: docsWorkspace.config.instances[0]?.audiences ? Array.isArray(docsWorkspace.config.instances[0].audiences) ? docsWorkspace.config.instances[0].audiences : [docsWorkspace.config.instances[0].audiences] : void 0
|
|
935669
936227
|
});
|
|
935670
936228
|
const docsDefinition = await docsResolver.resolve();
|
|
935671
|
-
await (0,
|
|
936229
|
+
await (0, import_promises180.writeFile)(AbsoluteFilePath2.of(outputPath), JSON.stringify(docsDefinition, null, 2));
|
|
935672
936230
|
context3.logger.info(source_default.green(`Docs definition written to ${outputPath}`));
|
|
935673
936231
|
});
|
|
935674
936232
|
}
|
|
@@ -935676,8 +936234,8 @@ async function writeDocsDefinitionForProject({
|
|
|
935676
936234
|
// src/commands/write-translation/writeTranslationForProject.ts
|
|
935677
936235
|
init_lib6();
|
|
935678
936236
|
var import_cli_progress2 = __toESM(require_cli_progress(), 1);
|
|
935679
|
-
var
|
|
935680
|
-
var
|
|
936237
|
+
var import_fs41 = require("fs");
|
|
936238
|
+
var import_promises184 = require("fs/promises");
|
|
935681
936239
|
var import_is_ci3 = __toESM(require_is_ci(), 1);
|
|
935682
936240
|
var import_path99 = __toESM(require("path"), 1);
|
|
935683
936241
|
|
|
@@ -936170,7 +936728,7 @@ function shouldProcessFile(filePath, stub) {
|
|
|
936170
936728
|
|
|
936171
936729
|
// src/commands/write-translation/docs-config-utils.ts
|
|
936172
936730
|
init_lib6();
|
|
936173
|
-
var
|
|
936731
|
+
var import_promises181 = require("fs/promises");
|
|
936174
936732
|
|
|
936175
936733
|
// src/commands/write-translation/url-utils.ts
|
|
936176
936734
|
function addLanguageSuffixToUrl(url3, language) {
|
|
@@ -936327,7 +936885,7 @@ async function createLanguageSpecificDocsConfig({
|
|
|
936327
936885
|
stub = false
|
|
936328
936886
|
}) {
|
|
936329
936887
|
try {
|
|
936330
|
-
const originalConfigContent = await (0,
|
|
936888
|
+
const originalConfigContent = await (0, import_promises181.readFile)(originalDocsConfigPath, "utf-8");
|
|
936331
936889
|
const transformation = {
|
|
936332
936890
|
filePath: DOCS_CONFIGURATION_FILENAME,
|
|
936333
936891
|
language,
|
|
@@ -936341,7 +936899,7 @@ async function createLanguageSpecificDocsConfig({
|
|
|
936341
936899
|
const modifiedConfigContent = jsYaml.dump(modifiedConfig, {
|
|
936342
936900
|
sortKeys: false
|
|
936343
936901
|
});
|
|
936344
|
-
await (0,
|
|
936902
|
+
await (0, import_promises181.writeFile)(modifiedConfigPath, modifiedConfigContent, "utf-8");
|
|
936345
936903
|
context3.logger.debug(`Created language-specific docs config: ${modifiedConfigPath}`);
|
|
936346
936904
|
} catch (error50) {
|
|
936347
936905
|
if (error50 instanceof Error && error50.message.includes("403")) {
|
|
@@ -936353,19 +936911,19 @@ async function createLanguageSpecificDocsConfig({
|
|
|
936353
936911
|
|
|
936354
936912
|
// src/commands/write-translation/file-collection-utils.ts
|
|
936355
936913
|
init_lib6();
|
|
936356
|
-
var
|
|
936357
|
-
var
|
|
936914
|
+
var import_fs39 = require("fs");
|
|
936915
|
+
var import_promises182 = require("fs/promises");
|
|
936358
936916
|
var import_path97 = __toESM(require("path"), 1);
|
|
936359
936917
|
async function collectFiles(baseDirectory, relativeBase) {
|
|
936360
936918
|
const discoveredFiles = {};
|
|
936361
|
-
const entries23 = await (0,
|
|
936919
|
+
const entries23 = await (0, import_promises182.readdir)(baseDirectory);
|
|
936362
936920
|
for (const entry of entries23) {
|
|
936363
936921
|
if (entry === "translations") {
|
|
936364
936922
|
continue;
|
|
936365
936923
|
}
|
|
936366
936924
|
const fullPath = import_path97.default.join(baseDirectory, entry);
|
|
936367
936925
|
const relativePath = relativeBase ? join8(relativeBase, RelativeFilePath2.of(entry)) : RelativeFilePath2.of(entry);
|
|
936368
|
-
const stat7 = (0,
|
|
936926
|
+
const stat7 = (0, import_fs39.statSync)(fullPath);
|
|
936369
936927
|
if (stat7.isDirectory()) {
|
|
936370
936928
|
const subdirectoryFiles = await collectFiles(fullPath, relativePath);
|
|
936371
936929
|
for (const [subPath, subRelativePath] of Object.entries(subdirectoryFiles)) {
|
|
@@ -936380,19 +936938,19 @@ async function collectFiles(baseDirectory, relativeBase) {
|
|
|
936380
936938
|
|
|
936381
936939
|
// src/commands/write-translation/hash-utils.ts
|
|
936382
936940
|
var import_crypto13 = require("crypto");
|
|
936383
|
-
var
|
|
936384
|
-
var
|
|
936941
|
+
var import_fs40 = require("fs");
|
|
936942
|
+
var import_promises183 = require("fs/promises");
|
|
936385
936943
|
var import_path98 = __toESM(require("path"), 1);
|
|
936386
936944
|
function calculateContentHash(content5) {
|
|
936387
936945
|
return (0, import_crypto13.createHash)("sha256").update(content5, "utf-8").digest("hex");
|
|
936388
936946
|
}
|
|
936389
936947
|
async function loadHashMappings(translationsDirectory) {
|
|
936390
936948
|
const hashesFilePath = import_path98.default.join(translationsDirectory, "hashes");
|
|
936391
|
-
if (!(0,
|
|
936949
|
+
if (!(0, import_fs40.existsSync)(hashesFilePath)) {
|
|
936392
936950
|
return {};
|
|
936393
936951
|
}
|
|
936394
936952
|
try {
|
|
936395
|
-
const hashesContent = await (0,
|
|
936953
|
+
const hashesContent = await (0, import_promises183.readFile)(hashesFilePath, "utf-8");
|
|
936396
936954
|
const parsed = JSON.parse(hashesContent);
|
|
936397
936955
|
const { _comment, ...hashMappings } = parsed;
|
|
936398
936956
|
return hashMappings;
|
|
@@ -936413,11 +936971,11 @@ async function saveHashMappings(translationsDirectory, hashMappings) {
|
|
|
936413
936971
|
_comment: "This file is auto-generated by Fern to track source file changes for translation purposes. Do not edit manually - it will be overwritten on the next translation update.",
|
|
936414
936972
|
...sortedMappings
|
|
936415
936973
|
};
|
|
936416
|
-
await (0,
|
|
936974
|
+
await (0, import_promises183.writeFile)(hashesFilePath, JSON.stringify(fileContent, null, 2), "utf-8");
|
|
936417
936975
|
}
|
|
936418
936976
|
async function hasFileChanged(filePath, relativePath, previousHashes) {
|
|
936419
936977
|
try {
|
|
936420
|
-
const content5 = await (0,
|
|
936978
|
+
const content5 = await (0, import_promises183.readFile)(filePath, "utf-8");
|
|
936421
936979
|
const currentHash = calculateContentHash(content5);
|
|
936422
936980
|
const previousHash = previousHashes[relativePath];
|
|
936423
936981
|
return currentHash !== previousHash;
|
|
@@ -936471,22 +937029,22 @@ async function writeTranslationForProject({
|
|
|
936471
937029
|
code: CliError.Code.InternalError
|
|
936472
937030
|
});
|
|
936473
937031
|
}
|
|
936474
|
-
if (!(0,
|
|
937032
|
+
if (!(0, import_fs41.existsSync)(translationsDirectory)) {
|
|
936475
937033
|
context3.logger.debug(`Creating translations directory at: ${translationsDirectory}`);
|
|
936476
|
-
await (0,
|
|
937034
|
+
await (0, import_promises184.mkdir)(translationsDirectory, { recursive: true });
|
|
936477
937035
|
}
|
|
936478
937036
|
const languageStats = {};
|
|
936479
937037
|
const targetLanguages = languages.filter((lang) => lang !== sourceLanguage);
|
|
936480
937038
|
const originalDocsConfigPath = join8(fernDirectory, RelativeFilePath2.of(DOCS_CONFIGURATION_FILENAME));
|
|
936481
|
-
const hasDocsConfig = (0,
|
|
937039
|
+
const hasDocsConfig = (0, import_fs41.existsSync)(originalDocsConfigPath);
|
|
936482
937040
|
for (const language of targetLanguages) {
|
|
936483
937041
|
const languageDirectory = join8(
|
|
936484
937042
|
translationsDirectory,
|
|
936485
937043
|
RelativeFilePath2.of(language),
|
|
936486
937044
|
RelativeFilePath2.of("fern")
|
|
936487
937045
|
);
|
|
936488
|
-
if (!(0,
|
|
936489
|
-
await (0,
|
|
937046
|
+
if (!(0, import_fs41.existsSync)(languageDirectory)) {
|
|
937047
|
+
await (0, import_promises184.mkdir)(languageDirectory, { recursive: true });
|
|
936490
937048
|
}
|
|
936491
937049
|
languageStats[language] = {
|
|
936492
937050
|
filesProcessed: 0,
|
|
@@ -936588,7 +937146,7 @@ async function writeTranslationForProject({
|
|
|
936588
937146
|
`[COMPLETED] ${DOCS_CONFIGURATION_FILENAME} -> ${language}/${DOCS_CONFIGURATION_FILENAME}`
|
|
936589
937147
|
);
|
|
936590
937148
|
}
|
|
936591
|
-
const originalConfigContent = await (0,
|
|
937149
|
+
const originalConfigContent = await (0, import_promises184.readFile)(originalDocsConfigPath, "utf-8");
|
|
936592
937150
|
await updateAndSaveHashForFile(
|
|
936593
937151
|
translationsDirectory,
|
|
936594
937152
|
hashMappings,
|
|
@@ -936633,7 +937191,7 @@ async function writeTranslationForProject({
|
|
|
936633
937191
|
continue;
|
|
936634
937192
|
}
|
|
936635
937193
|
cliContext.logger.debug(`[PROCESSING] ${relativePath} (detected changes)`);
|
|
936636
|
-
const originalContent = await (0,
|
|
937194
|
+
const originalContent = await (0, import_promises184.readFile)(filePath, "utf-8");
|
|
936637
937195
|
await updateAndSaveHashForFile(translationsDirectory, hashMappings, relativePath, originalContent);
|
|
936638
937196
|
const sourceStats = languageStats[sourceLanguage];
|
|
936639
937197
|
if (sourceStats) {
|
|
@@ -936657,8 +937215,8 @@ async function writeTranslationForProject({
|
|
|
936657
937215
|
);
|
|
936658
937216
|
const destPath = join8(languageDirectory, relativePath);
|
|
936659
937217
|
const destDir = import_path99.default.dirname(destPath);
|
|
936660
|
-
if (!(0,
|
|
936661
|
-
await (0,
|
|
937218
|
+
if (!(0, import_fs41.existsSync)(destDir)) {
|
|
937219
|
+
await (0, import_promises184.mkdir)(destDir, { recursive: true });
|
|
936662
937220
|
}
|
|
936663
937221
|
const transformation = {
|
|
936664
937222
|
filePath: relativePath,
|
|
@@ -936671,7 +937229,7 @@ async function writeTranslationForProject({
|
|
|
936671
937229
|
cliContext,
|
|
936672
937230
|
stub
|
|
936673
937231
|
});
|
|
936674
|
-
await (0,
|
|
937232
|
+
await (0, import_promises184.writeFile)(destPath, transformedContent, "utf-8");
|
|
936675
937233
|
const languageStatsForLang = languageStats[language];
|
|
936676
937234
|
if (languageStatsForLang) {
|
|
936677
937235
|
languageStatsForLang.filesProcessed++;
|
|
@@ -936701,10 +937259,10 @@ async function writeTranslationForProject({
|
|
|
936701
937259
|
);
|
|
936702
937260
|
const destPath = join8(languageDirectory, relativePath);
|
|
936703
937261
|
const destDir = import_path99.default.dirname(destPath);
|
|
936704
|
-
if (!(0,
|
|
936705
|
-
await (0,
|
|
937262
|
+
if (!(0, import_fs41.existsSync)(destDir)) {
|
|
937263
|
+
await (0, import_promises184.mkdir)(destDir, { recursive: true });
|
|
936706
937264
|
}
|
|
936707
|
-
await (0,
|
|
937265
|
+
await (0, import_promises184.copyFile)(filePath, destPath);
|
|
936708
937266
|
assetsCopied++;
|
|
936709
937267
|
cliContext.logger.debug(`[ASSET COPIED] ${relativePath} -> ${language}/${relativePath}`);
|
|
936710
937268
|
}
|
|
@@ -938845,13 +939403,13 @@ function addAutomationsGenerateCommand(cli, cliContext) {
|
|
|
938845
939403
|
// hidden
|
|
938846
939404
|
(yargs) => yargs.option("api", {
|
|
938847
939405
|
type: "string",
|
|
938848
|
-
description: "
|
|
939406
|
+
description: "Filter to a specific API in a multi-API repo (e.g. 'foo' for fern/apis/foo/). Omit to fan out across every API in the project."
|
|
938849
939407
|
}).option("group", {
|
|
938850
939408
|
type: "string",
|
|
938851
|
-
description: "
|
|
939409
|
+
description: "Filter to a specific generator group (e.g. 'sdk'). Omit to fan out across every group. The default-group field in generators.yml is intentionally ignored."
|
|
938852
939410
|
}).option("generator", {
|
|
938853
939411
|
type: "string",
|
|
938854
|
-
description: "Target a specific generator by 0-based index (e.g. '0', '1') or by name.
|
|
939412
|
+
description: "Target a specific generator by 0-based index (e.g. '0', '1') or by name. When targeting an opted-out generator by index, the command rejects with an error rather than silently skipping. Omit to fan out across every eligible generator in the selected APIs and groups."
|
|
938855
939413
|
}).option("version", {
|
|
938856
939414
|
type: "string",
|
|
938857
939415
|
description: "Version for generated packages. Use 'AUTO' for AI-based semantic versioning that analyzes the diff and determines MAJOR/MINOR/PATCH automatically."
|
|
@@ -938859,39 +939417,21 @@ function addAutomationsGenerateCommand(cli, cliContext) {
|
|
|
938859
939417
|
boolean: true,
|
|
938860
939418
|
default: false,
|
|
938861
939419
|
description: "Enable GitHub automerge on generated PRs. Automerge is skipped when breaking changes (MAJOR bump) are detected, regardless of this flag."
|
|
939420
|
+
}).option("json-file-output", {
|
|
939421
|
+
type: "string",
|
|
939422
|
+
description: "Write a JSON summary of per-generator results to the given path. CI-neutral companion to the markdown summary auto-written to $GITHUB_STEP_SUMMARY."
|
|
938862
939423
|
}),
|
|
938863
939424
|
async (argv) => {
|
|
938864
|
-
|
|
938865
|
-
|
|
938866
|
-
|
|
938867
|
-
|
|
938868
|
-
|
|
938869
|
-
|
|
938870
|
-
}),
|
|
938871
|
-
cliContext,
|
|
939425
|
+
await executeAutomationsGenerate({
|
|
939426
|
+
cliContext,
|
|
939427
|
+
options: {
|
|
939428
|
+
api: argv.api,
|
|
939429
|
+
group: argv.group,
|
|
939430
|
+
generator: argv.generator,
|
|
938872
939431
|
version: argv.version,
|
|
938873
|
-
|
|
938874
|
-
|
|
938875
|
-
|
|
938876
|
-
shouldLogS3Url: false,
|
|
938877
|
-
keepDocker: false,
|
|
938878
|
-
useLocalDocker: false,
|
|
938879
|
-
preview: false,
|
|
938880
|
-
mode: void 0,
|
|
938881
|
-
force: true,
|
|
938882
|
-
runner: void 0,
|
|
938883
|
-
inspect: false,
|
|
938884
|
-
lfsOverride: void 0,
|
|
938885
|
-
fernignorePath: void 0,
|
|
938886
|
-
skipFernignore: false,
|
|
938887
|
-
dynamicIrOnly: false,
|
|
938888
|
-
outputDir: void 0,
|
|
938889
|
-
noReplay: false,
|
|
938890
|
-
retryRateLimited: false,
|
|
938891
|
-
requireEnvVars: false,
|
|
938892
|
-
automationMode: true,
|
|
938893
|
-
autoMerge: argv["auto-merge"]
|
|
938894
|
-
});
|
|
939432
|
+
autoMerge: argv["auto-merge"],
|
|
939433
|
+
jsonOutputPath: argv["json-file-output"]
|
|
939434
|
+
}
|
|
938895
939435
|
});
|
|
938896
939436
|
}
|
|
938897
939437
|
);
|