Skip to content

Commit

Permalink
move genexample under extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 21, 2024
1 parent cbcb685 commit e857f4b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fs = require('fs')
const main = require('./../../lib/main')
const { logger } = require('./../../shared/logger')
const createSpinner = require('./../../shared/createSpinner')
const main = require('./../../../lib/main')
const { logger } = require('./../../../shared/logger')
const createSpinner = require('./../../../shared/createSpinner')

const sleep = require('./../../lib/helpers/sleep')
const sleep = require('./../../../lib/helpers/sleep')

const spinner = createSpinner('generating')

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

ext
.description('extended dotenvx functionality')
.description('dotenvx extensions - ls, genexample, precommit, and more')

// dotenvx ls
ext.command('ls')
Expand All @@ -15,4 +15,11 @@ ext.command('ls')
.option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
.action(require('./../actions/ext/ls'))

// dotenvx genexample
ext.command('genexample')
.description('generate .env.example')
.argument('[directory]', 'directory to generate from', '.')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)', '.env')
.action(require('./../actions/ext/genexample'))

module.exports = ext
19 changes: 12 additions & 7 deletions src/cli/dotenvx.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ program.command('encrypt')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
.action(encryptAction)

// dotenvx genexample
program.command('genexample')
.description('generate .env.example')
.argument('[directory]', 'directory to generate from', '.')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)', '.env')
.action(require('./actions/genexample'))

// dotenvx gitignore
program.command('gitignore')
.description('append to .gitignore file (and if existing, .dockerignore, .npmignore, and .vercelignore)')
Expand Down Expand Up @@ -160,4 +153,16 @@ program.command('ls')
lsAction.apply(this, args)
})

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

genexampleAction.apply(this, args)
})

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

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

t.test('genexample calls main.genexample', async ct => {
const stub = sinon.stub(main, 'genexample')
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/actions/ext/ls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const t = require('tap')
const sinon = require('sinon')

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

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

0 comments on commit e857f4b

Please sign in to comment.