@dotenvx/dotenvx-ops 0.25.0 → 0.26.0

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,25 @@
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.25.0...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.26.0...main)
6
+
7
+ ## [0.26.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.25.2...v0.26.0) (2025-12-14)
8
+
9
+ ### Added
10
+
11
+ * Add `rotate github connect` ([#16](https://github.com/dotenvx/dotenvx-ops/pull/16))
12
+
13
+ ## [0.25.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.25.1...v0.25.2) (2025-12-11)
14
+
15
+ ### Changed
16
+
17
+ * Change `npm publish` mechanism
18
+
19
+ ## [0.25.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.25.0...v0.25.1) (2025-12-11)
20
+
21
+ ### Changed
22
+
23
+ * Change `npm publish` mechanism
6
24
 
7
25
  ## [0.25.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.24.0...v0.25.0) (2025-12-11)
8
26
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.25.0",
2
+ "version": "0.26.0",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "Dotenvx Ops – commercial tooling for .env files",
5
5
  "author": "@motdotla",
@@ -0,0 +1,75 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+ const prompts = require('@inquirer/prompts')
3
+ const Session = require('./../../../../db/session')
4
+ const RotateGithubConnect = require('./../../../../lib/services/rotateGithubConnect')
5
+ const { createSpinner } = require('./../../../../lib/helpers/createSpinner')
6
+ const GetAccount = require('./../../../../lib/api/getAccount')
7
+
8
+ const spinner = createSpinner('waiting on browser completion')
9
+
10
+ async function connect () {
11
+ const options = this.opts()
12
+ logger.debug(`options: ${JSON.stringify(options)}`)
13
+
14
+ try {
15
+ const sesh = new Session()
16
+ const hostname = options.hostname
17
+ const token = options.token || sesh.token()
18
+ let org = options.org
19
+ let username = options.username
20
+ let password = options.password
21
+ const email = options.email
22
+
23
+ // user must be logged in to use feature
24
+ const accountJson = await new GetAccount(hostname, token).run()
25
+
26
+ if (!org) {
27
+ const choices = accountJson.organizations.map(o => ({
28
+ name: o.provider_slug,
29
+ value: o.provider_slug
30
+ }))
31
+
32
+ if (choices.length === 1) {
33
+ org = choices[0].value // just use first choice
34
+ } else {
35
+ org = await prompts.select({
36
+ message: 'Select dotenvx organization',
37
+ choices
38
+ })
39
+ }
40
+ }
41
+
42
+ if (!username) {
43
+ username = await prompts.input({ message: 'github username:' })
44
+ }
45
+
46
+ if (!password) {
47
+ password = await prompts.password({ message: 'github password:' })
48
+ }
49
+
50
+ spinner.start()
51
+
52
+ const { uid, url } = await new RotateGithubConnect(hostname, token, org, username, password, email).run()
53
+
54
+ spinner.stop()
55
+
56
+ logger.success(`✔ connected [${url}]`)
57
+ logger.help(`⮕ next run [dotenvx-ops rotate dotenvx://${uid}]`)
58
+ } catch (error) {
59
+ spinner.stop()
60
+ if (error.message) {
61
+ logger.error(error.message)
62
+ } else {
63
+ logger.error(error)
64
+ }
65
+ if (error.help) {
66
+ logger.help(error.help)
67
+ }
68
+ if (error.stack) {
69
+ logger.debug(error.stack)
70
+ }
71
+ process.exit(1)
72
+ }
73
+ }
74
+
75
+ module.exports = connect
@@ -0,0 +1,25 @@
1
+ const { Command } = require('commander')
2
+
3
+ const github = new Command('github')
4
+
5
+ const Session = require('./../../../db/session')
6
+ const sesh = new Session()
7
+
8
+ github
9
+ .description('github')
10
+ .allowUnknownOption()
11
+
12
+ // dotenvx-ops rotate github connect
13
+ const connectAction = require('./../../actions/rotate/github/connect')
14
+ github
15
+ .command('connect')
16
+ .description('connect passcard')
17
+ .option('--org <organizationSlug>')
18
+ .option('--username <username>')
19
+ .option('--password <password>')
20
+ .option('--email <email>')
21
+ .option('--hostname <url>', 'set hostname', sesh.hostname())
22
+ .option('--token <token>', 'set token')
23
+ .action(connectAction)
24
+
25
+ module.exports = github
@@ -9,6 +9,7 @@ rotate
9
9
  .description('rotate secret')
10
10
  .allowUnknownOption()
11
11
 
12
+ rotate.addCommand(require('./rotate/github'))
12
13
  rotate.addCommand(require('./rotate/npm'))
13
14
 
14
15
  // dotenvx-ops rotate (fallback positional argument handler)
@@ -0,0 +1,56 @@
1
+ const PostRotateConnect = require('./../api/postRotateConnect')
2
+
3
+ const playwrightConnect = require('./../helpers/playwrightConnect')
4
+
5
+ const TIMEOUT = 500 // visibility timeout
6
+ const SLUG = 'github' // hardcoded
7
+
8
+ class RotateGithubConnect {
9
+ constructor (hostname, token, org, username, password, email = null) {
10
+ this.hostname = hostname
11
+ this.org = org
12
+ this.token = token
13
+ this.username = username
14
+ this.password = password
15
+
16
+ // optional
17
+ this.email = email
18
+ }
19
+
20
+ async run () {
21
+ const hostname = this.hostname
22
+ const token = this.token
23
+ const org = this.org
24
+ const username = this.username
25
+ const password = this.password
26
+ const email = this.email
27
+
28
+ const { browser, context, page } = await playwrightConnect()
29
+
30
+ const usernameSelector = 'input[type="text"]'
31
+ const passwordSelector = 'input[type="password"]'
32
+
33
+ await page.goto('https://github.com/login', { waitUntil: 'domcontentloaded' })
34
+ await page.waitForTimeout(TIMEOUT)
35
+ await page.fill(usernameSelector, username)
36
+ await page.waitForTimeout(TIMEOUT)
37
+ await page.fill(passwordSelector, password)
38
+ await page.waitForTimeout(TIMEOUT)
39
+ await page.press('input[type="password"]', 'Enter')
40
+ await page.waitForNavigation({ timeout: 0 })
41
+ await page.waitForSelector('img.avatar', { state: 'visible', timeout: 0 })
42
+
43
+ const playwrightStorageStateStringified = JSON.stringify(await context.storageState())
44
+
45
+ const { uid, url } = await new PostRotateConnect(hostname, token, org, SLUG, username, password, email, playwrightStorageStateStringified).run()
46
+
47
+ await browser.close()
48
+
49
+ return {
50
+ uid,
51
+ url
52
+ }
53
+ }
54
+ }
55
+
56
+ module.exports = RotateGithubConnect
@@ -3,6 +3,7 @@ const PostRotateConnect = require('./../api/postRotateConnect')
3
3
  const playwrightConnect = require('./../helpers/playwrightConnect')
4
4
 
5
5
  const TIMEOUT = 500 // visibility timeout
6
+ const SLUG = 'npm'
6
7
 
7
8
  class RotateNpmConnect {
8
9
  constructor (hostname, token, org, username, password, email = null) {
@@ -20,7 +21,6 @@ class RotateNpmConnect {
20
21
  const hostname = this.hostname
21
22
  const token = this.token
22
23
  const org = this.org
23
- const slug = 'npm' // hardcoded
24
24
  const username = this.username
25
25
  const password = this.password
26
26
  const email = this.email
@@ -42,7 +42,7 @@ class RotateNpmConnect {
42
42
 
43
43
  const playwrightStorageStateStringified = JSON.stringify(await context.storageState())
44
44
 
45
- const { uid, 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