@dotenvx/dotenvx 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +100 -2
  3. package/package.json +9 -10
  4. package/src/cli/actions/decrypt.js +71 -0
  5. package/src/cli/actions/encrypt.js +54 -42
  6. package/src/cli/actions/ext/genexample.js +4 -12
  7. package/src/cli/actions/ext/gitignore.js +5 -0
  8. package/src/cli/actions/ext/prebuild.js +1 -0
  9. package/src/cli/actions/ext/scan.js +9 -6
  10. package/src/cli/actions/ext/settings.js +5 -4
  11. package/src/cli/actions/ext/vault/decrypt.js +6 -13
  12. package/src/cli/actions/ext/vault/encrypt.js +5 -12
  13. package/src/cli/actions/ext/vault/migrate.js +22 -39
  14. package/src/cli/actions/get.js +6 -5
  15. package/src/cli/actions/run.js +3 -110
  16. package/src/cli/actions/set.js +2 -2
  17. package/src/cli/commands/ext.js +12 -1
  18. package/src/cli/dotenvx.js +16 -15
  19. package/src/cli/examples.js +17 -1
  20. package/src/lib/helpers/execute.js +9 -0
  21. package/src/lib/helpers/executeCommand.js +117 -0
  22. package/src/lib/helpers/executeExtension.js +38 -0
  23. package/src/lib/helpers/findOrCreatePublicKey.js +14 -8
  24. package/src/lib/helpers/isEncrypted.js +1 -2
  25. package/src/lib/helpers/isFullyEncrypted.js +2 -1
  26. package/src/lib/helpers/isIgnoringDotenvKeys.js +1 -1
  27. package/src/lib/helpers/isPublicKey.js +7 -0
  28. package/src/lib/helpers/keyPair.js +8 -2
  29. package/src/lib/helpers/smartDotenvPrivateKey.js +64 -6
  30. package/src/lib/main.js +16 -9
  31. package/src/lib/services/decrypt.js +79 -98
  32. package/src/lib/services/encrypt.js +12 -7
  33. package/src/lib/services/sets.js +9 -2
  34. package/src/lib/services/status.js +2 -2
  35. package/src/lib/services/vaultDecrypt.js +126 -0
  36. package/src/shared/logger.js +0 -3
  37. package/src/cli/actions/ext/hub/login.js +0 -126
  38. package/src/cli/actions/ext/hub/logout.js +0 -43
  39. package/src/cli/actions/ext/hub/open.js +0 -63
  40. package/src/cli/actions/ext/hub/pull.js +0 -105
  41. package/src/cli/actions/ext/hub/push.js +0 -112
  42. package/src/cli/actions/ext/hub/status.js +0 -8
  43. package/src/cli/actions/ext/hub/token.js +0 -9
  44. package/src/cli/commands/ext/hub.js +0 -89
  45. package/src/cli/commands/vault.js +0 -57
  46. package/src/lib/helpers/clipboardy/fallbacks/linux/xsel +0 -0
  47. package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_i686.exe +0 -0
  48. package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_x86_64.exe +0 -0
  49. package/src/lib/helpers/clipboardy/linux.js +0 -57
  50. package/src/lib/helpers/clipboardy/macos.js +0 -14
  51. package/src/lib/helpers/clipboardy/termux.js +0 -41
  52. package/src/lib/helpers/clipboardy/windows.js +0 -16
  53. package/src/lib/helpers/clipboardy.js +0 -51
  54. package/src/lib/helpers/extractUsernameName.js +0 -10
  55. package/src/lib/helpers/forgivingDirectory.js +0 -11
  56. package/src/lib/helpers/gitRoot.js +0 -14
  57. package/src/lib/helpers/gitUrl.js +0 -13
  58. package/src/lib/helpers/isGitRepo.js +0 -13
  59. package/src/lib/helpers/isGithub.js +0 -5
  60. package/src/lib/helpers/resolvePath.js +0 -8
  61. package/src/shared/createSpinner.js +0 -17
