@dotenvx/dotenvx 1.21.1 → 1.22.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.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,17 @@
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.21.1...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.22.0...main)
6
+
7
+ ## 1.22.0
8
+
9
+ ### Added
10
+
11
+ * add `--pattern` argument to `ext gitignore` (`dotenvx ext gitignore --pattern .env.keys`) ([#430](https://github.com/dotenvx/dotenvx/pull/430))
12
+
13
+ ### Changed
14
+
15
+ * clarify next steps after first time encrypting ([#430](https://github.com/dotenvx/dotenvx/pull/430))
6
16
 
7
17
  ## 1.21.1
8
18
 
package/README.md CHANGED
@@ -1222,8 +1222,8 @@ More examples
1222
1222
  $ dotenvx encrypt
1223
1223
  ✔ encrypted (.env)
1224
1224
  ✔ key added to .env.keys (DOTENV_PRIVATE_KEY)
1225
- add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
1226
- run [DOTENV_PRIVATE_KEY='122...0b8' dotenvx run -- yourcommand] to test decryption locally
1225
+ ⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys
1226
+ ⮕ next run [DOTENV_PRIVATE_KEY='122...0b8' dotenvx run -- yourcommand] to test decryption locally
1227
1227
  ```
1228
1228
 
1229
1229
  </details>
@@ -1238,8 +1238,8 @@ More examples
1238
1238
  $ dotenvx encrypt -f .env.production
1239
1239
  ✔ encrypted (.env.production)
1240
1240
  ✔ key added to .env.keys (DOTENV_PRIVATE_KEY_PRODUCTION)
1241
- add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
1242
- run [DOTENV_PRIVATE_KEY_PRODUCTION='bff..bc4' dotenvx run -- yourcommand] to test decryption locally
1241
+ ⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys
1242
+ ⮕ next run [DOTENV_PRIVATE_KEY='bff...bc4' dotenvx run -- yourcommand] to test decryption locally
1243
1243
  ```
1244
1244
 
1245
1245
  </details>
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.21.1",
2
+ "version": "1.22.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -64,10 +64,10 @@ function encrypt () {
64
64
  logger.success(`✔ key added to .env.keys (${processedEnv.privateKeyName})`)
65
65
 
66
66
  if (!isIgnoringDotenvKeys()) {
67
- logger.help2(' add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]')
67
+ logger.help('⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys')
68
68
  }
69
69
 
70
- logger.help2(`ℹ run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx run -- yourcommand] to test decryption locally`)
70
+ logger.help(`⮕ next run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx run -- yourcommand] to test decryption locally`)
71
71
  }
72
72
  }
73
73
  } catch (error) {
@@ -1,12 +1,12 @@
1
1
  const fsx = require('./../../../lib/helpers/fsx')
2
2
 
3
- const FORMATS = ['.env*', '!.env.vault']
3
+ const DEFAULT_PATTERNS = ['.env*']
4
4
  const { logger } = require('./../../../shared/logger')
5
5
 
6
6
  class Generic {
7
- constructor (filename, touchFile = false) {
7
+ constructor (filename, patterns = DEFAULT_PATTERNS, touchFile = false) {
8
8
  this.filename = filename
9
- this.formats = FORMATS
9
+ this.patterns = patterns
10
10
  this.touchFile = touchFile
11
11
  }
12
12
 
@@ -15,10 +15,9 @@ class Generic {
15
15
  }
16
16
 
17
17
  run () {
18
+ const changedPatterns = []
18
19
  if (!fsx.existsSync(this.filename)) {
19
- if (this.touchFile === true) {
20
- logger.info(`creating ${this.filename}`)
21
-
20
+ if (this.touchFile === true && this.patterns.length > 0) {
22
21
  fsx.writeFileX(this.filename, '')
23
22
  } else {
24
23
  return
@@ -26,41 +25,63 @@ class Generic {
26
25
  }
27
26
 
28
27
  const lines = fsx.readFileX(this.filename).split(/\r?\n/)
29
- this.formats.forEach(format => {
30
- if (!lines.includes(format.trim())) {
31
- logger.info(`appending ${format} to ${this.filename}`)
28
+ this.patterns.forEach(pattern => {
29
+ if (!lines.includes(pattern.trim())) {
30
+ this.append(pattern)
32
31
 
33
- this.append(format)
32
+ changedPatterns.push(pattern.trim())
34
33
  }
35
34
  })
35
+
36
+ if (changedPatterns.length > 0) {
37
+ logger.success(`✔ ignored ${this.patterns} (${this.filename})`)
38
+ } else {
39
+ logger.info(`no changes (${this.filename})`)
40
+ }
36
41
  }
37
42
  }
38
43
 
39
44
  class Git {
45
+ constructor (patterns = DEFAULT_PATTERNS) {
46
+ this.patterns = patterns
47
+ }
48
+
40
49
  run () {
41
- logger.verbose('appending to .gitignore')
42
- new Generic('.gitignore', true).run()
50
+ logger.verbose('add to .gitignore')
51
+ new Generic('.gitignore', this.patterns, true).run()
43
52
  }
44
53
  }
45
54
 
46
55
  class Docker {
56
+ constructor (patterns = DEFAULT_PATTERNS) {
57
+ this.patterns = patterns
58
+ }
59
+
47
60
  run () {
48
- logger.verbose('appending to .dockerignore (if existing)')
49
- new Generic('.dockerignore').run()
61
+ logger.verbose('add to .dockerignore (if exists)')
62
+ new Generic('.dockerignore', this.patterns).run()
50
63
  }
51
64
  }
52
65
 
53
66
  class Npm {
67
+ constructor (patterns = DEFAULT_PATTERNS) {
68
+ this.patterns = patterns
69
+ }
70
+
54
71
  run () {
55
- logger.verbose('appending to .npmignore (if existing)')
56
- new Generic('.npmignore').run()
72
+ logger.verbose('add to .npmignore (if existing)')
73
+ new Generic('.npmignore', this.patterns).run()
57
74
  }
58
75
  }
59
76
 
60
77
  class Vercel {
78
+ constructor (patterns = DEFAULT_PATTERNS) {
79
+ this.patterns = patterns
80
+ }
81
+
61
82
  run () {
62
- logger.verbose('appending to .vercelignore (if existing)')
63
- new Generic('.vercelignore').run()
83
+ logger.verbose('add to .vercelignore (if existing)')
84
+ new Generic('.vercelignore', this.patterns).run()
64
85
  }
65
86
  }
66
87
 
@@ -68,12 +89,12 @@ function gitignore () {
68
89
  const options = this.opts()
69
90
  logger.debug(`options: ${JSON.stringify(options)}`)
70
91
 
71
- new Git().run()
72
- new Docker().run()
73
- new Npm().run()
74
- new Vercel().run()
92
+ const patterns = options.pattern
75
93
 
76
- logger.success('done')
94
+ new Git(patterns).run()
95
+ new Docker(patterns).run()
96
+ new Npm(patterns).run()
97
+ new Vercel(patterns).run()
77
98
  }
78
99
 
79
100
  module.exports = gitignore
@@ -68,10 +68,10 @@ function set (key, value) {
68
68
  logger.success(`✔ key added to .env.keys (${processedEnv.privateKeyName})`)
69
69
 
70
70
  if (!isIgnoringDotenvKeys()) {
71
- logger.help2(' add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]')
71
+ logger.help('⮕ next run [dotenvx ext gitignore --pattern .env.keys] to gitignore .env.keys')
72
72
  }
73
73
 
74
- logger.help2(`ℹ run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx get ${key}] to test decryption locally`)
74
+ logger.help(`⮕ next run [${processedEnv.privateKeyName}='${processedEnv.privateKey}' dotenvx get ${key}] to test decryption locally`)
75
75
  }
76
76
  }
77
77
  } catch (error) {
@@ -40,6 +40,7 @@ ext.command('genexample')
40
40
  ext.command('gitignore')
41
41
  .description('append to .gitignore file (and if existing, .dockerignore, .npmignore, and .vercelignore)')
42
42
  .addHelpText('after', examples.gitignore)
43
+ .option('--pattern <patterns...>', 'pattern(s) to gitignore', ['.env*'])
43
44
  .action(require('./../actions/ext/gitignore'))
44
45
 
45
46
  // dotenvx ext prebuild
@@ -63,13 +63,14 @@ Examples:
63
63
 
64
64
  \`\`\`
65
65
  $ dotenvx ext gitignore
66
+ $ dotenvx ext gitignore --pattern .env.keys
66
67
  \`\`\`
67
68
 
68
69
  Try it:
69
70
 
70
71
  \`\`\`
71
72
  $ dotenvx ext gitignore
72
- done
73
+ ✔ ignored .env* (.gitignore)
73
74
  \`\`\`
74
75
  `
75
76
  }