aiot-toolkit 2.0.1-alpha.9 → 2.0.2-beta.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 +32 -29
- package/lib/bin.js +102 -41
- package/lib/builder/IBuilder.js +0 -2
- package/lib/builder/UxBuilder.d.ts +9 -0
- package/lib/builder/UxBuilder.js +69 -23
- package/lib/builder/XtsBuilder.js +30 -12
- package/lib/interface/CommandInterface.js +0 -2
- package/lib/interface/VelaEmulatorInterface.d.ts +6 -0
- package/lib/interface/VelaEmulatorInterface.js +0 -2
- package/lib/starter/IStarter.d.ts +23 -0
- package/lib/starter/IStarter.js +39 -0
- package/lib/starter/UxStarter.d.ts +21 -0
- package/lib/starter/UxStarter.js +186 -0
- package/lib/starter/XtsStarter.d.ts +9 -0
- package/lib/starter/XtsStarter.js +19 -0
- package/lib/utils/AdbUtils.js +2 -11
- package/lib/utils/DeviceUtil.d.ts +1 -1
- package/lib/utils/DeviceUtil.js +22 -93
- package/lib/utils/RequestUtils.js +4 -19
- package/lib/utils/UxBuilderUtils.d.ts +8 -0
- package/lib/utils/UxBuilderUtils.js +51 -0
- package/lib/utils/VelaAvdUtils.d.ts +26 -4
- package/lib/utils/VelaAvdUtils.js +263 -134
- package/lib/waiter.js +0 -2
- package/package.json +17 -11
- package/lib/bin.js.map +0 -1
- package/lib/builder/IBuilder.js.map +0 -1
- package/lib/builder/UxBuilder.js.map +0 -1
- package/lib/builder/XtsBuilder.js.map +0 -1
- package/lib/interface/CommandInterface.js.map +0 -1
- package/lib/interface/VelaEmulatorInterface.js.map +0 -1
- package/lib/starter/GoldfishStarter.d.ts +0 -9
- package/lib/starter/GoldfishStarter.js +0 -108
- package/lib/starter/GoldfishStarter.js.map +0 -1
- package/lib/utils/AdbUtils.js.map +0 -1
- package/lib/utils/DeviceUtil.js.map +0 -1
- package/lib/utils/RequestUtils.js.map +0 -1
- package/lib/utils/VelaAvdUtils.js.map +0 -1
- package/lib/waiter.js.map +0 -1
|
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const emulator_1 = require("@aiot-toolkit/emulator");
|
|
16
|
-
const
|
|
16
|
+
const constants_1 = require("@aiot-toolkit/emulator/lib/static/constants");
|
|
17
|
+
const utils_1 = require("@aiot-toolkit/emulator/lib/utils");
|
|
17
18
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
18
19
|
const prompts_1 = require("@inquirer/prompts");
|
|
19
20
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
@@ -22,7 +23,9 @@ const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
|
22
23
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
23
24
|
const os_1 = __importDefault(require("os"));
|
|
24
25
|
const path_1 = __importDefault(require("path"));
|
|
26
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
25
27
|
class VelaAvdUtils {
|
|
28
|
+
/** 校验AVD名称 */
|
|
26
29
|
static validateAvdName(avdName) {
|
|
27
30
|
if (!avdName) {
|
|
28
31
|
return `Please enter avd name`;
|
|
@@ -68,11 +71,7 @@ class VelaAvdUtils {
|
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
73
|
catch (e) {
|
|
71
|
-
ColorConsole_1.default.
|
|
72
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
73
|
-
message: `download ${filename} failed`
|
|
74
|
-
});
|
|
75
|
-
progress.stop();
|
|
74
|
+
ColorConsole_1.default.throw(`Download ${filename} failed`);
|
|
76
75
|
reject();
|
|
77
76
|
}
|
|
78
77
|
}));
|
|
@@ -107,34 +106,68 @@ class VelaAvdUtils {
|
|
|
107
106
|
/** 根据host获取模拟器下载地址 */
|
|
108
107
|
static getEmulatorUrl(version = '0.0.1') {
|
|
109
108
|
const systemOs = os_1.default.platform();
|
|
110
|
-
const
|
|
111
|
-
let hostOs = '';
|
|
112
|
-
let hostArch = '';
|
|
113
|
-
switch (systemOs) {
|
|
114
|
-
case 'linux':
|
|
115
|
-
hostOs = 'linux';
|
|
116
|
-
hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
|
|
117
|
-
break;
|
|
118
|
-
case 'win32':
|
|
119
|
-
hostOs = 'windows';
|
|
120
|
-
hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
|
|
121
|
-
break;
|
|
122
|
-
case 'darwin':
|
|
123
|
-
hostOs = 'darwin';
|
|
124
|
-
hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
|
|
125
|
-
default:
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
109
|
+
const hostArch = (0, utils_1.getSystemArch)();
|
|
110
|
+
let hostOs = systemOs === 'win32' ? 'windows' : systemOs;
|
|
128
111
|
return `${VelaAvdUtils.emulatorBaseUrl}/v${version}/${hostOs}-${hostArch}.zip`;
|
|
129
112
|
}
|
|
130
|
-
/**
|
|
131
|
-
static
|
|
132
|
-
|
|
113
|
+
/** 获取模拟器平台的名称,darwin-aarch64 linux-aarch64 windows-x86_64等 */
|
|
114
|
+
static getEmulatorPlatform() {
|
|
115
|
+
const systemOs = os_1.default.platform();
|
|
116
|
+
const hostArch = (0, utils_1.getSystemArch)();
|
|
117
|
+
const hostOs = systemOs === 'win32' ? 'windows' : systemOs;
|
|
118
|
+
return `${hostOs}-${hostArch}`;
|
|
119
|
+
}
|
|
120
|
+
/** 获取各项模拟器资源的根目录 */
|
|
121
|
+
static getEmulatorEnvHome(resourceName) {
|
|
122
|
+
return path_1.default.resolve(VelaAvdUtils.sdkHome, resourceName);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Vela镜像需要更新
|
|
126
|
+
* @param imageId 镜像id
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
static velaImageNeedUpdate(imageId) {
|
|
130
|
+
// 兼容之前的version.json
|
|
131
|
+
if (typeof imageId !== 'string' || !imageId)
|
|
132
|
+
return true;
|
|
133
|
+
let avdImagePath = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', imageId, 'nuttx');
|
|
134
|
+
if (!fs_extra_1.default.existsSync(avdImagePath)) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
if (VelaAvdUtils.isZipInImageUrl(imageId)) {
|
|
138
|
+
const stats = fs_extra_1.default.statSync(avdImagePath);
|
|
139
|
+
const version = constants_1.VelaImageVersionList.find((item) => item.value === imageId);
|
|
140
|
+
if (version && (0, dayjs_1.default)(version.time).isAfter(stats.mtime, 'day'))
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Vela镜像是否为zip包(是否为0.0.2版本)
|
|
147
|
+
* 只有Vela开发版(dev, 0.0.2)这个版本的镜像不是zip包
|
|
148
|
+
* @param velaImage
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
static isZipInImageUrl(velaImage) {
|
|
152
|
+
return velaImage.indexOf('0.0.2') < 0;
|
|
153
|
+
}
|
|
154
|
+
/** 获取vela镜像的下载地址 */
|
|
155
|
+
static getSystemImageUrl(version = 'vela-release-4.0') {
|
|
156
|
+
if (VelaAvdUtils.isZipInImageUrl(version)) {
|
|
157
|
+
const velaImage = constants_1.VelaImageVersionList.find((item) => item.value = version);
|
|
158
|
+
const dayOfTime = (0, dayjs_1.default)(velaImage === null || velaImage === void 0 ? void 0 : velaImage.time).format('YYYYMMDD');
|
|
159
|
+
return `${VelaAvdUtils.systemImageBaseUrl}/${version}/${dayOfTime}/${version}.zip`;
|
|
160
|
+
}
|
|
161
|
+
return `${VelaAvdUtils.systemImageBaseUrl}/${version}/nuttx`;
|
|
162
|
+
}
|
|
163
|
+
/** 获取模拟器其他资源的下载地址 */
|
|
164
|
+
static getDownloadUrl(dir, version = '0.0.1', filename = dir) {
|
|
165
|
+
return `${VelaAvdUtils.baseUrl}/${dir}/v${version}/${filename}.zip`;
|
|
133
166
|
}
|
|
134
167
|
/** 根据host获取ya-vm-file-server下载地址 */
|
|
135
168
|
static getv9fsToolUrl(version = '0.0.1') {
|
|
136
169
|
const systemOs = os_1.default.platform();
|
|
137
|
-
const arch =
|
|
170
|
+
const arch = (0, utils_1.getSystemArch)();
|
|
138
171
|
let v9fsTool = '';
|
|
139
172
|
switch (systemOs) {
|
|
140
173
|
case 'linux':
|
|
@@ -144,32 +177,58 @@ class VelaAvdUtils {
|
|
|
144
177
|
v9fsTool = 'ya-vm-file-server-windows.exe';
|
|
145
178
|
break;
|
|
146
179
|
case 'darwin':
|
|
147
|
-
v9fsTool =
|
|
180
|
+
v9fsTool = `ya-vm-file-server-darwin-${arch}`;
|
|
181
|
+
break;
|
|
148
182
|
default:
|
|
149
183
|
break;
|
|
150
184
|
}
|
|
151
185
|
return `${VelaAvdUtils.baseUrl}/tools/v${version}/${v9fsTool}`;
|
|
152
186
|
}
|
|
153
|
-
/**
|
|
154
|
-
static
|
|
155
|
-
|
|
187
|
+
/** 获取镜像构建时间 */
|
|
188
|
+
static getImageBuildTime(imageId) {
|
|
189
|
+
var _a;
|
|
190
|
+
if (!imageId)
|
|
191
|
+
return;
|
|
192
|
+
const imagePath = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', imageId, 'nuttx');
|
|
193
|
+
if (fs_extra_1.default.existsSync(imagePath)) {
|
|
194
|
+
if (VelaAvdUtils.isZipInImageUrl(imageId)) {
|
|
195
|
+
const stats = fs_extra_1.default.statSync(imagePath);
|
|
196
|
+
return stats.mtime;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const time = (_a = constants_1.VelaImageVersionList.find((item) => item.value === imageId)) === null || _a === void 0 ? void 0 : _a.time;
|
|
200
|
+
return time;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return;
|
|
156
204
|
}
|
|
157
205
|
/**
|
|
158
206
|
* 命令行访问方式创建模拟器
|
|
159
207
|
*/
|
|
160
208
|
static createVelaAvdByInquire() {
|
|
161
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const versionFile = path_1.default.resolve(VelaAvdUtils.sdkHome, 'versions.json');
|
|
211
|
+
const versionFileExist = fs_extra_1.default.existsSync(versionFile);
|
|
212
|
+
let currVersionInfo = {
|
|
213
|
+
name: '模拟器资源版本管理',
|
|
214
|
+
emulator: '',
|
|
215
|
+
qa: '',
|
|
216
|
+
skins: '',
|
|
217
|
+
'system-images': '',
|
|
218
|
+
tools: '',
|
|
219
|
+
modem_simulator: ''
|
|
220
|
+
};
|
|
221
|
+
if (versionFileExist) {
|
|
222
|
+
currVersionInfo = fs_extra_1.default.readJSONSync(versionFile);
|
|
223
|
+
}
|
|
224
|
+
const onlineVersionInfo = constants_1.EmulatorEnvVersion;
|
|
225
|
+
// 模拟器各项资源(除了镜像)是否存在
|
|
226
|
+
const emulatorExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'emulator', VelaAvdUtils.getEmulatorPlatform()));
|
|
227
|
+
const qaExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'qa/font'));
|
|
228
|
+
const skinsExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'skins'));
|
|
229
|
+
const toolsExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'tools'));
|
|
230
|
+
const modemSimulatorExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'modem_simulator/modem_nvram.json'));
|
|
162
231
|
try {
|
|
163
|
-
const versionFile = path_1.default.resolve(VelaAvdUtils.sdkHome, 'versions.json');
|
|
164
|
-
const versionFileExist = fs_extra_1.default.existsSync(versionFile);
|
|
165
|
-
let versionInfo = undefined;
|
|
166
|
-
if (versionFileExist) {
|
|
167
|
-
versionInfo = fs_extra_1.default.readJSONSync(versionFile);
|
|
168
|
-
}
|
|
169
|
-
// 下载version.json,保证每次下载的文件都是最新的版本
|
|
170
|
-
yield VelaAvdUtils.downloadFromCdn(VelaAvdUtils.versionUrl, VelaAvdUtils.sdkHome, 'online-version.json');
|
|
171
|
-
const onlineVersionFile = path_1.default.resolve(VelaAvdUtils.sdkHome, 'online-version.json');
|
|
172
|
-
const onlineVersionInfo = fs_extra_1.default.readJSONSync(onlineVersionFile);
|
|
173
232
|
// avdName
|
|
174
233
|
const avdName = yield (0, prompts_1.input)({
|
|
175
234
|
message: 'avd name starting with Vela. (eg. Vela_Virtual_Device)',
|
|
@@ -178,117 +237,189 @@ class VelaAvdUtils {
|
|
|
178
237
|
return VelaAvdUtils.validateAvdName(value);
|
|
179
238
|
}
|
|
180
239
|
});
|
|
240
|
+
// 镜像
|
|
241
|
+
const velaImage = (yield (0, prompts_1.select)({
|
|
242
|
+
message: 'vela image.',
|
|
243
|
+
choices: constants_1.VelaImageVersionList.map((item) => {
|
|
244
|
+
return { value: item.value, name: item.label };
|
|
245
|
+
})
|
|
246
|
+
}));
|
|
181
247
|
// skin或者size
|
|
182
|
-
const needSkin = yield (0, prompts_1.confirm)({
|
|
183
|
-
message: 'need avd skin?',
|
|
184
|
-
default: true
|
|
185
|
-
});
|
|
186
|
-
const skinDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'skins');
|
|
187
|
-
const skinExists = fs_extra_1.default.existsSync(skinDir);
|
|
188
248
|
let avdSkin = '';
|
|
189
|
-
let avdWidth = '';
|
|
190
|
-
let avdHeight = '';
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
249
|
+
let avdWidth = '466';
|
|
250
|
+
let avdHeight = '466';
|
|
251
|
+
// vela4.0不允许自定义分辨率
|
|
252
|
+
if (velaImage.indexOf('vela-release') < 0) {
|
|
253
|
+
const needSkin = yield (0, prompts_1.confirm)({
|
|
254
|
+
message: 'need avd skin?',
|
|
255
|
+
default: true
|
|
256
|
+
});
|
|
257
|
+
if (needSkin) {
|
|
258
|
+
if (!skinsExist || (currVersionInfo && currVersionInfo.skins < onlineVersionInfo.skins)) {
|
|
259
|
+
const skinsUrl = VelaAvdUtils.getDownloadUrl('skins', onlineVersionInfo.skins);
|
|
260
|
+
yield VelaAvdUtils.downloadAndUnzip(skinsUrl, path_1.default.resolve(VelaAvdUtils.sdkHome, 'skins'));
|
|
261
|
+
currVersionInfo.skins = constants_1.EmulatorEnvVersion.skins;
|
|
262
|
+
ColorConsole_1.default.success(`Download skins succeed.`);
|
|
263
|
+
}
|
|
264
|
+
const skinList = VelaAvdUtils.velaAvdCls.getVelaSkinList();
|
|
265
|
+
avdSkin = yield (0, prompts_1.select)({
|
|
266
|
+
message: 'avd skin.',
|
|
267
|
+
choices: skinList.map((item) => {
|
|
268
|
+
return {
|
|
269
|
+
name: item,
|
|
270
|
+
value: item,
|
|
271
|
+
description: item
|
|
272
|
+
};
|
|
273
|
+
})
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
avdWidth = yield (0, prompts_1.input)({
|
|
278
|
+
message: 'avd width.',
|
|
279
|
+
default: '466'
|
|
280
|
+
});
|
|
281
|
+
avdHeight = yield (0, prompts_1.input)({
|
|
282
|
+
message: 'avd height.',
|
|
283
|
+
default: '466'
|
|
198
284
|
});
|
|
199
285
|
}
|
|
200
|
-
const skinList = VelaAvdUtils.velaAvdCls.getVelaSkinList();
|
|
201
|
-
avdSkin = yield (0, prompts_1.select)({
|
|
202
|
-
message: 'avd skin.',
|
|
203
|
-
choices: skinList.map((item) => {
|
|
204
|
-
return {
|
|
205
|
-
name: item,
|
|
206
|
-
value: item,
|
|
207
|
-
description: item
|
|
208
|
-
};
|
|
209
|
-
})
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
avdWidth = yield (0, prompts_1.input)({
|
|
214
|
-
message: 'avd width.',
|
|
215
|
-
default: '480'
|
|
216
|
-
});
|
|
217
|
-
avdHeight = yield (0, prompts_1.input)({
|
|
218
|
-
message: 'avd height.',
|
|
219
|
-
default: '480'
|
|
220
|
-
});
|
|
221
286
|
}
|
|
222
|
-
// 镜像,TODO:后续需要考虑多种设备的镜像
|
|
223
|
-
const avdArch = (yield (0, prompts_1.select)({
|
|
224
|
-
message: 'vela image.',
|
|
225
|
-
choices: [{ value: 'arm' }, { value: 'arm64' }]
|
|
226
|
-
}));
|
|
227
287
|
// 下载模拟器
|
|
228
|
-
|
|
229
|
-
const emulatorExists = fs_extra_1.default.existsSync(emulatorDir);
|
|
230
|
-
if (!emulatorExists || (versionInfo && versionInfo.emulator < onlineVersionInfo.emulator)) {
|
|
288
|
+
if (!emulatorExist || (currVersionInfo && currVersionInfo.emulator < onlineVersionInfo.emulator)) {
|
|
231
289
|
const emulatorDownloadUrl = VelaAvdUtils.getEmulatorUrl(onlineVersionInfo.emulator);
|
|
232
|
-
yield VelaAvdUtils.downloadAndUnzip(emulatorDownloadUrl,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
message: `download emulator succeed.`
|
|
236
|
-
});
|
|
290
|
+
yield VelaAvdUtils.downloadAndUnzip(emulatorDownloadUrl, VelaAvdUtils.getEmulatorEnvHome('emulator'));
|
|
291
|
+
currVersionInfo.emulator = constants_1.EmulatorEnvVersion.emulator;
|
|
292
|
+
ColorConsole_1.default.success(`Download emulator succeed.`);
|
|
237
293
|
}
|
|
238
294
|
// 下载镜像
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
295
|
+
const imageDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', velaImage);
|
|
296
|
+
if (this.velaImageNeedUpdate(velaImage)) {
|
|
297
|
+
const velaImageDownloadUrl = this.getSystemImageUrl(velaImage);
|
|
298
|
+
if (VelaAvdUtils.isZipInImageUrl(velaImage)) {
|
|
299
|
+
yield VelaAvdUtils.downloadAndUnzip(velaImageDownloadUrl, imageDir);
|
|
300
|
+
currVersionInfo['system-images'] = constants_1.EmulatorEnvVersion['system-images'];
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
yield VelaAvdUtils.downloadFromCdn(velaImageDownloadUrl, imageDir, 'nuttx');
|
|
304
|
+
}
|
|
305
|
+
ColorConsole_1.default.success(`Download vela image succeed.`);
|
|
249
306
|
}
|
|
250
307
|
// 下载快应用qa文件
|
|
251
|
-
|
|
252
|
-
const qaExists = fs_extra_1.default.existsSync(qaDir);
|
|
253
|
-
if (!qaExists || (versionInfo && versionInfo.qa < onlineVersionInfo.qa)) {
|
|
308
|
+
if (!qaExist || (currVersionInfo && currVersionInfo.qa < onlineVersionInfo.qa)) {
|
|
254
309
|
const qaUrl = VelaAvdUtils.getDownloadUrl('qa', onlineVersionInfo.qa);
|
|
255
|
-
yield VelaAvdUtils.downloadAndUnzip(qaUrl,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
message: `download quickapp font succeed.`
|
|
259
|
-
});
|
|
310
|
+
yield VelaAvdUtils.downloadAndUnzip(qaUrl, VelaAvdUtils.getEmulatorEnvHome('qa'));
|
|
311
|
+
currVersionInfo.qa = constants_1.EmulatorEnvVersion.qa;
|
|
312
|
+
ColorConsole_1.default.success(`Download quickapp font succeed.`);
|
|
260
313
|
}
|
|
261
314
|
// 下载tools
|
|
262
|
-
|
|
263
|
-
const toolsExists = fs_extra_1.default.existsSync(toolsDir);
|
|
264
|
-
if (!toolsExists || (versionInfo && versionInfo.tools < onlineVersionInfo.tools)) {
|
|
315
|
+
if (!toolsExist || (currVersionInfo && currVersionInfo.tools < onlineVersionInfo.tools)) {
|
|
265
316
|
const v9fsToolUrl = VelaAvdUtils.getv9fsToolUrl();
|
|
266
|
-
const filename =
|
|
267
|
-
yield VelaAvdUtils.downloadFromCdn(v9fsToolUrl,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
message: `download tools succeed.`
|
|
271
|
-
});
|
|
317
|
+
const filename = os_1.default.platform() === 'win32' ? 'ya-vm-file-server.exe' : 'ya-vm-file-server';
|
|
318
|
+
yield VelaAvdUtils.downloadFromCdn(v9fsToolUrl, VelaAvdUtils.getEmulatorEnvHome('tools'), filename);
|
|
319
|
+
currVersionInfo.tools = constants_1.EmulatorEnvVersion.tools;
|
|
320
|
+
ColorConsole_1.default.success(`Download tools succeed.`);
|
|
272
321
|
}
|
|
273
|
-
//
|
|
274
|
-
if (
|
|
275
|
-
|
|
322
|
+
// 下载modem_simulator
|
|
323
|
+
if (!modemSimulatorExist || currVersionInfo.modem_simulator < constants_1.EmulatorEnvVersion.modem_simulator) {
|
|
324
|
+
const modemSimulatorUrl = VelaAvdUtils.getDownloadUrl('modem_simulator', constants_1.EmulatorEnvVersion.modem_simulator);
|
|
325
|
+
yield VelaAvdUtils.downloadAndUnzip(modemSimulatorUrl, VelaAvdUtils.getEmulatorEnvHome('modem_simulator'));
|
|
326
|
+
currVersionInfo.modem_simulator = constants_1.EmulatorEnvVersion.modem_simulator;
|
|
327
|
+
ColorConsole_1.default.success(`Download modem simulator succeed.`);
|
|
276
328
|
}
|
|
277
|
-
fs_extra_1.default.renameSync(onlineVersionFile, versionFile);
|
|
278
329
|
// 创建avd文本文件
|
|
279
330
|
const avdImagePath = imageDir;
|
|
280
|
-
const avdParams = { avdName, avdSkin, avdWidth, avdHeight, avdArch, avdImagePath };
|
|
331
|
+
const avdParams = { avdName, avdSkin, avdWidth, avdHeight, avdArch: emulator_1.IAvdArchType.arm, avdImagePath };
|
|
281
332
|
VelaAvdUtils.velaAvdCls.createVelaAvd(avdParams);
|
|
282
|
-
ColorConsole_1.default.
|
|
283
|
-
level: shared_utils_1.LOG_LEVEL.Success,
|
|
284
|
-
message: `create avd succeed.`
|
|
285
|
-
});
|
|
333
|
+
ColorConsole_1.default.success(`Create avd succeed.`);
|
|
286
334
|
}
|
|
287
335
|
catch (e) {
|
|
288
|
-
ColorConsole_1.default.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
336
|
+
ColorConsole_1.default.throw(`Create avd failed. Error: ${e.message}`);
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
// 写入versions.json
|
|
340
|
+
const versionJson = JSON.stringify(currVersionInfo, null, 2);
|
|
341
|
+
fs_extra_1.default.writeFileSync(versionFile, versionJson);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
/** 初始化/重置模拟器环境 */
|
|
346
|
+
static initEmulatorEnv() {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
const versionFile = path_1.default.resolve(VelaAvdUtils.sdkHome, 'versions.json');
|
|
349
|
+
const versionFileExist = fs_extra_1.default.existsSync(versionFile);
|
|
350
|
+
let currVersionInfo = {
|
|
351
|
+
name: '模拟器资源版本管理',
|
|
352
|
+
emulator: '',
|
|
353
|
+
qa: '',
|
|
354
|
+
skins: '',
|
|
355
|
+
'system-images': '',
|
|
356
|
+
tools: '',
|
|
357
|
+
modem_simulator: ''
|
|
358
|
+
};
|
|
359
|
+
if (versionFileExist) {
|
|
360
|
+
currVersionInfo = fs_extra_1.default.readJSONSync(versionFile);
|
|
361
|
+
}
|
|
362
|
+
// 模拟器的各项资源是否存在
|
|
363
|
+
const emulatorExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'emulator', VelaAvdUtils.getEmulatorPlatform()));
|
|
364
|
+
const qaExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'qa/font'));
|
|
365
|
+
const skinsExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'skins'));
|
|
366
|
+
const toolsExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'tools'));
|
|
367
|
+
const modemSimulatorExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'modem_simulator/modem_nvram.json'));
|
|
368
|
+
const systemImageExist = fs_extra_1.default.existsSync(path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', constants_1.VelaImageVersionList[0].value, 'nuttx'));
|
|
369
|
+
try {
|
|
370
|
+
// 下载皮肤
|
|
371
|
+
if (!skinsExist || currVersionInfo.skins < constants_1.EmulatorEnvVersion.skins) {
|
|
372
|
+
const skinsUrl = VelaAvdUtils.getDownloadUrl('skins', constants_1.EmulatorEnvVersion.skins);
|
|
373
|
+
yield VelaAvdUtils.downloadAndUnzip(skinsUrl, VelaAvdUtils.getEmulatorEnvHome('skins'));
|
|
374
|
+
currVersionInfo.skins = constants_1.EmulatorEnvVersion.skins;
|
|
375
|
+
ColorConsole_1.default.success(`Download skins succeed.`);
|
|
376
|
+
}
|
|
377
|
+
// 下载快应用font
|
|
378
|
+
if (!qaExist || currVersionInfo.qa < constants_1.EmulatorEnvVersion.qa) {
|
|
379
|
+
const qaUrl = VelaAvdUtils.getDownloadUrl('qa', constants_1.EmulatorEnvVersion.qa);
|
|
380
|
+
yield VelaAvdUtils.downloadAndUnzip(qaUrl, VelaAvdUtils.getEmulatorEnvHome('qa'));
|
|
381
|
+
currVersionInfo.qa = constants_1.EmulatorEnvVersion.qa;
|
|
382
|
+
ColorConsole_1.default.success(`Download quickapp font succeed.`);
|
|
383
|
+
}
|
|
384
|
+
// 下载工具
|
|
385
|
+
if (!toolsExist || currVersionInfo.tools < constants_1.EmulatorEnvVersion.tools) {
|
|
386
|
+
const v9fsToolUrl = VelaAvdUtils.getv9fsToolUrl(constants_1.EmulatorEnvVersion.tools);
|
|
387
|
+
const filename = (os_1.default.platform() === 'win32') ? 'ya-vm-file-server.exe' : 'ya-vm-file-server';
|
|
388
|
+
yield VelaAvdUtils.downloadFromCdn(v9fsToolUrl, VelaAvdUtils.getEmulatorEnvHome('tools'), filename);
|
|
389
|
+
currVersionInfo.tools = constants_1.EmulatorEnvVersion.tools;
|
|
390
|
+
ColorConsole_1.default.success(`Download tools succeed.`);
|
|
391
|
+
}
|
|
392
|
+
// 下载模拟器
|
|
393
|
+
if (!emulatorExist || currVersionInfo.emulator < constants_1.EmulatorEnvVersion.emulator) {
|
|
394
|
+
const emulatorUrl = VelaAvdUtils.getEmulatorUrl(constants_1.EmulatorEnvVersion.emulator);
|
|
395
|
+
yield VelaAvdUtils.downloadAndUnzip(emulatorUrl, VelaAvdUtils.getEmulatorEnvHome('emulator'));
|
|
396
|
+
currVersionInfo.emulator = constants_1.EmulatorEnvVersion.emulator;
|
|
397
|
+
ColorConsole_1.default.success(`Download emulator succeed.`);
|
|
398
|
+
}
|
|
399
|
+
// 下载modem_simultor
|
|
400
|
+
if (!modemSimulatorExist || currVersionInfo.modem_simulator < constants_1.EmulatorEnvVersion.modem_simulator) {
|
|
401
|
+
const modemSimulatorUrl = VelaAvdUtils.getDownloadUrl('modem_simulator', constants_1.EmulatorEnvVersion.modem_simulator);
|
|
402
|
+
yield VelaAvdUtils.downloadAndUnzip(modemSimulatorUrl, VelaAvdUtils.getEmulatorEnvHome('modem_simulator'));
|
|
403
|
+
currVersionInfo.modem_simulator = constants_1.EmulatorEnvVersion.modem_simulator;
|
|
404
|
+
ColorConsole_1.default.success(`Download modem simulator succeed.`);
|
|
405
|
+
}
|
|
406
|
+
// 下载vela镜像,默认只下载最新的vela正式版,dev版本需要创建模拟器的时候手动勾选
|
|
407
|
+
if (!systemImageExist || VelaAvdUtils.velaImageNeedUpdate(constants_1.VelaImageVersionList[0].value)) {
|
|
408
|
+
const systemImageUrl = VelaAvdUtils.getSystemImageUrl(constants_1.VelaImageVersionList[0].value);
|
|
409
|
+
const imageDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', constants_1.VelaImageVersionList[0].value);
|
|
410
|
+
yield VelaAvdUtils.downloadAndUnzip(systemImageUrl, imageDir);
|
|
411
|
+
currVersionInfo['system-images'] = constants_1.EmulatorEnvVersion['system-images'];
|
|
412
|
+
ColorConsole_1.default.success(`Download vela image succeed.`);
|
|
413
|
+
}
|
|
414
|
+
ColorConsole_1.default.success(`Create emulator environment succeed.`);
|
|
415
|
+
}
|
|
416
|
+
catch (e) {
|
|
417
|
+
ColorConsole_1.default.throw(`Create emulator environment failed. Error: ${e.message}`);
|
|
418
|
+
}
|
|
419
|
+
finally {
|
|
420
|
+
// 写入versions.json
|
|
421
|
+
const versionJson = JSON.stringify(currVersionInfo, null, 2);
|
|
422
|
+
fs_extra_1.default.writeFileSync(versionFile, versionJson);
|
|
292
423
|
}
|
|
293
424
|
});
|
|
294
425
|
}
|
|
@@ -296,7 +427,7 @@ class VelaAvdUtils {
|
|
|
296
427
|
VelaAvdUtils.sdkHome = path_1.default.resolve(os_1.default.homedir(), '.export');
|
|
297
428
|
VelaAvdUtils.avdHome = path_1.default.resolve(os_1.default.homedir(), '.android', 'avd');
|
|
298
429
|
VelaAvdUtils.baseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide';
|
|
299
|
-
VelaAvdUtils.versionUrl = 'https://
|
|
430
|
+
VelaAvdUtils.versionUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/versions.json';
|
|
300
431
|
VelaAvdUtils.emulatorBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/emulator';
|
|
301
432
|
VelaAvdUtils.systemImageBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/system-images';
|
|
302
433
|
VelaAvdUtils.velaAvdCls = new emulator_1.VelaAvdCls({
|
|
@@ -304,5 +435,3 @@ VelaAvdUtils.velaAvdCls = new emulator_1.VelaAvdCls({
|
|
|
304
435
|
avdHome: VelaAvdUtils.avdHome
|
|
305
436
|
});
|
|
306
437
|
exports.default = VelaAvdUtils;
|
|
307
|
-
|
|
308
|
-
//# sourceMappingURL=VelaAvdUtils.js.map
|
package/lib/waiter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2-beta.10",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -17,26 +17,32 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"lib"
|
|
19
19
|
],
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "ssh://xujunjie1@git.mioffice.cn:29418/vela/aiot-toolkit"
|
|
23
|
-
},
|
|
24
20
|
"scripts": {
|
|
25
21
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
26
22
|
},
|
|
27
23
|
"dependencies": {
|
|
28
|
-
"@aiot-toolkit/
|
|
29
|
-
"@aiot-toolkit/
|
|
24
|
+
"@aiot-toolkit/commander": "2.0.2-beta.10",
|
|
25
|
+
"@aiot-toolkit/emulator": "2.0.2-beta.10",
|
|
26
|
+
"@aiot-toolkit/shared-utils": "2.0.2-beta.10",
|
|
30
27
|
"@miwt/adb": "^0.7.1",
|
|
31
28
|
"adb-commander": "^0.1.9",
|
|
32
29
|
"adm-zip": "^0.5.10",
|
|
33
30
|
"axios": "^1.5.0",
|
|
34
31
|
"cli-progress": "^3.12.0",
|
|
35
|
-
"create-aiot": "2.0.
|
|
36
|
-
"
|
|
32
|
+
"create-aiot": "2.0.2-beta.10",
|
|
33
|
+
"dayjs": "^1.11.10",
|
|
34
|
+
"fast-glob": "^3.3.2",
|
|
35
|
+
"file-lane": "2.0.2-beta.10",
|
|
36
|
+
"lodash": "^4.17.21",
|
|
37
|
+
"semver": "^7.6.0",
|
|
38
|
+
"ws": "^8.15.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@types/adm-zip": "^0.5.4"
|
|
41
|
+
"@types/adm-zip": "^0.5.4",
|
|
42
|
+
"@types/fs-extra": "^11.0.4",
|
|
43
|
+
"@types/semver": "^7.5.8",
|
|
44
|
+
"@types/ws": "^8.5.10",
|
|
45
|
+
"fs-extra": "^11.2.0"
|
|
40
46
|
},
|
|
41
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "00d23c1ad1306a6c72bb007685de9fd4a6ee61af"
|
|
42
48
|
}
|
package/lib/bin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAqE;AACrE,6DAAsD;AACtD,+FAAsE;AACtE,6CAAkD;AAElD,sEAA6C;AAC7C,gFAAuD;AACvD,oEAA2C;AAC3C,wEAA8C;AAC9C,sDAA6B;AAC7B,qCAAqC;AAErC,SAAS,WAAW,CAAC,WAAmB;IACtC,OAAO,IAAI,oBAAU,EAAE,CAAA;AACzB,CAAC;AAED,SAAS,KAAK,CAAC,OAAe,EAAE,WAAmB;IACjD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACjC,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA;IAEjC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW;QACX,SAAS;QACT,MAAM,EAAE,CAAO,MAAW,EAAE,EAAE;YAC5B,sCAAsC;YACtC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;YACjC,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,CAAA;YACxC,IAAI,OAAO,EAAE;gBACX,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;gBACxB,MAAM,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;gBACxC,IAAI,KAAK,EAAE;oBACT,gBAAM,CAAC,QAAQ,EAAE,CAAA;oBACjB,gBAAM,CAAC,KAAK,EAAE,CAAA;iBACf;aACF;iBAAM;gBACL,sBAAY,CAAC,GAAG,CAA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,qBAAqB;aAErC;SACF,CAAA;QACD,mBAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;CAAA;AACD,IAAI,EAAE,CAAA","file":"bin.js","sourcesContent":["#!/usr/bin/env node\n\nimport { Command, ICommand, IProgram } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { getAiotCreateCommand } from 'create-aiot'\nimport IBuilder from './builder/IBuilder'\nimport XtsBuilder from './builder/XtsBuilder'\nimport GoldfishStarter from './starter/GoldfishStarter'\nimport DeviceUtil from './utils/DeviceUtil'\nimport VelaAvdUtil from './utils/VelaAvdUtils'\nimport waiter from './waiter'\n// 配置支持的 builder 类型,新增的项目类型,只需在此处加上类型\n\nfunction findBuilder(projectPath: string): IBuilder | undefined {\n return new XtsBuilder()\n}\n\nfunction build(command: string, description: string): ICommand {\n const projectPath = process.cwd()\n const builder = findBuilder(projectPath)\n const paramList = builder?.params\n\n return {\n name: command,\n description,\n paramList,\n action: async (option: any) => {\n // 获取对应的 build;如果存在,执行 build 函数,不存在,提示\n const projectPath = process.cwd()\n const builder = findBuilder(projectPath)\n if (builder) {\n const { watch } = option\n await builder.build(projectPath, option)\n if (watch) {\n waiter.describe()\n waiter.start()\n }\n } else {\n ColorConsole.log({\n message: `This type of project is not currently supported. The supported projects : xts`,\n level: LOG_LEVEL.Error,\n isOnlyPrintError: true\n })\n }\n }\n }\n}\n\nasync function main() {\n const aiotCreate = await getAiotCreateCommand()\n const config: IProgram = {\n name: 'aiot-toolkit',\n description: 'contains build, dev, release, etc. commands for aiot toolkit',\n version: '2.0.1',\n commandList: [\n build('build', 'build project'),\n new GoldfishStarter('start', 'start project').getParamList(),\n {\n name: 'getConnectedDevices',\n description: 'get all connected devices',\n action: async (option) => {\n try {\n const connectedDevices = await DeviceUtil.getAllConnectedDevices()\n ColorConsole.log({\n message: `The connected devices are: ${\n connectedDevices ? connectedDevices.join(', ') : 'null'\n }`\n })\n } catch (error) {\n ColorConsole.log({ message: (error as Error).message, level: LOG_LEVEL.Error })\n }\n }\n },\n {\n name: 'getPlatforms',\n description: 'get available platform(s) on selected device',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'port',\n description: 'device port(eg 39517)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'sn',\n description:\n 'view the serial number of the connected device through the \"adb devices\" command, if it is a device connected via wifi, the format is \"ip address:5555\"',\n type: 'string',\n enableInquirer: true\n }\n ],\n action: async (option) => {\n await DeviceUtil.getAvailablePlatform(option)\n }\n },\n {\n name: 'installDbgAndMkp',\n description: 'install \"org.hapjs.debugger\" & \"org.hapjs.mockup\" ',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string'\n },\n {\n name: 'port',\n description: 'device ip(eg 5555)',\n type: 'string'\n }\n ],\n action: async (option) => {\n try {\n const successMessage = await DeviceUtil.installDbgAndMkp(option)\n ColorConsole.log({ message: successMessage, level: LOG_LEVEL.Success })\n } catch (error) {\n ColorConsole.log({ message: (error as Error).message, level: LOG_LEVEL.Error })\n }\n }\n },\n {\n name: 'createVelaAvd',\n description: 'create a vela avd instance',\n action: async () => {\n VelaAvdUtil.createVelaAvdByInquire()\n }\n },\n {\n ...aiotCreate,\n name: 'create',\n description: 'create aiot project'\n }\n ]\n }\n Command.registeProgram(config)\n}\nmain()\n"],"sourceRoot":"../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/IBuilder.ts"],"names":[],"mappings":"","file":"IBuilder.js","sourcesContent":["import { IParam } from '@aiot-toolkit/commander'\n\n/**\n * IBuilder\n */\nexport default interface IBuilder<O = any> {\n /**\n * build 的参数列表\n */\n readonly params: IParam[]\n\n /**\n * 打包项目\n * @param projectPath 项目路径\n * @param options 命令参数\n * @param watch 是否监听文件变化并持续打包\n */\n build(projectPath: string, options: O): void | Promise<void>\n\n /**\n * 当前 builder 是否可打包指定目录的项目\n * @param projectPath 项目目录\n */\n match(projectPath: string): boolean\n}\n"],"sourceRoot":"../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/UxBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uGAA8E;AAC9E,mJAA0H;AAE1H,0FAAiE;AAGjE,iGAAwE;AAExE,yCAAoC;AACpC,wDAAyB;AACzB,oDAA2B;AAC3B,gDAAuB;AAQvB;;GAEG;AACH,MAAM,SAAS;IAAf;QACW,oBAAe,GAAG,oBAAoB,CAAA;QA0D/C,WAAM,GAAgB;YACpB;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,uCAAuC;aACrD;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,mBAAmB;aACjC;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,WAAW,EAAE,qBAAqB;aACnC;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,qBAAqB;gBAClC,YAAY,EAAE,IAAI;gBAClB,cAAc,EAAE,IAAI;aACrB;SACF,CAAA;IAKH,CAAC;IAlFC;;;;;OAKG;IACG,KAAK,CAAC,WAAmB,EAAE,OAAyB;;YACxD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;YACzB,aAAa;YACb,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;YAC3D,OAAO,GAAG,gBAAM,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,CAAA;YACxD,OAAO;YACP,MAAM,eAAe,GAAa,IAAI,kBAAQ,CAAC,WAAW,CAAC,CAAA;YAE3D,OAAO;YACP,MAAM,cAAc,GAAsC,gBAAM,CAAC,KAAK,CACpE;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DefaultCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption'\nimport IJavascriptCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/interface/IJavascriptCompileOption'\nimport UxConfig from '@aiot-toolkit/aiotpack/lib/config/UxConfig'\nimport IQuickAppConfig from '@aiot-toolkit/aiotpack/src/compiler/javascript/vela/interface/IQuickAppConfig'\nimport ParamType from '@aiot-toolkit/commander/lib/interface/IParam'\nimport ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport { FileLane } from 'file-lane'\nimport Fs from 'fs-extra'\nimport Lodash from 'lodash'\nimport Path from 'path'\nimport IBuilder from './IBuilder'\n\ninterface IUxBuilderOption extends Dictionary {\n watch?: boolean\n mode: CompileMode\n}\n\n/**\n * UxBuilder\n */\nclass UxBuilder implements IBuilder<IUxBuilderOption> {\n readonly QUICKAPP_CONFIG = 'quickapp.config.js'\n /**\n * ux项目的build函数\n * @param projectPath 项目路径\n * @param options 命令参数\n * @param watch 是否开启监听\n */\n async build(projectPath: string, options: IUxBuilderOption): Promise<void> {\n const { watch } = options\n // 读取项目中文件的配置\n const quickappConfig = this.readQuickAppConfig(projectPath)\n options = Lodash.merge({}, options, quickappConfig?.cli)\n // 项目配置\n const uxProjectConfig: UxConfig = new UxConfig(projectPath)\n\n // 编译配置\n const compilerOption: Partial<IJavascriptCompileOption> = Lodash.merge(\n {\n projectPath: Path.join(projectPath, uxProjectConfig.output),\n mode: CompileMode.DEVELOPMENT,\n disabledJSC: options.disabledJsc\n },\n JavascriptDefaultCompileOption,\n quickappConfig?.webpack\n )\n\n ColorConsole2.info({\n word: JSON.stringify(\n {\n step: 'build ux',\n projectPath,\n options,\n watch\n },\n null,\n 2\n )\n })\n // 开始编译项目\n await new FileLane<IJavascriptCompileOption>(\n uxProjectConfig,\n projectPath,\n compilerOption as IJavascriptCompileOption\n ).start({ watch })\n }\n\n private readQuickAppConfig(projectPath: string): IQuickAppConfig | undefined {\n const path = Path.join(projectPath, this.QUICKAPP_CONFIG)\n if (Fs.existsSync(path)) {\n try {\n return Fs.readJsonSync(path)\n } catch (error) {\n ColorConsole2.throw(error?.toString() || '')\n }\n }\n return\n }\n static readonly PROJECT_TYPE = 'ux quick app'\n params: ParamType[] = [\n {\n name: 'enable-e2e',\n description: 'inject test-suite for current project'\n },\n {\n name: 'devtool',\n description: 'source map config'\n },\n {\n name: 'disable-subpackages',\n description: 'disable subpackages'\n },\n {\n type: 'confirm',\n name: 'disabled-jsc',\n description: 'disabled jsc bundle',\n defaultValue: true,\n enableInquirer: true\n }\n ]\n\n match(projectPath: string): boolean {\n return projectPath.includes('ux')\n }\n}\nexport default UxBuilder\n"],"sourceRoot":"../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAKlD,0FAA+E;AAG/E,6DAAsD;AACtD,+FAAsE;AACtE,iGAAwE;AACxE,yCAAoC;AACpC,4CAAmB;AACnB,gDAAuB;AAQvB;;GAEG;AACH,MAAM,UAAU;IAAhB;QA4BW,WAAM,GAAa;YAC1B;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,0JAA0J;gBAC5J,QAAQ,CAAC,KAAa;oBACpB,sBAAsB;oBACtB,MAAM,GAAG,GAAG,oBAAU,CAAC,mBAAmB,CAAC,KAAK,CAAqB,CAAA;oBACrE,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;wBAC7B,OAAO,CAAC,0BAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;oBAC9B,CAAC,CAAC,CAAA;oBAEF,IAAI,OAAO,EAAE;wBACX,OAAO,GAAG,OAAO,uCAAuC,0BAAQ,CAAC,IAAI,CACnE,GAAG,CACJ,uCAAuC,CAAA;qBACzC;oBACD,OAAO,IAAI,CAAA;gBACb,CAAC;aACF;SACF,CAAA;IACH,CAAC;IA/CC,KAAK,CAAC,WAAmB;QACvB,wBAAwB;QACxB,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA;IAChE,CAAC;IAEK,KAAK,CAAC,WAAmB,EAAE,OAAuB;;YACtD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;YACzB,sBAAY,CAAC,GAAG,CAAC;gBACf,OAAO,EAAE,IAAI,CAAC,SAAS,CACrB;oBACE,WAAW;oBACX,OAAO;iBACR,EACD,SAAS,EACT,CAAC,CACF;gBACD,KAAK,EAAE,wBAAS,CAAC,OAAO;aACzB,CAAC,CAAA;YACF,MAAM,eAAe,GAAuB;gBAC1C,IAAI,EAAE,oBAAU,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAyB;aAC3E,CAAA;YACD,MAAM,MAAM,GAAG,IAAI,oBAAS,EAAE,CAAA;YAC9B,OAAO,IAAI,oBAAQ,CAAqB,MAAM,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAChG,CAAC;KAAA;;AAzBe,uBAAY,GAAG,eAAH,AAAkB,CAAA;AAkDhD,kBAAe,UAAU,CAAA","file":"XtsBuilder.js","sourcesContent":["import { XtsConfig } from '@aiot-toolkit/aiotpack'\nimport type {\n ISkipList,\n IXtsCompileOptions\n} from '@aiot-toolkit/aiotpack/lib/interface/ICompileOptions'\nimport { skipList } from '@aiot-toolkit/aiotpack/lib/interface/ICompileOptions'\n\nimport { IParam } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport StringUtil from '@aiot-toolkit/shared-utils/lib/utils/StringUtil'\nimport { FileLane } from 'file-lane'\nimport fs from 'fs'\nimport path from 'path'\nimport IBuilder from './IBuilder'\n\nexport interface IBuilderOption {\n watch?: boolean\n skip?: string\n}\n\n/**\n * XtsBuilder\n */\nclass XtsBuilder implements IBuilder<IBuilderOption> {\n static readonly PROJECT_TYPE = 'xts quick app'\n\n match(projectPath: string): boolean {\n // app/app.xts 存在视为xts项目\n return fs.existsSync(path.resolve(projectPath, 'app/app.xts'))\n }\n\n async build(projectPath: string, options: IBuilderOption) {\n const { watch } = options\n ColorConsole.log({\n message: JSON.stringify(\n {\n projectPath,\n options\n },\n undefined,\n 2\n ),\n level: LOG_LEVEL.Success\n })\n const compilerOptions: IXtsCompileOptions = {\n skip: StringUtil.string2arrayByComma(options.skip) as unknown as ISkipList\n }\n const config = new XtsConfig()\n return new FileLane<IXtsCompileOptions>(config, projectPath, compilerOptions).start({ watch })\n }\n\n readonly params: IParam[] = [\n {\n name: 'skip',\n type: 'string',\n description:\n 'Can configure skip steps, comma separated, optional values: install (skip install pre-dependencies),ts2wasm (skip compilation), package (skip packaging)',\n validate(value: string) {\n // TODO: validate 不起作用\n const res = StringUtil.string2arrayByComma(value) as any as ISkipList\n const unValid = res.find((r) => {\n return !skipList.includes(r)\n })\n\n if (unValid) {\n return `${unValid} is unvalidate, validate value are ${skipList.join(\n ','\n )}, Multiple values separated by commas`\n }\n return true\n }\n }\n ]\n}\nexport default XtsBuilder\n"],"sourceRoot":"../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["interface/CommandInterface.ts"],"names":[],"mappings":"","file":"CommandInterface.js","sourcesContent":["/**\n * IInstallApkAndDbg\n */\nexport interface IInstallApkAndDbg {\n ip?: string\n port?: string\n platform?: string\n apkVersion?: string\n forceInstall?: boolean\n}\nexport interface IGetAvailablePlatform {\n ip: string\n port: string\n sn: string\n}\n"],"sourceRoot":"../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["interface/VelaEmulatorInterface.ts"],"names":[],"mappings":"","file":"VelaEmulatorInterface.js","sourcesContent":["export interface IGoldfishVersionInfo {\n name: string;\n emulator: string;\n 'system-images': string;\n qa: string;\n skins: string;\n tools: string;\n}"],"sourceRoot":"../../src"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ICommand } from '@aiot-toolkit/commander';
|
|
2
|
-
declare class GoldfishStarter {
|
|
3
|
-
private name;
|
|
4
|
-
private description;
|
|
5
|
-
constructor(name: string, description: string);
|
|
6
|
-
getParamList(): ICommand;
|
|
7
|
-
start(option: any): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export default GoldfishStarter;
|