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

@dotenvx/dotenvx

Package Overview
Dependencies
Maintainers
2
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotenvx/dotenvx - npm Package Compare versions

Comparing version 1.21.0 to 1.21.1

src/lib/helpers/removeOptionsHelpParts.js

10

CHANGELOG.md

@@ -5,4 +5,12 @@ # Changelog

## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.21.0...main)
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.21.1...main)
## 1.21.1
### Changed
* for `--convention nextjs` ingnore `.env.local` for TEST environment ([#425](https://github.com/dotenvx/dotenvx/pull/425))
* for `precommit` redirect missing `dotenvx` command using POSIX compliant redirection ([#424](https://github.com/dotenvx/dotenvx/pull/424))
* make parent `dotenvx help` command less noisy by removing `[options]`. run `dotenvx COMMAND -h` to list all available options like always ([#429](https://github.com/dotenvx/dotenvx/pull/429))
## 1.21.0

@@ -9,0 +17,0 @@

2

package.json
{
"version": "1.21.0",
"version": "1.21.1",
"name": "@dotenvx/dotenvx",

@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`",

@@ -1539,3 +1539,3 @@ [![dotenvx](https://dotenvx.com/better-banner.png)](https://dotenvx.com)

$ dotenvx help
Usage: dotenvx [options] [command] [command] [args...]
Usage: dotenvx run -- yourcommand

@@ -1553,8 +1553,9 @@ a better dotenv–from the creator of `dotenv`

Commands:
run [options] inject env at runtime [dotenvx run -- yourcommand]
get [options] [key] return a single environment variable
set [options] <KEY> <value> set a single environment variable
encrypt [options] convert .env file(s) to encrypted .env file(s)
decrypt [options] convert encrypted .env file(s) to plain .env file(s)
ls [options] [directory] print all .env files in a tree structure
run inject env at runtime [dotenvx run -- yourcommand]
get [KEY] return a single environment variable
set <KEY> <value> set a single environment variable
encrypt convert .env file(s) to encrypted .env file(s)
decrypt convert encrypted .env file(s) to plain .env file(s)
keypair [KEY] print public/private keys for .env file(s)
ls [directory] print all .env files in a tree structure

@@ -1561,0 +1562,0 @@ Advanced:

@@ -12,2 +12,3 @@ #!/usr/bin/env node

const removeDynamicHelpSection = require('./../lib/helpers/removeDynamicHelpSection')
const removeOptionsHelpParts = require('./../lib/helpers/removeOptionsHelpParts')

@@ -25,2 +26,3 @@ // for use with run

program
.usage('run -- yourcommand')
.option('-l, --log-level <level>', 'set log level', 'info')

@@ -70,4 +72,5 @@ .option('-q, --quiet', 'sets log level to error')

program.command('get')
.usage('[KEY] [options]')
.description('return a single environment variable')
.argument('[key]', 'environment variable name')
.argument('[KEY]', 'environment variable name')
.option('-e, --env <strings...>', 'environment variable(s) set as string (example: "HELLO=World")', collectEnvs('env'), [])

@@ -89,2 +92,3 @@ .option('-f, --env-file <paths...>', 'path(s) to your env file(s)', collectEnvs('envFile'), [])

program.command('set')
.usage('<KEY> <value> [options]')
.description('set a single environment variable')

@@ -132,4 +136,5 @@ .addHelpText('after', examples.set)

program.command('keypair')
.usage('[KEY] [options]')
.description('print public/private keys for .env file(s)')
.argument('[key]', 'environment variable key name')
.argument('[KEY]', 'environment variable key name')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')

@@ -204,2 +209,3 @@ .option('-pp, --pretty-print', 'pretty print output')

removeDynamicHelpSection(lines)
removeOptionsHelpParts(lines)

@@ -206,0 +212,0 @@ // Filter out the hidden command from the help output

function conventions (convention) {
if (convention === 'nextjs') {
const nodeEnv = process.env.NODE_ENV || 'development'
const canonicalEnv = ['development', 'test', 'production'].includes(nodeEnv) && nodeEnv
const envs = []
if (['development', 'test', 'production'].includes(nodeEnv)) {
envs.push({ type: 'envFile', value: `.env.${nodeEnv}.local` })
}
if (['development', 'production'].includes(nodeEnv)) {
envs.push({ type: 'envFile', value: '.env.local' })
}
if (['development', 'test', 'production'].includes(nodeEnv)) {
envs.push({ type: 'envFile', value: `.env.${nodeEnv}` })
}
if (['development', 'test', 'production'].includes(nodeEnv)) {
envs.push({ type: 'envFile', value: '.env' })
}
return envs
return [
canonicalEnv && { type: 'envFile', value: `.env.${canonicalEnv}.local` },
canonicalEnv !== 'test' && { type: 'envFile', value: '.env.local' },
canonicalEnv && { type: 'envFile', value: `.env.${canonicalEnv}` },
{ type: 'envFile', value: '.env' }
].filter(Boolean)
} else {

@@ -25,0 +13,0 @@ throw new Error(`INVALID_CONVENTION: '${convention}'. permitted conventions: ['nextjs']`)

@@ -6,6 +6,6 @@ const fsx = require('./fsx')

if ! command -v dotenvx &> /dev/null
if ! command -v dotenvx 2>&1 >/dev/null
then
echo "[dotenvx][precommit] 'dotenvx' command not found"
echo "[dotenvx][precommit] ? install it with [brew install dotenvx/brew/dotenvx]"
echo "[dotenvx][precommit] ? install it with [curl -fsS https://dotenvx.sh | sh]"
echo "[dotenvx][precommit] ? other install options [https://dotenvx.com/docs/install]"

@@ -12,0 +12,0 @@ exit 1

@@ -7,3 +7,2 @@ /* istanbul ignore file */

const pluralize = require('./../helpers/pluralize')
const isFullyEncrypted = require('./../helpers/isFullyEncrypted')

@@ -31,4 +30,4 @@ const InstallPrecommitHook = require('./../helpers/installPrecommitHook')

} else {
let count = 0
const warnings = []
let successMessage = 'success'
let gitignore = MISSING_GITIGNORE

@@ -50,2 +49,4 @@

dotenvFiles.forEach(file => {
count += 1
// check if file is going to be commited

@@ -57,3 +58,3 @@ if (this._isFileToBeCommitted(file)) {

const warning = new Error(`${file} (currently ignored but should not be)`)
warning.help = `? add !${file} to .gitignore with [echo "!${file}" >> .gitignore]`
warning.help = `? add !${file} to .gitignore [echo "!${file}" >> .gitignore]`
warnings.push(warning)

@@ -68,4 +69,4 @@ }

if (!encrypted) {
const error = new Error(`${file} not encrypted (or not gitignored)`)
error.help = `? encrypt it with [dotenvx encrypt -f ${file}] or add ${file} to .gitignore with [echo ".env*" >> .gitignore]`
const error = new Error(`${file} not protected (encrypted or gitignored)`)
error.help = `? encrypt it [dotenvx encrypt -f ${file}] or gitignore it [echo "${file}" >> .gitignore]`
throw error

@@ -78,4 +79,8 @@ }

let successMessage = `.env files (${count}) protected (encrypted or gitignored)`
if (count === 0) {
successMessage = 'zero .env files'
}
if (warnings.length > 0) {
successMessage = `success (with ${pluralize('warning', warnings.length)})`
successMessage += ` with warnings (${warnings.length})`
}

@@ -82,0 +87,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