codemodctl 0.1.19 → 0.1.21
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 +4 -4
- package/dist/{codemod-cli-DailrcEf.js → codemod-cli-Cl-7TuC_.js} +2 -2
- package/dist/{codeowner-analysis-CBrsUJBb.d.ts → codeowner-analysis-BAoreMb0.d.ts} +2 -2
- package/dist/{codeowner-analysis-DlwMGduk.js → codeowner-analysis-Bgj5KJGV.js} +6 -6
- package/dist/codeowners.d.ts +1 -1
- package/dist/codeowners.js +2 -2
- package/dist/{consistent-sharding-BVHk7fEf.js → consistent-sharding-CQg-qiBA.js} +3 -3
- package/dist/{consistent-sharding-DhhmhZM-.d.ts → consistent-sharding-bHfBogeY.d.ts} +1 -1
- package/dist/{directory-analysis-CxsEy7Sj.js → directory-analysis-B78voaeo.js} +5 -5
- package/dist/directory.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/sharding.d.ts +1 -1
- package/dist/sharding.js +1 -1
- package/package.json +4 -1
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./codemod-cli-
|
|
3
|
-
import { analyzeCodeowners } from "./codeowner-analysis-
|
|
4
|
-
import "./consistent-sharding-
|
|
5
|
-
import { analyzeDirectories } from "./directory-analysis-
|
|
2
|
+
import "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import { t as analyzeCodeowners } from "./codeowner-analysis-Bgj5KJGV.js";
|
|
4
|
+
import "./consistent-sharding-CQg-qiBA.js";
|
|
5
|
+
import { t as analyzeDirectories } from "./directory-analysis-B78voaeo.js";
|
|
6
6
|
import { defineCommand, runMain } from "citty";
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import { $ } from "execa";
|
|
@@ -7,7 +7,7 @@ import { execSync } from "node:child_process";
|
|
|
7
7
|
*/
|
|
8
8
|
async function getApplicableFiles(rulePath, language, projectRoot) {
|
|
9
9
|
try {
|
|
10
|
-
const command = `npx -y codemod@
|
|
10
|
+
const command = `npx -y codemod@1.0.18 jssg list-applicable --no-interactive --allow-fs --allow-fetch --allow-child-process --language ${language} --target ${projectRoot} ${rulePath}`;
|
|
11
11
|
console.debug(`Executing: ${command}`);
|
|
12
12
|
const applicableFiles = execSync(command, {
|
|
13
13
|
encoding: "utf8",
|
|
@@ -23,4 +23,4 @@ async function getApplicableFiles(rulePath, language, projectRoot) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
|
-
export { getApplicableFiles };
|
|
26
|
+
export { getApplicableFiles as t };
|
|
@@ -58,7 +58,7 @@ interface CodeownerAnalysisResult {
|
|
|
58
58
|
*/
|
|
59
59
|
declare function findCodeownersFile(projectRoot?: string, explicitPath?: string): Promise<string | null>;
|
|
60
60
|
/**
|
|
61
|
-
* Normalizes owner name by removing
|
|
61
|
+
* Normalizes owner name by removing `@` prefix and converting to lowercase
|
|
62
62
|
*/
|
|
63
63
|
declare function normalizeOwnerName(owner: string): string;
|
|
64
64
|
/**
|
|
@@ -92,4 +92,4 @@ declare function getTeamFileInfo(filesByOwner: Map<string, string[]>): TeamFileI
|
|
|
92
92
|
*/
|
|
93
93
|
declare function analyzeCodeowners(options: CodeownerAnalysisOptions): Promise<CodeownerAnalysisResult>;
|
|
94
94
|
//#endregion
|
|
95
|
-
export {
|
|
95
|
+
export { analyzeCodeowners as a, findCodeownersFile as c, normalizeOwnerName as d, TeamFileInfo as i, generateShards as l, CodeownerAnalysisResult as n, analyzeFilesByOwner as o, ShardResult as r, analyzeFilesWithoutOwner as s, CodeownerAnalysisOptions as t, getTeamFileInfo as u };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getApplicableFiles } from "./codemod-cli-
|
|
2
|
+
import { t as getApplicableFiles } from "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import Codeowners from "codeowners";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import path, { resolve } from "node:path";
|
|
5
|
-
import Codeowners from "codeowners";
|
|
6
6
|
|
|
7
7
|
//#region src/utils/codeowner-analysis.ts
|
|
8
8
|
/**
|
|
@@ -25,7 +25,7 @@ async function findCodeownersFile(projectRoot = process.cwd(), explicitPath) {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Normalizes owner name by removing
|
|
28
|
+
* Normalizes owner name by removing `@` prefix and converting to lowercase
|
|
29
29
|
*/
|
|
30
30
|
function normalizeOwnerName(owner) {
|
|
31
31
|
return owner.replace("@", "").toLowerCase();
|
|
@@ -48,7 +48,7 @@ async function analyzeFilesByOwner(codeownersPath, language, rulePath, projectRo
|
|
|
48
48
|
ownerKey = normalizeOwnerName(owner ?? "unknown");
|
|
49
49
|
} else ownerKey = "unassigned";
|
|
50
50
|
if (!filesByOwner.has(ownerKey)) filesByOwner.set(ownerKey, []);
|
|
51
|
-
filesByOwner.get(ownerKey)
|
|
51
|
+
filesByOwner.get(ownerKey)?.push(relativePath);
|
|
52
52
|
}
|
|
53
53
|
return filesByOwner;
|
|
54
54
|
}
|
|
@@ -87,7 +87,7 @@ function generateShards(filesByOwner, shardSize, existingState) {
|
|
|
87
87
|
const existingByTeam = /* @__PURE__ */ new Map();
|
|
88
88
|
if (existingState) for (const shard of existingState) {
|
|
89
89
|
if (!existingByTeam.has(shard.team)) existingByTeam.set(shard.team, []);
|
|
90
|
-
existingByTeam.get(shard.team)
|
|
90
|
+
existingByTeam.get(shard.team)?.push(shard);
|
|
91
91
|
}
|
|
92
92
|
for (const [team, files] of filesByOwner.entries()) {
|
|
93
93
|
const fileCount = files.length;
|
|
@@ -155,4 +155,4 @@ async function analyzeCodeowners(options) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
//#endregion
|
|
158
|
-
export {
|
|
158
|
+
export { generateShards as a, findCodeownersFile as i, analyzeFilesByOwner as n, getTeamFileInfo as o, analyzeFilesWithoutOwner as r, normalizeOwnerName as s, analyzeCodeowners as t };
|
package/dist/codeowners.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as analyzeCodeowners, c as findCodeownersFile, d as normalizeOwnerName, i as TeamFileInfo, l as generateShards, n as CodeownerAnalysisResult, o as analyzeFilesByOwner, r as ShardResult, s as analyzeFilesWithoutOwner, t as CodeownerAnalysisOptions, u as getTeamFileInfo } from "./codeowner-analysis-BAoreMb0.js";
|
|
2
2
|
export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
|
package/dist/codeowners.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./codemod-cli-
|
|
3
|
-
import {
|
|
2
|
+
import "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import { a as generateShards, i as findCodeownersFile, n as analyzeFilesByOwner, o as getTeamFileInfo, r as analyzeFilesWithoutOwner, s as normalizeOwnerName, t as analyzeCodeowners } from "./codeowner-analysis-Bgj5KJGV.js";
|
|
4
4
|
|
|
5
5
|
export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
|
|
@@ -43,7 +43,7 @@ function getShardForFilename(filename, { shardCount }) {
|
|
|
43
43
|
});
|
|
44
44
|
shardInfo.sort((a, b) => a.position - b.position);
|
|
45
45
|
for (const shard of shardInfo) if (filePosition <= shard.position) return shard.index;
|
|
46
|
-
return shardInfo[0]
|
|
46
|
+
return shardInfo[0]?.index ?? 0;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Checks if a file belongs to a specific shard by simply checking if it's in the shard's files list
|
|
@@ -68,7 +68,7 @@ function distributeFilesAcrossShards(filenames, shardCount) {
|
|
|
68
68
|
for (let i = 0; i < shardCount; i++) shardMap.set(i, []);
|
|
69
69
|
for (const filename of filenames) {
|
|
70
70
|
const shardIndex = getShardForFilename(filename, { shardCount });
|
|
71
|
-
shardMap.get(shardIndex)
|
|
71
|
+
shardMap.get(shardIndex)?.push(filename);
|
|
72
72
|
}
|
|
73
73
|
return shardMap;
|
|
74
74
|
}
|
|
@@ -105,4 +105,4 @@ function analyzeShardScaling(filenames, oldShardCount, newShardCount) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
//#endregion
|
|
108
|
-
export {
|
|
108
|
+
export { getFileHashPosition as a, fitsInShard as i, calculateOptimalShardCount as n, getNumericFileNameSha1 as o, distributeFilesAcrossShards as r, getShardForFilename as s, analyzeShardScaling as t };
|
|
@@ -64,4 +64,4 @@ declare function analyzeShardScaling(filenames: string[], oldShardCount: number,
|
|
|
64
64
|
stableFiles: number;
|
|
65
65
|
};
|
|
66
66
|
//#endregion
|
|
67
|
-
export {
|
|
67
|
+
export { getFileHashPosition as a, fitsInShard as i, calculateOptimalShardCount as n, getNumericFileNameSha1 as o, distributeFilesAcrossShards as r, getShardForFilename as s, analyzeShardScaling as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getApplicableFiles } from "./codemod-cli-
|
|
3
|
-
import { calculateOptimalShardCount, distributeFilesAcrossShards } from "./consistent-sharding-
|
|
2
|
+
import { t as getApplicableFiles } from "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import { n as calculateOptimalShardCount, r as distributeFilesAcrossShards } from "./consistent-sharding-CQg-qiBA.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/directory-analysis.ts
|
|
@@ -26,7 +26,7 @@ function groupFilesByDirectory(files, target, projectRoot) {
|
|
|
26
26
|
if (!firstDir) continue;
|
|
27
27
|
const subdirectory = path.relative(projectRoot, path.join(resolvedTarget, firstDir));
|
|
28
28
|
if (!filesByDirectory.has(subdirectory)) filesByDirectory.set(subdirectory, []);
|
|
29
|
-
filesByDirectory.get(subdirectory)
|
|
29
|
+
filesByDirectory.get(subdirectory)?.push(relativePath);
|
|
30
30
|
}
|
|
31
31
|
return filesByDirectory;
|
|
32
32
|
}
|
|
@@ -44,7 +44,7 @@ function createDirectoryShards(filesByDirectory, shardSize, existingState) {
|
|
|
44
44
|
const existingByDirectory = /* @__PURE__ */ new Map();
|
|
45
45
|
if (existingState) for (const shard of existingState) {
|
|
46
46
|
if (!existingByDirectory.has(shard.directory)) existingByDirectory.set(shard.directory, []);
|
|
47
|
-
existingByDirectory.get(shard.directory)
|
|
47
|
+
existingByDirectory.get(shard.directory)?.push(shard);
|
|
48
48
|
}
|
|
49
49
|
for (const [directory, files] of filesByDirectory.entries()) {
|
|
50
50
|
const fileCount = files.length;
|
|
@@ -95,4 +95,4 @@ async function analyzeDirectories(options) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
//#endregion
|
|
98
|
-
export {
|
|
98
|
+
export { createDirectoryShards as n, groupFilesByDirectory as r, analyzeDirectories as t };
|
package/dist/directory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./codemod-cli-
|
|
3
|
-
import "./consistent-sharding-
|
|
4
|
-
import {
|
|
2
|
+
import "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import "./consistent-sharding-CQg-qiBA.js";
|
|
4
|
+
import { n as createDirectoryShards, r as groupFilesByDirectory, t as analyzeDirectories } from "./directory-analysis-B78voaeo.js";
|
|
5
5
|
|
|
6
6
|
export { analyzeDirectories, createDirectoryShards, groupFilesByDirectory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as getFileHashPosition, i as fitsInShard, n as calculateOptimalShardCount, o as getNumericFileNameSha1, r as distributeFilesAcrossShards, s as getShardForFilename, t as analyzeShardScaling } from "./consistent-sharding-bHfBogeY.js";
|
|
2
|
+
import { a as analyzeCodeowners, c as findCodeownersFile, d as normalizeOwnerName, i as TeamFileInfo, l as generateShards, n as CodeownerAnalysisResult, o as analyzeFilesByOwner, r as ShardResult, s as analyzeFilesWithoutOwner, t as CodeownerAnalysisOptions, u as getTeamFileInfo } from "./codeowner-analysis-BAoreMb0.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
|
-
import "./codemod-cli-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import "./codemod-cli-Cl-7TuC_.js";
|
|
3
|
+
import { a as generateShards, i as findCodeownersFile, n as analyzeFilesByOwner, o as getTeamFileInfo, r as analyzeFilesWithoutOwner, s as normalizeOwnerName, t as analyzeCodeowners } from "./codeowner-analysis-Bgj5KJGV.js";
|
|
4
|
+
import { a as getFileHashPosition, i as fitsInShard, n as calculateOptimalShardCount, o as getNumericFileNameSha1, r as distributeFilesAcrossShards, s as getShardForFilename, t as analyzeShardScaling } from "./consistent-sharding-CQg-qiBA.js";
|
|
5
5
|
|
|
6
6
|
export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
|
package/dist/sharding.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as getFileHashPosition, i as fitsInShard, n as calculateOptimalShardCount, o as getNumericFileNameSha1, r as distributeFilesAcrossShards, s as getShardForFilename, t as analyzeShardScaling } from "./consistent-sharding-bHfBogeY.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 {
|
|
2
|
+
import { a as getFileHashPosition, i as fitsInShard, n as calculateOptimalShardCount, o as getNumericFileNameSha1, r as distributeFilesAcrossShards, s as getShardForFilename, t as analyzeShardScaling } from "./consistent-sharding-CQg-qiBA.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.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.16.5",
|
|
36
|
+
"@typescript/native-preview": "7.0.0-dev.20251018.1",
|
|
37
|
+
"oxlint": "^1.23.0",
|
|
36
38
|
"tsdown": "^0.15.4",
|
|
37
39
|
"typescript": "^5.7.2",
|
|
38
40
|
"vitest": "^3.0.5",
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"build": "tsdown",
|
|
55
57
|
"dev": "tsdown --watch",
|
|
56
58
|
"clean": "rm -rf dist",
|
|
59
|
+
"typecheck:native": "tsgo --noEmit",
|
|
57
60
|
"typecheck": "tsc --noEmit",
|
|
58
61
|
"test": "vitest"
|
|
59
62
|
}
|