@aiot-toolkit/aiotpack 2.0.1-alpha.0

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 (123) hide show
  1. package/README.md +46 -0
  2. package/lib/compiler/c/README.md +1 -0
  3. package/lib/compiler/c++/README.md +1 -0
  4. package/lib/compiler/enum/CompileMode.d.ts +22 -0
  5. package/lib/compiler/enum/CompileMode.js +30 -0
  6. package/lib/compiler/enum/CompileMode.js.map +1 -0
  7. package/lib/compiler/interface/ICompileParam.d.ts +24 -0
  8. package/lib/compiler/interface/ICompileParam.js +4 -0
  9. package/lib/compiler/interface/ICompileParam.js.map +1 -0
  10. package/lib/compiler/interface/ICompiler.d.ts +5 -0
  11. package/lib/compiler/interface/ICompiler.js +4 -0
  12. package/lib/compiler/interface/ICompiler.js.map +1 -0
  13. package/lib/compiler/interface/ISignConfig.d.ts +8 -0
  14. package/lib/compiler/interface/ISignConfig.js +4 -0
  15. package/lib/compiler/interface/ISignConfig.js.map +1 -0
  16. package/lib/compiler/javascript/JavascriptCompiler.d.ts +11 -0
  17. package/lib/compiler/javascript/JavascriptCompiler.js +108 -0
  18. package/lib/compiler/javascript/JavascriptCompiler.js.map +1 -0
  19. package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +3 -0
  20. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +21 -0
  21. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +1 -0
  22. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +40 -0
  23. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +4 -0
  24. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +1 -0
  25. package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +40 -0
  26. package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -0
  27. package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +1 -0
  28. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +16 -0
  29. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +74 -0
  30. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +1 -0
  31. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.d.ts +25 -0
  32. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +47 -0
  33. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +1 -0
  34. package/lib/compiler/javascript/vela/enum/EntryType.d.ts +30 -0
  35. package/lib/compiler/javascript/vela/enum/EntryType.js +35 -0
  36. package/lib/compiler/javascript/vela/enum/EntryType.js.map +1 -0
  37. package/lib/compiler/javascript/vela/interface/IChunk.d.ts +29 -0
  38. package/lib/compiler/javascript/vela/interface/IChunk.js +4 -0
  39. package/lib/compiler/javascript/vela/interface/IChunk.js.map +1 -0
  40. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +27 -0
  41. package/lib/compiler/javascript/vela/interface/IManifest.js +4 -0
  42. package/lib/compiler/javascript/vela/interface/IManifest.js.map +1 -0
  43. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +11 -0
  44. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +4 -0
  45. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +1 -0
  46. package/lib/compiler/javascript/vela/model/Package.d.ts +75 -0
  47. package/lib/compiler/javascript/vela/model/Package.js +62 -0
  48. package/lib/compiler/javascript/vela/model/Package.js.map +1 -0
  49. package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +7 -0
  50. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +51 -0
  51. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +1 -0
  52. package/lib/compiler/javascript/vela/utils/Jsc.d.ts +10 -0
  53. package/lib/compiler/javascript/vela/utils/Jsc.js +34 -0
  54. package/lib/compiler/javascript/vela/utils/Jsc.js.map +1 -0
  55. package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +29 -0
  56. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +144 -0
  57. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +1 -0
  58. package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +75 -0
  59. package/lib/compiler/javascript/vela/utils/ZipUtil.js +278 -0
  60. package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +1 -0
  61. package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +11 -0
  62. package/lib/compiler/javascript/vela/utils/signature/Base64.js +77 -0
  63. package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +1 -0
  64. package/lib/compiler/javascript/vela/utils/signature/CRC32.d.ts +9 -0
  65. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +45 -0
  66. package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +1 -0
  67. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +94 -0
  68. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +713 -0
  69. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +1 -0
  70. package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +16 -0
  71. package/lib/compiler/javascript/vela/utils/signature/Signer.js +30 -0
  72. package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +1 -0
  73. package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +27 -0
  74. package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +51 -0
  75. package/lib/config/UxConfig.d.ts +30 -0
  76. package/lib/config/UxConfig.js +52 -0
  77. package/lib/config/UxConfig.js.map +1 -0
  78. package/lib/config/XtsConfig.d.ts +18 -0
  79. package/lib/config/XtsConfig.js +28 -0
  80. package/lib/config/XtsConfig.js.map +1 -0
  81. package/lib/followWorks/xts/entryTemplate.d.ts +21 -0
  82. package/lib/followWorks/xts/entryTemplate.js +166 -0
  83. package/lib/followWorks/xts/entryTemplate.js.map +1 -0
  84. package/lib/followWorks/xts/ts2wasm.d.ts +6 -0
  85. package/lib/followWorks/xts/ts2wasm.js +31 -0
  86. package/lib/followWorks/xts/ts2wasm.js.map +1 -0
  87. package/lib/index.d.ts +2 -0
  88. package/lib/index.js +10 -0
  89. package/lib/index.js.map +1 -0
  90. package/lib/interface/IDeviceList.d.ts +7 -0
  91. package/lib/interface/IDeviceList.js +4 -0
  92. package/lib/interface/IDeviceList.js.map +1 -0
  93. package/lib/loader/ux/AppUxLoader.d.ts +10 -0
  94. package/lib/loader/ux/AppUxLoader.js +31 -0
  95. package/lib/loader/ux/AppUxLoader.js.map +1 -0
  96. package/lib/loader/ux/PngLoader.d.ts +10 -0
  97. package/lib/loader/ux/PngLoader.js +70 -0
  98. package/lib/loader/ux/PngLoader.js.map +1 -0
  99. package/lib/loader/ux/UxLoader.d.ts +6 -0
  100. package/lib/loader/ux/UxLoader.js +31 -0
  101. package/lib/loader/ux/UxLoader.js.map +1 -0
  102. package/lib/loader/xts/XtsLoader.d.ts +9 -0
  103. package/lib/loader/xts/XtsLoader.js +55 -0
  104. package/lib/loader/xts/XtsLoader.js.map +1 -0
  105. package/lib/utils/PngUtils.d.ts +20 -0
  106. package/lib/utils/PngUtils.js +45 -0
  107. package/lib/utils/PngUtils.js.map +1 -0
  108. package/lib/utils/PreWorkUtils.d.ts +17 -0
  109. package/lib/utils/PreWorkUtils.js +76 -0
  110. package/lib/utils/PreWorkUtils.js.map +1 -0
  111. package/lib/utils/ux/UxFileUtils.d.ts +22 -0
  112. package/lib/utils/ux/UxFileUtils.js +34 -0
  113. package/lib/utils/ux/UxFileUtils.js.map +1 -0
  114. package/lib/utils/ux/UxFollowWorks.d.ts +35 -0
  115. package/lib/utils/ux/UxFollowWorks.js +200 -0
  116. package/lib/utils/ux/UxFollowWorks.js.map +1 -0
  117. package/lib/utils/ux/UxLoaderUtils.d.ts +60 -0
  118. package/lib/utils/ux/UxLoaderUtils.js +241 -0
  119. package/lib/utils/ux/UxLoaderUtils.js.map +1 -0
  120. package/lib/utils/xts/XtsFollowWorks.d.ts +29 -0
  121. package/lib/utils/xts/XtsFollowWorks.js +149 -0
  122. package/lib/utils/xts/XtsFollowWorks.js.map +1 -0
  123. package/package.json +44 -0
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
+ const FileLaneUtil_1 = __importDefault(require("file-lane/lib/utils/FileLaneUtil"));
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const UxFileUtils_1 = __importDefault(require("./../ux/UxFileUtils"));
21
+ /**
22
+ * XtsFollowWorks
23
+ */
24
+ class XtsFollowWorks {
25
+ /**
26
+ * 将项目中build文件夹的内容压缩成zip包,并将压缩产物放到dist文件夹下
27
+ * @param context
28
+ */
29
+ static defaultZipProject(context) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { output, projectPath } = context;
32
+ const buildPath = path_1.default.join(projectPath, output);
33
+ const zipPath = path_1.default.join(projectPath, 'dist');
34
+ // buildPath必须是真实文件夹路径
35
+ if (!fs_extra_1.default.existsSync(buildPath)) {
36
+ ColorConsole_1.default.log({
37
+ level: shared_utils_1.LOG_LEVEL.Error,
38
+ message: `XtsConfig follwWorkers zip build error, buildPath not exist`
39
+ });
40
+ }
41
+ try {
42
+ // 确认文件夹是否存在,不存在则创建
43
+ fs_extra_1.default.ensureDirSync(zipPath);
44
+ // 清空dist文件夹
45
+ fs_extra_1.default.emptyDirSync(zipPath);
46
+ const filePath = XtsFollowWorks.getFilePath(projectPath);
47
+ yield FileLaneUtil_1.default.zipProject([buildPath], filePath);
48
+ }
49
+ catch (err) {
50
+ ColorConsole_1.default.log({ level: shared_utils_1.LOG_LEVEL.Error, message: err.message });
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * 将分布式项目按照manifest.json中的配置打包,思路如下:
56
+ * 1. 获取manifest中aspect的路由配置
57
+ * 2. 对aspects中的所有路由信息进行遍历
58
+ * 3. 按照设备(设备+rule)对aspect分类
59
+ * 4. 按照设备列表分别进行打包
60
+ * @param context
61
+ */
62
+ static zipDistributedQuickApp(context) {
63
+ var _a, _b;
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const deviceList = [
66
+ {
67
+ device: 'phone',
68
+ aspectList: []
69
+ }
70
+ ];
71
+ const { projectPath, output } = context;
72
+ const manifestPath = UxFileUtils_1.default.getManifestFilePath(projectPath, 'app');
73
+ if (fs_extra_1.default.existsSync(manifestPath)) {
74
+ //获取manifest.json内容
75
+ const aspectsRule = (_b = (_a = fs_extra_1.default.readJSONSync(manifestPath)) === null || _a === void 0 ? void 0 : _a.router) === null || _b === void 0 ? void 0 : _b.aspects;
76
+ if (aspectsRule) {
77
+ Object.keys(aspectsRule).forEach((aspectRule) => {
78
+ // 分别处理每个aspectRule数组
79
+ for (let item of aspectsRule[aspectRule]) {
80
+ const { devices, rule, path } = item;
81
+ // 如果存在设备列表
82
+ if (devices && Array.isArray(devices) && devices.length > 0) {
83
+ for (let device of devices) {
84
+ // 设备名与rule组合为一个设备
85
+ if (rule) {
86
+ device = `${device}.${rule}`;
87
+ }
88
+ // 查找设备是否已存在于设备列表中
89
+ const index = device === 'phone' ? 0 : deviceList.findIndex((item) => item.device === device);
90
+ if (index === -1) {
91
+ // 新设备
92
+ deviceList.push({
93
+ device,
94
+ aspectList: [path]
95
+ });
96
+ }
97
+ else {
98
+ // 已存在的设备信息时,仅需添加aspect路由
99
+ deviceList[index].aspectList.push(path);
100
+ }
101
+ }
102
+ }
103
+ else {
104
+ // 设备值默认值为phone
105
+ deviceList[0].aspectList.push(path);
106
+ }
107
+ }
108
+ });
109
+ }
110
+ const zipPath = path_1.default.join(projectPath, 'dist');
111
+ fs_extra_1.default.ensureDirSync(zipPath);
112
+ fs_extra_1.default.emptyDirSync(zipPath);
113
+ // 根据deviceList进行打包
114
+ for (const item of deviceList) {
115
+ // 所有zip包都需要app信息
116
+ item.aspectList.push('app');
117
+ // 将路由转为真实路径
118
+ const buildPaths = item.aspectList.map((name) => path_1.default.join(projectPath, output, name));
119
+ const filePath = XtsFollowWorks.getFilePath(projectPath, 'dist', item.device);
120
+ try {
121
+ yield FileLaneUtil_1.default.zipProject(buildPaths, filePath);
122
+ }
123
+ catch (error) { }
124
+ }
125
+ }
126
+ else {
127
+ ColorConsole_1.default.log({
128
+ level: shared_utils_1.LOG_LEVEL.Error,
129
+ message: 'zip DistributedQuickApp not find manifest.json'
130
+ });
131
+ }
132
+ });
133
+ }
134
+ /**
135
+ * 根据项目路径,打包文件夹名和传入的压缩包名,生成压缩文件zip路径
136
+ * @param projectPath
137
+ * @param outputDir
138
+ * @param zipName
139
+ * @returns
140
+ */
141
+ static getFilePath(projectPath, outputDir = 'dist', zipName) {
142
+ zipName = zipName ? `${zipName}.zip` : `${path_1.default.basename(projectPath)}.zip`;
143
+ const zipPath = path_1.default.join(projectPath, outputDir);
144
+ return path_1.default.join(zipPath, zipName);
145
+ }
146
+ }
147
+ exports.default = XtsFollowWorks;
148
+
149
+ //# sourceMappingURL=XtsFollowWorks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/xts/XtsFollowWorks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6DAAsD;AACtD,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,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAA;QAC1E,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QACjD,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACpC,CAAC;CACF;AACD,kBAAe,cAAc,CAAA","file":"XtsFollowWorks.js","sourcesContent":["import { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { IFileLaneContext } from 'file-lane'\nimport FileLaneUtil from 'file-lane/lib/utils/FileLaneUtil'\nimport Fs from 'fs-extra'\nimport Path from 'path'\nimport IDeviceList from '../../interface/IDeviceList'\nimport UxFileUtils from './../ux/UxFileUtils'\n/**\n * XtsFollowWorks\n */\nclass XtsFollowWorks {\n /**\n * 将项目中build文件夹的内容压缩成zip包,并将压缩产物放到dist文件夹下\n * @param context\n */\n static async defaultZipProject(context: IFileLaneContext) {\n const { output, projectPath } = context\n const buildPath = Path.join(projectPath, output)\n const zipPath = Path.join(projectPath, 'dist')\n // buildPath必须是真实文件夹路径\n if (!Fs.existsSync(buildPath)) {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: `XtsConfig follwWorkers zip build error, buildPath not exist`\n })\n }\n try {\n // 确认文件夹是否存在,不存在则创建\n Fs.ensureDirSync(zipPath)\n // 清空dist文件夹\n Fs.emptyDirSync(zipPath)\n const filePath = XtsFollowWorks.getFilePath(projectPath)\n await FileLaneUtil.zipProject([buildPath], filePath)\n } catch (err) {\n ColorConsole.log({ level: LOG_LEVEL.Error, message: (err as Error).message })\n }\n }\n /**\n * 将分布式项目按照manifest.json中的配置打包,思路如下:\n * 1. 获取manifest中aspect的路由配置\n * 2. 对aspects中的所有路由信息进行遍历\n * 3. 按照设备(设备+rule)对aspect分类\n * 4. 按照设备列表分别进行打包\n * @param context\n */\n static async zipDistributedQuickApp(context: IFileLaneContext) {\n const deviceList: IDeviceList[] = [\n {\n device: 'phone',\n aspectList: []\n }\n ]\n const { projectPath, output } = context\n const manifestPath = UxFileUtils.getManifestFilePath(projectPath, 'app')\n if (Fs.existsSync(manifestPath)) {\n //获取manifest.json内容\n const aspectsRule = Fs.readJSONSync(manifestPath)?.router?.aspects\n if (aspectsRule) {\n Object.keys(aspectsRule).forEach((aspectRule) => {\n // 分别处理每个aspectRule数组\n for (let item of aspectsRule[aspectRule]) {\n const { devices, rule, path } = item\n // 如果存在设备列表\n if (devices && Array.isArray(devices) && devices.length > 0) {\n for (let device of devices) {\n // 设备名与rule组合为一个设备\n if (rule) {\n device = `${device}.${rule}`\n }\n // 查找设备是否已存在于设备列表中\n const index =\n device === 'phone' ? 0 : deviceList.findIndex((item) => item.device === device)\n if (index === -1) {\n // 新设备\n deviceList.push({\n device,\n aspectList: [path]\n })\n } else {\n // 已存在的设备信息时,仅需添加aspect路由\n deviceList[index].aspectList.push(path)\n }\n }\n } else {\n // 设备值默认值为phone\n deviceList[0].aspectList.push(path)\n }\n }\n })\n }\n const zipPath = Path.join(projectPath, 'dist')\n\n Fs.ensureDirSync(zipPath)\n Fs.emptyDirSync(zipPath)\n // 根据deviceList进行打包\n for (const item of deviceList) {\n // 所有zip包都需要app信息\n item.aspectList.push('app')\n // 将路由转为真实路径\n const buildPaths = item.aspectList.map((name) => Path.join(projectPath, output, name))\n const filePath = XtsFollowWorks.getFilePath(projectPath, 'dist', item.device)\n try {\n await FileLaneUtil.zipProject(buildPaths, filePath)\n } catch (error) {}\n }\n } else {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: 'zip DistributedQuickApp not find manifest.json'\n })\n }\n }\n /**\n * 根据项目路径,打包文件夹名和传入的压缩包名,生成压缩文件zip路径\n * @param projectPath\n * @param outputDir\n * @param zipName\n * @returns\n */\n static getFilePath(projectPath: string, outputDir: string = 'dist', zipName?: string) {\n zipName = zipName ? `${zipName}.zip` : `${Path.basename(projectPath)}.zip`\n const zipPath = Path.join(projectPath, outputDir)\n return Path.join(zipPath, zipName)\n }\n}\nexport default XtsFollowWorks\n"],"sourceRoot":"../../../src"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@aiot-toolkit/aiotpack",
3
+ "version": "2.0.1-alpha.0",
4
+ "description": "The process tool for packaging aiot projects.",
5
+ "keywords": [
6
+ "aiotpack"
7
+ ],
8
+ "author": "徐俊杰 <xujunjie1@xiaomi.com>",
9
+ "homepage": "",
10
+ "license": "ISC",
11
+ "main": "lib/index.js",
12
+ "directories": {
13
+ "lib": "lib",
14
+ "test": "__tests__"
15
+ },
16
+ "files": [
17
+ "lib"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "ssh://xujunjie1@git.mioffice.cn:29418/vela/aiot-toolkit"
22
+ },
23
+ "scripts": {
24
+ "test": "node ./__tests__/aiotpack.test.js"
25
+ },
26
+ "dependencies": {
27
+ "@aiot-toolkit/parser": "2.0.1-alpha.0",
28
+ "@hap-toolkit/aaptjs": "^2.0.0",
29
+ "babel-loader": "^9.1.3",
30
+ "del": "^4.1.0",
31
+ "file-lane": "2.0.1-alpha.0",
32
+ "file-loader": "^6.2.0",
33
+ "fs-extra": "^11.2.0",
34
+ "jsrsasign": "^7.2.2",
35
+ "jszip": "^3.10.1",
36
+ "url-loader": "^4.1.1",
37
+ "webpack": "^5.89.0",
38
+ "webpack-sources": "^3.2.3"
39
+ },
40
+ "devDependencies": {
41
+ "@types/jsrsasign": "^10.5.12",
42
+ "@types/webpack-sources": "^3.2.3"
43
+ }
44
+ }