@dotenvx/dotenvx-ops 0.20.2 → 0.22.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/README.md +1 -3
- package/package.json +2 -2
- package/src/cli/actions/get.js +32 -0
- package/src/cli/actions/observe.js +2 -1
- package/src/cli/dotenvx-ops.js +11 -0
- package/src/lib/api/postGet.js +37 -0
- package/src/lib/api/postObserve.js +5 -2
- package/src/lib/main.js +23 -1
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.22.0...main)
|
|
6
|
+
|
|
7
|
+
## [0.22.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.21.0...v0.22.0) (2025-11-26)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add `get` command for getting rotation tokens: `dotenvx get rot://gh/<slug>/NPM_TOKEN` ([#](https://github.com/dotenvx/dotenvx-ops/pull/7))
|
|
12
|
+
|
|
13
|
+
## [0.21.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.20.2...v0.21.0) (2025-10-11)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Send `DOTENVX_PROJECT_ID` along with `observe` call ([#5](https://github.com/dotenvx/dotenvx-ops/pull/5))
|
|
6
18
|
|
|
7
19
|
## [0.20.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.20.1...v0.20.2) (2025-10-07)
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
[](https://dotenvx.com/ops)
|
|
2
2
|
|
|
3
|
-
> Dotenvx Ops is commercial tooling for
|
|
4
|
-
|
|
5
|
-
*Use dotenvx across your team, infrastructure, agents, and more.*
|
|
3
|
+
> Dotenvx Ops is commercial tooling for .env files.
|
|
6
4
|
|
|
7
5
|
[Learn more](https://dotenvx.com/docs/ops)
|
|
8
6
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { logger } = require('@dotenvx/dotenvx')
|
|
2
|
+
|
|
3
|
+
const main = require('./../../lib/main')
|
|
4
|
+
|
|
5
|
+
async function get (uri) {
|
|
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
|
+
const value = await main.get(uri, { hostname, token })
|
|
15
|
+
process.stdout.write(value)
|
|
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 = get
|
|
@@ -11,9 +11,10 @@ async function observe (base64) {
|
|
|
11
11
|
|
|
12
12
|
const hostname = options.hostname
|
|
13
13
|
const token = options.token
|
|
14
|
+
const dotenvxProjectId = options.dotenvxProjectId
|
|
14
15
|
|
|
15
16
|
try {
|
|
16
|
-
await main.observe(base64, { hostname, token })
|
|
17
|
+
await main.observe(base64, { hostname, token, dotenvxProjectId })
|
|
17
18
|
} catch (error) {
|
|
18
19
|
if (error.message) {
|
|
19
20
|
logger.error(error.message)
|
package/src/cli/dotenvx-ops.js
CHANGED
|
@@ -39,10 +39,21 @@ program.command('observe')
|
|
|
39
39
|
.argument('BASE64', 'BASE64')
|
|
40
40
|
.option('--hostname <url>', 'set hostname', sesh.hostname())
|
|
41
41
|
.option('--token <token>', 'set token')
|
|
42
|
+
.option('--dotenvxProjectId <identifier>', 'set DOTENVX_PROJECT_ID')
|
|
42
43
|
.action(function (...args) {
|
|
43
44
|
observeAction.apply(this, args)
|
|
44
45
|
})
|
|
45
46
|
|
|
47
|
+
// dotenvx-ops get
|
|
48
|
+
const getAction = require('./actions/get')
|
|
49
|
+
program
|
|
50
|
+
.command('get')
|
|
51
|
+
.description('fetch secret')
|
|
52
|
+
.argument('URI', 'URI')
|
|
53
|
+
.option('--hostname <url>', 'set hostname', sesh.hostname())
|
|
54
|
+
.option('--token <token>', 'set token')
|
|
55
|
+
.action(getAction)
|
|
56
|
+
|
|
46
57
|
// dotenvx-ops sync
|
|
47
58
|
const syncAction = require('./actions/sync')
|
|
48
59
|
program
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { http } = require('../../lib/helpers/http')
|
|
2
|
+
const buildApiError = require('../../lib/helpers/buildApiError')
|
|
3
|
+
|
|
4
|
+
class PostGet {
|
|
5
|
+
constructor (hostname, token, uri) {
|
|
6
|
+
this.hostname = hostname || 'https://ops.dotenvx.com'
|
|
7
|
+
this.token = token
|
|
8
|
+
this.uri = uri
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async run () {
|
|
12
|
+
const token = this.token
|
|
13
|
+
const uri = this.uri
|
|
14
|
+
const url = `${this.hostname}/api/get`
|
|
15
|
+
|
|
16
|
+
const resp = await http(url, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${token}`,
|
|
20
|
+
'Content-Type': 'application/json'
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
uri
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (resp.statusCode >= 400) {
|
|
28
|
+
const json = await resp.body.json()
|
|
29
|
+
throw buildApiError(resp.statusCode, json)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const text = await resp.body.text()
|
|
33
|
+
return text
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = PostGet
|
|
@@ -3,7 +3,7 @@ const buildApiError = require('../../lib/helpers/buildApiError')
|
|
|
3
3
|
const packageJson = require('../../lib/helpers/packageJson')
|
|
4
4
|
|
|
5
5
|
class PostObserve {
|
|
6
|
-
constructor (hostname, token, encoded, pwd = null, gitUrl = null, gitBranch = null, systemUuid = null, osPlatform = null, osArch = null) {
|
|
6
|
+
constructor (hostname, token, encoded, pwd = null, gitUrl = null, gitBranch = null, systemUuid = null, osPlatform = null, osArch = null, dotenvxProjectId = null) {
|
|
7
7
|
this.hostname = hostname || 'https://ops.dotenvx.com'
|
|
8
8
|
this.token = token
|
|
9
9
|
this.encoded = encoded
|
|
@@ -13,6 +13,7 @@ class PostObserve {
|
|
|
13
13
|
this.systemUuid = systemUuid
|
|
14
14
|
this.osPlatform = osPlatform
|
|
15
15
|
this.osArch = osArch
|
|
16
|
+
this.dotenvxProjectId = dotenvxProjectId
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
async run () {
|
|
@@ -26,6 +27,7 @@ class PostObserve {
|
|
|
26
27
|
const systemUuid = this.systemUuid
|
|
27
28
|
const osPlatform = this.osPlatform
|
|
28
29
|
const osArch = this.osArch
|
|
30
|
+
const dotenvxProjectId = this.dotenvxProjectId
|
|
29
31
|
|
|
30
32
|
const resp = await http(url, {
|
|
31
33
|
method: 'POST',
|
|
@@ -42,7 +44,8 @@ class PostObserve {
|
|
|
42
44
|
system_uuid: systemUuid,
|
|
43
45
|
os_platform: osPlatform,
|
|
44
46
|
os_arch: osArch,
|
|
45
|
-
cli_version: packageJson.version
|
|
47
|
+
cli_version: packageJson.version,
|
|
48
|
+
dotenvx_project_id: dotenvxProjectId
|
|
46
49
|
})
|
|
47
50
|
})
|
|
48
51
|
|
package/src/lib/main.js
CHANGED
|
@@ -3,9 +3,11 @@ const dotenvx = require('@dotenvx/dotenvx')
|
|
|
3
3
|
|
|
4
4
|
const Session = require('./../db/session')
|
|
5
5
|
const PostObserve = require('./api/postObserve')
|
|
6
|
+
const PostGet = require('./api/postGet')
|
|
6
7
|
|
|
7
8
|
const gitUrl = require('./helpers/gitUrl')
|
|
8
9
|
const gitBranch = require('./helpers/gitBranch')
|
|
10
|
+
const dotenvxProjectId = require('./helpers/dotenvxProjectId')
|
|
9
11
|
|
|
10
12
|
const observe = async function (encoded, options = {}) {
|
|
11
13
|
const sesh = new Session() // TODO: handle scenario where constructor fails
|
|
@@ -21,6 +23,8 @@ const observe = async function (encoded, options = {}) {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const _pwd = process.cwd()
|
|
26
|
+
const _dotenvxProjectId = process.env.DOTENVX_PROJECT_ID || options.dotenvxProjectId || dotenvxProjectId(_pwd, false)
|
|
27
|
+
|
|
24
28
|
const _gitUrl = gitUrl()
|
|
25
29
|
const _gitBranch = gitBranch()
|
|
26
30
|
|
|
@@ -31,17 +35,35 @@ const observe = async function (encoded, options = {}) {
|
|
|
31
35
|
const _osPlatform = osInfo.platform
|
|
32
36
|
const _osArch = osInfo.arch
|
|
33
37
|
|
|
34
|
-
const json = await new PostObserve(hostname, token, encoded, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch).run()
|
|
38
|
+
const json = await new PostObserve(hostname, token, encoded, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch, _dotenvxProjectId).run()
|
|
35
39
|
|
|
36
40
|
return json
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
const get = async function (uri, options = {}) {
|
|
44
|
+
const sesh = new Session() // TODO: handle scenario where constructor fails
|
|
45
|
+
|
|
46
|
+
let hostname = process.env.DOTENVX_OPS_HOSTNAME || process.env.DOTENVX_RADAR_HOSTNAME || options.hostname
|
|
47
|
+
if (!hostname) {
|
|
48
|
+
hostname = sesh.hostname()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let token = process.env.DOTENVX_OPS_TOKEN || process.env.DOTENVX_RADAR_TOKEN || options.token
|
|
52
|
+
if (!token) {
|
|
53
|
+
token = sesh.token()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const value = await new PostGet(hostname, token, uri).run()
|
|
57
|
+
return value
|
|
58
|
+
}
|
|
59
|
+
|
|
39
60
|
const config = function (options = {}) {
|
|
40
61
|
return dotenvx.config(options)
|
|
41
62
|
}
|
|
42
63
|
|
|
43
64
|
module.exports = {
|
|
44
65
|
observe,
|
|
66
|
+
get,
|
|
45
67
|
// dotenv proxies
|
|
46
68
|
config
|
|
47
69
|
}
|