@soulbatical/tetra-dev-toolkit 1.9.0 → 1.9.1
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/tetra-setup.js +25 -18
- package/package.json +1 -1
package/bin/tetra-setup.js
CHANGED
|
@@ -122,35 +122,42 @@ async function setupHooks(options) {
|
|
|
122
122
|
execSync('npx husky init', { stdio: 'inherit' })
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
// Create pre-commit hook
|
|
125
|
+
// Create or extend pre-commit hook with tetra-audit quick
|
|
126
126
|
const preCommitPath = join(huskyDir, 'pre-commit')
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
echo "🔍 Running Tetra quality checks..."
|
|
132
|
-
|
|
133
|
-
# Run quick security checks (fast, blocks commit on critical issues)
|
|
127
|
+
const tetraAuditBlock = `
|
|
128
|
+
# Tetra quick security checks (hardcoded secrets, direct createClient, service key exposure)
|
|
129
|
+
echo "🔍 Running Tetra security checks..."
|
|
134
130
|
npx tetra-audit quick
|
|
135
131
|
if [ $? -ne 0 ]; then
|
|
136
132
|
echo ""
|
|
137
133
|
echo "❌ Security issues found! Fix before committing."
|
|
138
|
-
echo " Run 'tetra-audit' for
|
|
134
|
+
echo " Run 'npx tetra-audit security --verbose' for details."
|
|
139
135
|
exit 1
|
|
140
136
|
fi
|
|
141
|
-
|
|
142
|
-
# Run lint-staged if configured
|
|
143
|
-
if [ -f "package.json" ] && grep -q "lint-staged" package.json; then
|
|
144
|
-
npx lint-staged
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
echo "✅ Pre-commit checks passed"
|
|
148
137
|
`
|
|
138
|
+
|
|
139
|
+
if (!existsSync(preCommitPath)) {
|
|
140
|
+
// No pre-commit hook — create one
|
|
141
|
+
const preCommitContent = `#!/bin/sh\n${tetraAuditBlock}\necho "✅ Pre-commit checks passed"\n`
|
|
142
|
+
writeFileSync(preCommitPath, preCommitContent)
|
|
143
|
+
execSync(`chmod +x ${preCommitPath}`)
|
|
144
|
+
console.log(' ✅ Created .husky/pre-commit with tetra-audit quick')
|
|
145
|
+
} else if (options.force) {
|
|
146
|
+
// Force overwrite
|
|
147
|
+
const preCommitContent = `#!/bin/sh\n${tetraAuditBlock}\necho "✅ Pre-commit checks passed"\n`
|
|
149
148
|
writeFileSync(preCommitPath, preCommitContent)
|
|
150
149
|
execSync(`chmod +x ${preCommitPath}`)
|
|
151
|
-
console.log(' ✅
|
|
150
|
+
console.log(' ✅ Overwrote .husky/pre-commit with tetra-audit quick')
|
|
152
151
|
} else {
|
|
153
|
-
|
|
152
|
+
// Pre-commit exists — add tetra-audit quick if missing
|
|
153
|
+
const existing = readFileSync(preCommitPath, 'utf-8')
|
|
154
|
+
if (!existing.includes('tetra-audit')) {
|
|
155
|
+
const updated = existing.trimEnd() + '\n' + tetraAuditBlock
|
|
156
|
+
writeFileSync(preCommitPath, updated)
|
|
157
|
+
console.log(' ✅ Added tetra-audit quick to existing .husky/pre-commit')
|
|
158
|
+
} else {
|
|
159
|
+
console.log(' ⏭️ .husky/pre-commit already has tetra-audit')
|
|
160
|
+
}
|
|
154
161
|
}
|
|
155
162
|
|
|
156
163
|
// Create or extend pre-push hook with hygiene check + RLS security gate
|