mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat: add npm commands for single file operations with minified output
- Add 'npm run checkFile <file>' to run prettier and lint on a single file - Add 'npm run prettier:file <file>' for formatting individual files - Add 'npm run lint:file <file>' for linting individual files - Add 'npm run test:file <file>' for running tests on individual spec files - Create wrapper scripts that show minimal output on success, full output on errors - Update CLAUDE.md to emphasize using checkFile command frequently - Add 25-second timeout for test execution to prevent hanging
This commit is contained in:
parent
6f40e18d34
commit
4ea38843d0
4 changed files with 109 additions and 3 deletions
36
tools/check-file.js
Normal file
36
tools/check-file.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
const { execSync } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const file = process.argv[2];
|
||||
if (!file) {
|
||||
console.error('❌ Please provide a file path');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Get absolute path
|
||||
const absolutePath = path.resolve(file);
|
||||
|
||||
try {
|
||||
// Run prettier
|
||||
console.log(`🎨 Formatting ${path.basename(file)}...`);
|
||||
execSync(`npm run prettier:file ${absolutePath}`, {
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
// Run lint
|
||||
console.log(`🔍 Linting ${path.basename(file)}...`);
|
||||
const lintOutput = execSync(`npm run lint:file ${absolutePath}`, {
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
// If we get here, both commands succeeded
|
||||
console.log(`✅ ${path.basename(file)} - All checks passed!`);
|
||||
} catch (error) {
|
||||
// If there's an error, show the full output
|
||||
console.error('\n❌ Errors found:\n');
|
||||
console.error(error.stdout || error.stderr || error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
59
tools/test-file.js
Normal file
59
tools/test-file.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env node
|
||||
const { execSync } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const file = process.argv[2];
|
||||
if (!file) {
|
||||
console.error('❌ Please provide a test file path');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Get absolute path
|
||||
const absolutePath = path.resolve(file);
|
||||
|
||||
try {
|
||||
console.log(`🧪 Running tests for ${path.basename(file)}...`);
|
||||
|
||||
// Run the test directly with cross-env
|
||||
const { execSync: exec } = require('child_process');
|
||||
const output = exec(
|
||||
`./node_modules/.bin/cross-env TZ='Europe/Berlin' ./node_modules/.bin/ng test --watch=false --include="${absolutePath}"`,
|
||||
{
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
timeout: 25000, // 25 second timeout
|
||||
},
|
||||
);
|
||||
|
||||
// Extract test results
|
||||
const lines = output.split('\n');
|
||||
const successLine = lines.find(
|
||||
(line) => line.includes('SUCCESS') || line.includes('FAILED'),
|
||||
);
|
||||
const totalLine = lines.find((line) => line.includes('TOTAL:'));
|
||||
|
||||
if (totalLine) {
|
||||
const match = totalLine.match(/TOTAL: (\d+) (?:SUCCESS|FAILED)/);
|
||||
if (match) {
|
||||
const totalTests = match[1];
|
||||
if (successLine && successLine.includes('SUCCESS')) {
|
||||
console.log(`✅ All ${totalTests} tests passed!`);
|
||||
} else {
|
||||
console.log(`❌ ${totalLine.trim()}`);
|
||||
}
|
||||
} else {
|
||||
console.log(`✅ Tests completed: ${totalLine.trim()}`);
|
||||
}
|
||||
} else if (successLine) {
|
||||
console.log(`✅ ${successLine.trim()}`);
|
||||
} else {
|
||||
// Fallback - just indicate completion
|
||||
console.log(`✅ Tests completed for ${path.basename(file)}`);
|
||||
}
|
||||
} catch (error) {
|
||||
// If there's an error, show the full output
|
||||
console.error('\n❌ Test failures:\n');
|
||||
console.error(error.stdout || error.stderr || error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue