@dotenvx/dotenvx-ops 0.23.3 → 0.23.5

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.23.3...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.5...main)
6
+
7
+ ## [0.23.5](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.4...v0.23.5) (2025-12-10)
8
+
9
+ ### Added
10
+
11
+ * Prompt for username and password on `rotate npm connect` ([#14](https://github.com/dotenvx/dotenvx-ops/pull/14))
12
+
13
+ ## [0.23.4](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.3...v0.23.4) (2025-12-10)
14
+
15
+ ### Added
16
+
17
+ * Add working `rotate URI` command ([#13](https://github.com/dotenvx/dotenvx-ops/pull/13))
6
18
 
7
19
  ## [0.23.3](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.2...v0.23.3) (2025-12-09)
8
20
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.23.3",
2
+ "version": "0.23.5",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "Dotenvx Ops – commercial tooling for .env files",
5
5
  "author": "@motdotla",
@@ -1,4 +1,6 @@
1
1
  const { logger } = require('@dotenvx/dotenvx')
2
+ const prompts = require('@inquirer/prompts')
3
+ const Session = require('./../../../../db/session')
2
4
  const RotateNpmConnect = require('./../../../../lib/services/rotateNpmConnect')
3
5
  const { createSpinner } = require('./../../../../lib/helpers/createSpinner')
4
6
 
@@ -9,21 +11,30 @@ async function connect () {
9
11
  logger.debug(`options: ${JSON.stringify(options)}`)
10
12
 
11
13
  try {
12
- spinner.start()
13
-
14
+ const sesh = new Session()
14
15
  const hostname = options.hostname
15
- const token = options.token
16
+ const token = options.token || sesh.token()
16
17
  const org = options.org
17
- const username = options.username
18
- const password = options.password
18
+ let username = options.username
19
+ let password = options.password
19
20
  const email = options.email
20
21
 
21
- const { url } = await new RotateNpmConnect(hostname, token, org, username, password, email).run()
22
+ if (!username || username === '') {
23
+ username = await prompts.input({ message: 'npm username:' })
24
+ }
25
+
26
+ if (!password || password === '') {
27
+ password = await prompts.password({ message: 'npm password:' })
28
+ }
29
+
30
+ spinner.start()
31
+
32
+ const { uid, url } = await new RotateNpmConnect(hostname, token, org, username, password, email).run()
22
33
 
23
34
  spinner.stop()
24
35
 
25
36
  logger.success(`✔ connected [${url}]`)
26
- logger.help('⮕ next run [dotenvx-ops rotate npm rotate]')
37
+ logger.help(`⮕ next run [dotenvx-ops rotate dotenvx://${uid}]`)
27
38
  } catch (error) {
28
39
  spinner.stop()
29
40
  if (error.message) {
@@ -0,0 +1,42 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+ const Session = require('./../../db/session')
3
+ const Rotate = require('./../../lib/services/rotate')
4
+ const { createSpinner } = require('./../../lib/helpers/createSpinner')
5
+
6
+ const spinner = createSpinner('rotating..')
7
+
8
+ async function rotate (uri) {
9
+ const options = this.opts()
10
+ logger.debug(`options: ${JSON.stringify(options)}`)
11
+
12
+ try {
13
+ spinner.start()
14
+
15
+ const sesh = new Session()
16
+ const hostname = options.hostname
17
+ const token = options.token || sesh.token()
18
+
19
+ const { url, rotUid } = await new Rotate(hostname, token, uri).run()
20
+
21
+ spinner.stop()
22
+
23
+ logger.success(`✔ rotated [${url}]`)
24
+ logger.help(`⮕ next run [dotenvx-ops get dotenvx://${rotUid}]`)
25
+ } catch (error) {
26
+ spinner.stop()
27
+ if (error.message) {
28
+ logger.error(error.message)
29
+ } else {
30
+ logger.error(error)
31
+ }
32
+ if (error.help) {
33
+ logger.help(error.help)
34
+ }
35
+ if (error.stack) {
36
+ logger.debug(error.stack)
37
+ }
38
+ process.exit(1)
39
+ }
40
+ }
41
+
42
+ module.exports = rotate
@@ -15,18 +15,11 @@ npm
15
15
  .command('connect')
16
16
  .description('connect passcard')
17
17
  .requiredOption('--org <organizationSlug>')
18
- .requiredOption('--username <username>')
19
- .requiredOption('--password <password>')
18
+ .option('--username <username>')
19
+ .option('--password <password>')
20
20
  .option('--email <email>')
21
21
  .option('--hostname <url>', 'set hostname', sesh.hostname())
22
- .option('--token <token>', 'set token', sesh.token())
22
+ .option('--token <token>', 'set token')
23
23
  .action(connectAction)
24
24
 
25
- // dotenvx-ops rotate npm rotate
26
- const rotateAction = require('./../../actions/rotate/npm/rotate')
27
- npm
28
- .command('rotate')
29
- .description('rotate api key')
30
- .action(rotateAction)
31
-
32
25
  module.exports = npm
@@ -2,10 +2,29 @@ const { Command } = require('commander')
2
2
 
3
3
  const rotate = new Command('rotate')
4
4
 
5
+ const Session = require('./../../db/session')
6
+ const sesh = new Session()
7
+
5
8
  rotate
6
- .description('rotate api keys')
9
+ .description('rotate secret')
7
10
  .allowUnknownOption()
8
11
 
9
12
  rotate.addCommand(require('./rotate/npm'))
10
13
 
14
+ // dotenvx-ops rotate (fallback positional argument handler)
15
+ const rotateAction = require('../actions/rotate')
16
+ rotate
17
+ .argument('[URI]', 'URI') // brackets = optional
18
+ .option('--hostname <url>', 'set hostname', sesh.hostname())
19
+ .option('--token <token>', 'set token')
20
+ .action(async function (uri, options, command) {
21
+ if (!uri) {
22
+ command.help()
23
+ return
24
+ }
25
+
26
+ // Call external action with correct "this" binding
27
+ await rotateAction.call(this, uri)
28
+ })
29
+
11
30
  module.exports = rotate
@@ -53,9 +53,6 @@ program
53
53
  .option('--force', 'force changes')
54
54
  .action(syncAction)
55
55
 
56
- // dotenvx-ops rotate
57
- program.addCommand(require('./commands/rotate'))
58
-
59
56
  // dotenvx-ops get
60
57
  const getAction = require('./actions/get')
61
58
  program
@@ -66,6 +63,9 @@ program
66
63
  .option('--token <token>', 'set token')
67
64
  .action(getAction)
68
65
 
66
+ // dotenvx-ops rotate
67
+ program.addCommand(require('./commands/rotate'))
68
+
69
69
  // dotenvx-ops login
70
70
  const loginAction = require('./actions/login')
71
71
  program
@@ -0,0 +1,39 @@
1
+ const { http } = require('../../lib/helpers/http')
2
+ const buildApiError = require('../../lib/helpers/buildApiError')
3
+
4
+ class PostRotate {
5
+ constructor (hostname, token, uri) {
6
+ this.hostname = hostname || 'https://ops.dotenvx.com'
7
+ this.token = token
8
+
9
+ this.uri = uri
10
+ }
11
+
12
+ async run () {
13
+ const token = this.token
14
+ const url = `${this.hostname}/api/rotate`
15
+
16
+ const uri = this.uri
17
+
18
+ const resp = await http(url, {
19
+ method: 'POST',
20
+ headers: {
21
+ Authorization: `Bearer ${token}`,
22
+ 'Content-Type': 'application/json'
23
+ },
24
+ body: JSON.stringify({
25
+ uri
26
+ })
27
+ })
28
+
29
+ const json = await resp.body.json()
30
+
31
+ if (resp.statusCode >= 400) {
32
+ throw buildApiError(resp.statusCode, json)
33
+ }
34
+
35
+ return json
36
+ }
37
+ }
38
+
39
+ module.exports = PostRotate
@@ -0,0 +1,28 @@
1
+ const PostRotate = require('./../api/postRotate')
2
+
3
+ class Rotate {
4
+ constructor (hostname, token, inputUri) {
5
+ this.hostname = hostname
6
+ this.token = token
7
+ this.inputUri = inputUri
8
+ }
9
+
10
+ async run () {
11
+ const hostname = this.hostname
12
+ const token = this.token
13
+ const inputUri = this.inputUri
14
+
15
+ const json = await new PostRotate(hostname, token, inputUri).run()
16
+ const uri = json.uri
17
+ const url = json.url
18
+ const rotUid = json.rot_uid
19
+
20
+ return {
21
+ uri,
22
+ url,
23
+ rotUid
24
+ }
25
+ }
26
+ }
27
+
28
+ module.exports = Rotate
@@ -42,11 +42,12 @@ class RotateNpmConnect {
42
42
 
43
43
  const playwrightStorageStateStringified = JSON.stringify(await context.storageState())
44
44
 
45
- const { url } = await new PostRotateConnect(hostname, token, org, slug, username, password, email, playwrightStorageStateStringified).run()
45
+ const { uid, url } = await new PostRotateConnect(hostname, token, org, slug, username, password, email, playwrightStorageStateStringified).run()
46
46
 
47
47
  await browser.close()
48
48
 
49
49
  return {
50
+ uid,
50
51
  url
51
52
  }
52
53
  }
@@ -1,9 +0,0 @@
1
- const { logger } = require('@dotenvx/dotenvx')
2
-
3
- async function rotate () {
4
- const options = this.opts()
5
- logger.debug(`options: ${JSON.stringify(options)}`)
6
- process.stdout.write('coming soon')
7
- }
8
-
9
- module.exports = rotate