Skip to content

Commit

Permalink
move scan and hub under ext
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 22, 2024
1 parent 49cdad0 commit ecf8238
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const open = require('open')
const { request } = require('undici')
const clipboardy = require('./../../../lib/helpers/clipboardy')
const clipboardy = require('./../../../../lib/helpers/clipboardy')
const confirm = require('@inquirer/confirm').default

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

const OAUTH_CLIENT_ID = 'oac_dotenvxcli'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const openBrowser = require('open')
const confirm = require('@inquirer/confirm').default

const createSpinner = require('./../../../shared/createSpinner')
const store = require('./../../../shared/store')
const { logger } = require('./../../../shared/logger')
const sleep = require('./../../../lib/helpers/sleep')
const createSpinner = require('./../../../../shared/createSpinner')
const store = require('./../../../../shared/store')
const { logger } = require('./../../../../shared/logger')
const sleep = require('./../../../../lib/helpers/sleep')

const username = store.getUsername()
const usernamePart = username ? ` [${username}]` : ''
Expand Down
18 changes: 9 additions & 9 deletions src/cli/actions/hub/open.js → src/cli/actions/ext/hub/open.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const openBrowser = require('open')
const confirm = require('@inquirer/confirm').default

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

const isGitRepo = require('./../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../lib/helpers/isGithub')
const gitUrl = require('./../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../lib/helpers/sleep')
const createSpinner = require('./../../../../shared/createSpinner')
const { logger } = require('./../../../../shared/logger')

const isGitRepo = require('./../../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../../lib/helpers/isGithub')
const gitUrl = require('./../../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../../lib/helpers/sleep')

const spinner = createSpinner('opening')

Expand Down
18 changes: 9 additions & 9 deletions src/cli/actions/hub/pull.js → src/cli/actions/ext/hub/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const fs = require('fs')
const path = require('path')
const { request } = require('undici')

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

const isGitRepo = require('./../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../lib/helpers/isGithub')
const gitUrl = require('./../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../lib/helpers/sleep')
const isGitRepo = require('./../../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../../lib/helpers/isGithub')
const gitUrl = require('./../../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../../lib/helpers/sleep')

const spinner = createSpinner('pulling')

Expand Down
22 changes: 11 additions & 11 deletions src/cli/actions/hub/push.js → src/cli/actions/ext/hub/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ const fs = require('fs')
const path = require('path')
const { request } = require('undici')

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

const isGitRepo = require('./../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../lib/helpers/isGithub')
const gitUrl = require('./../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../lib/helpers/sleep')
const forgivingDirectory = require('./../../../lib/helpers/forgivingDirectory')
const store = require('./../../../../shared/store')
const { logger } = require('./../../../../shared/logger')
const createSpinner = require('./../../../../shared/createSpinner')

const isGitRepo = require('./../../../../lib/helpers/isGitRepo')
const isGithub = require('./../../../../lib/helpers/isGithub')
const gitUrl = require('./../../../../lib/helpers/gitUrl')
const gitRoot = require('./../../../../lib/helpers/gitRoot')
const extractUsernameName = require('./../../../../lib/helpers/extractUsernameName')
const sleep = require('./../../../../lib/helpers/sleep')
const forgivingDirectory = require('./../../../../lib/helpers/forgivingDirectory')

const spinner = createSpinner('pushing')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const store = require('./../../../shared/store')
const { logger } = require('./../../../shared/logger')
const store = require('./../../../../shared/store')
const { logger } = require('./../../../../shared/logger')

