@dotenvx/dotenvx-ops 0.37.7 → 0.37.9

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-ops/compare/v0.37.7...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.37.9...main)
6
+
7
+ ## [0.37.9](https://github.com/dotenvx/dotenvx-ops/compare/v0.37.8...v0.37.9) (2026-04-17)
8
+
9
+ ### Changed
10
+
11
+ * Fix `open` when open command does not exist on user's machine ([#36](https://github.com/dotenvx/dotenvx-ops/pull/36))
12
+
13
+ ## [0.37.8](https://github.com/dotenvx/dotenvx-ops/compare/v0.37.7...v0.37.8) (2026-04-08)
14
+
15
+ ### Changed
16
+
17
+ * Improve `keypair` coldstart ([#35](https://github.com/dotenvx/dotenvx-ops/pull/35))
6
18
 
7
19
  ## [0.37.7](https://github.com/dotenvx/dotenvx-ops/compare/v0.37.6...v0.37.7) (2026-04-08)
8
20
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.37.7",
2
+ "version": "0.37.9",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "Secrets for agents–from the creator of `dotenv` and `dotenvx`",
5
5
  "author": "@motdotla",
@@ -1,5 +1,4 @@
1
1
  const fs = require('fs')
2
- const open = require('open')
3
2
 
4
3
  const { logger } = require('@dotenvx/dotenvx')
5
4
  const Session = require('./../../db/session')
@@ -9,6 +8,7 @@ const clipboardy = require('./../../lib/helpers/clipboardy')
9
8
  const confirm = require('./../../lib/helpers/confirm')
10
9
  const formatCode = require('./../../lib/helpers/formatCode')
11
10
  const truncate = require('./../../lib/helpers/truncate')
11
+ const openUrl = require('./../../lib/helpers/openUrl')
12
12
 
13
13
  const LoggedIn = require('./../../lib/services/loggedIn')
14
14
  const Login = require('./../../lib/services/login')
@@ -48,7 +48,7 @@ async function backup () {
48
48
 
49
49
  // optionally allow user to open browser
50
50
  confirm({ message: `press Enter to open [${verificationUri}] and enter code [${formatCode(userCode)}]...` })
51
- .then(answer => answer && open(verificationUriComplete))
51
+ .then(answer => answer && openUrl(verificationUriComplete))
52
52
  .catch(() => {}) // ignore
53
53
 
54
54
  const data = await pollPromise
@@ -1,17 +1,22 @@
1
1
  const { logger } = require('@dotenvx/dotenvx')
2
2
  const Session = require('./../../db/session')
3
-
4
- const main = require('./../../lib/main')
3
+ const createSpinner = require('../../lib/helpers/createSpinner2')
5
4
 
6
5
  async function keypair (publicKey) {
7
6
  // debug opts
8
7
  const options = this.opts()
8
+ const spinner = await createSpinner({ ...options, text: 'retrieving' })
9
+
9
10
  logger.debug(`options: ${JSON.stringify(options)}`)
11
+ if (publicKey) {
12
+ logger.debug(`publicKey: ${publicKey}`)
13
+ }
10
14
 
11
15
  const sesh = new Session()
12
16
  const hostname = options.hostname || sesh.hostname()
13
17
  const token = options.token
14
18
  try {
19
+ const main = require('./../../lib/main')
15
20
  const kp = await main.keypair(publicKey, { hostname, token })
16
21
  const output = {
17
22
  public_key: kp.publicKey,
@@ -23,16 +28,15 @@ async function keypair (publicKey) {
23
28
  space = 2
24
29
  }
25
30
 
31
+ if (spinner) spinner.stop()
26
32
  console.log(JSON.stringify(output, null, space))
27
33
  } catch (error) {
34
+ if (spinner) spinner.stop()
28
35
  if (error.message) {
29
36
  logger.error(error.message)
30
37
  } else {
31
38
  logger.error(error)
32
39
  }
33
- if (error.help) {
34
- logger.help(error.help)
35
- }
36
40
  if (error.stack) {
37
41
  logger.debug(error.stack)
38
42
  }
@@ -1,4 +1,3 @@
1
- const open = require('open')
2
1
  const { logger } = require('@dotenvx/dotenvx')
3
2
  const Session = require('./../../db/session')
4
3
 
@@ -8,6 +7,7 @@ const LoginPoll = require('./../../lib/services/loginPoll')
8
7
  const clipboardy = require('./../../lib/helpers/clipboardy')
9
8
  const createSpinner2 = require('../../lib/helpers/createSpinner2')
10
9
  const formatCode = require('./../../lib/helpers/formatCode')
10
+ const openUrl = require('./../../lib/helpers/openUrl')
11
11
 
12
12
  const FRAMES = ['◐', '◓', '◑', '◒']
13
13
 
@@ -17,6 +17,7 @@ function listenForOpenKey (onOpen) {
17
17
 
18
18
  const canSetRawMode = typeof stdin.setRawMode === 'function'
19
19
  const wasRawMode = Boolean(stdin.isRaw)
20
+ let didHandleOpenChoice = false
20
21
 
21
22
  const cleanup = () => {
22
23
  stdin.off('data', onData)
@@ -35,12 +36,17 @@ function listenForOpenKey (onOpen) {
35
36
  }
36
37
 
37
38
  if (key === '\r' || key === '\n' || lower === 'y') {
38
- cleanup()
39
- Promise.resolve(onOpen()).catch(() => {})
39
+ if (!didHandleOpenChoice) {
40
+ didHandleOpenChoice = true
41
+ Promise.resolve(onOpen()).catch(() => {})
42
+ }
40
43
  return
41
44
  }
42
45
 
43
- if (lower === 'n') cleanup()
46
+ if (lower === 'n') {
47
+ cleanup()
48
+ process.kill(process.pid, 'SIGINT')
49
+ }
44
50
  }
45
51
 
46
52
  if (canSetRawMode) stdin.setRawMode(true)
@@ -78,7 +84,7 @@ async function login () {
78
84
 
79
85
  // begin polling
80
86
  const pollPromise = new LoginPoll(hostname, deviceCode, interval).run()
81
- cleanupOpenKeyListener = listenForOpenKey(() => open(verificationUriComplete))
87
+ cleanupOpenKeyListener = listenForOpenKey(() => openUrl(verificationUriComplete))
82
88
  const data = await pollPromise
83
89
 
84
90
  cleanupOpenKeyListener()
@@ -1,9 +1,8 @@
1
- const _open = require('open')
2
-
3
1
  const { logger } = require('@dotenvx/dotenvx')
4
2
  const Session = require('./../../db/session')
5
3
 
6
4
  const dotenvxProjectId = require('./../../lib/helpers/dotenvxProjectId')
5
+ const openUrl = require('./../../lib/helpers/openUrl')
7
6
 
8
7
  async function open () {
9
8
  // debug opts
@@ -15,7 +14,7 @@ async function open () {
15
14
  const uid = dotenvxProjectId(this.cwd)
16
15
  const url = `${hostname}/go/${uid}`
17
16
 
18
- _open(url)
17
+ await openUrl(url)
19
18
 
20
19
  logger.success(`✔ opened [${url}]`)
21
20
  } catch (error) {
@@ -9,8 +9,6 @@ github
9
9
  .description('github')
10
10
  .allowUnknownOption()
11
11
 
12
- // dotenvx-ops rotate github connect
13
- const connectAction = require('./../../actions/rotate/github/connect')
14
12
  github
15
13
  .command('connect')
16
14
  .description('connect passcard')
@@ -20,6 +18,9 @@ github
20
18
  .option('--email <email>')
21
19
  .option('--hostname <url>', 'set hostname', sesh.hostname())
22
20
  .option('--token <token>', 'set token')
23
- .action(connectAction)
21
+ .action(async function (...args) {
22
+ const connectAction = require('./../../actions/rotate/github/connect')
23
+ await connectAction.apply(this, args)
24
+ })
24
25
 
25
26
  module.exports = github
@@ -9,8 +9,6 @@ npm
9
9
  .description('npm')
10
10
  .allowUnknownOption()
11
11
 
12
- // dotenvx-ops rotate npm connect
13
- const connectAction = require('./../../actions/rotate/npm/connect')
14
12
  npm
15
13
  .command('connect')
16
14
  .description('connect passcard')
@@ -20,6 +18,9 @@ npm
20
18
  .option('--email <email>')
21
19
  .option('--hostname <url>', 'set hostname', sesh.hostname())
22
20
  .option('--token <token>', 'set token')
23
- .action(connectAction)
21
+ .action(async function (...args) {
22
+ const connectAction = require('./../../actions/rotate/npm/connect')
23
+ await connectAction.apply(this, args)
24
+ })
24
25
 
25
26
  module.exports = npm
@@ -9,8 +9,6 @@ openai
9
9
  .description('openai')
10
10
  .allowUnknownOption()
11
11
 
12
- // dotenvx-ops rotate openai connect
13
- const connectAction = require('./../../actions/rotate/openai/connect')
14
12
  openai
15
13
  .command('connect')
16
14
  .description('connect passcard')
@@ -20,6 +18,9 @@ openai
20
18
  .option('--email <email>')
21
19
  .option('--hostname <url>', 'set hostname', sesh.hostname())
22
20
  .option('--token <token>', 'set token')
23
- .action(connectAction)
21
+ .action(async function (...args) {
22
+ const connectAction = require('./../../actions/rotate/openai/connect')
23
+ await connectAction.apply(this, args)
24
+ })
24
25
 
25
26
  module.exports = openai
@@ -90,7 +90,12 @@ program
90
90
  .action(setAction)
91
91
 
92
92
  // dotenvx-ops rotate
93
- program.addCommand(require('./commands/rotate'))
93
+ const argv = process.argv.slice(2)
94
+ const firstArg = argv[0]
95
+ const shouldLoadRotateCommand = firstArg === 'rotate' || firstArg === 'help' || firstArg === '--help' || firstArg === '-h'
96
+ if (shouldLoadRotateCommand) {
97
+ program.addCommand(require('./commands/rotate'))
98
+ }
94
99
 
95
100
  // dotenvx-ops login
96
101
  const loginAction = require('./actions/login')
@@ -1,6 +1,7 @@
1
1
  const { http } = require('../../lib/helpers/http')
2
2
  const buildApiError = require('../../lib/helpers/buildApiError')
3
3
  const packageJson = require('../../lib/helpers/packageJson')
4
+ const normalizeToken = require('../../lib/helpers/normalizeToken')
4
5
 
5
6
  class PostKeypair {
6
7
  constructor (hostname, token, devicePublicKey, publicKey) {
@@ -11,7 +12,7 @@ class PostKeypair {
11
12
  }
12
13
 
13
14
  async run () {
14
- const token = this.token
15
+ const token = normalizeToken(this.token)
15
16
  const devicePublicKey = this.devicePublicKey
16
17
  const publicKey = this.publicKey
17
18
  const url = `${this.hostname}/api/keypair`
@@ -0,0 +1,7 @@
1
+ const open = require('open')
2
+
3
+ async function openUrl (url) {
4
+ return open(url, { wait: true })
5
+ }
6
+
7
+ module.exports = openUrl