@rachel_rotenberg/ai-contribution-tracker 1.0.25 → 1.0.26
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/cli.js +38 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -112,6 +112,41 @@ function ensurePassthroughHooks(hooksDir) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
function installPreCommitFramework(hooksDir) {
|
|
116
|
+
const configFile = path.join(process.cwd(), ".pre-commit-config.yaml");
|
|
117
|
+
if (!fs.existsSync(configFile)) return;
|
|
118
|
+
|
|
119
|
+
let preCommitBin = "";
|
|
120
|
+
try {
|
|
121
|
+
preCommitBin = execSync("which pre-commit 2>/dev/null || command -v pre-commit 2>/dev/null", {
|
|
122
|
+
encoding: "utf8", shell: true, stdio: ["pipe", "pipe", "pipe"],
|
|
123
|
+
}).trim();
|
|
124
|
+
} catch { }
|
|
125
|
+
if (!preCommitBin) return;
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
execFileSync("git", ["config", "--global", "--unset", "core.hooksPath"], {
|
|
129
|
+
encoding: "utf8", stdio: ["pipe", "pipe", "pipe"],
|
|
130
|
+
});
|
|
131
|
+
} catch { }
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
execFileSync(preCommitBin, ["install"], {
|
|
135
|
+
encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], cwd: process.cwd(),
|
|
136
|
+
});
|
|
137
|
+
ok("Installed pre-commit framework hooks");
|
|
138
|
+
} catch (e) {
|
|
139
|
+
warn(`Could not run pre-commit install: ${e.message}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const gitPath = hooksDir.replace(/\\/g, "/");
|
|
144
|
+
execFileSync("git", ["config", "--global", "core.hooksPath", gitPath], {
|
|
145
|
+
encoding: "utf8", stdio: ["pipe", "pipe", "pipe"],
|
|
146
|
+
});
|
|
147
|
+
} catch { }
|
|
148
|
+
}
|
|
149
|
+
|
|
115
150
|
/** Install the global git commit-msg hook. */
|
|
116
151
|
function installGitHook() {
|
|
117
152
|
console.log("\nGit commit-msg hook:");
|
|
@@ -128,10 +163,10 @@ function installGitHook() {
|
|
|
128
163
|
}
|
|
129
164
|
|
|
130
165
|
if (existingPath) {
|
|
131
|
-
// Use existing hooksPath directory
|
|
132
166
|
fs.mkdirSync(existingPath, { recursive: true });
|
|
133
167
|
appendOrCreateHook(existingPath);
|
|
134
168
|
ensurePassthroughHooks(existingPath);
|
|
169
|
+
installPreCommitFramework(existingPath);
|
|
135
170
|
} else {
|
|
136
171
|
const hooksDir = path.join(os.homedir(), ".config", "ai-contribution-tracker", "git-hooks");
|
|
137
172
|
fs.mkdirSync(hooksDir, { recursive: true });
|
|
@@ -148,6 +183,8 @@ function installGitHook() {
|
|
|
148
183
|
} catch (e) {
|
|
149
184
|
fail(`Could not set core.hooksPath: ${e.message}`);
|
|
150
185
|
}
|
|
186
|
+
|
|
187
|
+
installPreCommitFramework(hooksDir);
|
|
151
188
|
}
|
|
152
189
|
}
|
|
153
190
|
|
package/package.json
CHANGED