@emeryld/rrroutes-export 1.0.5 → 1.0.7
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 +6 -0
- package/dist/exportFinalizedLeaves.changelog.d.ts +1 -0
- package/dist/index.cjs +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +47 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1800,10 +1800,28 @@ async function loadChangelogInput(modulePath, exportName) {
|
|
|
1800
1800
|
}
|
|
1801
1801
|
return value;
|
|
1802
1802
|
}
|
|
1803
|
+
async function ensureWorktreeDependencies(repoRoot, worktreeDir) {
|
|
1804
|
+
const rootNodeModules = path4.join(repoRoot, "node_modules");
|
|
1805
|
+
const worktreeNodeModules = path4.join(worktreeDir, "node_modules");
|
|
1806
|
+
try {
|
|
1807
|
+
await fs2.access(rootNodeModules);
|
|
1808
|
+
} catch {
|
|
1809
|
+
throw new Error(
|
|
1810
|
+
`Missing dependencies at ${rootNodeModules}. Run install in the repository root before changelog export.`
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1813
|
+
try {
|
|
1814
|
+
await fs2.lstat(worktreeNodeModules);
|
|
1815
|
+
return;
|
|
1816
|
+
} catch {
|
|
1817
|
+
}
|
|
1818
|
+
await fs2.symlink(rootNodeModules, worktreeNodeModules, "junction");
|
|
1819
|
+
}
|
|
1803
1820
|
async function createSnapshot(repoRoot, moduleRel, exportName, commit, tempRoot, tsconfigRel, exportOptions) {
|
|
1804
1821
|
const worktreeDir = path4.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
|
|
1805
1822
|
await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
|
|
1806
1823
|
try {
|
|
1824
|
+
await ensureWorktreeDependencies(repoRoot, worktreeDir);
|
|
1807
1825
|
const modulePath = path4.resolve(worktreeDir, moduleRel);
|
|
1808
1826
|
const tsconfigPath = tsconfigRel ? path4.resolve(worktreeDir, tsconfigRel) : void 0;
|
|
1809
1827
|
const input = await loadChangelogInput(modulePath, exportName);
|
|
@@ -2029,7 +2047,9 @@ async function writeFinalizedLeavesChangelogExport(payload, outFileOrOptions) {
|
|
|
2029
2047
|
return written;
|
|
2030
2048
|
}
|
|
2031
2049
|
async function exportFinalizedLeavesChangelog(options) {
|
|
2050
|
+
const log = options.log ?? (() => void 0);
|
|
2032
2051
|
const cwd = process.cwd();
|
|
2052
|
+
log(`[changelog] resolving repository root from ${cwd}`);
|
|
2033
2053
|
const repoRoot = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
2034
2054
|
const modulePathAbsolute = path4.resolve(cwd, options.modulePath);
|
|
2035
2055
|
const modulePathRelative = normalizePath(path4.relative(repoRoot, modulePathAbsolute));
|
|
@@ -2042,25 +2062,36 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2042
2062
|
throw new Error("tsconfigPath must resolve inside the git repository root.");
|
|
2043
2063
|
}
|
|
2044
2064
|
const exportName = options.exportName ?? "leaves";
|
|
2065
|
+
log("[changelog] resolving commit window");
|
|
2045
2066
|
const window = await resolveCommitWindow(repoRoot, options.from, options.to);
|
|
2067
|
+
log(`[changelog] window: ${window.from.slice(0, 12)}..${window.to.slice(0, 12)}`);
|
|
2046
2068
|
const allCommits = await resolveCommitPath(repoRoot, window.from, window.to);
|
|
2069
|
+
log(`[changelog] commits in ancestry path: ${allCommits.length}`);
|
|
2047
2070
|
const selectedCommitShas = await filterCommits(
|
|
2048
2071
|
repoRoot,
|
|
2049
2072
|
allCommits,
|
|
2050
2073
|
modulePathRelative,
|
|
2051
2074
|
tsconfigRelative
|
|
2052
2075
|
);
|
|
2076
|
+
log(`[changelog] commits after path filter: ${selectedCommitShas.length}`);
|
|
2053
2077
|
if (selectedCommitShas.length === 0) {
|
|
2054
2078
|
selectedCommitShas.push(window.to);
|
|
2079
|
+
log("[changelog] filter returned no commits, forcing tip commit inclusion");
|
|
2055
2080
|
}
|
|
2056
2081
|
const commits = [];
|
|
2082
|
+
log("[changelog] loading commit metadata");
|
|
2057
2083
|
for (const commit of selectedCommitShas) {
|
|
2058
2084
|
commits.push(await getCommitMetadata(repoRoot, commit));
|
|
2059
2085
|
}
|
|
2060
2086
|
const tempRoot = await fs2.mkdtemp(path4.join(os.tmpdir(), "rrroutes-export-changelog-"));
|
|
2087
|
+
log(`[changelog] temp workspace: ${tempRoot}`);
|
|
2061
2088
|
try {
|
|
2062
2089
|
const snapshots = [];
|
|
2063
|
-
for (
|
|
2090
|
+
for (let index = 0; index < commits.length; index += 1) {
|
|
2091
|
+
const commit = commits[index];
|
|
2092
|
+
log(
|
|
2093
|
+
`[changelog] snapshot ${index + 1}/${commits.length}: ${commit.sha.slice(0, 12)} ${commit.subject}`
|
|
2094
|
+
);
|
|
2064
2095
|
snapshots.push(
|
|
2065
2096
|
await createSnapshot(
|
|
2066
2097
|
repoRoot,
|
|
@@ -2075,6 +2106,7 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2075
2106
|
}
|
|
2076
2107
|
const routeEvents = [];
|
|
2077
2108
|
const sourceEvents = [];
|
|
2109
|
+
log("[changelog] diffing adjacent snapshots");
|
|
2078
2110
|
for (let i = 1; i < snapshots.length; i += 1) {
|
|
2079
2111
|
const { routeEvents: nextRouteEvents, sourceEvents: nextSourceEvents } = diffSnapshots(
|
|
2080
2112
|
snapshots[i - 1],
|
|
@@ -2083,6 +2115,9 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2083
2115
|
routeEvents.push(...nextRouteEvents);
|
|
2084
2116
|
sourceEvents.push(...nextSourceEvents);
|
|
2085
2117
|
}
|
|
2118
|
+
log(
|
|
2119
|
+
`[changelog] diff complete: route events=${routeEvents.length}, source events=${sourceEvents.length}`
|
|
2120
|
+
);
|
|
2086
2121
|
const payload = {
|
|
2087
2122
|
kind: "finalized-leaves-changelog",
|
|
2088
2123
|
_meta: {
|
|
@@ -2100,6 +2135,7 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2100
2135
|
rollups: buildRollups(routeEvents, sourceEvents, commits)
|
|
2101
2136
|
};
|
|
2102
2137
|
if (options.outFile || options.htmlFile) {
|
|
2138
|
+
log("[changelog] writing output artifacts");
|
|
2103
2139
|
await writeFinalizedLeavesChangelogExport(payload, {
|
|
2104
2140
|
outFile: options.outFile,
|
|
2105
2141
|
htmlFile: options.htmlFile,
|
|
@@ -2107,9 +2143,11 @@ async function exportFinalizedLeavesChangelog(options) {
|
|
|
2107
2143
|
openOnFinish: options.openOnFinish
|
|
2108
2144
|
});
|
|
2109
2145
|
}
|
|
2146
|
+
log("[changelog] done");
|
|
2110
2147
|
return payload;
|
|
2111
2148
|
} finally {
|
|
2112
2149
|
await fs2.rm(tempRoot, { recursive: true, force: true }).catch(() => void 0);
|
|
2150
|
+
log("[changelog] cleaned temp workspace");
|
|
2113
2151
|
}
|
|
2114
2152
|
}
|
|
2115
2153
|
var __private = {
|
|
@@ -2156,6 +2194,10 @@ function parseFinalizedLeavesChangelogCliArgs(argv) {
|
|
|
2156
2194
|
}
|
|
2157
2195
|
async function runExportFinalizedLeavesChangelogCli(argv) {
|
|
2158
2196
|
const args = parseFinalizedLeavesChangelogCliArgs(argv);
|
|
2197
|
+
const log = (message) => {
|
|
2198
|
+
process.stdout.write(`${message}
|
|
2199
|
+
`);
|
|
2200
|
+
};
|
|
2159
2201
|
const options = {
|
|
2160
2202
|
modulePath: args.modulePath,
|
|
2161
2203
|
exportName: args.exportName,
|
|
@@ -2164,9 +2206,12 @@ async function runExportFinalizedLeavesChangelogCli(argv) {
|
|
|
2164
2206
|
tsconfigPath: args.tsconfigPath,
|
|
2165
2207
|
from: args.from,
|
|
2166
2208
|
to: args.to,
|
|
2167
|
-
includeSource: true
|
|
2209
|
+
includeSource: true,
|
|
2210
|
+
log
|
|
2168
2211
|
};
|
|
2212
|
+
log("[changelog-cli] starting changelog export");
|
|
2169
2213
|
const payload = await exportFinalizedLeavesChangelog(options);
|
|
2214
|
+
log("[changelog-cli] changelog export completed");
|
|
2170
2215
|
return {
|
|
2171
2216
|
payload,
|
|
2172
2217
|
outFile: path5.resolve(args.outFile),
|