aiot-toolkit 2.0.6-alpha.1 → 2.0.6-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 +21 -0
- package/lib/bin.js +51 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ aiot-toolkit2.0目前支持的打包格式如下:
|
|
|
51
51
|
| aiot createVVD | 创建 vela 模拟器 |
|
|
52
52
|
| aiot deleteVVD | 删除 vela 模拟器 |
|
|
53
53
|
| aiot resign | build目录重新生成rpk, 详情: [resign](#resign) |
|
|
54
|
+
| aiot jsc | js转换为jsc文件, 详情:[jsc](#jsc) |
|
|
54
55
|
|
|
55
56
|
## build 参数
|
|
56
57
|
|
|
@@ -92,3 +93,23 @@ folder
|
|
|
92
93
|
dist // 生成
|
|
93
94
|
***.rpk
|
|
94
95
|
```
|
|
96
|
+
|
|
97
|
+
## jsc
|
|
98
|
+
|
|
99
|
+
指定目录的js文件转换为jsc文件
|
|
100
|
+
|
|
101
|
+
| 参数名 | 类型 | 描述 | 必填 | 默认值 |
|
|
102
|
+
| -------- | ------- | ------------------------------------------ | ---- | --------- |
|
|
103
|
+
| source | string | 源目录, `绝对路径` 或 `相对当前目录的路径` | 否 | `./` |
|
|
104
|
+
| output | string | 产物目录 | 否 | `../dist` |
|
|
105
|
+
| deletejs | boolean | 产物目录,是否删除js文件 | 否 | false |
|
|
106
|
+
|
|
107
|
+
### 示例
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
# `当前目录`的文件生成到 `../dist`
|
|
111
|
+
aiot jsc
|
|
112
|
+
|
|
113
|
+
# `build目录` 的文件生成到 `myDist`, 且删除myDist中的js文件
|
|
114
|
+
aiot jsc --source=build --output=myDist --deletejs
|
|
115
|
+
```
|
package/lib/bin.js
CHANGED
|
@@ -13,6 +13,9 @@ var _DeviceUtil = _interopRequireDefault(require("./utils/DeviceUtil"));
|
|
|
13
13
|
var _VelaAvdUtils = _interopRequireDefault(require("./utils/VelaAvdUtils"));
|
|
14
14
|
var _ZipUtil = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/utils/ZipUtil"));
|
|
15
15
|
var _BuildNameFormatType = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/enum/BuildNameFormatType"));
|
|
16
|
+
var _Jsc = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/utils/Jsc"));
|
|
17
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
18
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
20
|
// 支持的最低node版本
|
|
18
21
|
const NODE_MINIMUM_VERSION = '18.0.0';
|
|
@@ -186,8 +189,56 @@ async function main() {
|
|
|
186
189
|
};
|
|
187
190
|
return _ZipUtil.default.createRpk(projectPath + '/build', param);
|
|
188
191
|
}
|
|
192
|
+
}, {
|
|
193
|
+
name: 'jsc',
|
|
194
|
+
description: 'transform js file to jsc file',
|
|
195
|
+
paramList: [{
|
|
196
|
+
name: 'source',
|
|
197
|
+
description: 'source folder',
|
|
198
|
+
type: 'string',
|
|
199
|
+
defaultValue: './'
|
|
200
|
+
}, {
|
|
201
|
+
name: 'output',
|
|
202
|
+
description: 'output folder',
|
|
203
|
+
type: 'string',
|
|
204
|
+
defaultValue: '../dist'
|
|
205
|
+
}, {
|
|
206
|
+
name: 'deletejs',
|
|
207
|
+
description: 'delete js file after transform',
|
|
208
|
+
type: 'confirm',
|
|
209
|
+
defaultValue: false
|
|
210
|
+
}],
|
|
211
|
+
action: translateJsToJsc
|
|
189
212
|
}]
|
|
190
213
|
};
|
|
191
214
|
_commander.Command.registeProgram(config);
|
|
192
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* js 文件转换为 jsc 文件
|
|
219
|
+
* @param option
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
function translateJsToJsc(option) {
|
|
223
|
+
const {
|
|
224
|
+
source,
|
|
225
|
+
deletejs,
|
|
226
|
+
output = 'dist'
|
|
227
|
+
} = option;
|
|
228
|
+
const sourcePath = _path.default.resolve(process.cwd(), source);
|
|
229
|
+
const outputPath = _path.default.resolve(process.cwd(), output);
|
|
230
|
+
if (!sourcePath) {
|
|
231
|
+
_sharedUtils.ColorConsole.throw('Please provide a valid source for the jsc command.');
|
|
232
|
+
return;
|
|
233
|
+
} else if (!_fsExtra.default.existsSync(sourcePath)) {
|
|
234
|
+
_sharedUtils.ColorConsole.throw(`The provided source "${sourcePath}" does not exist.`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
_fsExtra.default.removeSync(outputPath);
|
|
238
|
+
_fsExtra.default.mkdirSync(outputPath, {
|
|
239
|
+
recursive: true
|
|
240
|
+
});
|
|
241
|
+
_fsExtra.default.copySync(source, outputPath);
|
|
242
|
+
return new _Jsc.default(process.cwd(), outputPath).jsc(deletejs);
|
|
243
|
+
}
|
|
193
244
|
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.6-
|
|
3
|
+
"version": "2.0.6-beta.10",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aiot-toolkit/aiotpack": "2.0.6-
|
|
26
|
-
"@aiot-toolkit/commander": "2.0.6-
|
|
27
|
-
"@aiot-toolkit/emulator": "2.0.6-
|
|
28
|
-
"@aiot-toolkit/shared-utils": "2.0.6-
|
|
25
|
+
"@aiot-toolkit/aiotpack": "2.0.6-beta.10",
|
|
26
|
+
"@aiot-toolkit/commander": "2.0.6-beta.10",
|
|
27
|
+
"@aiot-toolkit/emulator": "2.0.6-beta.10",
|
|
28
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.10",
|
|
29
29
|
"@inquirer/prompts": "^5.3.0",
|
|
30
30
|
"@miwt/adb": "^0.9.0",
|
|
31
31
|
"axios": "^1.7.4",
|
|
32
|
-
"file-lane": "2.0.6-
|
|
32
|
+
"file-lane": "2.0.6-beta.10",
|
|
33
33
|
"fs-extra": "^11.2.0",
|
|
34
34
|
"koa-router": "^13.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@types/qr-image": "^3.2.9",
|
|
44
44
|
"@types/semver": "^7.5.8"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b6a63385af95a6ba445e65225a92014026ce3144"
|
|
47
47
|
}
|