@vkontakte/vk-miniapps-deploy 0.1.9 → 0.2.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/.github/workflows/pull_request.yml +0 -2
- package/CHANGELOG.md +7 -0
- package/index.js +11 -3
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const prompt = require('prompts');
|
|
|
5
5
|
const nodeFetch = require('node-fetch');
|
|
6
6
|
const { zip } = require('zip-a-folder');
|
|
7
7
|
const fs = require('fs-extra');
|
|
8
|
+
const { HttpsProxyAgent } = require('https-proxy-agent');
|
|
8
9
|
const FormData = require('form-data');
|
|
9
10
|
const Configstore = require('configstore');
|
|
10
11
|
const vault = new Configstore(packageJson.name, {});
|
|
@@ -69,14 +70,21 @@ function getTraceId() {
|
|
|
69
70
|
return crypto.randomBytes(4).toString('hex');
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
function getProxyAgent() {
|
|
74
|
+
const proxy = cfg.proxy_url || process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
|
|
75
|
+
return proxy ? new HttpsProxyAgent(proxy) : undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
/**
|
|
73
79
|
* @param {nodeFetch.RequestInfo} url
|
|
74
80
|
* @param {nodeFetch.RequestInit} options
|
|
75
81
|
* @returns {Promise<nodeFetch.Response>}
|
|
76
82
|
*/
|
|
77
83
|
async function fetch(url, options) {
|
|
84
|
+
const fetchOptions = { ...options, agent: getProxyAgent() || options?.agent };
|
|
85
|
+
|
|
78
86
|
if (!DEBUG_MODE) {
|
|
79
|
-
return nodeFetch(url,
|
|
87
|
+
return nodeFetch(url, fetchOptions);
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
const traceId = chalk.hex(`#${((Math.random() * 0xffffff) << 0).toString(16)}`)(getTraceId());
|
|
@@ -85,9 +93,9 @@ async function fetch(url, options) {
|
|
|
85
93
|
|
|
86
94
|
try {
|
|
87
95
|
logLine(url, 'REQ');
|
|
88
|
-
options && logLine(JSON.stringify(
|
|
96
|
+
options && logLine(JSON.stringify(fetchOptions), 'REQ');
|
|
89
97
|
|
|
90
|
-
const response = await nodeFetch(url,
|
|
98
|
+
const response = await nodeFetch(url, fetchOptions);
|
|
91
99
|
const body = await response.clone().text();
|
|
92
100
|
|
|
93
101
|
logLine(`${response.status} ${response.statusText}`, 'RESP');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/vk-miniapps-deploy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Deploy to VK Mini Apps hosting with one simple command",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"configstore": "^5.0.0",
|
|
43
43
|
"form-data": "^3.0.0",
|
|
44
44
|
"fs-extra": "^8.0.1",
|
|
45
|
+
"https-proxy-agent": "^7.0.6",
|
|
45
46
|
"node-fetch": "^2.6.0",
|
|
46
47
|
"prompts": "^2.1.0",
|
|
47
48
|
"require-module": "^0.1.0",
|