@dotenvx/dotenvx 0.15.1 → 0.15.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/package.json +3 -3
- package/src/cli/actions/hub/login.js +54 -42
- package/src/cli/actions/hub/push.js +22 -19
- package/src/shared/axios.js +0 -7
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.15.
|
|
2
|
+
"version": "0.15.2",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a better dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"funding": "Have you seen dotenvx.com? run anywhere, cross-platform, and encrypted envs.",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@inquirer/prompts": "^3.3.0",
|
|
29
|
-
"axios": "^1.6.2",
|
|
30
29
|
"chalk": "^4.1.2",
|
|
31
30
|
"clipboardy": "^2.3.0",
|
|
32
31
|
"commander": "^11.1.0",
|
|
33
32
|
"conf": "^10.2.0",
|
|
34
33
|
"dotenv": "^16.4.2",
|
|
35
|
-
"dotenv-expand": "^11.0.
|
|
34
|
+
"dotenv-expand": "^11.0.3",
|
|
36
35
|
"execa": "^5.1.1",
|
|
37
36
|
"ignore": "^5.3.0",
|
|
38
37
|
"open": "^8.4.2",
|
|
39
38
|
"ora": "^5.4.1",
|
|
39
|
+
"undici": "^6.6.2",
|
|
40
40
|
"update-notifier": "^5.1.0",
|
|
41
41
|
"winston": "^3.11.0",
|
|
42
42
|
"xxhashjs": "^0.2.2"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const open = require('open')
|
|
2
|
-
const
|
|
2
|
+
const { request } = require('undici')
|
|
3
3
|
const clipboardy = require('clipboardy')
|
|
4
4
|
const { confirm } = require('@inquirer/prompts')
|
|
5
5
|
|
|
@@ -16,41 +16,47 @@ async function pollTokenUrl (tokenUrl, deviceCode, interval) {
|
|
|
16
16
|
logger.http(`POST ${tokenUrl} with deviceCode ${deviceCode} at interval ${interval}`)
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
|
-
const response = await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const response = await request(tokenUrl, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
client_id: OAUTH_CLIENT_ID,
|
|
26
|
+
device_code: deviceCode,
|
|
27
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code'
|
|
28
|
+
})
|
|
23
29
|
})
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
const responseData = await response.body.json()
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
spinner.start()
|
|
29
|
-
store.setToken(response.data.full_username, response.data.access_token)
|
|
30
|
-
store.setHostname(response.data.hostname)
|
|
31
|
-
spinner.succeed(`logged in as ${response.data.username}`)
|
|
32
|
-
process.exit(0)
|
|
33
|
-
} else {
|
|
34
|
-
// continue polling if no access_token. shouldn't ever get here it server is implemented correctly
|
|
35
|
-
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000)
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error.response && error.response.data) {
|
|
39
|
-
logger.http(error.response.data)
|
|
33
|
+
logger.http(responseData)
|
|
40
34
|
|
|
35
|
+
if (response.statusCode >= 400) {
|
|
41
36
|
// continue polling if authorization_pending
|
|
42
|
-
if (
|
|
37
|
+
if (responseData.error === 'authorization_pending') {
|
|
43
38
|
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000)
|
|
44
39
|
} else {
|
|
45
40
|
spinner.start()
|
|
46
|
-
spinner.fail(
|
|
41
|
+
spinner.fail(responseData.error_description)
|
|
47
42
|
process.exit(1)
|
|
48
43
|
}
|
|
49
|
-
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (responseData.access_token) {
|
|
50
47
|
spinner.start()
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
store.setToken(responseData.full_username, responseData.access_token)
|
|
49
|
+
store.setHostname(responseData.hostname)
|
|
50
|
+
spinner.succeed(`logged in as ${responseData.username}`)
|
|
51
|
+
process.exit(0)
|
|
52
|
+
} else {
|
|
53
|
+
// continue polling if no access_token. shouldn't ever get here it server is implemented correctly
|
|
54
|
+
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000)
|
|
53
55
|
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
spinner.start()
|
|
58
|
+
spinner.fail(error.toString())
|
|
59
|
+
process.exit(1)
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -63,14 +69,28 @@ async function login () {
|
|
|
63
69
|
const tokenUrl = `${hostname}/oauth/token`
|
|
64
70
|
|
|
65
71
|
try {
|
|
66
|
-
const response = await
|
|
67
|
-
|
|
72
|
+
const response = await request(deviceCodeUrl, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json'
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({ client_id: OAUTH_CLIENT_ID })
|
|
68
78
|
})
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
|
|
80
|
+
const responseData = await response.body.json()
|
|
81
|
+
|
|
82
|
+
if (response.statusCode >= 400) {
|
|
83
|
+
logger.http(responseData)
|
|
84
|
+
|
|
85
|
+
spinner.start()
|
|
86
|
+
spinner.fail(responseData.error_description)
|
|
87
|
+
process.exit(1)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const deviceCode = responseData.device_code
|
|
91
|
+
const userCode = responseData.user_code
|
|
92
|
+
const verificationUri = responseData.verification_uri
|
|
93
|
+
const interval = responseData.interval
|
|
74
94
|
|
|
75
95
|
try { clipboardy.writeSync(userCode) } catch (_e) {}
|
|
76
96
|
|
|
@@ -88,17 +108,9 @@ async function login () {
|
|
|
88
108
|
spinner.start()
|
|
89
109
|
}
|
|
90
110
|
} catch (error) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
spinner.start()
|
|
95
|
-
spinner.fail(error.response.data.error_description)
|
|
96
|
-
process.exit(1)
|
|
97
|
-
} else {
|
|
98
|
-
spinner.start()
|
|
99
|
-
spinner.fail(error.toString())
|
|
100
|
-
process.exit(1)
|
|
101
|
-
}
|
|
111
|
+
spinner.start()
|
|
112
|
+
spinner.fail(error.toString())
|
|
113
|
+
process.exit(1)
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const { execSync } = require('child_process')
|
|
3
|
-
const
|
|
3
|
+
const { request } = require('undici')
|
|
4
4
|
|
|
5
5
|
const store = require('./../../../shared/store')
|
|
6
6
|
const logger = require('./../../../shared/logger')
|
|
@@ -79,29 +79,32 @@ async function push () {
|
|
|
79
79
|
const usernameName = helpers.extractUsernameName(remoteOriginUrl)
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
DOTENV_KEYS: dotenvKeysContent,
|
|
85
|
-
DOTENV_VAULT: dotenvVaultContent
|
|
86
|
-
}
|
|
87
|
-
const options = {
|
|
82
|
+
const response = await request(pushUrl, {
|
|
83
|
+
method: 'POST',
|
|
88
84
|
headers: {
|
|
89
|
-
Authorization: `Bearer ${oauthToken}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
Authorization: `Bearer ${oauthToken}`,
|
|
86
|
+
'Content-Type': 'application/json'
|
|
87
|
+
},
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
username_name: usernameName,
|
|
90
|
+
DOTENV_KEYS: dotenvKeysContent,
|
|
91
|
+
DOTENV_VAULT: dotenvVaultContent
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const responseData = await response.body.json()
|
|
96
|
+
|
|
97
|
+
if (response.statusCode >= 400) {
|
|
98
|
+
logger.http(responseData)
|
|
99
|
+
spinner.fail(responseData.error.message)
|
|
100
|
+
if (response.statusCode === 404) {
|
|
98
101
|
logger.help(`? try visiting [${hostname}gh/${usernameName}] in your browser`)
|
|
99
102
|
}
|
|
100
103
|
process.exit(1)
|
|
101
|
-
} else {
|
|
102
|
-
spinner.fail(error.toString())
|
|
103
|
-
process.exit(1)
|
|
104
104
|
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
spinner.fail(error.toString())
|
|
107
|
+
process.exit(1)
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
spinner.succeed(`pushed [${usernameName}]`)
|