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

@commutatus/cm-env

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commutatus/cm-env - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0-0

34

index.js

@@ -13,4 +13,4 @@ #!/usr/bin/env node

var program = new Command();
var envList = ['dev', 'staging', 'prod'];
var envToFileName = {
// This is to allow easier integration for Next.js projects
var nextJsEnvToFileName = {
dev: 'development',

@@ -20,7 +20,19 @@ staging: 'staging',

};
var isNextJsEnvType = function (env) {
return env in nextJsEnvToFileName;
};
var getEncOrKeyFileNameFromEnv = function (env) {
var fileName = env;
if (isNextJsEnvType(env)) {
fileName = nextJsEnvToFileName[env];
}
return fileName;
};
var getEncryptedFilePath = function (env) {
return "keys/".concat(envToFileName[env], ".enc");
var fileName = getEncOrKeyFileNameFromEnv(env);
return "keys/".concat(fileName, ".enc");
};
var getKeyFilePath = function (env) {
return ".".concat(envToFileName[env], ".key");
var fileName = getEncOrKeyFileNameFromEnv(env);
return ".".concat(fileName, ".key");
};

@@ -37,2 +49,5 @@ var getCryptoKey = function (env) {

};
var getEnvNameArgument = function () {
return new commander_1.default.Argument('<env>', 'Name of the environment. For example: "prod", "dev", "staging"');
};
var encryptFile = function (env, envFile) {

@@ -73,3 +88,3 @@ var fileData = fs_1.default.readFileSync(envFile, 'utf8');

.description('Encrypt env file')
.addArgument(new commander_1.default.Argument('<env>', 'Name of the environment').choices(envList))
.addArgument(getEnvNameArgument())
.option('--env-file <file>', 'Path to env file', '.env.local')

@@ -83,3 +98,3 @@ .action(function (env, _a) {

.description('Decrypt env file')
.addArgument(new commander_1.default.Argument('<env>', 'Name of the environment').choices(envList))
.addArgument(getEnvNameArgument())
.option('--env-file <file>', 'Path to env file', '.env.local')

@@ -93,6 +108,11 @@ .action(function (env, _a) {

.description('Setup keys directory and generate keys')
.argument('[env]', 'Name of the environment. For example: prod, dev, staging')
.option('-f, --force', 'Force overwrite of existing keys')
.action(function (_a) {
.action(function (env, _a) {
var force = _a.force;
setupKeysDirectory();
var envList = Object.keys(nextJsEnvToFileName);
if (typeof env === 'string') {
envList = [env];
}
envList.forEach(function (env) {

@@ -99,0 +119,0 @@ var keyFilePath = getKeyFilePath(env);

{
"name": "@commutatus/cm-env",
"version": "1.0.2",
"version": "1.1.0-0",
"description": "Utilities for encrypting and decrypting env files",

@@ -5,0 +5,0 @@ "main": "index.ts",

@@ -66,2 +66,4 @@ # cm-env

Custom environment names are supported
This will create a file under `keys/[env name].enc` which is the encrypted version of `.env.local`

@@ -68,0 +70,0 @@

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