@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 CHANGED
@@ -77,6 +77,11 @@ Behavior summary:
77
77
  - route events (`route_added`, `route_removed`, `schema_changed`, `cfg_changed`)
78
78
  - source-object events (`source_object_added`, `source_object_removed`, `source_schema_changed`)
79
79
 
80
+ Runtime progress logs:
81
+
82
+ - `rrroutes-export-changelog` now prints step-by-step progress (window resolution, commit filtering, per-commit snapshot progress, diff totals, output writing, cleanup).
83
+ - Bundle script prints stage logs for snapshot export + changelog export.
84
+
80
85
  ## Recommended end-to-end script
81
86
 
82
87
  Use this when you want one command to produce everything (snapshot + changelog + HTML + summary + timestamped storage).
@@ -135,5 +140,6 @@ const changelog = await exportFinalizedLeavesChangelog({
135
140
  to: 'HEAD',
136
141
  outFile: './finalized-leaves.changelog.json',
137
142
  htmlFile: './finalized-leaves.changelog.viewer.html',
143
+ log: (message) => console.log(message),
138
144
  })
139
145
  ```
@@ -114,6 +114,7 @@ export type ExportFinalizedLeavesChangelogOptions = {
114
114
  openOnFinish?: boolean;
115
115
  includeSource?: boolean;
116
116
  handlers?: ExportFinalizedLeavesOptions['handlers'];
117
+ log?: (message: string) => void;
117
118
  };
118
119
  declare function resolveCommitWindow(cwd: string, from?: string, to?: string): Promise<{
119
120
  from: string;
package/dist/index.cjs CHANGED
@@ -1854,10 +1854,28 @@ async function loadChangelogInput(modulePath, exportName) {
1854
1854
  }
1855
1855
  return value;
1856
1856
  }
1857
+ async function ensureWorktreeDependencies(repoRoot, worktreeDir) {
1858
+ const rootNodeModules = import_node_path4.default.join(repoRoot, "node_modules");
1859
+ const worktreeNodeModules = import_node_path4.default.join(worktreeDir, "node_modules");
1860
+ try {
1861
+ await import_promises2.default.access(rootNodeModules);
1862
+ } catch {
1863
+ throw new Error(
1864
+ `Missing dependencies at ${rootNodeModules}. Run install in the repository root before changelog export.`
1865
+ );
1866
+ }
1867
+ try {
1868
+ await import_promises2.default.lstat(worktreeNodeModules);
1869
+ return;
1870
+ } catch {
1871
+ }
1872
+ await import_promises2.default.symlink(rootNodeModules, worktreeNodeModules, "junction");
1873
+ }
1857
1874
  async function createSnapshot(repoRoot, moduleRel, exportName, commit, tempRoot, tsconfigRel, exportOptions) {
1858
1875
  const worktreeDir = import_node_path4.default.join(tempRoot, `wt-${commit.sha.slice(0, 12)}`);
1859
1876
  await runGit(repoRoot, ["worktree", "add", "--detach", worktreeDir, commit.sha]);
1860
1877
  try {
1878
+ await ensureWorktreeDependencies(repoRoot, worktreeDir);
1861
1879
  const modulePath = import_node_path4.default.resolve(worktreeDir, moduleRel);
1862
1880
  const tsconfigPath = tsconfigRel ? import_node_path4.default.resolve(worktreeDir, tsconfigRel) : void 0;
1863
1881
  const input = await loadChangelogInput(modulePath, exportName);
@@ -2083,7 +2101,9 @@ async function writeFinalizedLeavesChangelogExport(payload, outFileOrOptions) {
2083
2101
  return written;
2084
2102
  }
2085
2103
  async function exportFinalizedLeavesChangelog(options) {
2104
+ const log = options.log ?? (() => void 0);
2086
2105
  const cwd = process.cwd();
2106
+ log(`[changelog] resolving repository root from ${cwd}`);
2087
2107
  const repoRoot = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
2088
2108
  const modulePathAbsolute = import_node_path4.default.resolve(cwd, options.modulePath);
2089
2109
  const modulePathRelative = normalizePath(import_node_path4.default.relative(repoRoot, modulePathAbsolute));
@@ -2096,25 +2116,36 @@ async function exportFinalizedLeavesChangelog(options) {
2096
2116
  throw new Error("tsconfigPath must resolve inside the git repository root.");
2097
2117
  }
2098
2118
  const exportName = options.exportName ?? "leaves";
2119
+ log("[changelog] resolving commit window");
2099
2120
  const window = await resolveCommitWindow(repoRoot, options.from, options.to);
2121
+ log(`[changelog] window: ${window.from.slice(0, 12)}..${window.to.slice(0, 12)}`);
2100
2122
  const allCommits = await resolveCommitPath(repoRoot, window.from, window.to);
2123
+ log(`[changelog] commits in ancestry path: ${allCommits.length}`);
2101
2124
  const selectedCommitShas = await filterCommits(
2102
2125
  repoRoot,
2103
2126
  allCommits,
2104
2127
  modulePathRelative,
2105
2128
  tsconfigRelative
2106
2129
  );
2130
+ log(`[changelog] commits after path filter: ${selectedCommitShas.length}`);
2107
2131
  if (selectedCommitShas.length === 0) {
2108
2132
  selectedCommitShas.push(window.to);
2133
+ log("[changelog] filter returned no commits, forcing tip commit inclusion");
2109
2134
  }
2110
2135
  const commits = [];
2136
+ log("[changelog] loading commit metadata");
2111
2137
  for (const commit of selectedCommitShas) {
2112
2138
  commits.push(await getCommitMetadata(repoRoot, commit));
2113
2139
  }
2114
2140
  const tempRoot = await import_promises2.default.mkdtemp(import_node_path4.default.join(import_node_os.default.tmpdir(), "rrroutes-export-changelog-"));
2141
+ log(`[changelog] temp workspace: ${tempRoot}`);
2115
2142
  try {
2116
2143
  const snapshots = [];
2117
- for (const commit of commits) {
2144
+ for (let index = 0; index < commits.length; index += 1) {
2145
+ const commit = commits[index];
2146
+ log(
2147
+ `[changelog] snapshot ${index + 1}/${commits.length}: ${commit.sha.slice(0, 12)} ${commit.subject}`
2148
+ );
2118
2149
  snapshots.push(
2119
2150
  await createSnapshot(
2120
2151
  repoRoot,
@@ -2129,6 +2160,7 @@ async function exportFinalizedLeavesChangelog(options) {
2129
2160
  }
2130
2161
  const routeEvents = [];
2131
2162
  const sourceEvents = [];
2163
+ log("[changelog] diffing adjacent snapshots");
2132
2164
  for (let i = 1; i < snapshots.length; i += 1) {
2133
2165
  const { routeEvents: nextRouteEvents, sourceEvents: nextSourceEvents } = diffSnapshots(
2134
2166
  snapshots[i - 1],
@@ -2137,6 +2169,9 @@ async function exportFinalizedLeavesChangelog(options) {
2137
2169
  routeEvents.push(...nextRouteEvents);
2138
2170
  sourceEvents.push(...nextSourceEvents);
2139
2171
  }
2172
+ log(
2173
+ `[changelog] diff complete: route events=${routeEvents.length}, source events=${sourceEvents.length}`
2174
+ );
2140
2175
  const payload = {
2141
2176
  kind: "finalized-leaves-changelog",
2142
2177
  _meta: {
@@ -2154,6 +2189,7 @@ async function exportFinalizedLeavesChangelog(options) {
2154
2189
  rollups: buildRollups(routeEvents, sourceEvents, commits)
2155
2190
  };
2156
2191
  if (options.outFile || options.htmlFile) {
2192
+ log("[changelog] writing output artifacts");
2157
2193
  await writeFinalizedLeavesChangelogExport(payload, {
2158
2194
  outFile: options.outFile,
2159
2195
  htmlFile: options.htmlFile,
@@ -2161,9 +2197,11 @@ async function exportFinalizedLeavesChangelog(options) {
2161
2197
  openOnFinish: options.openOnFinish
2162
2198
  });
2163
2199
  }
2200
+ log("[changelog] done");
2164
2201
  return payload;
2165
2202
  } finally {
2166
2203
  await import_promises2.default.rm(tempRoot, { recursive: true, force: true }).catch(() => void 0);
2204
+ log("[changelog] cleaned temp workspace");
2167
2205
  }
2168
2206
  }
2169
2207
  var __private = {
@@ -2210,6 +2248,10 @@ function parseFinalizedLeavesChangelogCliArgs(argv) {
2210
2248
  }
2211
2249
  async function runExportFinalizedLeavesChangelogCli(argv) {
2212
2250
  const args = parseFinalizedLeavesChangelogCliArgs(argv);
2251
+ const log = (message) => {
2252
+ process.stdout.write(`${message}
2253
+ `);
2254
+ };
2213
2255
  const options = {
2214
2256
  modulePath: args.modulePath,
2215
2257
  exportName: args.exportName,
@@ -2218,9 +2260,12 @@ async function runExportFinalizedLeavesChangelogCli(argv) {
2218
2260
  tsconfigPath: args.tsconfigPath,
2219
2261
  from: args.from,
2220
2262
  to: args.to,
2221
- includeSource: true
2263
+ includeSource: true,
2264
+ log
2222
2265
  };
2266
+ log("[changelog-cli] starting changelog export");
2223
2267
  const payload = await exportFinalizedLeavesChangelog(options);
2268
+ log("[changelog-cli] changelog export completed");
2224
2269
  return {
2225
2270
  payload,
2226
2271
  outFile: import_node_path5.default.resolve(args.outFile),