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