create-qa-architect 5.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/.editorconfig +12 -0
- package/.github/CLAUDE_MD_AUTOMATION.md +248 -0
- package/.github/PROGRESSIVE_QUALITY_IMPLEMENTATION.md +408 -0
- package/.github/PROGRESSIVE_QUALITY_PROPOSAL.md +443 -0
- package/.github/RELEASE_CHECKLIST.md +100 -0
- package/.github/dependabot.yml +50 -0
- package/.github/git-sync.sh +48 -0
- package/.github/workflows/claude-md-validation.yml +82 -0
- package/.github/workflows/nightly-gitleaks-verification.yml +176 -0
- package/.github/workflows/pnpm-ci.yml.example +53 -0
- package/.github/workflows/python-ci.yml.example +69 -0
- package/.github/workflows/quality-legacy.yml.backup +165 -0
- package/.github/workflows/quality-progressive.yml.example +291 -0
- package/.github/workflows/quality.yml +436 -0
- package/.github/workflows/release.yml +53 -0
- package/.nvmrc +1 -0
- package/.prettierignore +14 -0
- package/.prettierrc +9 -0
- package/.stylelintrc.json +5 -0
- package/README.md +212 -0
- package/config/.lighthouserc.js +45 -0
- package/config/.pre-commit-config.yaml +66 -0
- package/config/constants.js +128 -0
- package/config/defaults.js +124 -0
- package/config/pyproject.toml +124 -0
- package/config/quality-config.schema.json +97 -0
- package/config/quality-python.yml +89 -0
- package/config/requirements-dev.txt +15 -0
- package/create-saas-monetization.js +1465 -0
- package/eslint.config.cjs +117 -0
- package/eslint.config.ts.cjs +99 -0
- package/legal/README.md +106 -0
- package/legal/copyright.md +76 -0
- package/legal/disclaimer.md +146 -0
- package/legal/privacy-policy.html +324 -0
- package/legal/privacy-policy.md +196 -0
- package/legal/terms-of-service.md +224 -0
- package/lib/billing-dashboard.html +645 -0
- package/lib/config-validator.js +163 -0
- package/lib/dependency-monitoring-basic.js +185 -0
- package/lib/dependency-monitoring-premium.js +1490 -0
- package/lib/error-reporter.js +444 -0
- package/lib/interactive/prompt.js +128 -0
- package/lib/interactive/questions.js +146 -0
- package/lib/license-validator.js +403 -0
- package/lib/licensing.js +989 -0
- package/lib/package-utils.js +187 -0
- package/lib/project-maturity.js +516 -0
- package/lib/security-enhancements.js +340 -0
- package/lib/setup-enhancements.js +317 -0
- package/lib/smart-strategy-generator.js +344 -0
- package/lib/telemetry.js +323 -0
- package/lib/template-loader.js +252 -0
- package/lib/typescript-config-generator.js +210 -0
- package/lib/ui-helpers.js +74 -0
- package/lib/validation/base-validator.js +174 -0
- package/lib/validation/cache-manager.js +158 -0
- package/lib/validation/config-security.js +741 -0
- package/lib/validation/documentation.js +326 -0
- package/lib/validation/index.js +186 -0
- package/lib/validation/validation-factory.js +153 -0
- package/lib/validation/workflow-validation.js +172 -0
- package/lib/yaml-utils.js +120 -0
- package/marketing/beta-user-email-campaign.md +372 -0
- package/marketing/landing-page.html +721 -0
- package/package.json +165 -0
- package/setup.js +2076 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security-First Configuration Enhancements
|
|
3
|
+
* Comprehensive security scanning and validation by default
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generate enhanced security configuration
|
|
11
|
+
* Makes security scanning the default, not optional
|
|
12
|
+
*/
|
|
13
|
+
function generateSecurityFirstConfig(_projectPath = '.') {
|
|
14
|
+
const securityConfig = {
|
|
15
|
+
// Secret scanning configuration
|
|
16
|
+
gitleaks: {
|
|
17
|
+
enabled: true,
|
|
18
|
+
configPath: '.gitleaks.toml',
|
|
19
|
+
blockCommits: true,
|
|
20
|
+
scanHistory: false, // Don't scan full history by default for performance
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// Dependency vulnerability scanning
|
|
24
|
+
npm: {
|
|
25
|
+
audit: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
level: 'high', // Only block on high/critical vulnerabilities
|
|
28
|
+
autoFix: true,
|
|
29
|
+
excludePatterns: [],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// ESLint security rules
|
|
34
|
+
eslint: {
|
|
35
|
+
security: {
|
|
36
|
+
enabled: true,
|
|
37
|
+
rules: {
|
|
38
|
+
'security/detect-object-injection': 'error',
|
|
39
|
+
'security/detect-non-literal-regexp': 'error',
|
|
40
|
+
'security/detect-unsafe-regex': 'error',
|
|
41
|
+
'security/detect-eval-with-expression': 'error',
|
|
42
|
+
'security/detect-no-csrf-before-method-override': 'error',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// GitHub Actions security
|
|
48
|
+
github: {
|
|
49
|
+
actionlint: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
blockWorkflows: true,
|
|
52
|
+
},
|
|
53
|
+
dependabot: {
|
|
54
|
+
enabled: true,
|
|
55
|
+
autoMerge: false, // Manual review required
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return securityConfig
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Generate comprehensive security npm scripts
|
|
65
|
+
*/
|
|
66
|
+
function getSecurityScripts() {
|
|
67
|
+
return {
|
|
68
|
+
// Core security audit commands
|
|
69
|
+
'security:audit': 'npm audit --audit-level high',
|
|
70
|
+
'security:audit:fix': 'npm audit fix',
|
|
71
|
+
'security:secrets': 'npx gitleaks detect --no-banner --redact --verbose',
|
|
72
|
+
'security:secrets:baseline':
|
|
73
|
+
'npx gitleaks detect --no-banner --redact --baseline-path .gitleaksignore',
|
|
74
|
+
|
|
75
|
+
// Comprehensive security check (all tools)
|
|
76
|
+
'security:check':
|
|
77
|
+
'npm run security:audit && npm run security:secrets && npm run security:eslint',
|
|
78
|
+
'security:eslint': 'npx eslint . --config eslint-security.config.js',
|
|
79
|
+
|
|
80
|
+
// CI/CD security validation
|
|
81
|
+
'security:ci': 'npm run security:check && npm run validate:workflows',
|
|
82
|
+
'validate:workflows': 'npx actionlint .github/workflows/*.yml',
|
|
83
|
+
|
|
84
|
+
// Security reporting
|
|
85
|
+
'security:report': 'npm run security:check > security-report.txt 2>&1',
|
|
86
|
+
'security:baseline':
|
|
87
|
+
'npm run security:secrets:baseline && npm run security:audit',
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Generate .gitleaks.toml configuration
|
|
93
|
+
* Comprehensive secret detection patterns
|
|
94
|
+
*/
|
|
95
|
+
function generateGitleaksConfig() {
|
|
96
|
+
return `# Gitleaks configuration for comprehensive secret detection
|
|
97
|
+
# Generated by create-qa-architect
|
|
98
|
+
|
|
99
|
+
[extend]
|
|
100
|
+
# Use default gitleaks rules as base
|
|
101
|
+
useDefault = true
|
|
102
|
+
|
|
103
|
+
# Additional custom patterns for common secrets
|
|
104
|
+
[[rules]]
|
|
105
|
+
description = "JWT tokens"
|
|
106
|
+
id = "jwt-token"
|
|
107
|
+
regex = '''eyJ[A-Za-z0-9_/+-]{10,}={0,2}'''
|
|
108
|
+
tags = ["key", "JWT"]
|
|
109
|
+
|
|
110
|
+
[[rules]]
|
|
111
|
+
description = "Base64 encoded secrets (long)"
|
|
112
|
+
id = "base64-secret"
|
|
113
|
+
regex = '''[A-Za-z0-9+/]{40,}={0,2}'''
|
|
114
|
+
tags = ["secret", "base64"]
|
|
115
|
+
keywords = ["secret", "key", "token", "password"]
|
|
116
|
+
|
|
117
|
+
[[rules]]
|
|
118
|
+
description = "Environment variable secrets"
|
|
119
|
+
id = "env-secret"
|
|
120
|
+
regex = '''(?i)(api_key|secret|password|token)\\s*=\\s*['""][^'"\\s]{10,}['""]'''
|
|
121
|
+
tags = ["env", "secret"]
|
|
122
|
+
|
|
123
|
+
# Allowlist for test files and examples
|
|
124
|
+
[[rules.allowlist]]
|
|
125
|
+
description = "Test secrets and examples"
|
|
126
|
+
regexes = [
|
|
127
|
+
'''test_secret_.*''',
|
|
128
|
+
'''example_.*''',
|
|
129
|
+
'''dummy_.*''',
|
|
130
|
+
'''fake_.*'''
|
|
131
|
+
]
|
|
132
|
+
paths = [
|
|
133
|
+
'''tests/''',
|
|
134
|
+
'''test/''',
|
|
135
|
+
'''__tests__/''',
|
|
136
|
+
'''examples/''',
|
|
137
|
+
'''docs/''',
|
|
138
|
+
'''.md$'''
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
# Global allowlist for common false positives
|
|
142
|
+
[[allowlist]]
|
|
143
|
+
description = "Common false positives"
|
|
144
|
+
regexes = [
|
|
145
|
+
'''EXAMPLE_.*''',
|
|
146
|
+
'''your_.*_here''',
|
|
147
|
+
'''replace_with_.*''',
|
|
148
|
+
'''TODO:.*'''
|
|
149
|
+
]
|
|
150
|
+
`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Generate eslint-security.config.js for security-specific linting
|
|
155
|
+
*/
|
|
156
|
+
function generateEslintSecurityConfig() {
|
|
157
|
+
return `// ESLint security configuration
|
|
158
|
+
// Generated by create-qa-architect
|
|
159
|
+
|
|
160
|
+
const security = require('eslint-plugin-security')
|
|
161
|
+
|
|
162
|
+
module.exports = [
|
|
163
|
+
{
|
|
164
|
+
plugins: {
|
|
165
|
+
security
|
|
166
|
+
},
|
|
167
|
+
rules: {
|
|
168
|
+
// Critical security rules (errors)
|
|
169
|
+
'security/detect-object-injection': 'error',
|
|
170
|
+
'security/detect-non-literal-regexp': 'error',
|
|
171
|
+
'security/detect-unsafe-regex': 'error',
|
|
172
|
+
'security/detect-eval-with-expression': 'error',
|
|
173
|
+
'security/detect-no-csrf-before-method-override': 'error',
|
|
174
|
+
'security/detect-buffer-noassert': 'error',
|
|
175
|
+
'security/detect-child-process': 'error',
|
|
176
|
+
'security/detect-disable-mustache-escape': 'error',
|
|
177
|
+
'security/detect-new-buffer': 'error',
|
|
178
|
+
'security/detect-possible-timing-attacks': 'error',
|
|
179
|
+
'security/detect-pseudoRandomBytes': 'error',
|
|
180
|
+
|
|
181
|
+
// Warning-level security rules
|
|
182
|
+
'security/detect-bidi-characters': 'warn',
|
|
183
|
+
'security/detect-non-literal-fs-filename': 'warn',
|
|
184
|
+
'security/detect-non-literal-require': 'warn'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
`
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Apply security-first configuration to project
|
|
193
|
+
*/
|
|
194
|
+
function applySecurityFirstConfiguration(projectPath = '.') {
|
|
195
|
+
const securityFixes = []
|
|
196
|
+
|
|
197
|
+
// 1. Generate .gitleaks.toml
|
|
198
|
+
const gitleaksConfigPath = path.join(projectPath, '.gitleaks.toml')
|
|
199
|
+
if (!fs.existsSync(gitleaksConfigPath)) {
|
|
200
|
+
fs.writeFileSync(gitleaksConfigPath, generateGitleaksConfig())
|
|
201
|
+
securityFixes.push(
|
|
202
|
+
'โ
Created .gitleaks.toml - comprehensive secret detection'
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 2. Generate eslint-security.config.js
|
|
207
|
+
const eslintSecurityPath = path.join(projectPath, 'eslint-security.config.js')
|
|
208
|
+
if (!fs.existsSync(eslintSecurityPath)) {
|
|
209
|
+
fs.writeFileSync(eslintSecurityPath, generateEslintSecurityConfig())
|
|
210
|
+
securityFixes.push(
|
|
211
|
+
'โ
Created eslint-security.config.js - security-focused linting'
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 3. Create .gitleaksignore for managing false positives
|
|
216
|
+
const gitleaksIgnorePath = path.join(projectPath, '.gitleaksignore')
|
|
217
|
+
if (!fs.existsSync(gitleaksIgnorePath)) {
|
|
218
|
+
const ignoreContent = `# Gitleaks ignore file
|
|
219
|
+
# Add specific secrets that are false positives or test data
|
|
220
|
+
# Format: <rule-id>:<file-path>:<line-number>:<commit-hash>
|
|
221
|
+
|
|
222
|
+
# Example:
|
|
223
|
+
# jwt-token:tests/fixtures/example.js:15:abc123def456
|
|
224
|
+
`
|
|
225
|
+
fs.writeFileSync(gitleaksIgnorePath, ignoreContent)
|
|
226
|
+
securityFixes.push('โ
Created .gitleaksignore - manage false positives')
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 4. Generate security documentation
|
|
230
|
+
const securityDocsPath = path.join(projectPath, 'SECURITY.md')
|
|
231
|
+
if (!fs.existsSync(securityDocsPath)) {
|
|
232
|
+
const securityDocs = generateSecurityDocumentation()
|
|
233
|
+
fs.writeFileSync(securityDocsPath, securityDocs)
|
|
234
|
+
securityFixes.push(
|
|
235
|
+
'โ
Created SECURITY.md - security policies and procedures'
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return securityFixes
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Generate SECURITY.md documentation
|
|
244
|
+
*/
|
|
245
|
+
function generateSecurityDocumentation() {
|
|
246
|
+
return `# Security Policy
|
|
247
|
+
|
|
248
|
+
## Automated Security Scanning
|
|
249
|
+
|
|
250
|
+
This project uses multiple layers of automated security scanning:
|
|
251
|
+
|
|
252
|
+
### Secret Detection
|
|
253
|
+
- **Tool**: Gitleaks
|
|
254
|
+
- **Configuration**: \`.gitleaks.toml\`
|
|
255
|
+
- **Coverage**: API keys, passwords, tokens, certificates
|
|
256
|
+
- **Pre-commit**: Blocks commits containing secrets
|
|
257
|
+
- **CI/CD**: Scans all pull requests
|
|
258
|
+
|
|
259
|
+
### Dependency Scanning
|
|
260
|
+
- **Tool**: npm audit
|
|
261
|
+
- **Level**: High and critical vulnerabilities only
|
|
262
|
+
- **Auto-fix**: Enabled for compatible updates
|
|
263
|
+
- **CI/CD**: Fails builds on high/critical vulnerabilities
|
|
264
|
+
|
|
265
|
+
### Code Security Scanning
|
|
266
|
+
- **Tool**: ESLint security plugin
|
|
267
|
+
- **Configuration**: \`eslint-security.config.js\`
|
|
268
|
+
- **Coverage**: Injection attacks, unsafe patterns, crypto issues
|
|
269
|
+
- **Pre-commit**: Blocks commits with security violations
|
|
270
|
+
|
|
271
|
+
### Workflow Security
|
|
272
|
+
- **Tool**: actionlint
|
|
273
|
+
- **Coverage**: GitHub Actions workflow security issues
|
|
274
|
+
- **CI/CD**: Validates workflow syntax and security
|
|
275
|
+
|
|
276
|
+
## Manual Security Commands
|
|
277
|
+
|
|
278
|
+
\`\`\`bash
|
|
279
|
+
# Run all security checks
|
|
280
|
+
npm run security:check
|
|
281
|
+
|
|
282
|
+
# Check for secrets
|
|
283
|
+
npm run security:secrets
|
|
284
|
+
|
|
285
|
+
# Check dependencies
|
|
286
|
+
npm run security:audit
|
|
287
|
+
|
|
288
|
+
# Fix dependency issues
|
|
289
|
+
npm run security:audit:fix
|
|
290
|
+
|
|
291
|
+
# Generate security report
|
|
292
|
+
npm run security:report
|
|
293
|
+
\`\`\`
|
|
294
|
+
|
|
295
|
+
## Reporting Security Issues
|
|
296
|
+
|
|
297
|
+
If you discover a security vulnerability:
|
|
298
|
+
|
|
299
|
+
1. **DO NOT** create a public GitHub issue
|
|
300
|
+
2. Email security reports to: [Your security email]
|
|
301
|
+
3. Include:
|
|
302
|
+
- Description of the vulnerability
|
|
303
|
+
- Steps to reproduce
|
|
304
|
+
- Potential impact
|
|
305
|
+
- Suggested fix (if known)
|
|
306
|
+
|
|
307
|
+
## Security Best Practices
|
|
308
|
+
|
|
309
|
+
### For Developers
|
|
310
|
+
- Never commit secrets, API keys, or passwords
|
|
311
|
+
- Use environment variables for sensitive configuration
|
|
312
|
+
- Run \`npm run security:check\` before pushing
|
|
313
|
+
- Keep dependencies updated
|
|
314
|
+
- Review security scanner output carefully
|
|
315
|
+
|
|
316
|
+
### For CI/CD
|
|
317
|
+
- All security checks must pass before merge
|
|
318
|
+
- Dependency updates require security review
|
|
319
|
+
- Secrets stored in secure environment variables
|
|
320
|
+
- Regular security audits in automated schedules
|
|
321
|
+
|
|
322
|
+
## Security Contact
|
|
323
|
+
|
|
324
|
+
For security-related questions: [Your contact information]
|
|
325
|
+
|
|
326
|
+
## Policy Updates
|
|
327
|
+
|
|
328
|
+
This security policy is reviewed and updated quarterly.
|
|
329
|
+
Last updated: [Current date]
|
|
330
|
+
`
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
module.exports = {
|
|
334
|
+
generateSecurityFirstConfig,
|
|
335
|
+
getSecurityScripts,
|
|
336
|
+
generateGitleaksConfig,
|
|
337
|
+
generateEslintSecurityConfig,
|
|
338
|
+
applySecurityFirstConfiguration,
|
|
339
|
+
generateSecurityDocumentation,
|
|
340
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup Enhancements
|
|
3
|
+
* Critical fixes to prevent production issues that bypassed reviews and tests
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const {
|
|
9
|
+
generateTestsTypeScriptConfig,
|
|
10
|
+
getEnhancedTypeScriptScripts,
|
|
11
|
+
getEnhancedLintStaged,
|
|
12
|
+
detectProjectType,
|
|
13
|
+
getProjectQualityConfig,
|
|
14
|
+
} = require('./typescript-config-generator')
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
applySecurityFirstConfiguration,
|
|
18
|
+
getSecurityScripts,
|
|
19
|
+
} = require('./security-enhancements')
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Apply critical quality fixes that prevent production issues
|
|
23
|
+
* These fixes address gaps that allowed 13+ TypeScript errors to reach production
|
|
24
|
+
*/
|
|
25
|
+
function applyProductionQualityFixes(projectPath = '.', options = {}) {
|
|
26
|
+
const {
|
|
27
|
+
hasTypeScript = false,
|
|
28
|
+
hasPython = false,
|
|
29
|
+
skipTypeScriptTests = false,
|
|
30
|
+
} = options
|
|
31
|
+
|
|
32
|
+
console.log('\n๐ง Applying Critical Quality Fixes...')
|
|
33
|
+
|
|
34
|
+
const fixes = []
|
|
35
|
+
|
|
36
|
+
// Fix 1: Generate tests/tsconfig.json (CRITICAL)
|
|
37
|
+
if (hasTypeScript && !skipTypeScriptTests) {
|
|
38
|
+
try {
|
|
39
|
+
const testsTsConfigPath = generateTestsTypeScriptConfig(projectPath)
|
|
40
|
+
fixes.push(
|
|
41
|
+
`โ
Created ${testsTsConfigPath} - TypeScript now validates test files`
|
|
42
|
+
)
|
|
43
|
+
console.log(' ๐ฏ Fix: TypeScript errors in tests will now be caught')
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.warn(
|
|
46
|
+
`โ ๏ธ Could not generate tests TypeScript config: ${error.message}`
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Fix 2: Enhanced npm scripts with comprehensive quality gates
|
|
52
|
+
const enhancedScripts = getEnhancedTypeScriptScripts()
|
|
53
|
+
fixes.push('โ
Added comprehensive npm scripts:')
|
|
54
|
+
fixes.push(' โข type-check:all - validates both src and tests')
|
|
55
|
+
fixes.push(' โข quality:check - comprehensive pre-commit gate')
|
|
56
|
+
fixes.push(' โข quality:ci - full CI validation')
|
|
57
|
+
|
|
58
|
+
// Fix 3: Project-specific quality configuration
|
|
59
|
+
const projectType = detectProjectType(projectPath)
|
|
60
|
+
const qualityConfig = getProjectQualityConfig(projectType)
|
|
61
|
+
|
|
62
|
+
fixes.push(`โ
Detected project type: ${projectType}`)
|
|
63
|
+
fixes.push(` ๐ฏ Applied ${projectType}-specific quality standards`)
|
|
64
|
+
|
|
65
|
+
// Fix 4: Enhanced pre-commit hooks
|
|
66
|
+
const enhancedLintStaged = getEnhancedLintStaged(hasPython, hasTypeScript)
|
|
67
|
+
fixes.push('โ
Enhanced pre-commit hooks:')
|
|
68
|
+
if (hasTypeScript) {
|
|
69
|
+
fixes.push(' โข TypeScript validation on ALL .ts/.tsx files')
|
|
70
|
+
fixes.push(' โข Separate test TypeScript validation')
|
|
71
|
+
}
|
|
72
|
+
fixes.push(' โข Comprehensive ESLint + Prettier + Stylelint')
|
|
73
|
+
|
|
74
|
+
// Fix 5: Copy quality troubleshooting guide
|
|
75
|
+
copyQualityTroubleshootingGuide(projectPath)
|
|
76
|
+
fixes.push('โ
Added QUALITY_TROUBLESHOOTING.md')
|
|
77
|
+
fixes.push(' ๐ฏ Diagnostic commands for common production issues')
|
|
78
|
+
|
|
79
|
+
// Fix 6: Copy integration test templates based on project type
|
|
80
|
+
copyIntegrationTestTemplates(projectPath, projectType)
|
|
81
|
+
fixes.push(`โ
Added ${projectType} integration test templates`)
|
|
82
|
+
|
|
83
|
+
// Fix 7: Apply security-first configuration
|
|
84
|
+
const securityFixes = applySecurityFirstConfiguration(projectPath)
|
|
85
|
+
fixes.push('โ
Applied security-first configuration:')
|
|
86
|
+
securityFixes.forEach(fix => fixes.push(` ${fix}`))
|
|
87
|
+
|
|
88
|
+
// Fix 8: Add comprehensive security scripts
|
|
89
|
+
const securityScripts = getSecurityScripts()
|
|
90
|
+
fixes.push('โ
Added comprehensive security scripts:')
|
|
91
|
+
fixes.push(' โข security:check - all security validations')
|
|
92
|
+
fixes.push(' โข security:secrets - secret scanning')
|
|
93
|
+
fixes.push(' โข security:audit - dependency vulnerabilities')
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
enhancedScripts: { ...enhancedScripts, ...securityScripts },
|
|
97
|
+
enhancedLintStaged,
|
|
98
|
+
projectType,
|
|
99
|
+
qualityConfig,
|
|
100
|
+
fixes,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Copy quality troubleshooting guide to project
|
|
106
|
+
*/
|
|
107
|
+
function copyQualityTroubleshootingGuide(projectPath) {
|
|
108
|
+
const sourcePath = path.join(
|
|
109
|
+
__dirname,
|
|
110
|
+
'../templates/QUALITY_TROUBLESHOOTING.md'
|
|
111
|
+
)
|
|
112
|
+
const destPath = path.join(projectPath, 'QUALITY_TROUBLESHOOTING.md')
|
|
113
|
+
|
|
114
|
+
if (fs.existsSync(sourcePath)) {
|
|
115
|
+
fs.copyFileSync(sourcePath, destPath)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Copy integration test templates based on project type
|
|
121
|
+
*/
|
|
122
|
+
function copyIntegrationTestTemplates(projectPath, projectType) {
|
|
123
|
+
const templatesDir = path.join(__dirname, '../templates/integration-tests')
|
|
124
|
+
const targetTestsDir = path.join(projectPath, 'tests', 'integration')
|
|
125
|
+
|
|
126
|
+
// Create integration tests directory
|
|
127
|
+
if (!fs.existsSync(targetTestsDir)) {
|
|
128
|
+
fs.mkdirSync(targetTestsDir, { recursive: true })
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Copy project-type-specific template
|
|
132
|
+
const templateFile = `${projectType}.test.js`
|
|
133
|
+
const sourcePath = path.join(templatesDir, templateFile)
|
|
134
|
+
const destPath = path.join(targetTestsDir, 'example.test.js')
|
|
135
|
+
|
|
136
|
+
if (fs.existsSync(sourcePath)) {
|
|
137
|
+
fs.copyFileSync(sourcePath, destPath)
|
|
138
|
+
|
|
139
|
+
// Add README explaining the template
|
|
140
|
+
const readmePath = path.join(targetTestsDir, 'README.md')
|
|
141
|
+
const readmeContent = `# Integration Tests
|
|
142
|
+
|
|
143
|
+
This directory contains integration tests for your ${projectType}.
|
|
144
|
+
|
|
145
|
+
## Getting Started
|
|
146
|
+
|
|
147
|
+
1. Review \`example.test.js\` for patterns specific to ${projectType} projects
|
|
148
|
+
2. Rename and customize the example test for your use case
|
|
149
|
+
3. Run integration tests: \`npm run test:integration\`
|
|
150
|
+
|
|
151
|
+
## Test Types for ${projectType}
|
|
152
|
+
|
|
153
|
+
${getTestTypesDocumentation(projectType)}
|
|
154
|
+
|
|
155
|
+
## Troubleshooting
|
|
156
|
+
|
|
157
|
+
See \`QUALITY_TROUBLESHOOTING.md\` in the project root for common issues.
|
|
158
|
+
`
|
|
159
|
+
fs.writeFileSync(readmePath, readmeContent)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get test types documentation for project type
|
|
165
|
+
*/
|
|
166
|
+
function getTestTypesDocumentation(projectType) {
|
|
167
|
+
const docs = {
|
|
168
|
+
'api-service': `
|
|
169
|
+
- **Unit Tests**: Individual functions and modules
|
|
170
|
+
- **Integration Tests**: Database operations, API endpoints
|
|
171
|
+
- **E2E Tests**: Full request/response cycles
|
|
172
|
+
- **Performance Tests**: Load testing, concurrency
|
|
173
|
+
`,
|
|
174
|
+
'frontend-app': `
|
|
175
|
+
- **Unit Tests**: Components, utilities, hooks
|
|
176
|
+
- **Integration Tests**: Component interactions, forms
|
|
177
|
+
- **E2E Tests**: Browser automation, user flows
|
|
178
|
+
- **Accessibility Tests**: Screen reader, keyboard navigation
|
|
179
|
+
`,
|
|
180
|
+
'cli-tool': `
|
|
181
|
+
- **Unit Tests**: Individual commands and utilities
|
|
182
|
+
- **Integration Tests**: File operations, command execution
|
|
183
|
+
- **Command Tests**: CLI argument parsing, exit codes
|
|
184
|
+
- **Cross-platform Tests**: Windows, macOS, Linux compatibility
|
|
185
|
+
`,
|
|
186
|
+
library: `
|
|
187
|
+
- **Unit Tests**: Public API methods
|
|
188
|
+
- **Integration Tests**: Module interactions
|
|
189
|
+
- **Type Tests**: TypeScript definitions
|
|
190
|
+
- **Bundle Tests**: Distribution package validation
|
|
191
|
+
`,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
docs[projectType] ||
|
|
196
|
+
`
|
|
197
|
+
- **Unit Tests**: Individual functions and modules
|
|
198
|
+
- **Integration Tests**: System component interactions
|
|
199
|
+
- **E2E Tests**: Full application workflows
|
|
200
|
+
`
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Generate comprehensive pre-commit hook
|
|
206
|
+
* This replaces the narrow CLAUDE.md-only validation
|
|
207
|
+
*/
|
|
208
|
+
function generateEnhancedPreCommitHook(hasTypeScript, _hasPython) {
|
|
209
|
+
let hook = `#!/usr/bin/env sh
|
|
210
|
+
# Enhanced pre-commit hook - prevents production issues
|
|
211
|
+
|
|
212
|
+
echo "๐ Running comprehensive quality checks..."
|
|
213
|
+
|
|
214
|
+
# Run lint-staged (file-specific checks)
|
|
215
|
+
npx lint-staged
|
|
216
|
+
|
|
217
|
+
# Critical: TypeScript validation on ALL files
|
|
218
|
+
`
|
|
219
|
+
|
|
220
|
+
if (hasTypeScript) {
|
|
221
|
+
hook += `echo "๐ง Checking TypeScript..."
|
|
222
|
+
if ! npm run type-check:all; then
|
|
223
|
+
echo "โ TypeScript validation failed"
|
|
224
|
+
echo "๐ก Run: npm run type-check:all to see errors"
|
|
225
|
+
echo "๐ See QUALITY_TROUBLESHOOTING.md for help"
|
|
226
|
+
exit 1
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
`
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
hook += `# Fast test suite for immediate feedback
|
|
233
|
+
echo "๐งช Running fast tests..."
|
|
234
|
+
if ! npm run test:fast --if-present; then
|
|
235
|
+
echo "โ Fast tests failed"
|
|
236
|
+
echo "๐ก Run: npm test for details"
|
|
237
|
+
echo "๐ See QUALITY_TROUBLESHOOTING.md for help"
|
|
238
|
+
exit 1
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
echo "โ
All quality checks passed"
|
|
242
|
+
`
|
|
243
|
+
|
|
244
|
+
return hook
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Validate project setup for common gaps
|
|
249
|
+
* This catches configuration issues that cause production problems
|
|
250
|
+
*/
|
|
251
|
+
function validateProjectSetup(projectPath = '.') {
|
|
252
|
+
const warnings = []
|
|
253
|
+
const errors = []
|
|
254
|
+
|
|
255
|
+
// Check 1: TypeScript configuration completeness
|
|
256
|
+
const tsConfigPath = path.join(projectPath, 'tsconfig.json')
|
|
257
|
+
const testsTsConfigPath = path.join(projectPath, 'tests/tsconfig.json')
|
|
258
|
+
|
|
259
|
+
if (fs.existsSync(tsConfigPath) && !fs.existsSync(testsTsConfigPath)) {
|
|
260
|
+
errors.push(
|
|
261
|
+
'โ CRITICAL: TypeScript config exists but tests/tsconfig.json missing'
|
|
262
|
+
)
|
|
263
|
+
errors.push(
|
|
264
|
+
' ๐ฏ This allows TypeScript errors in tests to reach production'
|
|
265
|
+
)
|
|
266
|
+
errors.push(
|
|
267
|
+
' ๐ก Fix: create-qa-architect will generate tests/tsconfig.json'
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Check 2: Pre-commit hook comprehensiveness
|
|
272
|
+
const preCommitPath = path.join(projectPath, '.husky/pre-commit')
|
|
273
|
+
if (fs.existsSync(preCommitPath)) {
|
|
274
|
+
const preCommitContent = fs.readFileSync(preCommitPath, 'utf8')
|
|
275
|
+
|
|
276
|
+
if (!preCommitContent.includes('type-check')) {
|
|
277
|
+
warnings.push('โ ๏ธ Pre-commit hook missing TypeScript validation')
|
|
278
|
+
warnings.push(' ๐ก Add: npm run type-check:all to .husky/pre-commit')
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (!preCommitContent.includes('test')) {
|
|
282
|
+
warnings.push('โ ๏ธ Pre-commit hook missing test validation')
|
|
283
|
+
warnings.push(' ๐ก Add: npm run test:fast to .husky/pre-commit')
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Check 3: Quality gate scripts
|
|
288
|
+
const packageJsonPath = path.join(projectPath, 'package.json')
|
|
289
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
290
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
291
|
+
const scripts = packageJson.scripts || {}
|
|
292
|
+
|
|
293
|
+
if (!scripts['type-check:all']) {
|
|
294
|
+
warnings.push('โ ๏ธ Missing comprehensive TypeScript validation script')
|
|
295
|
+
warnings.push(
|
|
296
|
+
' ๐ก Add: "type-check:all": "npm run type-check && npm run type-check:tests"'
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (!scripts['quality:check']) {
|
|
301
|
+
warnings.push('โ ๏ธ Missing comprehensive quality check script')
|
|
302
|
+
warnings.push(
|
|
303
|
+
' ๐ก Add: "quality:check": "npm run type-check:all && npm run lint && npm test"'
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return { warnings, errors }
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
module.exports = {
|
|
312
|
+
applyProductionQualityFixes,
|
|
313
|
+
copyQualityTroubleshootingGuide,
|
|
314
|
+
copyIntegrationTestTemplates,
|
|
315
|
+
generateEnhancedPreCommitHook,
|
|
316
|
+
validateProjectSetup,
|
|
317
|
+
}
|