package/CHANGELOG.md CHANGED
@@ -2,7 +2,38 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.4.0...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.6.0...main)
6
+
7
+ ## 1.6.0
8
+
9
+ ### Added
10
+
11
+ * add `dotenvx decrypt` command. works inversely to `dotenvx encrypt`. same flags. ([#294](https://github.com/dotenvx/dotenvx/pull/294))
12
+ * add `--stdout` option to `dotenvx decrypt`. example: `dotenvx decrypt -f .env.production > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
13
+ * add `--stdout` option to `dotenvx encrypt`. example: `dotenvx encrypt -f .env.production > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
14
+
15
+ ### Changed
16
+
17
+ * smarter private key finder. if you rename your file to `secrets.txt` it can still decrypt from `DOTENV_PRIVATE_KEY` by seeking out the invert of the `DOTENV_PUBLIC_KEY` inside `secrets.txt` ([#302](https://github.com/dotenvx/dotenvx/pull/302))
18
+
19
+ ### Removed
20
+
21
+ * remove `dotenvx convert` - still at `dotenvx encrypt`
22
+ * remove `dotenvx vault` - still at `dotenvx ext vault`
23
+
24
+ ## 1.5.0
25
+
26
+ ### Added
27
+
28
+ * add help text for dashed values on `set`. example: `dotenvx set KEY -- "- + * ÷"` ([#293](https://github.com/dotenvx/dotenvx/pull/293))
29
+
30
+ ### Changed
31
+
32
+ * replace `@inquirer/confirm` and `ora` ([#285](https://github.com/dotenvx/dotenvx/pull/285))
33
+
34
+ ### Removed
35
+
36
+ * remove `dotenvx ext hub`, replace with [dotenvx-ext-hub](https://github.com/dotenvx/dotenvx-ext-hub) (install there to continue using hub) ([#291](https://github.com/dotenvx/dotenvx/pull/291))
6
37
 
7
38
  ## 1.4.0
8
39
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
   
10
10
 
11
11
 
12
- ### Quickstart [![npm version](https://img.shields.io/npm/v/@dotenvx/dotenvx.svg)](https://www.npmjs.com/package/@dotenvx/dotenvx) [![test count](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/motdotenv/bb76445765a9731e7d824a6efdf53524/raw/dotenvxTestCount.json)](https://github.com/dotenvx/dotenvx/tree/main/tests) [![npm installs](https://img.shields.io/npm/dm/@dotenvx/dotenvx)](https://www.npmjs.com/package/@dotenvx/dotenvx)
12
+ ### Quickstart [![npm version](https://img.shields.io/npm/v/@dotenvx/dotenvx.svg)](https://www.npmjs.com/package/@dotenvx/dotenvx) [![test count](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/motdotenv/bb76445765a9731e7d824a6efdf53524/raw/dotenvxTestCount.json)](https://github.com/dotenvx/dotenvx/tree/main/tests) [![npm installs](https://img.shields.io/npm/dt/@dotenvx/dotenvx)](https://www.npmjs.com/package/@dotenvx/dotenvx)
13
13
 
14
14
  Install and use it in code just like `dotenv`.
15
15
 
@@ -660,6 +660,16 @@ More examples
660
660
  Note the `DOTENV_PRIVATE_KEY_CI` (and any `DOTENV_PRIVATE_KEY*`) can take multiple private keys by simply comma separating them.
661
661
 
662
662
  </details>
663
+ * <details><summary>`--stdout`</summary><br>
664
+
665
+ ```sh
666
+ $ echo "HELLO=World" > .env
667
+ $ dotenvx encrypt --stdout
668
+ $ dotenvx encrypt --stdout > .env.encrypted
669
+ ```
670
+
671
+ </details>
672
+
663
673
  * <details><summary>other curves</summary><br>
664
674
 
665
675
  > `secp256k1` is a well-known and battle tested curve, in use with Bitcoin and other cryptocurrencies, but we are open to adding support for more curves.
@@ -1071,6 +1081,18 @@ More examples
1071
1081
  set HELLO with encryption (.env.ci)
1072
1082
  ```
1073
1083
 
1084
+ </details>
1085
+ * <details><summary>`set KEY -- "- + * ÷"`</summary><br>
1086
+
1087
+ If your value starts with a dash (`-`), then place two dashes instructing the cli that there are no more flag arguments.
1088
+
1089
+ ```sh
1090
+ $ touch .env.ci
1091
+
1092
+ $ dotenvx set HELLO -f .env.ci -- "- + * ÷"
1093
+ set HELLO with encryption (.env.ci)
1094
+ ```
1095
+
1074
1096
  </details>
1075
1097
  * <details><summary>`set KEY value --plain`</summary><br>
1076
1098
 
@@ -1127,6 +1149,81 @@ More examples
1127
1149
  ```
1128
1150
 
1129
1151
  </details>
1152
+ * <details><summary>`encrypt --stdout`</summary><br>
1153
+
1154
+ Encrypt the contents of a `.env` file and send to stdout.
1155
+
1156
+ ```sh
1157
+ $ echo "HELLO=World" > .env
1158
+ $ dotenvx encrypt --stdout
1159
+ #/-------------------[DOTENV_PUBLIC_KEY]--------------------/
1160
+ #/ public-key encryption for .env files /
1161
+ #/ [how it works](https://dotenvx.com/encryption) /
1162
+ #/----------------------------------------------------------/
1163
+ DOTENV_PUBLIC_KEY="034af93e93708b994c10f236c96ef88e47291066946cce2e8d98c9e02c741ced45"
1164
+ # .env
1165
+ HELLO="encrypted:BDqDBibm4wsYqMpCjTQ6BsDHmMadg9K3dAt+Z9HPMfLEIRVz50hmLXPXRuDBXaJi/LwWYEVUNiq0HISrslzQPaoyS8Lotg3gFWJTsNCdOWnqpjF2xNUX2RQiP05kAbEXM6MWVjDr"
1166
+ ```
1167
+
1168
+ or send to a file:
1169
+
1170
+ ```sh
1171
+ $ echo "HELLO=World" > .env
1172
+ $ dotenvx encrypt --stdout > somefile.txt
1173
+ ```
1174
+
1175
+ </details>
1176
+ * <details><summary>`decrypt`</summary><br>
1177
+
1178
+ Decrypt the contents of an encrypted `.env` file to an unencrypted `.env` file.
1179
+
1180
+ ```sh
1181
+ $ echo "HELLO=World" > .env
1182
+ $ dotenvx encrypt
1183
+ ✔ encrypted (.env)
1184
+ $ dotenvx decrypt
1185
+ ✔ decrypted (.env)
1186
+ ```
1187
+
1188
+ </details>
1189
+ * <details><summary>`decrypt -f`</summary><br>
1190
+
1191
+ Decrypt the contents of a specified encrypted `.env` file to an unencrypted `.env` file.
1192
+
1193
+ ```sh
1194
+ $ echo "HELLO=World" > .env
1195
+ $ echo "HELLO=Production" > .env.production
1196
+
1197
+ $ dotenvx encrypt -f .env.production
1198
+ ✔ encrypted (.env.production)
1199
+ $ dotenvx decrypt -f .env.production
1200
+ ✔ decrypted (.env.production)
1201
+ ```
1202
+
1203
+ </details>
1204
+ * <details><summary>`decrypt --stdout`</summary><br>
1205
+
1206
+ Decrypt the contents of an encrypted `.env` file and send to stdout.
1207
+
1208
+ ```sh
1209
+ $ dotenvx decrypt --stdout
1210
+ #/-------------------[DOTENV_PUBLIC_KEY]--------------------/
1211
+ #/ public-key encryption for .env files /
1212
+ #/ [how it works](https://dotenvx.com/encryption) /
1213
+ #/----------------------------------------------------------/
1214
+ DOTENV_PUBLIC_KEY="034af93e93708b994c10f236c96ef88e47291066946cce2e8d98c9e02c741ced45"
1215
+ # .env
1216
+ HELLO="World"
1217
+ ```
1218
+
1219
+ or send to a file:
1220
+
1221
+ ```sh
1222
+ $ dotenvx decrypt --stdout > somefile.txt
1223
+ ```
1224
+
1225
+ </details>
1226
+
1130
1227
  * <details><summary>`help`</summary><br>
1131
1228
 
1132
1229
  Output help for `dotenvx`.
@@ -1150,8 +1247,9 @@ More examples
1150
1247
  get [options] [key] return a single environment variable
1151
1248
  set [options] <KEY> <value> set a single environment variable
1152
1249
  encrypt [options] convert .env file(s) to encrypted .env file(s)
1250
+ decrypt [options] convert encrypted .env file(s) to plain .env file(s)
1153
1251
  pro 🏆 pro
1154
- ext 🔌 extensions
1252
+ ext [command] [args...] 🔌 extensions
1155
1253
  help [command] display help for command
1156
1254
  ```
1157
1255
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.0",
2
+ "version": "1.6.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -8,7 +8,10 @@
8
8
  "env"
9
9
  ],
10
10
  "homepage": "https://github.com/dotenvx/dotenvx",
11
- "repository": "dotenvx/dotenvx",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/dotenvx/dotenvx.git"
14
+ },
12
15
  "license": "BSD-3-Clause",
13
16
  "files": [
14
17
  "src/**/*",
@@ -23,7 +26,9 @@
23
26
  "scripts": {
24
27
  "standard": "standard",
25
28
  "standard:fix": "standard --fix",
26
- "test": "tap run --show-full-coverage",
29
+ "test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
30
+ "test-coverage": "tap run --show-full-coverage --timeout=60000",
31
+ "test-single": "tap run --coverage-report=none tests/cli/actions/decrypt.test.js",
27
32
  "testshell": "bash shellspec",
28
33
  "prerelease": "npm test && npm run testshell",
29
34
  "release": "standard-version",
@@ -31,8 +36,6 @@
31
36
  },
32
37
  "funding": "https://dotenvx.com",
33
38
  "dependencies": {
34
- "@inquirer/confirm": "^2.0.17",
35
- "arch": "^2.1.1",
36
39
  "chalk": "^4.1.2",
37
40
  "commander": "^11.1.0",
38
41
  "conf": "^10.2.0",
@@ -42,12 +45,8 @@
42
45
  "execa": "^5.1.1",
43
46
  "fdir": "^6.1.1",
44
47
  "ignore": "^5.3.0",
45
- "is-wsl": "^2.1.1",
46
48
  "object-treeify": "1.1.33",
47
- "open": "^8.4.2",
48
- "ora": "^5.4.1",
49
49
  "picomatch": "^3.0.1",
50
- "undici": "^5.28.3",
51
50
  "which": "^4.0.0",
52
51
  "winston": "^3.11.0",
53
52
  "xxhashjs": "^0.2.2"
@@ -60,7 +59,7 @@
60
59
  "sinon": "^14.0.1",
61
60
  "standard": "^17.1.0",
62
61
  "standard-version": "^9.5.0",
63
- "tap": "^18.7.0"
62
+ "tap": "^19.2.0"
64
63
  },
65
64
  "publishConfig": {
66
65
  "access": "public",
@@ -0,0 +1,71 @@
1
+ const fs = require('fs')
2
+ const { logger } = require('./../../shared/logger')
3
+
4
+ const main = require('./../../lib/main')
5
+
6
+ const ENCODING = 'utf8'
7
+
8
+ function decrypt () {
9
+ const options = this.opts()
10
+ logger.debug(`options: ${JSON.stringify(options)}`)
11
+
12
+ // stdout - should not have a try so that exit codes can surface to stdout
13
+ if (options.stdout) {
14
+ const {
15
+ processedEnvFiles
16
+ } = main.decrypt(options.envFile, options.key)
17
+
18
+ for (const processedEnvFile of processedEnvFiles) {
19
+ process.stdout.write(processedEnvFile.envSrc)
20
+ }
21
+ process.exit(0) // exit early
22
+ } else {
23
+ try {
24
+ const {
25
+ processedEnvFiles,
26
+ changedFilepaths,
27
+ unchangedFilepaths
28
+ } = main.decrypt(options.envFile, options.key)
29
+
30
+ for (const processedEnvFile of processedEnvFiles) {
31
+ logger.verbose(`decrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
32
+ if (processedEnvFile.error) {
33
+ if (processedEnvFile.error.code === 'MISSING_ENV_FILE') {
34
+ logger.warn(processedEnvFile.error.message)
35
+ logger.help(`? add one with [echo "HELLO=World" > ${processedEnvFile.envFilepath}] and re-run [dotenvx decrypt]`)
36
+ } else {
37
+ logger.warn(processedEnvFile.error.message)
38
+ }
39
+ } else if (processedEnvFile.changed) {
40
+ fs.writeFileSync(processedEnvFile.filepath, processedEnvFile.envSrc, ENCODING)
41
+
42
+ logger.verbose(`decrypted ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
43
+ } else {
44
+ logger.verbose(`no changes ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
45
+ }
46
+ }
47
+
48
+ if (changedFilepaths.length > 0) {
49
+ logger.success(`✔ decrypted (${changedFilepaths.join(',')})`)
50
+ } else if (unchangedFilepaths.length > 0) {
51
+ logger.info(`no changes (${unchangedFilepaths})`)
52
+ } else {
53
+ // do nothing - scenario when no .env files found
54
+ }
55
+ } catch (error) {
56
+ logger.error(error.message)
57
+ if (error.help) {
58
+ logger.help(error.help)
59
+ }
60
+ if (error.debug) {
61
+ logger.debug(error.debug)
62
+ }
63
+ if (error.code) {
64
+ logger.debug(`ERROR_CODE: ${error.code}`)
65
+ }
66
+ process.exit(1)
67
+ }
68
+ }
69
+ }
70
+
71
+ module.exports = decrypt
@@ -7,66 +7,78 @@ const isIgnoringDotenvKeys = require('../../lib/helpers/isIgnoringDotenvKeys')
7
7
 
8
8
  const ENCODING = 'utf8'
9
9
 
10
- async function encrypt () {
10
+ function encrypt () {
11
11
  const options = this.opts()
12
12
  logger.debug(`options: ${JSON.stringify(options)}`)
13
13
 
14
- try {
14
+ // stdout - should not have a try so that exit codes can surface to stdout
15
+ if (options.stdout) {
15
16
  const {
16
- processedEnvFiles,
17
- changedFilepaths,
18
- unchangedFilepaths
17
+ processedEnvFiles
19
18
  } = main.encrypt(options.envFile, options.key)
20
19
 
21
20
  for (const processedEnvFile of processedEnvFiles) {
22
- logger.verbose(`encrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
23
- if (processedEnvFile.error) {
24
- if (processedEnvFile.error.code === 'MISSING_ENV_FILE') {
25
- logger.warn(processedEnvFile.error)
26
- logger.help(`? add one with [echo "HELLO=World" > ${processedEnvFile.envFilepath}] and re-run [dotenvx encrypt]`)
21
+ process.stdout.write(processedEnvFile.envSrc)
22
+ }
23
+ process.exit(0) // exit early
24
+ } else {
25
+ try {
26
+ const {
27
+ processedEnvFiles,
28
+ changedFilepaths,
29
+ unchangedFilepaths
30
+ } = main.encrypt(options.envFile, options.key)
31
+
32
+ for (const processedEnvFile of processedEnvFiles) {
33
+ logger.verbose(`encrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
34
+ if (processedEnvFile.error) {
35
+ if (processedEnvFile.error.code === 'MISSING_ENV_FILE') {
36
+ logger.warn(processedEnvFile.error.message)
37
+ logger.help(`? add one with [echo "HELLO=World" > ${processedEnvFile.envFilepath}] and re-run [dotenvx encrypt]`)
38
+ } else {
39
+ logger.warn(processedEnvFile.error.message)
40
+ }
41
+ } else if (processedEnvFile.changed) {
42
+ fs.writeFileSync(processedEnvFile.filepath, processedEnvFile.envSrc, ENCODING)
43
+
44
+ logger.verbose(`encrypted ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
27
45
  } else {
28
- logger.warn(processedEnvFile.error)
46
+ logger.verbose(`no changes ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
29
47
  }
30
- } else if (processedEnvFile.changed) {
31
- fs.writeFileSync(processedEnvFile.filepath, processedEnvFile.envSrc, ENCODING)
48
+ }
32
49
 
33
- logger.verbose(`encrypted ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
50
+ if (changedFilepaths.length > 0) {
51
+ logger.success(`✔ encrypted (${changedFilepaths.join(',')})`)
52
+ } else if (unchangedFilepaths.length > 0) {
53
+ logger.info(`no changes (${unchangedFilepaths})`)
34
54
  } else {
35
- logger.verbose(`no changes ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
55
+ // do nothing - scenario when no .env files found
36
56
  }
37
- }
38
57
 
39
- if (changedFilepaths.length > 0) {
40
- logger.success(`✔ encrypted (${changedFilepaths.join(',')})`)
41
- } else if (unchangedFilepaths.length > 0) {
42
- logger.info(`no changes (${unchangedFilepaths})`)
43
- } else {
44
- // do nothing - scenario when no .env files found
45
- }
58
+ for (const processedEnvFile of processedEnvFiles) {
59
+ if (processedEnvFile.privateKeyAdded) {
60
+ logger.success(`✔ key added to .env.keys (${processedEnvFile.privateKeyName})`)
46
61
 
47
- for (const processedEnvFile of processedEnvFiles) {
48
- if (processedEnvFile.privateKeyAdded) {
49
- logger.success(`✔ key added to .env.keys (${processedEnvFile.privateKeyName})`)
62
+ if (!isIgnoringDotenvKeys()) {
63
+ logger.help2('ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]')
64
+ }
50
65
 
51
- if (!isIgnoringDotenvKeys()) {
52
- logger.help2('ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]')
66
+ logger.help2(`ℹ run [${processedEnvFile.privateKeyName}='${processedEnvFile.privateKey}' dotenvx run -- yourcommand] to test decryption locally`)
53
67
  }
54
-
55
- logger.help2(`ℹ run [${processedEnvFile.privateKeyName}='${processedEnvFile.privateKey}' dotenvx run -- yourcommand] to test decryption locally`)
56
68
  }
69
+ } catch (error) {
70
+ logger.error(error.message)
71
+ if (error.help) {
72
+ logger.help(error.help)
73
+ }
74
+ if (error.debug) {
75
+ logger.debug(error.debug)
76
+ }
77
+ if (error.code) {
78
+ logger.debug(`ERROR_CODE: ${error.code}`)
79
+ }
80
+ process.exit(1)
57
81
  }
58
- } catch (error) {
59
- logger.error(error.message)
60
- if (error.help) {
61
- logger.help(error.help)
62
- }
63
- if (error.debug) {
64
- logger.debug(error.debug)
65
- }
66
- if (error.code) {
67
- logger.debug(`ERROR_CODE: ${error.code}`)
68
- }
69
- process.exit(1)
70
82
  }
71
83
  }
72
84
 
@@ -1,18 +1,10 @@
1
1
  const fs = require('fs')
2
2
  const main = require('./../../../lib/main')
3
3
  const { logger } = require('./../../../shared/logger')
4
- const createSpinner = require('./../../../shared/createSpinner')
5
-
6
- const sleep = require('./../../../lib/helpers/sleep')
7
-
8
- const spinner = createSpinner('generating')
9
4
 
10
5
  const ENCODING = 'utf8'
11
6
 
12
- async function genexample (directory) {
13
- spinner.start()
14
- await sleep(500) // better dx
15
-
7
+ function genexample (directory) {
16
8
  logger.debug(`directory: ${directory}`)
17
9
 
18
10
  const options = this.opts()
@@ -34,12 +26,12 @@ async function genexample (directory) {
34
26
  fs.writeFileSync(exampleFilepath, envExampleFile, ENCODING)
35
27
 
36
28
  if (addedKeys.length > 0) {
37
- spinner.succeed(`updated .env.example (${addedKeys.length})`)
29
+ logger.success(`updated .env.example (${addedKeys.length})`)
38
30
  } else {
39
- spinner.done('no changes (.env.example)')
31
+ logger.blank('no changes (.env.example)')
40
32
  }
41
33
  } catch (error) {
42
- spinner.fail(error.message)
34
+ logger.error(error.message)
43
35
  if (error.help) {
44
36
  logger.help(error.help)
45
37
  }
@@ -77,3 +77,8 @@ function gitignore () {
77
77
  }
78
78
 
79
79
  module.exports = gitignore
80
+ module.exports.Git = Git
81
+ module.exports.Docker = Docker
82
+ module.exports.Npm = Npm
83
+ module.exports.Vercel = Vercel
84
+ module.exports.Generic = Generic
@@ -14,6 +14,7 @@ function prebuild () {
14
14
  logger.errorvpb('.dockerignore missing')
15
15
  logger.help2('? add it with [touch .dockerignore]')
16
16
  process.exit(1)
17
+ return
17
18
  }
18
19
 
19
20
  // 2. check .env* files against .dockerignore file
@@ -1,25 +1,28 @@
1
- const execa = require('execa')
1
+ const childProcess = require('child_process')
2
2
 
3
3
  const { logger } = require('./../../../shared/logger')
4
4
 
5
- async function scan () {
5
+ function scan () {
6
6
  const options = this.opts()
7
7
  logger.debug(`options: ${JSON.stringify(options)}`)
8
8
 
9
9
  try {
10
- await execa('gitleaks', ['version'])
10
+ // redirect stderr to stdout to capture and ignore it
11
+ childProcess.execSync('gitleaks version', { stdio: ['ignore', 'pipe', 'ignore'] })
11
12
  } catch (error) {
12
- logger.error('gitleaks command not found')
13
+ logger.error('gitleaks: command not found')
13
14
  logger.help('? install gitleaks: [brew install gitleaks]')
14
15
  logger.help2('? other install options: [https://github.com/gitleaks/gitleaks]')
15
16
  process.exit(1)
17
+ return
16
18
  }
17
19
 
18
20
  try {
19
- const { stderr } = await execa('gitleaks', ['detect', '-v'])
20
- logger.blank(stderr) // gitleaks sends output as stderr for strange reason
21
+ const output = childProcess.execSync('gitleaks detect -v 2>&1', { stdio: 'pipe' }).toString() // gitleaks sends output as stderr for strange reason
22
+ logger.blank(output)
21
23
  } catch (error) {
22
24
  logger.error(error.message)
25
+
23
26
  process.exit(1)
24
27
  }
25
28
  }
@@ -11,13 +11,14 @@ function settings (key = null) {
11
11
  const value = main.settings(key)
12
12
 
13
13
  if (typeof value === 'object' && value !== null) {
14
+ let space = 0
14
15
  if (options.prettyPrint) {
15
- logger.blank(JSON.stringify(value, null, 2))
16
- } else {
17
- logger.blank(value)
16
+ space = 2
18
17
  }
18
+
19
+ process.stdout.write(JSON.stringify(value, null, space))
19
20
  } else {
20
- logger.blank(value)
21
+ process.stdout.write(value)
21
22
  }
22
23
  }
23
24
 
@@ -1,17 +1,10 @@
1
1
  const fs = require('fs')
2
2
 
3
3
  const { logger } = require('./../../../../shared/logger')
4
- const createSpinner = require('./../../../../shared/createSpinner')
5
- const sleep = require('./../../../../lib/helpers/sleep')
6
4
 
7
- const Decrypt = require('./../../../../lib/services/decrypt')
8
-
9
- const spinner = createSpinner('decrypting')
10
-
11
- async function decrypt (directory) {
12
- spinner.start()
13
- await sleep(500) // better dx
5
+ const VaultDecrypt = require('./../../../../lib/services/vaultDecrypt')
14
6
 
7
+ function decrypt (directory) {
15
8
  logger.debug(`directory: ${directory}`)
16
9
 
17
10
  const options = this.opts()
@@ -22,7 +15,7 @@ async function decrypt (directory) {
22
15
  processedEnvs,
23
16
  changedFilenames,
24
17
  unchangedFilenames
25
- } = new Decrypt(directory, options.environment).run()
18
+ } = new VaultDecrypt(directory, options.environment).run()
26
19
 
27
20
  for (const env of processedEnvs) {
28
21
  if (env.warning) {
@@ -49,12 +42,12 @@ async function decrypt (directory) {
49
42
  }
50
43
 
51
44
  if (changedMsg.length > 0) {
52
- spinner.succeed(`${changedMsg} ${unchangedMsg}`)
45
+ logger.success(`${changedMsg} ${unchangedMsg}`)
53
46
  } else {
54
- spinner.done(`${unchangedMsg}`)
47
+ logger.blank(`${unchangedMsg}`)
55
48
  }
56
49
  } catch (error) {
57
- spinner.fail(error.message)
50
+ logger.error(error.message)
58
51
  if (error.help) {
59
52
  logger.help(error.help)
60
53
  }
@@ -3,16 +3,9 @@ const path = require('path')
3
3
 
4
4
  const main = require('./../../../../lib/main')
5
5
  const { logger } = require('./../../../../shared/logger')
6
- const createSpinner = require('./../../../../shared/createSpinner')
7
- const sleep = require('./../../../../lib/helpers/sleep')
8
6
  const pluralize = require('./../../../../lib/helpers/pluralize')
9
7
 
10
- const spinner = createSpinner('encrypting')
11
-
12
- async function encrypt (directory) {
13
- spinner.start()
14
- await sleep(500) // better dx
15
-
8
+ function encrypt (directory) {
16
9
  logger.debug(`directory: ${directory}`)
17
10
 
18
11
  const options = this.opts()
@@ -50,14 +43,14 @@ async function encrypt (directory) {
50
43
  fs.writeFileSync(path.resolve(directory, '.env.vault'), dotenvVaultFile)
51
44
 
52
45
  if (addedDotenvFilenames.length > 0) {
53
- spinner.succeed(`encrypted to .env.vault (${addedDotenvFilenames})`)
46
+ logger.success(`encrypted to .env.vault (${addedDotenvFilenames})`)
54
47
  logger.help2('ℹ commit .env.vault to code: [git commit -am ".env.vault"]')
55
48
  } else {
56
- spinner.done(`no changes (${envFile})`)
49
+ logger.blank(`no changes (${envFile})`)
57
50
  }
58
51
 
59
52
  if (addedKeys.length > 0) {
60
- spinner.succeed(`${pluralize('key', addedKeys.length)} added to .env.keys (${addedKeys})`)
53
+ logger.success(`${pluralize('key', addedKeys.length)} added to .env.keys (${addedKeys})`)
61
54
  }
62
55
 
63
56
  if (addedVaults.length > 0) {
@@ -68,7 +61,7 @@ async function encrypt (directory) {
68
61
  logger.help2(`ℹ run [DOTENV_KEY='${tryKey}' dotenvx run -- yourcommand] to test decryption locally`)
69
62
  }
70
63
  } catch (error) {
71
- spinner.fail(error.message)
64
+ logger.error(error.message)
72
65
  if (error.help) {
73
66
  logger.help(error.help)
74
67
  }