@emeryld/rrroutes-export 1.0.11 → 1.0.13
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 +8 -0
- package/dist/index.cjs +89 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +89 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/tools/finalized-leaves-viewer.html +82 -1
package/README.md
CHANGED
|
@@ -79,15 +79,18 @@ Behavior summary:
|
|
|
79
79
|
- For TypeScript module entries, compiles the commit snapshot to JS and imports emitted output.
|
|
80
80
|
- For JavaScript module entries, imports directly from worktree.
|
|
81
81
|
- If module entrypoint cannot be resolved for a commit, changelog uses an empty snapshot for that commit (timeline continuity).
|
|
82
|
+
- If a commit snapshot fails to compile/load, changelog also uses an empty snapshot for that commit and continues.
|
|
82
83
|
- Exports snapshots, then computes adjacent diffs:
|
|
83
84
|
- route events (`route_added`, `route_removed`, `schema_changed`, `cfg_changed`)
|
|
84
85
|
- source-object events (`source_object_added`, `source_object_removed`, `source_schema_changed`)
|
|
86
|
+
- metadata includes fallback details in `_meta.unresolvedModuleCommits` and `_meta.snapshotFallbacks`
|
|
85
87
|
|
|
86
88
|
Runtime progress logs:
|
|
87
89
|
|
|
88
90
|
- `rrroutes-export-changelog` now prints step-by-step progress (window resolution, commit filtering, per-commit snapshot progress, diff totals, output writing, cleanup).
|
|
89
91
|
- Changelog logs include compile lifecycle details: selected tsconfig, cache hit/miss, emitted entry path.
|
|
90
92
|
- Changelog logs include per-commit module resolution and unresolved-entry fallback messages.
|
|
93
|
+
- Changelog logs include snapshot compile/load fallback messages when a commit cannot be materialized.
|
|
91
94
|
- Bundle script prints stage logs for snapshot export + changelog export.
|
|
92
95
|
|
|
93
96
|
Troubleshooting historical TS imports:
|
|
@@ -33,6 +33,8 @@ type CommitSnapshot = {
|
|
|
33
33
|
routesByKey: Record<string, RouteSnapshot>;
|
|
34
34
|
sourceObjectsById: Record<string, SourceObjectSnapshot>;
|
|
35
35
|
unresolvedModule?: boolean;
|
|
36
|
+
fallbackReason?: 'module_unresolved' | 'snapshot_error';
|
|
37
|
+
fallbackError?: string;
|
|
36
38
|
};
|
|
37
39
|
type DiffOp = 'added' | 'removed' | 'changed';
|
|
38
40
|
export type SchemaPathDelta = {
|
|
@@ -56,6 +58,7 @@ export type SourceSchemaPathDelta = {
|
|
|
56
58
|
export type ChangelogCommit = {
|
|
57
59
|
sha: string;
|
|
58
60
|
authorDate: string;
|
|
61
|
+
authorName: string;
|
|
59
62
|
subject: string;
|
|
60
63
|
};
|
|
61
64
|
export type RouteChangeType = 'route_added' | 'route_removed' | 'schema_changed' | 'cfg_changed';
|
|
@@ -98,6 +101,11 @@ export type FinalizedLeavesChangelogExport = {
|
|
|
98
101
|
to: string;
|
|
99
102
|
selectedCommitCount: number;
|
|
100
103
|
unresolvedModuleCommits?: string[];
|
|
104
|
+
snapshotFallbacks?: Array<{
|
|
105
|
+
sha: string;
|
|
106
|
+
reason: 'module_unresolved' | 'snapshot_error';
|
|
107
|
+
error?: string;
|
|
108
|
+
}>;
|
|
101
109
|
};
|
|
102
110
|
commits: ChangelogCommit[];
|
|
103
111
|
byRoute: Record<string, RouteChangeEvent[]>;
|
package/dist/index.cjs
CHANGED
|
@@ -1661,14 +1661,15 @@ async function filterCommits(cwd, commits, moduleCandidates, tsconfigRel) {
|
|
|
1661
1661
|
return keep;
|
|
1662
1662
|
}
|
|
1663
1663
|
async function getCommitMetadata(cwd, commit) {
|
|
1664
|
-
const out = await runGit(cwd, ["show", "-s", "--format=%H%x1f%aI%x1f%s", commit]);
|
|
1665
|
-
const [sha, authorDate, subject] = out.split("");
|
|
1666
|
-
if (!sha || !authorDate) {
|
|
1664
|
+
const out = await runGit(cwd, ["show", "-s", "--format=%H%x1f%aI%x1f%an%x1f%s", commit]);
|
|
1665
|
+
const [sha, authorDate, authorName, subject] = out.split("");
|
|
1666
|
+
if (!sha || !authorDate || !authorName) {
|
|
1667
1667
|
throw new Error(`Unable to read commit metadata for ${commit}`);
|
|
1668
1668
|
}
|
|
1669
1669
|
return {
|
|
1670
1670
|
sha,
|
|
1671
1671
|
authorDate,
|
|
1672
|
+
authorName,
|
|
1672
1673
|
subject: subject ?? ""
|
|
1673
1674
|
};
|
|
1674
1675
|
}
|
|
@@ -2121,72 +2122,87 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
|
|
|
2121
2122
|
const worktreeDir = import_node_path4.default.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
|
|
2122
2123
|
await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
|
|
2123
2124
|
try {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2125
|
+
try {
|
|
2126
|
+
await ensureWorktreeDependencies(repoRoot, worktreeDir);
|
|
2127
|
+
const resolvedModuleRel = await resolveModulePathForCommit(
|
|
2128
|
+
repoRoot,
|
|
2129
|
+
commit.sha,
|
|
2130
|
+
moduleCandidates
|
|
2131
|
+
);
|
|
2132
|
+
if (!resolvedModuleRel) {
|
|
2133
|
+
log?.(
|
|
2134
|
+
`[changelog] unresolved module for commit ${commit.sha.slice(0, 12)}; using empty snapshot`
|
|
2135
|
+
);
|
|
2136
|
+
return {
|
|
2137
|
+
commit,
|
|
2138
|
+
routesByKey: {},
|
|
2139
|
+
sourceObjectsById: {},
|
|
2140
|
+
unresolvedModule: true,
|
|
2141
|
+
fallbackReason: "module_unresolved"
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
log?.(
|
|
2145
|
+
`[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
|
|
2146
|
+
);
|
|
2147
|
+
const modulePath = import_node_path4.default.resolve(worktreeDir, resolvedModuleRel);
|
|
2148
|
+
let snapshotRuntimePath = modulePath;
|
|
2149
|
+
let resolvedTsconfigPath;
|
|
2150
|
+
if (isTypeScriptModule(modulePath)) {
|
|
2151
|
+
resolvedTsconfigPath = await resolveSnapshotTsconfig(
|
|
2152
|
+
worktreeDir,
|
|
2153
|
+
modulePath,
|
|
2154
|
+
tsconfigRel
|
|
2155
|
+
);
|
|
2156
|
+
log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
|
|
2157
|
+
const compileCacheRoot = import_node_path4.default.resolve(
|
|
2158
|
+
exportOptions?.cacheDir ?? import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-cache")
|
|
2159
|
+
);
|
|
2160
|
+
snapshotRuntimePath = await compileSnapshotEntry({
|
|
2161
|
+
worktreeDir,
|
|
2162
|
+
moduleRel: resolvedModuleRel,
|
|
2163
|
+
modulePath,
|
|
2164
|
+
tsconfigPath: resolvedTsconfigPath,
|
|
2165
|
+
commitSha: commit.sha,
|
|
2166
|
+
cacheRoot: compileCacheRoot,
|
|
2167
|
+
noCache: exportOptions?.noCache,
|
|
2168
|
+
log
|
|
2169
|
+
});
|
|
2170
|
+
} else if (!isJavaScriptModule(modulePath)) {
|
|
2171
|
+
throw new Error(
|
|
2172
|
+
`Unsupported module extension for changelog snapshots: ${modulePath}`
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
const input = await loadSnapshotExport({
|
|
2176
|
+
entryPath: snapshotRuntimePath,
|
|
2177
|
+
exportName
|
|
2178
|
+
});
|
|
2179
|
+
const payload = await exportFinalizedLeaves(input, {
|
|
2180
|
+
includeSource: true,
|
|
2181
|
+
sourceModulePath: modulePath,
|
|
2182
|
+
sourceExportName: exportName,
|
|
2183
|
+
tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0),
|
|
2184
|
+
handlers: exportOptions?.handlers
|
|
2185
|
+
});
|
|
2186
|
+
const routesByKey = toRouteSnapshots(payload);
|
|
2187
|
+
const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
|
|
2188
|
+
return {
|
|
2189
|
+
commit,
|
|
2190
|
+
routesByKey,
|
|
2191
|
+
sourceObjectsById
|
|
2192
|
+
};
|
|
2193
|
+
} catch (error) {
|
|
2194
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2131
2195
|
log?.(
|
|
2132
|
-
`[changelog]
|
|
2196
|
+
`[changelog] snapshot failed for ${commit.sha.slice(0, 12)}; using empty snapshot. ${message}`
|
|
2133
2197
|
);
|
|
2134
2198
|
return {
|
|
2135
2199
|
commit,
|
|
2136
2200
|
routesByKey: {},
|
|
2137
2201
|
sourceObjectsById: {},
|
|
2138
|
-
|
|
2202
|
+
fallbackReason: "snapshot_error",
|
|
2203
|
+
fallbackError: message
|
|
2139
2204
|
};
|
|
2140
2205
|
}
|
|
2141
|
-
log?.(
|
|
2142
|
-
`[changelog] resolved module for commit ${commit.sha.slice(0, 12)}: ${resolvedModuleRel}`
|
|
2143
|
-
);
|
|
2144
|
-
const modulePath = import_node_path4.default.resolve(worktreeDir, resolvedModuleRel);
|
|
2145
|
-
let snapshotRuntimePath = modulePath;
|
|
2146
|
-
let resolvedTsconfigPath;
|
|
2147
|
-
if (isTypeScriptModule(modulePath)) {
|
|
2148
|
-
resolvedTsconfigPath = await resolveSnapshotTsconfig(
|
|
2149
|
-
worktreeDir,
|
|
2150
|
-
modulePath,
|
|
2151
|
-
tsconfigRel
|
|
2152
|
-
);
|
|
2153
|
-
log?.(`[changelog] using tsconfig: ${resolvedTsconfigPath}`);
|
|
2154
|
-
const compileCacheRoot = import_node_path4.default.resolve(
|
|
2155
|
-
exportOptions?.cacheDir ?? import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-cache")
|
|
2156
|
-
);
|
|
2157
|
-
snapshotRuntimePath = await compileSnapshotEntry({
|
|
2158
|
-
worktreeDir,
|
|
2159
|
-
moduleRel: resolvedModuleRel,
|
|
2160
|
-
modulePath,
|
|
2161
|
-
tsconfigPath: resolvedTsconfigPath,
|
|
2162
|
-
commitSha: commit.sha,
|
|
2163
|
-
cacheRoot: compileCacheRoot,
|
|
2164
|
-
noCache: exportOptions?.noCache,
|
|
2165
|
-
log
|
|
2166
|
-
});
|
|
2167
|
-
} else if (!isJavaScriptModule(modulePath)) {
|
|
2168
|
-
throw new Error(
|
|
2169
|
-
`Unsupported module extension for changelog snapshots: ${modulePath}`
|
|
2170
|
-
);
|
|
2171
|
-
}
|
|
2172
|
-
const input = await loadSnapshotExport({
|
|
2173
|
-
entryPath: snapshotRuntimePath,
|
|
2174
|
-
exportName
|
|
2175
|
-
});
|
|
2176
|
-
const payload = await exportFinalizedLeaves(input, {
|
|
2177
|
-
includeSource: true,
|
|
2178
|
-
sourceModulePath: modulePath,
|
|
2179
|
-
sourceExportName: exportName,
|
|
2180
|
-
tsconfigPath: resolvedTsconfigPath ?? (tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0),
|
|
2181
|
-
handlers: exportOptions?.handlers
|
|
2182
|
-
});
|
|
2183
|
-
const routesByKey = toRouteSnapshots(payload);
|
|
2184
|
-
const sourceObjectsById = toSourceObjectSnapshots(routesByKey);
|
|
2185
|
-
return {
|
|
2186
|
-
commit,
|
|
2187
|
-
routesByKey,
|
|
2188
|
-
sourceObjectsById
|
|
2189
|
-
};
|
|
2190
2206
|
} finally {
|
|
2191
2207
|
await runGit(repoRoot, ["worktree", "remove", "--force", worktreeDir]).catch(() => void 0);
|
|
2192
2208
|
await import_promises2.default.rm(worktreeDir, { recursive: true, force: true }).catch(() => void 0);
|
|
@@ -2442,6 +2458,7 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2442
2458
|
try {
|
|
2443
2459
|
const snapshots = [];
|
|
2444
2460
|
const unresolvedModuleCommits = [];
|
|
2461
|
+
const snapshotFallbacks = [];
|
|
2445
2462
|
for (let index = 0; index < commits.length; index += 1) {
|
|
2446
2463
|
const commit = commits[index];
|
|
2447
2464
|
log(
|
|
@@ -2459,9 +2476,17 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2459
2476
|
log
|
|
2460
2477
|
)
|
|
2461
2478
|
);
|
|
2462
|
-
|
|
2479
|
+
const lastSnapshot = snapshots[snapshots.length - 1];
|
|
2480
|
+
if (lastSnapshot?.unresolvedModule) {
|
|
2463
2481
|
unresolvedModuleCommits.push(commit.sha);
|
|
2464
2482
|
}
|
|
2483
|
+
if (lastSnapshot?.fallbackReason) {
|
|
2484
|
+
snapshotFallbacks.push({
|
|
2485
|
+
sha: commit.sha,
|
|
2486
|
+
reason: lastSnapshot.fallbackReason,
|
|
2487
|
+
error: lastSnapshot.fallbackError
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2465
2490
|
}
|
|
2466
2491
|
const routeEvents = [];
|
|
2467
2492
|
const sourceEvents = [];
|
|
@@ -2487,7 +2512,8 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2487
2512
|
from: window.from,
|
|
2488
2513
|
to: window.to,
|
|
2489
2514
|
selectedCommitCount: commits.length,
|
|
2490
|
-
unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0
|
|
2515
|
+
unresolvedModuleCommits: unresolvedModuleCommits.length > 0 ? unresolvedModuleCommits : void 0,
|
|
2516
|
+
snapshotFallbacks: snapshotFallbacks.length > 0 ? snapshotFallbacks : void 0
|
|
2491
2517
|
},
|
|
2492
2518
|
commits,
|
|
2493
2519
|
byRoute: routeRecordByKey(routeEvents),
|