async function status () {
logger.info(`logged in to ${store.getHostname()} as ${store.getUsername()}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const store = require('./../../../shared/store')
const { logger } = require('./../../../shared/logger')
const store = require('./../../../../shared/store')
const { logger } = require('./../../../../shared/logger')

async function token () {
logger.debug(store.configPath())
Expand Down
2 changes: 1 addition & 1 deletion src/cli/actions/scan.js → src/cli/actions/ext/scan.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const execa = require('execa')

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

async function scan () {
const options = this.opts()
Expand Down
7 changes: 7 additions & 0 deletions src/cli/commands/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ ext.command('precommit')
.option('-i, --install', 'install to .git/hooks/pre-commit')
.action(require('./../actions/ext/precommit'))

// dotenvx scan
ext.command('scan')
.description('scan for leaked secrets')
.action(require('./../actions/ext/scan'))

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

module.exports = ext
89 changes: 89 additions & 0 deletions src/cli/commands/ext/hub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const { Command } = require('commander')

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

const hub = new Command('hub')

hub
.description('DEPRECATED: to be replaced by [dotenvx pro]')

const loginAction = require('./../../actions/ext/hub/login')
hub
.command('login')
.description('authenticate to dotenvx hub')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

loginAction.apply(this, args)
})

const pushAction = require('./../../actions/ext/hub/push')
hub
.command('push')
.description('push .env.keys to dotenvx hub')
.argument('[directory]', 'directory to push', '.')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

pushAction.apply(this, args)
})

const pullAction = require('./../../actions/ext/hub/pull')
hub
.command('pull')
.description('pull .env.keys from dotenvx hub')
.argument('[directory]', 'directory to pull', '.')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

pullAction.apply(this, args)
})

const openAction = require('./../../actions/ext/hub/open')
hub
.command('open')
.description('view repository on dotenvx hub')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

openAction.apply(this, args)
})

const tokenAction = require('./../../actions/ext/hub/token')
hub
.command('token')
.description('print the auth token dotenvx hub is configured to use')
.option('-h, --hostname <url>', 'set hostname', 'https://hub.dotenvx.com')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

tokenAction.apply(this, args)
})

const statusAction = require('./../../actions/ext/hub/status')
hub
.command('status')
.description('display logged in user')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

statusAction.apply(this, args)
})

const logoutAction = require('./../../actions/ext/hub/logout')
hub
.command('logout')
.description('log out this machine from dotenvx hub')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: to be replaced by [dotenvx pro]')

logoutAction.apply(this, args)
})

module.exports = hub
42 changes: 21 additions & 21 deletions src/cli/commands/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,80 @@ const hub = new Command('hub')
hub
.description('DEPRECATED: to be replaced by [dotenvx pro]')

const loginAction = require('./../actions/hub/login')
const loginAction = require('./../actions/ext/hub/login')
hub
.command('login')
.description('authenticate to dotenvx hub')
.description('DEPRECATED: moved to [dotenvx ext hub login]')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub login] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub login] moved to [dotenvx ext hub login]')

loginAction.apply(this, args)
})

const pushAction = require('./../actions/hub/push')
const pushAction = require('./../actions/ext/hub/push')
hub
.command('push')
.description('push .env.keys to dotenvx hub')
.description('DEPRECATED: moved to [dotenvx ext hub push]')
.argument('[directory]', 'directory to push', '.')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub push] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub push] moved to [dotenvx ext hub push]')

pushAction.apply(this, args)
})

const pullAction = require('./../actions/hub/pull')
const pullAction = require('./../actions/ext/hub/pull')
hub
.command('pull')
.description('pull .env.keys from dotenvx hub')
.description('DEPRECATED: moved to [dotenvx ext hub pull]')
.argument('[directory]', 'directory to pull', '.')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub pull] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub pull] moved to [dotenvx ext hub pull]')

pullAction.apply(this, args)
})

const openAction = require('./../actions/hub/open')
const openAction = require('./../actions/ext/hub/open')
hub
.command('open')
.description('view repository on dotenvx hub')
.description('DEPRECATED: moved to [dotenvx ext hub open]')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub open] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub open] moved to [dotenvx ext hub open]')

openAction.apply(this, args)
})

const tokenAction = require('./../actions/hub/token')
const tokenAction = require('./../actions/ext/hub/token')
hub
.command('token')
.description('print the auth token dotenvx hub is configured to use')
.description('DEPRECATED: moved to [dotenvx ext hub token]')
.option('-h, --hostname <url>', 'set hostname', 'https://hub.dotenvx.com')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub token] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub token] moved to [dotenvx ext hub token]')

tokenAction.apply(this, args)
})

const statusAction = require('./../actions/hub/status')
const statusAction = require('./../actions/ext/hub/status')
hub
.command('status')
.description('display logged in user')
.description('DEPRECATED: moved to [dotenvx ext hub status]')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub status] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub status] moved to [dotenvx ext hub status]')

statusAction.apply(this, args)
})

const logoutAction = require('./../actions/hub/logout')
const logoutAction = require('./../actions/ext/hub/logout')
hub
.command('logout')
.description('log out this machine from dotenvx hub')
.description('DEPRECATED: moved to [dotenvx ext hub logout]')
.option('-h, --hostname <url>', 'set hostname', store.getHostname())
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [dotenvx hub logout] will be removed in 1.0.0 release soon')
logger.warn('DEPRECATION NOTICE: [dotenvx hub logout] moved to [dotenvx ext hub logout]')

logoutAction.apply(this, args)
})
Expand Down
24 changes: 14 additions & 10 deletions src/cli/dotenvx.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,12 @@ program.command('set')
// dotenvx encrypt
const encryptAction = require('./actions/encrypt')
program.command('encrypt')
.description('convert env file(s) to encrypted env file(s)')
.description('convert .env file(s) to encrypted .env file(s)')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
.action(encryptAction)

// dotenvx scan
program.command('scan')
.description('scan for leaked secrets')
.action(require('./actions/scan'))

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

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

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

Expand All @@ -115,6 +107,8 @@ program.command('settings')
//
// DEPRECATED AND hidden
//
program.addCommand(require('./commands/hub'))

program.command('convert')
.description('DEPRECATED: moved to [dotenvx encrypt]')
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
Expand Down Expand Up @@ -180,13 +174,23 @@ program.command('precommit')
precommitAction.apply(this, args)
})

// dotenvx scan
const scanAction = require('./actions/ext/scan')
program.command('scan')
.description('DEPRECATED: moved to [dotenvx ext scan]')
.action(function (...args) {
logger.warn('DEPRECATION NOTICE: [scan] has moved to [dotenvx ext scan]')

scanAction.apply(this, args)
})

// overide helpInformation to hide DEPRECATED commands
program.helpInformation = function () {
const originalHelp = Command.prototype.helpInformation.call(this)
const lines = originalHelp.split('\n')

// Filter out the hidden command from the help output
const filteredLines = lines.filter(line => !line.includes('DEPRECATED') || line.includes('hub'))
const filteredLines = lines.filter(line => !line.includes('DEPRECATED'))

return filteredLines.join('\n')
}
Expand Down

0 comments on commit ecf8238

Please sign in to comment.