zmp-cli 3.13.0 → 3.14.0-rc.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { axiosClient } = require('../../utils/axios');
|
|
2
2
|
const config = require('../../config');
|
|
3
3
|
|
|
4
4
|
const requestUpload = async (url, appData, versionStatus, token) => {
|
|
@@ -15,7 +15,7 @@ const requestUpload = async (url, appData, versionStatus, token) => {
|
|
|
15
15
|
Authorization: `Bearer ${token}`,
|
|
16
16
|
'cache-control': 'no-cache',
|
|
17
17
|
};
|
|
18
|
-
const res = await
|
|
18
|
+
const res = await axiosClient.get(url, {
|
|
19
19
|
params,
|
|
20
20
|
headers,
|
|
21
21
|
withCredentials: true,
|
package/login/index.js
CHANGED
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const ora = require('ora');
|
|
5
5
|
const jwt = require('jsonwebtoken');
|
|
6
|
-
const axios = require('axios');
|
|
7
6
|
const qrcode = require('qrcode-terminal');
|
|
8
7
|
const logSymbols = require('log-symbols');
|
|
9
8
|
const config = require('../config');
|
|
10
9
|
const envUtils = require('../utils/env');
|
|
11
10
|
const log = require('../utils/log');
|
|
12
11
|
const zaloLogin = require('./utils/zalo-login');
|
|
13
|
-
|
|
14
|
-
const env = envUtils.getEnv('NODE_ENV') || 'production';
|
|
12
|
+
const { axiosClient } = require('../utils/axios');
|
|
15
13
|
|
|
16
14
|
const waitText = chalk.gray('Login...');
|
|
17
15
|
const spinner = ora(waitText);
|
|
@@ -34,7 +32,6 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
|
34
32
|
}
|
|
35
33
|
logger.statusStart(waitText);
|
|
36
34
|
spinner.start();
|
|
37
|
-
const cwd = options.cwd || process.cwd();
|
|
38
35
|
const loginMethod = options.loginMethod;
|
|
39
36
|
const appId = options.appId || envUtils.getEnv(config.env.appId);
|
|
40
37
|
const token = options.token;
|
|
@@ -125,7 +122,7 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
|
125
122
|
});
|
|
126
123
|
} else {
|
|
127
124
|
await new Promise((resolve, reject) => {
|
|
128
|
-
|
|
125
|
+
axiosClient({
|
|
129
126
|
method: 'get',
|
|
130
127
|
url: `${apiLogin}?accessToken=${token}&appId=${appId}`,
|
|
131
128
|
headers: {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
const envUtils = require('../../utils/env');
|
|
3
1
|
const config = require('../../config');
|
|
4
|
-
|
|
5
|
-
const env = envUtils.getEnv('NODE_ENV') || 'production';
|
|
2
|
+
const { axiosClient } = require('../../utils/axios');
|
|
6
3
|
|
|
7
4
|
module.exports = (function () {
|
|
8
5
|
const apiRequestLogin = `${config.api_domain}${config.path.requestLogin}`;
|
|
9
6
|
|
|
10
7
|
const apiCheckStatusLogin = `${config.api_domain}${config.path.checkLoginStatus}`;
|
|
11
8
|
const getQRCode = (appId) => {
|
|
12
|
-
return
|
|
9
|
+
return axiosClient({
|
|
13
10
|
method: 'get',
|
|
14
11
|
url: `${apiRequestLogin}?appId=${appId}`,
|
|
15
12
|
headers: {
|
|
@@ -19,7 +16,7 @@ module.exports = (function () {
|
|
|
19
16
|
});
|
|
20
17
|
};
|
|
21
18
|
const checkStatus = (zmpsk) => {
|
|
22
|
-
return
|
|
19
|
+
return axiosClient({
|
|
23
20
|
method: 'get',
|
|
24
21
|
url: `${apiCheckStatusLogin}?zmpsk=${zmpsk}`,
|
|
25
22
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zmp-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0-rc.0",
|
|
4
4
|
"description": "ZMP command line utility (CLI)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"opn": "^6.0.0",
|
|
78
78
|
"ora": "^3.4.0",
|
|
79
79
|
"prettier": "^2.2.1",
|
|
80
|
+
"proxy-agent": "^6.2.1",
|
|
80
81
|
"qrcode": "^1.4.4",
|
|
81
82
|
"qrcode-terminal": "^0.12.0",
|
|
82
83
|
"react-refresh": "^0.9.0",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const DomParser = require('dom-parser');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
const
|
|
3
|
+
const { axiosClient } = require('../utils/axios');
|
|
4
4
|
|
|
5
|
-
async function generateListResourcesFromIndex(
|
|
5
|
+
async function generateListResourcesFromIndex(
|
|
6
|
+
html,
|
|
7
|
+
{ outputDir, rootElement }
|
|
8
|
+
) {
|
|
6
9
|
const listCSS = [];
|
|
7
10
|
const listSyncJS = [];
|
|
8
11
|
const listAsyncJS = [];
|
|
@@ -27,7 +30,7 @@ async function generateListResourcesFromIndex(html, { outputDir, rootElement })
|
|
|
27
30
|
if (src.includes('://')) {
|
|
28
31
|
let filename = src.substring(src.lastIndexOf('/') + 1);
|
|
29
32
|
filename = `cdn.` + filename;
|
|
30
|
-
const response = await
|
|
33
|
+
const response = await axiosClient({
|
|
31
34
|
method: 'get',
|
|
32
35
|
url: src,
|
|
33
36
|
responseType: 'stream',
|
|
@@ -75,7 +78,7 @@ async function generateListResourcesFromIndex(html, { outputDir, rootElement })
|
|
|
75
78
|
if (href.includes('://')) {
|
|
76
79
|
filename = href.substring(href.lastIndexOf('/') + 1);
|
|
77
80
|
filename = `cdn.` + filename;
|
|
78
|
-
const response = await
|
|
81
|
+
const response = await axiosClient({
|
|
79
82
|
method: 'get',
|
|
80
83
|
url: href,
|
|
81
84
|
responseType: 'stream',
|
package/utils/axios.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { ProxyAgent } = require('proxy-agent');
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
|
|
4
|
+
const agent = new ProxyAgent();
|
|
5
|
+
|
|
6
|
+
const axiosClient = axios.create({
|
|
7
|
+
proxy: false,
|
|
8
|
+
httpsAgent: agent,
|
|
9
|
+
httpAgent: agent,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
agent,
|
|
14
|
+
axiosClient,
|
|
15
|
+
};
|
package/utils/get-app-info.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const axios = require('axios').default;
|
|
2
1
|
const config = require('../config');
|
|
3
2
|
const envUtils = require('../utils/env');
|
|
3
|
+
const { axiosClient } = require('./axios');
|
|
4
4
|
|
|
5
|
-
module.exports = async function (appId
|
|
5
|
+
module.exports = async function (appId) {
|
|
6
6
|
const url = `${config.api_domain}${config.path.getAppInfo}?appId=${appId}`;
|
|
7
7
|
const token = envUtils.getEnv(config.env.token);
|
|
8
|
-
const response = await
|
|
8
|
+
const response = await axiosClient.get(url, {
|
|
9
9
|
headers: {
|
|
10
10
|
'cache-control': 'no-cache',
|
|
11
11
|
Authorization: `Bearer ${token}`,
|
package/utils/resumable.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
const FileAPI = require('file-api');
|
|
2
2
|
const Blob = require('./node-blob');
|
|
3
3
|
const XMLHttpRequest = require('xhr2');
|
|
4
|
+
const { agent } = require('./axios');
|
|
5
|
+
|
|
6
|
+
XMLHttpRequest.nodejsSet({
|
|
7
|
+
httpAgent: agent,
|
|
8
|
+
httpsAgent: agent,
|
|
9
|
+
});
|
|
4
10
|
|
|
5
11
|
const File = FileAPI.File;
|
|
6
12
|
const FileList = FileAPI.FileList;
|