aiot-toolkit 2.0.6-beta.1 → 2.0.6-beta.2

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.
Files changed (3) hide show
  1. package/README.md +10 -9
  2. package/lib/bin.js +26 -10
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -98,17 +98,18 @@ folder
98
98
 
99
99
  指定目录的js文件转换为jsc文件
100
100
 
101
- | 参数名 | 类型 | 描述 | 必填 | 默认值 |
102
- | -------- | ------- | ---------------- | ---- | ------ |
103
- | path | string | 转换的目录 | | |
104
- | deletejs | boolean | 是否删除源js文件 | 否 | false |
101
+ | 参数名 | 类型 | 描述 | 必填 | 默认值 |
102
+ | -------- | ------- | ------------------------------------------ | ---- | --------- |
103
+ | source | string | 源目录, `绝对路径` 或 `相对当前目录的路径` | | `./` |
104
+ | output | string | 产物目录 | 否 | `../dist` |
105
+ | deletejs | boolean | 产物目录,是否删除js文件 | 否 | false |
105
106
 
106
- ### 删除
107
+ ### 示例
107
108
 
108
109
  ```shell
109
- aiot jsc --path=folder
110
- ```
110
+ # `当前目录`的文件生成到 `../dist`
111
+ aiot jsc
111
112
 
112
- ```shell
113
- aiot jsc --path=folder --deletejs
113
+ # `build目录` 的文件生成到 `myDist`, 且删除myDist中的js文件
114
+ aiot jsc --source=build --output=myDist --deletejs
114
115
  ```
package/lib/bin.js CHANGED
@@ -14,7 +14,8 @@ 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
16
  var _Jsc = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/utils/Jsc"));
17
- var _fs = _interopRequireDefault(require("fs"));
17
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
18
+ var _path = _interopRequireDefault(require("path"));
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  // 支持的最低node版本
20
21
  const NODE_MINIMUM_VERSION = '18.0.0';
@@ -192,8 +193,15 @@ async function main() {
192
193
  name: 'jsc',
193
194
  description: 'transform js file to jsc file',
194
195
  paramList: [{
195
- name: 'path',
196
- description: 'source folder'
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'
197
205
  }, {
198
206
  name: 'deletejs',
199
207
  description: 'delete js file after transform',
@@ -213,16 +221,24 @@ async function main() {
213
221
  */
214
222
  function translateJsToJsc(option) {
215
223
  const {
216
- path,
217
- deletejs
224
+ source,
225
+ deletejs,
226
+ output = 'dist'
218
227
  } = option;
219
- if (!path) {
220
- _sharedUtils.ColorConsole.throw('Please provide a valid path for the jsc command.');
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.');
221
232
  return;
222
- } else if (!_fs.default.existsSync(path)) {
223
- _sharedUtils.ColorConsole.throw(`The provided path "${path}" does not exist.`);
233
+ } else if (!_fsExtra.default.existsSync(sourcePath)) {
234
+ _sharedUtils.ColorConsole.throw(`The provided source "${sourcePath}" does not exist.`);
224
235
  return;
225
236
  }
226
- return new _Jsc.default(process.cwd(), path).jsc(deletejs);
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);
227
243
  }
228
244
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiot-toolkit",
3
- "version": "2.0.6-beta.1",
3
+ "version": "2.0.6-beta.2",
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-beta.1",
26
- "@aiot-toolkit/commander": "2.0.6-beta.1",
27
- "@aiot-toolkit/emulator": "2.0.6-beta.1",
28
- "@aiot-toolkit/shared-utils": "2.0.6-beta.1",
25
+ "@aiot-toolkit/aiotpack": "2.0.6-beta.2",
26
+ "@aiot-toolkit/commander": "2.0.6-beta.2",
27
+ "@aiot-toolkit/emulator": "2.0.6-beta.2",
28
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.2",
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-beta.1",
32
+ "file-lane": "2.0.6-beta.2",
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": "892743ccc51408960e6cee86675538501b3e47f1"
46
+ "gitHead": "d0057f9e62ac191d21445787667217cfa4aff1e9"
47
47
  }