@dotenvx/dotenvx 0.11.0 → 0.12.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.11.0",
2
+ "version": "0.12.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs')
2
2
 
3
3
  const FORMATS = ['.env*', '!.env.vault']
4
+ const logger = require('./../../shared/logger')
4
5
 
5
6
  class Generic {
6
7
  constructor (filename, touchFile = false) {
@@ -16,6 +17,8 @@ class Generic {
16
17
  run () {
17
18
  if (!fs.existsSync(this.filename)) {
18
19
  if (this.touchFile === true) {
20
+ logger.info(`creating ${this.filename}`)
21
+
19
22
  fs.writeFileSync(this.filename, '')
20
23
  } else {
21
24
  return
@@ -25,6 +28,8 @@ class Generic {
25
28
  const lines = fs.readFileSync(this.filename, 'utf8').split(/\r?\n/)
26
29
  this.formats.forEach(format => {
27
30
  if (!lines.includes(format.trim())) {
31
+ logger.info(`appending ${format} to ${this.filename}`)
32
+
28
33
  this.append(format)
29
34
  }
30
35
  })
@@ -55,13 +60,23 @@ class Vercel {
55
60
  }
56
61
  }
57
62
 
58
- class AppendToIgnores {
59
- run () {
60
- new Docker().run()
61
- new Git().run()
62
- new Npm().run()
63
- new Vercel().run()
64
- }
63
+ function gitignore () {
64
+ const options = this.opts()
65
+ logger.debug(`options: ${JSON.stringify(options)}`)
66
+
67
+ logger.verbose('appending to .gitignore')
68
+ new Git().run()
69
+
70
+ logger.verbose('appending to .dockerignore (if existing)')
71
+ new Docker().run()
72
+
73
+ logger.verbose('appending to .npmignore (if existing)')
74
+ new Npm().run()
75
+
76
+ logger.verbose('appending to .vercelignore (if existing)')
77
+ new Vercel().run()
78
+
79
+ logger.success('done')
65
80
  }
66
81
 
67
- module.exports = { AppendToIgnores, Generic }
82
+ module.exports = gitignore
@@ -79,6 +79,12 @@ program.command('prebuild')
79
79
  .addHelpText('after', examples.prebuild)
80
80
  .action(require('./actions/prebuild'))
81
81
 
82
+ // dotenvx gitignore
83
+ program.command('gitignore')
84
+ .description('append to .gitignore file (and if existing, .dockerignore, .npmignore, and .vercelignore)')
85
+ .addHelpText('after', examples.gitignore)
86
+ .action(require('./actions/gitignore'))
87
+
82
88
  // dotenvx hub
83
89
  program.addCommand(require('./commands/hub'))
84
90
 
@@ -83,9 +83,27 @@ Try it:
83
83
  `
84
84
  }
85
85
 
86
+ const gitignore = function () {
87
+ return `
88
+ Examples:
89
+
90
+ \`\`\`
91
+ $ dotenvx gitignore
92
+ \`\`\`
93
+
94
+ Try it:
95
+
96
+ \`\`\`
97
+ $ dotenvx gitignore
98
+ done
99
+ \`\`\`
100
+ `
101
+ }
102
+
86
103
  module.exports = {
87
104
  run,
88
105
  encrypt,
89
106
  precommit,
90
- prebuild
107
+ prebuild,
108
+ gitignore
91
109
  }