@aiot-toolkit/aiotpack 2.0.6-beta.3 → 2.0.6-beta.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.
@@ -100,13 +100,13 @@ class UxAfterCompile {
100
100
  static toRpk = async params => {
101
101
  const {
102
102
  compilerOption,
103
- compalition,
103
+ compilation,
104
104
  context
105
105
  } = params;
106
106
  if (compilerOption) {
107
107
  const fileName = await _ZipUtil.default.createRpk(_path.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
108
- if (compalition && fileName) {
109
- compalition.info.rpk = _path.default.join(context.projectPath, compilerOption.releasePath, fileName);
108
+ if (compilation && fileName) {
109
+ compilation.info.rpk = _path.default.join(context.projectPath, compilerOption.releasePath, fileName);
110
110
  }
111
111
  return fileName;
112
112
  }
@@ -196,13 +196,15 @@ class UxAfterCompile {
196
196
  }
197
197
 
198
198
  // feature
199
+ // 无需检查的feature
200
+ const ignoreFeatureList = ['system.router', 'system.configuration', 'system.app'];
199
201
  if (translateCache?.featureCache.size) {
200
202
  // 消息提示
201
203
  // 1. 获取未手动配置的 feature
202
204
  // 2. 如果开启自动填充,则 info;否则 warn
203
205
  const featureSet = new Set([...Array.from(translateCache.featureCache), ...(content.features || []).map(item => item.name)]);
204
206
  const usedList = Array.from(featureSet).filter(Boolean);
205
- const unSetList = usedList.filter(featureItem => !content.features?.find(item => item.name === featureItem));
207
+ const unSetList = usedList.filter(featureItem => !ignoreFeatureList.includes(featureItem) && !content.features?.find(item => item.name === featureItem));
206
208
  if (unSetList?.length) {
207
209
  const featureMessage = {
208
210
  word: `\n${JSON.stringify(unSetList.map(item => ({
@@ -313,13 +315,13 @@ class UxAfterCompile {
313
315
  static generateDiff = async params => {
314
316
  const {
315
317
  compilerOption,
316
- compalition,
318
+ compilation,
317
319
  context
318
320
  } = params;
319
- if (!compilerOption || !compalition) {
321
+ if (!compilerOption || !compilation) {
320
322
  return;
321
323
  }
322
- if (compalition.trigger === _FileLaneTriggerType.default.START) {
324
+ if (compilation.trigger === _FileLaneTriggerType.default.START) {
323
325
  return;
324
326
  }
325
327
  // 读取临时项目build文件夹中所有文件路径
@@ -327,7 +329,7 @@ class UxAfterCompile {
327
329
  // 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
328
330
  const tempFileList = _sharedUtils.FileUtil.readAlldirSync(tempBuildDir);
329
331
  const buildDir = _path.default.join(context.projectPath, compilerOption.outputPath);
330
- const diffList = _UxFileUtils.default.getDiffJSON(compalition.buildFileList, tempFileList, buildDir, tempBuildDir);
332
+ const diffList = _UxFileUtils.default.getDiffJSON(compilation.buildFileList, tempFileList, buildDir, tempBuildDir);
331
333
 
332
334
  // 所有差异文件,压缩到 .diff.rpk 中
333
335
  if (diffList?.length) {
@@ -339,8 +341,8 @@ class UxAfterCompile {
339
341
  filePath: _path.default.join(buildFold, item),
340
342
  zipFilePath: item
341
343
  })));
342
- compalition.info.diffList = diffList;
343
- compalition.info.diffFile = _path.default.join(context.projectPath, compilerOption.releasePath, diffFileName);
344
+ compilation.info.diffList = diffList;
345
+ compilation.info.diffFile = _path.default.join(context.projectPath, compilerOption.releasePath, diffFileName);
344
346
  }
345
347
  };
346
348
 
@@ -420,10 +422,11 @@ class UxAfterCompile {
420
422
  static compileLiteCard = async params => {
421
423
  const {
422
424
  compilerOption,
423
- context
425
+ context,
426
+ compilation
424
427
  } = params;
425
428
  try {
426
- if (context?.liteCards?.length > 0 && compilerOption) {
429
+ if (compilation && compilation?.liteCards?.length > 0 && compilerOption) {
427
430
  const {
428
431
  projectPath: tempProjectPath,
429
432
  outputPath: LITE_OUTPUT_PATH
@@ -434,7 +437,7 @@ class UxAfterCompile {
434
437
  // 1.
435
438
  await new _LiteCard.default(projectPath).compileLiteCard();
436
439
  // 2.
437
- context.liteCards.forEach(card => {
440
+ compilation.liteCards.forEach(card => {
438
441
  // hap-toolkit的产物在项目的build文件夹下
439
442
  const fromPath = _path.default.join(projectPath, LITE_OUTPUT_PATH, card);
440
443
  // aiot-toolkit的产物在临时项目的build文件夹下
@@ -1,11 +1,13 @@
1
1
  import { IFileLaneContext } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../../interface/IJavascriptCompileOption';
3
3
  import { ILog } from '@aiot-toolkit/shared-utils';
4
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  /**
5
6
  * IWebpackLoaderOption
6
7
  */
7
8
  export default interface IWebpackLoaderOption {
8
9
  compileParam: IJavascriptCompileOption;
9
10
  context: IFileLaneContext;
11
+ compilation: FileLaneCompilation;
10
12
  onLog: (log: ILog[]) => void;
11
13
  }
@@ -11,7 +11,8 @@ async function _default(source) {
11
11
  const {
12
12
  onLog,
13
13
  compileParam,
14
- context
14
+ context,
15
+ compilation
15
16
  } = options;
16
17
  const callback = this.async();
17
18
  const {
@@ -20,7 +21,7 @@ async function _default(source) {
20
21
  } = await _UxLoaderUtils.default.compileUxToJavascript({
21
22
  path: this.resourcePath,
22
23
  content: source
23
- }, context, false, compileParam);
24
+ }, context, false, compileParam, compilation);
24
25
  onLog?.(logs);
25
26
  callback(null, compiledFiles[0].content, compiledFiles[1].content);
26
27
  }
@@ -1,12 +1,14 @@
1
1
  import { ILog } from '@aiot-toolkit/shared-utils';
2
2
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
3
3
  import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
4
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  /**
5
6
  * UxLoader
6
7
  */
7
8
  declare class UxLoader implements ILoader {
8
9
  context: IFileLaneContext;
9
10
  compilerOption: IJavascriptCompileOption;
11
+ compilation: FileLaneCompilation;
10
12
  logs?: ILog[] | undefined;
11
13
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
12
14
  }
@@ -19,7 +19,8 @@ class UxLoader {
19
19
  } = await new _AndroidUx.default().compileUx({
20
20
  context: this.context,
21
21
  file: item,
22
- compilerOption: this.compilerOption
22
+ compilerOption: this.compilerOption,
23
+ compilation: this.compilation
23
24
  });
24
25
  this.logs = logs;
25
26
  result.push(...files);
@@ -1,6 +1,7 @@
1
1
  import { ILog } from '@aiot-toolkit/shared-utils';
2
2
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
3
3
  import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
4
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  /**
5
6
  * 处理app.ux的Loader
6
7
  * AppUxLoader
@@ -8,6 +9,7 @@ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJa
8
9
  declare class AppUxLoader implements ILoader {
9
10
  context: IFileLaneContext;
10
11
  compilerOption: IJavascriptCompileOption;
12
+ compilation: FileLaneCompilation;
11
13
  logs?: ILog[] | undefined;
12
14
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
13
15
  }
@@ -15,7 +15,7 @@ class AppUxLoader {
15
15
  const {
16
16
  files: resultFiles,
17
17
  logs
18
- } = await _UxLoaderUtils.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
18
+ } = await _UxLoaderUtils.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption, this.compilation);
19
19
  this.logs = logs;
20
20
  return resultFiles;
21
21
  }
@@ -1,9 +1,11 @@
1
1
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
3
3
  import { ILog } from '@aiot-toolkit/shared-utils/lib/interface/ILog';
4
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  declare class UxLoader implements ILoader {
5
6
  context: IFileLaneContext;
6
7
  compilerOption: IJavascriptCompileOption;
8
+ compilation: FileLaneCompilation;
7
9
  logs?: ILog[] | undefined;
8
10
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
9
11
  }
@@ -11,7 +11,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
11
11
  class UxLoader {
12
12
  async parser(files) {
13
13
  const resultFiles = [];
14
- const liteCardList = this.context.liteCards?.map(item => _path.default.join(this.context.projectPath, this.compilerOption.sourceRoot, `${item}${_parser.ExtensionConfig.UX}`)) || [];
14
+ const liteCardList = this.compilation.liteCards?.map(item => _path.default.join(this.context.projectPath, this.compilerOption.sourceRoot, `${item}${_parser.ExtensionConfig.UX}`)) || [];
15
15
  for (const file of files) {
16
16
  // 轻卡ux不转换
17
17
  if (liteCardList.includes(file.path)) {
@@ -21,7 +21,7 @@ class UxLoader {
21
21
  const {
22
22
  files: compiledFiles,
23
23
  logs
24
- } = await _UxLoaderUtils.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
24
+ } = await _UxLoaderUtils.default.compileUxToJavascript(file, this.context, false, this.compilerOption, this.compilation);
25
25
  this.logs = logs.map(item => {
26
26
  return {
27
27
  ...item,
@@ -6,8 +6,6 @@ import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascri
6
6
  declare class BeforeCompileUtils {
7
7
  /**
8
8
  * 获取ux项目的路由入口
9
- * context.entries中存放ux页面路由
10
- * context.liteCards中存放轻卡路由
11
9
  * @param context
12
10
  * @param fileList
13
11
  * @returns
@@ -20,8 +20,6 @@ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobu
20
20
  class BeforeCompileUtils {
21
21
  /**
22
22
  * 获取ux项目的路由入口
23
- * context.entries中存放ux页面路由
24
- * context.liteCards中存放轻卡路由
25
23
  * @param context
26
24
  * @param fileList
27
25
  * @returns
@@ -29,7 +27,8 @@ class BeforeCompileUtils {
29
27
  static getEntries = params => {
30
28
  const {
31
29
  context,
32
- compilerOption
30
+ compilerOption,
31
+ compilation
33
32
  } = params;
34
33
  const {
35
34
  projectPath
@@ -85,22 +84,24 @@ class BeforeCompileUtils {
85
84
  // 没有router配置
86
85
  _sharedUtils.ColorConsole.throw(`### manifest ### No router configuration`);
87
86
  }
88
- context['entries'] = entryList;
89
- context['liteCards'] = liteCardList;
87
+ if (compilation) {
88
+ compilation['entries'] = entryList;
89
+ compilation['liteCards'] = liteCardList;
90
+ }
90
91
  return Promise.resolve();
91
92
  };
92
93
  static clean = async params => {
93
94
  const {
94
95
  context,
95
96
  compilerOption,
96
- compalition
97
+ compilation
97
98
  } = params;
98
99
  if (compilerOption) {
99
100
  // 存储build中的文件列表
100
101
  const buildPath = _path.default.join(context.projectPath, compilerOption.outputPath);
101
102
  const buildFileList = _fsExtra.default.existsSync(buildPath) ? _sharedUtils.FileUtil.readAlldirSync(buildPath).map(filePath => _path.default.relative(buildPath, filePath)) : [];
102
- if (compalition) {
103
- compalition.buildFileList = buildFileList;
103
+ if (compilation) {
104
+ compilation.buildFileList = buildFileList;
104
105
  }
105
106
  }
106
107
  context.translateCache = new _TranslateCache.default();
@@ -3,6 +3,7 @@ import { ILog } from '@aiot-toolkit/shared-utils';
3
3
  import { IFileLaneContext, IFileParam } from 'file-lane';
4
4
  import { SourceFile } from 'ts-morph';
5
5
  import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
6
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
6
7
  /**
7
8
  * UxLoaderUtils
8
9
  */
@@ -15,7 +16,7 @@ declare class UxLoaderUtils {
15
16
  * @param project
16
17
  * @returns
17
18
  */
18
- static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean, compilerOption: IJavascriptCompileOption): Promise<{
19
+ static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean, compilerOption: IJavascriptCompileOption, compilation: FileLaneCompilation): Promise<{
19
20
  files: IFileParam[];
20
21
  logs: ILog[];
21
22
  }>;
@@ -25,7 +26,7 @@ declare class UxLoaderUtils {
25
26
  * @param resultFiles
26
27
  * @param context
27
28
  */
28
- static compileAppUxToJavascript(file: IFileParam, context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<{
29
+ static compileAppUxToJavascript(file: IFileParam, context: IFileLaneContext, compileOption: IJavascriptCompileOption, compilation: FileLaneCompilation): Promise<{
29
30
  files: IFileParam[];
30
31
  logs: ILog[];
31
32
  }>;
@@ -41,7 +42,7 @@ declare class UxLoaderUtils {
41
42
  * @param filePath
42
43
  * @returns
43
44
  */
44
- static isPageUx(context: IFileLaneContext, filePath: string): boolean;
45
+ static isPageUx(compilation: FileLaneCompilation, filePath: string): boolean;
45
46
  /**
46
47
  * 获取app.ux的内容,且只返回script和style内容
47
48
  * @param fileContent
@@ -54,7 +54,7 @@ class UxLoaderUtils {
54
54
  * @param project
55
55
  * @returns
56
56
  */
57
- static async compileUxToJavascript(file, context, isAppUx, compilerOption) {
57
+ static async compileUxToJavascript(file, context, isAppUx, compilerOption, compilation) {
58
58
  const logs = [];
59
59
  const {
60
60
  path: filePath,
@@ -77,7 +77,7 @@ class UxLoaderUtils {
77
77
  }
78
78
 
79
79
  // 区分页面组件和子组件
80
- const isPageUx = UxLoaderUtils.isPageUx(context, filePath);
80
+ const isPageUx = UxLoaderUtils.isPageUx(compilation, filePath);
81
81
  // 配置转换参数
82
82
  const options = {
83
83
  projectPath: context.projectPath,
@@ -179,7 +179,7 @@ class UxLoaderUtils {
179
179
  * @param resultFiles
180
180
  * @param context
181
181
  */
182
- static async compileAppUxToJavascript(file, context, compileOption) {
182
+ static async compileAppUxToJavascript(file, context, compileOption, compilation) {
183
183
  const {
184
184
  path: filePath,
185
185
  content
@@ -194,7 +194,7 @@ class UxLoaderUtils {
194
194
  const compileResult = await UxLoaderUtils.compileUxToJavascript({
195
195
  path: filePath,
196
196
  content: appContent
197
- }, context, isAppUx, compileOption);
197
+ }, context, isAppUx, compileOption, compilation);
198
198
  return compileResult;
199
199
  }
200
200
  /**
@@ -213,8 +213,8 @@ class UxLoaderUtils {
213
213
  * @param filePath
214
214
  * @returns
215
215
  */
216
- static isPageUx(context, filePath) {
217
- return Boolean(context.entries?.includes(filePath));
216
+ static isPageUx(compilation, filePath) {
217
+ return Boolean(compilation.entries?.includes(filePath));
218
218
  }
219
219
  /**
220
220
  * 获取app.ux的内容,且只返回script和style内容
@@ -1,6 +1,7 @@
1
1
  import { ILog } from '@aiot-toolkit/shared-utils';
2
2
  import { IFileLaneContext, IFileParam } from 'file-lane';
3
3
  import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
4
+ import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  /**
5
6
  * AndroidUx
6
7
  */
@@ -18,6 +19,7 @@ declare class AndroidUx {
18
19
  context: IFileLaneContext;
19
20
  file: IFileParam;
20
21
  compilerOption: IJavascriptCompileOption;
22
+ compilation: FileLaneCompilation;
21
23
  }): Promise<{
22
24
  files: IFileParam[];
23
25
  logs: ILog[];
@@ -28,7 +28,8 @@ class AndroidUx {
28
28
  const {
29
29
  context,
30
30
  file,
31
- compilerOption
31
+ compilerOption,
32
+ compilation
32
33
  } = params;
33
34
  const {
34
35
  path: filePath,
@@ -37,7 +38,7 @@ class AndroidUx {
37
38
  const {
38
39
  projectPath
39
40
  } = context;
40
- const fileType = this.getFileType(filePath, context);
41
+ const fileType = this.getFileType(filePath, compilation);
41
42
 
42
43
  // 无内容的文件,添加空内容警告
43
44
  if (!content) {
@@ -84,10 +85,10 @@ class AndroidUx {
84
85
  logs
85
86
  };
86
87
  }
87
- getFileType(filePath, context) {
88
+ getFileType(filePath, compilation) {
88
89
  const {
89
90
  entries
90
- } = context;
91
+ } = compilation;
91
92
  if (_path.default.basename(filePath) === 'app.ux') {
92
93
  return 'app';
93
94
  } else if (entries.includes(filePath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.6-beta.3",
3
+ "version": "2.0.6-beta.4",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,14 +19,14 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.6-beta.3",
23
- "@aiot-toolkit/parser": "2.0.6-beta.3",
24
- "@aiot-toolkit/shared-utils": "2.0.6-beta.3",
22
+ "@aiot-toolkit/generator": "2.0.6-beta.4",
23
+ "@aiot-toolkit/parser": "2.0.6-beta.4",
24
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.4",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.3.9",
27
27
  "aiot-parse5": "^1.0.2",
28
28
  "babel-loader": "^9.1.3",
29
- "file-lane": "2.0.6-beta.3",
29
+ "file-lane": "2.0.6-beta.4",
30
30
  "file-loader": "^6.2.0",
31
31
  "fs-extra": "^11.2.0",
32
32
  "jsrsasign": "^11.1.0",
@@ -42,5 +42,5 @@
42
42
  "@types/jsrsasign": "^10.5.12",
43
43
  "@types/webpack-sources": "^3.2.3"
44
44
  },
45
- "gitHead": "2e2ba4b1d293218736343237d963fe93c5fb27a8"
45
+ "gitHead": "1acc8279ba3c5995aebe3a97a6b33154086f09d6"
46
46
  }