UNPKG

bws-secure

Version:

Secure environment management with Bitwarden Secrets Manager

52 lines (41 loc) 1.41 kB
#!/usr/bin/env node import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; // Get the directory name in ESM const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); function listProjects() { // Define potential config paths const configPaths = [ path.join(process.cwd(), 'bwsconfig.json'), path.join(__dirname, '../../bwsconfig.json'), path.join(__dirname, '../bwsconfig.json'), path.join(__dirname, 'bwsconfig.json') ]; // Find first existing config file let configPath = null; for (const testPath of configPaths) { if (fs.existsSync(testPath)) { configPath = testPath; break; } } if (!configPath) { console.error('\x1b[31mError: No bwsconfig.json file found in any expected location\x1b[0m'); return; } const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); console.log('\nAvailable Projects:\n'); config.projects.forEach((project) => { console.log(`\x1b[36m${project.projectName}\x1b[0m`); console.log(` Platform: ${project.platform}`); console.log(''); }); console.log('\nTo use a specific project:'); console.log('1. Add to your .env file:'); console.log(' BWS_PROJECT=project-name'); console.log('\n2. Or run with environment variable:'); console.log(' BWS_PROJECT=project-name pnpm dev\n'); } listProjects();