codemodctl 0.1.28 → 0.1.29

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.d.mts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { };
@@ -1,14 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import "./codemod-cli-Bf23tAfy.js";
3
- import { t as analyzeCodeowners } from "./codeowner-analysis-CV8ViyRo.js";
4
- import "./consistent-sharding-jDHVRq1U.js";
5
- import { t as analyzeDirectories } from "./directory-analysis-BrskPjFj.js";
2
+ import { analyzeCodeowners } from "./codeowners.mjs";
3
+ import { analyzeDirectories } from "./directory.mjs";
6
4
  import { defineCommand, runMain } from "citty";
7
5
  import crypto from "node:crypto";
8
6
  import { $ } from "execa";
9
7
  import { writeFile } from "node:fs/promises";
10
8
 
11
9
  //#region src/commands/git/create-pr.ts
10
+ function logExecError(message, error) {
11
+ console.error(message);
12
+ if (error && typeof error === "object" && "stderr" in error) {
13
+ const execError = error;
14
+ if (execError.stderr) console.error(execError.stderr);
15
+ if (execError.stdout) console.error(execError.stdout);
16
+ } else console.error(error instanceof Error ? error.message : String(error));
17
+ }
12
18
  const createPrCommand = defineCommand({
13
19
  meta: {
14
20
  name: "create-pr",
@@ -89,8 +95,7 @@ const createPrCommand = defineCommand({
89
95
  try {
90
96
  remoteBaseBranch = (await $`git remote show origin`).stdout.match(/HEAD branch: (.+)/)?.[1]?.trim() || "main";
91
97
  } catch (error) {
92
- console.error("Error: Failed to get remote base branch");
93
- console.error(error);
98
+ logExecError("Error: Failed to get remote base branch", error);
94
99
  process.exit(1);
95
100
  }
96
101
  if (codemodBranchName) prData.head = codemodBranchName;
@@ -99,43 +104,47 @@ const createPrCommand = defineCommand({
99
104
  try {
100
105
  await $`git checkout -b ${codemodBranchName}`;
101
106
  } catch (error) {
102
- console.error("Error: Failed to checkout branch");
103
- console.error(error);
107
+ logExecError("Error: Failed to checkout branch", error);
104
108
  process.exit(1);
105
109
  }
106
110
  try {
107
111
  await $`git add .`;
108
112
  } catch (error) {
109
- console.error("Error: Failed to add changes");
110
- console.error(error);
113
+ logExecError("Error: Failed to add changes", error);
111
114
  process.exit(1);
112
115
  }
113
116
  try {
114
117
  await $`git commit --no-verify -m ${commitMessage}`;
115
118
  } catch (error) {
116
- console.error("Error: Failed to commit changes");
117
- console.error(error);
119
+ logExecError("Error: Failed to commit changes", error);
118
120
  process.exit(1);
119
121
  }
120
122
  try {
121
- await $`git push origin ${codemodBranchName} --force`;
123
+ await $({ env: process.env.DEBUG ? {
124
+ GIT_TRACE: "1",
125
+ GIT_TRACE_PACKET: "1"
126
+ } : {} })`git push origin ${codemodBranchName} --force`;
122
127
  console.log(`Pushed branch to origin: ${codemodBranchName}`);
123
128
  } catch (error) {
124
- console.error("Error: Failed to push changes");
125
- console.error(error);
126
- process.exit(1);
129
+ if ((error && typeof error === "object" && "stderr" in error ? String(error.stderr) : "").includes("Everything up-to-date")) console.log(`Branch ${codemodBranchName} is already up-to-date on remote, continuing...`);
130
+ else {
131
+ logExecError("Error: Failed to push changes", error);
132
+ process.exit(1);
133
+ }
127
134
  }
128
135
  }
129
136
  if (body) prData.body = body;
130
137
  if (head && !prData.head) prData.head = head;
131
138
  if (base && !prData.base) prData.base = base;
139
+ const prUrl = `${apiEndpoint}/api/butterflow/v1/tasks/${taskId}/pull-request`;
132
140
  try {
133
- console.debug("Creating pull request...");
134
- console.debug(`Title: ${title}`);
135
- if (body) console.debug(`Body: ${body}`);
136
- if (head) console.debug(`Head: ${head}`);
137
- console.debug(`Base: ${base}`);
138
- const response = await fetch(`${apiEndpoint}/api/butterflow/v1/tasks/${taskId}/pull-request`, {
141
+ console.log("Creating pull request...");
142
+ console.log(` URL: ${prUrl}`);
143
+ console.log(` Title: ${title}`);
144
+ console.log(` Head: ${prData.head ?? head ?? "(not set)"}`);
145
+ console.log(` Base: ${prData.base ?? base ?? "(not set)"}`);
146
+ if (body) console.log(` Body: ${body}`);
147
+ const response = await fetch(prUrl, {
139
148
  method: "POST",
140
149
  headers: {
141
150
  Authorization: `Bearer ${authToken}`,
@@ -145,13 +154,20 @@ const createPrCommand = defineCommand({
145
154
  });
146
155
  if (!response.ok) {
147
156
  const errorText = await response.text();
148
- throw new Error(`HTTP ${response.status}: ${errorText}`);
157
+ console.error(`❌ Failed to create pull request: HTTP ${response.status}`);
158
+ console.error(` Response: ${errorText}`);
159
+ process.exit(1);
149
160
  }
150
161
  await response.json();
151
162
  console.log("✅ Pull request created successfully!");
152
163
  } catch (error) {
153
164
  console.error("❌ Failed to create pull request:");
154
- console.error(error instanceof Error ? error.message : String(error));
165
+ console.error(` URL: ${prUrl}`);
166
+ console.error(` PR data: ${JSON.stringify(prData)}`);
167
+ if (error instanceof TypeError && error.message === "fetch failed") {
168
+ const cause = error.cause;
169
+ console.error(` Cause: ${cause instanceof Error ? cause.message : String(cause ?? "unknown")}`);
170
+ } else console.error(` Error: ${error instanceof Error ? error.message : String(error)}`);
155
171
  process.exit(1);
156
172
  }
157
173
  }
@@ -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@1.2.1 jssg list-applicable --allow-fs --allow-fetch --allow-child-process --language ${language} --target ${projectRoot} ${rulePath}`;
10
+ const command = `npx -y codemod@latest jssg list-applicable --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",
@@ -1,3 +1,4 @@
1
+
1
2
  //#region src/utils/codeowner-analysis.d.ts
2
3
  /**
3
4
  * Result for a single team-based shard
@@ -92,4 +93,4 @@ declare function getTeamFileInfo(filesByOwner: Map<string, string[]>): TeamFileI
92
93
  */
93
94
  declare function analyzeCodeowners(options: CodeownerAnalysisOptions): Promise<CodeownerAnalysisResult>;
94
95
  //#endregion
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 };
96
+ export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as getApplicableFiles } from "./codemod-cli-Bf23tAfy.js";
2
+ import { t as getApplicableFiles } from "./codemod-cli-D-ormE6R.mjs";
3
3
  import Codeowners from "codeowners";
4
4
  import { existsSync } from "node:fs";
5
5
  import path, { resolve } from "node:path";
@@ -155,4 +155,4 @@ async function analyzeCodeowners(options) {
155
155
  }
156
156
 
157
157
  //#endregion
158
- export { generateShards as a, findCodeownersFile as i, analyzeFilesByOwner as n, getTeamFileInfo as o, analyzeFilesWithoutOwner as r, normalizeOwnerName as s, analyzeCodeowners as t };
158
+ export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
@@ -1,3 +1,4 @@
1
+
1
2
  //#region src/utils/directory-analysis.d.ts
2
3
  /**
3
4
  * Result for a single directory-based shard
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as getApplicableFiles } from "./codemod-cli-Bf23tAfy.js";
3
- import { n as calculateOptimalShardCount, r as distributeFilesAcrossShards } from "./consistent-sharding-jDHVRq1U.js";
2
+ import { t as getApplicableFiles } from "./codemod-cli-D-ormE6R.mjs";
3
+ import { calculateOptimalShardCount, distributeFilesAcrossShards } from "./sharding.mjs";
4
4
  import path from "node:path";
5
5
 
6
6
  //#region src/utils/directory-analysis.ts
@@ -95,4 +95,4 @@ async function analyzeDirectories(options) {
95
95
  }
96
96
 
97
97
  //#endregion
98
- export { createDirectoryShards as n, groupFilesByDirectory as r, analyzeDirectories as t };
98
+ export { analyzeDirectories, createDirectoryShards, groupFilesByDirectory };
@@ -0,0 +1,4 @@
1
+
2
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./sharding.mjs";
3
+ import { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowners.mjs";
4
+ export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName } from "./codeowners.mjs";
3
+ import { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename } from "./sharding.mjs";
4
+
5
+ export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
@@ -1,3 +1,4 @@
1
+
1
2
  //#region src/utils/consistent-sharding.d.ts
2
3
  /**
3
4
  * Generates a numeric hash from a filename using SHA1
@@ -64,4 +65,4 @@ declare function analyzeShardScaling(filenames: string[], oldShardCount: number,
64
65
  stableFiles: number;
65
66
  };
66
67
  //#endregion
67
- export { getFileHashPosition as a, fitsInShard as i, calculateOptimalShardCount as n, getNumericFileNameSha1 as o, distributeFilesAcrossShards as r, getShardForFilename as s, analyzeShardScaling as t };
68
+ export { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename };
@@ -105,4 +105,4 @@ function analyzeShardScaling(filenames, oldShardCount, newShardCount) {
105
105
  }
106
106
 
107
107
  //#endregion
108
- export { getFileHashPosition as a, fitsInShard as i, calculateOptimalShardCount as n, getNumericFileNameSha1 as o, distributeFilesAcrossShards as r, getShardForFilename as s, analyzeShardScaling as t };
108
+ 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.28",
3
+ "version": "0.1.29",
4
4
  "description": "CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis",
5
5
  "type": "module",
6
6
  "exports": {
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^22.16.5",
36
- "@typescript/native-preview": "7.0.0-dev.20251120.1",
36
+ "@typescript/native-preview": "7.0.0-dev.20260122.3",
37
37
  "oxlint": "^1.29.0",
38
- "tsdown": "^0.15.4",
38
+ "tsdown": "0.20.3",
39
39
  "typescript": "^5.9.3",
40
40
  "vitest": "^4.0.9",
41
41
  "@acme/tsconfig": "0.1.0"
@@ -1 +0,0 @@
1
- export { };
@@ -1,2 +0,0 @@
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-Db2TrMsU.js";
2
- export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import "./codemod-cli-Bf23tAfy.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-CV8ViyRo.js";
4
-
5
- export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, findCodeownersFile, generateShards, getTeamFileInfo, normalizeOwnerName };
package/dist/directory.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import "./codemod-cli-Bf23tAfy.js";
3
- import "./consistent-sharding-jDHVRq1U.js";
4
- import { n as createDirectoryShards, r as groupFilesByDirectory, t as analyzeDirectories } from "./directory-analysis-BrskPjFj.js";
5
-
6
- export { analyzeDirectories, createDirectoryShards, groupFilesByDirectory };
@@ -1,3 +0,0 @@
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-BzehCX2u.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-Db2TrMsU.js";
3
- export { CodeownerAnalysisOptions, CodeownerAnalysisResult, ShardResult, TeamFileInfo, analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import "./codemod-cli-Bf23tAfy.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-CV8ViyRo.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-jDHVRq1U.js";
5
-
6
- export { analyzeCodeowners, analyzeFilesByOwner, analyzeFilesWithoutOwner, analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, findCodeownersFile, fitsInShard, generateShards, getFileHashPosition, getNumericFileNameSha1, getShardForFilename, getTeamFileInfo, normalizeOwnerName };
@@ -1,2 +0,0 @@
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-BzehCX2u.js";
2
- export { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename };
package/dist/sharding.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
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-jDHVRq1U.js";
3
-
4
- export { analyzeShardScaling, calculateOptimalShardCount, distributeFilesAcrossShards, fitsInShard, getFileHashPosition, getNumericFileNameSha1, getShardForFilename };