driftdetect 0.1.0
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/bin/drift.d.ts +11 -0
- package/dist/bin/drift.d.ts.map +1 -0
- package/dist/bin/drift.js +83 -0
- package/dist/bin/drift.js.map +1 -0
- package/dist/commands/approve.d.ts +18 -0
- package/dist/commands/approve.d.ts.map +1 -0
- package/dist/commands/approve.js +271 -0
- package/dist/commands/approve.js.map +1 -0
- package/dist/commands/check.d.ts +39 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +268 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/export.d.ts +14 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +109 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/files.d.ts +13 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +88 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/ignore.d.ts +18 -0
- package/dist/commands/ignore.d.ts.map +1 -0
- package/dist/commands/ignore.js +200 -0
- package/dist/commands/ignore.js.map +1 -0
- package/dist/commands/index.d.ts +16 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +16 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +19 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +320 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/report.d.ts +20 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +202 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/scan.d.ts +27 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +444 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/status.d.ts +18 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +199 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/where.d.ts +13 -0
- package/dist/commands/where.d.ts.map +1 -0
- package/dist/commands/where.js +80 -0
- package/dist/commands/where.js.map +1 -0
- package/dist/git/hooks.d.ts +108 -0
- package/dist/git/hooks.d.ts.map +1 -0
- package/dist/git/hooks.js +389 -0
- package/dist/git/hooks.js.map +1 -0
- package/dist/git/index.d.ts +6 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +6 -0
- package/dist/git/index.js.map +1 -0
- package/dist/git/staged-files.d.ts +41 -0
- package/dist/git/staged-files.d.ts.map +1 -0
- package/dist/git/staged-files.js +118 -0
- package/dist/git/staged-files.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/reporters/github-reporter.d.ts +13 -0
- package/dist/reporters/github-reporter.d.ts.map +1 -0
- package/dist/reporters/github-reporter.js +59 -0
- package/dist/reporters/github-reporter.js.map +1 -0
- package/dist/reporters/gitlab-reporter.d.ts +16 -0
- package/dist/reporters/gitlab-reporter.d.ts.map +1 -0
- package/dist/reporters/gitlab-reporter.js +62 -0
- package/dist/reporters/gitlab-reporter.js.map +1 -0
- package/dist/reporters/index.d.ts +9 -0
- package/dist/reporters/index.d.ts.map +1 -0
- package/dist/reporters/index.js +9 -0
- package/dist/reporters/index.js.map +1 -0
- package/dist/reporters/json-reporter.d.ts +13 -0
- package/dist/reporters/json-reporter.d.ts.map +1 -0
- package/dist/reporters/json-reporter.js +44 -0
- package/dist/reporters/json-reporter.js.map +1 -0
- package/dist/reporters/text-reporter.d.ts +13 -0
- package/dist/reporters/text-reporter.d.ts.map +1 -0
- package/dist/reporters/text-reporter.js +96 -0
- package/dist/reporters/text-reporter.js.map +1 -0
- package/dist/reporters/types.d.ts +42 -0
- package/dist/reporters/types.d.ts.map +1 -0
- package/dist/reporters/types.js +5 -0
- package/dist/reporters/types.js.map +1 -0
- package/dist/services/scanner-service.d.ts +166 -0
- package/dist/services/scanner-service.d.ts.map +1 -0
- package/dist/services/scanner-service.js +453 -0
- package/dist/services/scanner-service.js.map +1 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/progress.d.ts +115 -0
- package/dist/ui/progress.d.ts.map +1 -0
- package/dist/ui/progress.js +232 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/prompts.d.ts +91 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +160 -0
- package/dist/ui/prompts.js.map +1 -0
- package/dist/ui/spinner.d.ts +109 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +179 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/table.d.ts +118 -0
- package/dist/ui/table.d.ts.map +1 -0
- package/dist/ui/table.js +235 -0
- package/dist/ui/table.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Hooks - Pre-commit and pre-push hook setup
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality to install and manage Git hooks for Drift integration.
|
|
5
|
+
* Supports both Husky-based and direct Git hooks installation.
|
|
6
|
+
*
|
|
7
|
+
* @requirements 37.1, 37.3
|
|
8
|
+
*/
|
|
9
|
+
import { exec } from 'node:child_process';
|
|
10
|
+
import { promisify } from 'node:util';
|
|
11
|
+
import * as fs from 'node:fs/promises';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
const execAsync = promisify(exec);
|
|
14
|
+
/**
|
|
15
|
+
* Pre-commit hook script content
|
|
16
|
+
* Runs drift check on staged files only
|
|
17
|
+
*/
|
|
18
|
+
const PRE_COMMIT_HOOK = `#!/bin/sh
|
|
19
|
+
# Drift pre-commit hook
|
|
20
|
+
# Checks staged files for architectural drift
|
|
21
|
+
|
|
22
|
+
# Exit on error
|
|
23
|
+
set -e
|
|
24
|
+
|
|
25
|
+
# Run drift check on staged files
|
|
26
|
+
npx drift check --staged
|
|
27
|
+
|
|
28
|
+
# Exit with drift's exit code
|
|
29
|
+
exit $?
|
|
30
|
+
`;
|
|
31
|
+
/**
|
|
32
|
+
* Pre-push hook script content
|
|
33
|
+
* Runs full drift check before push
|
|
34
|
+
*/
|
|
35
|
+
const PRE_PUSH_HOOK = `#!/bin/sh
|
|
36
|
+
# Drift pre-push hook
|
|
37
|
+
# Runs full drift check before pushing
|
|
38
|
+
|
|
39
|
+
# Exit on error
|
|
40
|
+
set -e
|
|
41
|
+
|
|
42
|
+
# Run full drift check
|
|
43
|
+
npx drift check
|
|
44
|
+
|
|
45
|
+
# Exit with drift's exit code
|
|
46
|
+
exit $?
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* Get the hook script content for a given hook type
|
|
50
|
+
*/
|
|
51
|
+
function getHookScript(hookType) {
|
|
52
|
+
switch (hookType) {
|
|
53
|
+
case 'pre-commit':
|
|
54
|
+
return PRE_COMMIT_HOOK;
|
|
55
|
+
case 'pre-push':
|
|
56
|
+
return PRE_PUSH_HOOK;
|
|
57
|
+
default:
|
|
58
|
+
throw new Error(`Unknown hook type: ${hookType}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if Husky is installed and configured in the project
|
|
63
|
+
*
|
|
64
|
+
* @param rootDir - Root directory of the repository
|
|
65
|
+
* @returns True if Husky is available
|
|
66
|
+
*/
|
|
67
|
+
export async function isHuskyInstalled(rootDir) {
|
|
68
|
+
try {
|
|
69
|
+
// Check for .husky directory
|
|
70
|
+
const huskyDir = path.join(rootDir, '.husky');
|
|
71
|
+
const stats = await fs.stat(huskyDir);
|
|
72
|
+
return stats.isDirectory();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the Git hooks directory path
|
|
80
|
+
*
|
|
81
|
+
* @param rootDir - Root directory of the repository
|
|
82
|
+
* @returns Path to the Git hooks directory
|
|
83
|
+
*/
|
|
84
|
+
export async function getGitHooksDir(rootDir) {
|
|
85
|
+
try {
|
|
86
|
+
const { stdout } = await execAsync('git rev-parse --git-path hooks', {
|
|
87
|
+
cwd: rootDir,
|
|
88
|
+
encoding: 'utf-8',
|
|
89
|
+
});
|
|
90
|
+
const hooksPath = stdout.trim();
|
|
91
|
+
// If relative path, resolve against rootDir
|
|
92
|
+
if (!path.isAbsolute(hooksPath)) {
|
|
93
|
+
return path.join(rootDir, hooksPath);
|
|
94
|
+
}
|
|
95
|
+
return hooksPath;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const err = error;
|
|
99
|
+
throw new Error(`Failed to get Git hooks directory: ${err.message}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if a hook already exists
|
|
104
|
+
*
|
|
105
|
+
* @param hookPath - Path to the hook file
|
|
106
|
+
* @returns True if hook exists
|
|
107
|
+
*/
|
|
108
|
+
async function hookExists(hookPath) {
|
|
109
|
+
try {
|
|
110
|
+
await fs.access(hookPath);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if an existing hook contains Drift commands
|
|
119
|
+
*
|
|
120
|
+
* @param hookPath - Path to the hook file
|
|
121
|
+
* @returns True if hook contains Drift commands
|
|
122
|
+
*/
|
|
123
|
+
async function hookContainsDrift(hookPath) {
|
|
124
|
+
try {
|
|
125
|
+
const content = await fs.readFile(hookPath, 'utf-8');
|
|
126
|
+
return content.includes('drift check') || content.includes('drift ');
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Install a Git hook using Husky
|
|
134
|
+
*
|
|
135
|
+
* @param rootDir - Root directory of the repository
|
|
136
|
+
* @param hookType - Type of hook to install
|
|
137
|
+
* @param options - Installation options
|
|
138
|
+
* @returns Installation result
|
|
139
|
+
*/
|
|
140
|
+
async function installHuskyHook(rootDir, hookType, options = {}) {
|
|
141
|
+
const huskyDir = path.join(rootDir, '.husky');
|
|
142
|
+
const hookPath = path.join(huskyDir, hookType);
|
|
143
|
+
// Check if hook already exists
|
|
144
|
+
if (await hookExists(hookPath)) {
|
|
145
|
+
if (!options.force) {
|
|
146
|
+
// Check if it already has Drift
|
|
147
|
+
if (await hookContainsDrift(hookPath)) {
|
|
148
|
+
return {
|
|
149
|
+
success: true,
|
|
150
|
+
hookType,
|
|
151
|
+
method: 'husky',
|
|
152
|
+
message: `Drift ${hookType} hook already configured in Husky`,
|
|
153
|
+
path: hookPath,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
hookType,
|
|
159
|
+
method: 'husky',
|
|
160
|
+
message: `${hookType} hook already exists. Use --force to overwrite or manually add Drift commands.`,
|
|
161
|
+
path: hookPath,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
// Write the hook file
|
|
167
|
+
await fs.writeFile(hookPath, getHookScript(hookType), { mode: 0o755 });
|
|
168
|
+
return {
|
|
169
|
+
success: true,
|
|
170
|
+
hookType,
|
|
171
|
+
method: 'husky',
|
|
172
|
+
message: `Successfully installed ${hookType} hook via Husky`,
|
|
173
|
+
path: hookPath,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const err = error;
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
hookType,
|
|
181
|
+
method: 'husky',
|
|
182
|
+
message: `Failed to install ${hookType} hook via Husky: ${err.message}`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Install a Git hook directly in .git/hooks
|
|
188
|
+
*
|
|
189
|
+
* @param rootDir - Root directory of the repository
|
|
190
|
+
* @param hookType - Type of hook to install
|
|
191
|
+
* @param options - Installation options
|
|
192
|
+
* @returns Installation result
|
|
193
|
+
*/
|
|
194
|
+
async function installGitHook(rootDir, hookType, options = {}) {
|
|
195
|
+
const hooksDir = await getGitHooksDir(rootDir);
|
|
196
|
+
const hookPath = path.join(hooksDir, hookType);
|
|
197
|
+
// Check if hook already exists
|
|
198
|
+
if (await hookExists(hookPath)) {
|
|
199
|
+
if (!options.force) {
|
|
200
|
+
// Check if it already has Drift
|
|
201
|
+
if (await hookContainsDrift(hookPath)) {
|
|
202
|
+
return {
|
|
203
|
+
success: true,
|
|
204
|
+
hookType,
|
|
205
|
+
method: 'git',
|
|
206
|
+
message: `Drift ${hookType} hook already configured`,
|
|
207
|
+
path: hookPath,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
hookType,
|
|
213
|
+
method: 'git',
|
|
214
|
+
message: `${hookType} hook already exists. Use --force to overwrite or manually add Drift commands.`,
|
|
215
|
+
path: hookPath,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
// Ensure hooks directory exists
|
|
221
|
+
await fs.mkdir(hooksDir, { recursive: true });
|
|
222
|
+
// Write the hook file
|
|
223
|
+
await fs.writeFile(hookPath, getHookScript(hookType), { mode: 0o755 });
|
|
224
|
+
return {
|
|
225
|
+
success: true,
|
|
226
|
+
hookType,
|
|
227
|
+
method: 'git',
|
|
228
|
+
message: `Successfully installed ${hookType} hook`,
|
|
229
|
+
path: hookPath,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
const err = error;
|
|
234
|
+
return {
|
|
235
|
+
success: false,
|
|
236
|
+
hookType,
|
|
237
|
+
method: 'git',
|
|
238
|
+
message: `Failed to install ${hookType} hook: ${err.message}`,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Install a pre-commit hook for Drift
|
|
244
|
+
*
|
|
245
|
+
* The pre-commit hook runs `drift check --staged` to check only staged files
|
|
246
|
+
* before allowing a commit.
|
|
247
|
+
*
|
|
248
|
+
* @param rootDir - Root directory of the repository
|
|
249
|
+
* @param options - Installation options
|
|
250
|
+
* @returns Installation result
|
|
251
|
+
*
|
|
252
|
+
* @requirements 37.1
|
|
253
|
+
*/
|
|
254
|
+
export async function installPreCommitHook(rootDir, options = {}) {
|
|
255
|
+
const preferHusky = options.preferHusky ?? true;
|
|
256
|
+
if (preferHusky && (await isHuskyInstalled(rootDir))) {
|
|
257
|
+
return installHuskyHook(rootDir, 'pre-commit', options);
|
|
258
|
+
}
|
|
259
|
+
return installGitHook(rootDir, 'pre-commit', options);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Install a pre-push hook for Drift
|
|
263
|
+
*
|
|
264
|
+
* The pre-push hook runs `drift check` to perform a full check
|
|
265
|
+
* before allowing a push.
|
|
266
|
+
*
|
|
267
|
+
* @param rootDir - Root directory of the repository
|
|
268
|
+
* @param options - Installation options
|
|
269
|
+
* @returns Installation result
|
|
270
|
+
*
|
|
271
|
+
* @requirements 37.3
|
|
272
|
+
*/
|
|
273
|
+
export async function installPrePushHook(rootDir, options = {}) {
|
|
274
|
+
const preferHusky = options.preferHusky ?? true;
|
|
275
|
+
if (preferHusky && (await isHuskyInstalled(rootDir))) {
|
|
276
|
+
return installHuskyHook(rootDir, 'pre-push', options);
|
|
277
|
+
}
|
|
278
|
+
return installGitHook(rootDir, 'pre-push', options);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Install all Drift Git hooks (pre-commit and pre-push)
|
|
282
|
+
*
|
|
283
|
+
* @param rootDir - Root directory of the repository
|
|
284
|
+
* @param options - Installation options
|
|
285
|
+
* @returns Array of installation results
|
|
286
|
+
*
|
|
287
|
+
* @requirements 37.1, 37.3
|
|
288
|
+
*/
|
|
289
|
+
export async function installAllHooks(rootDir, options = {}) {
|
|
290
|
+
const results = [];
|
|
291
|
+
results.push(await installPreCommitHook(rootDir, options));
|
|
292
|
+
results.push(await installPrePushHook(rootDir, options));
|
|
293
|
+
return results;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Uninstall a Git hook
|
|
297
|
+
*
|
|
298
|
+
* @param rootDir - Root directory of the repository
|
|
299
|
+
* @param hookType - Type of hook to uninstall
|
|
300
|
+
* @returns True if hook was removed
|
|
301
|
+
*/
|
|
302
|
+
export async function uninstallHook(rootDir, hookType) {
|
|
303
|
+
// Try Husky first
|
|
304
|
+
if (await isHuskyInstalled(rootDir)) {
|
|
305
|
+
const huskyHookPath = path.join(rootDir, '.husky', hookType);
|
|
306
|
+
try {
|
|
307
|
+
const content = await fs.readFile(huskyHookPath, 'utf-8');
|
|
308
|
+
// Only remove if it's a Drift hook
|
|
309
|
+
if (content.includes('drift check') || content.includes('Drift')) {
|
|
310
|
+
await fs.unlink(huskyHookPath);
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// Hook doesn't exist in Husky
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Try Git hooks directory
|
|
319
|
+
try {
|
|
320
|
+
const hooksDir = await getGitHooksDir(rootDir);
|
|
321
|
+
const hookPath = path.join(hooksDir, hookType);
|
|
322
|
+
const content = await fs.readFile(hookPath, 'utf-8');
|
|
323
|
+
// Only remove if it's a Drift hook
|
|
324
|
+
if (content.includes('drift check') || content.includes('Drift')) {
|
|
325
|
+
await fs.unlink(hookPath);
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
// Hook doesn't exist
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Uninstall all Drift Git hooks
|
|
336
|
+
*
|
|
337
|
+
* @param rootDir - Root directory of the repository
|
|
338
|
+
* @returns Object with results for each hook type
|
|
339
|
+
*/
|
|
340
|
+
export async function uninstallAllHooks(rootDir) {
|
|
341
|
+
return {
|
|
342
|
+
'pre-commit': await uninstallHook(rootDir, 'pre-commit'),
|
|
343
|
+
'pre-push': await uninstallHook(rootDir, 'pre-push'),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Get the status of installed hooks
|
|
348
|
+
*
|
|
349
|
+
* @param rootDir - Root directory of the repository
|
|
350
|
+
* @returns Object with status for each hook type
|
|
351
|
+
*/
|
|
352
|
+
export async function getHooksStatus(rootDir) {
|
|
353
|
+
const status = {
|
|
354
|
+
'pre-commit': { installed: false },
|
|
355
|
+
'pre-push': { installed: false },
|
|
356
|
+
};
|
|
357
|
+
const hookTypes = ['pre-commit', 'pre-push'];
|
|
358
|
+
for (const hookType of hookTypes) {
|
|
359
|
+
// Check Husky first
|
|
360
|
+
if (await isHuskyInstalled(rootDir)) {
|
|
361
|
+
const huskyHookPath = path.join(rootDir, '.husky', hookType);
|
|
362
|
+
if (await hookContainsDrift(huskyHookPath)) {
|
|
363
|
+
status[hookType] = {
|
|
364
|
+
installed: true,
|
|
365
|
+
method: 'husky',
|
|
366
|
+
path: huskyHookPath,
|
|
367
|
+
};
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Check Git hooks directory
|
|
372
|
+
try {
|
|
373
|
+
const hooksDir = await getGitHooksDir(rootDir);
|
|
374
|
+
const hookPath = path.join(hooksDir, hookType);
|
|
375
|
+
if (await hookContainsDrift(hookPath)) {
|
|
376
|
+
status[hookType] = {
|
|
377
|
+
installed: true,
|
|
378
|
+
method: 'git',
|
|
379
|
+
path: hookPath,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
// Git hooks directory not accessible
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return status;
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/git/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AA4BlC;;;GAGG;AACH,MAAM,eAAe,GAAG;;;;;;;;;;;;CAYvB,CAAC;AAEF;;;GAGG;AACH,MAAM,aAAa,GAAG;;;;;;;;;;;;CAYrB,CAAC;AAEF;;GAEG;AACH,SAAS,aAAa,CAAC,QAAkB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,YAAY;YACf,OAAO,eAAe,CAAC;QACzB,KAAK,UAAU;YACb,OAAO,aAAa,CAAC;QACvB;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAe;IACpD,IAAI,CAAC;QACH,6BAA6B;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO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CAAC,EAAE,CAAC;gBACtC,MAAM,CAAC,QAAQ,CAAC,GAAG;oBACjB,SAAS,EAAE,IAAI;oBACf,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,QAAQ;iBACf,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git module exports
|
|
3
|
+
*/
|
|
4
|
+
export { getStagedFiles, getChangedFiles, getUntrackedFiles, isGitRepository, getGitRoot, } from './staged-files.js';
|
|
5
|
+
export { type HookType, type HookInstallResult, type HookInstallOptions, isHuskyInstalled, getGitHooksDir, installPreCommitHook, installPrePushHook, installAllHooks, uninstallHook, uninstallAllHooks, getHooksStatus, } from './hooks.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git module exports
|
|
3
|
+
*/
|
|
4
|
+
export { getStagedFiles, getChangedFiles, getUntrackedFiles, isGitRepository, getGitRoot, } from './staged-files.js';
|
|
5
|
+
export { isHuskyInstalled, getGitHooksDir, installPreCommitHook, installPrePushHook, installAllHooks, uninstallHook, uninstallAllHooks, getHooksStatus, } from './hooks.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAIL,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Staged Files - Get list of staged files from Git
|
|
3
|
+
*
|
|
4
|
+
* @requirements 37.2
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get list of staged files from Git
|
|
8
|
+
*
|
|
9
|
+
* @param rootDir - Root directory of the repository
|
|
10
|
+
* @returns Array of staged file paths (relative to rootDir)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getStagedFiles(rootDir: string): Promise<string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Get list of all changed files (staged and unstaged)
|
|
15
|
+
*
|
|
16
|
+
* @param rootDir - Root directory of the repository
|
|
17
|
+
* @returns Array of changed file paths (relative to rootDir)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getChangedFiles(rootDir: string): Promise<string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get list of untracked files
|
|
22
|
+
*
|
|
23
|
+
* @param rootDir - Root directory of the repository
|
|
24
|
+
* @returns Array of untracked file paths (relative to rootDir)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getUntrackedFiles(rootDir: string): Promise<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a path is inside a Git repository
|
|
29
|
+
*
|
|
30
|
+
* @param dirPath - Directory path to check
|
|
31
|
+
* @returns True if inside a Git repository
|
|
32
|
+
*/
|
|
33
|
+
export declare function isGitRepository(dirPath: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the root directory of the Git repository
|
|
36
|
+
*
|
|
37
|
+
* @param dirPath - Directory path inside the repository
|
|
38
|
+
* @returns Root directory of the Git repository
|
|
39
|
+
*/
|
|
40
|
+
export declare function getGitRoot(dirPath: string): Promise<string>;
|
|
41
|
+
//# sourceMappingURL=staged-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-files.d.ts","sourceRoot":"","sources":["../../src/git/staged-files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBvE;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBxE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiB1E;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUvE;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWjE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Staged Files - Get list of staged files from Git
|
|
3
|
+
*
|
|
4
|
+
* @requirements 37.2
|
|
5
|
+
*/
|
|
6
|
+
import { exec } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
const execAsync = promisify(exec);
|
|
9
|
+
/**
|
|
10
|
+
* Get list of staged files from Git
|
|
11
|
+
*
|
|
12
|
+
* @param rootDir - Root directory of the repository
|
|
13
|
+
* @returns Array of staged file paths (relative to rootDir)
|
|
14
|
+
*/
|
|
15
|
+
export async function getStagedFiles(rootDir) {
|
|
16
|
+
try {
|
|
17
|
+
const { stdout } = await execAsync('git diff --cached --name-only --diff-filter=ACMR', {
|
|
18
|
+
cwd: rootDir,
|
|
19
|
+
encoding: 'utf-8',
|
|
20
|
+
});
|
|
21
|
+
const files = stdout
|
|
22
|
+
.split('\n')
|
|
23
|
+
.map((line) => line.trim())
|
|
24
|
+
.filter((line) => line.length > 0);
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const err = error;
|
|
29
|
+
if (err.code === 'ENOENT') {
|
|
30
|
+
throw new Error('Git is not installed or not in PATH');
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Failed to get staged files: ${err.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get list of all changed files (staged and unstaged)
|
|
37
|
+
*
|
|
38
|
+
* @param rootDir - Root directory of the repository
|
|
39
|
+
* @returns Array of changed file paths (relative to rootDir)
|
|
40
|
+
*/
|
|
41
|
+
export async function getChangedFiles(rootDir) {
|
|
42
|
+
try {
|
|
43
|
+
const { stdout } = await execAsync('git diff --name-only --diff-filter=ACMR HEAD', {
|
|
44
|
+
cwd: rootDir,
|
|
45
|
+
encoding: 'utf-8',
|
|
46
|
+
});
|
|
47
|
+
const files = stdout
|
|
48
|
+
.split('\n')
|
|
49
|
+
.map((line) => line.trim())
|
|
50
|
+
.filter((line) => line.length > 0);
|
|
51
|
+
return files;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const err = error;
|
|
55
|
+
throw new Error(`Failed to get changed files: ${err.message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get list of untracked files
|
|
60
|
+
*
|
|
61
|
+
* @param rootDir - Root directory of the repository
|
|
62
|
+
* @returns Array of untracked file paths (relative to rootDir)
|
|
63
|
+
*/
|
|
64
|
+
export async function getUntrackedFiles(rootDir) {
|
|
65
|
+
try {
|
|
66
|
+
const { stdout } = await execAsync('git ls-files --others --exclude-standard', {
|
|
67
|
+
cwd: rootDir,
|
|
68
|
+
encoding: 'utf-8',
|
|
69
|
+
});
|
|
70
|
+
const files = stdout
|
|
71
|
+
.split('\n')
|
|
72
|
+
.map((line) => line.trim())
|
|
73
|
+
.filter((line) => line.length > 0);
|
|
74
|
+
return files;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const err = error;
|
|
78
|
+
throw new Error(`Failed to get untracked files: ${err.message}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if a path is inside a Git repository
|
|
83
|
+
*
|
|
84
|
+
* @param dirPath - Directory path to check
|
|
85
|
+
* @returns True if inside a Git repository
|
|
86
|
+
*/
|
|
87
|
+
export async function isGitRepository(dirPath) {
|
|
88
|
+
try {
|
|
89
|
+
await execAsync('git rev-parse --git-dir', {
|
|
90
|
+
cwd: dirPath,
|
|
91
|
+
encoding: 'utf-8',
|
|
92
|
+
});
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the root directory of the Git repository
|
|
101
|
+
*
|
|
102
|
+
* @param dirPath - Directory path inside the repository
|
|
103
|
+
* @returns Root directory of the Git repository
|
|
104
|
+
*/
|
|
105
|
+
export async function getGitRoot(dirPath) {
|
|
106
|
+
try {
|
|
107
|
+
const { stdout } = await execAsync('git rev-parse --show-toplevel', {
|
|
108
|
+
cwd: dirPath,
|
|
109
|
+
encoding: 'utf-8',
|
|
110
|
+
});
|
|
111
|
+
return stdout.trim();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const err = error;
|
|
115
|
+
throw new Error(`Failed to get Git root: ${err.message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=staged-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-files.js","sourceRoot":"","sources":["../../src/git/staged-files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,kDAAkD,EAAE;YACrF,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,MAAM;aACjB,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAAkC,CAAC;QAC/C,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAe;IACnD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,8CAA8C,EAAE;YACjF,GA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CAAC,yBAAyB,EAAE;YACzC,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,+BAA+B,EAAE;YAClE,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAAc,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @drift/cli - Command-line interface for Drift
|
|
3
|
+
*
|
|
4
|
+
* This package provides CLI commands:
|
|
5
|
+
* - drift init: Initialize Drift in a project
|
|
6
|
+
* - drift scan: Scan codebase for patterns
|
|
7
|
+
* - drift check: Check for violations
|
|
8
|
+
* - drift status: Show current drift status
|
|
9
|
+
* - drift approve: Approve a pattern
|
|
10
|
+
* - drift ignore: Ignore a pattern
|
|
11
|
+
* - drift report: Generate reports
|
|
12
|
+
*/
|
|
13
|
+
export declare const VERSION = "0.1.0";
|
|
14
|
+
export * from './types/index.js';
|
|
15
|
+
export * from './ui/index.js';
|
|
16
|
+
export { initCommand, scanCommand, checkCommand, statusCommand, approveCommand, ignoreCommand, reportCommand, } from './commands/index.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,eAAe,CAAC;AAG9B,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @drift/cli - Command-line interface for Drift
|
|
3
|
+
*
|
|
4
|
+
* This package provides CLI commands:
|
|
5
|
+
* - drift init: Initialize Drift in a project
|
|
6
|
+
* - drift scan: Scan codebase for patterns
|
|
7
|
+
* - drift check: Check for violations
|
|
8
|
+
* - drift status: Show current drift status
|
|
9
|
+
* - drift approve: Approve a pattern
|
|
10
|
+
* - drift ignore: Ignore a pattern
|
|
11
|
+
* - drift report: Generate reports
|
|
12
|
+
*/
|
|
13
|
+
// Export version
|
|
14
|
+
export const VERSION = '0.1.0';
|
|
15
|
+
// Type exports
|
|
16
|
+
export * from './types/index.js';
|
|
17
|
+
// UI exports
|
|
18
|
+
export * from './ui/index.js';
|
|
19
|
+
// Command exports (for programmatic use)
|
|
20
|
+
export { initCommand, scanCommand, checkCommand, statusCommand, approveCommand, ignoreCommand, reportCommand, } from './commands/index.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iBAAiB;AACjB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,eAAe;AACf,cAAc,kBAAkB,CAAC;AAEjC,aAAa;AACb,cAAc,eAAe,CAAC;AAE9B,yCAAyC;AACzC,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Reporter - GitHub Actions annotations
|
|
3
|
+
*
|
|
4
|
+
* @requirements 30.2
|
|
5
|
+
*/
|
|
6
|
+
import type { Reporter, ReportData } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* GitHub Actions reporter for CI annotations
|
|
9
|
+
*/
|
|
10
|
+
export declare class GitHubReporter implements Reporter {
|
|
11
|
+
generate(data: ReportData): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=github-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-reporter.d.ts","sourceRoot":"","sources":["../../src/reporters/github-reporter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAmBvD;;GAEG;AACH,qBAAa,cAAe,YAAW,QAAQ;IAC7C,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;CAmCnC"}
|