@dotenvx/dotenvx-ops 0.23.8 → 0.25.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 +13 -1
- package/package.json +1 -1
- package/src/cli/actions/rotate/npm/connect.js +23 -3
- package/src/cli/actions/set.js +32 -0
- package/src/cli/commands/rotate/npm.js +1 -1
- package/src/cli/dotenvx-ops.js +11 -0
- package/src/lib/api/getAccount.js +32 -0
- package/src/lib/api/postLogout.js +0 -1
- package/src/lib/api/postSet.js +40 -0
- package/src/lib/main.js +18 -0
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.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.25.0...main)
|
|
6
|
+
|
|
7
|
+
## [0.25.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.24.0...v0.25.0) (2025-12-11)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Select organization convenience
|
|
12
|
+
|
|
13
|
+
## [0.24.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.8...v0.24.0) (2025-12-10)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Add `set` ([#15](https://github.com/dotenvx/dotenvx-ops/pull/15))
|
|
6
18
|
|
|
7
19
|
## [0.23.8](https://github.com/dotenvx/dotenvx-ops/compare/v0.23.7...v0.23.8) (2025-12-10)
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ const prompts = require('@inquirer/prompts')
|
|
|
3
3
|
const Session = require('./../../../../db/session')
|
|
4
4
|
const RotateNpmConnect = require('./../../../../lib/services/rotateNpmConnect')
|
|
5
5
|
const { createSpinner } = require('./../../../../lib/helpers/createSpinner')
|
|
6
|
+
const GetAccount = require('./../../../../lib/api/getAccount')
|
|
6
7
|
|
|
7
8
|
const spinner = createSpinner('waiting on browser completion')
|
|
8
9
|
|
|
@@ -14,16 +15,35 @@ async function connect () {
|
|
|
14
15
|
const sesh = new Session()
|
|
15
16
|
const hostname = options.hostname
|
|
16
17
|
const token = options.token || sesh.token()
|
|
17
|
-
|
|
18
|
+
let org = options.org
|
|
18
19
|
let username = options.username
|
|
19
20
|
let password = options.password
|
|
20
21
|
const email = options.email
|
|
21
22
|
|
|
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) {
|
|
23
43
|
username = await prompts.input({ message: 'npm username:' })
|
|
24
44
|
}
|
|
25
45
|
|
|
26
|
-
if (!password
|
|
46
|
+
if (!password) {
|
|
27
47
|
password = await prompts.password({ message: 'npm password:' })
|
|
28
48
|
}
|
|
29
49
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { logger } = require('@dotenvx/dotenvx')
|
|
2
|
+
|
|
3
|
+
const main = require('./../../lib/main')
|
|
4
|
+
|
|
5
|
+
async function set (uri, value) {
|
|
6
|
+
// debug opts
|
|
7
|
+
const options = this.opts()
|
|
8
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
9
|
+
|
|
10
|
+
const hostname = options.hostname
|
|
11
|
+
const token = options.token
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
await main.set(uri, value, { hostname, token })
|
|
15
|
+
logger.success(`✔ set [${uri}]`)
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error.message) {
|
|
18
|
+
logger.error(error.message)
|
|
19
|
+
} else {
|
|
20
|
+
logger.error(error)
|
|
21
|
+
}
|
|
22
|
+
if (error.help) {
|
|
23
|
+
logger.help(error.help)
|
|
24
|
+
}
|
|
25
|
+
if (error.stack) {
|
|
26
|
+
logger.debug(error.stack)
|
|
27
|
+
}
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = set
|
|
@@ -14,7 +14,7 @@ const connectAction = require('./../../actions/rotate/npm/connect')
|
|
|
14
14
|
npm
|
|
15
15
|
.command('connect')
|
|
16
16
|
.description('connect passcard')
|
|
17
|
-
.
|
|
17
|
+
.option('--org <organizationSlug>')
|
|
18
18
|
.option('--username <username>')
|
|
19
19
|
.option('--password <password>')
|
|
20
20
|
.option('--email <email>')
|
package/src/cli/dotenvx-ops.js
CHANGED
|
@@ -63,6 +63,17 @@ program
|
|
|
63
63
|
.option('--token <token>', 'set token')
|
|
64
64
|
.action(getAction)
|
|
65
65
|
|
|
66
|
+
// dotenvx-ops set
|
|
67
|
+
const setAction = require('./actions/set')
|
|
68
|
+
program
|
|
69
|
+
.command('set')
|
|
70
|
+
.description('set secret')
|
|
71
|
+
.argument('URI', 'URI')
|
|
72
|
+
.argument('value', 'value')
|
|
73
|
+
.option('--hostname <url>', 'set hostname', sesh.hostname())
|
|
74
|
+
.option('--token <token>', 'set token')
|
|
75
|
+
.action(setAction)
|
|
76
|
+
|
|
66
77
|
// dotenvx-ops rotate
|
|
67
78
|
program.addCommand(require('./commands/rotate'))
|
|
68
79
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { http } = require('../../lib/helpers/http')
|
|
2
|
+
const buildApiError = require('../../lib/helpers/buildApiError')
|
|
3
|
+
|
|
4
|
+
class GetAccount {
|
|
5
|
+
constructor (hostname, token) {
|
|
6
|
+
this.hostname = hostname || 'https://ops.dotenvx.com'
|
|
7
|
+
this.token = token
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run () {
|
|
11
|
+
const token = this.token
|
|
12
|
+
const url = `${this.hostname}/api/account`
|
|
13
|
+
|
|
14
|
+
const resp = await http(url, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${token}`,
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const json = await resp.body.json()
|
|
23
|
+
|
|
24
|
+
if (resp.statusCode >= 400) {
|
|
25
|
+
throw buildApiError(resp.statusCode, json)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return json
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = GetAccount
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { http } = require('../../lib/helpers/http')
|
|
2
|
+
const buildApiError = require('../../lib/helpers/buildApiError')
|
|
3
|
+
|
|
4
|
+
class PostSet {
|
|
5
|
+
constructor (hostname, token, uri, value) {
|
|
6
|
+
this.hostname = hostname || 'https://ops.dotenvx.com'
|
|
7
|
+
this.token = token
|
|
8
|
+
this.uri = uri
|
|
9
|
+
this.value = value
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async run () {
|
|
13
|
+
const token = this.token
|
|
14
|
+
const uri = this.uri
|
|
15
|
+
const value = this.value
|
|
16
|
+
const url = `${this.hostname}/api/set`
|
|
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
|
+
value
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (resp.statusCode >= 400) {
|
|
31
|
+
const json = await resp.body.json()
|
|
32
|
+
throw buildApiError(resp.statusCode, json)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const text = await resp.body.text()
|
|
36
|
+
return text
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = PostSet
|
package/src/lib/main.js
CHANGED
|
@@ -4,6 +4,7 @@ const dotenvx = require('@dotenvx/dotenvx')
|
|
|
4
4
|
const Session = require('./../db/session')
|
|
5
5
|
const PostObserve = require('./api/postObserve')
|
|
6
6
|
const PostGet = require('./api/postGet')
|
|
7
|
+
const PostSet = require('./api/postSet')
|
|
7
8
|
|
|
8
9
|
const gitUrl = require('./helpers/gitUrl')
|
|
9
10
|
const gitBranch = require('./helpers/gitBranch')
|
|
@@ -57,6 +58,22 @@ const get = async function (uri, options = {}) {
|
|
|
57
58
|
return value
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
const set = async function (uri, value, options = {}) {
|
|
62
|
+
const sesh = new Session() // TODO: handle scenario where constructor fails
|
|
63
|
+
|
|
64
|
+
let hostname = process.env.DOTENVX_OPS_HOSTNAME || process.env.DOTENVX_RADAR_HOSTNAME || options.hostname
|
|
65
|
+
if (!hostname) {
|
|
66
|
+
hostname = sesh.hostname()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let token = process.env.DOTENVX_OPS_TOKEN || process.env.DOTENVX_RADAR_TOKEN || options.token
|
|
70
|
+
if (!token) {
|
|
71
|
+
token = sesh.token()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return await new PostSet(hostname, token, uri, value).run()
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
const config = function (options = {}) {
|
|
61
78
|
return dotenvx.config(options)
|
|
62
79
|
}
|
|
@@ -64,6 +81,7 @@ const config = function (options = {}) {
|
|
|
64
81
|
module.exports = {
|
|
65
82
|
observe,
|
|
66
83
|
get,
|
|
84
|
+
set,
|
|
67
85
|
// dotenv proxies
|
|
68
86
|
config
|
|
69
87
|
}
|