UNPKG

@onboardbase/cli

Version:

[![Version](https://img.shields.io/npm/v/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![Downloads/week](https://img.shields.io/npm/dw/@onboardbase/cli.svg)](https://www.npmjs.com/package/@onboardbase/cli) [![License](https://img

22 lines (21 loc) 952 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.encryptTfState = void 0; const fs_1 = require("fs"); const utils_1 = require("../../utils"); const chalk = require("chalk"); const encryptTfState = async (flags) => { var _a; const pathToFile = (_a = flags.file) !== null && _a !== void 0 ? _a : "./terraform.tfstate"; if ((0, utils_1.isExist)(pathToFile) && pathToFile !== "-") { const fileContent = (0, fs_1.readFileSync)(pathToFile, "utf-8"); if ((0, utils_1.isJSON)(fileContent)) { const encryptedFile = await (0, utils_1.encryptSecrets)(JSON.stringify(fileContent), flags["enc-key"]); (0, fs_1.writeFileSync)(pathToFile, encryptedFile); console.log(`${chalk.greenBright(pathToFile)} encrypted successfully`); } else console.error(`Could not locate file: ${pathToFile}`); } }; exports.encryptTfState = encryptTfState;