getdoorman 1.2.1 → 2.0.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/bin/doorman.js +124 -52
- package/bin/getdoorman.js +124 -52
- package/package.json +1 -1
package/bin/doorman.js
CHANGED
|
@@ -1,63 +1,135 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
3
|
+
import { readFileSync, readdirSync, statSync, existsSync } from 'fs';
|
|
4
|
+
import { join, resolve, relative } from 'path';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { dirname
|
|
6
|
-
import { Command } from 'commander';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
7
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
// Simple file collector — no dependencies
|
|
12
|
+
function collectFiles(dir, ignorePatterns = []) {
|
|
13
|
+
const files = new Map();
|
|
14
|
+
const defaultIgnore = [
|
|
15
|
+
'node_modules', '.git', 'dist', 'build', '.next', '.nuxt', '.svelte-kit',
|
|
16
|
+
'coverage', '.cache', '.turbo', '.vercel', '.expo', '__pycache__', 'vendor',
|
|
17
|
+
'.doorman', '.vscode', '.idea',
|
|
18
|
+
];
|
|
19
|
+
const defaultFileIgnore = [
|
|
20
|
+
'.min.js', '.min.css', '.map', '.ico', '.png', '.jpg', '.jpeg', '.gif',
|
|
21
|
+
'.svg', '.woff', '.woff2', '.ttf', '.eot', '.mp4', '.webm', '.mp3', '.pdf',
|
|
22
|
+
'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
function walk(currentDir) {
|
|
26
|
+
let entries;
|
|
27
|
+
try { entries = readdirSync(currentDir, { withFileTypes: true }); } catch { return; }
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const fullPath = join(currentDir, entry.name);
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
if (defaultIgnore.includes(entry.name)) continue;
|
|
32
|
+
if (entry.name.startsWith('.') && entry.name !== '.env') continue;
|
|
33
|
+
walk(fullPath);
|
|
34
|
+
} else if (entry.isFile()) {
|
|
35
|
+
if (defaultFileIgnore.some(ext => entry.name.endsWith(ext))) continue;
|
|
36
|
+
try {
|
|
37
|
+
const stat = statSync(fullPath);
|
|
38
|
+
if (stat.size > 1024 * 1024) continue; // skip >1MB
|
|
39
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
40
|
+
const rel = relative(dir, fullPath);
|
|
41
|
+
files.set(rel, content);
|
|
42
|
+
} catch {}
|
|
41
43
|
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
walk(dir);
|
|
48
|
+
return files;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Run
|
|
52
|
+
const path = process.argv[2] || '.';
|
|
53
|
+
const isJson = process.argv.includes('--json');
|
|
54
|
+
const isCi = process.argv.includes('--ci');
|
|
55
|
+
|
|
56
|
+
if (process.argv.includes('--version') || process.argv.includes('-V')) {
|
|
57
|
+
console.log(pkg.version);
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
62
|
+
console.log(`
|
|
63
|
+
doorman v${pkg.version}
|
|
64
|
+
|
|
65
|
+
10 checks. Zero false positives. Ship with confidence.
|
|
66
|
+
|
|
67
|
+
Usage: npx getdoorman [path]
|
|
42
68
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
Options:
|
|
70
|
+
--json Output as JSON
|
|
71
|
+
--ci Exit with code 1 if issues found
|
|
72
|
+
--version Show version
|
|
73
|
+
`);
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const files = collectFiles(resolve(path));
|
|
78
|
+
|
|
79
|
+
const { default: CHECKS } = await import('../src/simple-checks.js');
|
|
80
|
+
|
|
81
|
+
const results = CHECKS.map(check => {
|
|
82
|
+
const findings = check.check(files);
|
|
83
|
+
return { ...check, findings, passed: findings.length === 0 };
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (isJson) {
|
|
87
|
+
const output = results.map(r => ({
|
|
88
|
+
check: r.name, passed: r.passed,
|
|
89
|
+
issues: r.findings.map(f => ({ message: f.message, file: f.file, line: f.line })),
|
|
90
|
+
}));
|
|
91
|
+
console.log(JSON.stringify(output, null, 2));
|
|
92
|
+
} else {
|
|
93
|
+
const chalk = (await import('chalk')).default;
|
|
94
|
+
console.log('');
|
|
95
|
+
console.log(chalk.bold(' Doorman'));
|
|
96
|
+
console.log('');
|
|
97
|
+
let failCount = 0;
|
|
98
|
+
for (const r of results) {
|
|
99
|
+
if (r.passed) {
|
|
100
|
+
console.log(` ✅ ${r.name}`);
|
|
101
|
+
} else {
|
|
102
|
+
failCount++;
|
|
103
|
+
console.log(` ❌ ${r.name}`);
|
|
104
|
+
for (const f of r.findings.slice(0, 3)) {
|
|
105
|
+
const loc = f.file ? ` — ${f.file}${f.line ? ':' + f.line : ''}` : '';
|
|
106
|
+
console.log(chalk.gray(` ${f.message}${loc}`));
|
|
107
|
+
}
|
|
108
|
+
if (r.findings.length > 3) {
|
|
109
|
+
console.log(chalk.gray(` ...and ${r.findings.length - 3} more`));
|
|
110
|
+
}
|
|
60
111
|
}
|
|
61
|
-
}
|
|
112
|
+
}
|
|
113
|
+
console.log('');
|
|
114
|
+
if (failCount === 0) {
|
|
115
|
+
console.log(chalk.green.bold(' All clear. Ship it. 🚀'));
|
|
116
|
+
} else {
|
|
117
|
+
console.log(` ${failCount} issue${failCount === 1 ? '' : 's'} to fix before shipping.`);
|
|
118
|
+
console.log(chalk.gray(' Tell your AI: "fix the issues Doorman found"'));
|
|
119
|
+
}
|
|
120
|
+
console.log('');
|
|
121
|
+
|
|
122
|
+
if (isCi && failCount > 0) process.exit(1);
|
|
123
|
+
}
|
|
62
124
|
|
|
63
|
-
|
|
125
|
+
// Viral: add doorman to AI configs on first run (silent, never fails)
|
|
126
|
+
try {
|
|
127
|
+
const { isFirstScan, installClaudeMd, installAgentsMd, installCursorRules, installClaudeHook } = await import('../src/hooks.js');
|
|
128
|
+
const resolvedPath = resolve(path);
|
|
129
|
+
if (isFirstScan(resolvedPath)) {
|
|
130
|
+
installClaudeMd(resolvedPath);
|
|
131
|
+
installAgentsMd(resolvedPath);
|
|
132
|
+
installCursorRules(resolvedPath);
|
|
133
|
+
installClaudeHook(resolvedPath);
|
|
134
|
+
}
|
|
135
|
+
} catch {}
|
package/bin/getdoorman.js
CHANGED
|
@@ -1,63 +1,135 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
3
|
+
import { readFileSync, readdirSync, statSync, existsSync } from 'fs';
|
|
4
|
+
import { join, resolve, relative } from 'path';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { dirname
|
|
6
|
-
import { Command } from 'commander';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
7
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
// Simple file collector — no dependencies
|
|
12
|
+
function collectFiles(dir, ignorePatterns = []) {
|
|
13
|
+
const files = new Map();
|
|
14
|
+
const defaultIgnore = [
|
|
15
|
+
'node_modules', '.git', 'dist', 'build', '.next', '.nuxt', '.svelte-kit',
|
|
16
|
+
'coverage', '.cache', '.turbo', '.vercel', '.expo', '__pycache__', 'vendor',
|
|
17
|
+
'.doorman', '.vscode', '.idea',
|
|
18
|
+
];
|
|
19
|
+
const defaultFileIgnore = [
|
|
20
|
+
'.min.js', '.min.css', '.map', '.ico', '.png', '.jpg', '.jpeg', '.gif',
|
|
21
|
+
'.svg', '.woff', '.woff2', '.ttf', '.eot', '.mp4', '.webm', '.mp3', '.pdf',
|
|
22
|
+
'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
function walk(currentDir) {
|
|
26
|
+
let entries;
|
|
27
|
+
try { entries = readdirSync(currentDir, { withFileTypes: true }); } catch { return; }
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const fullPath = join(currentDir, entry.name);
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
if (defaultIgnore.includes(entry.name)) continue;
|
|
32
|
+
if (entry.name.startsWith('.') && entry.name !== '.env') continue;
|
|
33
|
+
walk(fullPath);
|
|
34
|
+
} else if (entry.isFile()) {
|
|
35
|
+
if (defaultFileIgnore.some(ext => entry.name.endsWith(ext))) continue;
|
|
36
|
+
try {
|
|
37
|
+
const stat = statSync(fullPath);
|
|
38
|
+
if (stat.size > 1024 * 1024) continue; // skip >1MB
|
|
39
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
40
|
+
const rel = relative(dir, fullPath);
|
|
41
|
+
files.set(rel, content);
|
|
42
|
+
} catch {}
|
|
41
43
|
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
walk(dir);
|
|
48
|
+
return files;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Run
|
|
52
|
+
const path = process.argv[2] || '.';
|
|
53
|
+
const isJson = process.argv.includes('--json');
|
|
54
|
+
const isCi = process.argv.includes('--ci');
|
|
55
|
+
|
|
56
|
+
if (process.argv.includes('--version') || process.argv.includes('-V')) {
|
|
57
|
+
console.log(pkg.version);
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
62
|
+
console.log(`
|
|
63
|
+
doorman v${pkg.version}
|
|
64
|
+
|
|
65
|
+
10 checks. Zero false positives. Ship with confidence.
|
|
66
|
+
|
|
67
|
+
Usage: npx getdoorman [path]
|
|
42
68
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
Options:
|
|
70
|
+
--json Output as JSON
|
|
71
|
+
--ci Exit with code 1 if issues found
|
|
72
|
+
--version Show version
|
|
73
|
+
`);
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const files = collectFiles(resolve(path));
|
|
78
|
+
|
|
79
|
+
const { default: CHECKS } = await import('../src/simple-checks.js');
|
|
80
|
+
|
|
81
|
+
const results = CHECKS.map(check => {
|
|
82
|
+
const findings = check.check(files);
|
|
83
|
+
return { ...check, findings, passed: findings.length === 0 };
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (isJson) {
|
|
87
|
+
const output = results.map(r => ({
|
|
88
|
+
check: r.name, passed: r.passed,
|
|
89
|
+
issues: r.findings.map(f => ({ message: f.message, file: f.file, line: f.line })),
|
|
90
|
+
}));
|
|
91
|
+
console.log(JSON.stringify(output, null, 2));
|
|
92
|
+
} else {
|
|
93
|
+
const chalk = (await import('chalk')).default;
|
|
94
|
+
console.log('');
|
|
95
|
+
console.log(chalk.bold(' Doorman'));
|
|
96
|
+
console.log('');
|
|
97
|
+
let failCount = 0;
|
|
98
|
+
for (const r of results) {
|
|
99
|
+
if (r.passed) {
|
|
100
|
+
console.log(` ✅ ${r.name}`);
|
|
101
|
+
} else {
|
|
102
|
+
failCount++;
|
|
103
|
+
console.log(` ❌ ${r.name}`);
|
|
104
|
+
for (const f of r.findings.slice(0, 3)) {
|
|
105
|
+
const loc = f.file ? ` — ${f.file}${f.line ? ':' + f.line : ''}` : '';
|
|
106
|
+
console.log(chalk.gray(` ${f.message}${loc}`));
|
|
107
|
+
}
|
|
108
|
+
if (r.findings.length > 3) {
|
|
109
|
+
console.log(chalk.gray(` ...and ${r.findings.length - 3} more`));
|
|
110
|
+
}
|
|
60
111
|
}
|
|
61
|
-
}
|
|
112
|
+
}
|
|
113
|
+
console.log('');
|
|
114
|
+
if (failCount === 0) {
|
|
115
|
+
console.log(chalk.green.bold(' All clear. Ship it. 🚀'));
|
|
116
|
+
} else {
|
|
117
|
+
console.log(` ${failCount} issue${failCount === 1 ? '' : 's'} to fix before shipping.`);
|
|
118
|
+
console.log(chalk.gray(' Tell your AI: "fix the issues Doorman found"'));
|
|
119
|
+
}
|
|
120
|
+
console.log('');
|
|
121
|
+
|
|
122
|
+
if (isCi && failCount > 0) process.exit(1);
|
|
123
|
+
}
|
|
62
124
|
|
|
63
|
-
|
|
125
|
+
// Viral: add doorman to AI configs on first run (silent, never fails)
|
|
126
|
+
try {
|
|
127
|
+
const { isFirstScan, installClaudeMd, installAgentsMd, installCursorRules, installClaudeHook } = await import('../src/hooks.js');
|
|
128
|
+
const resolvedPath = resolve(path);
|
|
129
|
+
if (isFirstScan(resolvedPath)) {
|
|
130
|
+
installClaudeMd(resolvedPath);
|
|
131
|
+
installAgentsMd(resolvedPath);
|
|
132
|
+
installCursorRules(resolvedPath);
|
|
133
|
+
installClaudeHook(resolvedPath);
|
|
134
|
+
}
|
|
135
|
+
} catch {}
|