@dotenvx/dotenvx-ops 0.20.1 → 0.20.2
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,13 @@
|
|
|
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.20.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.20.2...main)
|
|
6
|
+
|
|
7
|
+
## [0.20.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.20.1...v0.20.2) (2025-10-07)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Send `DOTENVX_PROJECT_ID` along with login request for redirect convenience when present
|
|
6
12
|
|
|
7
13
|
## [0.20.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.20.0...v0.20.1) (2025-10-07)
|
|
8
14
|
|
package/package.json
CHANGED
package/src/cli/actions/login.js
CHANGED
|
@@ -8,6 +8,7 @@ const { createSpinner } = require('./../../lib/helpers/createSpinner')
|
|
|
8
8
|
const confirm = require('./../../lib/helpers/confirm')
|
|
9
9
|
const truncate = require('./../../lib/helpers/truncate')
|
|
10
10
|
const formatCode = require('./../../lib/helpers/formatCode')
|
|
11
|
+
const dotenvxProjectId = require('./../../lib/helpers/dotenvxProjectId')
|
|
11
12
|
|
|
12
13
|
const spinner = createSpinner('waiting on browser authorization')
|
|
13
14
|
|
|
@@ -73,7 +74,8 @@ async function login () {
|
|
|
73
74
|
const sesh = new Session()
|
|
74
75
|
const devicePublicKey = sesh.devicePublicKey()
|
|
75
76
|
const systemInformation = await sesh.systemInformation()
|
|
76
|
-
const
|
|
77
|
+
const _dotenvxProjectId = dotenvxProjectId(process.cwd(), false)
|
|
78
|
+
const data = await new PostOauthDeviceCode(hostname, devicePublicKey, systemInformation, _dotenvxProjectId).run()
|
|
77
79
|
|
|
78
80
|
const deviceCode = data.device_code
|
|
79
81
|
const userCode = data.user_code
|
|
@@ -6,16 +6,18 @@ const buildOauthError = require('../../lib/helpers/buildOauthError')
|
|
|
6
6
|
const OAUTH_CLIENT_ID = 'oac_dotenvxcli'
|
|
7
7
|
|
|
8
8
|
class PostOauthDeviceCode {
|
|
9
|
-
constructor (hostname, devicePublicKey, systemInformation) {
|
|
9
|
+
constructor (hostname, devicePublicKey, systemInformation, dotenvxProjectId = null) {
|
|
10
10
|
this.hostname = hostname
|
|
11
11
|
this.devicePublicKey = devicePublicKey
|
|
12
12
|
this.systemInformation = systemInformation
|
|
13
|
+
this.dotenvxProjectId = dotenvxProjectId
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
async run () {
|
|
16
17
|
const url = `${this.hostname}/oauth/device/code`
|
|
17
18
|
const devicePublicKey = this.devicePublicKey
|
|
18
19
|
const systemInformation = this.systemInformation
|
|
20
|
+
const dotenvxProjectId = this.dotenvxProjectId
|
|
19
21
|
|
|
20
22
|
const resp = await http(url, {
|
|
21
23
|
method: 'POST',
|
|
@@ -25,7 +27,8 @@ class PostOauthDeviceCode {
|
|
|
25
27
|
body: JSON.stringify({
|
|
26
28
|
client_id: OAUTH_CLIENT_ID,
|
|
27
29
|
device_public_key: devicePublicKey,
|
|
28
|
-
system_information: systemInformation
|
|
30
|
+
system_information: systemInformation,
|
|
31
|
+
dotenvx_project_id: dotenvxProjectId
|
|
29
32
|
})
|
|
30
33
|
})
|
|
31
34
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const dotenvx = require('@dotenvx/dotenvx')
|
|
4
|
+
const Errors = require('./errors')
|
|
5
|
+
|
|
6
|
+
function dotenvxProjectId (cwd = process.cwd(), raiseErrors = true) {
|
|
7
|
+
// 1. Prefer environment variable
|
|
8
|
+
if (process.env.DOTENVX_PROJECT_ID && process.env.DOTENVX_PROJECT_ID.trim()) {
|
|
9
|
+
return process.env.DOTENVX_PROJECT_ID.trim()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 2. Otherwise, parse .env.x contents
|
|
13
|
+
const filepath = path.join(cwd, '.env.x')
|
|
14
|
+
// file must exist
|
|
15
|
+
if (!fs.existsSync(filepath)) {
|
|
16
|
+
const filename = path.basename(filepath)
|
|
17
|
+
if (raiseErrors) {
|
|
18
|
+
throw new Errors({ filename, filepath }).envXFileMissing()
|
|
19
|
+
} else {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (fs.existsSync(filepath)) {
|
|
25
|
+
const src = fs.readFileSync(filepath, 'utf8')
|
|
26
|
+
const parsed = dotenvx.parse(src)
|
|
27
|
+
if (parsed.DOTENVX_PROJECT_ID && parsed.DOTENVX_PROJECT_ID.trim()) {
|
|
28
|
+
return parsed.DOTENVX_PROJECT_ID.trim()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 3. Nothing found
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = dotenvxProjectId
|
package/src/lib/services/sync.js
CHANGED
|
@@ -7,7 +7,7 @@ const Session = require('./../../db/session')
|
|
|
7
7
|
|
|
8
8
|
const gitUrl = require('./../helpers/gitUrl')
|
|
9
9
|
const gitBranch = require('./../helpers/gitBranch')
|
|
10
|
-
const
|
|
10
|
+
const dotenvxProjectId = require('./../helpers/dotenvxProjectId')
|
|
11
11
|
|
|
12
12
|
// api calls
|
|
13
13
|
const PostSync = require('./../api/postSync')
|
|
@@ -29,7 +29,7 @@ class Sync {
|
|
|
29
29
|
const files = this._files()
|
|
30
30
|
const payload = { files }
|
|
31
31
|
const encoded = Buffer.from(JSON.stringify(payload)).toString('base64')
|
|
32
|
-
const
|
|
32
|
+
const _dotenvxProjectId = dotenvxProjectId(this.cwd)
|
|
33
33
|
|
|
34
34
|
// optional
|
|
35
35
|
const _pwd = this.cwd
|
|
@@ -43,7 +43,7 @@ class Sync {
|
|
|
43
43
|
const _osPlatform = osInfo.platform
|
|
44
44
|
const _osArch = osInfo.arch
|
|
45
45
|
|
|
46
|
-
const data = await new PostSync(this.hostname, token, devicePublicKey, encoded,
|
|
46
|
+
const data = await new PostSync(this.hostname, token, devicePublicKey, encoded, _dotenvxProjectId, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch, this.force).run()
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
49
|
id: data.id,
|
|
@@ -53,32 +53,6 @@ class Sync {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
_dotenvxProjectId () {
|
|
57
|
-
// 1. Prefer environment variable
|
|
58
|
-
if (process.env.DOTENVX_PROJECT_ID && process.env.DOTENVX_PROJECT_ID.trim()) {
|
|
59
|
-
return process.env.DOTENVX_PROJECT_ID.trim()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 2. Otherwise, parse .env.x contents
|
|
63
|
-
const filepath = path.join(this.cwd, '.env.x')
|
|
64
|
-
// file must exist
|
|
65
|
-
if (!fs.existsSync(filepath)) {
|
|
66
|
-
const filename = path.basename(filepath)
|
|
67
|
-
throw new Errors({ filename, filepath }).envXFileMissing()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (fs.existsSync(filepath)) {
|
|
71
|
-
const src = fs.readFileSync(filepath, 'utf8')
|
|
72
|
-
const parsed = dotenvx.parse(src)
|
|
73
|
-
if (parsed.DOTENVX_PROJECT_ID && parsed.DOTENVX_PROJECT_ID.trim()) {
|
|
74
|
-
return parsed.DOTENVX_PROJECT_ID.trim()
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 3. Nothing found
|
|
79
|
-
return null
|
|
80
|
-
}
|
|
81
|
-
|
|
82
56
|
_files () {
|
|
83
57
|
const out = []
|
|
84
58
|
const filepaths = dotenvx.ls(this.cwd)
|