codemodctl 0.1.15 → 0.1.16
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "./codemod-cli-DailrcEf.js";
|
|
3
3
|
import { analyzeCodeowners } from "./codeowner-analysis-BcFoet6s.js";
|
|
4
4
|
import "./consistent-sharding-lYO6XLIO.js";
|
|
5
|
-
import { analyzeDirectories } from "./directory-analysis-
|
|
5
|
+
import { analyzeDirectories } from "./directory-analysis-v_cncT1X.js";
|
|
6
6
|
import { defineCommand, runMain } from "citty";
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import { $ } from "execa";
|
|
@@ -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
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
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(
|
|
27
|
+
const subdirectory = path.relative(projectRoot, path.join(resolvedTarget, firstDir));
|
|
25
28
|
if (!filesByDirectory.has(subdirectory)) filesByDirectory.set(subdirectory, []);
|
|
26
|
-
filesByDirectory.get(subdirectory).push(
|
|
29
|
+
filesByDirectory.get(subdirectory).push(relativePath);
|
|
27
30
|
}
|
|
28
31
|
return filesByDirectory;
|
|
29
32
|
}
|
|
@@ -73,14 +76,12 @@ function createDirectoryShards(filesByDirectory, shardSize, existingState) {
|
|
|
73
76
|
*/
|
|
74
77
|
async function analyzeDirectories(options) {
|
|
75
78
|
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
79
|
if (existingState) console.debug(`Using existing state with ${existingState.length} shards`);
|
|
80
80
|
console.log("Analyzing files with CLI command...");
|
|
81
81
|
const applicableFiles = await getApplicableFiles(rulePath, language, projectRoot);
|
|
82
82
|
console.log("Grouping files by directory...");
|
|
83
|
-
const
|
|
83
|
+
const resolvedTarget = path.resolve(projectRoot, target);
|
|
84
|
+
const filesByDirectory = groupFilesByDirectory(applicableFiles, resolvedTarget, projectRoot);
|
|
84
85
|
if (filesByDirectory.size === 0) throw new Error(`No files found in subdirectories of target: ${target}`);
|
|
85
86
|
console.log(`Found ${filesByDirectory.size} subdirectories in target`);
|
|
86
87
|
console.log("Generating directory-based shards...");
|
package/dist/directory.d.ts
CHANGED
|
@@ -43,9 +43,10 @@ interface DirectoryAnalysisResult {
|
|
|
43
43
|
*
|
|
44
44
|
* @param files - Array of file paths to group
|
|
45
45
|
* @param target - Target directory to analyze subdirectories within
|
|
46
|
+
* @param projectRoot - Root directory of the project for resolving relative paths
|
|
46
47
|
* @returns Map of subdirectory paths to their file lists
|
|
47
48
|
*/
|
|
48
|
-
declare function groupFilesByDirectory(files: string[], target: string): Map<string, string[]>;
|
|
49
|
+
declare function groupFilesByDirectory(files: string[], target: string, projectRoot: string): Map<string, string[]>;
|
|
49
50
|
/**
|
|
50
51
|
* Creates directory-based shards using consistent hashing within each directory group.
|
|
51
52
|
* 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
3
|
import "./consistent-sharding-lYO6XLIO.js";
|
|
4
|
-
import { analyzeDirectories, createDirectoryShards, groupFilesByDirectory } from "./directory-analysis-
|
|
4
|
+
import { analyzeDirectories, createDirectoryShards, groupFilesByDirectory } from "./directory-analysis-v_cncT1X.js";
|
|
5
5
|
|
|
6
6
|
export { analyzeDirectories, createDirectoryShards, groupFilesByDirectory };
|