@fern-api/generator-cli 0.9.25 → 0.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +12 -1
- package/dist/cli.js +525 -70
- package/package.json +2 -2
package/dist/api.js
CHANGED
|
@@ -6362,6 +6362,15 @@ async function cloneRepository({ githubRepository, installationToken, targetDire
|
|
|
6362
6362
|
});
|
|
6363
6363
|
}
|
|
6364
6364
|
|
|
6365
|
+
// ../commons/github/lib/getGithubApiBaseUrl.js
|
|
6366
|
+
function getGithubApiBaseUrl(repositoryUri) {
|
|
6367
|
+
const { remote } = parseRepository(repositoryUri);
|
|
6368
|
+
if (remote === DEFAULT_REMOTE) {
|
|
6369
|
+
return void 0;
|
|
6370
|
+
}
|
|
6371
|
+
return `https://${remote}/api/v3`;
|
|
6372
|
+
}
|
|
6373
|
+
|
|
6365
6374
|
// src/readme/ReadmeGenerator.ts
|
|
6366
6375
|
var import_compat = require("es-toolkit/compat");
|
|
6367
6376
|
var import_string2 = require("es-toolkit/string");
|
|
@@ -10069,8 +10078,10 @@ var GitHub = class {
|
|
|
10069
10078
|
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
10070
10079
|
await repository.commit("SDK Generation");
|
|
10071
10080
|
await repository.push();
|
|
10081
|
+
const apiBaseUrl = getGithubApiBaseUrl(this.githubConfig.uri);
|
|
10072
10082
|
const octokit = new import_rest.Octokit({
|
|
10073
|
-
auth: this.githubConfig.token
|
|
10083
|
+
auth: this.githubConfig.token,
|
|
10084
|
+
...apiBaseUrl != null ? { baseUrl: apiBaseUrl } : {}
|
|
10074
10085
|
});
|
|
10075
10086
|
const parsedRepo = parseRepository(this.githubConfig.uri);
|
|
10076
10087
|
const { owner, repo } = parsedRepo;
|
package/dist/cli.js
CHANGED
|
@@ -4186,10 +4186,10 @@ var require_tmp_promise = __commonJS({
|
|
|
4186
4186
|
"../../node_modules/.pnpm/tmp-promise@3.0.3/node_modules/tmp-promise/index.js"(exports2, module2) {
|
|
4187
4187
|
"use strict";
|
|
4188
4188
|
var { promisify } = require("util");
|
|
4189
|
-
var
|
|
4190
|
-
module2.exports.fileSync =
|
|
4189
|
+
var tmp4 = require_tmp();
|
|
4190
|
+
module2.exports.fileSync = tmp4.fileSync;
|
|
4191
4191
|
var fileWithOptions = promisify(
|
|
4192
|
-
(options, cb) =>
|
|
4192
|
+
(options, cb) => tmp4.file(
|
|
4193
4193
|
options,
|
|
4194
4194
|
(err, path5, fd, cleanup) => err ? cb(err) : cb(void 0, { path: path5, fd, cleanup: promisify(cleanup) })
|
|
4195
4195
|
)
|
|
@@ -4203,9 +4203,9 @@ var require_tmp_promise = __commonJS({
|
|
|
4203
4203
|
await cleanup();
|
|
4204
4204
|
}
|
|
4205
4205
|
};
|
|
4206
|
-
module2.exports.dirSync =
|
|
4206
|
+
module2.exports.dirSync = tmp4.dirSync;
|
|
4207
4207
|
var dirWithOptions = promisify(
|
|
4208
|
-
(options, cb) =>
|
|
4208
|
+
(options, cb) => tmp4.dir(
|
|
4209
4209
|
options,
|
|
4210
4210
|
(err, path5, cleanup) => err ? cb(err) : cb(void 0, { path: path5, cleanup: promisify(cleanup) })
|
|
4211
4211
|
)
|
|
@@ -4219,10 +4219,10 @@ var require_tmp_promise = __commonJS({
|
|
|
4219
4219
|
await cleanup();
|
|
4220
4220
|
}
|
|
4221
4221
|
};
|
|
4222
|
-
module2.exports.tmpNameSync =
|
|
4223
|
-
module2.exports.tmpName = promisify(
|
|
4224
|
-
module2.exports.tmpdir =
|
|
4225
|
-
module2.exports.setGracefulCleanup =
|
|
4222
|
+
module2.exports.tmpNameSync = tmp4.tmpNameSync;
|
|
4223
|
+
module2.exports.tmpName = promisify(tmp4.tmpName);
|
|
4224
|
+
module2.exports.tmpdir = tmp4.tmpdir;
|
|
4225
|
+
module2.exports.setGracefulCleanup = tmp4.setGracefulCleanup;
|
|
4226
4226
|
}
|
|
4227
4227
|
});
|
|
4228
4228
|
|
|
@@ -7035,15 +7035,15 @@ var require_sync = __commonJS({
|
|
|
7035
7035
|
var { readdirSync: readdirSync2, statSync: statSync4 } = require("fs");
|
|
7036
7036
|
module2.exports = function(start, callback) {
|
|
7037
7037
|
let dir = resolve8(".", start);
|
|
7038
|
-
let
|
|
7038
|
+
let tmp4, stats = statSync4(dir);
|
|
7039
7039
|
if (!stats.isDirectory()) {
|
|
7040
7040
|
dir = dirname5(dir);
|
|
7041
7041
|
}
|
|
7042
7042
|
while (true) {
|
|
7043
|
-
|
|
7044
|
-
if (
|
|
7045
|
-
dir = dirname5(
|
|
7046
|
-
if (
|
|
7043
|
+
tmp4 = callback(dir, readdirSync2(dir));
|
|
7044
|
+
if (tmp4) return resolve8(dir, tmp4);
|
|
7045
|
+
dir = dirname5(tmp4 = dir);
|
|
7046
|
+
if (tmp4 === dir) break;
|
|
7047
7047
|
}
|
|
7048
7048
|
};
|
|
7049
7049
|
}
|
|
@@ -7078,7 +7078,7 @@ var require_require_directory = __commonJS({
|
|
|
7078
7078
|
"../../node_modules/.pnpm/require-directory@2.1.1/node_modules/require-directory/index.js"(exports2, module2) {
|
|
7079
7079
|
"use strict";
|
|
7080
7080
|
var fs3 = require("fs");
|
|
7081
|
-
var
|
|
7081
|
+
var join16 = require("path").join;
|
|
7082
7082
|
var resolve8 = require("path").resolve;
|
|
7083
7083
|
var dirname5 = require("path").dirname;
|
|
7084
7084
|
var defaultOptions2 = {
|
|
@@ -7115,7 +7115,7 @@ var require_require_directory = __commonJS({
|
|
|
7115
7115
|
}
|
|
7116
7116
|
path5 = !path5 ? dirname5(m.filename) : resolve8(dirname5(m.filename), path5);
|
|
7117
7117
|
fs3.readdirSync(path5).forEach(function(filename) {
|
|
7118
|
-
var joined =
|
|
7118
|
+
var joined = join16(path5, filename), files, key, obj;
|
|
7119
7119
|
if (fs3.statSync(joined).isDirectory() && options.recurse) {
|
|
7120
7120
|
files = requireDirectory(m, joined, options);
|
|
7121
7121
|
if (Object.keys(files).length) {
|
|
@@ -22126,7 +22126,7 @@ var init_diff3 = __esm({
|
|
|
22126
22126
|
}
|
|
22127
22127
|
});
|
|
22128
22128
|
|
|
22129
|
-
// ../../node_modules/.pnpm/@fern-api+replay@0.
|
|
22129
|
+
// ../../node_modules/.pnpm/@fern-api+replay@0.15.0/node_modules/@fern-api/replay/dist/index.js
|
|
22130
22130
|
var dist_exports = {};
|
|
22131
22131
|
__export(dist_exports, {
|
|
22132
22132
|
CREDENTIAL_PATTERNS: () => CREDENTIAL_PATTERNS,
|
|
@@ -22939,17 +22939,17 @@ function overlayRegions(currentGenLines, locInCurrentGen, workingTreeLines, locI
|
|
|
22939
22939
|
}
|
|
22940
22940
|
async function unifiedDiff(beforeContent, afterContent, filePath) {
|
|
22941
22941
|
if (beforeContent === afterContent) return "";
|
|
22942
|
-
const
|
|
22942
|
+
const tmp4 = await (0, import_promises6.mkdtemp)((0, import_path11.join)((0, import_os3.tmpdir)(), "fern-replay-pp-"));
|
|
22943
22943
|
try {
|
|
22944
|
-
const beforePath = (0, import_path11.join)(
|
|
22945
|
-
const afterPath = (0, import_path11.join)(
|
|
22944
|
+
const beforePath = (0, import_path11.join)(tmp4, "before");
|
|
22945
|
+
const afterPath = (0, import_path11.join)(tmp4, "after");
|
|
22946
22946
|
await (0, import_promises6.writeFile)(beforePath, beforeContent, "utf-8");
|
|
22947
22947
|
await (0, import_promises6.writeFile)(afterPath, afterContent, "utf-8");
|
|
22948
22948
|
const raw = await runGitDiffNoIndex(beforePath, afterPath);
|
|
22949
22949
|
if (!raw.trim()) return "";
|
|
22950
22950
|
return rewriteDiffHeaders(raw, filePath);
|
|
22951
22951
|
} finally {
|
|
22952
|
-
await (0, import_promises6.rm)(
|
|
22952
|
+
await (0, import_promises6.rm)(tmp4, { recursive: true, force: true });
|
|
22953
22953
|
}
|
|
22954
22954
|
}
|
|
22955
22955
|
function runGitDiffNoIndex(beforePath, afterPath) {
|
|
@@ -23630,7 +23630,7 @@ function status(outputDir) {
|
|
|
23630
23630
|
}
|
|
23631
23631
|
var import_promises3, import_os, import_path7, import_fs6, import_path8, import_yaml, import_crypto, import_promises4, import_os2, import_path9, import_fs7, import_promises5, import_path10, import_promises6, import_os3, import_path11, import_child_process3, import_crypto2, import_fs8, import_path12, import_yaml2, import_crypto3, import_fs9, import_path13, import_fs10, import_promises7, import_path14, __defProp3, __getOwnPropNames3, __esm3, __export3, GitClient_exports, GitClient, init_GitClient, HybridReconstruction_exports, init_HybridReconstruction, PatchApplyTheirs_exports, init_PatchApplyTheirs, CREDENTIAL_PATTERNS, SENSITIVE_FILE_PATTERNS, FERN_BOT_NAME, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_SUPPORT_NAMES, LOCKFILE_HEADER, LockfileNotFoundError, LockfileManager, CONFLICT_OPENER, CONFLICT_SEPARATOR, CONFLICT_CLOSER, BINARY_EXTENSIONS, ReplayApplicator, INFRASTRUCTURE_FILES, ReplayDetector, ReplayCommitter, ReplayService, FernignoreMigrator, REPLAY_FERNIGNORE_ENTRIES, GITATTRIBUTES_ENTRIES, EMPTY_RESULT;
|
|
23632
23632
|
var init_dist3 = __esm({
|
|
23633
|
-
"../../node_modules/.pnpm/@fern-api+replay@0.
|
|
23633
|
+
"../../node_modules/.pnpm/@fern-api+replay@0.15.0/node_modules/@fern-api/replay/dist/index.js"() {
|
|
23634
23634
|
"use strict";
|
|
23635
23635
|
init_esm4();
|
|
23636
23636
|
import_promises3 = require("fs/promises");
|
|
@@ -26243,6 +26243,66 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26243
26243
|
}
|
|
26244
26244
|
return snapshot;
|
|
26245
26245
|
}
|
|
26246
|
+
/**
|
|
26247
|
+
* FER-10203: returns true when a `[fern-autoversion]` commit between
|
|
26248
|
+
* `fromSha` and `toSha` touched any of the patch's `files`. Re-classifies
|
|
26249
|
+
* each grep match via `isGenerationCommit` so a customer commit that
|
|
26250
|
+
* merely quotes the marker in its body doesn't false-positive.
|
|
26251
|
+
*/
|
|
26252
|
+
async hasAutoversionContamination(fromSha, toSha, files) {
|
|
26253
|
+
if (files.length === 0) return false;
|
|
26254
|
+
const log = await this.git.exec([
|
|
26255
|
+
"log",
|
|
26256
|
+
`${fromSha}..${toSha}`,
|
|
26257
|
+
"--grep=\\[fern-autoversion\\]",
|
|
26258
|
+
"--extended-regexp",
|
|
26259
|
+
"--format=%H%x09%aN%x09%ae%x09%s",
|
|
26260
|
+
"--",
|
|
26261
|
+
...files
|
|
26262
|
+
]).catch(() => "");
|
|
26263
|
+
if (!log.trim()) return false;
|
|
26264
|
+
for (const line of log.trim().split("\n")) {
|
|
26265
|
+
const [sha, authorName, authorEmail, message] = line.split(" ");
|
|
26266
|
+
if (sha == null) continue;
|
|
26267
|
+
if (isGenerationCommit({
|
|
26268
|
+
sha,
|
|
26269
|
+
authorName: authorName ?? "",
|
|
26270
|
+
authorEmail: authorEmail ?? "",
|
|
26271
|
+
message: message ?? ""
|
|
26272
|
+
})) {
|
|
26273
|
+
return true;
|
|
26274
|
+
}
|
|
26275
|
+
}
|
|
26276
|
+
return false;
|
|
26277
|
+
}
|
|
26278
|
+
/**
|
|
26279
|
+
* FER-10203: rebuild patch_content from `theirs_snapshot` (captured at
|
|
26280
|
+
* detection time, predates pipeline content) rather than a HEAD-relative
|
|
26281
|
+
* diff. Returns `null` when snapshot is missing or doesn't cover every
|
|
26282
|
+
* file in `patch.files` — caller leaves the patch unchanged.
|
|
26283
|
+
*/
|
|
26284
|
+
async computeSnapshotBasedPatchDiff(patch, currentGen) {
|
|
26285
|
+
if (!patch.theirs_snapshot) return null;
|
|
26286
|
+
if (Object.keys(patch.theirs_snapshot).length === 0) return null;
|
|
26287
|
+
for (const file of patch.files) {
|
|
26288
|
+
if (patch.theirs_snapshot[file] == null) return null;
|
|
26289
|
+
}
|
|
26290
|
+
const fragments = [];
|
|
26291
|
+
for (const file of patch.files) {
|
|
26292
|
+
const theirsContent = patch.theirs_snapshot[file];
|
|
26293
|
+
const oursContent = await this.git.showFile(currentGen, file).catch(() => null);
|
|
26294
|
+
if (oursContent == null) {
|
|
26295
|
+
fragments.push(synthesizeNewFileDiff(file, theirsContent));
|
|
26296
|
+
continue;
|
|
26297
|
+
}
|
|
26298
|
+
if (oursContent === theirsContent) continue;
|
|
26299
|
+
const fileDiff = await unifiedDiff(oursContent, theirsContent, file);
|
|
26300
|
+
if (fileDiff.trim()) {
|
|
26301
|
+
fragments.push(fileDiff);
|
|
26302
|
+
}
|
|
26303
|
+
}
|
|
26304
|
+
return fragments.join("");
|
|
26305
|
+
}
|
|
26246
26306
|
/**
|
|
26247
26307
|
* Read THEIRS snapshot from a git tree-ish (commit, branch, or tree).
|
|
26248
26308
|
* Used when the diff that produced `patch_content` was relative to that
|
|
@@ -26508,6 +26568,41 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26508
26568
|
}
|
|
26509
26569
|
if (patch.base_generation === currentGen) {
|
|
26510
26570
|
try {
|
|
26571
|
+
const contaminated = await this.hasAutoversionContamination(
|
|
26572
|
+
currentGen,
|
|
26573
|
+
"HEAD",
|
|
26574
|
+
patch.files
|
|
26575
|
+
);
|
|
26576
|
+
if (contaminated) {
|
|
26577
|
+
const snapshotDiff = await this.computeSnapshotBasedPatchDiff(
|
|
26578
|
+
patch,
|
|
26579
|
+
currentGen
|
|
26580
|
+
);
|
|
26581
|
+
if (snapshotDiff === null) continue;
|
|
26582
|
+
if (!snapshotDiff.trim()) {
|
|
26583
|
+
if (await allPatchFilesUserOwned(patch)) continue;
|
|
26584
|
+
this.lockManager.removePatch(patch.id);
|
|
26585
|
+
contentRefreshed++;
|
|
26586
|
+
continue;
|
|
26587
|
+
}
|
|
26588
|
+
const snapHasStaleMarkers = snapshotDiff.split("\n").some(
|
|
26589
|
+
(l) => l.startsWith("+<<<<<<< Generated") || l.startsWith("+>>>>>>> Your customization")
|
|
26590
|
+
);
|
|
26591
|
+
if (snapHasStaleMarkers) continue;
|
|
26592
|
+
const isProtectedSnap = patch.files.some(
|
|
26593
|
+
(file) => file === ".fernignore" || fernignorePatterns.some((p2) => file === p2 || minimatch(file, p2))
|
|
26594
|
+
);
|
|
26595
|
+
if (isProtectedSnap) continue;
|
|
26596
|
+
const snapHash = this.detector.computeContentHash(snapshotDiff);
|
|
26597
|
+
if (snapHash !== patch.content_hash) {
|
|
26598
|
+
this.lockManager.updatePatch(patch.id, {
|
|
26599
|
+
patch_content: snapshotDiff,
|
|
26600
|
+
content_hash: snapHash
|
|
26601
|
+
});
|
|
26602
|
+
contentRefreshed++;
|
|
26603
|
+
}
|
|
26604
|
+
continue;
|
|
26605
|
+
}
|
|
26511
26606
|
const ppResult = await computePerPatchDiffWithFallback(
|
|
26512
26607
|
patch,
|
|
26513
26608
|
(f) => this.git.showFile(currentGen, f),
|
|
@@ -26559,6 +26654,42 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26559
26654
|
try {
|
|
26560
26655
|
const markerFiles = await this.git.exec(["grep", "-l", "<<<<<<< Generated", "HEAD", "--", ...patch.files]).catch(() => "");
|
|
26561
26656
|
if (markerFiles.trim()) continue;
|
|
26657
|
+
const contaminated = await this.hasAutoversionContamination(
|
|
26658
|
+
currentGen,
|
|
26659
|
+
"HEAD",
|
|
26660
|
+
patch.files
|
|
26661
|
+
);
|
|
26662
|
+
if (contaminated) {
|
|
26663
|
+
const snapshotDiff = await this.computeSnapshotBasedPatchDiff(
|
|
26664
|
+
patch,
|
|
26665
|
+
currentGen
|
|
26666
|
+
);
|
|
26667
|
+
if (snapshotDiff === null) continue;
|
|
26668
|
+
if (!snapshotDiff.trim()) {
|
|
26669
|
+
if (await allPatchFilesUserOwned(patch)) {
|
|
26670
|
+
try {
|
|
26671
|
+
this.lockManager.updatePatch(patch.id, { base_generation: currentGen });
|
|
26672
|
+
} catch {
|
|
26673
|
+
}
|
|
26674
|
+
continue;
|
|
26675
|
+
}
|
|
26676
|
+
this.lockManager.removePatch(patch.id);
|
|
26677
|
+
conflictAbsorbed++;
|
|
26678
|
+
continue;
|
|
26679
|
+
}
|
|
26680
|
+
const snapHasStaleMarkers = snapshotDiff.split("\n").some(
|
|
26681
|
+
(l) => l.startsWith("+<<<<<<< Generated") || l.startsWith("+>>>>>>> Your customization")
|
|
26682
|
+
);
|
|
26683
|
+
if (snapHasStaleMarkers) continue;
|
|
26684
|
+
const snapHash = this.detector.computeContentHash(snapshotDiff);
|
|
26685
|
+
this.lockManager.updatePatch(patch.id, {
|
|
26686
|
+
base_generation: currentGen,
|
|
26687
|
+
patch_content: snapshotDiff,
|
|
26688
|
+
content_hash: snapHash
|
|
26689
|
+
});
|
|
26690
|
+
conflictResolved++;
|
|
26691
|
+
continue;
|
|
26692
|
+
}
|
|
26562
26693
|
const ppResult = await computePerPatchDiffWithFallback(
|
|
26563
26694
|
patch,
|
|
26564
26695
|
(f) => this.git.showFile(currentGen, f),
|
|
@@ -27170,9 +27301,9 @@ var require_path_key = __commonJS({
|
|
|
27170
27301
|
}
|
|
27171
27302
|
});
|
|
27172
27303
|
|
|
27173
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27304
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
27174
27305
|
var require_resolveCommand = __commonJS({
|
|
27175
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27306
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
27176
27307
|
"use strict";
|
|
27177
27308
|
var path5 = require("path");
|
|
27178
27309
|
var which = require_which();
|
|
@@ -27212,9 +27343,9 @@ var require_resolveCommand = __commonJS({
|
|
|
27212
27343
|
}
|
|
27213
27344
|
});
|
|
27214
27345
|
|
|
27215
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27346
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
27216
27347
|
var require_escape = __commonJS({
|
|
27217
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27348
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports2, module2) {
|
|
27218
27349
|
"use strict";
|
|
27219
27350
|
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
27220
27351
|
function escapeCommand(arg) {
|
|
@@ -27265,9 +27396,9 @@ var require_shebang_command = __commonJS({
|
|
|
27265
27396
|
}
|
|
27266
27397
|
});
|
|
27267
27398
|
|
|
27268
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27399
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
27269
27400
|
var require_readShebang = __commonJS({
|
|
27270
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27401
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
27271
27402
|
"use strict";
|
|
27272
27403
|
var fs3 = require("fs");
|
|
27273
27404
|
var shebangCommand = require_shebang_command();
|
|
@@ -27287,9 +27418,9 @@ var require_readShebang = __commonJS({
|
|
|
27287
27418
|
}
|
|
27288
27419
|
});
|
|
27289
27420
|
|
|
27290
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27421
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
27291
27422
|
var require_parse2 = __commonJS({
|
|
27292
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27423
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
27293
27424
|
"use strict";
|
|
27294
27425
|
var path5 = require("path");
|
|
27295
27426
|
var resolveCommand = require_resolveCommand();
|
|
@@ -27349,9 +27480,9 @@ var require_parse2 = __commonJS({
|
|
|
27349
27480
|
}
|
|
27350
27481
|
});
|
|
27351
27482
|
|
|
27352
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27483
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
27353
27484
|
var require_enoent = __commonJS({
|
|
27354
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27485
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports2, module2) {
|
|
27355
27486
|
"use strict";
|
|
27356
27487
|
var isWin = process.platform === "win32";
|
|
27357
27488
|
function notFoundError(original, syscall) {
|
|
@@ -27399,9 +27530,9 @@ var require_enoent = __commonJS({
|
|
|
27399
27530
|
}
|
|
27400
27531
|
});
|
|
27401
27532
|
|
|
27402
|
-
// ../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27533
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
27403
27534
|
var require_cross_spawn = __commonJS({
|
|
27404
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.
|
|
27535
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports2, module2) {
|
|
27405
27536
|
"use strict";
|
|
27406
27537
|
var cp2 = require("child_process");
|
|
27407
27538
|
var parse3 = require_parse2();
|
|
@@ -29507,9 +29638,9 @@ function resolve(...paths) {
|
|
|
29507
29638
|
}
|
|
29508
29639
|
|
|
29509
29640
|
// src/cli.ts
|
|
29510
|
-
var
|
|
29511
|
-
var
|
|
29512
|
-
var
|
|
29641
|
+
var import_fs16 = __toESM(require("fs"));
|
|
29642
|
+
var import_promises16 = require("fs/promises");
|
|
29643
|
+
var import_path22 = __toESM(require("path"));
|
|
29513
29644
|
|
|
29514
29645
|
// ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/yerror.js
|
|
29515
29646
|
var YError = class _YError extends Error {
|
|
@@ -30822,15 +30953,15 @@ var import_path3 = require("path");
|
|
|
30822
30953
|
var import_fs2 = require("fs");
|
|
30823
30954
|
function sync_default(start, callback) {
|
|
30824
30955
|
let dir = (0, import_path3.resolve)(".", start);
|
|
30825
|
-
let
|
|
30956
|
+
let tmp4, stats = (0, import_fs2.statSync)(dir);
|
|
30826
30957
|
if (!stats.isDirectory()) {
|
|
30827
30958
|
dir = (0, import_path3.dirname)(dir);
|
|
30828
30959
|
}
|
|
30829
30960
|
while (true) {
|
|
30830
|
-
|
|
30831
|
-
if (
|
|
30832
|
-
dir = (0, import_path3.dirname)(
|
|
30833
|
-
if (
|
|
30961
|
+
tmp4 = callback(dir, (0, import_fs2.readdirSync)(dir));
|
|
30962
|
+
if (tmp4) return (0, import_path3.resolve)(dir, tmp4);
|
|
30963
|
+
dir = (0, import_path3.dirname)(tmp4 = dir);
|
|
30964
|
+
if (tmp4 === dir) break;
|
|
30834
30965
|
}
|
|
30835
30966
|
}
|
|
30836
30967
|
|
|
@@ -31597,6 +31728,15 @@ function getUserAgent() {
|
|
|
31597
31728
|
return "<environment undetectable>";
|
|
31598
31729
|
}
|
|
31599
31730
|
|
|
31731
|
+
// ../commons/github/lib/getGithubApiBaseUrl.js
|
|
31732
|
+
function getGithubApiBaseUrl(repositoryUri) {
|
|
31733
|
+
const { remote } = parseRepository(repositoryUri);
|
|
31734
|
+
if (remote === DEFAULT_REMOTE) {
|
|
31735
|
+
return void 0;
|
|
31736
|
+
}
|
|
31737
|
+
return `https://${remote}/api/v3`;
|
|
31738
|
+
}
|
|
31739
|
+
|
|
31600
31740
|
// ../../node_modules/.pnpm/before-after-hook@4.0.0/node_modules/before-after-hook/lib/register.js
|
|
31601
31741
|
function register(state, name, method, options) {
|
|
31602
31742
|
if (typeof method !== "function") {
|
|
@@ -31862,23 +32002,23 @@ function getValues(context, operator, key, modifier) {
|
|
|
31862
32002
|
});
|
|
31863
32003
|
}
|
|
31864
32004
|
} else {
|
|
31865
|
-
const
|
|
32005
|
+
const tmp4 = [];
|
|
31866
32006
|
if (Array.isArray(value)) {
|
|
31867
32007
|
value.filter(isDefined).forEach(function(value2) {
|
|
31868
|
-
|
|
32008
|
+
tmp4.push(encodeValue(operator, value2));
|
|
31869
32009
|
});
|
|
31870
32010
|
} else {
|
|
31871
32011
|
Object.keys(value).forEach(function(k2) {
|
|
31872
32012
|
if (isDefined(value[k2])) {
|
|
31873
|
-
|
|
31874
|
-
|
|
32013
|
+
tmp4.push(encodeUnreserved(k2));
|
|
32014
|
+
tmp4.push(encodeValue(operator, value[k2].toString()));
|
|
31875
32015
|
}
|
|
31876
32016
|
});
|
|
31877
32017
|
}
|
|
31878
32018
|
if (isKeyOperator(operator)) {
|
|
31879
|
-
result.push(encodeUnreserved(key) + "=" +
|
|
31880
|
-
} else if (
|
|
31881
|
-
result.push(
|
|
32019
|
+
result.push(encodeUnreserved(key) + "=" + tmp4.join(","));
|
|
32020
|
+
} else if (tmp4.length !== 0) {
|
|
32021
|
+
result.push(tmp4.join(","));
|
|
31882
32022
|
}
|
|
31883
32023
|
}
|
|
31884
32024
|
}
|
|
@@ -31913,8 +32053,8 @@ function expand2(template2, context) {
|
|
|
31913
32053
|
expression = expression.substr(1);
|
|
31914
32054
|
}
|
|
31915
32055
|
expression.split(/,/g).forEach(function(variable) {
|
|
31916
|
-
var
|
|
31917
|
-
values.push(getValues(context, operator,
|
|
32056
|
+
var tmp4 = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
|
32057
|
+
values.push(getValues(context, operator, tmp4[1], tmp4[2] || tmp4[3]));
|
|
31918
32058
|
});
|
|
31919
32059
|
if (operator && operator !== "+") {
|
|
31920
32060
|
var separator = ",";
|
|
@@ -35287,8 +35427,10 @@ var GitHub = class {
|
|
|
35287
35427
|
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
35288
35428
|
await repository.commit("SDK Generation");
|
|
35289
35429
|
await repository.push();
|
|
35430
|
+
const apiBaseUrl = getGithubApiBaseUrl(this.githubConfig.uri);
|
|
35290
35431
|
const octokit = new Octokit2({
|
|
35291
|
-
auth: this.githubConfig.token
|
|
35432
|
+
auth: this.githubConfig.token,
|
|
35433
|
+
...apiBaseUrl != null ? { baseUrl: apiBaseUrl } : {}
|
|
35292
35434
|
});
|
|
35293
35435
|
const parsedRepo = parseRepository(this.githubConfig.uri);
|
|
35294
35436
|
const { owner, repo } = parsedRepo;
|
|
@@ -41252,13 +41394,20 @@ async function createReplayBranch(repository, branchName, commitMessage, replayC
|
|
|
41252
41394
|
}
|
|
41253
41395
|
const parentSha = replayConflictInfo.previousGenerationSha;
|
|
41254
41396
|
await repository.createBranchFromHead(branchName);
|
|
41255
|
-
|
|
41256
|
-
|
|
41257
|
-
|
|
41258
|
-
|
|
41259
|
-
|
|
41260
|
-
|
|
41261
|
-
|
|
41397
|
+
try {
|
|
41398
|
+
const genTreeHash = await repository.getCommitTreeHash(replayConflictInfo.currentGenerationSha);
|
|
41399
|
+
const tagCommitSha = await repository.commitTree(
|
|
41400
|
+
genTreeHash,
|
|
41401
|
+
parentSha,
|
|
41402
|
+
`[fern-generated] ${commitMessage ?? "Update SDK"}`
|
|
41403
|
+
);
|
|
41404
|
+
return tagCommitSha;
|
|
41405
|
+
} catch (error) {
|
|
41406
|
+
logger.warn(
|
|
41407
|
+
`Could not create fern-generation-base tag commit: parent ${parentSha} is unreachable in this clone (likely on a squash-merged + deleted branch). Continuing without tag update. Underlying error: ${String(error)}`
|
|
41408
|
+
);
|
|
41409
|
+
return void 0;
|
|
41410
|
+
}
|
|
41262
41411
|
}
|
|
41263
41412
|
|
|
41264
41413
|
// src/pipeline/github/findExistingUpdatablePR.ts
|
|
@@ -41650,8 +41799,8 @@ var GithubStep = class extends BaseStep {
|
|
|
41650
41799
|
}
|
|
41651
41800
|
async executePullRequestMode(repository, newPrBranch, skipCommit, replayConflictInfo, replayResult, resolved) {
|
|
41652
41801
|
const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
|
|
41653
|
-
const octokit =
|
|
41654
|
-
const { owner, repo } = parseRepository(this.config.uri);
|
|
41802
|
+
const octokit = this.createOctokit();
|
|
41803
|
+
const { owner, repo, remote } = parseRepository(this.config.uri);
|
|
41655
41804
|
let prBranch;
|
|
41656
41805
|
let isUpdatingExistingPR = false;
|
|
41657
41806
|
let generationBaseSha;
|
|
@@ -41730,7 +41879,7 @@ var GithubStep = class extends BaseStep {
|
|
|
41730
41879
|
logger: this.logger
|
|
41731
41880
|
});
|
|
41732
41881
|
const pushedBranch = await repository.getCurrentBranch();
|
|
41733
|
-
result.branchUrl = `https
|
|
41882
|
+
result.branchUrl = `https://${remote}/${owner}/${repo}/tree/${pushedBranch}`;
|
|
41734
41883
|
this.logger.info(`Pushed branch: ${result.branchUrl}`);
|
|
41735
41884
|
if (generationBaseSha != null) {
|
|
41736
41885
|
try {
|
|
@@ -41745,7 +41894,7 @@ var GithubStep = class extends BaseStep {
|
|
|
41745
41894
|
}
|
|
41746
41895
|
}
|
|
41747
41896
|
const headSha = await repository.getHeadSha();
|
|
41748
|
-
const changelogUrl = resolved.changelogEntry ? `https
|
|
41897
|
+
const changelogUrl = resolved.changelogEntry ? `https://${remote}/${owner}/${repo}/blob/${headSha}/changelog.md` : void 0;
|
|
41749
41898
|
const { prTitle, prBody } = parseCommitMessageForPR(
|
|
41750
41899
|
resolved.commitMessage,
|
|
41751
41900
|
resolved.changelogEntry,
|
|
@@ -41839,8 +41988,8 @@ var GithubStep = class extends BaseStep {
|
|
|
41839
41988
|
success: true
|
|
41840
41989
|
};
|
|
41841
41990
|
if (!this.config.previewMode) {
|
|
41842
|
-
const octokit =
|
|
41843
|
-
const { owner, repo } = parseRepository(this.config.uri);
|
|
41991
|
+
const octokit = this.createOctokit();
|
|
41992
|
+
const { owner, repo, remote } = parseRepository(this.config.uri);
|
|
41844
41993
|
await pushSignedCommit({
|
|
41845
41994
|
repository,
|
|
41846
41995
|
octokit,
|
|
@@ -41852,11 +42001,18 @@ var GithubStep = class extends BaseStep {
|
|
|
41852
42001
|
logger: this.logger
|
|
41853
42002
|
});
|
|
41854
42003
|
const pushedBranch = await repository.getCurrentBranch();
|
|
41855
|
-
result.branchUrl = `https
|
|
42004
|
+
result.branchUrl = `https://${remote}/${owner}/${repo}/tree/${pushedBranch}`;
|
|
41856
42005
|
this.logger.info(`Pushed branch: ${result.branchUrl}`);
|
|
41857
42006
|
}
|
|
41858
42007
|
return result;
|
|
41859
42008
|
}
|
|
42009
|
+
createOctokit() {
|
|
42010
|
+
const opts = { auth: this.config.token };
|
|
42011
|
+
if (this.config.apiBaseUrl != null) {
|
|
42012
|
+
opts.baseUrl = this.config.apiBaseUrl;
|
|
42013
|
+
}
|
|
42014
|
+
return new Octokit2(opts);
|
|
42015
|
+
}
|
|
41860
42016
|
async ensureFernignore() {
|
|
41861
42017
|
this.logger.debug("Checking for .fernignore file...");
|
|
41862
42018
|
const fernignorePath = (0, import_path20.join)(this.outputDir, ".fernignore");
|
|
@@ -42075,6 +42231,278 @@ var ReplayStep = class extends BaseStep {
|
|
|
42075
42231
|
}
|
|
42076
42232
|
};
|
|
42077
42233
|
|
|
42234
|
+
// ../cli/generation/local-generation/docker-utils/lib/runDocker.js
|
|
42235
|
+
var import_promises15 = require("fs/promises");
|
|
42236
|
+
var import_tmp_promise3 = __toESM(require_tmp_promise(), 1);
|
|
42237
|
+
async function pullImage(imageName, runner, signal) {
|
|
42238
|
+
await loggingExeca(void 0, runner ?? "docker", ["pull", imageName], {
|
|
42239
|
+
all: true,
|
|
42240
|
+
doNotPipeOutput: true,
|
|
42241
|
+
signal
|
|
42242
|
+
});
|
|
42243
|
+
}
|
|
42244
|
+
async function startContainer({ logger, imageName, runner }) {
|
|
42245
|
+
const containerRunner = runner ?? "docker";
|
|
42246
|
+
const tryStart = async () => {
|
|
42247
|
+
const { stdout, exitCode, stderr } = await loggingExeca(logger, containerRunner, ["run", "--user", "root", "-dit", "--entrypoint", "/bin/sh", imageName], {
|
|
42248
|
+
reject: false,
|
|
42249
|
+
doNotPipeOutput: true
|
|
42250
|
+
});
|
|
42251
|
+
if (exitCode == null) {
|
|
42252
|
+
throw new Error(`Container runtime '${containerRunner}' is not installed or not found on PATH.
|
|
42253
|
+
Error details: ${stderr || stdout || "No output"}`);
|
|
42254
|
+
}
|
|
42255
|
+
if (exitCode !== 0) {
|
|
42256
|
+
throw new Error(`Failed to start container from image ${imageName}.
|
|
42257
|
+
${stdout}
|
|
42258
|
+
${stderr}`);
|
|
42259
|
+
}
|
|
42260
|
+
return stdout.trim();
|
|
42261
|
+
};
|
|
42262
|
+
try {
|
|
42263
|
+
return await tryStart();
|
|
42264
|
+
} catch (e) {
|
|
42265
|
+
if (e instanceof Error && e.message.includes("No such image")) {
|
|
42266
|
+
await pullImage(imageName, runner);
|
|
42267
|
+
return await tryStart();
|
|
42268
|
+
}
|
|
42269
|
+
throw e;
|
|
42270
|
+
}
|
|
42271
|
+
}
|
|
42272
|
+
async function execInContainer({ logger, containerId, command, runner, writeLogsToFile = true, reject = true }) {
|
|
42273
|
+
const containerRunner = runner ?? "docker";
|
|
42274
|
+
const { stdout, stderr, exitCode } = await loggingExeca(logger, containerRunner, ["exec", "--user", "root", containerId, ...command], {
|
|
42275
|
+
reject: false,
|
|
42276
|
+
all: true,
|
|
42277
|
+
doNotPipeOutput: true
|
|
42278
|
+
});
|
|
42279
|
+
const logs = stdout + stderr;
|
|
42280
|
+
if (writeLogsToFile) {
|
|
42281
|
+
const tmpFile = await import_tmp_promise3.default.file();
|
|
42282
|
+
await (0, import_promises15.writeFile)(tmpFile.path, logs);
|
|
42283
|
+
logger.info(`Generator logs here: ${tmpFile.path}`);
|
|
42284
|
+
}
|
|
42285
|
+
const resolvedExitCode = exitCode ?? 1;
|
|
42286
|
+
if (reject && resolvedExitCode !== 0) {
|
|
42287
|
+
throw new Error(`Container exec exited with code ${resolvedExitCode}.
|
|
42288
|
+
${stdout}
|
|
42289
|
+
${stderr}`);
|
|
42290
|
+
}
|
|
42291
|
+
return { stdout, stderr, exitCode: resolvedExitCode };
|
|
42292
|
+
}
|
|
42293
|
+
async function copyToContainer({ logger, containerId, hostPath, containerPath, runner }) {
|
|
42294
|
+
const containerRunner = runner ?? "docker";
|
|
42295
|
+
const { exitCode, stdout, stderr } = await loggingExeca(logger, containerRunner, ["cp", hostPath, `${containerId}:${containerPath}`], {
|
|
42296
|
+
reject: false,
|
|
42297
|
+
doNotPipeOutput: true
|
|
42298
|
+
});
|
|
42299
|
+
if (exitCode !== 0) {
|
|
42300
|
+
throw new Error(`Failed to copy ${hostPath} to container ${containerId}:${containerPath}.
|
|
42301
|
+
${stdout}
|
|
42302
|
+
${stderr}`);
|
|
42303
|
+
}
|
|
42304
|
+
}
|
|
42305
|
+
async function stopContainer({ logger, containerId, runner }) {
|
|
42306
|
+
const containerRunner = runner ?? "docker";
|
|
42307
|
+
await loggingExeca(logger, containerRunner, ["rm", "-f", containerId], {
|
|
42308
|
+
reject: false,
|
|
42309
|
+
doNotPipeOutput: true
|
|
42310
|
+
});
|
|
42311
|
+
}
|
|
42312
|
+
|
|
42313
|
+
// ../cli/logger/lib/LogLevel.js
|
|
42314
|
+
var LogLevel2 = {
|
|
42315
|
+
Trace: "trace",
|
|
42316
|
+
Debug: "debug",
|
|
42317
|
+
Info: "info",
|
|
42318
|
+
Warn: "warn",
|
|
42319
|
+
Error: "error"
|
|
42320
|
+
};
|
|
42321
|
+
var LOG_LEVELS = Object.values(LogLevel2);
|
|
42322
|
+
|
|
42323
|
+
// ../cli/logger/lib/createLogger.js
|
|
42324
|
+
var LoggerImpl = class {
|
|
42325
|
+
log;
|
|
42326
|
+
enabled;
|
|
42327
|
+
constructor(log, enabled = true) {
|
|
42328
|
+
this.log = log;
|
|
42329
|
+
this.enabled = enabled;
|
|
42330
|
+
}
|
|
42331
|
+
disable() {
|
|
42332
|
+
this.enabled = false;
|
|
42333
|
+
}
|
|
42334
|
+
enable() {
|
|
42335
|
+
this.enabled = true;
|
|
42336
|
+
}
|
|
42337
|
+
debug(...args) {
|
|
42338
|
+
if (this.enabled) {
|
|
42339
|
+
this.log(LogLevel2.Debug, ...args);
|
|
42340
|
+
}
|
|
42341
|
+
}
|
|
42342
|
+
info(...args) {
|
|
42343
|
+
if (this.enabled) {
|
|
42344
|
+
this.log(LogLevel2.Info, ...args);
|
|
42345
|
+
}
|
|
42346
|
+
}
|
|
42347
|
+
warn(...args) {
|
|
42348
|
+
if (this.enabled) {
|
|
42349
|
+
this.log(LogLevel2.Warn, ...args);
|
|
42350
|
+
}
|
|
42351
|
+
}
|
|
42352
|
+
error(...args) {
|
|
42353
|
+
if (this.enabled) {
|
|
42354
|
+
this.log(LogLevel2.Error, ...args);
|
|
42355
|
+
}
|
|
42356
|
+
}
|
|
42357
|
+
trace(...args) {
|
|
42358
|
+
if (this.enabled) {
|
|
42359
|
+
this.log(LogLevel2.Trace, ...args);
|
|
42360
|
+
}
|
|
42361
|
+
}
|
|
42362
|
+
};
|
|
42363
|
+
function createLogger4(log) {
|
|
42364
|
+
return new LoggerImpl(log);
|
|
42365
|
+
}
|
|
42366
|
+
|
|
42367
|
+
// src/pipeline/steps/VerificationStep.ts
|
|
42368
|
+
var import_fs15 = require("fs");
|
|
42369
|
+
var import_path21 = require("path");
|
|
42370
|
+
var CONTAINER_WORKSPACE_PATH = "/workspace";
|
|
42371
|
+
var VERIFY_SCRIPT_RELATIVE_PATH = ".fern/verify.sh";
|
|
42372
|
+
var VERIFY_SCRIPT_CONTAINER_PATH = `${CONTAINER_WORKSPACE_PATH}/${VERIFY_SCRIPT_RELATIVE_PATH}`;
|
|
42373
|
+
var VerificationStep = class extends BaseStep {
|
|
42374
|
+
constructor(outputDir, logger, config, generatorName, generatorVersions) {
|
|
42375
|
+
super(outputDir, logger);
|
|
42376
|
+
this.config = config;
|
|
42377
|
+
this.generatorName = generatorName;
|
|
42378
|
+
this.generatorVersions = generatorVersions;
|
|
42379
|
+
}
|
|
42380
|
+
config;
|
|
42381
|
+
generatorName;
|
|
42382
|
+
generatorVersions;
|
|
42383
|
+
name = "verify";
|
|
42384
|
+
async execute(_context) {
|
|
42385
|
+
const verifyScriptHostPath = (0, import_path21.join)(this.outputDir, VERIFY_SCRIPT_RELATIVE_PATH);
|
|
42386
|
+
if (!(0, import_fs15.existsSync)(verifyScriptHostPath)) {
|
|
42387
|
+
return { executed: true, success: true, skipped: true };
|
|
42388
|
+
}
|
|
42389
|
+
const validatorImage = this.deriveValidatorImage();
|
|
42390
|
+
if (validatorImage == null) {
|
|
42391
|
+
const message = "Cannot derive validator image: generatorName and generatorVersions are required to compute the `{generatorImage}-validator:{version}` tag.";
|
|
42392
|
+
this.logger.error(message);
|
|
42393
|
+
return {
|
|
42394
|
+
executed: true,
|
|
42395
|
+
success: false,
|
|
42396
|
+
skipped: false,
|
|
42397
|
+
errorMessage: message
|
|
42398
|
+
};
|
|
42399
|
+
}
|
|
42400
|
+
const runner = this.config.runner ?? "docker";
|
|
42401
|
+
const dockerLogger = createDockerLoggerAdapter(this.logger);
|
|
42402
|
+
let containerId;
|
|
42403
|
+
try {
|
|
42404
|
+
try {
|
|
42405
|
+
containerId = await startContainer({
|
|
42406
|
+
logger: dockerLogger,
|
|
42407
|
+
imageName: validatorImage,
|
|
42408
|
+
runner
|
|
42409
|
+
});
|
|
42410
|
+
} catch (error) {
|
|
42411
|
+
const message = `Failed to start verification container from image ${validatorImage}: ${extractErrorMessage(error)}`;
|
|
42412
|
+
this.logger.error(message);
|
|
42413
|
+
return {
|
|
42414
|
+
executed: true,
|
|
42415
|
+
success: false,
|
|
42416
|
+
skipped: false,
|
|
42417
|
+
errorMessage: message
|
|
42418
|
+
};
|
|
42419
|
+
}
|
|
42420
|
+
try {
|
|
42421
|
+
await copyToContainer({
|
|
42422
|
+
logger: dockerLogger,
|
|
42423
|
+
containerId,
|
|
42424
|
+
hostPath: `${this.outputDir}/.`,
|
|
42425
|
+
containerPath: CONTAINER_WORKSPACE_PATH,
|
|
42426
|
+
runner
|
|
42427
|
+
});
|
|
42428
|
+
} catch (error) {
|
|
42429
|
+
const message = `Failed to copy workspace into verification container: ${extractErrorMessage(error)}`;
|
|
42430
|
+
this.logger.error(message);
|
|
42431
|
+
return {
|
|
42432
|
+
executed: true,
|
|
42433
|
+
success: false,
|
|
42434
|
+
skipped: false,
|
|
42435
|
+
errorMessage: message
|
|
42436
|
+
};
|
|
42437
|
+
}
|
|
42438
|
+
const { stdout, stderr, exitCode } = await execInContainer({
|
|
42439
|
+
logger: dockerLogger,
|
|
42440
|
+
containerId,
|
|
42441
|
+
command: ["bash", VERIFY_SCRIPT_CONTAINER_PATH],
|
|
42442
|
+
runner,
|
|
42443
|
+
writeLogsToFile: false,
|
|
42444
|
+
reject: false
|
|
42445
|
+
});
|
|
42446
|
+
if (exitCode !== 0) {
|
|
42447
|
+
const capturedStderr = stderr.length > 0 ? stderr : stdout;
|
|
42448
|
+
this.logger.error(
|
|
42449
|
+
`Verification failed (exit code ${exitCode}) for image ${validatorImage}.
|
|
42450
|
+
${capturedStderr}`
|
|
42451
|
+
);
|
|
42452
|
+
return {
|
|
42453
|
+
executed: true,
|
|
42454
|
+
success: false,
|
|
42455
|
+
skipped: false,
|
|
42456
|
+
stderr: capturedStderr,
|
|
42457
|
+
errorMessage: `Verification script exited with code ${exitCode}`
|
|
42458
|
+
};
|
|
42459
|
+
}
|
|
42460
|
+
this.logger.info(`Verification succeeded for image ${validatorImage}`);
|
|
42461
|
+
return { executed: true, success: true, skipped: false };
|
|
42462
|
+
} finally {
|
|
42463
|
+
if (containerId != null) {
|
|
42464
|
+
try {
|
|
42465
|
+
await stopContainer({ logger: dockerLogger, containerId, runner });
|
|
42466
|
+
} catch (error) {
|
|
42467
|
+
this.logger.debug(
|
|
42468
|
+
`Best-effort cleanup: failed to stop verification container ${containerId}: ${extractErrorMessage(error)}`
|
|
42469
|
+
);
|
|
42470
|
+
}
|
|
42471
|
+
}
|
|
42472
|
+
}
|
|
42473
|
+
}
|
|
42474
|
+
deriveValidatorImage() {
|
|
42475
|
+
if (this.generatorName == null) {
|
|
42476
|
+
return void 0;
|
|
42477
|
+
}
|
|
42478
|
+
const version2 = this.generatorVersions?.[this.generatorName];
|
|
42479
|
+
if (version2 == null) {
|
|
42480
|
+
return void 0;
|
|
42481
|
+
}
|
|
42482
|
+
return `${this.generatorName}-validator:${version2}`;
|
|
42483
|
+
}
|
|
42484
|
+
};
|
|
42485
|
+
function createDockerLoggerAdapter(pipelineLogger) {
|
|
42486
|
+
return createLogger4((level, ...args) => {
|
|
42487
|
+
const message = args.join(" ");
|
|
42488
|
+
switch (level) {
|
|
42489
|
+
case LogLevel2.Trace:
|
|
42490
|
+
case LogLevel2.Debug:
|
|
42491
|
+
pipelineLogger.debug(message);
|
|
42492
|
+
return;
|
|
42493
|
+
case LogLevel2.Info:
|
|
42494
|
+
pipelineLogger.info(message);
|
|
42495
|
+
return;
|
|
42496
|
+
case LogLevel2.Warn:
|
|
42497
|
+
pipelineLogger.warn(message);
|
|
42498
|
+
return;
|
|
42499
|
+
case LogLevel2.Error:
|
|
42500
|
+
pipelineLogger.error(message);
|
|
42501
|
+
return;
|
|
42502
|
+
}
|
|
42503
|
+
});
|
|
42504
|
+
}
|
|
42505
|
+
|
|
42078
42506
|
// src/pipeline/PostGenerationPipeline.ts
|
|
42079
42507
|
var PostGenerationPipeline = class {
|
|
42080
42508
|
constructor(config, logger = consolePipelineLogger) {
|
|
@@ -42119,6 +42547,17 @@ var PostGenerationPipeline = class {
|
|
|
42119
42547
|
)
|
|
42120
42548
|
);
|
|
42121
42549
|
}
|
|
42550
|
+
if (config.verify?.enabled) {
|
|
42551
|
+
this.steps.push(
|
|
42552
|
+
new VerificationStep(
|
|
42553
|
+
config.outputDir,
|
|
42554
|
+
this.logger,
|
|
42555
|
+
config.verify,
|
|
42556
|
+
config.generatorName,
|
|
42557
|
+
config.generatorVersions
|
|
42558
|
+
)
|
|
42559
|
+
);
|
|
42560
|
+
}
|
|
42122
42561
|
if (config.github?.enabled) {
|
|
42123
42562
|
this.steps.push(new GithubStep(config.outputDir, this.logger, config.github));
|
|
42124
42563
|
}
|
|
@@ -42157,12 +42596,25 @@ var PostGenerationPipeline = class {
|
|
|
42157
42596
|
pipelineContext.previousStepResults.autoVersion = stepResult;
|
|
42158
42597
|
} else if (step.name === "fernignore") {
|
|
42159
42598
|
result.steps.fernignore = stepResult;
|
|
42599
|
+
} else if (step.name === "verify") {
|
|
42600
|
+
const verifyResult = stepResult;
|
|
42601
|
+
result.steps.verify = verifyResult;
|
|
42602
|
+
pipelineContext.previousStepResults.verify = verifyResult;
|
|
42160
42603
|
} else if (step.name === "github") {
|
|
42161
42604
|
result.steps.github = stepResult;
|
|
42162
42605
|
}
|
|
42163
42606
|
if (!stepResult.success) {
|
|
42164
42607
|
result.success = false;
|
|
42165
42608
|
result.errors = result.errors ?? [];
|
|
42609
|
+
if (step.name === "verify") {
|
|
42610
|
+
const verifyResult = stepResult;
|
|
42611
|
+
if (verifyResult.stderr != null && verifyResult.stderr.length > 0) {
|
|
42612
|
+
result.errors.push(verifyResult.stderr);
|
|
42613
|
+
} else {
|
|
42614
|
+
result.errors.push(verifyResult.errorMessage ?? `${step.name} step failed`);
|
|
42615
|
+
}
|
|
42616
|
+
break;
|
|
42617
|
+
}
|
|
42166
42618
|
result.errors.push(stepResult.errorMessage ?? `${step.name} step failed`);
|
|
42167
42619
|
}
|
|
42168
42620
|
} catch (error) {
|
|
@@ -42170,6 +42622,9 @@ var PostGenerationPipeline = class {
|
|
|
42170
42622
|
result.errors = result.errors ?? [];
|
|
42171
42623
|
const errorMessage = extractErrorMessage(error);
|
|
42172
42624
|
result.errors.push(`${step.name} step error: ${errorMessage}`);
|
|
42625
|
+
if (step.name === "verify") {
|
|
42626
|
+
break;
|
|
42627
|
+
}
|
|
42173
42628
|
}
|
|
42174
42629
|
}
|
|
42175
42630
|
return result;
|
|
@@ -42200,7 +42655,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
42200
42655
|
const readmeConfig = await loadReadmeConfig({
|
|
42201
42656
|
absolutePathToConfig: resolve(wd, argv.config)
|
|
42202
42657
|
});
|
|
42203
|
-
const originalReadmeContent = argv.originalReadme != null ? await (0,
|
|
42658
|
+
const originalReadmeContent = argv.originalReadme != null ? await (0, import_promises16.readFile)(argv.originalReadme, "utf8") : void 0;
|
|
42204
42659
|
await generateReadmeToStream({
|
|
42205
42660
|
originalReadmeContent,
|
|
42206
42661
|
readmeConfig,
|
|
@@ -42328,7 +42783,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
42328
42783
|
try {
|
|
42329
42784
|
const wd = cwd();
|
|
42330
42785
|
const configValue = argv.config;
|
|
42331
|
-
const configContent = configValue === STDIN_MARKER ? await readStdin() : configValue.trimStart().startsWith("{") ? configValue : await (0,
|
|
42786
|
+
const configContent = configValue === STDIN_MARKER ? await readStdin() : configValue.trimStart().startsWith("{") ? configValue : await (0, import_promises16.readFile)(resolve(wd, configValue), "utf-8");
|
|
42332
42787
|
let config;
|
|
42333
42788
|
try {
|
|
42334
42789
|
config = JSON.parse(configContent);
|
|
@@ -42624,9 +43079,9 @@ async function createWriteStream(outputPath) {
|
|
|
42624
43079
|
}
|
|
42625
43080
|
async function createWriteStreamFromFile(filepath) {
|
|
42626
43081
|
if (!await doesPathExist(filepath)) {
|
|
42627
|
-
await (0,
|
|
43082
|
+
await (0, import_promises16.mkdir)(import_path22.default.dirname(filepath), { recursive: true });
|
|
42628
43083
|
}
|
|
42629
|
-
return
|
|
43084
|
+
return import_fs16.default.createWriteStream(filepath);
|
|
42630
43085
|
}
|
|
42631
43086
|
/*! Bundled license information:
|
|
42632
43087
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/generator-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.27",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/fern-api/fern.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@boundaryml/baml": "^0.219.0",
|
|
26
|
-
"@fern-api/replay": "0.
|
|
26
|
+
"@fern-api/replay": "0.15.0",
|
|
27
27
|
"@octokit/rest": "^22.0.1",
|
|
28
28
|
"es-toolkit": "^1.45.1",
|
|
29
29
|
"semver": "^7.6.3",
|