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/index.js
CHANGED
|
@@ -1,320 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const clear = require('clear');
|
|
5
|
-
const figlet = require('figlet');
|
|
6
|
-
const program = require('commander');
|
|
7
|
-
const logSymbols = require('log-symbols');
|
|
8
|
-
const fse = require('./utils/fs-extra');
|
|
9
|
-
const checkUpdate = require('./utils/check-update');
|
|
10
|
-
const spinner = require('./utils/spinner');
|
|
11
|
-
const log = require('./utils/log');
|
|
12
|
-
const getCurrentProject = require('./utils/get-current-project');
|
|
13
|
-
const getOptions = require('./create/utils/get-options');
|
|
14
|
-
const getLoginOptions = require('./login/utils/get-options');
|
|
15
|
-
const getDeployOptions = require('./deploy/utils/get-options');
|
|
16
|
-
const getMigrateOptions = require('./migrate/utils/get-options');
|
|
17
|
-
const loginApp = require('./login/index');
|
|
18
|
-
const createApp = require('./create/index');
|
|
19
|
-
const startApp = require('./start/index');
|
|
20
|
-
const buildApp = require('./build/index');
|
|
21
|
-
const deployApp = require('./deploy/index');
|
|
22
|
-
const syncApp = require('./sync/index');
|
|
23
|
-
const migrateApp = require('./migrate/index');
|
|
24
|
-
const os = require('os');
|
|
25
|
-
// const generateAssets = require('./assets/index');
|
|
26
|
-
// const server = require('./ui/server');
|
|
27
|
-
const pkg = require('./package.json');
|
|
28
|
-
const config = require('./config');
|
|
29
|
-
const { versionStatus } = require('./utils/constants');
|
|
30
|
-
|
|
31
|
-
const cwd = process.cwd();
|
|
32
|
-
|
|
33
|
-
const logger = {
|
|
34
|
-
statusStart: (text) => spinner.start(text),
|
|
35
|
-
statusDone: (text) => spinner.done(text),
|
|
36
|
-
statusText: (text) => spinner.text(text),
|
|
37
|
-
statusError: (text) => spinner.error(text),
|
|
38
|
-
text: (text) => log.text(text),
|
|
39
|
-
error: (text) => log.error(text),
|
|
40
|
-
showOnUI: () => {},
|
|
41
|
-
};
|
|
42
|
-
/* =============================================
|
|
43
|
-
Header
|
|
44
|
-
============================================= */
|
|
45
|
-
|
|
46
|
-
clear();
|
|
47
|
-
if (!fse.existsSync(config.root_env())) {
|
|
48
|
-
fse.writeFileSync(config.root_env());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(
|
|
52
|
-
chalk.cyan(
|
|
53
|
-
figlet.textSync('ZMP CLI', {
|
|
54
|
-
horizontalLayout: 'full',
|
|
55
|
-
verticalLayout: 'full',
|
|
56
|
-
})
|
|
57
|
-
),
|
|
58
|
-
chalk.cyan(`Version: ${pkg.version}\n`)
|
|
59
|
-
);
|
|
60
|
-
/* =============================================
|
|
61
|
-
Commands
|
|
62
|
-
============================================= */
|
|
63
|
-
program
|
|
64
|
-
.version(pkg.version)
|
|
65
|
-
.usage('<command> [options]')
|
|
66
|
-
.command('init')
|
|
67
|
-
.option('--skipUpdate', 'Skip checking for update of zmp-cli')
|
|
68
|
-
.description('Init ZMP project')
|
|
69
|
-
.action(async (options) => {
|
|
70
|
-
if (!options.skipUpdate) await checkUpdate();
|
|
71
|
-
|
|
72
|
-
const currentProject = getCurrentProject(cwd);
|
|
73
|
-
if (currentProject) {
|
|
74
|
-
log.text(
|
|
75
|
-
`${logSymbols.error} ZMP project already set up in current directory`
|
|
76
|
-
);
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
const optsLogin = await getLoginOptions();
|
|
80
|
-
await loginApp({ cwd, ...optsLogin }, logger);
|
|
81
|
-
const opts = await getOptions();
|
|
82
|
-
await createApp({ cwd, ...opts }, logger);
|
|
83
|
-
process.exit(0);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
program
|
|
87
|
-
.usage('<command> [options]')
|
|
88
|
-
.command('login')
|
|
89
|
-
.description('Login ZMP')
|
|
90
|
-
.action(async () => {
|
|
91
|
-
// const currentProject = getCurrentProject(cwd);
|
|
92
|
-
// if (!currentProject) {
|
|
93
|
-
// log.text(`${logSymbols.error} This is not ZMP project`);
|
|
94
|
-
// process.exit(1);
|
|
95
|
-
// }
|
|
96
|
-
|
|
97
|
-
const optsLogin = await getLoginOptions();
|
|
98
|
-
await loginApp(
|
|
99
|
-
{
|
|
100
|
-
cwd,
|
|
101
|
-
...optsLogin,
|
|
102
|
-
},
|
|
103
|
-
logger
|
|
104
|
-
);
|
|
105
|
-
process.exit(0);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
program
|
|
109
|
-
.usage('<command> [options]')
|
|
110
|
-
.command('start')
|
|
111
|
-
.option(
|
|
112
|
-
'-iosH, --ios-host-name <n>',
|
|
113
|
-
'Specify server hostname. By default it is os.hostname'
|
|
114
|
-
)
|
|
115
|
-
.option(
|
|
116
|
-
'-P, --port <n>',
|
|
117
|
-
'Specify server port. By default it is 3000',
|
|
118
|
-
parseInt
|
|
119
|
-
)
|
|
120
|
-
.option('-Z, --zalo-app', 'Preview on Zalo')
|
|
121
|
-
.option('-ios, --ios', 'Run on ios')
|
|
122
|
-
.option('-nF, --no-frame', 'Run without Zalo frame')
|
|
123
|
-
.option('-D, --device', 'Device mode')
|
|
124
|
-
.option('-M, --mode <m>', 'Env mode')
|
|
125
|
-
.description('Start a ZMP project')
|
|
126
|
-
.action(async (options) => {
|
|
127
|
-
const currentProject = getCurrentProject(cwd);
|
|
128
|
-
|
|
129
|
-
if (!currentProject) {
|
|
130
|
-
log.text(`${logSymbols.error} This is not ZMP project`);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (options && options.showMobileUi) {
|
|
135
|
-
try {
|
|
136
|
-
console.log(require.resolve('nw'));
|
|
137
|
-
} catch (e) {
|
|
138
|
-
console.error(
|
|
139
|
-
'NW.js module is not found. Please run "npm install -g nw@sdk"'
|
|
140
|
-
);
|
|
141
|
-
process.exit(e.code);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let defaultIOSHostName = os.hostname();
|
|
146
|
-
if (!defaultIOSHostName.includes('.local')) {
|
|
147
|
-
defaultIOSHostName = `${defaultIOSHostName}.local`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
await startApp(
|
|
151
|
-
{
|
|
152
|
-
cwd,
|
|
153
|
-
port: (options && options.port) || 3000,
|
|
154
|
-
iosHostName: (options && options.iosHostName) || defaultIOSHostName,
|
|
155
|
-
showMobileUI: (options && options.showMobileUi) || false,
|
|
156
|
-
previewOnZalo: (options && options.zaloApp) || false,
|
|
157
|
-
ios: (options && options.ios) || false,
|
|
158
|
-
mode: options && options.mode,
|
|
159
|
-
frame:
|
|
160
|
-
options &&
|
|
161
|
-
(typeof options.frame === 'undefined' || options.frame === null)
|
|
162
|
-
? true
|
|
163
|
-
: options.frame,
|
|
164
|
-
deviceMode: (options && options.device) || false,
|
|
165
|
-
},
|
|
166
|
-
logger
|
|
167
|
-
);
|
|
168
|
-
process.exit(0);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
program
|
|
172
|
-
.usage('<command> [options]')
|
|
173
|
-
.command('build')
|
|
174
|
-
.description('Build a ZMP project')
|
|
175
|
-
.action(async () => {
|
|
176
|
-
const currentProject = getCurrentProject(cwd);
|
|
177
|
-
|
|
178
|
-
if (!currentProject) {
|
|
179
|
-
log.text(`${logSymbols.error} This is not ZMP project`);
|
|
180
|
-
process.exit(1);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
await buildApp(
|
|
184
|
-
{
|
|
185
|
-
cwd,
|
|
186
|
-
},
|
|
187
|
-
logger
|
|
188
|
-
);
|
|
189
|
-
process.exit(0);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
program
|
|
193
|
-
.usage('<command> [options]')
|
|
194
|
-
.command('deploy')
|
|
195
|
-
.option('-D, --dev', 'Deploy in Development server')
|
|
196
|
-
.option('-M, --mode <m>', 'Env mode')
|
|
197
|
-
.option('-p, --passive', 'Passive mode (non-interactive)')
|
|
198
|
-
.option('-e, --existing', 'Deploy existing project')
|
|
199
|
-
.option('-t, --testing', 'Deploy testing version')
|
|
200
|
-
.option('-m, --desc <message>', 'Version description')
|
|
201
|
-
.option('-o, --outputDir <output>', 'Output folder. Default www')
|
|
202
|
-
.option(
|
|
203
|
-
'-P, --port <n>',
|
|
204
|
-
'Specify UI server port. By default it is 3001',
|
|
205
|
-
parseInt
|
|
206
|
-
)
|
|
207
|
-
.description('Deploy a ZMP project')
|
|
208
|
-
.action(async (options) => {
|
|
209
|
-
const currentProject = getCurrentProject(cwd);
|
|
210
|
-
let opts = options;
|
|
211
|
-
if (options.existing) {
|
|
212
|
-
opts.customProject = true;
|
|
213
|
-
} else {
|
|
214
|
-
if (!options.passive) {
|
|
215
|
-
opts = await getDeployOptions(currentProject);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (options.testing) {
|
|
219
|
-
opts.versionStatus = versionStatus.TESTING;
|
|
220
|
-
}
|
|
221
|
-
if (opts.quit) process.exit(1);
|
|
222
|
-
await deployApp(
|
|
223
|
-
{
|
|
224
|
-
cwd,
|
|
225
|
-
dev: options && options.dev,
|
|
226
|
-
mode: options && options.mode,
|
|
227
|
-
...opts,
|
|
228
|
-
},
|
|
229
|
-
logger
|
|
230
|
-
);
|
|
231
|
-
process.exit(0);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
program
|
|
235
|
-
.usage('<command> [options]')
|
|
236
|
-
.command('sync-config <source>')
|
|
237
|
-
.option(
|
|
238
|
-
'-r, --root-element <selector>',
|
|
239
|
-
'Custom entry point, default is #app'
|
|
240
|
-
)
|
|
241
|
-
.description(
|
|
242
|
-
'Automatically update app-config.json resources list based on index.html'
|
|
243
|
-
)
|
|
244
|
-
.action(async (source, options) => {
|
|
245
|
-
await syncApp(
|
|
246
|
-
{
|
|
247
|
-
source,
|
|
248
|
-
...options,
|
|
249
|
-
},
|
|
250
|
-
logger
|
|
251
|
-
);
|
|
252
|
-
process.exit(0);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
program
|
|
256
|
-
.usage('<command> [options]')
|
|
257
|
-
.command('migrate')
|
|
258
|
-
.action(async function () {
|
|
259
|
-
const currentProject = getCurrentProject(cwd);
|
|
260
|
-
if (!currentProject) {
|
|
261
|
-
logger.text(`${logSymbols.error} This is not ZMP project`);
|
|
262
|
-
process.exit(1);
|
|
263
|
-
}
|
|
264
|
-
const opts = await getMigrateOptions();
|
|
265
|
-
await migrateApp(
|
|
266
|
-
{
|
|
267
|
-
cwd,
|
|
268
|
-
...opts,
|
|
269
|
-
...currentProject,
|
|
270
|
-
},
|
|
271
|
-
logger
|
|
272
|
-
);
|
|
273
|
-
process.exit(0);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// program
|
|
277
|
-
// .command('assets')
|
|
278
|
-
// .alias('generate-assets')
|
|
279
|
-
// .option('--skipUpdate', 'Skip checking for update of zmp-cli')
|
|
280
|
-
// .option('--ui', 'Launch assets generation UI')
|
|
281
|
-
// .option(
|
|
282
|
-
// '-P, --port <n>',
|
|
283
|
-
// 'Specify UI server port. By default it is 3001',
|
|
284
|
-
// parseInt
|
|
285
|
-
// )
|
|
286
|
-
// .description('Generate ZMP app icons and splash screens')
|
|
287
|
-
// .action(async (options) => {
|
|
288
|
-
// // Check update
|
|
289
|
-
// if (options.skipUpdate === undefined) {
|
|
290
|
-
// await checkUpdate();
|
|
291
|
-
// }
|
|
292
|
-
|
|
293
|
-
// const currentProject = getCurrentProject(cwd);
|
|
294
|
-
// if (!currentProject) {
|
|
295
|
-
// log.text(
|
|
296
|
-
// `${logSymbols.error} ZMP project not found in current directory`
|
|
297
|
-
// );
|
|
298
|
-
// process.exit(1);
|
|
299
|
-
// }
|
|
300
|
-
|
|
301
|
-
// if (options.ui) {
|
|
302
|
-
// spinner.start('Launching ZMP UI server');
|
|
303
|
-
// server('/assets/', options.port);
|
|
304
|
-
// spinner.end('Launching ZMP UI server');
|
|
305
|
-
// } else {
|
|
306
|
-
// await generateAssets({}, currentProject, logger);
|
|
307
|
-
// process.exit(0);
|
|
308
|
-
// }
|
|
309
|
-
// });
|
|
310
|
-
|
|
311
|
-
program.on('command:*', (cmd) => {
|
|
312
|
-
program.outputHelp();
|
|
313
|
-
log.text(`\n Unknown command ${cmd}`);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
program.parse(process.argv);
|
|
317
|
-
|
|
318
|
-
if (!program.args.length) {
|
|
319
|
-
program.outputHelp();
|
|
320
|
-
}
|
|
2
|
+
'use strict';const _0x548a02=_0xe762;function _0x2d94(){const _0x3c94cc=['command:*','Specify\x20server\x20hostname.\x20By\x20default\x20it\x20is\x20os.hostname','ZMP\x20CLI','clear','6rdCVdg','Env\x20mode','mode','Build\x20a\x20ZMP\x20project','testing','-m,\x20--desc\x20<message>','Deploy\x20a\x20ZMP\x20project','cyan','existsSync','./utils/constants','length','./create/utils/get-options','./login/index','command','<command>\x20[options]','-P,\x20--port\x20<n>','root_env','Deploy\x20in\x20Development\x20server','outputHelp','-M,\x20--mode\x20<m>','./start/index','-r,\x20--root-element\x20<selector>','ios','error','cwd','Login\x20ZMP','log-symbols','quit','args','-iosH,\x20--ios-host-name\x20<n>','Passive\x20mode\x20(non-interactive)','Automatically\x20update\x20app-config.json\x20resources\x20list\x20based\x20on\x20index.html','.local','./utils/log','1819391TTqEsc','description','option','Preview\x20on\x20Zalo','Version:\x20','./utils/fs-extra','583312ylvERk','./migrate/utils/get-options','frame','port','./deploy/utils/get-options','-p,\x20--passive','20jHLoYz','sync-config\x20<source>','Deploy\x20testing\x20version','218746XhHnEA','-D,\x20--device','Start\x20a\x20ZMP\x20project','textSync','version','\x20This\x20is\x20not\x20ZMP\x20project','./config','-t,\x20--testing','iosHostName','Run\x20without\x20Zalo\x20frame','./create/index','skipUpdate','chalk','Deploy\x20existing\x20project','Run\x20on\x20ios','device','resolve','Output\x20folder.\x20Default\x20www','Custom\x20entry\x20point,\x20default\x20is\x20#app','deploy','./utils/check-update','./login/utils/get-options','1324450VdGvpa','writeFileSync','figlet','-D,\x20--dev','commander','8FvmYBa','action','passive','text','./build/index','3574215NyWAxW','dev','migrate','3111656cwifhy','exit','Device\x20mode','login','--skipUpdate','9JmhgcB','NW.js\x20module\x20is\x20not\x20found.\x20Please\x20run\x20\x22npm\x20install\x20-g\x20nw@sdk\x22','showMobileUi','log','6904887tHOEqu','-o,\x20--outputDir\x20<output>','includes','start','usage'];_0x2d94=function(){return _0x3c94cc;};return _0x2d94();}function _0xe762(_0x5431bc,_0x496707){const _0x2d946c=_0x2d94();return _0xe762=function(_0xe76299,_0x9f6dba){_0xe76299=_0xe76299-0x102;let _0x3ca25c=_0x2d946c[_0xe76299];return _0x3ca25c;},_0xe762(_0x5431bc,_0x496707);}(function(_0x2fdb6f,_0x57f0b4){const _0x39c159=_0xe762,_0x188606=_0x2fdb6f();while(!![]){try{const _0xc80207=-parseInt(_0x39c159(0x124))/0x1+parseInt(_0x39c159(0x11b))/0x2+parseInt(_0x39c159(0x144))/0x3+-parseInt(_0x39c159(0x13f))/0x4*(-parseInt(_0x39c159(0x13a))/0x5)+-parseInt(_0x39c159(0x159))/0x6*(parseInt(_0x39c159(0x115))/0x7)+parseInt(_0x39c159(0x147))/0x8*(parseInt(_0x39c159(0x14c))/0x9)+parseInt(_0x39c159(0x121))/0xa*(-parseInt(_0x39c159(0x150))/0xb);if(_0xc80207===_0x57f0b4)break;else _0x188606['push'](_0x188606['shift']());}catch(_0x2a4ff2){_0x188606['push'](_0x188606['shift']());}}}(_0x2d94,0xa3039));const e=require(_0x548a02(0x130)),o=require(_0x548a02(0x158)),t=require(_0x548a02(0x13c)),i=require(_0x548a02(0x13e)),r=require(_0x548a02(0x10d)),s=require(_0x548a02(0x11a)),n=require(_0x548a02(0x138)),a=require('./utils/spinner'),c=require(_0x548a02(0x114)),p=require('./utils/get-current-project'),u=require(_0x548a02(0x164)),l=require(_0x548a02(0x139)),d=require(_0x548a02(0x11f)),m=require(_0x548a02(0x11c)),g=require(_0x548a02(0x165)),x=require(_0x548a02(0x12e)),y=require(_0x548a02(0x107)),v=require(_0x548a02(0x143)),w=require('./deploy/index'),f=require('./sync/index'),q=require('./migrate/index'),h=require('os'),M=require('./package.json'),P=require(_0x548a02(0x12a)),{versionStatus:j}=require(_0x548a02(0x162)),Z=process[_0x548a02(0x10b)](),D={'statusStart':_0x350a6f=>a[_0x548a02(0x153)](_0x350a6f),'statusDone':_0x2d39f1=>a['done'](_0x2d39f1),'statusText':_0x452dc7=>a[_0x548a02(0x142)](_0x452dc7),'statusError':_0x47b720=>a['error'](_0x47b720),'text':_0x4956dd=>c['text'](_0x4956dd),'error':_0x51e369=>c[_0x548a02(0x10a)](_0x51e369),'showOnUI':()=>{}};o(),s[_0x548a02(0x161)](P[_0x548a02(0x103)]())||s[_0x548a02(0x13b)](P[_0x548a02(0x103)]()),console[_0x548a02(0x14f)](e[_0x548a02(0x160)](t[_0x548a02(0x127)](_0x548a02(0x157),{'horizontalLayout':'full','verticalLayout':'full'})),e[_0x548a02(0x160)](_0x548a02(0x119)+M[_0x548a02(0x128)]+'\x0a')),i[_0x548a02(0x128)](M['version'])[_0x548a02(0x154)](_0x548a02(0x167))[_0x548a02(0x166)]('init')['option'](_0x548a02(0x14b),'Skip\x20checking\x20for\x20update\x20of\x20zmp-cli')[_0x548a02(0x116)]('Init\x20ZMP\x20project')[_0x548a02(0x140)](async _0xe423cc=>{const _0x29fd01=_0x548a02;_0xe423cc[_0x29fd01(0x12f)]||await n(),p(Z)&&(c['text'](r['error']+'\x20ZMP\x20project\x20already\x20set\x20up\x20in\x20current\x20directory'),process['exit'](0x1));let _0x2f4a96=await l();await g({'cwd':Z,..._0x2f4a96},D);let _0x1113cc=await u();await x({'cwd':Z,..._0x1113cc},D),process[_0x29fd01(0x148)](0x0);}),i[_0x548a02(0x154)](_0x548a02(0x167))[_0x548a02(0x166)](_0x548a02(0x14a))['description'](_0x548a02(0x10c))[_0x548a02(0x140)](async()=>{const _0x150376=_0x548a02;let _0x14b43e=await l();await g({'cwd':Z,..._0x14b43e},D),process[_0x150376(0x148)](0x0);}),i[_0x548a02(0x154)](_0x548a02(0x167))[_0x548a02(0x166)](_0x548a02(0x153))[_0x548a02(0x117)](_0x548a02(0x110),_0x548a02(0x156))[_0x548a02(0x117)](_0x548a02(0x102),'Specify\x20server\x20port.\x20By\x20default\x20it\x20is\x203000',parseInt)['option']('-Z,\x20--zalo-app',_0x548a02(0x118))[_0x548a02(0x117)]('-ios,\x20--ios',_0x548a02(0x132))[_0x548a02(0x117)]('-nF,\x20--no-frame',_0x548a02(0x12d))[_0x548a02(0x117)](_0x548a02(0x125),_0x548a02(0x149))[_0x548a02(0x117)](_0x548a02(0x106),_0x548a02(0x15a))[_0x548a02(0x116)](_0x548a02(0x126))['action'](async _0x5209c2=>{const _0x511ab9=_0x548a02;if(p(Z)||(c[_0x511ab9(0x142)](r[_0x511ab9(0x10a)]+'\x20This\x20is\x20not\x20ZMP\x20project'),process[_0x511ab9(0x148)](0x1)),_0x5209c2&&_0x5209c2['showMobileUi'])try{console[_0x511ab9(0x14f)](require[_0x511ab9(0x134)]('nw'));}catch(_0x595c47){console[_0x511ab9(0x10a)](_0x511ab9(0x14d)),process[_0x511ab9(0x148)](_0x595c47['code']);}let _0x444a10=h['hostname']();_0x444a10[_0x511ab9(0x152)]('.local')||(_0x444a10=_0x444a10+_0x511ab9(0x113)),await y({'cwd':Z,'port':_0x5209c2&&_0x5209c2[_0x511ab9(0x11e)]||0xbb8,'iosHostName':_0x5209c2&&_0x5209c2[_0x511ab9(0x12c)]||_0x444a10,'showMobileUI':_0x5209c2&&_0x5209c2[_0x511ab9(0x14e)]||!0x1,'previewOnZalo':_0x5209c2&&_0x5209c2['zaloApp']||!0x1,'ios':_0x5209c2&&_0x5209c2[_0x511ab9(0x109)]||!0x1,'mode':_0x5209c2&&_0x5209c2[_0x511ab9(0x15b)],'frame':!!_0x5209c2&&(void 0x0===_0x5209c2[_0x511ab9(0x11d)]||null===_0x5209c2['frame'])||_0x5209c2[_0x511ab9(0x11d)],'deviceMode':_0x5209c2&&_0x5209c2[_0x511ab9(0x133)]||!0x1},D),process[_0x511ab9(0x148)](0x0);}),i[_0x548a02(0x154)](_0x548a02(0x167))['command']('build')[_0x548a02(0x116)](_0x548a02(0x15c))[_0x548a02(0x140)](async()=>{const _0x2281e0=_0x548a02;p(Z)||(c[_0x2281e0(0x142)](r[_0x2281e0(0x10a)]+_0x2281e0(0x129)),process[_0x2281e0(0x148)](0x1)),await v({'cwd':Z},D),process[_0x2281e0(0x148)](0x0);}),i[_0x548a02(0x154)]('<command>\x20[options]')[_0x548a02(0x166)](_0x548a02(0x137))[_0x548a02(0x117)](_0x548a02(0x13d),_0x548a02(0x104))['option'](_0x548a02(0x106),'Env\x20mode')[_0x548a02(0x117)](_0x548a02(0x120),_0x548a02(0x111))[_0x548a02(0x117)]('-e,\x20--existing',_0x548a02(0x131))['option'](_0x548a02(0x12b),_0x548a02(0x123))[_0x548a02(0x117)](_0x548a02(0x15e),'Version\x20description')[_0x548a02(0x117)](_0x548a02(0x151),_0x548a02(0x135))[_0x548a02(0x117)](_0x548a02(0x102),'Specify\x20UI\x20server\x20port.\x20By\x20default\x20it\x20is\x203001',parseInt)[_0x548a02(0x116)](_0x548a02(0x15f))[_0x548a02(0x140)](async _0x25eeee=>{const _0x5943f9=_0x548a02;let _0x4f63b7=p(Z),_0x2cf37a=_0x25eeee;_0x25eeee['existing']?_0x2cf37a['customProject']=!0x0:_0x25eeee[_0x5943f9(0x141)]||(_0x2cf37a=await d(_0x4f63b7)),_0x25eeee[_0x5943f9(0x15d)]&&(_0x2cf37a['versionStatus']=j['TESTING']),_0x2cf37a[_0x5943f9(0x10e)]&&process['exit'](0x1),await w({'cwd':Z,'dev':_0x25eeee&&_0x25eeee[_0x5943f9(0x145)],'mode':_0x25eeee&&_0x25eeee[_0x5943f9(0x15b)],..._0x2cf37a},D),process['exit'](0x0);}),i[_0x548a02(0x154)](_0x548a02(0x167))[_0x548a02(0x166)](_0x548a02(0x122))[_0x548a02(0x117)](_0x548a02(0x108),_0x548a02(0x136))[_0x548a02(0x116)](_0x548a02(0x112))['action'](async(_0x20df75,_0x39872e)=>{const _0x3b81f9=_0x548a02;await f({'source':_0x20df75,..._0x39872e},D),process[_0x3b81f9(0x148)](0x0);}),i['usage'](_0x548a02(0x167))[_0x548a02(0x166)](_0x548a02(0x146))[_0x548a02(0x140)](async function(){const _0x1cd0e5=_0x548a02;let _0x1898c9=p(Z);_0x1898c9||(D[_0x1cd0e5(0x142)](r[_0x1cd0e5(0x10a)]+_0x1cd0e5(0x129)),process[_0x1cd0e5(0x148)](0x1));let _0x35916f=await m();await q({'cwd':Z,..._0x35916f,..._0x1898c9},D),process[_0x1cd0e5(0x148)](0x0);}),i['on'](_0x548a02(0x155),_0x2c0f90=>{const _0x319500=_0x548a02;i['outputHelp'](),c[_0x319500(0x142)]('\x0a\x20Unknown\x20command\x20'+_0x2c0f90);}),i['parse'](process['argv']),i[_0x548a02(0x10f)][_0x548a02(0x163)]||i[_0x548a02(0x105)]();
|
package/login/index.js
CHANGED
|
@@ -1,169 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint no-console: off */
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const ora = require('ora');
|
|
5
|
-
const jwt = require('jsonwebtoken');
|
|
6
|
-
const qrcode = require('qrcode-terminal');
|
|
7
|
-
const logSymbols = require('log-symbols');
|
|
8
|
-
const config = require('../config');
|
|
9
|
-
const envUtils = require('../utils/env');
|
|
10
|
-
const log = require('../utils/log');
|
|
11
|
-
const zaloLogin = require('./utils/zalo-login');
|
|
12
|
-
const { axiosClient } = require('../utils/axios');
|
|
13
|
-
const qs = require('qs');
|
|
14
|
-
|
|
15
|
-
const waitText = chalk.gray('Login...');
|
|
16
|
-
const spinner = ora(waitText);
|
|
17
|
-
|
|
18
|
-
module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
19
|
-
function errorExit(err) {
|
|
20
|
-
log.error(err.stderr || err);
|
|
21
|
-
if (exitOnError) process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
if (!logger) {
|
|
24
|
-
// eslint-disable-next-line
|
|
25
|
-
logger = {
|
|
26
|
-
statusStart() {},
|
|
27
|
-
statusDone() {},
|
|
28
|
-
statusText() {},
|
|
29
|
-
statusError() {},
|
|
30
|
-
text() {},
|
|
31
|
-
error() {},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
logger.statusStart(waitText);
|
|
35
|
-
spinner.start();
|
|
36
|
-
const loginMethod = options.loginMethod;
|
|
37
|
-
const appId = options.appId || envUtils.getEnv(config.env.appId);
|
|
38
|
-
const token = options.token;
|
|
39
|
-
|
|
40
|
-
const apiLogin = `${config.api_domain}${config.path.login}`;
|
|
41
|
-
|
|
42
|
-
let intervalCheckLogin;
|
|
43
|
-
try {
|
|
44
|
-
spinner.start();
|
|
45
|
-
if (loginMethod === 'zalo') {
|
|
46
|
-
let zmpsk;
|
|
47
|
-
await new Promise((resolve, reject) => {
|
|
48
|
-
zaloLogin
|
|
49
|
-
.getQRCode(appId)
|
|
50
|
-
.then(function (response) {
|
|
51
|
-
//handle success
|
|
52
|
-
spinner.stop();
|
|
53
|
-
const resData = response.data;
|
|
54
|
-
if (!resData || resData.err < 0) {
|
|
55
|
-
return reject(new Error(resData.msg));
|
|
56
|
-
}
|
|
57
|
-
const loginUrl = resData.data && resData.data.loginUrl;
|
|
58
|
-
// const loginUrl = 'jaflksdjfalksdjfalksd'
|
|
59
|
-
zmpsk = resData.data && resData.data.zmpsk;
|
|
60
|
-
qrcode.generate(loginUrl, { small: true }, function (qrcode) {
|
|
61
|
-
const qrCode = `${logSymbols.info} ${chalk.bold(
|
|
62
|
-
`Scan the QR code with Zalo app:\n${qrcode}`
|
|
63
|
-
)}`;
|
|
64
|
-
logger.text(qrCode);
|
|
65
|
-
});
|
|
66
|
-
envUtils.setEnv(config.env.appId, appId);
|
|
67
|
-
return resolve();
|
|
68
|
-
})
|
|
69
|
-
.catch(function (error) {
|
|
70
|
-
//handle error
|
|
71
|
-
spinner.stop();
|
|
72
|
-
return reject(error);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
await new Promise((resolve, reject) => {
|
|
76
|
-
if (!zmpsk) return reject(new Error('Token Invalid!'));
|
|
77
|
-
let count = 0;
|
|
78
|
-
|
|
79
|
-
intervalCheckLogin = setInterval(() => {
|
|
80
|
-
logger.statusText(`${waitText} (Time out after ${60 - count}s)`);
|
|
81
|
-
if (count > 60) {
|
|
82
|
-
clearInterval(intervalCheckLogin);
|
|
83
|
-
return reject(new Error(config.error_msg.request_timeout));
|
|
84
|
-
}
|
|
85
|
-
count++;
|
|
86
|
-
zaloLogin
|
|
87
|
-
.checkStatus(zmpsk)
|
|
88
|
-
.then(function (response) {
|
|
89
|
-
//handle success
|
|
90
|
-
spinner.stop();
|
|
91
|
-
const resData = response.data;
|
|
92
|
-
if (
|
|
93
|
-
resData &&
|
|
94
|
-
resData.err === config.error_code.permission_denied
|
|
95
|
-
) {
|
|
96
|
-
clearInterval(intervalCheckLogin);
|
|
97
|
-
return reject(new Error(config.error_msg.permission_denied));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
resData &&
|
|
102
|
-
resData.err === config.error_code.request_timeout
|
|
103
|
-
) {
|
|
104
|
-
clearInterval(intervalCheckLogin);
|
|
105
|
-
return reject(new Error(config.error_msg.request_timeout));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (resData && resData.err >= 0) {
|
|
109
|
-
clearInterval(intervalCheckLogin);
|
|
110
|
-
const token = resData.data && resData.data.jwt;
|
|
111
|
-
envUtils.setEnv(config.env.token, token);
|
|
112
|
-
logger.statusDone('Login Success!');
|
|
113
|
-
return resolve();
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
.catch(function (error) {
|
|
117
|
-
//handle error
|
|
118
|
-
clearInterval(intervalCheckLogin);
|
|
119
|
-
spinner.stop();
|
|
120
|
-
return reject(error);
|
|
121
|
-
});
|
|
122
|
-
}, 2000);
|
|
123
|
-
});
|
|
124
|
-
} else {
|
|
125
|
-
await new Promise((resolve, reject) => {
|
|
126
|
-
axiosClient({
|
|
127
|
-
url: apiLogin,
|
|
128
|
-
method: 'POST',
|
|
129
|
-
headers: {
|
|
130
|
-
'cache-control': 'no-cache',
|
|
131
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
132
|
-
},
|
|
133
|
-
data: qs.stringify({
|
|
134
|
-
accessToken: token,
|
|
135
|
-
appId: appId,
|
|
136
|
-
}),
|
|
137
|
-
withCredentials: true,
|
|
138
|
-
})
|
|
139
|
-
.then(function (response) {
|
|
140
|
-
//handle success
|
|
141
|
-
spinner.stop();
|
|
142
|
-
const resData = response.data;
|
|
143
|
-
if (!resData || resData.err < 0) {
|
|
144
|
-
return reject(new Error(resData.msg));
|
|
145
|
-
}
|
|
146
|
-
const token = resData.data && resData.data.jwt;
|
|
147
|
-
try {
|
|
148
|
-
const dataDecoded = jwt.decode(token);
|
|
149
|
-
envUtils.setEnv(config.env.appId, dataDecoded.appId);
|
|
150
|
-
envUtils.setEnv(config.env.token, token);
|
|
151
|
-
} catch (error) {
|
|
152
|
-
return reject(error);
|
|
153
|
-
}
|
|
154
|
-
logger.statusDone('Login Success!');
|
|
155
|
-
return resolve();
|
|
156
|
-
})
|
|
157
|
-
.catch(function (error) {
|
|
158
|
-
//handle error
|
|
159
|
-
spinner.stop();
|
|
160
|
-
return reject(error);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
} catch (err) {
|
|
165
|
-
logger.statusError('Login failed!');
|
|
166
|
-
errorExit(err);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
1
|
+
'use strict';const _0x2d8a25=_0x2e1b;function _0x2e1b(_0x5dafbf,_0x5e891b){const _0x42d3fb=_0x42d3();return _0x2e1b=function(_0x2e1bf8,_0x2e910e){_0x2e1bf8=_0x2e1bf8-0x1de;let _0x5817c8=_0x42d3fb[_0x2e1bf8];return _0x5817c8;},_0x2e1b(_0x5dafbf,_0x5e891b);}(function(_0x3158eb,_0x3c8ef0){const _0x583fda=_0x2e1b,_0x465a8f=_0x3158eb();while(!![]){try{const _0x216c3e=parseInt(_0x583fda(0x216))/0x1*(parseInt(_0x583fda(0x217))/0x2)+parseInt(_0x583fda(0x214))/0x3+-parseInt(_0x583fda(0x1e6))/0x4*(-parseInt(_0x583fda(0x211))/0x5)+-parseInt(_0x583fda(0x1fa))/0x6+-parseInt(_0x583fda(0x1f7))/0x7*(parseInt(_0x583fda(0x201))/0x8)+parseInt(_0x583fda(0x1f8))/0x9+-parseInt(_0x583fda(0x213))/0xa;if(_0x216c3e===_0x3c8ef0)break;else _0x465a8f['push'](_0x465a8f['shift']());}catch(_0x3ad9b9){_0x465a8f['push'](_0x465a8f['shift']());}}}(_0x42d3,0x3e13a));function _0x42d3(){const _0x128aff=['bold','250eAbzTH','Scan\x20the\x20QR\x20code\x20with\x20Zalo\x20app:\x0a','5424110SRDGia','545046WSqfkR','error','262981wdhujl','2PHoGhg','../utils/env','permission_denied','zalo','./utils/zalo-login','POST','token','stop','Login\x20Success!','then','text','env','31124HvDFcK','catch','log-symbols','statusDone','info','statusText','Login\x20failed!','appId','start','gray','zmpsk','chalk','ora','Login...','error_msg','loginMethod','statusError','989023epSgzj','2409885tdfKlD','getEnv','981072EIOYDr','qrcode-terminal','decode','jwt','api_domain','stringify','setEnv','8ZbFTUF','../utils/axios','path','msg','../utils/log','data','getQRCode','error_code','exports','request_timeout','login','jsonwebtoken','err','checkStatus','../config'];_0x42d3=function(){return _0x128aff;};return _0x42d3();}const e=require(_0x2d8a25(0x1f1)),t=require(_0x2d8a25(0x1f2)),r=require(_0x2d8a25(0x20c)),a=require(_0x2d8a25(0x1fb)),n=require(_0x2d8a25(0x1e8)),o=require(_0x2d8a25(0x20f)),s=require(_0x2d8a25(0x218)),i=require(_0x2d8a25(0x205)),u=require(_0x2d8a25(0x1de)),{axiosClient:l}=require(_0x2d8a25(0x202)),c=require('qs'),d=e[_0x2d8a25(0x1ef)](_0x2d8a25(0x1f3)),p=t(d);module[_0x2d8a25(0x209)]=async(_0x42a87d={},_0x44d987,{exitOnError:_0x413683=!0x0}={})=>{const _0x5249a1=_0x2d8a25;let _0x329971;_0x44d987||(_0x44d987={'statusStart'(){},'statusDone'(){},'statusText'(){},'statusError'(){},'text'(){},'error'(){}}),_0x44d987['statusStart'](d),p[_0x5249a1(0x1ee)]();let _0x746a12=_0x42a87d[_0x5249a1(0x1f5)],_0x58b36c=_0x42a87d[_0x5249a1(0x1ed)]||s[_0x5249a1(0x1f9)](o['env'][_0x5249a1(0x1ed)]),_0x36dcd0=_0x42a87d[_0x5249a1(0x1e0)],_0x208a25=''+o[_0x5249a1(0x1fe)]+o[_0x5249a1(0x203)][_0x5249a1(0x20b)];try{if(p[_0x5249a1(0x1ee)](),_0x5249a1(0x21a)===_0x746a12){let _0x60308e;await new Promise((_0x348a57,_0x239d7c)=>{const _0xaa634a=_0x5249a1;u[_0xaa634a(0x207)](_0x58b36c)['then'](function(_0xa1dd43){const _0x10d663=_0xaa634a;p[_0x10d663(0x1e1)]();let _0x5333bf=_0xa1dd43[_0x10d663(0x206)];if(!_0x5333bf||_0x5333bf[_0x10d663(0x20d)]<0x0)return _0x239d7c(Error(_0x5333bf[_0x10d663(0x204)]));let _0x114deb=_0x5333bf[_0x10d663(0x206)]&&_0x5333bf['data']['loginUrl'];return _0x60308e=_0x5333bf[_0x10d663(0x206)]&&_0x5333bf['data'][_0x10d663(0x1f0)],a['generate'](_0x114deb,{'small':!0x0},function(_0x71b3f7){const _0x4d304c=_0x10d663;let _0x48602f=n[_0x4d304c(0x1ea)]+'\x20'+e[_0x4d304c(0x210)](_0x4d304c(0x212)+_0x71b3f7);_0x44d987[_0x4d304c(0x1e4)](_0x48602f);}),s[_0x10d663(0x200)](o[_0x10d663(0x1e5)][_0x10d663(0x1ed)],_0x58b36c),_0x348a57();})[_0xaa634a(0x1e7)](function(_0x369554){return p['stop'](),_0x239d7c(_0x369554);});}),await new Promise((_0x58c075,_0x3c3330)=>{if(!_0x60308e)return _0x3c3330(Error('Token\x20Invalid!'));let _0x1bb543=0x0;_0x329971=setInterval(()=>{const _0x1de7ad=_0x2e1b;if(_0x44d987[_0x1de7ad(0x1eb)](d+'\x20(Time\x20out\x20after\x20'+(0x3c-_0x1bb543)+'s)'),_0x1bb543>0x3c)return clearInterval(_0x329971),_0x3c3330(Error(o['error_msg'][_0x1de7ad(0x20a)]));_0x1bb543++,u[_0x1de7ad(0x20e)](_0x60308e)[_0x1de7ad(0x1e3)](function(_0x5a7941){const _0x21d1be=_0x1de7ad;p['stop']();let _0xc6fdd4=_0x5a7941[_0x21d1be(0x206)];if(_0xc6fdd4&&_0xc6fdd4[_0x21d1be(0x20d)]===o['error_code'][_0x21d1be(0x219)])return clearInterval(_0x329971),_0x3c3330(Error(o[_0x21d1be(0x1f4)]['permission_denied']));if(_0xc6fdd4&&_0xc6fdd4[_0x21d1be(0x20d)]===o[_0x21d1be(0x208)][_0x21d1be(0x20a)])return clearInterval(_0x329971),_0x3c3330(Error(o[_0x21d1be(0x1f4)][_0x21d1be(0x20a)]));if(_0xc6fdd4&&_0xc6fdd4[_0x21d1be(0x20d)]>=0x0){clearInterval(_0x329971);let _0x30c7e0=_0xc6fdd4[_0x21d1be(0x206)]&&_0xc6fdd4[_0x21d1be(0x206)][_0x21d1be(0x1fd)];return s['setEnv'](o['env'][_0x21d1be(0x1e0)],_0x30c7e0),_0x44d987[_0x21d1be(0x1e9)](_0x21d1be(0x1e2)),_0x58c075();}})[_0x1de7ad(0x1e7)](function(_0x33e1af){const _0x4ea1f7=_0x1de7ad;return clearInterval(_0x329971),p[_0x4ea1f7(0x1e1)](),_0x3c3330(_0x33e1af);});},0x7d0);});}else await new Promise((_0x231b0d,_0x2f1a6f)=>{const _0x49b742=_0x5249a1;l({'url':_0x208a25,'method':_0x49b742(0x1df),'headers':{'cache-control':'no-cache','content-type':'application/x-www-form-urlencoded'},'data':c[_0x49b742(0x1ff)]({'accessToken':_0x36dcd0,'appId':_0x58b36c}),'withCredentials':!0x0})[_0x49b742(0x1e3)](function(_0x9b6207){const _0x1f156b=_0x49b742;p['stop']();let _0x232350=_0x9b6207[_0x1f156b(0x206)];if(!_0x232350||_0x232350[_0x1f156b(0x20d)]<0x0)return _0x2f1a6f(Error(_0x232350['msg']));let _0x547e0f=_0x232350[_0x1f156b(0x206)]&&_0x232350['data']['jwt'];try{let _0x252a94=r[_0x1f156b(0x1fc)](_0x547e0f);s[_0x1f156b(0x200)](o[_0x1f156b(0x1e5)][_0x1f156b(0x1ed)],_0x252a94[_0x1f156b(0x1ed)]),s[_0x1f156b(0x200)](o[_0x1f156b(0x1e5)][_0x1f156b(0x1e0)],_0x547e0f);}catch(_0x5e9d0f){return _0x2f1a6f(_0x5e9d0f);}return _0x44d987[_0x1f156b(0x1e9)](_0x1f156b(0x1e2)),_0x231b0d();})[_0x49b742(0x1e7)](function(_0x2a0700){const _0x2271c3=_0x49b742;return p[_0x2271c3(0x1e1)](),_0x2f1a6f(_0x2a0700);});});}catch(_0x1c838a){_0x44d987[_0x5249a1(0x1f6)](_0x5249a1(0x1ec)),i[_0x5249a1(0x215)](_0x1c838a['stderr']||_0x1c838a),_0x413683&&process['exit'](0x1);return;}};
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const inquirer = require('inquirer');
|
|
3
|
-
const envUtils = require('../../utils/env');
|
|
4
|
-
const config = require('../../config');
|
|
5
|
-
|
|
6
|
-
module.exports = function getOptions() {
|
|
7
|
-
const questions = [
|
|
8
|
-
{
|
|
9
|
-
type: 'input',
|
|
10
|
-
name: 'appId',
|
|
11
|
-
message: 'Mini App ID:',
|
|
12
|
-
when: () => !envUtils.getEnv(config.env.appId),
|
|
13
|
-
validate(input) {
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
if (!input) reject(new Error('Mimi App ID is required'));
|
|
16
|
-
else resolve(true);
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: 'list',
|
|
22
|
-
name: 'loginMethod',
|
|
23
|
-
message: 'Choose a Login Method',
|
|
24
|
-
choices: [
|
|
25
|
-
{
|
|
26
|
-
name: '1. Login Via QR Code With Zalo App',
|
|
27
|
-
value: 'zalo',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: '2. Login With App Access Token',
|
|
31
|
-
value: 'accessToken',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
validate(input) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
if (!input || !input.length)
|
|
37
|
-
reject(new Error('Login method is required!'));
|
|
38
|
-
else resolve(true);
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: 'input',
|
|
44
|
-
name: 'token',
|
|
45
|
-
message: 'Zalo Access Token:',
|
|
46
|
-
when: (opts) => opts.loginMethod === 'accessToken',
|
|
47
|
-
validate(input) {
|
|
48
|
-
return new Promise((resolve, reject) => {
|
|
49
|
-
if (!input) reject(new Error('Zalo Access Token is required'));
|
|
50
|
-
else resolve(true);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
return inquirer.prompt(questions).then((options) => {
|
|
56
|
-
return Promise.resolve(options);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
1
|
+
'use strict';function _0x526c(_0x226373,_0x5e5834){const _0x2c8cda=_0x2c8c();return _0x526c=function(_0x526cee,_0x4890f0){_0x526cee=_0x526cee-0x6b;let _0x333693=_0x2c8cda[_0x526cee];return _0x333693;},_0x526c(_0x226373,_0x5e5834);}function _0x2c8c(){const _0x26b711=['Choose\x20a\x20Login\x20Method','250410AfkKNM','exports','resolve','381670YuUYwO','Zalo\x20Access\x20Token\x20is\x20required','loginMethod','343973PyIeit','list','input','Zalo\x20Access\x20Token:','3926850OYCoea','Mimi\x20App\x20ID\x20is\x20required','zalo','env','getEnv','then','../../config','appId','8HyguPR','accessToken','1.\x20Login\x20Via\x20QR\x20Code\x20With\x20Zalo\x20App','../../utils/env','inquirer','token','96VDOxzg','531194iazzlT','prompt','1384360KcnfGA','Mini\x20App\x20ID:','180OLRHjs','1151634jomNDg'];_0x2c8c=function(){return _0x26b711;};return _0x2c8c();}const _0x2561c8=_0x526c;(function(_0x137f11,_0x139cb6){const _0x3f5252=_0x526c,_0x5747e9=_0x137f11();while(!![]){try{const _0xa1ccf6=-parseInt(_0x3f5252(0x70))/0x1+parseInt(_0x3f5252(0x72))/0x2+-parseInt(_0x3f5252(0x75))/0x3+-parseInt(_0x3f5252(0x89))/0x4*(-parseInt(_0x3f5252(0x77))/0x5)+parseInt(_0x3f5252(0x81))/0x6+parseInt(_0x3f5252(0x7d))/0x7*(parseInt(_0x3f5252(0x6f))/0x8)+parseInt(_0x3f5252(0x74))/0x9*(-parseInt(_0x3f5252(0x7a))/0xa);if(_0xa1ccf6===_0x139cb6)break;else _0x5747e9['push'](_0x5747e9['shift']());}catch(_0x532273){_0x5747e9['push'](_0x5747e9['shift']());}}}(_0x2c8c,0x576bb));const e=require(_0x2561c8(0x6d)),i=require(_0x2561c8(0x6c)),o=require(_0x2561c8(0x87));module[_0x2561c8(0x78)]=function(){const _0x3b23db=_0x2561c8;let _0x3b8429=[{'type':_0x3b23db(0x7f),'name':_0x3b23db(0x88),'message':_0x3b23db(0x73),'when':()=>!i[_0x3b23db(0x85)](o[_0x3b23db(0x84)]['appId']),'validate':_0x2d288b=>new Promise((_0x20e91c,_0x1e4d39)=>{const _0x379540=_0x3b23db;_0x2d288b?_0x20e91c(!0x0):_0x1e4d39(Error(_0x379540(0x82)));})},{'type':_0x3b23db(0x7e),'name':'loginMethod','message':_0x3b23db(0x76),'choices':[{'name':_0x3b23db(0x6b),'value':_0x3b23db(0x83)},{'name':'2.\x20Login\x20With\x20App\x20Access\x20Token','value':_0x3b23db(0x8a)}],'validate':_0x1ae45a=>new Promise((_0x23a67b,_0x9abedc)=>{_0x1ae45a&&_0x1ae45a['length']?_0x23a67b(!0x0):_0x9abedc(Error('Login\x20method\x20is\x20required!'));})},{'type':_0x3b23db(0x7f),'name':_0x3b23db(0x6e),'message':_0x3b23db(0x80),'when':_0x3508ef=>_0x3b23db(0x8a)===_0x3508ef[_0x3b23db(0x7c)],'validate':_0x58b9ef=>new Promise((_0x144d1d,_0x22b0d1)=>{const _0x36af3f=_0x3b23db;_0x58b9ef?_0x144d1d(!0x0):_0x22b0d1(Error(_0x36af3f(0x7b)));})}];return e[_0x3b23db(0x71)](_0x3b8429)[_0x3b23db(0x86)](_0x36d47d=>Promise[_0x3b23db(0x79)](_0x36d47d));};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { axiosClient } = require('../../utils/axios');
|
|
3
|
-
|
|
4
|
-
module.exports = (function () {
|
|
5
|
-
const apiRequestLogin = `${config.api_domain}${config.path.requestLogin}`;
|
|
6
|
-
|
|
7
|
-
const apiCheckStatusLogin = `${config.api_domain}${config.path.checkLoginStatus}`;
|
|
8
|
-
const getQRCode = (appId) => {
|
|
9
|
-
return axiosClient({
|
|
10
|
-
method: 'get',
|
|
11
|
-
url: `${apiRequestLogin}?appId=${appId}`,
|
|
12
|
-
headers: {
|
|
13
|
-
'cache-control': 'no-cache',
|
|
14
|
-
},
|
|
15
|
-
withCredentials: true,
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const checkStatus = (zmpsk) => {
|
|
19
|
-
return axiosClient({
|
|
20
|
-
method: 'get',
|
|
21
|
-
url: `${apiCheckStatusLogin}?zmpsk=${zmpsk}`,
|
|
22
|
-
headers: {
|
|
23
|
-
'cache-control': 'no-cache',
|
|
24
|
-
},
|
|
25
|
-
withCredentials: true,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
getQRCode,
|
|
30
|
-
checkStatus,
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
1
|
+
'use strict';function _0x3c63(_0x21319a,_0x2f3322){const _0xe296b5=_0xe296();return _0x3c63=function(_0x3c637f,_0x965ff2){_0x3c637f=_0x3c637f-0x9f;let _0x395fe3=_0xe296b5[_0x3c637f];return _0x395fe3;},_0x3c63(_0x21319a,_0x2f3322);}const _0x1ee839=_0x3c63;(function(_0x3e723a,_0x1a97d1){const _0x4ea3fd=_0x3c63,_0x435fd8=_0x3e723a();while(!![]){try{const _0x4636ee=-parseInt(_0x4ea3fd(0xb0))/0x1*(parseInt(_0x4ea3fd(0xa8))/0x2)+-parseInt(_0x4ea3fd(0xab))/0x3*(-parseInt(_0x4ea3fd(0xa3))/0x4)+-parseInt(_0x4ea3fd(0xac))/0x5*(parseInt(_0x4ea3fd(0x9f))/0x6)+-parseInt(_0x4ea3fd(0xa7))/0x7*(parseInt(_0x4ea3fd(0xa6))/0x8)+parseInt(_0x4ea3fd(0xa2))/0x9*(parseInt(_0x4ea3fd(0xb2))/0xa)+-parseInt(_0x4ea3fd(0xaf))/0xb*(-parseInt(_0x4ea3fd(0xa9))/0xc)+-parseInt(_0x4ea3fd(0xaa))/0xd*(-parseInt(_0x4ea3fd(0xb1))/0xe);if(_0x4636ee===_0x1a97d1)break;else _0x435fd8['push'](_0x435fd8['shift']());}catch(_0x236b39){_0x435fd8['push'](_0x435fd8['shift']());}}}(_0xe296,0xc6049));const e=require('../../config'),{axiosClient:t}=require(_0x1ee839(0xad));module[_0x1ee839(0xa0)]=(function(){const _0x383cb2=_0x1ee839;let _0x51f018=''+e['api_domain']+e['path'][_0x383cb2(0xa4)],_0x881c53=''+e['api_domain']+e['path']['checkLoginStatus'];return{'getQRCode':_0x78a79f=>t({'method':_0x383cb2(0xa1),'url':_0x51f018+'?appId='+_0x78a79f,'headers':{'cache-control':_0x383cb2(0xa5)},'withCredentials':!0x0}),'checkStatus':_0x43bdd3=>t({'method':_0x383cb2(0xa1),'url':_0x881c53+_0x383cb2(0xae)+_0x43bdd3,'headers':{'cache-control':'no-cache'},'withCredentials':!0x0})};}());function _0xe296(){const _0x1dfb0a=['3123bRaGFo','72EeGZmD','requestLogin','no-cache','26424EpAvDR','413BqCmrE','11754rjEkFO','1303716ImXRHA','11037NWbxhU','103263FOQmay','16855Evqpeq','../../utils/axios','?zmpsk=','11geVOzP','96loLzUI','21490ITSTHL','2930exEOrn','1002AxenFV','exports','get'];_0xe296=function(){return _0x1dfb0a;};return _0xe296();}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const exec = require('exec-sh');
|
|
4
|
-
|
|
5
|
-
async function updateIcon(options) {
|
|
6
|
-
if (options.uiFramework === 'zmp-framework') {
|
|
7
|
-
fse.copyFileAsync(
|
|
8
|
-
path.resolve(__dirname, './icons.css'),
|
|
9
|
-
path.resolve(options.cwd, './src/css/icons.css')
|
|
10
|
-
);
|
|
11
|
-
await exec.promise(`npm install zmp-framework@latest`, true);
|
|
12
|
-
} else if (options.uiFramework === 'zmp-ui') {
|
|
13
|
-
await exec.promise(`npm install zmp-ui@latest`, true);
|
|
14
|
-
} else {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = updateIcon;
|
|
1
|
+
'use strict';const _0x2698b5=_0x26ff;(function(_0xffc4e3,_0x5882db){const _0x37e76b=_0x26ff,_0x5be2cf=_0xffc4e3();while(!![]){try{const _0x116b3b=-parseInt(_0x37e76b(0x1ce))/0x1*(parseInt(_0x37e76b(0x1c9))/0x2)+parseInt(_0x37e76b(0x1c2))/0x3+-parseInt(_0x37e76b(0x1d0))/0x4*(-parseInt(_0x37e76b(0x1bd))/0x5)+-parseInt(_0x37e76b(0x1b9))/0x6*(-parseInt(_0x37e76b(0x1cd))/0x7)+parseInt(_0x37e76b(0x1bb))/0x8*(-parseInt(_0x37e76b(0x1c1))/0x9)+parseInt(_0x37e76b(0x1cb))/0xa*(-parseInt(_0x37e76b(0x1cf))/0xb)+parseInt(_0x37e76b(0x1cc))/0xc;if(_0x116b3b===_0x5882db)break;else _0x5be2cf['push'](_0x5be2cf['shift']());}catch(_0x402c16){_0x5be2cf['push'](_0x5be2cf['shift']());}}}(_0x3325,0x9d293));function _0x26ff(_0x511ffc,_0x39c7ed){const _0x332536=_0x3325();return _0x26ff=function(_0x26ff00,_0x1eed17){_0x26ff00=_0x26ff00-0x1b8;let _0x46623b=_0x332536[_0x26ff00];return _0x46623b;},_0x26ff(_0x511ffc,_0x39c7ed);}const e=require(_0x2698b5(0x1bc)),s=require(_0x2698b5(0x1b8)),r=require(_0x2698b5(0x1d1));function _0x3325(){const _0x5efb9f=['2524191GuMyne','./src/css/icons.css','copyFileAsync','promise','uiFramework','zmp-ui','./icons.css','265852xTuaTw','exports','40gxvPVs','16195800oRUxhx','2083151TOyobw','7aHuIeU','2944359sEnmxy','4lWerlj','exec-sh','path','6tOzhqO','zmp-framework','54880fkZEWp','../../utils/fs-extra','2359045LPIcRC','resolve','npm\x20install\x20zmp-framework@latest','npm\x20install\x20zmp-ui@latest','414hqPfSy'];_0x3325=function(){return _0x5efb9f;};return _0x3325();}async function i(_0x266986){const _0x56ddfd=_0x2698b5;if(_0x56ddfd(0x1ba)===_0x266986[_0x56ddfd(0x1c6)])e[_0x56ddfd(0x1c4)](s['resolve'](__dirname,_0x56ddfd(0x1c8)),s[_0x56ddfd(0x1be)](_0x266986['cwd'],_0x56ddfd(0x1c3))),await r[_0x56ddfd(0x1c5)](_0x56ddfd(0x1bf),!0x0);else{if(_0x56ddfd(0x1c7)!==_0x266986[_0x56ddfd(0x1c6)])return;await r[_0x56ddfd(0x1c5)](_0x56ddfd(0x1c0),!0x0);}}module[_0x2698b5(0x1ca)]=i;
|