aiot-toolkit 1.0.20-importfile-dev.2 → 2.0.1-alpha.10
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 +26 -192
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +148 -0
- package/lib/bin.js.map +1 -0
- package/lib/builder/IBuilder.d.ts +22 -0
- package/lib/builder/IBuilder.js +4 -0
- package/lib/builder/IBuilder.js.map +1 -0
- package/lib/builder/UxBuilder.d.ts +26 -0
- package/lib/builder/UxBuilder.js +102 -0
- package/lib/builder/UxBuilder.js.map +1 -0
- package/lib/builder/XtsBuilder.d.ts +16 -0
- package/lib/builder/XtsBuilder.js +100 -0
- package/lib/builder/XtsBuilder.js.map +1 -0
- package/lib/interface/CommandInterface.d.ts +15 -0
- package/lib/interface/CommandInterface.js +4 -0
- package/lib/interface/CommandInterface.js.map +1 -0
- package/lib/interface/VelaEmulatorInterface.d.ts +8 -0
- package/lib/interface/VelaEmulatorInterface.js +4 -0
- package/lib/interface/VelaEmulatorInterface.js.map +1 -0
- package/lib/starter/GoldfishStarter.d.ts +9 -0
- package/lib/starter/GoldfishStarter.js +108 -0
- package/lib/starter/GoldfishStarter.js.map +1 -0
- package/lib/utils/AdbUtils.d.ts +14 -0
- package/lib/utils/AdbUtils.js +103 -0
- package/lib/utils/AdbUtils.js.map +1 -0
- package/lib/utils/DeviceUtil.d.ts +62 -0
- package/lib/utils/DeviceUtil.js +366 -0
- package/lib/utils/DeviceUtil.js.map +1 -0
- package/lib/utils/RequestUtils.d.ts +11 -0
- package/lib/utils/RequestUtils.js +90 -0
- package/lib/utils/RequestUtils.js.map +1 -0
- package/lib/utils/VelaAvdUtils.d.ts +39 -0
- package/lib/utils/VelaAvdUtils.js +308 -0
- package/lib/utils/VelaAvdUtils.js.map +1 -0
- package/lib/waiter.d.ts +3 -0
- package/lib/waiter.js +39 -0
- package/lib/waiter.js.map +1 -0
- package/package.json +33 -47
- package/CHANGELOG.md +0 -353
- package/bin/index.js +0 -495
- package/gen-webpack-conf/get-devtool.js +0 -51
- package/gen-webpack-conf/helpers.js +0 -143
- package/gen-webpack-conf/index.js +0 -436
- package/gen-webpack-conf/manifest-schema.js +0 -284
- package/gen-webpack-conf/validate.js +0 -284
- package/lib/commands/compile.js +0 -2
- package/lib/commands/debug.js +0 -2
- package/lib/commands/init.js +0 -2
- package/lib/commands/packages.js +0 -2
- package/lib/commands/preview.js +0 -2
- package/lib/commands/report.js +0 -2
- package/lib/commands/resign.js +0 -2
- package/lib/commands/update.js +0 -2
- package/lib/commands/utils.js +0 -2
- package/lib/index.js +0 -2
- package/lib/plugins/manifest-watch-plugin.js +0 -2
- package/lib/utils.js +0 -2
package/bin/index.js
DELETED
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2017, hapjs.org. All rights reserved.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const program = require('commander')
|
|
8
|
-
const chalk = require('chalk')
|
|
9
|
-
const semver = require('semver')
|
|
10
|
-
const { colorconsole } = require('@aiot-toolkit/shared-utils')
|
|
11
|
-
const { compileOptionsMeta } = require('@aiot-toolkit/shared-utils/compilation-config')
|
|
12
|
-
|
|
13
|
-
// 最低支持的node版本
|
|
14
|
-
const NODE_MINIMUM_VERSION = '10.13.0'
|
|
15
|
-
|
|
16
|
-
function checkVersion() {
|
|
17
|
-
const currentVersion = process.versions.node
|
|
18
|
-
|
|
19
|
-
// 若当前版本小于支持版本
|
|
20
|
-
if (semver.lt(currentVersion, NODE_MINIMUM_VERSION)) {
|
|
21
|
-
colorconsole.warn(
|
|
22
|
-
`It is detected that the current NodeJS version is too low, please upgrade to NodeJS version higher than ${NODE_MINIMUM_VERSION}`
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
checkVersion()
|
|
28
|
-
|
|
29
|
-
program.version(require('../package').version, '-v, --version').usage('<command> [options]')
|
|
30
|
-
|
|
31
|
-
program
|
|
32
|
-
.command('init <app-name>')
|
|
33
|
-
.option('--dsl <name>', 'init project by specific dsl template, eg: vue')
|
|
34
|
-
.option('--web', 'init project by specific web template')
|
|
35
|
-
.option('--mina-h5', 'init project by specific mina-h5 template')
|
|
36
|
-
.option('--mina-tv', 'init project by specific mina-tv template')
|
|
37
|
-
.option(
|
|
38
|
-
'-d --deviceType <deviceTypeList>',
|
|
39
|
-
'init project by specific device separated with comma "," eg: tv,car,watch'
|
|
40
|
-
)
|
|
41
|
-
.option(
|
|
42
|
-
'-t --templateType <templateType>',
|
|
43
|
-
'init project by specific template eg: maml; you should use this with -d'
|
|
44
|
-
)
|
|
45
|
-
.description('create a new project.')
|
|
46
|
-
.action((name, options) => {
|
|
47
|
-
const generate = require('../lib/commands/init')
|
|
48
|
-
generate(name, options)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
program
|
|
52
|
-
.command('build')
|
|
53
|
-
.description('build the project')
|
|
54
|
-
.option('--enable-e2e', 'inject test-suite for current project')
|
|
55
|
-
.option('--stats', 'analyse time and size of webpack output files')
|
|
56
|
-
.option('--devtool <value>', 'source map config')
|
|
57
|
-
.option('--disable-subpackages', 'disable subpackages')
|
|
58
|
-
.option('--disable-stream-pack', 'disable stream pack')
|
|
59
|
-
.option('--disable-sign', 'disable signature')
|
|
60
|
-
.option('--disable-script-v8-v65', 'disable compile script match with v8 version 6.5')
|
|
61
|
-
.option('--optimize-desc-meta', 'optimize desc meta')
|
|
62
|
-
.option('--optimize-css-attr', 'optimize css attr')
|
|
63
|
-
.option('--optimize-template-attr', 'optimize template attr')
|
|
64
|
-
.option('--optimize-style-page-level', 'optimize style in page')
|
|
65
|
-
.option('--optimize-style-app-level', 'optimize style in app ')
|
|
66
|
-
.option('--enable-lazy-component', 'lazy load component')
|
|
67
|
-
.option('--optimize-unused-resource', 'remove unused resource')
|
|
68
|
-
.option('--include-dsl-from-lib', 'bundle dsl to rpk')
|
|
69
|
-
.option('--include-static-resources', 'bundle static resources to rpk')
|
|
70
|
-
.option('--match-sourcemap', 'match sourcemap')
|
|
71
|
-
.option('--enable-extract-css', 'extract css to json')
|
|
72
|
-
.option('--enable-custom-component', 'explort entrys by function')
|
|
73
|
-
.option('--enable-jsc', 'bundle to jsc if the projectType is vela')
|
|
74
|
-
.option('--enable-ops-wrap', 'inject performance log in code')
|
|
75
|
-
.option('--disable-build-rpk', 'disable build rpk')
|
|
76
|
-
.option(
|
|
77
|
-
'--split-chunks-mode <value>',
|
|
78
|
-
'extract js module to single files',
|
|
79
|
-
validateSplitChunksMode
|
|
80
|
-
)
|
|
81
|
-
.option('--remove-ux-style', 'remove style object in js')
|
|
82
|
-
.option('--enable-istanbul', 'enable coverage for ux/js files')
|
|
83
|
-
.option('--enable-performance-check', 'inject performance log in code')
|
|
84
|
-
.option(
|
|
85
|
-
'--enable-diagnosis [value]',
|
|
86
|
-
'proxy console object, send log to server, write into project/logs'
|
|
87
|
-
)
|
|
88
|
-
.option(
|
|
89
|
-
'--build-name-format <build-name-format>',
|
|
90
|
-
'custom output rpk file name',
|
|
91
|
-
validateBuildNameFormat
|
|
92
|
-
)
|
|
93
|
-
.option('--enable-protobuf', 'use protobuf gen binary.bin file')
|
|
94
|
-
.action(options => {
|
|
95
|
-
// 必备参数:当开发者不传递该参数时,要解析为默认
|
|
96
|
-
const signModeTmp = options.disableSign && compileOptionsMeta.signModeEnum.NULL
|
|
97
|
-
options.signMode = validateSignMode(signModeTmp, compileOptionsMeta.signModeEnum.BUILD)
|
|
98
|
-
|
|
99
|
-
const { compile } = require('../lib/commands/compile')
|
|
100
|
-
compile('native', 'dev', false, options)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
program
|
|
104
|
-
.command('debug', { noHelp: true })
|
|
105
|
-
.description('debug the project')
|
|
106
|
-
.option('--open-browser', 'open QR code page in default browser')
|
|
107
|
-
.action(options => {
|
|
108
|
-
const { launchServer } = require('@aiot-toolkit/server')
|
|
109
|
-
const { openBrowser } = options
|
|
110
|
-
launchServer({
|
|
111
|
-
modules: ['debugger'],
|
|
112
|
-
port: 8081,
|
|
113
|
-
openBrowser
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
program
|
|
118
|
-
.command('server')
|
|
119
|
-
.description('open server for project')
|
|
120
|
-
.option('--port <port>', 'specified port')
|
|
121
|
-
.option('--watch', 'recompile project while file changes')
|
|
122
|
-
.option('--devtool <value>', 'source map config')
|
|
123
|
-
.option('--clear-records', 'clear device records')
|
|
124
|
-
.option('--disable-adb', 'disable adb debug')
|
|
125
|
-
.option('--chrome-path <chrome-path>', 'support for a user specified chrome path')
|
|
126
|
-
.option('--open-browser', 'open QR code page in default browser')
|
|
127
|
-
.option('--open-nuttx', 'open Nuttx in default emulator')
|
|
128
|
-
.option('--include-dsl-from-lib', 'bundle dsl to rpk')
|
|
129
|
-
.option('--include-static-resources', 'bundle static resources to rpk')
|
|
130
|
-
.option('--enable-performance-check', 'inject performance log in code')
|
|
131
|
-
.option('--enable-custom-component', 'explort entrys by function')
|
|
132
|
-
.option('--enable-jsc', 'bundle to jsc if the projectType is vela')
|
|
133
|
-
.option('--enable-ops-wrap', 'inject performance log in code')
|
|
134
|
-
.option('--disable-build-rpk', 'disable build rpk')
|
|
135
|
-
.option('--enable-protobuf', 'use protobuf gen binary.bin file')
|
|
136
|
-
.option(
|
|
137
|
-
'--build-name-format <build-name-format>',
|
|
138
|
-
'custom output rpk file name',
|
|
139
|
-
validateBuildNameFormat
|
|
140
|
-
)
|
|
141
|
-
.option(
|
|
142
|
-
'--split-chunks-mode <value>',
|
|
143
|
-
'extract js module to single files',
|
|
144
|
-
validateSplitChunksMode
|
|
145
|
-
)
|
|
146
|
-
.action(options => {
|
|
147
|
-
const { launchServer } = require('@aiot-toolkit/server')
|
|
148
|
-
const { compile } = require('../lib/commands/compile')
|
|
149
|
-
const { port, watch, clearRecords, chromePath, disableAdb, openBrowser } = options
|
|
150
|
-
launchServer({
|
|
151
|
-
port,
|
|
152
|
-
watch,
|
|
153
|
-
clearRecords,
|
|
154
|
-
chromePath,
|
|
155
|
-
disableADB: disableAdb,
|
|
156
|
-
openBrowser
|
|
157
|
-
})
|
|
158
|
-
if (options.watch) {
|
|
159
|
-
compile('native', 'dev', true, options)
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
program
|
|
164
|
-
.command('watch')
|
|
165
|
-
.description('recompile project while file changes')
|
|
166
|
-
.option('--enable-e2e', 'inject test-suite for current project')
|
|
167
|
-
.option('--devtool <value>', 'source map config')
|
|
168
|
-
.option('--disable-subpackages', 'disable subpackages')
|
|
169
|
-
.option('--disable-stream-pack', 'disable stream pack')
|
|
170
|
-
.option('--disable-script-v8-v65', 'disable compile script match with v8 version 6.5')
|
|
171
|
-
.option('--include-dsl-from-lib', 'bundle dsl to rpk')
|
|
172
|
-
.option('--include-static-resources', 'bundle static resources to rpk')
|
|
173
|
-
.option('--match-sourcemap', 'match sourcemap')
|
|
174
|
-
.option('--open-nuttx', 'open Nuttx in default emulator')
|
|
175
|
-
.option('--enable-extract-css', 'extract css to json')
|
|
176
|
-
.option(
|
|
177
|
-
'--split-chunks-mode <value>',
|
|
178
|
-
'extract js module to single files',
|
|
179
|
-
validateSplitChunksMode
|
|
180
|
-
)
|
|
181
|
-
.option('--remove-ux-style', 'remove style object in js')
|
|
182
|
-
.option('--enable-istanbul', 'enable coverage for ux/js files')
|
|
183
|
-
.option('--enable-performance-check', 'inject performance log in code')
|
|
184
|
-
.option(
|
|
185
|
-
'--enable-diagnosis [value]',
|
|
186
|
-
'proxy console object, send log to server, write into project/logs'
|
|
187
|
-
)
|
|
188
|
-
.option(
|
|
189
|
-
'--build-name-format <build-name-format>',
|
|
190
|
-
'custom output rpk file name',
|
|
191
|
-
validateBuildNameFormat
|
|
192
|
-
)
|
|
193
|
-
.action(options => {
|
|
194
|
-
const { compile } = require('../lib/commands/compile')
|
|
195
|
-
compile('native', 'dev', true, options)
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
program
|
|
199
|
-
.command('release')
|
|
200
|
-
.description('release the project')
|
|
201
|
-
.option('--enable-e2e', 'inject test-suite for current project')
|
|
202
|
-
.option('--stats', 'analyse time and size of webpack output files')
|
|
203
|
-
.option('--devtool <value>', 'source map config')
|
|
204
|
-
.option('--disable-subpackages', 'disable subpackages')
|
|
205
|
-
.option('--disable-stream-pack', 'disable stream pack')
|
|
206
|
-
.option('--disable-sign', 'disable signature')
|
|
207
|
-
.option('--disable-script-v8-v65', 'disable compile script match with v8 version 6.5')
|
|
208
|
-
.option('--optimize-desc-meta', 'optimize desc meta')
|
|
209
|
-
.option('--optimize-css-attr', 'optimize css attr')
|
|
210
|
-
.option('--optimize-template-attr', 'optimize template attr')
|
|
211
|
-
.option('--optimize-style-page-level', 'optimize style in page')
|
|
212
|
-
.option('--optimize-style-app-level', 'optimize style in app ')
|
|
213
|
-
.option('--enable-lazy-component', 'lazy load component')
|
|
214
|
-
.option('--optimize-unused-resource', 'remove unused resource')
|
|
215
|
-
.option('--include-dsl-from-lib', 'bundle dsl to rpk')
|
|
216
|
-
.option('--include-static-resources', 'bundle static resources to rpk')
|
|
217
|
-
.option('--match-sourcemap', 'match sourcemap')
|
|
218
|
-
.option('--enable-extract-css', 'extract css to json')
|
|
219
|
-
.option('--enable-jsc', 'bundle to jsc if the projectType is vela')
|
|
220
|
-
.option('--enable-ops-wrap', 'inject performance log in code')
|
|
221
|
-
.option('--disable-build-rpk', 'disable build rpk')
|
|
222
|
-
.option('--enable-protobuf', 'use protobuf gen binary.bin file')
|
|
223
|
-
.option(
|
|
224
|
-
'--split-chunks-mode <value>',
|
|
225
|
-
'extract js module to single files',
|
|
226
|
-
validateSplitChunksMode
|
|
227
|
-
)
|
|
228
|
-
.option('--remove-ux-style', 'remove style object in js')
|
|
229
|
-
.option('--enable-istanbul', 'enable coverage for ux/js files')
|
|
230
|
-
.option('--enable-performance-check', 'inject performance log in code')
|
|
231
|
-
.option(
|
|
232
|
-
'--enable-diagnosis [value]',
|
|
233
|
-
'proxy console object, send log to server, write into project/logs'
|
|
234
|
-
)
|
|
235
|
-
.option(
|
|
236
|
-
'--build-name-format <build-name-format>',
|
|
237
|
-
'custom output rpk file name',
|
|
238
|
-
validateBuildNameFormat
|
|
239
|
-
)
|
|
240
|
-
.option('--enable-custom-component', 'explort entrys by function')
|
|
241
|
-
.action(options => {
|
|
242
|
-
// 必备参数:当开发者不传递该参数时,要解析为默认
|
|
243
|
-
const signModeTmp = options.disableSign && compileOptionsMeta.signModeEnum.NULL
|
|
244
|
-
options.signMode = validateSignMode(signModeTmp, compileOptionsMeta.signModeEnum.RELEASE)
|
|
245
|
-
|
|
246
|
-
const { compile } = require('../lib/commands/compile')
|
|
247
|
-
compile('native', 'prod', false, options)
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
program
|
|
251
|
-
.command('preview <target>')
|
|
252
|
-
.description('preview app in your browser')
|
|
253
|
-
.option('--port <port>', 'specified port', 8989)
|
|
254
|
-
.action((target, options) => {
|
|
255
|
-
const preview = require('../lib/commands/preview')
|
|
256
|
-
preview(target, options)
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
program
|
|
260
|
-
.command('postinstall', { noHelp: true })
|
|
261
|
-
.description('Transpiling async/await for nodejs<7.6.x, deprecated.')
|
|
262
|
-
.action(() => {
|
|
263
|
-
colorconsole.warn('Deprecated command!')
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
// TODO
|
|
267
|
-
// Since we properly have all dependencies included,
|
|
268
|
-
// and if we make {babel, eslint}-configuration built-in,
|
|
269
|
-
// we won't need this `update` command anymore.
|
|
270
|
-
program
|
|
271
|
-
.command('update')
|
|
272
|
-
.description('update tools for project')
|
|
273
|
-
.option('--force', 'force update tools for project')
|
|
274
|
-
.option('--update-deps', 'update dependencies directly', { noHelp: true })
|
|
275
|
-
.action(options => {
|
|
276
|
-
const update = require('../lib/commands/update')
|
|
277
|
-
colorconsole.warn('aiot-toolkit>=0.1.0 No longer need to run this command\n')
|
|
278
|
-
update(options)
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
program
|
|
282
|
-
.command('report', { noHelp: true })
|
|
283
|
-
.description('collect system information and create report.log')
|
|
284
|
-
.action(() => {
|
|
285
|
-
const report = require('../lib/commands/report')
|
|
286
|
-
report()
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
program
|
|
290
|
-
.command('view <rpk-path>')
|
|
291
|
-
.description('run server to view rpk')
|
|
292
|
-
.option('--port <port>', 'specified port', 8000)
|
|
293
|
-
.option('--open-browser', 'open QR code page in default browser')
|
|
294
|
-
.action((rpkPath, options) => {
|
|
295
|
-
const { launchServer } = require('@aiot-toolkit/server')
|
|
296
|
-
const { port, openBrowser } = options
|
|
297
|
-
launchServer({
|
|
298
|
-
port,
|
|
299
|
-
openBrowser,
|
|
300
|
-
rpkPath
|
|
301
|
-
})
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
program
|
|
305
|
-
.command('resign')
|
|
306
|
-
.description('resign the rpk/rpks packages')
|
|
307
|
-
.option('--sign <dir>', 'folder where your signature stored', 'sign/release')
|
|
308
|
-
.option('--file <rpk-path>', 'rpk that need to be re-signed')
|
|
309
|
-
.option('--origin <dir>', 'folder where unsigned rpk(s) stored', 'dist')
|
|
310
|
-
.option('--dest <dir>', 'folder where re-signed rpk(s) stored', 'dest')
|
|
311
|
-
.action(options => {
|
|
312
|
-
const { resign } = require('../lib/commands/resign')
|
|
313
|
-
resign(options)
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
program
|
|
317
|
-
.command('packages')
|
|
318
|
-
.description('generate the rpk packages')
|
|
319
|
-
.option('--file <dir>', 'folder where need to generate rpk', 'build')
|
|
320
|
-
.option('--output <dir>', 'folder where generate rpk stored', 'dist')
|
|
321
|
-
.action(options => {
|
|
322
|
-
const { packages } = require('../lib/commands/packages')
|
|
323
|
-
packages(options)
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
program
|
|
327
|
-
.command('installdbg')
|
|
328
|
-
.description('install "org.hapjs.debugger"')
|
|
329
|
-
.option('-I, --ip <value>', 'connect remote devices, eg: 127.0.0.1')
|
|
330
|
-
.option('-P, --platform <value>', 'quickapp debugger platform, default: phone')
|
|
331
|
-
.option('-V, --apkVersion <value>', 'debugger version, default: v1080')
|
|
332
|
-
.option('-F, --force-install', 'overwrite install original debugger')
|
|
333
|
-
.action(async options => {
|
|
334
|
-
const { installdbg } = require('../lib/commands/debug')
|
|
335
|
-
try {
|
|
336
|
-
const successMessage = await installdbg(options)
|
|
337
|
-
colorconsole.info(successMessage)
|
|
338
|
-
} catch (error) {
|
|
339
|
-
colorconsole.error(error.message)
|
|
340
|
-
}
|
|
341
|
-
})
|
|
342
|
-
|
|
343
|
-
program
|
|
344
|
-
.command('installmkp')
|
|
345
|
-
.description('install "org.hapjs.mockup"')
|
|
346
|
-
.option('-I, --ip <value>', 'connect remote devices, eg: 127.0.0.1')
|
|
347
|
-
.option('-P, --platform <value>', 'quickapp engine platform, default: phone')
|
|
348
|
-
.option('-V, --apkVersion <value>', 'quickapp engine version, default: v1080')
|
|
349
|
-
.option('-F, --force-install', 'overwrite install quickapp engine')
|
|
350
|
-
.action(async options => {
|
|
351
|
-
const { installmkp } = require('../lib/commands/debug')
|
|
352
|
-
try {
|
|
353
|
-
const successMessage = await installmkp(options)
|
|
354
|
-
colorconsole.info(successMessage)
|
|
355
|
-
} catch (error) {
|
|
356
|
-
colorconsole.error(error.message)
|
|
357
|
-
}
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
// 运行rpk在所有已连接的设备
|
|
361
|
-
program
|
|
362
|
-
.command('runapp')
|
|
363
|
-
.description('run app on multiple devices')
|
|
364
|
-
.option('-D, --debugMode', 'open chrome devtools')
|
|
365
|
-
.option('-C, --cardMode', 'open cardMode')
|
|
366
|
-
.option('--watch', 'recompile project while file changes')
|
|
367
|
-
.option('--include-static-resources', 'bundle static resources to rpk')
|
|
368
|
-
.action(async options => {
|
|
369
|
-
const { runapp } = require('../lib/commands/debug')
|
|
370
|
-
try {
|
|
371
|
-
await runapp(options)
|
|
372
|
-
} catch (error) {
|
|
373
|
-
colorconsole.error(error.message)
|
|
374
|
-
}
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
program
|
|
378
|
-
.command('installrun')
|
|
379
|
-
.description('install quickapp background and run')
|
|
380
|
-
.option('-I --ip <value>', 'connect remote devices, eg: 127.0.0.1')
|
|
381
|
-
.option('-P --platform <value>', 'quickapp platform, default: phone')
|
|
382
|
-
.option('-V --apkVersion <value>', 'quickapp version, default: v1080')
|
|
383
|
-
.option('-F, --force-install', 'overwrite install debugger and engine')
|
|
384
|
-
.option('-D, --debugMode', 'open chrome devtools')
|
|
385
|
-
.option('-C, --cardMode', 'open cardMode')
|
|
386
|
-
.action(async options => {
|
|
387
|
-
const { installAndRun } = require('../lib/commands/debug')
|
|
388
|
-
try {
|
|
389
|
-
await installAndRun(options)
|
|
390
|
-
} catch (error) {
|
|
391
|
-
colorconsole.error(error.message)
|
|
392
|
-
}
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
// 获取设备上支持运行快应用的引擎包名(数组形式),主要供IDE使用
|
|
396
|
-
program
|
|
397
|
-
.command('getPlatforms')
|
|
398
|
-
.option('-I --ip <value>', 'device ip,eg 127.0.0.1')
|
|
399
|
-
.option('-P --port <value>', 'device port,eg 39517')
|
|
400
|
-
.option('-S --sn <value>', 'device sn,eg 2a75794a')
|
|
401
|
-
.description('get available platform(s) on selected device')
|
|
402
|
-
.action(async options => {
|
|
403
|
-
const { getAvailablePlatform } = require('../lib/commands/debug')
|
|
404
|
-
getAvailablePlatform(options)
|
|
405
|
-
})
|
|
406
|
-
|
|
407
|
-
// 获取所有连接上的设备列表(数组形式),主要供IDE使用
|
|
408
|
-
program
|
|
409
|
-
.command('getConnectedDevices')
|
|
410
|
-
.description('get all connected devices')
|
|
411
|
-
.action(async options => {
|
|
412
|
-
const { getAllConnectedDevices } = require('../lib/commands/debug')
|
|
413
|
-
try {
|
|
414
|
-
const connectedDevices = await getAllConnectedDevices(options)
|
|
415
|
-
colorconsole.info(`The connected devices are: ${connectedDevices.join(', ')}`)
|
|
416
|
-
} catch (error) {
|
|
417
|
-
colorconsole.error(error.message)
|
|
418
|
-
}
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
program.on('--help', () => {
|
|
422
|
-
console.log()
|
|
423
|
-
console.log(`Run ${chalk.cyan(`aiot <command> --help`)} for detailed usage of given command.`)
|
|
424
|
-
console.log()
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
// 更改 NodeJS 10.1.0 上的 "fs.promise is Experiment" 日志输出位置
|
|
428
|
-
require('fs-extra')
|
|
429
|
-
setTimeout(() => {
|
|
430
|
-
program.parse(process.argv)
|
|
431
|
-
|
|
432
|
-
if (!process.argv.slice(2).length) {
|
|
433
|
-
program.outputHelp()
|
|
434
|
-
}
|
|
435
|
-
}, 0)
|
|
436
|
-
|
|
437
|
-
function validateSignMode(value, defaultValue) {
|
|
438
|
-
// 无值则为空串
|
|
439
|
-
if ([null, undefined].includes(value)) {
|
|
440
|
-
value = defaultValue
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// 转成枚举常量比较
|
|
444
|
-
value = value.toUpperCase()
|
|
445
|
-
|
|
446
|
-
let ret = value
|
|
447
|
-
|
|
448
|
-
if (!compileOptionsMeta.signModeEnum[value]) {
|
|
449
|
-
ret = defaultValue
|
|
450
|
-
colorconsole.warn(
|
|
451
|
-
`The current signMode parameter does not support: ${value} , change to default:${ret}`
|
|
452
|
-
)
|
|
453
|
-
}
|
|
454
|
-
return ret
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* 校验SplitChunkMode参数的有效值
|
|
459
|
-
* @param value {string}
|
|
460
|
-
* @return {string}
|
|
461
|
-
*/
|
|
462
|
-
function validateSplitChunksMode(value) {
|
|
463
|
-
// 转成枚举常量比较
|
|
464
|
-
value = value.toUpperCase()
|
|
465
|
-
|
|
466
|
-
let ret = value
|
|
467
|
-
|
|
468
|
-
if (!compileOptionsMeta.splitChunksModeEnum[value]) {
|
|
469
|
-
ret = compileOptionsMeta.splitChunksModeEnum.REDUNDANCY
|
|
470
|
-
colorconsole.warn(
|
|
471
|
-
`The current splitChunksMode parameter does not support: ${value} , change to default:${ret}`
|
|
472
|
-
)
|
|
473
|
-
}
|
|
474
|
-
return ret
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* 校验buildNameFormat参数的有效值
|
|
479
|
-
* @param value {string}
|
|
480
|
-
* @return {string}
|
|
481
|
-
*/
|
|
482
|
-
function validateBuildNameFormat(value) {
|
|
483
|
-
// 转成枚举常量比较
|
|
484
|
-
value = value.toUpperCase()
|
|
485
|
-
|
|
486
|
-
let ret = value
|
|
487
|
-
|
|
488
|
-
if (!compileOptionsMeta.buildNameFormat[value]) {
|
|
489
|
-
ret = compileOptionsMeta.buildNameFormat.DEFAULT
|
|
490
|
-
colorconsole.warn(
|
|
491
|
-
`The current buildNameFormat parameter does not support: ${value} , change to default:${ret}`
|
|
492
|
-
)
|
|
493
|
-
}
|
|
494
|
-
return ret
|
|
495
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const { colorconsole } = require('@aiot-toolkit/shared-utils')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 校验并返回 webpack devtool值(sourcemap)
|
|
5
|
-
* @param {String} mode - webpack mode
|
|
6
|
-
* @param {String} devtool - devtool参数值
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function getDevtoolValue(mode, devtool) {
|
|
9
|
-
// TODO:https://webpack.js.org/configuration/devtool/#root eval模式在 webpack5 下运行白屏
|
|
10
|
-
// 后续或虑改为:有(source-map)无(false)二元选项
|
|
11
|
-
const sourcemaps = {
|
|
12
|
-
development: {
|
|
13
|
-
default: 'cheap-source-map',
|
|
14
|
-
options: [
|
|
15
|
-
false,
|
|
16
|
-
'cheap-source-map',
|
|
17
|
-
'cheap-module-source-map',
|
|
18
|
-
'inline-cheap-source-map',
|
|
19
|
-
'inline-cheap-module-source-map',
|
|
20
|
-
'source-map',
|
|
21
|
-
'inline-source-map',
|
|
22
|
-
'hidden-source-map',
|
|
23
|
-
'nosources-source-map'
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
production: {
|
|
27
|
-
default: false,
|
|
28
|
-
options: [
|
|
29
|
-
false,
|
|
30
|
-
'cheap-source-map',
|
|
31
|
-
'cheap-module-source-map',
|
|
32
|
-
'source-map',
|
|
33
|
-
'hidden-source-map',
|
|
34
|
-
'nosources-source-map'
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const sourcemapArr = sourcemaps[mode].options
|
|
39
|
-
const defaultSourcemap = sourcemaps[mode].default
|
|
40
|
-
if (typeof devtool !== 'string' && typeof devtool !== 'boolean') {
|
|
41
|
-
return defaultSourcemap
|
|
42
|
-
}
|
|
43
|
-
if (sourcemapArr.indexOf(devtool) === -1) {
|
|
44
|
-
colorconsole.warn(
|
|
45
|
-
`The devtool in ${mode} mode does not support '${devtool}', change to default '${defaultSourcemap}'`
|
|
46
|
-
)
|
|
47
|
-
return defaultSourcemap
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return devtool
|
|
51
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const builtinList = require('module').builtinModules
|
|
4
|
-
const globalConfig = require('@aiot-toolkit/shared-utils/config')
|
|
5
|
-
|
|
6
|
-
const { readJson, colorconsole } = require('@aiot-toolkit/shared-utils')
|
|
7
|
-
|
|
8
|
-
// 兼容配置文件
|
|
9
|
-
const configFileList = ['quickapp.config.js', 'hap.config.js']
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 获取配置文件路径
|
|
13
|
-
* @param {String} cwd
|
|
14
|
-
*/
|
|
15
|
-
exports.getConfigPath = function getConfigPath(cwd) {
|
|
16
|
-
let configPath = ''
|
|
17
|
-
let index = 0
|
|
18
|
-
do {
|
|
19
|
-
configPath = path.resolve(cwd, configFileList[index])
|
|
20
|
-
if (fs.existsSync(configPath)) break
|
|
21
|
-
configPath = ''
|
|
22
|
-
} while (++index < configFileList.length)
|
|
23
|
-
return configPath
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 清理 BUILD_DIR DIST_DIR
|
|
28
|
-
*/
|
|
29
|
-
exports.cleanup = function cleanup(BUILD_DIR, DIST_DIR) {
|
|
30
|
-
fs.emptyDirSync(BUILD_DIR)
|
|
31
|
-
|
|
32
|
-
// 清空 dist 目录下的文件(仅文件)
|
|
33
|
-
if (fs.existsSync(DIST_DIR)) {
|
|
34
|
-
const zipfiles = fs.readdirSync(DIST_DIR)
|
|
35
|
-
zipfiles.forEach(function(file) {
|
|
36
|
-
const curPath = DIST_DIR + '/' + file
|
|
37
|
-
if (fs.statSync(curPath).isFile()) {
|
|
38
|
-
fs.unlinkSync(curPath)
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 使用 node 原生模块给予警告
|
|
46
|
-
*/
|
|
47
|
-
exports.checkBuiltinModules = function checkBuiltinModules({ request }, callback) {
|
|
48
|
-
const packageJson = require(path.join(globalConfig.projectPath, 'package.json'))
|
|
49
|
-
// 提取 package.json 中的依赖
|
|
50
|
-
let projectDependencies = []
|
|
51
|
-
if (packageJson.devDependencies) {
|
|
52
|
-
projectDependencies = Object.keys(packageJson.devDependencies)
|
|
53
|
-
}
|
|
54
|
-
if (packageJson.dependencies) {
|
|
55
|
-
projectDependencies = projectDependencies.concat(Object.keys(packageJson.dependencies))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 枚举 node 原生模块
|
|
59
|
-
const enumList = [
|
|
60
|
-
'assert',
|
|
61
|
-
'console',
|
|
62
|
-
'buffer',
|
|
63
|
-
'child_process',
|
|
64
|
-
'cluster',
|
|
65
|
-
'console',
|
|
66
|
-
'constants',
|
|
67
|
-
'crypto',
|
|
68
|
-
'dgram',
|
|
69
|
-
'dns',
|
|
70
|
-
'domain',
|
|
71
|
-
'events',
|
|
72
|
-
'fs',
|
|
73
|
-
'http',
|
|
74
|
-
'https',
|
|
75
|
-
'module',
|
|
76
|
-
'net',
|
|
77
|
-
'os',
|
|
78
|
-
'path',
|
|
79
|
-
'process',
|
|
80
|
-
'punycode',
|
|
81
|
-
'querystring',
|
|
82
|
-
'readline',
|
|
83
|
-
'repl',
|
|
84
|
-
'stream',
|
|
85
|
-
'string_decoder',
|
|
86
|
-
'sys',
|
|
87
|
-
'timers',
|
|
88
|
-
'tls',
|
|
89
|
-
'tty',
|
|
90
|
-
'url',
|
|
91
|
-
'util',
|
|
92
|
-
'vm',
|
|
93
|
-
'zlib'
|
|
94
|
-
]
|
|
95
|
-
const externalsList = Array.isArray(builtinList) ? builtinList : enumList
|
|
96
|
-
// 确定是node原生模块,并且没有在package.json 中引用这个模块
|
|
97
|
-
if (externalsList.indexOf(request) > -1 && projectDependencies.indexOf(request) === -1) {
|
|
98
|
-
colorconsole.warn(
|
|
99
|
-
`The ${request} you are currently using seems to be a node native module, Quickapp is not a node environment does not support node native modules`
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
callback()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 设置v8版本
|
|
107
|
-
* @param {boolean} disableScriptV8V65
|
|
108
|
-
*/
|
|
109
|
-
exports.setAdaptForV8Version = function setAdaptForV8Version(disableScriptV8V65, manifest, cwd) {
|
|
110
|
-
const packageJsonFile = path.resolve(cwd, 'package.json')
|
|
111
|
-
const packageJson = readJson(packageJsonFile)
|
|
112
|
-
const minPlatformVersion = parseInt(manifest.minPlatformVersion)
|
|
113
|
-
if (fs.existsSync(packageJsonFile)) {
|
|
114
|
-
if (!disableScriptV8V65 && minPlatformVersion >= 1040) {
|
|
115
|
-
const hasDefinedChrome65 =
|
|
116
|
-
packageJson.browserslist && packageJson.browserslist.includes('chrome 65')
|
|
117
|
-
colorconsole.log(
|
|
118
|
-
`Current minPlatformVersion >= 1040,the platform adopts v8 version 6.5+(corresponding to chrome version 65+),the tool will no longer convert the ES6 code supported by V8 6.5 version`
|
|
119
|
-
)
|
|
120
|
-
if (hasDefinedChrome65) return
|
|
121
|
-
// v8 6.5相当于chrome 65版本
|
|
122
|
-
packageJson.browserslist = ['chrome 65']
|
|
123
|
-
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2))
|
|
124
|
-
} else if (packageJson.browserslist) {
|
|
125
|
-
delete packageJson.browserslist
|
|
126
|
-
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2))
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 简单检查是否有安装 Babel 相关依赖
|
|
133
|
-
* @param {String} cwd - 项目路径
|
|
134
|
-
*/
|
|
135
|
-
exports.checkBabelModulesExists = function valiedateSitemap(cwd) {
|
|
136
|
-
const babelconfigjs = path.join(cwd, 'babel.config.js')
|
|
137
|
-
const babelModules = path.join(cwd, 'node_modules/@babel')
|
|
138
|
-
if (fs.existsSync(babelconfigjs) && !fs.existsSync(babelModules)) {
|
|
139
|
-
colorconsole.warn(
|
|
140
|
-
`You have used a custom babel.config.js, please confirm whether there are installation dependencies`
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
}
|