Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

secure-env-ts

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

secure-env-ts - npm Package Compare versions

Comparing version 1.2.5 to 1.2.6

112

dist/cli.js

@@ -57,2 +57,8 @@ #! /usr/bin/env node

const path = `./${file}`;
const clean = () => fs_1.default.unlinkSync(path);
process.on('exit', clean);
process.on('SIGINT', clean);
process.on('SIGUSR1', clean);
process.on('SIGUSR2', clean);
process.on('uncaughtException', clean);
fs_1.default.writeFileSync(path, decrypted);

@@ -63,3 +69,3 @@ console.log(colors_1.default.bold.white('Opening your text editor...'));

const vim = (0, command_exists_1.sync)('vim') ? 'vim' : null;
const usersEditor = process.env.EDITOR || nano || code || vim || 'vi';
const usersEditor = "code" || process.env.EDITOR || nano || code || vim || 'vi';
const childProcess = (0, child_process_1.spawn)(usersEditor, [file], {

@@ -69,3 +75,58 @@ stdio: 'inherit',

});
childProcess.on('data', () => process.exit());
let saved = false;
const diffAndSave = () => {
if (saved) {
return;
}
saved = true;
const newEnvVars = fs_1.default.readFileSync(path);
const envVarsDiff = diff.diffLines(decrypted, newEnvVars.toString());
const removed = (envVarsDiff.filter(line => line.removed))?.map((line) => line.value);
const added = (envVarsDiff.filter(line => line.added))?.map((line) => line.value);
if (!removed.length && !added.length) {
abort();
}
console.log(colors_1.default.bold.white('Your changes:'));
console.log('\n');
console.log(colors_1.default.bold.underline.red('Removed:'));
console.log('\n');
console.log(colors_1.default.red(removed.join('\n')));
console.log('\n');
console.log(colors_1.default.bold.underline.green('Added:'));
console.log('\n');
console.log(colors_1.default.green(added.join('\n')));
console.log('\n');
inquirer_1.default.prompt([{
name: 'continue',
type: 'string',
message: 'Encrypt? Yes/ No',
}]).then((answers) => {
if (['yes', 'y'].includes(answers.continue.toLowerCase())) {
(0, cryptography_1.encrypt)({ secret, inputFile: file, outputFile: inputFile, encryptionAlgo, isEdit: true })?.then(() => {
fs_1.default.unlinkSync(path);
console.log('\n');
console.log(colors_1.default.bold.white(`All done!`));
console.log(colors_1.default.bold.white(`The Environment file "${inputFile}" has been edited.`));
console.log(colors_1.default.bold.white(`Don't forget to push and commit "${inputFile}"".`));
console.log('\n');
process.exit(0);
});
}
else {
abort();
}
});
};
if (!code) {
childProcess.on('exit', diffAndSave);
}
else {
const watcher = fs_1.default.watch(path, (evenType) => {
if (evenType === "change") {
console.log(colors_1.default.bold.white(`File saved!`));
diffAndSave();
watcher.close();
}
});
}
const abort = () => {

@@ -78,49 +139,2 @@ fs_1.default.unlinkSync(path);

};
let saved = false;
fs_1.default.watch(path, (evenType) => {
console.log(evenType);
if (evenType === "change") {
if (saved) {
return;
}
saved = true;
const newEnvVars = fs_1.default.readFileSync(path);
const envVarsDiff = diff.diffLines(decrypted, newEnvVars.toString());
const removed = (envVarsDiff.filter(line => line.removed))?.map((line) => line.value);
const added = (envVarsDiff.filter(line => line.added))?.map((line) => line.value);
if (!removed.length && !added.length) {
abort();
}
console.log(colors_1.default.bold.white('Your changes:'));
console.log('\n');
console.log(colors_1.default.bold.underline.red('Removed:'));
console.log('\n');
console.log(colors_1.default.red(removed.join('\n')));
console.log('\n');
console.log(colors_1.default.bold.underline.green('Added:'));
console.log('\n');
console.log(colors_1.default.green(added.join('\n')));
console.log('\n');
inquirer_1.default.prompt([{
name: 'continue',
type: 'string',
message: 'Encrypt? Yes/ No',
}]).then((answers) => {
if (['yes', 'y'].includes(answers.continue.toLowerCase())) {
(0, cryptography_1.encrypt)({ secret, inputFile: file, outputFile: inputFile, encryptionAlgo, isEdit: true })?.then(() => {
fs_1.default.unlinkSync(path);
console.log('\n');
console.log(colors_1.default.bold.white(`All done!`));
console.log(colors_1.default.bold.white(`The Environment file "${inputFile}" has been edited.`));
console.log(colors_1.default.bold.white(`Don't forget to push and commit "${inputFile}"".`));
console.log('\n');
process.exit(0);
});
}
else {
abort();
}
});
}
});
}

@@ -127,0 +141,0 @@ else {

{
"name": "secure-env-ts",
"version": "1.2.5",
"version": "1.2.6",
"description": "Use ENVs securely with encryption",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc