@emeryld/rrroutes-export 1.0.11 → 1.0.12
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/README.md +3 -0
- package/dist/exportFinalizedLeaves.changelog.d.ts +7 -0
- package/dist/index.cjs +85 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +85 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2067,72 +2067,87 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
|
|
|
2067
2067
|
const worktreeDir = path4.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
|
|
2068
2068
|
await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
|
|
2069
2069
|
try {
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2070
|
+
try {
|
|
2071
|
+
await ensureWorktreeDependencies(repoRoot, worktreeDir);
|
|
2072
|
+
const resolvedModuleRel = await resolveModulePathForCommit(
|
|
2073
|
+
repoRoot,
|
|
2074
|
+
commit.sha,
|
|
2075
|
+
moduleCandidates
|
|
2076
|
+
);
|
|
2077
|
+
if (!resolvedModuleRel) {
|
|
2078
|
+
log?.(
|
|
2079
|
+
`[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
|
|
2080
|
+
);
|
|
2081
|
+
return {
|
|
2082
|
+
commit,
|
|
2083
|
+
routesByKey: {},
|
|
2084
|
+
sourceObjectsById: {},
|
|
2085
|
+
unresolvedModule: true,
|
|
2086
|
+
fallbackReason: "module_unresolved"
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
log?.(
|
|
2090
|
+
`[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
|
|
2091
|
+
);
|
|
2092
|
+
const modulePath = path4.resolve(worktreeDir, resolvedModuleRel);
|
|
2093
|
+
let snapshotRuntimePath = modulePath;
|
|
2094
|
+
let resolvedTsconfigPath;
|
|
2095
|
+
if (isTypeScriptModule(modulePath)) {
|
|
2096
|
+
resolvedTsconfigPath = await resolveSnapshotTsconfig(
|
|
2097
|
+
worktreeDir,
|
|
2098
|
+
modulePath,
|
|
2099
|
+
tsconfigRel
|
|
2100
|
+
);
|
|
2101
|
+
log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
|
|
2102
|
+
const compileCacheRoot = path4.resolve(
|
|
2103
|
+
exportOptions?.cacheDir ?? path4.join(os.tmpdir(), "rrroutes-export-changelog-cache")
|
|
2104
|
+
);
|
|
2105
|
+
snapshotRuntimePath = await compileSnapshotEntry({
|
|
2106
|
+
worktreeDir,
|
|
2107
|
+
moduleRel: resolvedModuleRel,
|
|
2108
|
+
modulePath,
|
|
2109
|
+
tsconfigPath: resolvedTsconfigPath,
|
|
2110
|
+
commitSha: commit.sha,
|
|
2111
|
+
cacheRoot: compileCacheRoot,
|
|
2112
|
+
noCache: exportOptions?.noCache,
|
|
2113
|
+
log
|
|
2114
|
+
});
|
|
2115
|
+
} else if (!isJavaScriptModule(modulePath)) {
|
|
2116
|
+
throw new Error(
|
|
2117
|
+
`Unsupported module extension for changelog snapshots: ${modulePath}`
|
|
2118
|
+
);
|
|
2119
|
+
}
|
|
2120
|
+
const input = await loadSnapshotExport({
|
|
2121
|
+
entryPath: snapshotRuntimePath,
|
|
2122
|
+
exportName
|
|
2123
|
+
});
|
|
2124
|
+
const payload = await exportFinalizedLeaves(input, {
|
|
2125
|
+
includeSource: true,
|
|
2126
|
+
sourceModulePath: modulePath,
|
|
2127
|
+
sourceExportName: exportName,
|
|
2128
|
+
tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? path4.resolve(worktreeDir, tsconfigRel) : void 0),
|
|
2129
|
+
handlers: exportOptions?.handlers
|
|
2130
|
+
});
|
|
2131
|
+
const routesByKey = toRouteSnapshots(payload);
|
|
2132
|
+
const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
|
|
2133
|
+
return {
|
|
2134
|
+
commit,
|
|
2135
|
+
routesByKey,
|
|
2136
|
+
sourceObjectsById
|
|
2137
|
+
};
|
|
2138
|
+
} catch (error) {
|
|
2139
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2077
2140
|
log?.(
|
|
2078
|
-
`[changelog]
|
|
2141
|
+
`[changelog] snapshot failed for ${commit.sha.slice(0, 12)}; using empty snapshot. ${message}`
|
|
2079
2142
|
);
|
|
2080
2143
|
return {
|
|
2081
2144
|
commit,
|
|
2082
2145
|
routesByKey: {},
|
|
2083
2146
|
sourceObjectsById: {},
|
|
2084
|
-
|
|
2147
|
+
fallbackReason: "snapshot_error",
|
|
2148
|
+
fallbackError: message
|
|
2085
2149
|
};
|
|
2086
2150
|
}
|
|
2087
|
-
log?.(
|
|
2088
|
-
`[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
|
|
2089
|
-
);
|
|
2090
|
-
const modulePath = path4.resolve(worktreeDir, resolvedModuleRel);
|
|
2091
|
-
let snapshotRuntimePath = modulePath;
|
|
2092
|
-
let resolvedTsconfigPath;
|
|
2093
|
-
if (isTypeScriptModule(modulePath)) {
|
|
2094
|
-
resolvedTsconfigPath = await resolveSnapshotTsconfig(
|
|
2095
|
-
worktreeDir,
|
|
2096
|
-
modulePath,
|
|
2097
|
-
tsconfigRel
|
|
2098
|
-
);
|
|
2099
|
-
log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
|
|
2100
|
-
const compileCacheRoot = path4.resolve(
|
|
2101
|
-
exportOptions?.cacheDir ?? path4.join(os.tmpdir(), "rrroutes-export-changelog-cache")
|
|
2102
|
-
);
|
|
2103
|
-
snapshotRuntimePath = await compileSnapshotEntry({
|
|
2104
|
-
worktreeDir,
|
|
2105
|
-
moduleRel: resolvedModuleRel,
|
|
2106
|
-
modulePath,
|
|
2107
|
-
tsconfigPath: resolvedTsconfigPath,
|
|
2108
|
-
commitSha: commit.sha,
|
|
2109
|
-
cacheRoot: compileCacheRoot,
|
|
2110
|
-
noCache: exportOptions?.noCache,
|
|
2111
|
-
log
|
|
2112
|
-
});
|
|
2113
|
-
} else if (!isJavaScriptModule(modulePath)) {
|
|
2114
|
-
throw new Error(
|
|
2115
|
-
`Unsupported module extension for changelog snapshots: ${modulePath}`
|
|
2116
|
-
);
|
|
2117
|
-
}
|
|
2118
|
-
const input = await loadSnapshotExport({
|
|
2119
|
-
entryPath: snapshotRuntimePath,
|
|
2120
|
-
exportName
|
|
2121
|
-
});
|
|
2122
|
-
const payload = await exportFinalizedLeaves(input, {
|
|
2123
|
-
includeSource: true,
|
|
2124
|
-
sourceModulePath: modulePath,
|
|
2125
|
-
sourceExportName: exportName,
|
|
2126
|
-
tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? path4.resolve(worktreeDir, tsconfigRel) : void 0),
|
|
2127
|
-
handlers: exportOptions?.handlers
|
|
2128
|
-
});
|
|
2129
|
-
const routesByKey = toRouteSnapshots(payload);
|
|
2130
|
-
const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
|
|
2131
|
-
return {
|
|
2132
|
-
commit,
|
|
2133
|
-
routesByKey,
|
|
2134
|
-
sourceObjectsById
|
|
2135
|
-
};
|
|
2136
2151
|
} finally {
|
|
2137
2152
|
await runGit(repoRoot, ["worktree", "remove", "--force", worktreeDir]).catch(() => void 0);
|
|
2138
2153
|
await fs2.rm(worktreeDir, { recursive: true, force: true }).catch(() => void 0);
|
|
@@ -2388,6 +2403,7 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2388
2403
|
try {
|
|
2389
2404
|
const snapshots = [];
|
|
2390
2405
|
const unresolvedModuleCommits = [];
|
|
2406
|
+
const snapshotFallbacks = [];
|
|
2391
2407
|
for (let index = 0; index < commits.length; index += 1) {
|
|
2392
2408
|
const commit = commits[index];
|
|
2393
2409
|
log(
|
|
@@ -2405,9 +2421,17 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2405
2421
|
log
|
|
2406
2422
|
)
|
|
2407
2423
|
);
|
|
2408
|
-
|
|
2424
|
+
const lastSnapshot = snapshots[snapshots.length - 1];
|
|
2425
|
+
if (lastSnapshot?.unresolvedModule) {
|
|
2409
2426
|
unresolvedModuleCommits.push(commit.sha);
|
|
2410
2427
|
}
|
|
2428
|
+
if (lastSnapshot?.fallbackReason) {
|
|
2429
|
+
snapshotFallbacks.push({
|
|
2430
|
+
sha: commit.sha,
|
|
2431
|
+
reason: lastSnapshot.fallbackReason,
|
|
2432
|
+
error: lastSnapshot.fallbackError
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2411
2435
|
}
|
|
2412
2436
|
const routeEvents = [];
|
|
2413
2437
|
const sourceEvents = [];
|
|
@@ -2433,7 +2457,8 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2433
2457
|
from: window.from,
|
|
2434
2458
|
to: window.to,
|
|
2435
2459
|
selectedCommitCount: commits.length,
|
|
2436
|
-
unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0
|
|
2460
|
+
unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0,
|
|
2461
|
+
snapshotFallbacks: snapshotFallbacks.length > 0 ? snapshotFallbacks : void 0
|
|
2437
2462
|
},
|
|
2438
2463
|
commits,
|
|
2439
2464
|
byRoute: routeRecordByKey(routeEvents),
|