Skip to content

Commit

Permalink
move ls under extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 21, 2024
1 parent 1c1b0f2 commit cbcb685
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/cli/actions/ls.js → src/cli/actions/ext/ls.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const treeify = require('object-treeify')

const { logger } = require('./../../shared/logger')
const { logger } = require('./../../../shared/logger')

const main = require('./../../lib/main')
const ArrayToTree = require('./../../lib/helpers/arrayToTree')
const main = require('./../../../lib/main')
const ArrayToTree = require('./../../../lib/helpers/arrayToTree')

function ls (directory) {
// debug args
Expand Down
18 changes: 18 additions & 0 deletions src/cli/commands/ext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { Command } = require('commander')

const store = require('./../../shared/store')
const { logger } = require('./../../shared/logger')

const ext = new Command('ext')

ext
.description('extended dotenvx functionality')

// dotenvx ls
ext.command('ls')
.description('print all .env files in a tree structure')
.argument('[directory]', 'directory to list .env files from', '.')
.option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
.action(require('./../actions/ext/ls'))

module.exports = ext
2 changes: 1 addition & 1 deletion src/cli/commands/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { logger } = require('./../../shared/logger')
const hub = new Command('hub')

hub
.description('DEPRECATED: interact with dotenvx hub')
.description('DEPRECATED: interact with hub (will be replaced by pro - @motdotla)')

const loginAction = require('./../actions/hub/login')
hub
Expand Down
39 changes: 24 additions & 15 deletions src/cli/dotenvx.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,6 @@ program.command('encrypt')
.description('convert env file(s) to encrypted env file(s)')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
.action(encryptAction)
program.command('convert')
.description('DEPRECATED: moved to [dotenvx encrypt]')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx convert] has moved to [dotenvx encrypt]')

encryptAction.apply(this, args)
})

// dotenvx ls
program.command('ls')
.description('print all .env files in a tree structure')
.argument('[directory]', 'directory to list .env files from', '.')
.option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
.action(require('./actions/ls'))

// dotenvx genexample
program.command('genexample')
Expand Down Expand Up @@ -145,10 +130,34 @@ program.command('settings')
.option('-pp, --pretty-print', 'pretty print output')
.action(require('./actions/settings'))

program.addCommand(require('./commands/ext'))

// dotenvx vault
program.addCommand(require('./commands/vault'))

// DEPRECATED: dotenvx hub
program.addCommand(require('./commands/hub'))

// DEPRECATED: dotenvx convert
program.command('convert')
.description('DEPRECATED: moved to [dotenvx encrypt]')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx convert] has moved to [dotenvx encrypt]')

encryptAction.apply(this, args)
})

// DEPRECATED: dotenvx ls
const lsAction = require('./actions/ext/ls')
program.command('ls')
.description('DEPRECATED: moved to [dotenvx ext ls]')
.argument('[directory]', 'directory to list .env files from', '.')
.option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [ls] has moved to [dotenvx ext ls]')

lsAction.apply(this, args)
})

program.parse(process.argv)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const t = require('tap')
const sinon = require('sinon')

const main = require('../../../src/lib/main')
const ls = require('../../../src/cli/actions/ls')
const main = require('../../../../src/lib/main')
const ls = require('../../../../src/cli/actions/ls')

t.test('ls calls main.ls', async ct => {
const stub = sinon.stub(main, 'ls')
Expand Down

0 comments on commit cbcb685

Please sign in to comment.