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 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, join, resolve } from 'path';
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
- const program = new Command();
12
-
13
- program
14
- .name('getdoorman')
15
- .description('10 checks. Zero false positives. Ship with confidence.')
16
- .version(pkg.version);
17
-
18
- program
19
- .command('check', { isDefault: true })
20
- .description('Check your code before shipping')
21
- .argument('[path]', 'Path to check', '.')
22
- .option('--json', 'Output results as JSON')
23
- .option('--ci', 'Exit with code 1 if issues found')
24
- .action(async (path, options) => {
25
- try {
26
- const { collectFiles } = await import('../src/scanner.js');
27
- const { runSimpleChecks, printSimpleReport } = await import('../src/simple-reporter.js');
28
-
29
- const files = await collectFiles(resolve(path), { silent: true });
30
- const results = runSimpleChecks(files);
31
-
32
- if (options.json) {
33
- const output = results.map(r => ({
34
- check: r.name,
35
- passed: r.passed,
36
- issues: r.findings.map(f => ({ message: f.message, file: f.file, line: f.line })),
37
- }));
38
- console.log(JSON.stringify(output, null, 2));
39
- } else {
40
- printSimpleReport(results);
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
- // On first scan: add doorman to AI tool configs
44
- try {
45
- const { isFirstScan, installClaudeMd, installAgentsMd, installCursorRules, installClaudeHook } = await import('../src/hooks.js');
46
- const resolvedPath = resolve(path);
47
- if (isFirstScan(resolvedPath)) {
48
- installClaudeMd(resolvedPath);
49
- installAgentsMd(resolvedPath);
50
- installCursorRules(resolvedPath);
51
- installClaudeHook(resolvedPath);
52
- }
53
- } catch {}
54
-
55
- const failCount = results.filter(r => !r.passed).length;
56
- process.exit(options.ci && failCount > 0 ? 1 : 0);
57
- } catch (err) {
58
- console.error('Error:', err.message);
59
- process.exit(2);
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
- program.parse();
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, join, resolve } from 'path';
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
- const program = new Command();
12
-
13
- program
14
- .name('getdoorman')
15
- .description('10 checks. Zero false positives. Ship with confidence.')
16
- .version(pkg.version);
17
-
18
- program
19
- .command('check', { isDefault: true })
20
- .description('Check your code before shipping')
21
- .argument('[path]', 'Path to check', '.')
22
- .option('--json', 'Output results as JSON')
23
- .option('--ci', 'Exit with code 1 if issues found')
24
- .action(async (path, options) => {
25
- try {
26
- const { collectFiles } = await import('../src/scanner.js');
27
- const { runSimpleChecks, printSimpleReport } = await import('../src/simple-reporter.js');
28
-
29
- const files = await collectFiles(resolve(path), { silent: true });
30
- const results = runSimpleChecks(files);
31
-
32
- if (options.json) {
33
- const output = results.map(r => ({
34
- check: r.name,
35
- passed: r.passed,
36
- issues: r.findings.map(f => ({ message: f.message, file: f.file, line: f.line })),
37
- }));
38
- console.log(JSON.stringify(output, null, 2));
39
- } else {
40
- printSimpleReport(results);
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
- // On first scan: add doorman to AI tool configs
44
- try {
45
- const { isFirstScan, installClaudeMd, installAgentsMd, installCursorRules, installClaudeHook } = await import('../src/hooks.js');
46
- const resolvedPath = resolve(path);
47
- if (isFirstScan(resolvedPath)) {
48
- installClaudeMd(resolvedPath);
49
- installAgentsMd(resolvedPath);
50
- installCursorRules(resolvedPath);
51
- installClaudeHook(resolvedPath);
52
- }
53
- } catch {}
54
-
55
- const failCount = results.filter(r => !r.passed).length;
56
- process.exit(options.ci && failCount > 0 ? 1 : 0);
57
- } catch (err) {
58
- console.error('Error:', err.message);
59
- process.exit(2);
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
- program.parse();
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getdoorman",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "description": "Zero-config security scanner for AI-assisted development. 2000+ rules, 11 languages, 4 detection engines.",
5
5
  "main": "src/index.js",
6
6
  "exports": {