@dotenvx/dotenvx 1.6.2 โ†’ 1.6.4

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,19 @@
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.6.2...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.6.4...main)
6
+
7
+ ## 1.6.4
8
+
9
+ ### Changed
10
+
11
+ * fix `dotenvx help` (command was missing)
12
+
13
+ ## 1.6.3
14
+
15
+ ### Changed
16
+
17
+ * adjust `dotenvx pro` to be dynamic if [dotenvx-pro](https://github.com/dotenvx/dotenvx-pro) is installed user's machine
6
18
 
7
19
  ## 1.6.2
8
20
 
@@ -21,8 +33,8 @@ All notable changes to this project will be documented in this file. See [standa
21
33
  ### Added
22
34
 
23
35
  * add `dotenvx decrypt` command. works inversely to `dotenvx encrypt`. same flags. ([#294](https://github.com/dotenvx/dotenvx/pull/294))
24
- * add `--stdout` option to `dotenvx decrypt`. example: `dotenvx decrypt -f .env.production > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
25
- * add `--stdout` option to `dotenvx encrypt`. example: `dotenvx encrypt -f .env.production > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
36
+ * add `--stdout` option to `dotenvx decrypt`. example: `dotenvx decrypt -f .env.production --stdout > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
37
+ * add `--stdout` option to `dotenvx encrypt`. example: `dotenvx encrypt -f .env.production --stdout > somefile.txt` ([#298](https://github.com/dotenvx/dotenvx/pull/298))
26
38
 
27
39
  ### Changed
28
40
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.2",
2
+ "version": "1.6.4",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenvโ€“from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -1,15 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /* c8 ignore start */
4
- const fs = require('fs')
5
- const path = require('path')
6
- const { execSync } = require('child_process')
7
4
  const { Command } = require('commander')
8
5
  const program = new Command()
9
6
 
10
7
  const { setLogLevel, logger } = require('../shared/logger')
11
8
  const examples = require('./examples')
12
9
  const packageJson = require('./../lib/helpers/packageJson')
10
+ const executeDynamic = require('./../lib/helpers/executeDynamic')
13
11
 
14
12
  // for use with run
15
13
  const envs = []
@@ -32,11 +30,22 @@ program
32
30
  setLogLevel(options)
33
31
  })
34
32
 
33
+ program.addHelpText('after', ' pro ๐Ÿ† pro\n')
34
+
35
+ program
36
+ .argument('[command]', 'dynamic command')
37
+ .argument('[args...]', 'dynamic command arguments')
38
+ .action((command, args, cmdObj) => {
39
+ const rawArgs = process.argv.slice(3) // adjust the index based on where actual args start
40
+ executeDynamic(program, command, rawArgs)
41
+ })
42
+
35
43
  // cli
36
44
  program
37
45
  .name(packageJson.name)
38
46
  .description(packageJson.description)
39
47
  .version(packageJson.version)
48
+ .allowUnknownOption()
40
49
 
41
50
  // dotenvx run -- node index.js
42
51
  const runAction = require('./actions/run')
@@ -103,27 +112,6 @@ program.command('decrypt')
103
112
  .option('--stdout', 'send to stdout')
104
113
  .action(decryptAction)
105
114
 
106
- // dotenvx pro
107
- program.command('pro')
108
- .description('๐Ÿ† pro')
109
- .action(function (...args) {
110
- try {
111
- // execute `dotenvx-pro` if available
112
- execSync('dotenvx-pro', { stdio: ['inherit', 'inherit', 'ignore'] })
113
- } catch (_error) {
114
- const pro = fs.readFileSync(path.join(__dirname, './pro.txt'), 'utf8')
115
-
116
- console.log(pro)
117
- }
118
- })
119
-
120
- // // dotenvx ent
121
- // program.command('ent')
122
- // .description('๐Ÿข enterprise')
123
- // .action(function (...args) {
124
- // console.log('coming soon (med-large companies)')
125
- // })
126
-
127
115
  // dotenvx ext
128
116
  program.addCommand(require('./commands/ext'))
129
117
 
@@ -193,6 +181,21 @@ program.command('scan')
193
181
  scanAction.apply(this, args)
194
182
  })
195
183
 
184
+ program.command('help [command]')
185
+ .description('display help for command')
186
+ .action((command) => {
187
+ if (command) {
188
+ const subCommand = program.commands.find(c => c.name() === command)
189
+ if (subCommand) {
190
+ subCommand.outputHelp()
191
+ } else {
192
+ program.outputHelp()
193
+ }
194
+ } else {
195
+ program.outputHelp()
196
+ }
197
+ })
198
+
196
199
  // overide helpInformation to hide DEPRECATED commands
197
200
  program.helpInformation = function () {
198
201
  const originalHelp = Command.prototype.helpInformation.call(this)
@@ -0,0 +1,42 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const childProcess = require('child_process')
4
+ const { logger } = require('../../shared/logger')
5
+
6
+ function executeDynamic (program, command, rawArgs) {
7
+ if (!command) {
8
+ program.outputHelp()
9
+ process.exit(1)
10
+ return
11
+ }
12
+
13
+ // construct the full command line manually including flags
14
+ const commandIndex = rawArgs.indexOf(command)
15
+ const forwardedArgs = rawArgs.slice(commandIndex + 1)
16
+
17
+ logger.debug(`command: ${command}`)
18
+ logger.debug(`args: ${JSON.stringify(forwardedArgs)}`)
19
+
20
+ const binPath = path.join(process.cwd(), 'node_modules', '.bin')
21
+ const newPath = `${binPath}:${process.env.PATH}`
22
+ const env = { ...process.env, PATH: newPath }
23
+
24
+ const result = childProcess.spawnSync(`dotenvx-${command}`, forwardedArgs, { stdio: 'inherit', env })
25
+ if (result.error) {
26
+ if (command === 'pro') {
27
+ // logger.warn(`[INSTALLATION_NEEDED] install dotenvx-${command} to use [dotenvx ${command}] commands ๐Ÿ†`)
28
+ // logger.help('? see installation instructions [https://github.com/dotenvx/dotenvx-pro]')
29
+
30
+ const pro = fs.readFileSync(path.join(__dirname, './../../cli/pro.txt'), 'utf8')
31
+ console.log(pro)
32
+ } else {
33
+ logger.info(`error: unknown command '${command}'`)
34
+ }
35
+ }
36
+
37
+ if (result.status !== 0) {
38
+ process.exit(result.status)
39
+ }
40
+ }
41
+
42
+ module.exports = executeDynamic