UNPKG

lambdaorm-cli

Version:
77 lines 3.02 kB
"use strict"; 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropCommand = void 0; const usesCases_1 = require("../builders/usesCases"); const path_1 = __importDefault(require("path")); const dotenv_1 = __importDefault(require("dotenv")); class DropCommand { constructor() { this.command = 'drop'; this.describe = 'Removes all database objects but not the database.'; } builder(args) { return args .option('w', { alias: 'workspace', type: 'string', describe: 'project path' }) .option('s', { alias: 'stage', type: 'string', describe: 'Name of stage' }) .option('e', { alias: 'envfile', type: 'string', describe: 'Read in a file of environment variables' }) .option('o', { alias: 'output', type: 'string', describe: 'Generates the queries but does not apply' }) .option('f', { alias: 'force', describe: 'If there is an error in a statement, continue executing the next statements' }) .option('u', { alias: 'url', describe: 'Url of service.' }); } handler(args) { return __awaiter(this, void 0, void 0, function* () { const workspace = path_1.default.resolve(process.cwd(), args.workspace || '.'); const stage = args.stage; const output = args.output; const force = args.force !== undefined; const envfile = args.envfile; const url = args.url; if (envfile) { const fullPath = path_1.default.resolve(process.cwd(), envfile); dotenv_1.default.config({ path: fullPath, override: true }); } try { yield usesCases_1.drop.execute(workspace, stage, output, url, force); } catch (error) { console.error(`error: ${error}`); } }); } } exports.DropCommand = DropCommand; //# sourceMappingURL=drop.js.map