codemodctl 0.1.15 → 0.1.17

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/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import "./codemod-cli-DailrcEf.js";
3
- import { analyzeCodeowners } from "./codeowner-analysis-BcFoet6s.js";
4
- import "./consistent-sharding-lYO6XLIO.js";
5
- import { analyzeDirectories } from "./directory-analysis-6DFgAaDz.js";
3
+ import { analyzeCodeowners } from "./codeowner-analysis-DlwMGduk.js";
4
+ import "./consistent-sharding-BfgFDhwr.js";
5
+ import { analyzeDirectories } from "./directory-analysis-WCzArWS4.js";
6
6
  import { defineCommand, runMain } from "citty";
7
7
  import crypto from "node:crypto";
8
8
  import { $ } from "execa";
@@ -10,7 +10,7 @@ interface ShardResult {
10
10
  /** The combined shard ID (e.g., "team-name 1/3") */
11
11
  shardId: string;
12
12
  /** Array of file paths in this shard */
13
- files: string[];
13
+ _meta_files: string[];
14
14
  }
15
15
  /**
16
16
  * Information about a team and their files
@@ -103,7 +103,7 @@ function generateShards(filesByOwner, shardSize, existingState) {
103
103
  team,
104
104
  shard: `${i}/${numShards}`,
105
105
  shardId: `${team} ${i}/${numShards}`,
106
- files: shardFiles
106
+ _meta_files: shardFiles
107
107
  });
108
108
  }
109
109
  }
@@ -1,2 +1,2 @@
1
- import { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-CkGR1oU6.js";
1
+ import { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-CBrsUJBb.js";
2
2
  export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import "./codemod-cli-DailrcEf.js";
3
- import { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-BcFoet6s.js";
3
+ import { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-DlwMGduk.js";
4
4
 
5
5
  export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
@@ -53,7 +53,7 @@ function getShardForFilename(filename, { shardCount }) {
53
53
  * @returns True if file is in the shard's files list
54
54
  */
55
55
  function fitsInShard(filename, shard) {
56
- return shard.files.includes(filename);
56
+ return shard._meta_files.includes(filename);
57
57
  }
58
58
  /**
59
59
  * Distributes files across shards using deterministic hashing
@@ -30,7 +30,7 @@ declare function getShardForFilename(filename: string, {
30
30
  * @returns True if file is in the shard's files list
31
31
  */
32
32
  declare function fitsInShard(filename: string, shard: {
33
- files: string[];
33
+ _meta_files: string[];
34
34
  }): boolean;
35
35
  /**
36
36
  * Distributes files across shards using deterministic hashing
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { getApplicableFiles } from "./codemod-cli-DailrcEf.js";
3
- import { calculateOptimalShardCount, distributeFilesAcrossShards } from "./consistent-sharding-lYO6XLIO.js";
3
+ import { calculateOptimalShardCount, distributeFilesAcrossShards } from "./consistent-sharding-BfgFDhwr.js";
4
4
  import path from "node:path";
5
5
 
6
6
  //#region src/utils/directory-analysis.ts
@@ -9,21 +9,24 @@ import path from "node:path";
9
9
  *
10
10
  * @param files - Array of file paths to group
11
11
  * @param target - Target directory to analyze subdirectories within
12
+ * @param projectRoot - Root directory of the project for resolving relative paths
12
13
  * @returns Map of subdirectory paths to their file lists
13
14
  */
14
- function groupFilesByDirectory(files, target) {
15
- const normalizedTarget = path.normalize(target);
15
+ function groupFilesByDirectory(files, target, projectRoot) {
16
+ const resolvedTarget = path.resolve(projectRoot, target);
16
17
  const filesByDirectory = /* @__PURE__ */ new Map();
17
18
  for (const filePath of files) {
18
19
  const normalizedFile = path.normalize(filePath);
19
- if (!normalizedFile.startsWith(normalizedTarget)) continue;
20
- const relativePath = path.relative(normalizedTarget, normalizedFile);
21
- if (!relativePath.includes(path.sep)) continue;
22
- const firstDir = relativePath.split(path.sep)[0];
20
+ const resolvedFile = path.resolve(projectRoot, normalizedFile);
21
+ if (!resolvedFile.startsWith(resolvedTarget)) continue;
22
+ const relativePath = path.relative(projectRoot, resolvedFile);
23
+ const relativeFromTarget = path.relative(resolvedTarget, resolvedFile);
24
+ if (!relativeFromTarget.includes(path.sep)) continue;
25
+ const firstDir = relativeFromTarget.split(path.sep)[0];
23
26
  if (!firstDir) continue;
24
- const subdirectory = path.join(normalizedTarget, firstDir);
27
+ const subdirectory = path.relative(projectRoot, path.join(resolvedTarget, firstDir));
25
28
  if (!filesByDirectory.has(subdirectory)) filesByDirectory.set(subdirectory, []);
26
- filesByDirectory.get(subdirectory).push(normalizedFile);
29
+ filesByDirectory.get(subdirectory).push(relativePath);
27
30
  }
28
31
  return filesByDirectory;
29
32
  }
@@ -57,7 +60,8 @@ function createDirectoryShards(filesByDirectory, shardSize, existingState) {
57
60
  directory,
58
61
  shard: shardIndex + 1,
59
62
  shardCount,
60
- files: shardFiles.sort()
63
+ _meta_files: shardFiles.sort(),
64
+ name: `${directory} ${shardIndex + 1}/${shardCount}`
61
65
  });
