@aiot-toolkit/aiotpack 2.0.5-beta.16 → 2.0.5-beta.18

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.
@@ -62,5 +62,9 @@ declare class UxAfterCompile {
62
62
  * @param params
63
63
  */
64
64
  static resourceCheck: FollowWork<IJavascriptCompileOption>;
65
+ /**
66
+ * 写入.gitignore文件, 忽略临时目录
67
+ */
68
+ static writeGitIgnore: FollowWork<IJavascriptCompileOption>;
65
69
  }
66
70
  export default UxAfterCompile;
@@ -29,9 +29,10 @@ class UxAfterCompile {
29
29
  static compileJavascript = async params => {
30
30
  const {
31
31
  context,
32
- compilerOption
32
+ compilerOption,
33
+ onLog
33
34
  } = params;
34
- return new _JavascriptCompiler.default().compile({
35
+ return new _JavascriptCompiler.default(context, onLog).compile({
35
36
  projectPath: _path.default.join(context.projectPath, context.output),
36
37
  mode: _CompileMode.default.DEVELOPMENT,
37
38
  devtool: false,
@@ -320,8 +321,8 @@ class UxAfterCompile {
320
321
  const diffFileName = `.diff.rpk`;
321
322
  const diffPath = _path.default.join(distFold, diffFileName);
322
323
  await _ZipFileUtil.default.createZipFile(diffPath, diffList.map(item => ({
323
- filePath: _path.default.join(buildFold, item.path),
324
- zipFilePath: item.path
324
+ filePath: _path.default.join(buildFold, item),
325
+ zipFilePath: item
325
326
  })));
326
327
  compalition.info.diffList = diffList;
327
328
  compalition.info.diffFile = _path.default.join(context.projectPath, compilerOption.releasePath, diffFileName);
@@ -493,5 +494,20 @@ class UxAfterCompile {
493
494
  onLog?.(logs);
494
495
  }
495
496
  };
497
+
498
+ /**
499
+ * 写入.gitignore文件, 忽略临时目录
500
+ */
501
+ static writeGitIgnore = async params => {
502
+ const {
503
+ context
504
+ } = params;
505
+ const {
506
+ output,
507
+ projectPath
508
+ } = context;
509
+ const gitIgnorePath = _path.default.join(projectPath, output, '.gitignore');
510
+ _fsExtra.default.writeFileSync(gitIgnorePath, '*');
511
+ };
496
512
  }
497
513
  var _default = exports.default = UxAfterCompile;
@@ -1,8 +1,13 @@
1
+ import { ILog } from '@aiot-toolkit/shared-utils';
2
+ import { IFileLaneContext } from 'file-lane';
1
3
  import ICompileParam from '../interface/ICompileParam';
2
4
  import ICompiler from '../interface/ICompiler';
3
5
  import IJavascriptCompileOption from './interface/IJavascriptCompileOption';
4
6
  declare class JavascriptCompiler implements ICompiler {
7
+ private readonly context;
8
+ private readonly onLog?;
5
9
  readonly QUICKAPP_CONFIG = "quickapp.config.js";
10
+ constructor(context: IFileLaneContext, onLog?: ((log: ILog[]) => void) | undefined);
6
11
  compile(param: IJavascriptCompileOption): Promise<void>;
7
12
  /**
8
13
  * 压缩插件
@@ -8,13 +8,17 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
8
  var _core = require("@rspack/core");
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _path = _interopRequireDefault(require("path"));
11
+ var _CompileMode = _interopRequireDefault(require("../enum/CompileMode"));
11
12
  var _AndroidWebpackConfigurator = _interopRequireDefault(require("./android/AndroidWebpackConfigurator"));
12
13
  var _VelaWebpackConfigurator = _interopRequireDefault(require("./vela/VelaWebpackConfigurator"));
13
14
  var _UxCompileUtil = _interopRequireDefault(require("./vela/utils/UxCompileUtil"));
14
- var _CompileMode = _interopRequireDefault(require("../enum/CompileMode"));
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  class JavascriptCompiler {
17
17
  QUICKAPP_CONFIG = 'quickapp.config.js';
18
+ constructor(context, onLog) {
19
+ this.context = context;
20
+ this.onLog = onLog;
21
+ }
18
22
  async compile(param) {
19
23
  return new Promise(async (resolve, reject) => {
20
24
  try {
@@ -142,9 +146,34 @@ class JavascriptCompiler {
142
146
  rules: [{
143
147
  test: /\.ux$/,
144
148
  // 匹配以 .ux 结尾的文件
149
+ exclude: /node_modules/,
145
150
  use: [{
146
151
  loader: _path.default.join(__dirname, '../javascript/vela/utils/webpackLoader/extractMapData.js')
147
152
  }]
153
+ },
154
+ // node_modules下的ux文件
155
+ {
156
+ test: /\.ux$/,
157
+ include: /node_modules/,
158
+ use: [{
159
+ loader: _path.default.join(__dirname, '../javascript/vela/utils/webpackLoader/WebpackUxLoader'),
160
+ options: {
161
+ compileParam: param,
162
+ context: this.context,
163
+ onLog: this.onLog
164
+ }
165
+ }]
166
+ }, {
167
+ test: /\.js$/,
168
+ include: /node_modules/,
169
+ use: [{
170
+ loader: _path.default.join(__dirname, '../javascript/vela/utils/webpackLoader/WebpackJsLoader'),
171
+ options: {
172
+ compileParam: param,
173
+ context: this.context,
174
+ onLog: this.onLog
175
+ }
176
+ }]
148
177
  }]
149
178
  },
150
179
  optimization: {
@@ -1,6 +1,6 @@
1
1
  import ICompileParam from '../../interface/ICompileParam';
2
2
  import BuildNameFormatType from '../vela/enum/BuildNameFormatType';
3
- export default interface IJavascriptCompileOption extends ICompileParam {
3
+ interface IJavascriptCompileOption extends ICompileParam {
4
4
  devtool?: string | false;
5
5
  /**
6
6
  * 源码路径(相对项目根目录)
@@ -85,3 +85,4 @@ export default interface IJavascriptCompileOption extends ICompileParam {
85
85
  certificate: Buffer;
86
86
  }>;
87
87
  }
88
+ export default IJavascriptCompileOption;
@@ -1 +1,5 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -33,8 +33,7 @@ class WrapPlugin {
33
33
  const source = compilation.assets[entry];
34
34
  const isApp = entry === 'app.js';
35
35
  const createFuncnName = isApp ? 'createAppHandler' : 'createPageHandler';
36
- compilation.assets[entry] = new _webpackSources.ConcatSource(`
37
- export default function(global, globalThis, window, $app_exports$, $app_evaluate$){
36
+ compilation.assets[entry] = new _webpackSources.ConcatSource(`export default function(global, globalThis, window, $app_exports$, $app_evaluate$){
38
37
  var org_app_require = $app_require$;
39
38
 
40
39
  (function(global, globalThis, window, $app_exports$, $app_evaluate$){
@@ -0,0 +1,11 @@
1
+ import { IFileLaneContext } from 'file-lane';
2
+ import IJavascriptCompileOption from '../../../interface/IJavascriptCompileOption';
3
+ import { ILog } from '@aiot-toolkit/shared-utils';
4
+ /**
5
+ * IWebpackLoaderOption
6
+ */
7
+ export default interface IWebpackLoaderOption {
8
+ compileParam: IJavascriptCompileOption;
9
+ context: IFileLaneContext;
10
+ onLog: (log: ILog[]) => void;
11
+ }
@@ -0,0 +1,2 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+ export default function (this: LoaderContext<any>, source: string): Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ var _parser = require("@aiot-toolkit/parser");
8
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
9
+ async function _default(source) {
10
+ const callback = this.async();
11
+ const options = this.getOptions();
12
+ const {
13
+ context,
14
+ onLog,
15
+ compileParam
16
+ } = options;
17
+ const result = await new _parser.ScriptToTypescript({
18
+ filePath: this.resourcePath,
19
+ content: source,
20
+ projectPath: this.rootContext,
21
+ onLog: log => onLog?.([log]),
22
+ projectType: _sharedUtils.ProjectType.VELA_UX
23
+ }, compileParam, context).translate({
24
+ content: source
25
+ }, []);
26
+ callback(null, result.targetTree.getFullText());
27
+ }
@@ -0,0 +1,2 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+ export default function (this: LoaderContext<any>, source: string): Promise<void>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ var _UxLoaderUtils = _interopRequireDefault(require("../../../../../utils/ux/UxLoaderUtils"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ async function _default(source) {
10
+ const options = this.getOptions();
11
+ const {
12
+ onLog,
13
+ compileParam,
14
+ context
15
+ } = options;
16
+ const callback = this.async();
17
+ const {
18
+ files: compiledFiles,
19
+ logs
20
+ } = await _UxLoaderUtils.default.compileUxToJavascript({
21
+ path: this.resourcePath,
22
+ content: source
23
+ }, context, false, compileParam);
24
+ onLog?.(logs);
25
+ callback(null, compiledFiles[0].content, compiledFiles[1].content);
26
+ }
@@ -26,10 +26,13 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
26
26
  get output(): string;
27
27
  beforeWorks: (typeof UxBeforeWorks.cleanOutput)[];
28
28
  beforeCompile: import("file-lane").PreWork<IJavascriptCompileOption>[];
29
- afterCompile: {
29
+ afterCompile: ({
30
+ worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
31
+ workerDescribe?: undefined;
32
+ } | {
30
33
  worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
31
34
  workerDescribe: string;
32
- }[];
35
+ })[];
33
36
  afterWorks: (typeof UxAfterWorks.cleanOutput)[];
34
37
  watchIgnores: RegExp[];
35
38
  /**
@@ -75,6 +75,8 @@ class UxConfig {
75
75
  beforeWorks = (() => [_UxBeforeWorks.default.cleanOutput])();
76
76
  beforeCompile = (() => [_UxBeforeCompile.default.validateManifest, _UxBeforeCompile.default.validateSitemap, _BeforeCompileUtils.default.clean, _BeforeCompileUtils.default.getEntries, _BeforeCompileUtils.default.getGlobalVar])();
77
77
  afterCompile = (() => [{
78
+ worker: _UxAfterCompile.default.writeGitIgnore
79
+ }, {
78
80
  worker: _UxAfterCompile.default.symlinkNodeModule,
79
81
  workerDescribe: 'Create a soft link to the node_modules folder'
80
82
  }, {
@@ -9,13 +9,16 @@ const ManifestSchema = {
9
9
  required: ['package', 'name', 'icon', 'versionCode', 'config', 'router'],
10
10
  properties: {
11
11
  package: {
12
- type: 'string'
12
+ type: 'string',
13
+ minLength: 1
13
14
  },
14
15
  name: {
15
- type: 'string'
16
+ type: 'string',
17
+ minLength: 1
16
18
  },
17
19
  icon: {
18
- type: 'string'
20
+ type: 'string',
21
+ minLength: 1
19
22
  },
20
23
  banner: {
21
24
  type: 'string'
@@ -48,9 +48,6 @@ export declare class UxFileUtils {
48
48
  * @param newFileList 新文件列表
49
49
  * @returns
50
50
  */
51
- static getDiffJSON(compilation: FileLaneCompilation, newFileList: string[], buildPath: string): {
52
- path: string;
53
- content: Buffer;
54
- }[];
51
+ static getDiffJSON(compilation: FileLaneCompilation, newFileList: string[], buildPath: string): string[];
55
52
  }
56
53
  export default UxFileUtils;
@@ -135,22 +135,16 @@ class UxFileUtils {
135
135
  if (index !== -1) {
136
136
  // 1.2
137
137
  const oldContent = oldFileList[i].content?.toString('utf-8');
138
- const newContent = _fsExtra.default.readFileSync(_path.default.join(buildPath, newFileList[index]));
139
- if (oldContent !== newContent.toString()) {
140
- diffList.push({
141
- path: newFileList[index],
142
- content: newContent
143
- });
138
+ const newContent = _fsExtra.default.readFileSync(_path.default.join(buildPath, newFileList[index]), 'utf-8');
139
+ if (oldContent !== newContent) {
140
+ diffList.push(newFileList[index]);
144
141
  }
145
142
  // 从newFileList中移除该项
146
143
  newFileList.splice(index, 1);
147
144
  }
148
145
  }
149
146
  // 2.
150
- newFileList.length > 0 && newFileList.forEach(file => diffList.push({
151
- path: file,
152
- content: _fsExtra.default.readFileSync(_path.default.join(buildPath, file))
153
- }));
147
+ newFileList.length > 0 && newFileList.forEach(file => diffList.push(file));
154
148
  return diffList;
155
149
  }
156
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.5-beta.16",
3
+ "version": "2.0.5-beta.18",
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.5-beta.16",
23
- "@aiot-toolkit/parser": "2.0.5-beta.16",
24
- "@aiot-toolkit/shared-utils": "2.0.5-beta.16",
22
+ "@aiot-toolkit/generator": "2.0.5-beta.18",
23
+ "@aiot-toolkit/parser": "2.0.5-beta.18",
24
+ "@aiot-toolkit/shared-utils": "2.0.5-beta.18",
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.5-beta.16",
29
+ "file-lane": "2.0.5-beta.18",
30
30
  "file-loader": "^6.2.0",
31
31
  "fs-extra": "^11.2.0",
32
32
  "hap-toolkit": "^2.0.0",
@@ -43,5 +43,5 @@
43
43
  "@types/jsrsasign": "^10.5.12",
44
44
  "@types/webpack-sources": "^3.2.3"
45
45
  },
46
- "gitHead": "66255b9d69f9b15db10283d662f94f3d1f2486c3"
46
+ "gitHead": "cdcbff776773be9854039419016d04fa11bc7186"
47
47
  }