@dotenvx/dotenvx
Advanced tools
Comparing version 0.15.1 to 0.15.2
{ | ||
"version": "0.15.1", | ||
"version": "0.15.2", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -29,3 +29,2 @@ "description": "a better dotenv–from the creator of `dotenv`", | ||
"@inquirer/prompts": "^3.3.0", | ||
"axios": "^1.6.2", | ||
"chalk": "^4.1.2", | ||
@@ -36,3 +35,3 @@ "clipboardy": "^2.3.0", | ||
"dotenv": "^16.4.2", | ||
"dotenv-expand": "^11.0.2", | ||
"dotenv-expand": "^11.0.3", | ||
"execa": "^5.1.1", | ||
@@ -42,2 +41,3 @@ "ignore": "^5.3.0", | ||
"ora": "^5.4.1", | ||
"undici": "^6.6.2", | ||
"update-notifier": "^5.1.0", | ||
@@ -44,0 +44,0 @@ "winston": "^3.11.0", |
const open = require('open') | ||
const axios = require('./../../../shared/axios') | ||
const { request } = require('undici') | ||
const clipboardy = require('clipboardy') | ||
@@ -19,37 +19,43 @@ const { confirm } = require('@inquirer/prompts') | ||
try { | ||
const response = await axios.post(tokenUrl, { | ||
client_id: OAUTH_CLIENT_ID, | ||
device_code: deviceCode, | ||
grant_type: 'urn:ietf:params:oauth:grant-type:device_code' | ||
const response = await request(tokenUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
client_id: OAUTH_CLIENT_ID, | ||
device_code: deviceCode, | ||
grant_type: 'urn:ietf:params:oauth:grant-type:device_code' | ||
}) | ||
}) | ||
logger.http(response.data) | ||
const responseData = await response.body.json() | ||
if (response.data.access_token) { | ||
spinner.start() | ||
store.setToken(response.data.full_username, response.data.access_token) | ||
store.setHostname(response.data.hostname) | ||
spinner.succeed(`logged in as ${response.data.username}`) | ||
process.exit(0) | ||
} else { | ||
// continue polling if no access_token. shouldn't ever get here it server is implemented correctly | ||
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000) | ||
} | ||
} catch (error) { | ||
if (error.response && error.response.data) { | ||
logger.http(error.response.data) | ||
logger.http(responseData) | ||
if (response.statusCode >= 400) { | ||
// continue polling if authorization_pending | ||
if (error.response.data.error === 'authorization_pending') { | ||
if (responseData.error === 'authorization_pending') { | ||
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000) | ||
} else { | ||
spinner.start() | ||
spinner.fail(error.response.data.error_description) | ||
spinner.fail(responseData.error_description) | ||
process.exit(1) | ||
} | ||
} | ||
if (responseData.access_token) { | ||
spinner.start() | ||
store.setToken(responseData.full_username, responseData.access_token) | ||
store.setHostname(responseData.hostname) | ||
spinner.succeed(`logged in as ${responseData.username}`) | ||
process.exit(0) | ||
} else { | ||
spinner.start() | ||
spinner.fail(error) | ||
process.exit(1) | ||
// continue polling if no access_token. shouldn't ever get here it server is implemented correctly | ||
setTimeout(() => pollTokenUrl(tokenUrl, deviceCode, interval), interval * 1000) | ||
} | ||
} catch (error) { | ||
spinner.start() | ||
spinner.fail(error.toString()) | ||
process.exit(1) | ||
} | ||
@@ -67,11 +73,25 @@ } | ||
try { | ||
const response = await axios.post(deviceCodeUrl, { | ||
client_id: OAUTH_CLIENT_ID | ||
const response = await request(deviceCodeUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ client_id: OAUTH_CLIENT_ID }) | ||
}) | ||
const data = response.data | ||
const deviceCode = data.device_code | ||
const userCode = data.user_code | ||
const verificationUri = data.verification_uri | ||
const interval = data.interval | ||
const responseData = await response.body.json() | ||
if (response.statusCode >= 400) { | ||
logger.http(responseData) | ||
spinner.start() | ||
spinner.fail(responseData.error_description) | ||
process.exit(1) | ||
} | ||
const deviceCode = responseData.device_code | ||
const userCode = responseData.user_code | ||
const verificationUri = responseData.verification_uri | ||
const interval = responseData.interval | ||
try { clipboardy.writeSync(userCode) } catch (_e) {} | ||
@@ -93,13 +113,5 @@ | ||
} catch (error) { | ||
if (error.response && error.response.data) { | ||
logger.http(error.response.data) | ||
spinner.start() | ||
spinner.fail(error.response.data.error_description) | ||
process.exit(1) | ||
} else { | ||
spinner.start() | ||
spinner.fail(error.toString()) | ||
process.exit(1) | ||
} | ||
spinner.start() | ||
spinner.fail(error.toString()) | ||
process.exit(1) | ||
} | ||
@@ -106,0 +118,0 @@ } |
const fs = require('fs') | ||
const { execSync } = require('child_process') | ||
const axios = require('./../../../shared/axios') | ||
const { request } = require('undici') | ||
@@ -82,25 +82,28 @@ const store = require('./../../../shared/store') | ||
try { | ||
const postData = { | ||
username_name: usernameName, | ||
DOTENV_KEYS: dotenvKeysContent, | ||
DOTENV_VAULT: dotenvVaultContent | ||
} | ||
const options = { | ||
const response = await request(pushUrl, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: `Bearer ${oauthToken}` | ||
} | ||
} | ||
await axios.post(pushUrl, postData, options) | ||
} catch (error) { | ||
if (error.response && error.response.data) { | ||
logger.http(error.response.data) | ||
spinner.fail(error.response.data.error.message) | ||
if (error.response.status === 404) { | ||
Authorization: `Bearer ${oauthToken}`, | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
username_name: usernameName, | ||
DOTENV_KEYS: dotenvKeysContent, | ||
DOTENV_VAULT: dotenvVaultContent | ||
}) | ||
}) | ||
const responseData = await response.body.json() | ||
if (response.statusCode >= 400) { | ||
logger.http(responseData) | ||
spinner.fail(responseData.error.message) | ||
if (response.statusCode === 404) { | ||
logger.help(`? try visiting [${hostname}gh/${usernameName}] in your browser`) | ||
} | ||
process.exit(1) | ||
} else { | ||
spinner.fail(error.toString()) | ||
process.exit(1) | ||
} | ||
} catch (error) { | ||
spinner.fail(error.toString()) | ||
process.exit(1) | ||
} | ||
@@ -107,0 +110,0 @@ |
70797
1511
24
+ Addedundici@^6.6.2
+ Addedundici@6.21.1(transitive)
- Removedaxios@^1.6.2
- Removedasynckit@0.4.0(transitive)
- Removedaxios@1.7.9(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedproxy-from-env@1.1.0(transitive)
Updateddotenv-expand@^11.0.3