@emeryld/rrroutes-export 1.0.5 → 1.0.6

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/index.mjs CHANGED
@@ -2029,7 +2029,9 @@ async function writeFinalizedLeavesChangelogExport(payload, outFileOrOptions) {
2029
2029
  return written;
2030
2030
  }
2031
2031
  async function exportFinalizedLeavesChangelog(options) {
2032
+ const log = options.log ?? (() => void 0);
2032
2033
  const cwd = process.cwd();
2034
+ log(`[changelog] resolving repository root from ${cwd}`);
2033
2035
  const repoRoot = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
2034
2036
  const modulePathAbsolute = path4.resolve(cwd, options.modulePath);
2035
2037
  const modulePathRelative = normalizePath(path4.relative(repoRoot, modulePathAbsolute));
@@ -2042,25 +2044,36 @@ async function exportFinalizedLeavesChangelog(options) {
2042
2044
  throw new Error("tsconfigPath must resolve inside the git repository root.");
2043
2045
  }
2044
2046
  const exportName = options.exportName ?? "leaves";
2047
+ log("[changelog] resolving commit window");
2045
2048
  const window = await resolveCommitWindow(repoRoot, options.from, options.to);
2049
+ log(`[changelog] window: ${window.from.slice(0, 12)}..${window.to.slice(0, 12)}`);
2046
2050
  const allCommits = await resolveCommitPath(repoRoot, window.from, window.to);
2051
+ log(`[changelog] commits in ancestry path: ${allCommits.length}`);
2047
2052
  const selectedCommitShas = await filterCommits(
2048
2053
  repoRoot,
2049
2054
  allCommits,
2050
2055
  modulePathRelative,
2051
2056
  tsconfigRelative
2052
2057
  );
2058
+ log(`[changelog] commits after path filter: ${selectedCommitShas.length}`);
2053
2059
  if (selectedCommitShas.length === 0) {
2054
2060
  selectedCommitShas.push(window.to);
2061
+ log("[changelog] filter returned no commits, forcing tip commit inclusion");
2055
2062
  }
2056
2063
  const commits = [];
2064
+ log("[changelog] loading commit metadata");
2057
2065
  for (const commit of selectedCommitShas) {
2058
2066
  commits.push(await getCommitMetadata(repoRoot, commit));
2059
2067
  }
2060
2068
  const tempRoot = await fs2.mkdtemp(path4.join(os.tmpdir(), "rrroutes-export-changelog-"));
2069
+ log(`[changelog] temp workspace: ${tempRoot}`);
2061
2070
  try {
2062
2071
  const snapshots = [];
2063
- for (const commit of commits) {
2072
+ for (let index = 0; index < commits.length; index += 1) {
2073
+ const commit = commits[index];
2074
+ log(
2075
+ `[changelog] snapshot ${index + 1}/${commits.length}: ${commit.sha.slice(0, 12)} ${commit.subject}`
2076
+ );
2064
2077
  snapshots.push(
2065
2078
  await createSnapshot(
2066
2079
  repoRoot,
@@ -2075,6 +2088,7 @@ async function exportFinalizedLeavesChangelog(options) {
2075
2088
  }
2076
2089
  const routeEvents = [];
2077
2090
  const sourceEvents = [];
2091
+ log("[changelog] diffing adjacent snapshots");
2078
2092
  for (let i = 1; i < snapshots.length; i += 1) {
2079
2093
  const { routeEvents: nextRouteEvents, sourceEvents: nextSourceEvents } = diffSnapshots(
2080
2094
  snapshots[i - 1],
@@ -2083,6 +2097,9 @@ async function exportFinalizedLeavesChangelog(options) {
2083
2097
  routeEvents.push(...nextRouteEvents);
2084
2098
  sourceEvents.push(...nextSourceEvents);
2085
2099
  }
2100
+ log(
2101
+ `[changelog] diff complete: route events=${routeEvents.length}, source events=${sourceEvents.length}`
2102
+ );
2086
2103
  const payload = {
2087
2104
  kind: "finalized-leaves-changelog",
2088
2105
  _meta: {
@@ -2100,6 +2117,7 @@ async function exportFinalizedLeavesChangelog(options) {
2100
2117
  rollups: buildRollups(routeEvents, sourceEvents, commits)
2101
2118
  };
2102
2119
  if (options.outFile || options.htmlFile) {
2120
+ log("[changelog] writing output artifacts");
2103
2121
  await writeFinalizedLeavesChangelogExport(payload, {
2104
2122
  outFile: options.outFile,
2105
2123
  htmlFile: options.htmlFile,
@@ -2107,9 +2125,11 @@ async function exportFinalizedLeavesChangelog(options) {
2107
2125
  openOnFinish: options.openOnFinish
2108
2126
  });
2109
2127
  }
2128
+ log("[changelog] done");
2110
2129
  return payload;
2111
2130
  } finally {
2112
2131
  await fs2.rm(tempRoot, { recursive: true, force: true }).catch(() => void 0);
2132
+ log("[changelog] cleaned temp workspace");
2113
2133
  }
2114
2134
  }
2115
2135
  var __private = {
@@ -2156,6 +2176,10 @@ function parseFinalizedLeavesChangelogCliArgs(argv) {
2156
2176
  }
2157
2177
  async function runExportFinalizedLeavesChangelogCli(argv) {
2158
2178
  const args = parseFinalizedLeavesChangelogCliArgs(argv);
2179
+ const log = (message) => {
2180
+ process.stdout.write(`${message}
2181
+ `);
2182
+ };
2159
2183
  const options = {
2160
2184
  modulePath: args.modulePath,
2161
2185
  exportName: args.exportName,
@@ -2164,9 +2188,12 @@ async function runExportFinalizedLeavesChangelogCli(argv) {
2164
2188
  tsconfigPath: args.tsconfigPath,
2165
2189
  from: args.from,
2166
2190
  to: args.to,
2167
- includeSource: true
2191
+ includeSource: true,
2192
+ log
2168
2193
  };
2194
+ log("[changelog-cli] starting changelog export");
2169
2195
  const payload = await exportFinalizedLeavesChangelog(options);
2196
+ log("[changelog-cli] changelog export completed");
2170
2197
  return {
2171
2198
  payload,
2172
2199
  outFile: path5.resolve(args.outFile),