@dotenvx/dotenvx
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -5,4 +5,10 @@ # Changelog | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.9.1...main) | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.10.0...main) | ||
## 1.10.0 | ||
### Removed | ||
* remove `dotenvx ext vault`, replace with [dotenvx-ext-vault](https://github.com/dotenvx/dotenvx-ext-vaut) (install there to continue using `ext vault`) ([#351](https://github.com/dotenvx/dotenvx/pull/351)) | ||
## 1.9.1 | ||
@@ -9,0 +15,0 @@ |
{ | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -48,4 +48,3 @@ "description": "a better dotenv–from the creator of `dotenv`", | ||
"tinyexec": "^0.2.0", | ||
"which": "^4.0.0", | ||
"xxhashjs": "^0.2.2" | ||
"which": "^4.0.0" | ||
}, | ||
@@ -52,0 +51,0 @@ "devDependencies": { |
@@ -12,2 +12,5 @@ const { Command } = require('commander') | ||
// list known extensions here you want to display | ||
ext.addHelpText('after', ' vault 🔐 manage .env.vault files') | ||
ext | ||
@@ -59,4 +62,2 @@ .argument('[command]', 'dynamic ext command') | ||
ext.addCommand(require('./../commands/ext/vault')) | ||
module.exports = ext |
@@ -25,28 +25,2 @@ const run = function () { | ||
const vaultEncrypt = function () { | ||
return ` | ||
Examples: | ||
\`\`\` | ||
$ dotenvx ext vault encrypt | ||
\`\`\` | ||
Try it: | ||
\`\`\` | ||
$ echo "HELLO=World" > .env | ||
$ echo "HELLO=production" > .env.production | ||
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js | ||
$ dotenvx ext vault encrypt | ||
encrypted to .env.vault (.env,.env.production) | ||
keys added to .env.keys (DOTENV_KEY_PRODUCTION,DOTENV_KEY_PRODUCTION) | ||
$ DOTENV_KEY='<dotenv_key_production>' dotenvx run -- node index.js | ||
[dotenvx] injecting env (1) from encrypted .env.vault | ||
Hello production | ||
\`\`\` | ||
` | ||
} | ||
const precommit = function () { | ||
@@ -121,3 +95,2 @@ return ` | ||
run, | ||
vaultEncrypt, | ||
precommit, | ||
@@ -124,0 +97,0 @@ prebuild, |
@@ -25,6 +25,6 @@ const path = require('path') | ||
if (result.error) { | ||
if (command === 'vault') { | ||
// when ready, uncomment to deprecate ext vault | ||
// logger.warn(`[INSTALLATION_NEEDED] install dotenvx-ext-${command} to use [dotenvx ext ${command}] commands`) | ||
// logger.help('? see installation instructions [https://github.com/dotenvx/dotenvx-ext-vault]') | ||
// list known extension here for convenience to the user | ||
if (['vault', 'hub'].includes(command)) { | ||
logger.warn(`[INSTALLATION_NEEDED] install dotenvx-ext-${command} to use [dotenvx ext ${command}] commands`) | ||
logger.help('? see installation instructions [https://github.com/dotenvx/dotenvx-ext-vault]') | ||
} else { | ||
@@ -31,0 +31,0 @@ logger.info(`error: unknown command '${command}'`) |
@@ -183,14 +183,2 @@ import type { URL } from 'url'; | ||
export type VaultEncryptOutput = { | ||
dotenvKeys: Record<string, string>; | ||
dotenvKeysFile: string; | ||
addedKeys: string[]; | ||
existingKeys: string[]; | ||
dotenvVaultFile: string; | ||
addedVaults: string[]; | ||
existingVaults: string[]; | ||
addedDotenvFilenames: string[]; | ||
envFile: string | string[]; | ||
}; | ||
/** | ||
@@ -292,20 +280,1 @@ * List all env files in the current working directory | ||
): GenExampleOutput; | ||
/** | ||
* Decrypt ciphertext | ||
* @param encrypted - the encrypted ciphertext string | ||
* @param keyStr - the decryption key string | ||
*/ | ||
export function vaultDecrypt(encrypted: string, keyStr: string): string; | ||
/** | ||
* Encrypt plaintext | ||
* | ||
* @see https://dotenvx.com/docs | ||
* @param directory - current working directory | ||
* @param envFile - path to the .env file(s) | ||
*/ | ||
export function vaultEncrypt( | ||
directory?: string, | ||
envFile?: string | string[] | ||
): VaultEncryptOutput; |
@@ -11,7 +11,5 @@ // @ts-check | ||
const Sets = require('./services/sets') | ||
const Status = require('./services/status') | ||
const Encrypt = require('./services/encrypt') | ||
const Decrypt = require('./services/decrypt') | ||
const Genexample = require('./services/genexample') | ||
const VaultEncrypt = require('./services/vaultEncrypt') | ||
@@ -202,39 +200,2 @@ // helpers | ||
/** @type {import('./main').status} */ | ||
const status = function (directory) { | ||
return new Status(directory).run() | ||
} | ||
// misc/cleanup | ||
/** @type {import('./main').vaultDecrypt} */ | ||
const vaultDecrypt = function (encrypted, keyStr) { | ||
try { | ||
return dotenv.decrypt(encrypted, keyStr) | ||
} catch (e) { | ||
switch (e.code) { | ||
case 'DECRYPTION_FAILED': | ||
// more helpful error when decryption fails | ||
logger.error( | ||
'[DECRYPTION_FAILED] Unable to decrypt .env.vault with DOTENV_KEY.' | ||
) | ||
logger.help( | ||
'[DECRYPTION_FAILED] Run with debug flag [dotenvx run --debug -- yourcommand] or manually run [echo $DOTENV_KEY] to compare it to the one in .env.keys.' | ||
) | ||
logger.debug( | ||
`[DECRYPTION_FAILED] DOTENV_KEY is ${process.env.DOTENV_KEY}` | ||
) | ||
process.exit(1) | ||
break | ||
default: | ||
throw e | ||
} | ||
} | ||
} | ||
/** @type {import('./main').vaultEncrypt} */ | ||
const vaultEncrypt = function (directory, envFile) { | ||
return new VaultEncrypt(directory, envFile).run() | ||
} | ||
module.exports = { | ||
@@ -251,7 +212,3 @@ // dotenv proxies | ||
set, | ||
status, | ||
genexample, | ||
// misc/cleanup | ||
vaultEncrypt, | ||
vaultDecrypt | ||
genexample | ||
} |
10
36
186940
68
3191
- Removedxxhashjs@^0.2.2
- Removedcuint@0.2.2(transitive)
- Removedxxhashjs@0.2.2(transitive)