62
66
  }
63
67
  }
@@ -73,14 +77,12 @@ function createDirectoryShards(filesByDirectory, shardSize, existingState) {
73
77
  */
74
78
  async function analyzeDirectories(options) {
75
79
  const { shardSize, target, rulePath, language, projectRoot = process.cwd(), existingState } = options;
76
- console.debug(`Using rule file: ${rulePath}`);
77
- console.debug(`Target directory: ${target}`);
78
- console.debug(`Shard size: ${shardSize}`);
79
80
  if (existingState) console.debug(`Using existing state with ${existingState.length} shards`);
80
81
  console.log("Analyzing files with CLI command...");
81
82
  const applicableFiles = await getApplicableFiles(rulePath, language, projectRoot);
82
83
  console.log("Grouping files by directory...");
83
- const filesByDirectory = groupFilesByDirectory(applicableFiles, target);
84
+ const resolvedTarget = path.resolve(projectRoot, target);
85
+ const filesByDirectory = groupFilesByDirectory(applicableFiles, resolvedTarget, projectRoot);
84
86
  if (filesByDirectory.size === 0) throw new Error(`No files found in subdirectories of target: ${target}`);
85
87
  console.log(`Found ${filesByDirectory.size} subdirectories in target`);
86
88
  console.log("Generating directory-based shards...");
@@ -10,7 +10,9 @@ interface DirectoryShardResult {
10
10
  /** Total number of shards for this directory */
11
11
  shardCount: number;
12
12
  /** Array of file paths in this shard */
13
- files: string[];
13
+ _meta_files: string[];
14
+ /** The name of the shard */
15
+ name: string;
14
16
  }
15
17
  /**
16
18
  * Options for directory-based analysis
@@ -43,9 +45,10 @@ interface DirectoryAnalysisResult {
43
45
  *
44
46
  * @param files - Array of file paths to group
45
47
  * @param target - Target directory to analyze subdirectories within
48
+ * @param projectRoot - Root directory of the project for resolving relative paths
46
49
  * @returns Map of subdirectory paths to their file lists
47
50
  */
48
- declare function groupFilesByDirectory(files: string[], target: string): Map<string, string[]>;
51
+ declare function groupFilesByDirectory(files: string[], target: string, projectRoot: string): Map<string, string[]>;
49
52
  /**
50
53
  * Creates directory-based shards using consistent hashing within each directory group.
51
54
  * Maintains consistency with existing state when provided.
package/dist/directory.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./codemod-cli-DailrcEf.js";
3
- import "./consistent-sharding-lYO6XLIO.js";
4
- import { analyzeDirectories, createDirectoryShards, groupFilesByDirectory } from "./directory-analysis-6DFgAaDz.js";
3
+ import "./consistent-sharding-BfgFDhwr.js";
4
+ import { analyzeDirectories, createDirectoryShards, groupFilesByDirectory } from "./directory-analysis-WCzArWS4.js";
5
5
 
6
6
  export { analyzeDirectories, createDirectoryShards, groupFilesByDirectory };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-B-Si8jYX.js";
2
- import { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-CkGR1oU6.js";
1
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-DhhmhZM-.js";
2
+ import { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-CBrsUJBb.js";
3
3
  export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./codemod-cli-DailrcEf.js";
3
- import { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-BcFoet6s.js";
4
- import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-lYO6XLIO.js";
3
+ import { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowner-analysis-DlwMGduk.js";
4
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-BfgFDhwr.js";
5
5
 
6
6
  export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
@@ -1,2 +1,2 @@
1
- import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-B-Si8jYX.js";
1
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-DhhmhZM-.js";
2
2
  export { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename };
package/dist/sharding.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-lYO6XLIO.js";
2
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./consistent-sharding-BfgFDhwr.js";
3
3
 
4
4
  export { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemodctl",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis",
5
5
  "type": "module",
6
6
  "exports": {