aiot-toolkit 2.0.1-alpha.3 → 2.0.1-alpha.4
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/lib/bin.js +9 -0
- package/lib/bin.js.map +1 -1
- package/lib/builder/XtsBuilder.js +5 -20
- package/lib/builder/XtsBuilder.js.map +1 -1
- package/package.json +5 -5
package/lib/bin.js
CHANGED
|
@@ -70,6 +70,15 @@ function build(command, description) {
|
|
|
70
70
|
}
|
|
71
71
|
function start(command, description) {
|
|
72
72
|
const avdList = VelaAvdUtils_1.default.velaAvdCls.getVelaAvdList();
|
|
73
|
+
if (avdList.length === 0) {
|
|
74
|
+
ColorConsole_1.default.log({
|
|
75
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
76
|
+
message: 'No emulator available, please create it first.',
|
|
77
|
+
isOnlyPrintError: true
|
|
78
|
+
});
|
|
79
|
+
VelaAvdUtils_1.default.createVelaAvdByInquire();
|
|
80
|
+
return { name: command, description, paramList: [], action: (option) => __awaiter(this, void 0, void 0, function* () { }) };
|
|
81
|
+
}
|
|
73
82
|
return {
|
|
74
83
|
name: command,
|
|
75
84
|
description,
|
package/lib/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAwF;AACxF,qDAAyD;AACzD,6DAAsD;AACtD,+FAAsE;AACtE,6CAAkD;AAClD,4CAAmB;AACnB,gDAAuB;AAEvB,oEAA2C;AAC3C,sEAA6C;AAC7C,oEAA2C;AAC3C,wEAA8C;AAC9C,sDAA6B;AAC7B,qCAAqC;AACrC,MAAM,eAAe,GAAG,CAAC,mBAAS,EAAE,oBAAU,CAAC,CAAA;AAE/C,SAAS,WAAW,CAAC,WAAmB;IACtC,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE;QAClC,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAA;QAC3B,IAA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AC,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAS,CAAC,KAAK,EAAE,CAAC,CAAA;yBAChF;oBACH,CAAC,CAAA;iBACF;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,WAAW,EAAE,4BAA4B;oBACzC,MAAM,EAAE,GAAS,EAAE;wBACjB,sBAAW,CAAC,sBAAsB,EAAE,CAAA;oBACtC,CAAC,CAAA;iBACF;gDAEI,UAAU,KACb,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,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, PersistentCommand } from '@aiot-toolkit/commander'\nimport { GoldfishInstance } from '@aiot-toolkit/emulator'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { getAiotCreateCommand } from 'create-aiot'\nimport os from 'os'\nimport path from 'path'\nimport IBuilder from './builder/IBuilder'\nimport UxBuilder from './builder/UxBuilder'\nimport XtsBuilder from './builder/XtsBuilder'\nimport DeviceUtil from './utils/DeviceUtil'\nimport VelaAvdUtil from './utils/VelaAvdUtils'\nimport waiter from './waiter'\n// 配置支持的 builder 类型,新增的项目类型,只需在此处加上类型\nconst builderTypeList = [UxBuilder, XtsBuilder]\n\nfunction findBuilder(projectPath: string): IBuilder | undefined {\n for (const item of builderTypeList) {\n const instance = new item()\n if (instance.match(projectPath)) {\n return instance\n }\n }\n return new UxBuilder()\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 are: ${builderTypeList\n .map((item) => item.PROJECT_TYPE)\n .join('、')}`,\n level: LOG_LEVEL.Error,\n isOnlyPrintError: true\n })\n }\n }\n }\n}\n\nfunction start(command: string, description: string): ICommand {\n const avdList = VelaAvdUtil.velaAvdCls.getVelaAvdList()\n return {\n name: command,\n description,\n paramList: [\n {\n name: 'avdname',\n description: 'name of the avd to start',\n type: 'select',\n choices: avdList.map((item) => {\n return { value: item.avdName }\n }),\n enableInquirer: true\n },\n {\n name: 'devtool',\n description: 'source map config'\n },\n {\n name: 'disableNSH',\n description: 'disable goldfish NSH terminal',\n defaultValue: false,\n type: 'confirm'\n }\n ],\n action: async (option: any) => {\n const goldfishInstance = new GoldfishInstance({\n sdkHome: path.resolve(os.homedir(), '.export'),\n avdHome: path.resolve(os.homedir(), '.android/avd'),\n projectPath: process.cwd()\n })\n const startOptions = {\n avdName: option.avdname,\n devtool: option.devtool,\n disableNSH: option.disableNSH\n }\n goldfishInstance.start(startOptions)\n // waiter\n const startWaiter: PersistentCommand = new PersistentCommand({\n description: 'aiot-toolkit start 的常驻命令',\n options: [\n {\n key: 'r',\n description: `重启快应用 ${option.disableNSH ? '' : '(需要手动关闭模拟器)'}`,\n action() {\n console.log('重启中......')\n goldfishInstance.stop()\n goldfishInstance.start(startOptions)\n }\n },\n {\n key: '?',\n description: '显示所有命令',\n action() {\n startWaiter.clearLog()\n startWaiter.describe()\n }\n }\n ]\n })\n startWaiter.describe()\n startWaiter.start()\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 start('start', 'start project in goldfish'),\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
|
+
{"version":3,"sources":["bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAwF;AACxF,qDAAyD;AACzD,6DAAsD;AACtD,+FAAsE;AACtE,6CAAkD;AAClD,4CAAmB;AACnB,gDAAuB;AAEvB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,EAAE;wBACvB,MAAM,oBAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;oBAC/C,CAAC,CAAA;iBACF;gBACD;oBACE,IAAI,EAAE,kBAAkB;oBACxB,WAAW,EAAE,oDAAoD;oBACjE,SAAS,EAAE;wBACT;4BACE,IAAI,EAAE,IAAI;4BACV,WAAW,EAAE,yBAAyB;4BACtC,IAAI,EAAE,QAAQ;yBACf;wBACD;4BACE,IAAI,EAAE,MAAM;4BACZ,WAAW,EAAE,oBAAoB;4BACjC,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,MAAM,EAAE,CAAO,MAAM,EAAE,EAAE;wBACvB,IAAI;4BACF,MAAM,cAAc,GAAG,MAAM,oBAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;4BAChE,sBAAY,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAS,CAAC,OAAO,EAAE,CAAC,CAAA;yBACxE;wBAAC,OAAO,KAAK,EAAE;4BACd,sBAAY,CAAC,GAAG,CAAC,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAS,CAAC,KAAK,EAAE,CAAC,CAAA;yBAChF;oBACH,CAAC,CAAA;iBACF;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,WAAW,EAAE,4BAA4B;oBACzC,MAAM,EAAE,GAAS,EAAE;wBACjB,sBAAW,CAAC,sBAAsB,EAAE,CAAA;oBACtC,CAAC,CAAA;iBACF;gDAEI,UAAU,KACb,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,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, PersistentCommand } from '@aiot-toolkit/commander'\nimport { GoldfishInstance } from '@aiot-toolkit/emulator'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { getAiotCreateCommand } from 'create-aiot'\nimport os from 'os'\nimport path from 'path'\nimport IBuilder from './builder/IBuilder'\nimport UxBuilder from './builder/UxBuilder'\nimport XtsBuilder from './builder/XtsBuilder'\nimport DeviceUtil from './utils/DeviceUtil'\nimport VelaAvdUtil from './utils/VelaAvdUtils'\nimport waiter from './waiter'\n// 配置支持的 builder 类型,新增的项目类型,只需在此处加上类型\nconst builderTypeList = [UxBuilder, XtsBuilder]\n\nfunction findBuilder(projectPath: string): IBuilder | undefined {\n for (const item of builderTypeList) {\n const instance = new item()\n if (instance.match(projectPath)) {\n return instance\n }\n }\n return new UxBuilder()\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 are: ${builderTypeList\n .map((item) => item.PROJECT_TYPE)\n .join('、')}`,\n level: LOG_LEVEL.Error,\n isOnlyPrintError: true\n })\n }\n }\n }\n}\n\nfunction start(command: string, description: string): ICommand {\n const avdList = VelaAvdUtil.velaAvdCls.getVelaAvdList()\n if (avdList.length === 0) {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: 'No emulator available, please create it first.',\n isOnlyPrintError: true\n })\n VelaAvdUtil.createVelaAvdByInquire()\n return { name: command, description, paramList: [], action: async (option: any) => {} }\n }\n return {\n name: command,\n description,\n paramList: [\n {\n name: 'avdname',\n description: 'name of the avd to start',\n type: 'select',\n choices: avdList.map((item) => {\n return { value: item.avdName }\n }),\n enableInquirer: true\n },\n {\n name: 'devtool',\n description: 'source map config'\n },\n {\n name: 'disableNSH',\n description: 'disable goldfish NSH terminal',\n defaultValue: false,\n type: 'confirm'\n }\n ],\n action: async (option: any) => {\n const goldfishInstance = new GoldfishInstance({\n sdkHome: path.resolve(os.homedir(), '.export'),\n avdHome: path.resolve(os.homedir(), '.android/avd'),\n projectPath: process.cwd()\n })\n const startOptions = {\n avdName: option.avdname,\n devtool: option.devtool,\n disableNSH: option.disableNSH\n }\n goldfishInstance.start(startOptions)\n // waiter\n const startWaiter: PersistentCommand = new PersistentCommand({\n description: 'aiot-toolkit start 的常驻命令',\n options: [\n {\n key: 'r',\n description: `重启快应用 ${option.disableNSH ? '' : '(需要手动关闭模拟器)'}`,\n action() {\n console.log('重启中......')\n goldfishInstance.stop()\n goldfishInstance.start(startOptions)\n }\n },\n {\n key: '?',\n description: '显示所有命令',\n action() {\n startWaiter.clearLog()\n startWaiter.describe()\n }\n }\n ]\n })\n startWaiter.describe()\n startWaiter.start()\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 start('start', 'start project in goldfish'),\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"}
|
|
@@ -16,33 +16,18 @@ const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
|
16
16
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
17
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
18
18
|
const file_lane_1 = require("file-lane");
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
19
21
|
/**
|
|
20
22
|
* XtsBuilder
|
|
21
23
|
*/
|
|
22
24
|
class XtsBuilder {
|
|
23
25
|
constructor() {
|
|
24
|
-
this.params = [
|
|
25
|
-
{
|
|
26
|
-
name: 'p1',
|
|
27
|
-
description: 'xts 的第1个参数',
|
|
28
|
-
type: 'string'
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'p2',
|
|
32
|
-
description: 'xts 的第2个参数',
|
|
33
|
-
type: 'string',
|
|
34
|
-
enableInquirer: true
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'watch',
|
|
38
|
-
description: 'watch file change',
|
|
39
|
-
defaultValue: false,
|
|
40
|
-
type: 'confirm'
|
|
41
|
-
}
|
|
42
|
-
];
|
|
26
|
+
this.params = [];
|
|
43
27
|
}
|
|
44
28
|
match(projectPath) {
|
|
45
|
-
|
|
29
|
+
// app/app.xts 存在视为xts项目
|
|
30
|
+
return fs_1.default.existsSync(path_1.default.resolve(projectPath, 'app/app.xts'));
|
|
46
31
|
}
|
|
47
32
|
build(projectPath, options) {
|
|
48
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,6DAAsD;AACtD,+FAAsE;AACtE,yCAAoC;
|
|
1
|
+
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,6DAAsD;AACtD,+FAAsE;AACtE,yCAAoC;AACpC,4CAAmB;AACnB,gDAAuB;AAOvB;;GAEG;AACH,MAAM,UAAU;IAAhB;QAyBW,WAAM,GAAa,EAAE,CAAA;IAChC,CAAC;IAvBC,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,MAAM,GAAG,IAAI,oBAAS,EAAE,CAAA;YAC9B,OAAO,IAAI,oBAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC3D,CAAC;KAAA;;AAtBe,uBAAY,GAAG,eAAH,AAAkB,CAAA;AA0BhD,kBAAe,UAAU,CAAA","file":"XtsBuilder.js","sourcesContent":["import { XtsConfig } from '@aiot-toolkit/aiotpack'\nimport { IParam } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { FileLane } from 'file-lane'\nimport fs from 'fs'\nimport path from 'path'\nimport IBuilder from './IBuilder'\n\ninterface IBuilderOption {\n watch?: boolean\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 config = new XtsConfig()\n return new FileLane(config, projectPath).start({ watch })\n }\n\n readonly params: IParam[] = []\n}\nexport default XtsBuilder\n"],"sourceRoot":"../../src"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.4",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aiot-toolkit/emulator": "2.0.1-alpha.
|
|
29
|
-
"@aiot-toolkit/shared-utils": "2.0.1-alpha.
|
|
28
|
+
"@aiot-toolkit/emulator": "2.0.1-alpha.4",
|
|
29
|
+
"@aiot-toolkit/shared-utils": "2.0.1-alpha.4",
|
|
30
30
|
"@miwt/adb": "^0.7.1",
|
|
31
31
|
"adb-commander": "^0.1.9",
|
|
32
32
|
"adm-zip": "^0.5.10",
|
|
33
33
|
"axios": "^1.5.0",
|
|
34
34
|
"cli-progress": "^3.12.0",
|
|
35
|
-
"create-aiot": "2.0.1-alpha.
|
|
35
|
+
"create-aiot": "2.0.1-alpha.4",
|
|
36
36
|
"fast-glob": "^3.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/adm-zip": "^0.5.4"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "da4d5ab15aa1b8bcde3250a58d6e9a50e098cc20"
|
|
42
42
|
}
|