zmp-cli 3.15.5 → 3.15.6-beta.1
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 -148
- 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/utils/dist/get-options.dev.js +0 -277
- package/deploy/dist/index.dev.js +0 -227
- package/dist/index.dev.js +0 -352
- package/jsconfig.json +0 -8
- package/login/dist/index.dev.js +0 -223
- 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 _0x55679e=_0xe9a6;(function(_0x398670,_0x5ee62d){const _0x424818=_0xe9a6,_0x303747=_0x398670();while(!![]){try{const _0x46a939=parseInt(_0x424818(0x240))/0x1+-parseInt(_0x424818(0x204))/0x2*(-parseInt(_0x424818(0x221))/0x3)+-parseInt(_0x424818(0x226))/0x4*(parseInt(_0x424818(0x212))/0x5)+-parseInt(_0x424818(0x23a))/0x6+-parseInt(_0x424818(0x214))/0x7+-parseInt(_0x424818(0x21e))/0x8*(parseInt(_0x424818(0x227))/0x9)+parseInt(_0x424818(0x1f7))/0xa;if(_0x46a939===_0x5ee62d)break;else _0x303747['push'](_0x303747['shift']());}catch(_0x2484ac){_0x303747['push'](_0x303747['shift']());}}}(_0x3c1b,0xcace7));function _0x3c1b(){const _0x237b3b=['error','-e,\x20--existing','226aPKtho','./migrate/utils/get-options','command','testing','iosHostName','mode','length','Run\x20without\x20Zalo\x20frame','start','log','deploy','./utils/log','description','parse','1722190OnLpox','cwd','7998886iqZoSD','Version:\x20','hostname','cyan','\x0a\x20Unknown\x20command\x20','./utils/fs-extra','outputHelp','./create/utils/get-options','text','root_env','40mQekOm','./deploy/index','existing','9uddmXS','frame','NW.js\x20module\x20is\x20not\x20found.\x20Please\x20run\x20\x22npm\x20install\x20-g\x20nw@sdk\x22','-M,\x20--mode\x20<m>','-nF,\x20--no-frame','8dqxWSu','1594224NOlPtG','customProject','textSync','dev','-P,\x20--port\x20<n>','versionStatus','./build/index','./login/utils/get-options','-D,\x20--device','exit','.local','build','includes','Specify\x20UI\x20server\x20port.\x20By\x20default\x20it\x20is\x203001','zaloApp','writeFileSync','version','Version\x20description','Preview\x20on\x20Zalo','8627112GbzJWJ','-Z,\x20--zalo-app','./utils/check-update','./login/index','showMobileUi','<command>\x20[options]','115300yWTiKz','usage','done','Deploy\x20a\x20ZMP\x20project','-iosH,\x20--ios-host-name\x20<n>','./start/index','Run\x20on\x20ios','passive','-r,\x20--root-element\x20<selector>','Deploy\x20in\x20Development\x20server','./utils/get-current-project','-o,\x20--outputDir\x20<output>','Specify\x20server\x20port.\x20By\x20default\x20it\x20is\x203000','figlet','commander','migrate','-p,\x20--passive','code','\x20This\x20is\x20not\x20ZMP\x20project','Specify\x20server\x20hostname.\x20By\x20default\x20it\x20is\x20os.hostname','existsSync','init','full','Device\x20mode','clear','device','Start\x20a\x20ZMP\x20project','argv','Automatically\x20update\x20app-config.json\x20resources\x20list\x20based\x20on\x20index.html','resolve','48701620reqkLX','Deploy\x20existing\x20project','./config','action','Build\x20a\x20ZMP\x20project','chalk','./package.json','sync-config\x20<source>','./sync/index','option','Env\x20mode'];_0x3c1b=function(){return _0x237b3b;};return _0x3c1b();}function _0xe9a6(_0x3dd45e,_0x3e1b29){const _0x3c1b94=_0x3c1b();return _0xe9a6=function(_0xe9a65c,_0x1288d7){_0xe9a65c=_0xe9a65c-0x1de;let _0x325e28=_0x3c1b94[_0xe9a65c];return _0x325e28;},_0xe9a6(_0x3dd45e,_0x3e1b29);}const e=require(_0x55679e(0x1fc)),o=require(_0x55679e(0x1f1)),t=require(_0x55679e(0x1e6)),i=require(_0x55679e(0x1e7)),r=require('log-symbols'),s=require(_0x55679e(0x219)),n=require(_0x55679e(0x23c)),a=require('./utils/spinner'),c=require(_0x55679e(0x20f)),p=require(_0x55679e(0x1e3)),u=require(_0x55679e(0x21b)),l=require(_0x55679e(0x22e)),d=require('./deploy/utils/get-options'),m=require(_0x55679e(0x205)),g=require(_0x55679e(0x23d)),x=require('./create/index'),y=require(_0x55679e(0x1de)),v=require(_0x55679e(0x22d)),w=require(_0x55679e(0x21f)),f=require(_0x55679e(0x1ff)),q=require('./migrate/index'),h=require('os'),M=require(_0x55679e(0x1fd)),P=require(_0x55679e(0x1f9)),{versionStatus:j}=require('./utils/constants'),Z=process[_0x55679e(0x213)](),D={'statusStart':_0x461e78=>a[_0x55679e(0x20c)](_0x461e78),'statusDone':_0x41519a=>a[_0x55679e(0x242)](_0x41519a),'statusText':_0x1c318d=>a['text'](_0x1c318d),'statusError':_0x48b267=>a[_0x55679e(0x202)](_0x48b267),'text':_0x4bac89=>c[_0x55679e(0x21c)](_0x4bac89),'error':_0x4bb9d8=>c[_0x55679e(0x202)](_0x4bb9d8),'showOnUI':()=>{}};o(),s[_0x55679e(0x1ed)](P[_0x55679e(0x21d)]())||s[_0x55679e(0x236)](P[_0x55679e(0x21d)]()),console[_0x55679e(0x20d)](e[_0x55679e(0x217)](t[_0x55679e(0x229)]('ZMP\x20CLI',{'horizontalLayout':'full','verticalLayout':_0x55679e(0x1ef)})),e[_0x55679e(0x217)](_0x55679e(0x215)+M[_0x55679e(0x237)]+'\x0a')),i[_0x55679e(0x237)](M[_0x55679e(0x237)])[_0x55679e(0x241)](_0x55679e(0x23f))[_0x55679e(0x206)](_0x55679e(0x1ee))[_0x55679e(0x200)]('--skipUpdate','Skip\x20checking\x20for\x20update\x20of\x20zmp-cli')['description']('Init\x20ZMP\x20project')[_0x55679e(0x1fa)](async _0x39c512=>{const _0x2c65ac=_0x55679e;_0x39c512['skipUpdate']||await n(),p(Z)&&(c[_0x2c65ac(0x21c)](r[_0x2c65ac(0x202)]+'\x20ZMP\x20project\x20already\x20set\x20up\x20in\x20current\x20directory'),process[_0x2c65ac(0x230)](0x1));let _0x1a2a1d=await l();await g({'cwd':Z,..._0x1a2a1d},D);let _0x55328c=await u();await x({'cwd':Z,..._0x55328c},D),process['exit'](0x0);}),i[_0x55679e(0x241)](_0x55679e(0x23f))['command']('login')[_0x55679e(0x210)]('Login\x20ZMP')[_0x55679e(0x1fa)](async()=>{let _0x356df4=await l();await g({'cwd':Z,..._0x356df4},D),process['exit'](0x0);}),i['usage'](_0x55679e(0x23f))[_0x55679e(0x206)](_0x55679e(0x20c))[_0x55679e(0x200)](_0x55679e(0x244),_0x55679e(0x1ec))['option'](_0x55679e(0x22b),_0x55679e(0x1e5),parseInt)['option'](_0x55679e(0x23b),_0x55679e(0x239))[_0x55679e(0x200)]('-ios,\x20--ios',_0x55679e(0x1df))['option'](_0x55679e(0x225),_0x55679e(0x20b))[_0x55679e(0x200)](_0x55679e(0x22f),_0x55679e(0x1f0))['option'](_0x55679e(0x224),_0x55679e(0x201))[_0x55679e(0x210)](_0x55679e(0x1f3))[_0x55679e(0x1fa)](async _0x3de003=>{const _0x52c4fd=_0x55679e;if(p(Z)||(c['text'](r[_0x52c4fd(0x202)]+_0x52c4fd(0x1eb)),process[_0x52c4fd(0x230)](0x1)),_0x3de003&&_0x3de003[_0x52c4fd(0x23e)])try{console[_0x52c4fd(0x20d)](require[_0x52c4fd(0x1f6)]('nw'));}catch(_0x231442){console[_0x52c4fd(0x202)](_0x52c4fd(0x223)),process['exit'](_0x231442[_0x52c4fd(0x1ea)]);}let _0x68249b=h[_0x52c4fd(0x216)]();_0x68249b[_0x52c4fd(0x233)]('.local')||(_0x68249b=_0x68249b+_0x52c4fd(0x231)),await y({'cwd':Z,'port':_0x3de003&&_0x3de003['port']||0xbb8,'iosHostName':_0x3de003&&_0x3de003[_0x52c4fd(0x208)]||_0x68249b,'showMobileUI':_0x3de003&&_0x3de003[_0x52c4fd(0x23e)]||!0x1,'previewOnZalo':_0x3de003&&_0x3de003[_0x52c4fd(0x235)]||!0x1,'ios':_0x3de003&&_0x3de003['ios']||!0x1,'mode':_0x3de003&&_0x3de003[_0x52c4fd(0x209)],'frame':!!_0x3de003&&(void 0x0===_0x3de003[_0x52c4fd(0x222)]||null===_0x3de003[_0x52c4fd(0x222)])||_0x3de003['frame'],'deviceMode':_0x3de003&&_0x3de003[_0x52c4fd(0x1f2)]||!0x1},D),process['exit'](0x0);}),i[_0x55679e(0x241)]('<command>\x20[options]')[_0x55679e(0x206)](_0x55679e(0x232))['description'](_0x55679e(0x1fb))[_0x55679e(0x1fa)](async()=>{const _0x309296=_0x55679e;p(Z)||(c[_0x309296(0x21c)](r['error']+_0x309296(0x1eb)),process['exit'](0x1)),await v({'cwd':Z},D),process['exit'](0x0);}),i[_0x55679e(0x241)](_0x55679e(0x23f))[_0x55679e(0x206)](_0x55679e(0x20e))[_0x55679e(0x200)]('-D,\x20--dev',_0x55679e(0x1e2))['option'](_0x55679e(0x224),_0x55679e(0x201))['option'](_0x55679e(0x1e9),'Passive\x20mode\x20(non-interactive)')[_0x55679e(0x200)](_0x55679e(0x203),_0x55679e(0x1f8))['option']('-t,\x20--testing','Deploy\x20testing\x20version')[_0x55679e(0x200)]('-m,\x20--desc\x20<message>',_0x55679e(0x238))[_0x55679e(0x200)](_0x55679e(0x1e4),'Output\x20folder.\x20Default\x20www')[_0x55679e(0x200)](_0x55679e(0x22b),_0x55679e(0x234),parseInt)['description'](_0x55679e(0x243))['action'](async _0x2d6dfb=>{const _0x574fde=_0x55679e;let _0x2e9f0f=p(Z),_0x4c10cd=_0x2d6dfb;_0x2d6dfb[_0x574fde(0x220)]?_0x4c10cd[_0x574fde(0x228)]=!0x0:_0x2d6dfb[_0x574fde(0x1e0)]||(_0x4c10cd=await d(_0x2e9f0f)),_0x2d6dfb[_0x574fde(0x207)]&&(_0x4c10cd[_0x574fde(0x22c)]=j['TESTING']),_0x4c10cd['quit']&&process[_0x574fde(0x230)](0x1),await w({'cwd':Z,'dev':_0x2d6dfb&&_0x2d6dfb[_0x574fde(0x22a)],'mode':_0x2d6dfb&&_0x2d6dfb[_0x574fde(0x209)],..._0x4c10cd},D),process[_0x574fde(0x230)](0x0);}),i[_0x55679e(0x241)](_0x55679e(0x23f))[_0x55679e(0x206)](_0x55679e(0x1fe))['option'](_0x55679e(0x1e1),'Custom\x20entry\x20point,\x20default\x20is\x20#app')['description'](_0x55679e(0x1f5))[_0x55679e(0x1fa)](async(_0x4cc8cd,_0x1e8a2b)=>{const _0x3aebc5=_0x55679e;await f({'source':_0x4cc8cd,..._0x1e8a2b},D),process[_0x3aebc5(0x230)](0x0);}),i[_0x55679e(0x241)](_0x55679e(0x23f))['command'](_0x55679e(0x1e8))[_0x55679e(0x1fa)](async function(){const _0x56376e=_0x55679e;let _0x5dedf7=p(Z);_0x5dedf7||(D['text'](r[_0x56376e(0x202)]+_0x56376e(0x1eb)),process[_0x56376e(0x230)](0x1));let _0x168856=await m();await q({'cwd':Z,..._0x168856,..._0x5dedf7},D),process[_0x56376e(0x230)](0x0);}),i['on']('command:*',_0x55ea68=>{const _0x4ebd43=_0x55679e;i[_0x4ebd43(0x21a)](),c[_0x4ebd43(0x21c)](_0x4ebd43(0x218)+_0x55ea68);}),i[_0x55679e(0x211)](process[_0x55679e(0x1f4)]),i['args'][_0x55679e(0x20a)]||i[_0x55679e(0x21a)]();
|
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';function _0x14ee(_0x48577e,_0xa4700){const _0x515ac3=_0x515a();return _0x14ee=function(_0x14eeea,_0x6d8c46){_0x14eeea=_0x14eeea-0x194;let _0x29411c=_0x515ac3[_0x14eeea];return _0x29411c;},_0x14ee(_0x48577e,_0xa4700);}const _0x153be6=_0x14ee;(function(_0x41f2ea,_0x4df51c){const _0x3faacd=_0x14ee,_0x13e982=_0x41f2ea();while(!![]){try{const _0x384ae0=-parseInt(_0x3faacd(0x19f))/0x1+-parseInt(_0x3faacd(0x1c0))/0x2+parseInt(_0x3faacd(0x198))/0x3+-parseInt(_0x3faacd(0x1b7))/0x4+-parseInt(_0x3faacd(0x1c2))/0x5+parseInt(_0x3faacd(0x1c1))/0x6+parseInt(_0x3faacd(0x1bb))/0x7;if(_0x384ae0===_0x4df51c)break;else _0x13e982['push'](_0x13e982['shift']());}catch(_0x21757a){_0x13e982['push'](_0x13e982['shift']());}}}(_0x515a,0xe9ece));const e=require(_0x153be6(0x199)),t=require('ora'),r=require(_0x153be6(0x1be)),a=require(_0x153be6(0x19d)),n=require(_0x153be6(0x1c9)),o=require(_0x153be6(0x1cc)),s=require(_0x153be6(0x1a6)),i=require(_0x153be6(0x1ab)),u=require('./utils/zalo-login'),{axiosClient:l}=require('../utils/axios'),c=require('qs'),d=e['gray'](_0x153be6(0x1bf)),p=t(d);module[_0x153be6(0x1bd)]=async(_0x4a100d={},_0x4bea45,{exitOnError:_0x37cbdb=!0x0}={})=>{const _0x4c9eda=_0x153be6;let _0x1b8b46;_0x4bea45||(_0x4bea45={'statusStart'(){},'statusDone'(){},'statusText'(){},'statusError'(){},'text'(){},'error'(){}}),_0x4bea45[_0x4c9eda(0x1ce)](d),p[_0x4c9eda(0x1ca)]();let _0x1ddc66=_0x4a100d[_0x4c9eda(0x195)],_0x37f83a=_0x4a100d[_0x4c9eda(0x1b9)]||s[_0x4c9eda(0x1c7)](o['env'][_0x4c9eda(0x1b9)]),_0x475085=_0x4a100d[_0x4c9eda(0x19a)],_0x2cda72=''+o['api_domain']+o[_0x4c9eda(0x1af)][_0x4c9eda(0x1ac)];try{if(p[_0x4c9eda(0x1ca)](),_0x4c9eda(0x1cb)===_0x1ddc66){let _0x284858;await new Promise((_0x4df8ea,_0x14c31e)=>{const _0x45bc58=_0x4c9eda;u[_0x45bc58(0x19e)](_0x37f83a)['then'](function(_0x33d88a){const _0x20cf2d=_0x45bc58;p[_0x20cf2d(0x1a7)]();let _0x39187e=_0x33d88a[_0x20cf2d(0x1c3)];if(!_0x39187e||_0x39187e['err']<0x0)return _0x14c31e(Error(_0x39187e[_0x20cf2d(0x1bc)]));let _0x43451a=_0x39187e[_0x20cf2d(0x1c3)]&&_0x39187e[_0x20cf2d(0x1c3)][_0x20cf2d(0x1ae)];return _0x284858=_0x39187e['data']&&_0x39187e[_0x20cf2d(0x1c3)][_0x20cf2d(0x1b3)],a[_0x20cf2d(0x1c4)](_0x43451a,{'small':!0x0},function(_0x191dfb){const _0x327283=_0x20cf2d;let _0x140e97=n['info']+'\x20'+e[_0x327283(0x19c)](_0x327283(0x1a1)+_0x191dfb);_0x4bea45[_0x327283(0x1aa)](_0x140e97);}),s[_0x20cf2d(0x196)](o[_0x20cf2d(0x1b6)][_0x20cf2d(0x1b9)],_0x37f83a),_0x4df8ea();})[_0x45bc58(0x1b1)](function(_0x17072e){const _0x4c320f=_0x45bc58;return p[_0x4c320f(0x1a7)](),_0x14c31e(_0x17072e);});}),await new Promise((_0x46cd8c,_0x5a45b1)=>{const _0x5903ee=_0x4c9eda;if(!_0x284858)return _0x5a45b1(Error(_0x5903ee(0x1a5)));let _0x96030e=0x0;_0x1b8b46=setInterval(()=>{const _0x3245b4=_0x5903ee;if(_0x4bea45[_0x3245b4(0x1b8)](d+'\x20(Time\x20out\x20after\x20'+(0x3c-_0x96030e)+'s)'),_0x96030e>0x3c)return clearInterval(_0x1b8b46),_0x5a45b1(Error(o[_0x3245b4(0x1a3)][_0x3245b4(0x1a0)]));_0x96030e++,u[_0x3245b4(0x1a2)](_0x284858)[_0x3245b4(0x19b)](function(_0x32153b){const _0x1cb696=_0x3245b4;p[_0x1cb696(0x1a7)]();let _0x1aaf83=_0x32153b[_0x1cb696(0x1c3)];if(_0x1aaf83&&_0x1aaf83[_0x1cb696(0x1a4)]===o[_0x1cb696(0x1cd)]['permission_denied'])return clearInterval(_0x1b8b46),_0x5a45b1(Error(o[_0x1cb696(0x1a3)][_0x1cb696(0x1a8)]));if(_0x1aaf83&&_0x1aaf83[_0x1cb696(0x1a4)]===o['error_code'][_0x1cb696(0x1a0)])return clearInterval(_0x1b8b46),_0x5a45b1(Error(o[_0x1cb696(0x1a3)][_0x1cb696(0x1a0)]));if(_0x1aaf83&&_0x1aaf83[_0x1cb696(0x1a4)]>=0x0){clearInterval(_0x1b8b46);let _0x55562c=_0x1aaf83[_0x1cb696(0x1c3)]&&_0x1aaf83['data'][_0x1cb696(0x1ad)];return s[_0x1cb696(0x196)](o[_0x1cb696(0x1b6)][_0x1cb696(0x19a)],_0x55562c),_0x4bea45[_0x1cb696(0x1b2)]('Login\x20Success!'),_0x46cd8c();}})[_0x3245b4(0x1b1)](function(_0x3eca70){const _0xd40da8=_0x3245b4;return clearInterval(_0x1b8b46),p[_0xd40da8(0x1a7)](),_0x5a45b1(_0x3eca70);});},0x7d0);});}else await new Promise((_0x456a88,_0x4d7312)=>{const _0xbc17cf=_0x4c9eda;l({'url':_0x2cda72,'method':_0xbc17cf(0x1ba),'headers':{'cache-control':'no-cache','content-type':_0xbc17cf(0x1b5)},'data':c[_0xbc17cf(0x1b4)]({'accessToken':_0x475085,'appId':_0x37f83a}),'withCredentials':!0x0})[_0xbc17cf(0x19b)](function(_0x216dd6){const _0x54ea4c=_0xbc17cf;p[_0x54ea4c(0x1a7)]();let _0x491046=_0x216dd6['data'];if(!_0x491046||_0x491046['err']<0x0)return _0x4d7312(Error(_0x491046[_0x54ea4c(0x1bc)]));let _0x50ecd2=_0x491046[_0x54ea4c(0x1c3)]&&_0x491046[_0x54ea4c(0x1c3)]['jwt'];try{let _0x56526c=r[_0x54ea4c(0x1c5)](_0x50ecd2);s[_0x54ea4c(0x196)](o[_0x54ea4c(0x1b6)][_0x54ea4c(0x1b9)],_0x56526c[_0x54ea4c(0x1b9)]),s[_0x54ea4c(0x196)](o[_0x54ea4c(0x1b6)]['token'],_0x50ecd2);}catch(_0x34b39b){return _0x4d7312(_0x34b39b);}return _0x4bea45['statusDone'](_0x54ea4c(0x194)),_0x456a88();})[_0xbc17cf(0x1b1)](function(_0x49a38d){return p['stop'](),_0x4d7312(_0x49a38d);});});}catch(_0x44d701){_0x4bea45[_0x4c9eda(0x1a9)](_0x4c9eda(0x1b0)),i[_0x4c9eda(0x197)](_0x44d701[_0x4c9eda(0x1c6)]||_0x44d701),_0x37cbdb&&process[_0x4c9eda(0x1c8)](0x1);return;}};function _0x515a(){const _0x1ddaff=['statusDone','zmpsk','stringify','application/x-www-form-urlencoded','env','2552988oRegBE','statusText','appId','POST','31481695wLGQec','msg','exports','jsonwebtoken','Login...','3722242vEOIYj','6992244ZPdqbE','8440560aiNlSD','data','generate','decode','stderr','getEnv','exit','log-symbols','start','zalo','../config','error_code','statusStart','Login\x20Success!','loginMethod','setEnv','error','1479777zaEHJL','chalk','token','then','bold','qrcode-terminal','getQRCode','1010380QKLSPi','request_timeout','Scan\x20the\x20QR\x20code\x20with\x20Zalo\x20app:\x0a','checkStatus','error_msg','err','Token\x20Invalid!','../utils/env','stop','permission_denied','statusError','text','../utils/log','login','jwt','loginUrl','path','Login\x20failed!','catch'];_0x515a=function(){return _0x1ddaff;};return _0x515a();}
|
|
@@ -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';const _0x42ca6b=_0x584c;(function(_0x1441c3,_0x3a8d61){const _0x10afd4=_0x584c,_0x45fc32=_0x1441c3();while(!![]){try{const _0x28a782=parseInt(_0x10afd4(0xe4))/0x1+-parseInt(_0x10afd4(0xf9))/0x2*(parseInt(_0x10afd4(0xef))/0x3)+parseInt(_0x10afd4(0xe8))/0x4+parseInt(_0x10afd4(0xf0))/0x5+parseInt(_0x10afd4(0xeb))/0x6+parseInt(_0x10afd4(0xdf))/0x7*(parseInt(_0x10afd4(0xe2))/0x8)+parseInt(_0x10afd4(0xe7))/0x9*(-parseInt(_0x10afd4(0xf2))/0xa);if(_0x28a782===_0x3a8d61)break;else _0x45fc32['push'](_0x45fc32['shift']());}catch(_0x49317e){_0x45fc32['push'](_0x45fc32['shift']());}}}(_0x124a,0xd36e6));function _0x584c(_0x27a8e9,_0x44a997){const _0x124a07=_0x124a();return _0x584c=function(_0x584c40,_0x586f37){_0x584c40=_0x584c40-0xda;let _0x406167=_0x124a07[_0x584c40];return _0x406167;},_0x584c(_0x27a8e9,_0x44a997);}const e=require(_0x42ca6b(0xda)),i=require(_0x42ca6b(0xf7)),o=require(_0x42ca6b(0xde));function _0x124a(){const _0x242428=['9IOJhOf','6234968gfnyUK','1.\x20Login\x20Via\x20QR\x20Code\x20With\x20Zalo\x20App','Zalo\x20Access\x20Token\x20is\x20required','4515858ULhxkS','Mimi\x20App\x20ID\x20is\x20required','Choose\x20a\x20Login\x20Method','getEnv','3284535ipoFcO','7581020aahnhx','Mini\x20App\x20ID:','24555830KSjjPE','appId','Zalo\x20Access\x20Token:','prompt','loginMethod','../../utils/env','then','2yCMEGJ','accessToken','Login\x20method\x20is\x20required!','inquirer','2.\x20Login\x20With\x20App\x20Access\x20Token','env','zalo','../../config','371SraukJ','exports','length','28112NXyOWM','input','402619kGwRKG','token','list'];_0x124a=function(){return _0x242428;};return _0x124a();}module[_0x42ca6b(0xe0)]=function(){const _0x554c64=_0x42ca6b;let _0xd1da8a=[{'type':_0x554c64(0xe3),'name':_0x554c64(0xf3),'message':_0x554c64(0xf1),'when':()=>!i[_0x554c64(0xee)](o[_0x554c64(0xdc)][_0x554c64(0xf3)]),'validate':_0x58ebc4=>new Promise((_0x14d32e,_0x41f4a9)=>{const _0x22a849=_0x554c64;_0x58ebc4?_0x14d32e(!0x0):_0x41f4a9(Error(_0x22a849(0xec)));})},{'type':_0x554c64(0xe6),'name':_0x554c64(0xf6),'message':_0x554c64(0xed),'choices':[{'name':_0x554c64(0xe9),'value':_0x554c64(0xdd)},{'name':_0x554c64(0xdb),'value':_0x554c64(0xfa)}],'validate':_0xe7f16c=>new Promise((_0x7b0208,_0x56e433)=>{const _0x232b65=_0x554c64;_0xe7f16c&&_0xe7f16c[_0x232b65(0xe1)]?_0x7b0208(!0x0):_0x56e433(Error(_0x232b65(0xfb)));})},{'type':_0x554c64(0xe3),'name':_0x554c64(0xe5),'message':_0x554c64(0xf4),'when':_0x67ab86=>_0x554c64(0xfa)===_0x67ab86[_0x554c64(0xf6)],'validate':_0x47cd0b=>new Promise((_0x4839b4,_0x473cde)=>{const _0x29b4a1=_0x554c64;_0x47cd0b?_0x4839b4(!0x0):_0x473cde(Error(_0x29b4a1(0xea)));})}];return e[_0x554c64(0xf5)](_0xd1da8a)[_0x554c64(0xf8)](_0x38406a=>Promise['resolve'](_0x38406a));};
|
|
@@ -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';const _0x4aad71=_0x4dcf;function _0x4dcf(_0x3d72f4,_0x4e2133){const _0x5f38fe=_0x5f38();return _0x4dcf=function(_0x4dcf9b,_0x3ca16f){_0x4dcf9b=_0x4dcf9b-0x11d;let _0x4c45bd=_0x5f38fe[_0x4dcf9b];return _0x4c45bd;},_0x4dcf(_0x3d72f4,_0x4e2133);}(function(_0x133006,_0x5a9b61){const _0x5242ca=_0x4dcf,_0x3dc256=_0x133006();while(!![]){try{const _0x11ea52=parseInt(_0x5242ca(0x11e))/0x1*(parseInt(_0x5242ca(0x131))/0x2)+parseInt(_0x5242ca(0x12a))/0x3*(parseInt(_0x5242ca(0x12b))/0x4)+parseInt(_0x5242ca(0x122))/0x5*(-parseInt(_0x5242ca(0x130))/0x6)+parseInt(_0x5242ca(0x133))/0x7*(parseInt(_0x5242ca(0x128))/0x8)+-parseInt(_0x5242ca(0x120))/0x9*(-parseInt(_0x5242ca(0x124))/0xa)+parseInt(_0x5242ca(0x129))/0xb+-parseInt(_0x5242ca(0x11f))/0xc*(parseInt(_0x5242ca(0x12d))/0xd);if(_0x11ea52===_0x5a9b61)break;else _0x3dc256['push'](_0x3dc256['shift']());}catch(_0x12ca5a){_0x3dc256['push'](_0x3dc256['shift']());}}}(_0x5f38,0xe3dce));function _0x5f38(){const _0xb2bcb6=['requestLogin','2079uFbQsr','?appId=','255181Fpibpw','24301932DntPEe','36VjLMRn','checkLoginStatus','1525615fLCEyp','get','1136830loaMpV','exports','api_domain','no-cache','38392mJJOPt','19149559LXxoWl','3GBNxUd','6449816feaquG','?zmpsk=','26LgkkRf','../../utils/axios','path','30yzfuxA','10JNODLX'];_0x5f38=function(){return _0xb2bcb6;};return _0x5f38();}const e=require('../../config'),{axiosClient:t}=require(_0x4aad71(0x12e));module[_0x4aad71(0x125)]=(function(){const _0x181f38=_0x4aad71;let _0x375711=''+e[_0x181f38(0x126)]+e[_0x181f38(0x12f)][_0x181f38(0x132)],_0x1ab7d0=''+e['api_domain']+e['path'][_0x181f38(0x121)];return{'getQRCode':_0x380b8f=>t({'method':_0x181f38(0x123),'url':_0x375711+_0x181f38(0x11d)+_0x380b8f,'headers':{'cache-control':_0x181f38(0x127)},'withCredentials':!0x0}),'checkStatus':_0x3d67f8=>t({'method':'get','url':_0x1ab7d0+_0x181f38(0x12c)+_0x3d67f8,'headers':{'cache-control':'no-cache'},'withCredentials':!0x0})};}());
|
|
@@ -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 _0x344a76=_0x3f56;function _0x160f(){const _0x328372=['1007757mRGimw','zmp-ui','20XyRuPK','72926kRoVBF','101950VtyqbY','978096rihZoL','40iXSIMH','exec-sh','4149Dkloca','zmp-framework','promise','738XEOEQp','npm\x20install\x20zmp-ui@latest','uiFramework','1432wPxbPp','npm\x20install\x20zmp-framework@latest','96296OycAWk','resolve','./src/css/icons.css','copyFileAsync','./icons.css','path','../../utils/fs-extra','245655oLdOGf','cwd','583RQBQIH'];_0x160f=function(){return _0x328372;};return _0x160f();}(function(_0x1d593c,_0x167218){const _0x56f092=_0x3f56,_0x41c311=_0x1d593c();while(!![]){try{const _0x22be87=parseInt(_0x56f092(0x100))/0x1*(parseInt(_0x56f092(0x10e))/0x2)+-parseInt(_0x56f092(0xfe))/0x3+parseInt(_0x56f092(0x104))/0x4*(-parseInt(_0x56f092(0xfb))/0x5)+-parseInt(_0x56f092(0x109))/0x6*(-parseInt(_0x56f092(0x101))/0x7)+-parseInt(_0x56f092(0x10c))/0x8*(parseInt(_0x56f092(0x106))/0x9)+parseInt(_0x56f092(0x102))/0xa*(-parseInt(_0x56f092(0xfd))/0xb)+-parseInt(_0x56f092(0x103))/0xc;if(_0x22be87===_0x167218)break;else _0x41c311['push'](_0x41c311['shift']());}catch(_0x200679){_0x41c311['push'](_0x41c311['shift']());}}}(_0x160f,0xae04f));const e=require(_0x344a76(0x114)),s=require(_0x344a76(0x113)),r=require(_0x344a76(0x105));function _0x3f56(_0x3236e6,_0x1f53e8){const _0x160f1c=_0x160f();return _0x3f56=function(_0x3f5657,_0x10a73a){_0x3f5657=_0x3f5657-0xfb;let _0xdf2cfc=_0x160f1c[_0x3f5657];return _0xdf2cfc;},_0x3f56(_0x3236e6,_0x1f53e8);}async function i(_0x1a052b){const _0x93598a=_0x344a76;if(_0x93598a(0x107)===_0x1a052b[_0x93598a(0x10b)])e[_0x93598a(0x111)](s[_0x93598a(0x10f)](__dirname,_0x93598a(0x112)),s['resolve'](_0x1a052b[_0x93598a(0xfc)],_0x93598a(0x110))),await r[_0x93598a(0x108)](_0x93598a(0x10d),!0x0);else{if(_0x93598a(0xff)!==_0x1a052b[_0x93598a(0x10b)])return;await r[_0x93598a(0x108)](_0x93598a(0x10a),!0x0);}}module['exports']=i;
|