@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.
- package/README.md +46 -0
- package/lib/compiler/c/README.md +1 -0
- package/lib/compiler/c++/README.md +1 -0
- package/lib/compiler/enum/CompileMode.d.ts +22 -0
- package/lib/compiler/enum/CompileMode.js +30 -0
- package/lib/compiler/enum/CompileMode.js.map +1 -0
- package/lib/compiler/interface/ICompileParam.d.ts +24 -0
- package/lib/compiler/interface/ICompileParam.js +4 -0
- package/lib/compiler/interface/ICompileParam.js.map +1 -0
- package/lib/compiler/interface/ICompiler.d.ts +5 -0
- package/lib/compiler/interface/ICompiler.js +4 -0
- package/lib/compiler/interface/ICompiler.js.map +1 -0
- package/lib/compiler/interface/ISignConfig.d.ts +8 -0
- package/lib/compiler/interface/ISignConfig.js +4 -0
- package/lib/compiler/interface/ISignConfig.js.map +1 -0
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +11 -0
- package/lib/compiler/javascript/JavascriptCompiler.js +108 -0
- package/lib/compiler/javascript/JavascriptCompiler.js.map +1 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +3 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +21 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +1 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +40 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +4 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +1 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +40 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +1 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +16 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +74 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +1 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.d.ts +25 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +47 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +1 -0
- package/lib/compiler/javascript/vela/enum/EntryType.d.ts +30 -0
- package/lib/compiler/javascript/vela/enum/EntryType.js +35 -0
- package/lib/compiler/javascript/vela/enum/EntryType.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +29 -0
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -0
- package/lib/compiler/javascript/vela/interface/IChunk.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +27 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +4 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +11 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +4 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +1 -0
- package/lib/compiler/javascript/vela/model/Package.d.ts +75 -0
- package/lib/compiler/javascript/vela/model/Package.js +62 -0
- package/lib/compiler/javascript/vela/model/Package.js.map +1 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +7 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +51 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +10 -0
- package/lib/compiler/javascript/vela/utils/Jsc.js +34 -0
- package/lib/compiler/javascript/vela/utils/Jsc.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +29 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +144 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +75 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +278 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +11 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +77 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.d.ts +9 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +45 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +94 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +713 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +16 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +30 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +27 -0
- package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +51 -0
- package/lib/config/UxConfig.d.ts +30 -0
- package/lib/config/UxConfig.js +52 -0
- package/lib/config/UxConfig.js.map +1 -0
- package/lib/config/XtsConfig.d.ts +18 -0
- package/lib/config/XtsConfig.js +28 -0
- package/lib/config/XtsConfig.js.map +1 -0
- package/lib/followWorks/xts/entryTemplate.d.ts +21 -0
- package/lib/followWorks/xts/entryTemplate.js +166 -0
- package/lib/followWorks/xts/entryTemplate.js.map +1 -0
- package/lib/followWorks/xts/ts2wasm.d.ts +6 -0
- package/lib/followWorks/xts/ts2wasm.js +31 -0
- package/lib/followWorks/xts/ts2wasm.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/interface/IDeviceList.d.ts +7 -0
- package/lib/interface/IDeviceList.js +4 -0
- package/lib/interface/IDeviceList.js.map +1 -0
- package/lib/loader/ux/AppUxLoader.d.ts +10 -0
- package/lib/loader/ux/AppUxLoader.js +31 -0
- package/lib/loader/ux/AppUxLoader.js.map +1 -0
- package/lib/loader/ux/PngLoader.d.ts +10 -0
- package/lib/loader/ux/PngLoader.js +70 -0
- package/lib/loader/ux/PngLoader.js.map +1 -0
- package/lib/loader/ux/UxLoader.d.ts +6 -0
- package/lib/loader/ux/UxLoader.js +31 -0
- package/lib/loader/ux/UxLoader.js.map +1 -0
- package/lib/loader/xts/XtsLoader.d.ts +9 -0
- package/lib/loader/xts/XtsLoader.js +55 -0
- package/lib/loader/xts/XtsLoader.js.map +1 -0
- package/lib/utils/PngUtils.d.ts +20 -0
- package/lib/utils/PngUtils.js +45 -0
- package/lib/utils/PngUtils.js.map +1 -0
- package/lib/utils/PreWorkUtils.d.ts +17 -0
- package/lib/utils/PreWorkUtils.js +76 -0
- package/lib/utils/PreWorkUtils.js.map +1 -0
- package/lib/utils/ux/UxFileUtils.d.ts +22 -0
- package/lib/utils/ux/UxFileUtils.js +34 -0
- package/lib/utils/ux/UxFileUtils.js.map +1 -0
- package/lib/utils/ux/UxFollowWorks.d.ts +35 -0
- package/lib/utils/ux/UxFollowWorks.js +200 -0
- package/lib/utils/ux/UxFollowWorks.js.map +1 -0
- package/lib/utils/ux/UxLoaderUtils.d.ts +60 -0
- package/lib/utils/ux/UxLoaderUtils.js +241 -0
- package/lib/utils/ux/UxLoaderUtils.js.map +1 -0
- package/lib/utils/xts/XtsFollowWorks.d.ts +29 -0
- package/lib/utils/xts/XtsFollowWorks.js +149 -0
- package/lib/utils/xts/XtsFollowWorks.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# `aiotpack`
|
|
2
|
+
|
|
3
|
+
最终打包工具,包含各类语言、各类平台的打包配置
|
|
4
|
+
|
|
5
|
+
## 目录结构
|
|
6
|
+
|
|
7
|
+
| 目录 | 描述 |
|
|
8
|
+
| -------- | ------------------------------------------------------------------------------- |
|
|
9
|
+
| config | FileLane 配置,基于此配置,可完成“源码项目-->目标代码项目-->应用程序”的完整流程 |
|
|
10
|
+
| compiler | 目标语言-->应用程序编译器 |
|
|
11
|
+
| loader | 源码语言-->目标代码语言 |
|
|
12
|
+
| utils | 语言、项目无关的辅助工具 |
|
|
13
|
+
|
|
14
|
+
## config
|
|
15
|
+
|
|
16
|
+
通过在 FileLane 中配置各项参数,可完成“**源码项目-->目标代码项目-->应用程序**”的完整流程
|
|
17
|
+
|
|
18
|
+
## compiler
|
|
19
|
+
|
|
20
|
+
#### 概述
|
|
21
|
+
|
|
22
|
+
源码已生成目标代码项目,此时需要生成**最终产物--应用程序**。compiler 目录中的代码即为完成此项工作而生。
|
|
23
|
+
|
|
24
|
+
#### 子目录
|
|
25
|
+
|
|
26
|
+
compiler 下的每个子目录,对应一种目标语言;每种目标语言在不同平台又可能有不同的生成方式。
|
|
27
|
+
|
|
28
|
+
因此结构为:`compiler/目标语言/目标平台`,例如:
|
|
29
|
+
|
|
30
|
+
- `compiler/javascript/vela`--javascript 语言在 vela 平台的生成
|
|
31
|
+
|
|
32
|
+
#### 添加编译器
|
|
33
|
+
|
|
34
|
+
1. 按上述目录结构,添加目录
|
|
35
|
+
2. 创建编译器`class XCompiler`, 建议实现实现`ICompiler` 接口,以便以后实现统一的用户端接口
|
|
36
|
+
3. 在需要的位置调用
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
new XCompiler().compile({
|
|
40
|
+
projectPath: '',
|
|
41
|
+
mode: 'development',
|
|
42
|
+
platform: 'native'
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## loader--各类语言的转换器
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# todo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# todo
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 编译模式枚举
|
|
3
|
+
*/
|
|
4
|
+
declare enum CompileMode {
|
|
5
|
+
/**
|
|
6
|
+
* 开发模式
|
|
7
|
+
*/
|
|
8
|
+
DEVELOPMENT = "development",
|
|
9
|
+
/**
|
|
10
|
+
* 生产模式
|
|
11
|
+
*/
|
|
12
|
+
PRODUCTION = "production"
|
|
13
|
+
}
|
|
14
|
+
declare namespace CompileMode {
|
|
15
|
+
/**
|
|
16
|
+
* 判断是否为生产模式
|
|
17
|
+
* @param value
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
function isProductionMode(value: CompileMode): boolean;
|
|
21
|
+
}
|
|
22
|
+
export default CompileMode;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* 编译模式枚举
|
|
5
|
+
*/
|
|
6
|
+
var CompileMode;
|
|
7
|
+
(function (CompileMode) {
|
|
8
|
+
/**
|
|
9
|
+
* 开发模式
|
|
10
|
+
*/
|
|
11
|
+
CompileMode["DEVELOPMENT"] = "development";
|
|
12
|
+
/**
|
|
13
|
+
* 生产模式
|
|
14
|
+
*/
|
|
15
|
+
CompileMode["PRODUCTION"] = "production";
|
|
16
|
+
})(CompileMode || (CompileMode = {}));
|
|
17
|
+
(function (CompileMode) {
|
|
18
|
+
/**
|
|
19
|
+
* 判断是否为生产模式
|
|
20
|
+
* @param value
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
function isProductionMode(value) {
|
|
24
|
+
return value === CompileMode.PRODUCTION;
|
|
25
|
+
}
|
|
26
|
+
CompileMode.isProductionMode = isProductionMode;
|
|
27
|
+
})(CompileMode || (CompileMode = {}));
|
|
28
|
+
exports.default = CompileMode;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=CompileMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/enum/CompileMode.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAK,WAUJ;AAVD,WAAK,WAAW;IACd;;OAEG;IACH,0CAA2B,CAAA;IAE3B;;OAEG;IACH,wCAAyB,CAAA;AAC3B,CAAC,EAVI,WAAW,KAAX,WAAW,QAUf;AACD,WAAU,WAAW;IACnB;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,KAAkB;QACjD,OAAO,KAAK,KAAK,WAAW,CAAC,UAAU,CAAA;IACzC,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;AACH,CAAC,EATS,WAAW,KAAX,WAAW,QASpB;AACD,kBAAe,WAAW,CAAA","file":"CompileMode.js","sourcesContent":["/**\n * 编译模式枚举\n */\nenum CompileMode {\n /**\n * 开发模式\n */\n DEVELOPMENT = 'development',\n\n /**\n * 生产模式\n */\n PRODUCTION = 'production'\n}\nnamespace CompileMode {\n /**\n * 判断是否为生产模式\n * @param value\n * @returns\n */\n export function isProductionMode(value: CompileMode): boolean {\n return value === CompileMode.PRODUCTION\n }\n} \nexport default CompileMode\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type';
|
|
2
|
+
import CompileMode from '../enum/CompileMode';
|
|
3
|
+
/**
|
|
4
|
+
* 编译参数
|
|
5
|
+
*/
|
|
6
|
+
export default interface ICompileParam extends Dictionary<any> {
|
|
7
|
+
/**
|
|
8
|
+
* 项目路径
|
|
9
|
+
*/
|
|
10
|
+
projectPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* 打包模式,开发环境/生产环境
|
|
13
|
+
*/
|
|
14
|
+
mode: CompileMode;
|
|
15
|
+
platform: string;
|
|
16
|
+
/**
|
|
17
|
+
* 打包来源
|
|
18
|
+
*
|
|
19
|
+
* cmd:命令行
|
|
20
|
+
* quickapp-ide:快应用 IDE
|
|
21
|
+
* 其它自定义值
|
|
22
|
+
*/
|
|
23
|
+
originType?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/interface/ICompileParam.ts"],"names":[],"mappings":"","file":"ICompileParam.js","sourcesContent":["import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport CompileMode from '../enum/CompileMode'\n\n/**\n * 编译参数\n */\nexport default interface ICompileParam extends Dictionary<any> {\n /**\n * 项目路径\n */\n projectPath: string\n\n /**\n * 打包模式,开发环境/生产环境\n */\n mode: CompileMode\n\n platform: string\n\n /**\n * 打包来源\n *\n * cmd:命令行\n * quickapp-ide:快应用 IDE\n * 其它自定义值\n */\n originType?: string\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/interface/ICompiler.ts"],"names":[],"mappings":"","file":"ICompiler.js","sourcesContent":["import ICompileParam from \"./ICompileParam\";\n\nexport default interface ICompiler {\n compile(param: ICompileParam): Promise<void>;\n clean(param: ICompileParam): Promise<void>;\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/interface/ISignConfig.ts"],"names":[],"mappings":"","file":"ISignConfig.js","sourcesContent":["/**\n * ISignConfig\n */\nexport default interface ISignConfig {\n privatekey: Buffer\n certificate: Buffer\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ICompileParam from '../interface/ICompileParam';
|
|
2
|
+
import ICompiler from '../interface/ICompiler';
|
|
3
|
+
import IJavascriptCompileOption from './interface/IJavascriptCompileOption';
|
|
4
|
+
declare class JavascriptCompiler implements ICompiler {
|
|
5
|
+
compile(param: IJavascriptCompileOption): Promise<void>;
|
|
6
|
+
private createWebpackConfig;
|
|
7
|
+
private getConfigurator;
|
|
8
|
+
private showEnvLog;
|
|
9
|
+
clean(param: ICompileParam & IJavascriptCompileOption): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default JavascriptCompiler;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 ColorConsole2_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole2"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const webpack_1 = require("webpack");
|
|
18
|
+
const VelaWebpackConfigurator_1 = __importDefault(require("./vela/VelaWebpackConfigurator"));
|
|
19
|
+
const UxCompileUtil_1 = __importDefault(require("./vela/utils/UxCompileUtil"));
|
|
20
|
+
class JavascriptCompiler {
|
|
21
|
+
compile(param) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
this.showEnvLog(param);
|
|
25
|
+
yield this.clean(param);
|
|
26
|
+
const config = this.createWebpackConfig(param);
|
|
27
|
+
(0, webpack_1.webpack)(config, (error) => {
|
|
28
|
+
if (error) {
|
|
29
|
+
reject(error);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
ColorConsole2_1.default.info(`webpack complete`);
|
|
33
|
+
resolve();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
createWebpackConfig(param) {
|
|
40
|
+
const configurator = this.getConfigurator();
|
|
41
|
+
if (!configurator) {
|
|
42
|
+
throw new Error(`This project is not supported`);
|
|
43
|
+
}
|
|
44
|
+
configurator.param = param;
|
|
45
|
+
// 如果configurator有 create 函数,直接返回
|
|
46
|
+
// 否则,结合configurator生成默认配置,并使用
|
|
47
|
+
if (configurator.create) {
|
|
48
|
+
return configurator.create();
|
|
49
|
+
}
|
|
50
|
+
const { projectPath, mode, devtool, outputPath } = param;
|
|
51
|
+
const buildPath = path_1.default.resolve(projectPath, outputPath);
|
|
52
|
+
const result = {
|
|
53
|
+
context: projectPath,
|
|
54
|
+
mode,
|
|
55
|
+
devtool,
|
|
56
|
+
output: {
|
|
57
|
+
globalObject: 'window',
|
|
58
|
+
filename: '[name].js',
|
|
59
|
+
publicPath: './',
|
|
60
|
+
path: buildPath
|
|
61
|
+
},
|
|
62
|
+
module: {},
|
|
63
|
+
stats: {
|
|
64
|
+
builtAt: false,
|
|
65
|
+
entrypoints: false,
|
|
66
|
+
children: false,
|
|
67
|
+
chunks: false,
|
|
68
|
+
chunkModules: false,
|
|
69
|
+
chunkOrigins: false,
|
|
70
|
+
modules: false,
|
|
71
|
+
version: false,
|
|
72
|
+
assets: false
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (configurator.createEntry) {
|
|
76
|
+
result.entry = configurator.createEntry();
|
|
77
|
+
}
|
|
78
|
+
if (configurator.createRules && result.module) {
|
|
79
|
+
result.module.rules = configurator.createRules();
|
|
80
|
+
}
|
|
81
|
+
if (configurator.createPlugins) {
|
|
82
|
+
result.plugins = configurator.createPlugins();
|
|
83
|
+
}
|
|
84
|
+
if (configurator.hook) {
|
|
85
|
+
configurator.hook(result);
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
getConfigurator() {
|
|
90
|
+
return new VelaWebpackConfigurator_1.default();
|
|
91
|
+
}
|
|
92
|
+
showEnvLog(param) {
|
|
93
|
+
const env = {
|
|
94
|
+
NODE_PLATFORM: param.platform,
|
|
95
|
+
NODE_PHASE: param.mode
|
|
96
|
+
};
|
|
97
|
+
console.log(`Configuration environment:${JSON.stringify(env)}`);
|
|
98
|
+
}
|
|
99
|
+
clean(param) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const { outputPath, releasePath, projectPath } = param;
|
|
102
|
+
UxCompileUtil_1.default.clean([outputPath, releasePath].map((item) => path_1.default.resolve(projectPath, item)));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.default = JavascriptCompiler;
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=JavascriptCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/JavascriptCompiler.ts"],"names":[],"mappings":"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","file":"JavascriptCompiler.js","sourcesContent":["import ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport path from 'path'\nimport { Configuration, webpack } from 'webpack'\nimport ICompileParam from '../interface/ICompileParam'\nimport ICompiler from '../interface/ICompiler'\nimport IJavascriptCompileOption from './interface/IJavascriptCompileOption'\nimport IWebpackConfigurator from './interface/IWebpackConfigurator'\nimport VelaWebpackConfigurator from './vela/VelaWebpackConfigurator'\nimport UxCompileUtil from './vela/utils/UxCompileUtil'\n\nclass JavascriptCompiler implements ICompiler {\n async compile(param: IJavascriptCompileOption): Promise<void> {\n return new Promise(async (resolve, reject) => {\n this.showEnvLog(param)\n await this.clean(param)\n const config = this.createWebpackConfig(param)\n webpack(config, (error) => {\n if (error) {\n reject(error)\n } else {\n ColorConsole2.info(`webpack complete`)\n resolve()\n }\n })\n })\n }\n\n private createWebpackConfig(param: IJavascriptCompileOption): Configuration {\n const configurator = this.getConfigurator()\n if (!configurator) {\n throw new Error(`This project is not supported`)\n }\n\n configurator.param = param\n // 如果configurator有 create 函数,直接返回\n // 否则,结合configurator生成默认配置,并使用\n if (configurator.create) {\n return configurator.create()\n }\n\n const { projectPath, mode, devtool, outputPath } = param\n const buildPath = path.resolve(projectPath, outputPath)\n\n const result: Configuration = {\n context: projectPath,\n mode,\n devtool,\n output: {\n globalObject: 'window',\n filename: '[name].js',\n publicPath: './',\n path: buildPath\n },\n module: {},\n stats: {\n builtAt: false,\n entrypoints: false,\n children: false,\n chunks: false,\n chunkModules: false,\n chunkOrigins: false,\n modules: false,\n version: false,\n assets: false\n }\n }\n\n if (configurator.createEntry) {\n result.entry = configurator.createEntry()\n }\n\n if (configurator.createRules && result.module) {\n result.module.rules = configurator.createRules()\n }\n\n if (configurator.createPlugins) {\n result.plugins = configurator.createPlugins()\n }\n\n if (configurator.hook) {\n configurator.hook(result)\n }\n\n return result\n }\n\n private getConfigurator(): IWebpackConfigurator {\n return new VelaWebpackConfigurator()\n }\n\n private showEnvLog(param: ICompileParam) {\n const env = {\n NODE_PLATFORM: param.platform,\n NODE_PHASE: param.mode\n }\n\n console.log(`Configuration environment:${JSON.stringify(env)}`)\n }\n\n async clean(param: ICompileParam & IJavascriptCompileOption): Promise<void> {\n const { outputPath, releasePath, projectPath } = param\n UxCompileUtil.clean([outputPath, releasePath].map((item) => path.resolve(projectPath, item)))\n }\n}\n\nexport default JavascriptCompiler\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const os_1 = __importDefault(require("os"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const clientRecordPath = path_1.default.join(os_1.default.homedir(), 'hap-toolkit-client-records.json');
|
|
9
|
+
const JavascriptDefaultCompileOption = {
|
|
10
|
+
devtool: false,
|
|
11
|
+
sourceRoot: './src',
|
|
12
|
+
signRoot: './sign',
|
|
13
|
+
releasePath: './dist',
|
|
14
|
+
outputPath: './build',
|
|
15
|
+
dataCoverage: './.nyc_output',
|
|
16
|
+
clientRecordPath,
|
|
17
|
+
server: { port: 8000 }
|
|
18
|
+
};
|
|
19
|
+
exports.default = JavascriptDefaultCompileOption;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=JavascriptDefaultCompileOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/JavascriptDefaultCompileOption.ts"],"names":[],"mappings":";;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAGvB,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,iCAAiC,CAAC,CAAA;AACnF,MAAM,8BAA8B,GAAsC;IACxE,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,eAAe;IAC7B,gBAAgB;IAChB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;CACvB,CAAA;AAED,kBAAe,8BAA8B,CAAA","file":"JavascriptDefaultCompileOption.js","sourcesContent":["import os from 'os'\nimport path from 'path'\nimport IJavascriptCompileOption from './interface/IJavascriptCompileOption'\n\nconst clientRecordPath = path.join(os.homedir(), 'hap-toolkit-client-records.json')\nconst JavascriptDefaultCompileOption: Partial<IJavascriptCompileOption> = {\n devtool: false,\n sourceRoot: './src',\n signRoot: './sign',\n releasePath: './dist',\n outputPath: './build',\n dataCoverage: './.nyc_output',\n clientRecordPath,\n server: { port: 8000 }\n}\n\nexport default JavascriptDefaultCompileOption\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ICompileParam from '../../interface/ICompileParam';
|
|
2
|
+
import BuildNameFormatType from '../vela/enum/BuildNameFormatType';
|
|
3
|
+
export default interface IJavascriptCompileOption extends ICompileParam {
|
|
4
|
+
devtool?: string | false;
|
|
5
|
+
/**
|
|
6
|
+
* 源码根目录
|
|
7
|
+
*/
|
|
8
|
+
sourceRoot: string;
|
|
9
|
+
/**
|
|
10
|
+
* 证书签名路径
|
|
11
|
+
*/
|
|
12
|
+
signRoot: string;
|
|
13
|
+
/**
|
|
14
|
+
* 应用程序目录
|
|
15
|
+
*/
|
|
16
|
+
releasePath: string;
|
|
17
|
+
/**
|
|
18
|
+
* 输出目录
|
|
19
|
+
*/
|
|
20
|
+
outputPath: string;
|
|
21
|
+
/**
|
|
22
|
+
* 项目运行的代码覆盖率数据
|
|
23
|
+
*/
|
|
24
|
+
dataCoverage: string;
|
|
25
|
+
clientRecordPath: string;
|
|
26
|
+
/**
|
|
27
|
+
* 运行端口
|
|
28
|
+
*/
|
|
29
|
+
server: {
|
|
30
|
+
port: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 包名格式
|
|
34
|
+
*/
|
|
35
|
+
buildNameFormat?: BuildNameFormatType;
|
|
36
|
+
/**
|
|
37
|
+
* 禁用 jsc
|
|
38
|
+
*/
|
|
39
|
+
disabledJSC?: boolean;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/interface/IJavascriptCompileOption.ts"],"names":[],"mappings":"","file":"IJavascriptCompileOption.js","sourcesContent":["import ICompileParam from '../../interface/ICompileParam'\nimport BuildNameFormatType from '../vela/enum/BuildNameFormatType'\n\nexport default interface IJavascriptCompileOption extends ICompileParam {\n devtool?: string | false\n\n /**\n * 源码根目录\n */\n sourceRoot: string\n\n /**\n * 证书签名路径\n */\n signRoot: string\n\n /**\n * 应用程序目录\n */\n releasePath: string\n\n /**\n * 输出目录\n */\n outputPath: string\n\n /**\n * 项目运行的代码覆盖率数据\n */\n dataCoverage: string\n\n clientRecordPath: string\n\n /**\n * 运行端口\n */\n server: { port: number }\n\n /**\n * 包名格式\n */\n buildNameFormat?: BuildNameFormatType\n\n /**\n * 禁用 jsc\n */\n disabledJSC?: boolean\n}\n"],"sourceRoot":"../../../../src"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Configuration, EntryObject, RuleSetRule, WebpackPluginInstance } from "webpack";
|
|
2
|
+
import ICompileParam from "../../interface/ICompileParam";
|
|
3
|
+
/**
|
|
4
|
+
* webpack配置器
|
|
5
|
+
*
|
|
6
|
+
* 可用2种方式生成 webpack 配置
|
|
7
|
+
*
|
|
8
|
+
* 1. 完全自定义:仅实现 create 函数返回完整的 webpack配置
|
|
9
|
+
* 2. 系统默认配置 +自定义常用属性:实现createPlugin、createEntry、createRules、hook
|
|
10
|
+
*/
|
|
11
|
+
interface IWebpackConfigurator {
|
|
12
|
+
/**
|
|
13
|
+
* 编译参数
|
|
14
|
+
*/
|
|
15
|
+
param: ICompileParam;
|
|
16
|
+
/**
|
|
17
|
+
* 创建 webpack 完整配置
|
|
18
|
+
*
|
|
19
|
+
* 如实现此函数,则其它函数无效
|
|
20
|
+
*/
|
|
21
|
+
create?(): Configuration;
|
|
22
|
+
/**
|
|
23
|
+
* 创建 webpack 的 plugins
|
|
24
|
+
*/
|
|
25
|
+
createPlugins?(): WebpackPluginInstance[];
|
|
26
|
+
/**
|
|
27
|
+
* 创建 webpack 的 entry
|
|
28
|
+
*/
|
|
29
|
+
createEntry?(): string | string[] | EntryObject;
|
|
30
|
+
/**
|
|
31
|
+
* 创建 webpack 的 rules
|
|
32
|
+
*/
|
|
33
|
+
createRules?(): RuleSetRule[];
|
|
34
|
+
/**
|
|
35
|
+
* 对已有的 webpack 配置做修改
|
|
36
|
+
* @param config
|
|
37
|
+
*/
|
|
38
|
+
hook?(config: Configuration): void;
|
|
39
|
+
}
|
|
40
|
+
export default IWebpackConfigurator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/interface/IWebpackConfigurator.ts"],"names":[],"mappings":"","file":"IWebpackConfigurator.js","sourcesContent":["import {\n Configuration,\n EntryObject,\n RuleSetRule,\n WebpackPluginInstance,\n} from \"webpack\";\nimport ICompileParam from \"../../interface/ICompileParam\";\n\n/**\n * webpack配置器\n *\n * 可用2种方式生成 webpack 配置\n *\n * 1. 完全自定义:仅实现 create 函数返回完整的 webpack配置\n * 2. 系统默认配置 +自定义常用属性:实现createPlugin、createEntry、createRules、hook\n */\ninterface IWebpackConfigurator {\n /**\n * 编译参数\n */\n param: ICompileParam;\n\n /**\n * 创建 webpack 完整配置\n *\n * 如实现此函数,则其它函数无效\n */\n create?(): Configuration;\n\n /**\n * 创建 webpack 的 plugins\n */\n createPlugins?(): WebpackPluginInstance[];\n\n /**\n * 创建 webpack 的 entry\n */\n createEntry?(): string | string[] | EntryObject;\n\n /**\n * 创建 webpack 的 rules\n */\n createRules?(): RuleSetRule[];\n\n /**\n * 对已有的 webpack 配置做修改\n * @param config\n */\n hook?(config: Configuration): void;\n}\n\nexport default IWebpackConfigurator;\n"],"sourceRoot":"../../../../src"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Configuration, EntryObject, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
2
|
+
import ICompileParam from '../../interface/ICompileParam';
|
|
3
|
+
import IJavascriptCompileOption from '../interface/IJavascriptCompileOption';
|
|
4
|
+
import IWebpackConfigurator from '../interface/IWebpackConfigurator';
|
|
5
|
+
declare class VelaWebpackConfigurator implements IWebpackConfigurator {
|
|
6
|
+
param: ICompileParam & IJavascriptCompileOption;
|
|
7
|
+
createPlugins(): WebpackPluginInstance[];
|
|
8
|
+
/**
|
|
9
|
+
* 通过读取 manifest.json 生成 entry
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
createEntry(): string | EntryObject | string[];
|
|
13
|
+
createRules(): RuleSetRule[];
|
|
14
|
+
hook(config: Configuration): void;
|
|
15
|
+
}
|
|
16
|
+
export default VelaWebpackConfigurator;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const UxFileUtils_1 = __importDefault(require("../../../utils/ux/UxFileUtils"));
|
|
9
|
+
const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
10
|
+
const UxCompileUtil_1 = __importDefault(require("./utils/UxCompileUtil"));
|
|
11
|
+
class VelaWebpackConfigurator {
|
|
12
|
+
createPlugins() {
|
|
13
|
+
return [
|
|
14
|
+
// 给 入口js 添加包裹
|
|
15
|
+
new WrapPlugin_1.default()
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 通过读取 manifest.json 生成 entry
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
createEntry() {
|
|
23
|
+
const { projectPath, sourceRoot } = this.param;
|
|
24
|
+
const configFilePath = UxFileUtils_1.default.getManifestFilePath(this.param.projectPath, this.param.sourceRoot);
|
|
25
|
+
if (fs_extra_1.default.existsSync(configFilePath)) {
|
|
26
|
+
const config = fs_extra_1.default.readJSONSync(configFilePath);
|
|
27
|
+
return UxCompileUtil_1.default.resolveEntries(config, path_1.default.resolve(projectPath, sourceRoot), projectPath);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error(`Configuration file does not exist: ${configFilePath}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
createRules() {
|
|
34
|
+
const { projectPath, sourceRoot } = this.param;
|
|
35
|
+
const srcPath = path_1.default.resolve(projectPath, sourceRoot);
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
test: /\.js$/,
|
|
39
|
+
use: [
|
|
40
|
+
{
|
|
41
|
+
loader: require.resolve('babel-loader'),
|
|
42
|
+
options: {
|
|
43
|
+
// configFile: getBabelConfigJsPath(cwd),
|
|
44
|
+
cwd: this.param.projectPath,
|
|
45
|
+
cacheDirectory: true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
test: /\.json$/,
|
|
52
|
+
include: [path_1.default.join(srcPath, 'manifest.json')]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
test: /\.(png|jpe?g|gif|svg|bmp|webp|mp4|wmv|avi|mpg|rmvb|mov|flv|otf|ttf|ttc|woff|eot)$/i,
|
|
56
|
+
use: {
|
|
57
|
+
loader: require.resolve('url-loader'),
|
|
58
|
+
options: {
|
|
59
|
+
limit: 0,
|
|
60
|
+
name: `dynamicAssets/[name].[hash:8].[ext]`,
|
|
61
|
+
publicPath: '/',
|
|
62
|
+
esModule: false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
hook(config) {
|
|
69
|
+
// todo 合并用户配置
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = VelaWebpackConfigurator;
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=VelaWebpackConfigurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/vela/VelaWebpackConfigurator.ts"],"names":[],"mappings":";;;;;AAAA,wDAAyB;AACzB,gDAAuB;AAEvB,gFAAuD;AAIvD,qEAA4C;AAC5C,0EAAiD;AAEjD,MAAM,uBAAuB;IAG3B,aAAa;QACX,OAAO;YACL,cAAc;YACd,IAAI,oBAAU,EAAE;SACjB,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC9C,MAAM,cAAc,GAAG,qBAAW,CAAC,mBAAmB,CACpD,IAAI,CAAC,KAAK,CAAC,WAAW,EACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CACtB,CAAA;QAED,IAAI,kBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;YACjC,MAAM,MAAM,GAAG,kBAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;YAC9C,OAAO,uBAAa,CAAC,cAAc,CACjC,MAAM,EACN,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,EACrC,WAAW,CACZ,CAAA;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,sCAAsC,cAAc,EAAE,CAAC,CAAA;SACxE;IACH,CAAC;IACD,WAAW;QACT,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC9C,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACrD,OAAO;YACL;gBACE,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE;oBACH;wBACE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;wBACvC,OAAO,EAAE;4BACP,yCAAyC;4BACzC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;4BAC3B,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF;aACF;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;aAC/C;YACD;gBACE,IAAI,EAAE,oFAAoF;gBAC1F,GAAG,EAAE;oBACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;oBACrC,OAAO,EAAE;wBACP,KAAK,EAAE,CAAC;wBACR,IAAI,EAAE,qCAAqC;wBAC3C,UAAU,EAAE,GAAG;wBACf,QAAQ,EAAE,KAAK;qBAChB;iBACF;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,CAAC,MAAqB;QACxB,cAAc;IAChB,CAAC;CACF;AAED,kBAAe,uBAAuB,CAAA","file":"VelaWebpackConfigurator.js","sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\nimport { Configuration, EntryObject, RuleSetRule, WebpackPluginInstance } from 'webpack'\nimport UxFileUtils from '../../../utils/ux/UxFileUtils'\nimport ICompileParam from '../../interface/ICompileParam'\nimport IJavascriptCompileOption from '../interface/IJavascriptCompileOption'\nimport IWebpackConfigurator from '../interface/IWebpackConfigurator'\nimport WrapPlugin from './plugin/WrapPlugin'\nimport UxCompileUtil from './utils/UxCompileUtil'\n\nclass VelaWebpackConfigurator implements IWebpackConfigurator {\n param!: ICompileParam & IJavascriptCompileOption\n\n createPlugins(): WebpackPluginInstance[] {\n return [\n // 给 入口js 添加包裹\n new WrapPlugin()\n ]\n }\n\n /**\n * 通过读取 manifest.json 生成 entry\n * @returns\n */\n createEntry(): string | EntryObject | string[] {\n const { projectPath, sourceRoot } = this.param\n const configFilePath = UxFileUtils.getManifestFilePath(\n this.param.projectPath,\n this.param.sourceRoot\n )\n\n if (fs.existsSync(configFilePath)) {\n const config = fs.readJSONSync(configFilePath)\n return UxCompileUtil.resolveEntries(\n config,\n path.resolve(projectPath, sourceRoot),\n projectPath\n )\n } else {\n throw new Error(`Configuration file does not exist: ${configFilePath}`)\n }\n }\n createRules(): RuleSetRule[] {\n const { projectPath, sourceRoot } = this.param\n const srcPath = path.resolve(projectPath, sourceRoot)\n return [\n {\n test: /\\.js$/,\n use: [\n {\n loader: require.resolve('babel-loader'),\n options: {\n // configFile: getBabelConfigJsPath(cwd),\n cwd: this.param.projectPath,\n cacheDirectory: true\n }\n }\n ]\n },\n {\n test: /\\.json$/,\n include: [path.join(srcPath, 'manifest.json')]\n },\n {\n test: /\\.(png|jpe?g|gif|svg|bmp|webp|mp4|wmv|avi|mpg|rmvb|mov|flv|otf|ttf|ttc|woff|eot)$/i,\n use: {\n loader: require.resolve('url-loader'),\n options: {\n limit: 0,\n name: `dynamicAssets/[name].[hash:8].[ext]`,\n publicPath: '/',\n esModule: false\n }\n }\n }\n ]\n }\n\n hook(config: Configuration): void {\n // todo 合并用户配置\n }\n}\n\nexport default VelaWebpackConfigurator\n"],"sourceRoot":"../../../../src"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构建名格式类型枚举
|
|
3
|
+
*/
|
|
4
|
+
declare enum BuildNameFormatType {
|
|
5
|
+
/**
|
|
6
|
+
* 默认格式
|
|
7
|
+
*/
|
|
8
|
+
DEFAULT = 1,
|
|
9
|
+
/**
|
|
10
|
+
* 原始格式,文件名不带版本号
|
|
11
|
+
*/
|
|
12
|
+
ORIGINAL = 2
|
|
13
|
+
}
|
|
14
|
+
export default BuildNameFormatType;
|
|
15
|
+
declare namespace BuildNameFormatType {
|
|
16
|
+
/**
|
|
17
|
+
* 枚举值列表,一般用于列表显示,例如下拉框
|
|
18
|
+
*/
|
|
19
|
+
const ALL_LIST: BuildNameFormatType[];
|
|
20
|
+
/**
|
|
21
|
+
* 枚举值转换为字符串
|
|
22
|
+
*/
|
|
23
|
+
function toString(value: BuildNameFormatType): string;
|
|
24
|
+
function toDesc(value: BuildNameFormatType): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* 构建名格式类型枚举
|
|
5
|
+
*/
|
|
6
|
+
var BuildNameFormatType;
|
|
7
|
+
(function (BuildNameFormatType) {
|
|
8
|
+
/**
|
|
9
|
+
* 默认格式
|
|
10
|
+
*/
|
|
11
|
+
BuildNameFormatType[BuildNameFormatType["DEFAULT"] = 1] = "DEFAULT";
|
|
12
|
+
/**
|
|
13
|
+
* 原始格式,文件名不带版本号
|
|
14
|
+
*/
|
|
15
|
+
BuildNameFormatType[BuildNameFormatType["ORIGINAL"] = 2] = "ORIGINAL";
|
|
16
|
+
})(BuildNameFormatType || (BuildNameFormatType = {}));
|
|
17
|
+
exports.default = BuildNameFormatType;
|
|
18
|
+
(function (BuildNameFormatType) {
|
|
19
|
+
/**
|
|
20
|
+
* 枚举值列表,一般用于列表显示,例如下拉框
|
|
21
|
+
*/
|
|
22
|
+
BuildNameFormatType.ALL_LIST = [
|
|
23
|
+
BuildNameFormatType.DEFAULT,
|
|
24
|
+
BuildNameFormatType.ORIGINAL
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* 枚举值转换为字符串
|
|
28
|
+
*/
|
|
29
|
+
function toString(value) {
|
|
30
|
+
const dic = {
|
|
31
|
+
[BuildNameFormatType.DEFAULT]: 'default',
|
|
32
|
+
[BuildNameFormatType.ORIGINAL]: 'original'
|
|
33
|
+
};
|
|
34
|
+
return dic[value] || '';
|
|
35
|
+
}
|
|
36
|
+
BuildNameFormatType.toString = toString;
|
|
37
|
+
function toDesc(value) {
|
|
38
|
+
const dic = {
|
|
39
|
+
[BuildNameFormatType.DEFAULT]: 'The format is: packageName.signaturType.version.extname',
|
|
40
|
+
[BuildNameFormatType.ORIGINAL]: 'The format is: packageName.signaturType.extname'
|
|
41
|
+
};
|
|
42
|
+
return dic[value] || '';
|
|
43
|
+
}
|
|
44
|
+
BuildNameFormatType.toDesc = toDesc;
|
|
45
|
+
})(BuildNameFormatType || (BuildNameFormatType = {}));
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=BuildNameFormatType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler/javascript/vela/enum/BuildNameFormatType.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAK,mBAUJ;AAVD,WAAK,mBAAmB;IACtB;;OAEG;IACH,mEAAW,CAAA;IAEX;;OAEG;IACH,qEAAY,CAAA;AACd,CAAC,EAVI,mBAAmB,KAAnB,mBAAmB,QAUvB;AAED,kBAAe,mBAAmB,CAAA;AAElC,WAAU,mBAAmB;IAC3B;;OAEG;IACU,4BAAQ,GAA0B;QAC7C,mBAAmB,CAAC,OAAO;QAC3B,mBAAmB,CAAC,QAAQ;KAC7B,CAAA;IAED;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAA0B;QACjD,MAAM,GAAG,GAA6C;YACpD,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,SAAS;YACxC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,UAAU;SAC3C,CAAA;QACD,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;IANe,4BAAQ,WAMvB,CAAA;IAED,SAAgB,MAAM,CAAC,KAA0B;QAC/C,MAAM,GAAG,GAA6C;YACpD,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,yDAAyD;YACxF,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,iDAAiD;SAClF,CAAA;QACD,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;IANe,0BAAM,SAMrB,CAAA;AACH,CAAC,EA3BS,mBAAmB,KAAnB,mBAAmB,QA2B5B","file":"BuildNameFormatType.js","sourcesContent":["/**\n * 构建名格式类型枚举\n */\nenum BuildNameFormatType {\n /**\n * 默认格式\n */\n DEFAULT = 1,\n\n /**\n * 原始格式,文件名不带版本号\n */\n ORIGINAL = 2\n}\n\nexport default BuildNameFormatType\n\nnamespace BuildNameFormatType {\n /**\n * 枚举值列表,一般用于列表显示,例如下拉框\n */\n export const ALL_LIST: BuildNameFormatType[] = [\n BuildNameFormatType.DEFAULT,\n BuildNameFormatType.ORIGINAL\n ]\n\n /**\n * 枚举值转换为字符串\n */\n export function toString(value: BuildNameFormatType) {\n const dic: { [key in BuildNameFormatType]: string } = {\n [BuildNameFormatType.DEFAULT]: 'default',\n [BuildNameFormatType.ORIGINAL]: 'original'\n }\n return dic[value] || ''\n }\n\n export function toDesc(value: BuildNameFormatType) {\n const dic: { [key in BuildNameFormatType]: string } = {\n [BuildNameFormatType.DEFAULT]: 'The format is: packageName.signaturType.version.extname',\n [BuildNameFormatType.ORIGINAL]: 'The format is: packageName.signaturType.extname'\n }\n return dic[value] || ''\n }\n}\n"],"sourceRoot":"../../../../../src"}
|