zmp-cli 3.15.6 → 3.15.7
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/README.md +1 -0
- package/build/index.js +1 -184
- package/config/index.js +1 -44
- package/create/index.js +1 -230
- package/create/init-zmp-ui.js +1 -216
- package/create/templates/app-parameters.js +9 -25
- package/create/templates/common/webpack/build.js +2 -40
- package/create/templates/copy-assets.js +1 -158
- package/create/templates/core/copy-assets.js +14 -82
- package/create/templates/core/generate-home-page.js +16 -38
- package/create/templates/core/generate-root.js +28 -63
- package/create/templates/core/generate-routes.js +12 -38
- package/create/templates/core/generate-scripts.js +16 -65
- package/create/templates/create-folders.js +1 -30
- package/create/templates/generate-config-xml.js +2 -9
- package/create/templates/generate-index.js +10 -35
- package/create/templates/generate-manifest.js +1 -49
- package/create/templates/generate-recoil.js +4 -16
- package/create/templates/generate-routes.js +1 -16
- package/create/templates/generate-scripts.js +1 -16
- package/create/templates/generate-service-worker.js +4 -10
- package/create/templates/generate-store.js +4 -15
- package/create/templates/generate-styles.js +10 -64
- package/create/templates/generate-webpack-config.js +43 -125
- package/create/templates/generate-zmp-custom.js +14 -72
- package/create/templates/react/copy-assets.js +1 -85
- package/create/templates/react/generate-home-page.js +20 -50
- package/create/templates/react/generate-root.js +15 -44
- package/create/templates/react/generate-routes.js +1 -16
- package/create/templates/react/generate-scripts.js +12 -38
- package/create/templates/react/pages/404.js +2 -10
- package/create/templates/react/pages/about.js +2 -10
- package/create/templates/react/pages/catalog.js +3 -17
- package/create/templates/react/pages/dynamic-route.js +2 -10
- package/create/templates/react/pages/form.js +6 -26
- package/create/templates/react/pages/index copy.js +1 -17
- package/create/templates/react/pages/index.js +1 -17
- package/create/templates/react/pages/settings.js +3 -17
- package/create/templates/react/pages/user.js +8 -27
- package/create/templates/react-typescript/components/app-items.js +2 -9
- package/create/templates/react-typescript/components/index.js +1 -9
- package/create/templates/react-typescript/components/navbar-back.js +2 -9
- package/create/templates/react-typescript/components/user-card.js +2 -9
- package/create/templates/react-typescript/copy-assets.js +1 -94
- package/create/templates/react-typescript/generate-home-page.js +20 -52
- package/create/templates/react-typescript/generate-root.js +14 -45
- package/create/templates/react-typescript/generate-routes.js +1 -12
- package/create/templates/react-typescript/generate-scripts.js +12 -37
- package/create/templates/react-typescript/pages/404.js +2 -10
- package/create/templates/react-typescript/pages/about.js +2 -10
- package/create/templates/react-typescript/pages/catalog.js +3 -17
- package/create/templates/react-typescript/pages/dynamic-route.js +2 -10
- package/create/templates/react-typescript/pages/form.js +6 -26
- package/create/templates/react-typescript/pages/index.js +1 -17
- package/create/templates/react-typescript/pages/settings.js +3 -17
- package/create/templates/react-typescript/pages/user.js +8 -27
- package/create/templates/svelte/copy-assets.js +1 -47
- package/create/templates/svelte/generate-home-page.js +20 -56
- package/create/templates/svelte/generate-root.js +22 -80
- package/create/templates/svelte/generate-routes.js +7 -22
- package/create/templates/svelte/generate-scripts.js +7 -23
- package/create/templates/vue/copy-assets.js +1 -67
- package/create/templates/vue/generate-home-page.js +2 -8
- package/create/templates/vue/generate-root.js +3 -13
- package/create/templates/vue/generate-routes.js +1 -7
- package/create/templates/vue/generate-scripts.js +9 -26
- package/create/templates/vue/global-components.d.js +1 -0
- package/create/templates/zaui/copy-assets.js +1 -90
- package/create/templates/zaui/generate-home-page.js +27 -53
- package/create/templates/zaui/generate-root.js +14 -34
- package/create/templates/zaui/generate-routes.js +1 -10
- package/create/templates/zaui/generate-scripts.js +6 -20
- package/create/templates/zaui/generate-user-card.js +3 -18
- package/create/templates/zaui/pages/about.js +3 -20
- package/create/templates/zaui/pages/form.js +3 -20
- package/create/templates/zaui/pages/index.js +1 -9
- package/create/templates/zaui/pages/user.js +3 -20
- package/create/utils/colors.js +1 -94
- package/create/utils/generate-app-config.js +1 -34
- package/create/utils/generate-gitignore.js +1 -43
- package/create/utils/generate-npm-scripts.js +1 -26
- package/create/utils/generate-package-json.js +1 -132
- package/create/utils/generate-readme.js +1 -28
- package/create/utils/get-options.js +1 -204
- package/create/utils/indent.js +1 -31
- package/create/utils/npm-scripts.js +1 -62
- package/create/utils/string.js +1 -13
- package/create/utils/styles-extension.js +1 -9
- package/create/utils/template-if.js +1 -9
- package/deploy/index.js +1 -149
- package/deploy/utils/get-options.js +1 -69
- package/deploy/utils/request-upload.js +1 -34
- package/deploy/utils/upload-app.js +1 -82
- package/index.js +1 -319
- package/login/index.js +1 -169
- package/login/utils/get-options.js +1 -58
- package/login/utils/zalo-login.js +1 -32
- package/migrate/icons/update-icon-v3.js +1 -19
- package/migrate/index.js +1 -60
- package/migrate/utils/get-options.js +1 -46
- package/migrate/utils/migrate-react.js +1 -33
- package/package.json +11 -39
- package/start/generate-hr-config.js +1 -59
- package/start/index.js +1 -382
- package/sync/index-to-app-config.js +1 -146
- package/sync/index.js +1 -55
- package/utils/axios.js +1 -15
- package/utils/check-update.js +1 -53
- package/utils/constants.js +1 -20
- package/utils/env.js +1 -39
- package/utils/error.js +1 -16
- package/utils/find-files-by-ext.js +1 -27
- package/utils/find-free-port.js +1 -11
- package/utils/fs-extra.js +1 -90
- package/utils/generate-pages-map.js +1 -17
- package/utils/get-app-info.js +1 -22
- package/utils/get-current-project.js +1 -25
- package/utils/get-ip.js +1 -19
- package/utils/log.js +1 -19
- package/utils/node-blob.js +1 -106
- package/utils/resumable.d.js +1 -0
- package/utils/resumable.js +1 -1204
- package/utils/spinner.js +1 -25
- package/utils/tunnel.js +1 -36
- package/.editorconfig +0 -15
- package/.eslintignore +0 -8
- package/.eslintrc.js +0 -10
- package/.vscode/launch.json +0 -23
- package/LICENSE +0 -21
- package/README.git.md +0 -37
- package/assets/index.js +0 -147
- package/build/dist/index.dev.js +0 -217
- package/config/dist/index.dev.js +0 -48
- package/create/templates/dist/generate-styles.dev.js +0 -46
- package/create/templates/react/dist/generate-scripts.dev.js +0 -23
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +0 -23
- package/create/utils/dist/get-options.dev.js +0 -277
- package/deploy/dist/index.dev.js +0 -227
- package/deploy/utils/dist/request-upload.dev.js +0 -62
- package/deploy/utils/dist/upload-app.dev.js +0 -113
- package/dist/bundle.js +0 -1
- package/dist/index.dev.js +0 -352
- package/jsconfig.json +0 -8
- package/login/dist/index.dev.js +0 -223
- package/login/utils/dist/zalo-login.dev.js +0 -41
- package/screenshots/wellcome.jpg +0 -0
- package/show-qr-app/assets/css/style.css +0 -87
- package/show-qr-app/assets/js/qrcode.min.js +0 -1
- package/show-qr-app/index.html +0 -57
- package/show-qr-app/package.json +0 -14
- package/start/dist/index.dev.js +0 -312
- package/ui/server.js +0 -194
- package/ui/www/css/app.css +0 -1
- package/ui/www/css/app.css.map +0 -1
- package/ui/www/fonts/ZMPIcons-Regular.eot +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.ttf +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff2 +0 -0
- package/ui/www/images/logo.png +0 -0
- package/ui/www/index.html +0 -1
- package/ui/www/js/app.js +0 -3
- package/ui/www/js/app.js.LICENSE.txt +0 -20
- package/ui/www/js/app.js.map +0 -1
- package/ui/www/static/icons/apple-touch-icon.png +0 -0
- package/ui/www/static/icons/favicon.png +0 -0
- package/utils/dist/get-app-info.dev.js +0 -54
package/start/index.js
CHANGED
|
@@ -1,382 +1 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint no-console: off */
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const ora = require('ora');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const qrcode = require('qrcode-terminal');
|
|
7
|
-
const logSymbols = require('log-symbols');
|
|
8
|
-
const { createServer } = require('vite');
|
|
9
|
-
const chii = require('chii');
|
|
10
|
-
const { hri } = require('human-readable-ids');
|
|
11
|
-
|
|
12
|
-
const config = require('../config');
|
|
13
|
-
const envUtils = require('../utils/env');
|
|
14
|
-
const fs = require('../utils/fs-extra');
|
|
15
|
-
const fse = require('../utils/fs-extra');
|
|
16
|
-
const findFreePort = require('../utils/find-free-port');
|
|
17
|
-
const { openTunnel } = require('../utils/tunnel');
|
|
18
|
-
const { deviceModeSetup } = require('../utils/constants');
|
|
19
|
-
const { generateHrFromIndex } = require('./generate-hr-config');
|
|
20
|
-
|
|
21
|
-
const spinner = ora('Starting mini app...');
|
|
22
|
-
|
|
23
|
-
module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
24
|
-
function errorExit(err) {
|
|
25
|
-
logger.error(err.stderr || err);
|
|
26
|
-
if (exitOnError) process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
if (!logger) {
|
|
29
|
-
// eslint-disable-next-line
|
|
30
|
-
logger = {
|
|
31
|
-
statusStart() {},
|
|
32
|
-
statusDone() {},
|
|
33
|
-
statusError() {},
|
|
34
|
-
text() {},
|
|
35
|
-
error() {},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
spinner.start();
|
|
39
|
-
const cwd = options.cwd || process.cwd();
|
|
40
|
-
const appId = options.appId || envUtils.getEnv(config.env.appId);
|
|
41
|
-
const previewOnZalo = options.previewOnZalo;
|
|
42
|
-
const isIOS = options.ios;
|
|
43
|
-
const iosHostName = options.iosHostName;
|
|
44
|
-
const usingFrame = options.frame;
|
|
45
|
-
const host = isIOS ? iosHostName : 'localhost';
|
|
46
|
-
const port = options.port;
|
|
47
|
-
const remoteDebugPort = port - 2;
|
|
48
|
-
const mode = options.mode || (previewOnZalo ? 'production' : 'development');
|
|
49
|
-
const deviceMode = options.deviceMode;
|
|
50
|
-
try {
|
|
51
|
-
if (previewOnZalo) {
|
|
52
|
-
const hrConfigPath = path.join(cwd, 'hr.config.json');
|
|
53
|
-
const remoteDebugScript = {
|
|
54
|
-
id: 'remote-debug-script',
|
|
55
|
-
innerHTML: `(function () { var script = document.createElement('script'); script.src='http://${host}:${remoteDebugPort}/target.js'; document.body.appendChild(script); })()`,
|
|
56
|
-
type: 'text/javascript',
|
|
57
|
-
};
|
|
58
|
-
if (!fs.existsSync(hrConfigPath)) {
|
|
59
|
-
const hrConfig = {
|
|
60
|
-
listCSS: [],
|
|
61
|
-
listJS: [
|
|
62
|
-
{
|
|
63
|
-
src: '/src/app.js',
|
|
64
|
-
type: 'module',
|
|
65
|
-
async: true,
|
|
66
|
-
},
|
|
67
|
-
remoteDebugScript,
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
fs.writeFileSync(hrConfigPath, JSON.stringify(hrConfig, undefined, 4));
|
|
71
|
-
} else {
|
|
72
|
-
const fileData = fs.readFileSync(hrConfigPath);
|
|
73
|
-
const hrConfig = JSON.parse(fileData);
|
|
74
|
-
|
|
75
|
-
let listJS = hrConfig.listJS;
|
|
76
|
-
if (!Array.isArray(listJS)) {
|
|
77
|
-
listJS = [];
|
|
78
|
-
}
|
|
79
|
-
const remoteDebugScriptIndex = listJS.findIndex(
|
|
80
|
-
(js) => js.id === 'remote-debug-script'
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
if (remoteDebugScriptIndex <= 0) {
|
|
84
|
-
listJS.push(remoteDebugScript);
|
|
85
|
-
} else {
|
|
86
|
-
listJS.splice(remoteDebugScriptIndex, 1);
|
|
87
|
-
listJS.push(remoteDebugScript);
|
|
88
|
-
}
|
|
89
|
-
hrConfig.listJS = listJS;
|
|
90
|
-
fs.writeFileSync(hrConfigPath, JSON.stringify(hrConfig, undefined, 4));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const localServer = {};
|
|
94
|
-
|
|
95
|
-
const publicServer = {
|
|
96
|
-
host: '0.0.0.0',
|
|
97
|
-
hmr: {
|
|
98
|
-
host: host,
|
|
99
|
-
protocol: 'ws',
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
let viteConfig = 'vite.config.js';
|
|
104
|
-
const isTypeScriptProject = fse.existsSync(
|
|
105
|
-
path.join(cwd, 'vite.config.ts')
|
|
106
|
-
);
|
|
107
|
-
if (isTypeScriptProject) {
|
|
108
|
-
viteConfig = 'vite.config.ts';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let server;
|
|
112
|
-
let subdomain;
|
|
113
|
-
let freePort;
|
|
114
|
-
if (deviceMode) {
|
|
115
|
-
// generate a subdomain for the tunnel
|
|
116
|
-
subdomain = hri.random();
|
|
117
|
-
// start the chii server
|
|
118
|
-
freePort = await findFreePort();
|
|
119
|
-
chii.start({
|
|
120
|
-
port: freePort,
|
|
121
|
-
});
|
|
122
|
-
// expose the chii server by using localtunnel
|
|
123
|
-
const chiiUrl = await openTunnel(freePort);
|
|
124
|
-
const remoteHost = `${subdomain}.${deviceModeSetup.TUNNEL_SERVER_HOST}`;
|
|
125
|
-
|
|
126
|
-
server = await createServer({
|
|
127
|
-
configFile: path.join(cwd, viteConfig),
|
|
128
|
-
root: cwd,
|
|
129
|
-
mode,
|
|
130
|
-
define: {
|
|
131
|
-
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
132
|
-
'process.env.previewOnZalo': true,
|
|
133
|
-
},
|
|
134
|
-
server: {
|
|
135
|
-
port: port,
|
|
136
|
-
host: 'localhost',
|
|
137
|
-
origin: `https://${remoteHost}`,
|
|
138
|
-
base: `/zapps/${appId}/`,
|
|
139
|
-
hmr: {
|
|
140
|
-
host: remoteHost,
|
|
141
|
-
clientPort: 443,
|
|
142
|
-
protocol: 'wss',
|
|
143
|
-
},
|
|
144
|
-
https: false,
|
|
145
|
-
},
|
|
146
|
-
plugins: [
|
|
147
|
-
{
|
|
148
|
-
name: 'hr-config-plugin',
|
|
149
|
-
configureServer(server) {
|
|
150
|
-
const setupCors = (req, res) => {
|
|
151
|
-
if (
|
|
152
|
-
['https://h5.zdn.vn', 'zbrowser://h5.zdn.vn'].includes(
|
|
153
|
-
req.headers.origin
|
|
154
|
-
)
|
|
155
|
-
) {
|
|
156
|
-
res.setHeader(
|
|
157
|
-
'Access-Control-Allow-Origin',
|
|
158
|
-
req.headers.origin
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
server.middlewares.use('/app-config.json', (req, res, next) => {
|
|
163
|
-
// there would be another originalUrl - app-config.json?module that would be dynamicly imported in js format
|
|
164
|
-
if (req.originalUrl === '/app-config.json') {
|
|
165
|
-
res.setHeader('Content-Type', 'application/javascript');
|
|
166
|
-
setupCors(req, res);
|
|
167
|
-
return res.end(
|
|
168
|
-
fs.readFileSync(path.join(cwd, 'app-config.json'))
|
|
169
|
-
);
|
|
170
|
-
} else {
|
|
171
|
-
return next();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
server.middlewares.use('/hr.config.json', async (req, res) => {
|
|
175
|
-
res.setHeader('Content-Type', 'application/json');
|
|
176
|
-
setupCors(req, res);
|
|
177
|
-
const hrConfig = await generateHrFromIndex(
|
|
178
|
-
`http://localhost:${app.httpServer.address().port}`,
|
|
179
|
-
{
|
|
180
|
-
chiiUrl,
|
|
181
|
-
exposedUrl: `https://${subdomain}.${deviceModeSetup.TUNNEL_SERVER_HOST}`,
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
res.end(JSON.stringify(hrConfig));
|
|
185
|
-
});
|
|
186
|
-
server.middlewares.use('/studio.module.js', async (req, res) => {
|
|
187
|
-
res.setHeader('Content-Type', 'text/javascript');
|
|
188
|
-
setupCors(req, res);
|
|
189
|
-
res.end(`
|
|
190
|
-
import { createHotContext } from "/@vite/client";
|
|
191
|
-
import.meta.hot = createHotContext("${subdomain}");
|
|
192
|
-
if (import.meta.hot) {
|
|
193
|
-
import.meta.hot.on("vite:beforeFullReload", () => {
|
|
194
|
-
window.location.href = window.BACKUP_URL;
|
|
195
|
-
ZJSBridge.callCustomAction("action.ma.menu.reload", {}, () => {});
|
|
196
|
-
throw "(skipping full reload)";
|
|
197
|
-
});
|
|
198
|
-
import.meta.hot.on('zmp:close', (data) => {
|
|
199
|
-
ZJSBridge.callCustomAction("action.window.close", {}, () => {});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
let shownTip = false;
|
|
204
|
-
window.onerror = function (message, url, line, column, error) {
|
|
205
|
-
if (!error) {
|
|
206
|
-
console.error(
|
|
207
|
-
"An uncaught error has occurred, but the detailed error message cannot be displayed due to the cross-origin policy."
|
|
208
|
-
);
|
|
209
|
-
if (!shownTip) {
|
|
210
|
-
console.warn(
|
|
211
|
-
"To view the detailed error message, you can try one of the following methods:\\n\\n1. Wrap your code in a try-catch block, use .catch with Promises, or use <ErrorBoundary> in React to catch the detailed error object.\\n2. Try to reproduce the issue using a simulator."
|
|
212
|
-
);
|
|
213
|
-
shownTip = true;
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
console.error("[" + error.name + "] " + error.message);
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
} catch (error) {
|
|
220
|
-
console.error(error);
|
|
221
|
-
}
|
|
222
|
-
`);
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
} else {
|
|
229
|
-
server = await createServer({
|
|
230
|
-
configFile: path.join(cwd, viteConfig),
|
|
231
|
-
root: cwd,
|
|
232
|
-
mode,
|
|
233
|
-
define: {
|
|
234
|
-
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
235
|
-
'process.env.previewOnZalo': previewOnZalo,
|
|
236
|
-
},
|
|
237
|
-
server: {
|
|
238
|
-
port: usingFrame ? port - 1 : port,
|
|
239
|
-
...(previewOnZalo ? publicServer : localServer),
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
const app = await server.listen();
|
|
244
|
-
|
|
245
|
-
if (!previewOnZalo) {
|
|
246
|
-
if (!deviceMode) {
|
|
247
|
-
if (usingFrame) {
|
|
248
|
-
//run frame server
|
|
249
|
-
const serverFrame = await createServer({
|
|
250
|
-
// any valid user config options, plus `mode` and `configFile`
|
|
251
|
-
configFile: false,
|
|
252
|
-
root: __dirname + '/frame',
|
|
253
|
-
server: {
|
|
254
|
-
port: app.httpServer.address().port + 1,
|
|
255
|
-
strictPort: true,
|
|
256
|
-
open: true,
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
spinner.stop();
|
|
260
|
-
await serverFrame.listen();
|
|
261
|
-
const info = serverFrame.config.logger.info;
|
|
262
|
-
info(chalk.green(`Zalo Mini App dev server is running at:\n`));
|
|
263
|
-
serverFrame.printUrls();
|
|
264
|
-
} else {
|
|
265
|
-
spinner.stop();
|
|
266
|
-
const info = server.config.logger.info;
|
|
267
|
-
info(chalk.green(`Zalo Mini App dev server is running at:\n`));
|
|
268
|
-
server.printUrls();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
try {
|
|
273
|
-
chii.start({
|
|
274
|
-
port: remoteDebugPort,
|
|
275
|
-
});
|
|
276
|
-
logger.text(
|
|
277
|
-
chalk.green(
|
|
278
|
-
`${logSymbols.info} ${chalk.bold(
|
|
279
|
-
`Remote debugging tool is running at: http://localhost:${remoteDebugPort}`
|
|
280
|
-
)}`
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
if (!isIOS) {
|
|
284
|
-
const processAdbReverseRemoteDEbug = require('child_process').spawn(
|
|
285
|
-
`adb`,
|
|
286
|
-
['reverse', `tcp:${remoteDebugPort}`, `tcp:${remoteDebugPort}`]
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
processAdbReverseRemoteDEbug.stderr.on('data', function (data) {
|
|
290
|
-
logger.error(data.toString());
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
} catch (error) {
|
|
294
|
-
logger.text(
|
|
295
|
-
`${logSymbols.info} ${chalk.red(`Can not start remote debug server`)}`
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
spinner.stop();
|
|
301
|
-
return await new Promise(async () => {
|
|
302
|
-
if (previewOnZalo) {
|
|
303
|
-
const previewOnZaloURL = `https://zalo.me/app/link/zapps/${appId}/?env=TESTING_LOCAL&clientIp=http://${host}:${app.config.server.port}`;
|
|
304
|
-
qrcode.generate(previewOnZaloURL, { small: true }, function (qrcode) {
|
|
305
|
-
logger.text(
|
|
306
|
-
chalk.green(
|
|
307
|
-
`${logSymbols.info} ${chalk.bold(
|
|
308
|
-
`Zalo Mini App dev server is running at: ${host}:${app.config.server.port}`
|
|
309
|
-
)}`
|
|
310
|
-
)
|
|
311
|
-
);
|
|
312
|
-
logger.text(
|
|
313
|
-
chalk.green(
|
|
314
|
-
`${logSymbols.info} ${chalk.bold(
|
|
315
|
-
`Trying reverse socket connection`
|
|
316
|
-
)}`
|
|
317
|
-
)
|
|
318
|
-
);
|
|
319
|
-
if (isIOS) {
|
|
320
|
-
const qrCode = `${logSymbols.info} ${chalk.bold(
|
|
321
|
-
`Scan the QR code with Zalo app:\n${qrcode}`
|
|
322
|
-
)}`;
|
|
323
|
-
logger.text(qrCode);
|
|
324
|
-
} else {
|
|
325
|
-
const processAdbReverse = require('child_process').spawn(`adb`, [
|
|
326
|
-
'reverse',
|
|
327
|
-
`tcp:${app.config.server.port}`,
|
|
328
|
-
`tcp:${app.config.server.port}`,
|
|
329
|
-
]);
|
|
330
|
-
|
|
331
|
-
processAdbReverse.stderr.on('data', function (data) {
|
|
332
|
-
logger.error(data.toString());
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
processAdbReverse.on('exit', function (code) {
|
|
336
|
-
if (code !== 0) {
|
|
337
|
-
throw new Error(`adb reverse error: ${code}`);
|
|
338
|
-
} else {
|
|
339
|
-
const qrCode = `${logSymbols.info} ${chalk.bold(
|
|
340
|
-
`Scan the QR code with Zalo app:\n${qrcode}`
|
|
341
|
-
)}`;
|
|
342
|
-
logger.text(qrCode);
|
|
343
|
-
const processAdbDevices = require('child_process').spawn(
|
|
344
|
-
`adb`,
|
|
345
|
-
['devices']
|
|
346
|
-
);
|
|
347
|
-
|
|
348
|
-
processAdbDevices.stdout.on('data', function (data) {
|
|
349
|
-
logger.text(`${chalk.yellow(data.toString())}`);
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
if (deviceMode) {
|
|
357
|
-
const port = app.httpServer.address().port;
|
|
358
|
-
const remoteUrl = await openTunnel(port, subdomain);
|
|
359
|
-
const deviceModeUrl = `https://zalo.me/app/link/zapps/${appId}/?env=TESTING_LOCAL&clientIp=${remoteUrl}`;
|
|
360
|
-
qrcode.generate(deviceModeUrl, { small: true }, function (qrcode) {
|
|
361
|
-
const qrCode = `${logSymbols.info} ${chalk.bold(
|
|
362
|
-
`Scan the QR code with Zalo app:\n${qrcode}`
|
|
363
|
-
)}`;
|
|
364
|
-
logger.text(qrCode);
|
|
365
|
-
logger.text(
|
|
366
|
-
`${logSymbols.info} ${chalk.bold(
|
|
367
|
-
`To inspect your app, open: http://localhost:${freePort} in ${chalk.green(
|
|
368
|
-
`Google Chrome`
|
|
369
|
-
)} or a ${chalk.blue(`Chromium-based`)} browser.`
|
|
370
|
-
)}`
|
|
371
|
-
);
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
} catch (err) {
|
|
376
|
-
logger.statusError('Error starting project');
|
|
377
|
-
// if (err) logger.error(err.stderr || err);
|
|
378
|
-
logger.error(err);
|
|
379
|
-
errorExit(err);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
};
|
|
1
|
+
'use strict';const _0x54c847=_0x573a;(function(_0x4f442c,_0xa7f2eb){const _0x1f27f8=_0x573a,_0x5df9b2=_0x4f442c();while(!![]){try{const _0x4d3c5c=-parseInt(_0x1f27f8(0x1ea))/0x1*(parseInt(_0x1f27f8(0x1cb))/0x2)+-parseInt(_0x1f27f8(0x1f8))/0x3+parseInt(_0x1f27f8(0x1d0))/0x4*(parseInt(_0x1f27f8(0x1b4))/0x5)+-parseInt(_0x1f27f8(0x1b7))/0x6+-parseInt(_0x1f27f8(0x1a9))/0x7+-parseInt(_0x1f27f8(0x20e))/0x8*(parseInt(_0x1f27f8(0x1b0))/0x9)+parseInt(_0x1f27f8(0x1ae))/0xa;if(_0x4d3c5c===_0xa7f2eb)break;else _0x5df9b2['push'](_0x5df9b2['shift']());}catch(_0x4d50b0){_0x5df9b2['push'](_0x5df9b2['shift']());}}}(_0x3078,0x246be));function _0x573a(_0x3d1c13,_0x1d6c25){const _0x3078b8=_0x3078();return _0x573a=function(_0x573a0b,_0x2c9648){_0x573a0b=_0x573a0b-0x1a6;let _0x1626df=_0x3078b8[_0x573a0b];return _0x1626df;},_0x573a(_0x3d1c13,_0x1d6c25);}const e=require(_0x54c847(0x1c8)),r=require('ora'),t=require(_0x54c847(0x1f2)),o=require(_0x54c847(0x216)),i=require(_0x54c847(0x204)),{createServer:n}=require(_0x54c847(0x1a7)),s=require('chii'),{hri:a}=require('human-readable-ids'),l=require(_0x54c847(0x1e9)),c=require(_0x54c847(0x1e1)),p=require('../utils/fs-extra'),d=require('../utils/fs-extra'),u=require(_0x54c847(0x212)),{openTunnel:g}=require(_0x54c847(0x1f1)),{deviceModeSetup:h}=require(_0x54c847(0x1ce)),{generateHrFromIndex:f}=require(_0x54c847(0x1d4)),m=r(_0x54c847(0x1ff));function _0x3078(){const _0x4220e5=['chalk','stop','isArray','90TszFFh','exit','devices','../utils/constants','reverse','8NDTQFt','random','yellow','/hr.config.json','./generate-hr-config','application/javascript','getEnv','localhost','deviceMode','listen','module','start','port','middlewares','spawn','stderr','server','../utils/env','text/javascript','setHeader','remote-debug-script','includes','readFileSync','/frame','httpServer','../config','2791lhvmYr','address','Trying\x20reverse\x20socket\x20connection','stringify','use','Access-Control-Allow-Origin','Can\x20not\x20start\x20remote\x20debug\x20server','../utils/tunnel','path','iosHostName','listJS','production','text','Scan\x20the\x20QR\x20code\x20with\x20Zalo\x20app:\x0a','817503AatXEk','vite.config.ts','end','logger','config','error','generate','Starting\x20mini\x20app...','/app-config.json','adb\x20reverse\x20error:\x20','wss','\x20browser.','log-symbols','join','\x22);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(import.meta.hot)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20import.meta.hot.on(\x22vite:beforeFullReload\x22,\x20()\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20window.location.href\x20=\x20window.BACKUP_URL;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ZJSBridge.callCustomAction(\x22action.ma.menu.reload\x22,\x20{},\x20()\x20=>\x20{});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20throw\x20\x22(skipping\x20full\x20reload)\x22;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20import.meta.hot.on(\x27zmp:close\x27,\x20(data)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ZJSBridge.callCustomAction(\x22action.window.close\x22,\x20{},\x20()\x20=>\x20{});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20try\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20let\x20shownTip\x20=\x20false;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20window.onerror\x20=\x20function\x20(message,\x20url,\x20line,\x20column,\x20error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20console.error(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x22An\x20uncaught\x20error\x20has\x20occurred,\x20but\x20the\x20detailed\x20error\x20message\x20cannot\x20be\x20displayed\x20due\x20to\x20the\x20cross-origin\x20policy.\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!shownTip)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20console.warn(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x22To\x20view\x20the\x20detailed\x20error\x20message,\x20you\x20can\x20try\x20one\x20of\x20the\x20following\x20methods:\x5cn\x5cn1.\x20Wrap\x20your\x20code\x20in\x20a\x20try-catch\x20block,\x20use\x20.catch\x20with\x20Promises,\x20or\x20use\x20<ErrorBoundary>\x20in\x20React\x20to\x20catch\x20the\x20detailed\x20error\x20object.\x5cn2.\x20Try\x20to\x20reproduce\x20the\x20issue\x20using\x20a\x20simulator.\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20shownTip\x20=\x20true;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20console.error(\x22[\x22\x20+\x20error.name\x20+\x20\x22]\x20\x22\x20+\x20error.message);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20};\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20catch\x20(error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20console.error(error);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Error\x20starting\x20project','Chromium-based','/?env=TESTING_LOCAL&clientIp=','app-config.json','printUrls','Zalo\x20Mini\x20App\x20dev\x20server\x20is\x20running\x20at:\x0a','Remote\x20debugging\x20tool\x20is\x20running\x20at:\x20http://localhost:','136IDGJzB','TUNNEL_SERVER_HOST','mode','Content-Type','../utils/find-free-port','cwd','appId','application/json','qrcode-terminal','parse','vite','push','962122SeKzuS','vite.config.js','originalUrl','/src/app.js','child_process','6181550oSMaEh','adb','89415kcDrAO','data','https://','To\x20inspect\x20your\x20app,\x20open:\x20http://localhost:','681485qQJhYJ','zbrowser://h5.zdn.vn','bold','222780gJyOqH','headers','origin','(function\x20()\x20{\x20var\x20script\x20=\x20document.createElement(\x27script\x27);\x20script.src=\x27http://','hr-config-plugin','tcp:','existsSync','/target.js\x27;\x20document.body.appendChild(script);\x20})()','development','toString','previewOnZalo','info','green','frame','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20import\x20{\x20createHotContext\x20}\x20from\x20\x22/@vite/client\x22;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20import.meta.hot\x20=\x20createHotContext(\x22','writeFileSync','splice'];_0x3078=function(){return _0x4220e5;};return _0x3078();}module['exports']=async(_0x4faaf9={},_0x5683c1,{exitOnError:_0x5a4c1a=!0x0}={})=>{const _0x41c058=_0x54c847;_0x5683c1||(_0x5683c1={'statusStart'(){},'statusDone'(){},'statusError'(){},'text'(){},'error'(){}}),m[_0x41c058(0x1db)]();let _0x395d95=_0x4faaf9[_0x41c058(0x213)]||process[_0x41c058(0x213)](),_0x4cf538=_0x4faaf9[_0x41c058(0x214)]||c[_0x41c058(0x1d6)](l['env'][_0x41c058(0x214)]),_0x47b72b=_0x4faaf9[_0x41c058(0x1c1)],_0x2b6082=_0x4faaf9['ios'],_0x303c29=_0x4faaf9[_0x41c058(0x1f3)],_0x923711=_0x4faaf9[_0x41c058(0x1c4)],_0x4a33d8=_0x2b6082?_0x303c29:_0x41c058(0x1d7),_0x76cc17=_0x4faaf9[_0x41c058(0x1dc)],_0x1d8e5d=_0x76cc17-0x2,_0x44920e=_0x4faaf9[_0x41c058(0x210)]||(_0x47b72b?_0x41c058(0x1f5):_0x41c058(0x1bf)),_0x50bae3=_0x4faaf9[_0x41c058(0x1d8)];try{let _0xbed404,_0x3261e0,_0x216a25;if(_0x47b72b){let _0x1585ae=t[_0x41c058(0x205)](_0x395d95,'hr.config.json'),_0x16cc44={'id':_0x41c058(0x1e4),'innerHTML':_0x41c058(0x1ba)+_0x4a33d8+':'+_0x1d8e5d+_0x41c058(0x1be),'type':'text/javascript'};if(p['existsSync'](_0x1585ae)){let _0x4d3a04=p[_0x41c058(0x1e6)](_0x1585ae),_0x5c529d=JSON[_0x41c058(0x1a6)](_0x4d3a04),_0xb98f5a=_0x5c529d[_0x41c058(0x1f4)];Array[_0x41c058(0x1ca)](_0xb98f5a)||(_0xb98f5a=[]);let _0x40c416=_0xb98f5a['findIndex'](_0x5679e7=>_0x41c058(0x1e4)===_0x5679e7['id']);_0x40c416<=0x0||_0xb98f5a[_0x41c058(0x1c7)](_0x40c416,0x1),_0xb98f5a[_0x41c058(0x1a8)](_0x16cc44),_0x5c529d[_0x41c058(0x1f4)]=_0xb98f5a,p[_0x41c058(0x1c6)](_0x1585ae,JSON[_0x41c058(0x1ed)](_0x5c529d,void 0x0,0x4));}else p[_0x41c058(0x1c6)](_0x1585ae,JSON[_0x41c058(0x1ed)]({'listCSS':[],'listJS':[{'src':_0x41c058(0x1ac),'type':_0x41c058(0x1da),'async':!0x0},_0x16cc44]},void 0x0,0x4));}let _0x494d58=_0x41c058(0x1aa);if(d[_0x41c058(0x1bd)](t[_0x41c058(0x205)](_0x395d95,_0x41c058(0x1f9)))&&(_0x494d58='vite.config.ts'),_0x50bae3){_0x3261e0=a[_0x41c058(0x1d1)](),_0x216a25=await u(),s[_0x41c058(0x1db)]({'port':_0x216a25});let _0x4de27c=await g(_0x216a25),_0x445e59=_0x3261e0+'.'+h[_0x41c058(0x20f)];_0xbed404=await n({'configFile':t[_0x41c058(0x205)](_0x395d95,_0x494d58),'root':_0x395d95,'mode':_0x44920e,'define':{'process.env.NODE_ENV':JSON[_0x41c058(0x1ed)](_0x44920e),'process.env.previewOnZalo':!0x0},'server':{'port':_0x76cc17,'host':_0x41c058(0x1d7),'origin':_0x41c058(0x1b2)+_0x445e59,'base':'/zapps/'+_0x4cf538+'/','hmr':{'host':_0x445e59,'clientPort':0x1bb,'protocol':_0x41c058(0x202)},'https':!0x1},'plugins':[{'name':_0x41c058(0x1bb),'configureServer'(_0x369461){const _0x57d045=_0x41c058;let _0x3ed697=(_0x89cee0,_0x479dbf)=>{const _0x186508=_0x573a;['https://h5.zdn.vn',_0x186508(0x1b5)][_0x186508(0x1e5)](_0x89cee0['headers'][_0x186508(0x1b9)])&&_0x479dbf[_0x186508(0x1e3)](_0x186508(0x1ef),_0x89cee0[_0x186508(0x1b8)]['origin']);};_0x369461[_0x57d045(0x1dd)][_0x57d045(0x1ee)](_0x57d045(0x200),(_0x11f281,_0x4c4e00,_0x5a6896)=>_0x57d045(0x200)===_0x11f281[_0x57d045(0x1ab)]?(_0x4c4e00['setHeader'](_0x57d045(0x211),_0x57d045(0x1d5)),_0x3ed697(_0x11f281,_0x4c4e00),_0x4c4e00['end'](p[_0x57d045(0x1e6)](t[_0x57d045(0x205)](_0x395d95,_0x57d045(0x20a))))):_0x5a6896()),_0x369461[_0x57d045(0x1dd)]['use'](_0x57d045(0x1d3),async(_0x1adaf4,_0x47fa98)=>{const _0x178b48=_0x57d045;_0x47fa98[_0x178b48(0x1e3)](_0x178b48(0x211),_0x178b48(0x215)),_0x3ed697(_0x1adaf4,_0x47fa98);let _0x4a394a=await f('http://localhost:'+_0x4db3ef['httpServer'][_0x178b48(0x1eb)]()[_0x178b48(0x1dc)],{'chiiUrl':_0x4de27c,'exposedUrl':_0x178b48(0x1b2)+_0x3261e0+'.'+h['TUNNEL_SERVER_HOST']});_0x47fa98['end'](JSON['stringify'](_0x4a394a));}),_0x369461[_0x57d045(0x1dd)]['use']('/studio.module.js',async(_0x171dd8,_0x3a9b45)=>{const _0x16cd17=_0x57d045;_0x3a9b45[_0x16cd17(0x1e3)](_0x16cd17(0x211),_0x16cd17(0x1e2)),_0x3ed697(_0x171dd8,_0x3a9b45),_0x3a9b45[_0x16cd17(0x1fa)](_0x16cd17(0x1c5)+_0x3261e0+_0x16cd17(0x206));});}}]});}else _0xbed404=await n({'configFile':t['join'](_0x395d95,_0x494d58),'root':_0x395d95,'mode':_0x44920e,'define':{'process.env.NODE_ENV':JSON['stringify'](_0x44920e),'process.env.previewOnZalo':_0x47b72b},'server':{'port':_0x923711?_0x76cc17-0x1:_0x76cc17,..._0x47b72b?{'host':'0.0.0.0','hmr':{'host':_0x4a33d8,'protocol':'ws'}}:{}}});let _0x4db3ef=await _0xbed404[_0x41c058(0x1d9)]();if(_0x47b72b)try{s[_0x41c058(0x1db)]({'port':_0x1d8e5d}),_0x5683c1['text'](e[_0x41c058(0x1c3)](i[_0x41c058(0x1c2)]+'\x20'+e['bold'](_0x41c058(0x20d)+_0x1d8e5d))),_0x2b6082||require(_0x41c058(0x1ad))[_0x41c058(0x1de)](_0x41c058(0x1af),[_0x41c058(0x1cf),_0x41c058(0x1bc)+_0x1d8e5d,_0x41c058(0x1bc)+_0x1d8e5d])['stderr']['on']('data',function(_0x3e1cb5){const _0xf64454=_0x41c058;_0x5683c1[_0xf64454(0x1fd)](_0x3e1cb5['toString']());});}catch(_0x2e0608){_0x5683c1[_0x41c058(0x1f6)](i['info']+'\x20'+e['red'](_0x41c058(0x1f0)));}else{if(!_0x50bae3){if(_0x923711){let _0x4e7e9c=await n({'configFile':!0x1,'root':__dirname+_0x41c058(0x1e7),'server':{'port':_0x4db3ef[_0x41c058(0x1e8)]['address']()[_0x41c058(0x1dc)]+0x1,'strictPort':!0x0,'open':!0x0}});m[_0x41c058(0x1c9)](),await _0x4e7e9c['listen'](),(0x0,_0x4e7e9c[_0x41c058(0x1fc)][_0x41c058(0x1fb)][_0x41c058(0x1c2)])(e[_0x41c058(0x1c3)](_0x41c058(0x20c))),_0x4e7e9c[_0x41c058(0x20b)]();}else m[_0x41c058(0x1c9)](),(0x0,_0xbed404[_0x41c058(0x1fc)][_0x41c058(0x1fb)]['info'])(e[_0x41c058(0x1c3)](_0x41c058(0x20c))),_0xbed404[_0x41c058(0x20b)]();}}return m[_0x41c058(0x1c9)](),await new Promise(async()=>{const _0x5775af=_0x41c058;if(_0x47b72b){let _0x5c0e32='https://zalo.me/app/link/zapps/'+_0x4cf538+'/?env=TESTING_LOCAL&clientIp=http://'+_0x4a33d8+':'+_0x4db3ef[_0x5775af(0x1fc)][_0x5775af(0x1e0)]['port'];o[_0x5775af(0x1fe)](_0x5c0e32,{'small':!0x0},function(_0x57f17c){const _0xb736d2=_0x5775af;if(_0x5683c1[_0xb736d2(0x1f6)](e[_0xb736d2(0x1c3)](i[_0xb736d2(0x1c2)]+'\x20'+e[_0xb736d2(0x1b6)]('Zalo\x20Mini\x20App\x20dev\x20server\x20is\x20running\x20at:\x20'+_0x4a33d8+':'+_0x4db3ef[_0xb736d2(0x1fc)]['server'][_0xb736d2(0x1dc)]))),_0x5683c1['text'](e['green'](i[_0xb736d2(0x1c2)]+'\x20'+e[_0xb736d2(0x1b6)](_0xb736d2(0x1ec)))),_0x2b6082){let _0x4caf1a=i['info']+'\x20'+e[_0xb736d2(0x1b6)](_0xb736d2(0x1f7)+_0x57f17c);_0x5683c1[_0xb736d2(0x1f6)](_0x4caf1a);}else{let _0x5a7893=require(_0xb736d2(0x1ad))[_0xb736d2(0x1de)](_0xb736d2(0x1af),[_0xb736d2(0x1cf),'tcp:'+_0x4db3ef[_0xb736d2(0x1fc)][_0xb736d2(0x1e0)][_0xb736d2(0x1dc)],_0xb736d2(0x1bc)+_0x4db3ef[_0xb736d2(0x1fc)]['server'][_0xb736d2(0x1dc)]]);_0x5a7893[_0xb736d2(0x1df)]['on'](_0xb736d2(0x1b1),function(_0x2f4786){const _0x4c968d=_0xb736d2;_0x5683c1[_0x4c968d(0x1fd)](_0x2f4786[_0x4c968d(0x1c0)]());}),_0x5a7893['on'](_0xb736d2(0x1cc),function(_0x37683f){const _0x5ac969=_0xb736d2;if(0x0!==_0x37683f)throw Error(_0x5ac969(0x201)+_0x37683f);{let _0x1b6899=i['info']+'\x20'+e[_0x5ac969(0x1b6)]('Scan\x20the\x20QR\x20code\x20with\x20Zalo\x20app:\x0a'+_0x57f17c);_0x5683c1[_0x5ac969(0x1f6)](_0x1b6899),require('child_process')[_0x5ac969(0x1de)](_0x5ac969(0x1af),[_0x5ac969(0x1cd)])['stdout']['on'](_0x5ac969(0x1b1),function(_0x2f4a3f){const _0x16511b=_0x5ac969;_0x5683c1[_0x16511b(0x1f6)](''+e[_0x16511b(0x1d2)](_0x2f4a3f['toString']()));});}});}});}if(_0x50bae3){let _0x5b2c83=_0x4db3ef['httpServer'][_0x5775af(0x1eb)]()[_0x5775af(0x1dc)],_0x4adcc5=await g(_0x5b2c83,_0x3261e0),_0x1f5919='https://zalo.me/app/link/zapps/'+_0x4cf538+_0x5775af(0x209)+_0x4adcc5;o[_0x5775af(0x1fe)](_0x1f5919,{'small':!0x0},function(_0x57fe41){const _0x5e7818=_0x5775af;let _0x5368dc=i[_0x5e7818(0x1c2)]+'\x20'+e[_0x5e7818(0x1b6)]('Scan\x20the\x20QR\x20code\x20with\x20Zalo\x20app:\x0a'+_0x57fe41);_0x5683c1['text'](_0x5368dc),_0x5683c1[_0x5e7818(0x1f6)](i[_0x5e7818(0x1c2)]+'\x20'+e[_0x5e7818(0x1b6)](_0x5e7818(0x1b3)+_0x216a25+'\x20in\x20'+e[_0x5e7818(0x1c3)]('Google\x20Chrome')+'\x20or\x20a\x20'+e['blue'](_0x5e7818(0x208))+_0x5e7818(0x203)));});}});}catch(_0x309c9f){_0x5683c1['statusError'](_0x41c058(0x207)),_0x5683c1['error'](_0x309c9f),_0x5683c1['error'](_0x309c9f[_0x41c058(0x1df)]||_0x309c9f),_0x5a4c1a&&process[_0x41c058(0x1cc)](0x1);return;}};
|
|
@@ -1,146 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { axiosClient } = require('../utils/axios');
|
|
4
|
-
|
|
5
|
-
async function generateListResourcesFromIndex(
|
|
6
|
-
html,
|
|
7
|
-
{ outputDir, rootElement }
|
|
8
|
-
) {
|
|
9
|
-
const listCSS = [];
|
|
10
|
-
const listSyncJS = [];
|
|
11
|
-
const listAsyncJS = [];
|
|
12
|
-
let inlineJS = '';
|
|
13
|
-
try {
|
|
14
|
-
const parser = new DomParser();
|
|
15
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
16
|
-
const headInlines = [];
|
|
17
|
-
const bodyInlines = [];
|
|
18
|
-
|
|
19
|
-
const scripts = doc.getElementsByTagName('script');
|
|
20
|
-
for (const script of scripts) {
|
|
21
|
-
const src = script.getAttribute('src');
|
|
22
|
-
const type = script.getAttribute('type');
|
|
23
|
-
const async = script.getAttribute('async');
|
|
24
|
-
const inline = script.innerHTML;
|
|
25
|
-
try {
|
|
26
|
-
if (inline) {
|
|
27
|
-
bodyInlines.push(script.outerHTML);
|
|
28
|
-
} else {
|
|
29
|
-
let scriptName = src;
|
|
30
|
-
if (src.includes('://')) {
|
|
31
|
-
let filename = src.substring(src.lastIndexOf('/') + 1);
|
|
32
|
-
filename = `cdn.` + filename;
|
|
33
|
-
const response = await axiosClient({
|
|
34
|
-
method: 'get',
|
|
35
|
-
url: src,
|
|
36
|
-
responseType: 'stream',
|
|
37
|
-
});
|
|
38
|
-
const fileStream = fs.createWriteStream(`${outputDir}/${filename}`);
|
|
39
|
-
response.data.pipe(fileStream);
|
|
40
|
-
|
|
41
|
-
await new Promise((resolve, reject) => {
|
|
42
|
-
fileStream.on('finish', resolve);
|
|
43
|
-
fileStream.on('error', reject);
|
|
44
|
-
});
|
|
45
|
-
scriptName = filename;
|
|
46
|
-
}
|
|
47
|
-
if (type === 'module' && !scriptName.endsWith('module.js')) {
|
|
48
|
-
const newName = src.slice(0, -3).concat('.module.js');
|
|
49
|
-
fs.rename(scriptName, newName);
|
|
50
|
-
scriptName = newName;
|
|
51
|
-
}
|
|
52
|
-
(async ? listAsyncJS : listSyncJS).push(scriptName);
|
|
53
|
-
}
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.warn(
|
|
56
|
-
'\n⚠️ Unable to download resource from CDN. Please handle this file manually!',
|
|
57
|
-
src
|
|
58
|
-
);
|
|
59
|
-
console.error(error.message);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const styles = doc.getElementsByTagName('style');
|
|
64
|
-
styles.forEach((style) => {
|
|
65
|
-
const inline = style.innerHTML;
|
|
66
|
-
if (inline) {
|
|
67
|
-
headInlines.push(style.outerHTML);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const links = doc.getElementsByTagName('link');
|
|
72
|
-
for (const link of links) {
|
|
73
|
-
const rel = link.getAttribute('rel');
|
|
74
|
-
const href = link.getAttribute('href');
|
|
75
|
-
try {
|
|
76
|
-
if (rel === 'stylesheet') {
|
|
77
|
-
let filename = href;
|
|
78
|
-
if (href.includes('://')) {
|
|
79
|
-
filename = href.substring(href.lastIndexOf('/') + 1);
|
|
80
|
-
filename = `cdn.` + filename;
|
|
81
|
-
const response = await axiosClient({
|
|
82
|
-
method: 'get',
|
|
83
|
-
url: href,
|
|
84
|
-
responseType: 'stream',
|
|
85
|
-
});
|
|
86
|
-
const fileStream = fs.createWriteStream(`${outputDir}/${filename}`);
|
|
87
|
-
response.data.pipe(fileStream);
|
|
88
|
-
|
|
89
|
-
await new Promise((resolve, reject) => {
|
|
90
|
-
fileStream.on('finish', resolve);
|
|
91
|
-
fileStream.on('error', reject);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
listCSS.push(filename);
|
|
95
|
-
}
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error(
|
|
98
|
-
'\n⚠️ Unable to download resource from CDN. Please handle this file manually!',
|
|
99
|
-
href
|
|
100
|
-
);
|
|
101
|
-
console.error(error.message);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const metas = doc.getElementsByTagName('meta');
|
|
106
|
-
metas.forEach((meta) => {
|
|
107
|
-
headInlines.push(meta.outerHTML);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (rootElement && rootElement !== '#app') {
|
|
111
|
-
let html = `<${rootElement} />`;
|
|
112
|
-
if (rootElement.startsWith('#')) {
|
|
113
|
-
html = `<div id="${rootElement.substring(1)}" />`;
|
|
114
|
-
}
|
|
115
|
-
if (rootElement.startsWith('.')) {
|
|
116
|
-
html = `<div class="${rootElement.substring(1)}" />`;
|
|
117
|
-
}
|
|
118
|
-
if (rootElement.startsWith('<')) {
|
|
119
|
-
html = rootElement;
|
|
120
|
-
}
|
|
121
|
-
bodyInlines.unshift(html);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
inlineJS += headInlines
|
|
125
|
-
.map(
|
|
126
|
-
(inline) =>
|
|
127
|
-
`document.head.innerHTML += \`${inline.replaceAll('`', '\\`')}\`;`
|
|
128
|
-
)
|
|
129
|
-
.join('\n');
|
|
130
|
-
inlineJS += '\n';
|
|
131
|
-
inlineJS += bodyInlines
|
|
132
|
-
.map(
|
|
133
|
-
(inline) =>
|
|
134
|
-
`document.body.innerHTML += \`${inline.replaceAll('`', '\\`')}\`;`
|
|
135
|
-
)
|
|
136
|
-
.join('\n');
|
|
137
|
-
listSyncJS.unshift('inline.js');
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.error(error.message);
|
|
140
|
-
}
|
|
141
|
-
return { listCSS, listSyncJS, listAsyncJS, inlineJS };
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = {
|
|
145
|
-
generateListResourcesFromIndex,
|
|
146
|
-
};
|
|
1
|
+
'use strict';const _0x3971a2=_0x57b0;(function(_0x5ccd84,_0x1dc2cd){const _0x580d3a=_0x57b0,_0x49a8bf=_0x5ccd84();while(!![]){try{const _0x88366e=parseInt(_0x580d3a(0x9c))/0x1*(parseInt(_0x580d3a(0xc6))/0x2)+parseInt(_0x580d3a(0xb8))/0x3*(parseInt(_0x580d3a(0xc9))/0x4)+parseInt(_0x580d3a(0xc1))/0x5*(parseInt(_0x580d3a(0xaf))/0x6)+-parseInt(_0x580d3a(0xa0))/0x7+-parseInt(_0x580d3a(0xa8))/0x8+-parseInt(_0x580d3a(0xcc))/0x9+parseInt(_0x580d3a(0xcf))/0xa*(parseInt(_0x580d3a(0xa2))/0xb);if(_0x88366e===_0x1dc2cd)break;else _0x49a8bf['push'](_0x49a8bf['shift']());}catch(_0x4225c1){_0x49a8bf['push'](_0x49a8bf['shift']());}}}(_0xc576,0x26376));const e=require(_0x3971a2(0xb7)),t=require('fs'),{axiosClient:r}=require(_0x3971a2(0x9d));function _0x57b0(_0x1b6e07,_0x101f73){const _0xc576b0=_0xc576();return _0x57b0=function(_0x57b01b,_0x430626){_0x57b01b=_0x57b01b-0x9c;let _0x5554a1=_0xc576b0[_0x57b01b];return _0x5554a1;},_0x57b0(_0x1b6e07,_0x101f73);}function _0xc576(){const _0x77224c=['map','1908189XedwiN','.module.js','forEach','670RcgKlp','getAttribute','error','exports','cdn.','4471ioSYfF','../utils/axios','data','warn','1661863OfpZHd','unshift','89463dQYsqU','push','module','pipe','\x20/>','substring','2266704qxGwCD','outerHTML','href','inline.js','stream','lastIndexOf','://','30rxeQLX','getElementsByTagName','style','startsWith','createWriteStream','includes','concat','meta','dom-parser','3OtgIKd','join','type','document.head.innerHTML\x20+=\x20`','replaceAll','\x22\x20/>','stylesheet','<div\x20class=\x22','message','77890RFNEYo','innerHTML','endsWith','script','link','118loGJFA','src','module.js','10848vtfsOt','get'];_0xc576=function(){return _0x77224c;};return _0xc576();}async function s(_0x48c1dc,{outputDir:_0x4ac537,rootElement:_0x3ad84c}){const _0x339366=_0x3971a2;let _0x253c32=[],_0x388e12=[],_0xff541f=[],_0x5bf2a9='';try{let _0x19a04d=new e()['parseFromString'](_0x48c1dc,'text/html'),_0x3f471d=[],_0x38fcfe=[];for(let _0x441153 of _0x19a04d[_0x339366(0xb0)](_0x339366(0xc4))){let _0x56a244=_0x441153[_0x339366(0xd0)](_0x339366(0xc7)),_0x5ee98b=_0x441153['getAttribute'](_0x339366(0xba)),_0x3a52a0=_0x441153['getAttribute']('async'),_0x521171=_0x441153[_0x339366(0xc2)];try{if(_0x521171)_0x38fcfe[_0x339366(0xa3)](_0x441153[_0x339366(0xa9)]);else{let _0x1e30d8=_0x56a244;if(_0x56a244[_0x339366(0xb4)](_0x339366(0xae))){let _0x5830af=_0x56a244[_0x339366(0xa7)](_0x56a244[_0x339366(0xad)]('/')+0x1);_0x5830af='cdn.'+_0x5830af;let _0x313f3f=await r({'method':_0x339366(0xca),'url':_0x56a244,'responseType':_0x339366(0xac)}),_0x1b8f9d=t[_0x339366(0xb3)](_0x4ac537+'/'+_0x5830af);_0x313f3f[_0x339366(0x9e)]['pipe'](_0x1b8f9d),await new Promise((_0x2e58e8,_0x462d9c)=>{const _0xbcebc3=_0x339366;_0x1b8f9d['on']('finish',_0x2e58e8),_0x1b8f9d['on'](_0xbcebc3(0xd1),_0x462d9c);}),_0x1e30d8=_0x5830af;}if(_0x339366(0xa4)===_0x5ee98b&&!_0x1e30d8[_0x339366(0xc3)](_0x339366(0xc8))){let _0x424afc=_0x56a244['slice'](0x0,-0x3)[_0x339366(0xb5)](_0x339366(0xcd));t['rename'](_0x1e30d8,_0x424afc),_0x1e30d8=_0x424afc;}(_0x3a52a0?_0xff541f:_0x388e12)['push'](_0x1e30d8);}}catch(_0x16c24e){console[_0x339366(0x9f)]('\x0a⚠️\x20Unable\x20to\x20download\x20resource\x20from\x20CDN.\x20Please\x20handle\x20this\x20file\x20manually!',_0x56a244),console[_0x339366(0xd1)](_0x16c24e['message']);}}for(let _0x355aad of(_0x19a04d['getElementsByTagName'](_0x339366(0xb1))[_0x339366(0xce)](_0x4a1f64=>{const _0x1b2698=_0x339366;_0x4a1f64[_0x1b2698(0xc2)]&&_0x3f471d[_0x1b2698(0xa3)](_0x4a1f64[_0x1b2698(0xa9)]);}),_0x19a04d['getElementsByTagName'](_0x339366(0xc5)))){let _0x5a01e1=_0x355aad[_0x339366(0xd0)]('rel'),_0x3c680e=_0x355aad['getAttribute'](_0x339366(0xaa));try{if(_0x339366(0xbe)===_0x5a01e1){let _0x263c18=_0x3c680e;if(_0x3c680e[_0x339366(0xb4)]('://')){_0x263c18=_0x3c680e[_0x339366(0xa7)](_0x3c680e[_0x339366(0xad)]('/')+0x1),_0x263c18=_0x339366(0xd3)+_0x263c18;let _0x2e0ec1=await r({'method':_0x339366(0xca),'url':_0x3c680e,'responseType':_0x339366(0xac)}),_0x49f715=t[_0x339366(0xb3)](_0x4ac537+'/'+_0x263c18);_0x2e0ec1[_0x339366(0x9e)][_0x339366(0xa5)](_0x49f715),await new Promise((_0xc44635,_0x55c2d9)=>{_0x49f715['on']('finish',_0xc44635),_0x49f715['on']('error',_0x55c2d9);});}_0x253c32[_0x339366(0xa3)](_0x263c18);}}catch(_0x35b4e8){console['error']('\x0a⚠️\x20Unable\x20to\x20download\x20resource\x20from\x20CDN.\x20Please\x20handle\x20this\x20file\x20manually!',_0x3c680e),console['error'](_0x35b4e8['message']);}}if(_0x19a04d[_0x339366(0xb0)](_0x339366(0xb6))[_0x339366(0xce)](_0xb11fdf=>{const _0x269849=_0x339366;_0x3f471d[_0x269849(0xa3)](_0xb11fdf[_0x269849(0xa9)]);}),_0x3ad84c&&'#app'!==_0x3ad84c){let _0x4fa04f='<'+_0x3ad84c+_0x339366(0xa6);_0x3ad84c[_0x339366(0xb2)]('#')&&(_0x4fa04f='<div\x20id=\x22'+_0x3ad84c[_0x339366(0xa7)](0x1)+_0x339366(0xbd)),_0x3ad84c[_0x339366(0xb2)]('.')&&(_0x4fa04f=_0x339366(0xbf)+_0x3ad84c[_0x339366(0xa7)](0x1)+_0x339366(0xbd)),_0x3ad84c[_0x339366(0xb2)]('<')&&(_0x4fa04f=_0x3ad84c),_0x38fcfe[_0x339366(0xa1)](_0x4fa04f);}_0x5bf2a9+=_0x3f471d[_0x339366(0xcb)](_0x3562cc=>_0x339366(0xbb)+_0x3562cc['replaceAll']('`','\x5c`')+'`;')[_0x339366(0xb9)]('\x0a')+'\x0a'+_0x38fcfe['map'](_0x2b6bcf=>'document.body.innerHTML\x20+=\x20`'+_0x2b6bcf[_0x339366(0xbc)]('`','\x5c`')+'`;')[_0x339366(0xb9)]('\x0a'),_0x388e12[_0x339366(0xa1)](_0x339366(0xab));}catch(_0x319e30){console[_0x339366(0xd1)](_0x319e30[_0x339366(0xc0)]);}return{'listCSS':_0x253c32,'listSyncJS':_0x388e12,'listAsyncJS':_0xff541f,'inlineJS':_0x5bf2a9};}module[_0x3971a2(0xd2)]={'generateListResourcesFromIndex':s};
|
package/sync/index.js
CHANGED
|
@@ -1,55 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const fse = require('../utils/fs-extra');
|
|
4
|
-
const config = require('../config');
|
|
5
|
-
const { generateListResourcesFromIndex } = require('./index-to-app-config');
|
|
6
|
-
|
|
7
|
-
const waitText = chalk.gray('(Please wait, it can take a while)');
|
|
8
|
-
const defaultLogger = {
|
|
9
|
-
statusStart() {},
|
|
10
|
-
statusDone() {},
|
|
11
|
-
statusText() {},
|
|
12
|
-
statusError() {},
|
|
13
|
-
text() {},
|
|
14
|
-
error() {},
|
|
15
|
-
showOnUI() {},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
module.exports = async (options = {}, logger = defaultLogger) => {
|
|
19
|
-
logger.statusStart(`Synchronization configuration ${waitText}`);
|
|
20
|
-
const cwd = process.cwd();
|
|
21
|
-
const { source, rootElement } = options;
|
|
22
|
-
const appConfigFilename = config.filename.appConfig;
|
|
23
|
-
const resolvePath = (dir) => {
|
|
24
|
-
return path.join(cwd, dir);
|
|
25
|
-
};
|
|
26
|
-
function errorExit(err) {
|
|
27
|
-
logger.error(err.stderr || err);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
let appConfigJson;
|
|
31
|
-
try {
|
|
32
|
-
appConfigJson = require(resolvePath(appConfigFilename));
|
|
33
|
-
} catch (err) {
|
|
34
|
-
errorExit(new Error(config.error_msg.app_config_not_found));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const html = fse.readFileSync(source).toString();
|
|
38
|
-
const outputDir = path.dirname(source);
|
|
39
|
-
const { listCSS, listSyncJS, listAsyncJS, inlineJS } =
|
|
40
|
-
await generateListResourcesFromIndex(html, { outputDir, rootElement });
|
|
41
|
-
Object.assign(appConfigJson, {
|
|
42
|
-
listCSS,
|
|
43
|
-
listSyncJS,
|
|
44
|
-
listAsyncJS,
|
|
45
|
-
});
|
|
46
|
-
if (inlineJS) {
|
|
47
|
-
fse.writeFileSync(resolvePath(`${outputDir}/inline.js`), inlineJS);
|
|
48
|
-
}
|
|
49
|
-
const output = JSON.stringify(appConfigJson, null, 2);
|
|
50
|
-
fse.writeFileSync(resolvePath(appConfigFilename), output);
|
|
51
|
-
logger.statusDone(
|
|
52
|
-
`${chalk.bold.green('Configuration synchronization completed!')} 💪`
|
|
53
|
-
);
|
|
54
|
-
logger.text({ listCSS, listSyncJS, listAsyncJS });
|
|
55
|
-
};
|
|
1
|
+
'use strict';const _0x1706b7=_0x1bc7;(function(_0x5db636,_0x2ed99d){const _0x3b029c=_0x1bc7,_0x42e51d=_0x5db636();while(!![]){try{const _0x39a36b=parseInt(_0x3b029c(0x136))/0x1+-parseInt(_0x3b029c(0x13b))/0x2+parseInt(_0x3b029c(0x13c))/0x3+-parseInt(_0x3b029c(0x151))/0x4*(parseInt(_0x3b029c(0x139))/0x5)+-parseInt(_0x3b029c(0x14f))/0x6*(parseInt(_0x3b029c(0x135))/0x7)+-parseInt(_0x3b029c(0x138))/0x8*(-parseInt(_0x3b029c(0x14b))/0x9)+parseInt(_0x3b029c(0x144))/0xa;if(_0x39a36b===_0x2ed99d)break;else _0x42e51d['push'](_0x42e51d['shift']());}catch(_0x450677){_0x42e51d['push'](_0x42e51d['shift']());}}}(_0xcbc8,0x84bae));const t=require(_0x1706b7(0x147)),e=require(_0x1706b7(0x146)),r=require(_0x1706b7(0x143)),i=require(_0x1706b7(0x137)),{generateListResourcesFromIndex:n}=require(_0x1706b7(0x145)),a=e['gray']('(Please\x20wait,\x20it\x20can\x20take\x20a\x20while)'),o={'statusStart'(){},'statusDone'(){},'statusText'(){},'statusError'(){},'text'(){},'error'(){},'showOnUI'(){}};module['exports']=async(_0xb03baa={},_0x1273c4=o)=>{const _0x4ad4e2=_0x1706b7;let _0x3fb0b3;_0x1273c4[_0x4ad4e2(0x141)]('Synchronization\x20configuration\x20'+a);let _0x237515=process['cwd'](),{source:_0x27651f,rootElement:_0x325bc0}=_0xb03baa,_0x23ce3b=i[_0x4ad4e2(0x14a)][_0x4ad4e2(0x14e)],_0x352ffb=_0x695793=>t[_0x4ad4e2(0x150)](_0x237515,_0x695793);try{_0x3fb0b3=require(_0x352ffb(_0x23ce3b));}catch(_0x1a9bc3){var _0x31036a;_0x31036a=Error(i[_0x4ad4e2(0x140)][_0x4ad4e2(0x149)]),_0x1273c4[_0x4ad4e2(0x132)](_0x31036a['stderr']||_0x31036a),process[_0x4ad4e2(0x133)](0x1);}let _0x1cef12=r[_0x4ad4e2(0x148)](_0x27651f)['toString'](),_0x300bdb=t[_0x4ad4e2(0x13d)](_0x27651f),{listCSS:_0x557522,listSyncJS:_0x558fbe,listAsyncJS:_0x15b571,inlineJS:_0x264dbe}=await n(_0x1cef12,{'outputDir':_0x300bdb,'rootElement':_0x325bc0});Object[_0x4ad4e2(0x142)](_0x3fb0b3,{'listCSS':_0x557522,'listSyncJS':_0x558fbe,'listAsyncJS':_0x15b571}),_0x264dbe&&r[_0x4ad4e2(0x14d)](_0x352ffb(_0x300bdb+_0x4ad4e2(0x13a)),_0x264dbe);let _0x4c3478=JSON[_0x4ad4e2(0x134)](_0x3fb0b3,null,0x2);r[_0x4ad4e2(0x14d)](_0x352ffb(_0x23ce3b),_0x4c3478),_0x1273c4[_0x4ad4e2(0x14c)](e['bold'][_0x4ad4e2(0x13e)]('Configuration\x20synchronization\x20completed!')+'\x20💪'),_0x1273c4[_0x4ad4e2(0x13f)]({'listCSS':_0x557522,'listSyncJS':_0x558fbe,'listAsyncJS':_0x15b571});};function _0x1bc7(_0x424537,_0x2a7878){const _0xcbc8e9=_0xcbc8();return _0x1bc7=function(_0x1bc711,_0xe4f2c6){_0x1bc711=_0x1bc711-0x132;let _0x5d9900=_0xcbc8e9[_0x1bc711];return _0x5d9900;},_0x1bc7(_0x424537,_0x2a7878);}function _0xcbc8(){const _0x303254=['error_msg','statusStart','assign','../utils/fs-extra','2536480NpLGky','./index-to-app-config','chalk','path','readFileSync','app_config_not_found','filename','2329119YcgdQz','statusDone','writeFileSync','appConfig','786OONaoF','join','549052gtPkLf','error','exit','stringify','56189MjENmL','512109jicloD','../config','32UhMhWW','25nIwkFX','/inline.js','357392lXqsbh','1977867lcBnMH','dirname','green','text'];_0xcbc8=function(){return _0x303254;};return _0xcbc8();}
|
package/utils/axios.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
const {
|
|
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
|
-
};
|
|
1
|
+
'use strict';function _0x4df1(_0x3752b1,_0x2394c4){const _0x1e3fd1=_0x1e3f();return _0x4df1=function(_0x4df195,_0x38d92b){_0x4df195=_0x4df195-0xab;let _0x3e20b1=_0x1e3fd1[_0x4df195];return _0x3e20b1;},_0x4df1(_0x3752b1,_0x2394c4);}const _0xeee39=_0x4df1;function _0x1e3f(){const _0xdfeb25=['218005PKDSVi','create','18595runzsw','5052064Qpkzqs','proxy-agent','1496616CrAeKz','2224838LttZPu','exports','49216wFXTeo','894735OdlZHL','618pTRGCG'];_0x1e3f=function(){return _0xdfeb25;};return _0x1e3f();}(function(_0x11c949,_0x40fbc8){const _0x5c109f=_0x4df1,_0x5eb6fb=_0x11c949();while(!![]){try{const _0xa5644c=parseInt(_0x5c109f(0xad))/0x1+-parseInt(_0x5c109f(0xb5))/0x2+-parseInt(_0x5c109f(0xab))/0x3+parseInt(_0x5c109f(0xb2))/0x4+parseInt(_0x5c109f(0xaf))/0x5*(-parseInt(_0x5c109f(0xac))/0x6)+-parseInt(_0x5c109f(0xb3))/0x7+parseInt(_0x5c109f(0xb0))/0x8;if(_0xa5644c===_0x40fbc8)break;else _0x5eb6fb['push'](_0x5eb6fb['shift']());}catch(_0x566c95){_0x5eb6fb['push'](_0x5eb6fb['shift']());}}}(_0x1e3f,0x30cf3));const {ProxyAgent:e}=require(_0xeee39(0xb1)),t=require('axios'),r=new e(),o=t[_0xeee39(0xae)]({'proxy':!0x1,'httpsAgent':r,'httpAgent':r});module[_0xeee39(0xb4)]={'agent':r,'axiosClient':o};
|