UNPKG

ctrlshiftleft

Version:

AI-powered toolkit for embedding QA and security testing into development workflows

90 lines (74 loc) 2.63 kB
#!/usr/bin/env node /** * Ctrl+Shift+Left Directory Structure Tester * * This script creates and verifies the directory structure needed by the VS Code extension * to ensure that all commands will run correctly regardless of working directory. */ const fs = require('fs'); const path = require('path'); const { execSync } = require('child_process'); // Configuration const ROOT_DIR = path.resolve(__dirname, '..'); const TOOLS_DIR = __dirname; // All directories that should exist for the extension to work properly const REQUIRED_DIRECTORIES = [ // Project-level directories path.join(ROOT_DIR, 'tests'), path.join(ROOT_DIR, 'security-reports'), path.join(ROOT_DIR, 'reports'), path.join(ROOT_DIR, 'checklists'), // Tool-specific output directories path.join(TOOLS_DIR, 'generated-tests'), path.join(TOOLS_DIR, 'security-reports'), path.join(TOOLS_DIR, 'checklists'), // Working directory relative paths that might be used './tests', './security-reports', './checklists', './reports' ]; // Ensure each directory exists and is writable function ensureDirectories() { let allSuccessful = true; REQUIRED_DIRECTORIES.forEach(dir => { try { // Create directory if it doesn't exist if (!fs.existsSync(dir)) { console.log(`Creating directory: ${dir}`); fs.mkdirSync(dir, { recursive: true }); } // Test writability by creating and removing a test file const testFile = path.join(dir, '.test-write-permission'); fs.writeFileSync(testFile, 'test'); fs.unlinkSync(testFile); console.log(`✅ Directory is ready: ${dir}`); } catch (error) { console.error(`❌ Error with directory ${dir}: ${error.message}`); allSuccessful = false; } }); return allSuccessful; } // Main function function main() { console.log('Ctrl+Shift+Left Directory Structure Tester'); console.log('========================================='); console.log(`Root directory: ${ROOT_DIR}`); console.log(`Tools directory: ${TOOLS_DIR}`); console.log(); // Ensure all directories exist and are writable const success = ensureDirectories(); // Print summary console.log(); console.log('Test Results:'); if (success) { console.log('✅ All directories are ready for the VS Code extension'); console.log('Restart VS Code to apply these changes and try the extension again'); } else { console.log('❌ Some directories could not be created or are not writable'); console.log('Fix the permissions issues above and run this script again'); } } // Run the test main();