@fern-api/generator-cli 0.9.21 → 0.9.23
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.d.ts +7 -1
- package/dist/api.js +45 -13
- package/dist/cli.js +1620 -1146
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -572,7 +572,7 @@ interface ReplayRunParams {
|
|
|
572
572
|
logger?: PipelineLogger;
|
|
573
573
|
}
|
|
574
574
|
interface ReplayRunResult {
|
|
575
|
-
/** null if replay wasn't initialized (no lockfile) */
|
|
575
|
+
/** null if replay wasn't initialized (no lockfile) OR if prepare/apply crashed (see failureReason) */
|
|
576
576
|
report: ReplayReport | null;
|
|
577
577
|
/** Whether .fernignore was updated */
|
|
578
578
|
fernignoreUpdated: boolean;
|
|
@@ -582,6 +582,12 @@ interface ReplayRunResult {
|
|
|
582
582
|
currentGenerationSha: string | null;
|
|
583
583
|
/** SHA of main's HEAD before replay ran. Always on main's lineage, stable after squash merges. */
|
|
584
584
|
baseBranchHead: string | null;
|
|
585
|
+
/**
|
|
586
|
+
* Set when prepare or apply crashed (e.g. corrupted lockfile, git failure, library bug).
|
|
587
|
+
* Distinguishes a real failure from "no replay initialized" (lockfile missing → null report, no failureReason).
|
|
588
|
+
* Generation never fails on replay errors — callers should surface this for telemetry/logging only.
|
|
589
|
+
*/
|
|
590
|
+
failureReason?: string;
|
|
585
591
|
}
|
|
586
592
|
/**
|
|
587
593
|
* Backwards-compatible atomic entry point. Composes `replayPrepare` +
|
package/dist/api.js
CHANGED
|
@@ -6173,7 +6173,9 @@ function newRepositoryReference({ remote, owner, repo }) {
|
|
|
6173
6173
|
repoUrl,
|
|
6174
6174
|
cloneUrl,
|
|
6175
6175
|
getAuthedCloneUrl: (installationToken) => {
|
|
6176
|
-
|
|
6176
|
+
const isInstallationToken = installationToken.startsWith("ghs_") || installationToken.startsWith("ghu_");
|
|
6177
|
+
const userPrefix = isInstallationToken ? "x-access-token:" : "";
|
|
6178
|
+
return cloneUrl.replace("https://", `https://${userPrefix}${installationToken}@`);
|
|
6177
6179
|
}
|
|
6178
6180
|
};
|
|
6179
6181
|
}
|
|
@@ -9894,7 +9896,7 @@ function cwd() {
|
|
|
9894
9896
|
// ../commons/fs-utils/lib/resolve.js
|
|
9895
9897
|
var import_path2 = __toESM(require("path"), 1);
|
|
9896
9898
|
function resolve2(...paths) {
|
|
9897
|
-
return import_path2.default.resolve(...paths.map(convertToOsPath));
|
|
9899
|
+
return convertToOsPath(import_path2.default.resolve(...paths.map(convertToOsPath)));
|
|
9898
9900
|
}
|
|
9899
9901
|
|
|
9900
9902
|
// src/github/GitHub.ts
|
|
@@ -10295,12 +10297,17 @@ async function replayPrepare(params) {
|
|
|
10295
10297
|
`fern-generation-base tag ${tagSha} is not reachable from HEAD \u2014 skipping divergent-merge sync. The tag likely points at an unmerged generation (PR closed without merge).`
|
|
10296
10298
|
);
|
|
10297
10299
|
} else {
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10300
|
+
try {
|
|
10301
|
+
const syncService = new import_replay4.ReplayService(outputDir, { enabled: true });
|
|
10302
|
+
await syncService.syncFromDivergentMerge(tagSha, {
|
|
10303
|
+
cliVersion,
|
|
10304
|
+
generatorVersions,
|
|
10305
|
+
baseBranchHead: baseBranchHead ?? void 0
|
|
10306
|
+
});
|
|
10307
|
+
} catch (error) {
|
|
10308
|
+
logger?.warn("Replay divergent-merge sync failed, continuing without sync: " + String(error));
|
|
10309
|
+
throw new ReplayPrepareError(String(error), error);
|
|
10310
|
+
}
|
|
10304
10311
|
try {
|
|
10305
10312
|
const freshLockManager = new import_replay4.LockfileManager(outputDir);
|
|
10306
10313
|
if (freshLockManager.exists()) {
|
|
@@ -10322,8 +10329,8 @@ async function replayPrepare(params) {
|
|
|
10322
10329
|
baseBranchHead: baseBranchHead ?? void 0
|
|
10323
10330
|
});
|
|
10324
10331
|
} catch (error) {
|
|
10325
|
-
logger?.warn("Replay failed, continuing without replay: " + String(error));
|
|
10326
|
-
|
|
10332
|
+
logger?.warn("Replay prepare failed, continuing without replay: " + String(error));
|
|
10333
|
+
throw new ReplayPrepareError(String(error), error);
|
|
10327
10334
|
}
|
|
10328
10335
|
return {
|
|
10329
10336
|
_service: service,
|
|
@@ -10341,13 +10348,14 @@ async function replayApply(prepared, params = {}) {
|
|
|
10341
10348
|
try {
|
|
10342
10349
|
report = await prepared._service.applyPreparedReplay(prepared._preparation, { stageOnly });
|
|
10343
10350
|
} catch (error) {
|
|
10344
|
-
logger?.warn("Replay failed, continuing without replay: " + String(error));
|
|
10351
|
+
logger?.warn("Replay apply failed, continuing without replay: " + String(error));
|
|
10345
10352
|
return {
|
|
10346
10353
|
report: null,
|
|
10347
10354
|
fernignoreUpdated: false,
|
|
10348
10355
|
previousGenerationSha: prepared.previousGenerationSha,
|
|
10349
10356
|
currentGenerationSha: prepared.currentGenerationSha,
|
|
10350
|
-
baseBranchHead: prepared.baseBranchHead
|
|
10357
|
+
baseBranchHead: prepared.baseBranchHead,
|
|
10358
|
+
failureReason: String(error)
|
|
10351
10359
|
};
|
|
10352
10360
|
}
|
|
10353
10361
|
let resolvedBaseBranchHead = prepared.baseBranchHead;
|
|
@@ -10373,7 +10381,19 @@ async function replayApply(prepared, params = {}) {
|
|
|
10373
10381
|
};
|
|
10374
10382
|
}
|
|
10375
10383
|
async function replayRun(params) {
|
|
10376
|
-
|
|
10384
|
+
let prepared;
|
|
10385
|
+
try {
|
|
10386
|
+
prepared = await replayPrepare(params);
|
|
10387
|
+
} catch (error) {
|
|
10388
|
+
return {
|
|
10389
|
+
report: null,
|
|
10390
|
+
fernignoreUpdated: false,
|
|
10391
|
+
previousGenerationSha: null,
|
|
10392
|
+
currentGenerationSha: null,
|
|
10393
|
+
baseBranchHead: null,
|
|
10394
|
+
failureReason: error instanceof ReplayPrepareError ? error.reason : String(error)
|
|
10395
|
+
};
|
|
10396
|
+
}
|
|
10377
10397
|
if (prepared == null) {
|
|
10378
10398
|
return {
|
|
10379
10399
|
report: null,
|
|
@@ -10385,6 +10405,18 @@ async function replayRun(params) {
|
|
|
10385
10405
|
}
|
|
10386
10406
|
return replayApply(prepared, { stageOnly: params.stageOnly, logger: params.logger });
|
|
10387
10407
|
}
|
|
10408
|
+
var ReplayPrepareError = class extends Error {
|
|
10409
|
+
reason;
|
|
10410
|
+
constructor(reason, cause) {
|
|
10411
|
+
super(`Replay prepare failed: ${reason}`, { cause });
|
|
10412
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10413
|
+
if (Error.captureStackTrace) {
|
|
10414
|
+
Error.captureStackTrace(this, this.constructor);
|
|
10415
|
+
}
|
|
10416
|
+
this.name = this.constructor.name;
|
|
10417
|
+
this.reason = reason;
|
|
10418
|
+
}
|
|
10419
|
+
};
|
|
10388
10420
|
function isTagMergedIntoHead(cwd2, tagSha) {
|
|
10389
10421
|
try {
|
|
10390
10422
|
(0, import_child_process3.execFileSync)("git", ["merge-base", "--is-ancestor", tagSha, "HEAD"], {
|