UNPKG

envilder

Version:

A CLI that securely centralizes your environment variables from AWS SSM as a single source of truth

63 lines 3.63 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import 'reflect-metadata'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { Command } from 'commander'; import { DispatchActionCommand } from '../../envilder/application/dispatch/DispatchActionCommand.js'; import { PackageVersionReader } from '../../envilder/infrastructure/package/PackageVersionReader.js'; import { TYPES } from '../../envilder/types.js'; import { Startup } from './Startup.js'; let serviceProvider; function executeCommand(options) { return __awaiter(this, void 0, void 0, function* () { const commandHandler = serviceProvider.get(TYPES.DispatchActionCommandHandler); const command = DispatchActionCommand.fromCliOptions(options); yield commandHandler.handleCommand(command); }); } export function main() { return __awaiter(this, void 0, void 0, function* () { const program = new Command(); const version = yield readPackageVersion(); program .name('envilder') .description('🌟 A CLI tool to manage environment variables with AWS SSM. What do you want to do today?\n\n' + '✨ Generate a .env file?\n' + ' Example: envilder --map=param-map.json --envfile=.env\n\n' + '🔄 Sync your local .env file back to AWS SSM?\n' + ' Example: envilder --push --map=param-map.json --envfile=.env\n\n' + '🎯 Create or update a single secret?\n' + ' Example: envilder --push --key=API_KEY --value=secret123 --ssm-path=/my/path\n') .version(version) .option('--map <path>', 'Path to the JSON file with environment variable mapping (required for most commands)') .option('--envfile <path>', 'Path to the .env file to be generated or imported (required for most commands)') .option('--profile <name>', 'AWS CLI profile to use (optional)') .option('--push', 'Push local .env file back to AWS SSM') .option('--key <name>', 'Single environment variable name to push (only with --push)') .option('--value <value>', 'Value of the single environment variable to push (only with --push)') .option('--ssm-path <path>', 'SSM path for the single environment variable (only with --push)') .action((options) => __awaiter(this, void 0, void 0, function* () { serviceProvider = Startup.build() .configureServices() .configureInfrastructure(options.profile) .create(); yield executeCommand(options); })); yield program.parseAsync(process.argv); }); } function readPackageVersion() { const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const packageJsonPath = join(__dirname, '../../../package.json'); return new PackageVersionReader().getVersion(packageJsonPath); } //# sourceMappingURL=Cli.js.map