@cloudbase/lowcode-builder 1.1.10 → 1.2.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.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BuildAppProps } from '@cloudbase/lowcode-generator';
|
|
2
|
+
import { IPlatformApp } from '@cloudbase/cals';
|
|
2
3
|
import { BuildType } from '../types/common';
|
|
3
4
|
/**
|
|
4
5
|
* 该函数从 @govcloud/generate 取到需要的模版文件
|
|
5
6
|
*/
|
|
6
7
|
export declare function generateProjectFiles(buildData: BuildAppProps): Promise<void>;
|
|
7
|
-
export declare function generateHTML({ appId, appBuildDir,
|
|
8
|
+
export declare function generateHTML({ appId, appBuildDir, externalResources, mode, devTool, isBuildApp, buildTypeList, }: {
|
|
8
9
|
appId: string;
|
|
9
|
-
|
|
10
|
+
externalResources: Required<IPlatformApp>['externalResources'];
|
|
10
11
|
appBuildDir: string;
|
|
11
12
|
mode: string;
|
|
12
13
|
devTool: string;
|
|
@@ -7,6 +7,7 @@ exports.generateThemeVarsFile = exports.handleAssets = exports.generateHTML = ex
|
|
|
7
7
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
8
8
|
const generateFiles_1 = require("../util/generateFiles");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const cals_1 = require("@cloudbase/cals");
|
|
10
11
|
const util_1 = require("../util");
|
|
11
12
|
const common_1 = require("../util/common");
|
|
12
13
|
const webpack_1 = require("../service/webpack");
|
|
@@ -24,16 +25,31 @@ async function generateProjectFiles(buildData) {
|
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
27
|
exports.generateProjectFiles = generateProjectFiles;
|
|
27
|
-
async function generateHTML({ appId, appBuildDir,
|
|
28
|
+
async function generateHTML({ appId, appBuildDir, externalResources = [], mode, devTool, isBuildApp, buildTypeList, }) {
|
|
28
29
|
const templatePath = path_1.default.join(config_1.appTemplateDir, 'html', 'index.html.ejs');
|
|
29
30
|
const dstFilePath = path_1.default.join(appBuildDir, 'index.html');
|
|
30
31
|
const packageTpl = await fs_extra_1.default.readFile(templatePath, { encoding: 'utf8' });
|
|
32
|
+
const jsApis = [];
|
|
33
|
+
const cssStyles = [];
|
|
34
|
+
for (let externalResource of externalResources) {
|
|
35
|
+
switch (externalResource.type) {
|
|
36
|
+
case cals_1.EExternalResourceType.JSUrl: {
|
|
37
|
+
jsApis.push(externalResource.url || '');
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case cals_1.EExternalResourceType.CSSUrl: {
|
|
41
|
+
cssStyles.push(externalResource.url || '');
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
31
46
|
await fs_extra_1.default.writeFile(dstFilePath, (0, lodash_1.template)(packageTpl)({
|
|
32
47
|
appId,
|
|
33
48
|
title: '',
|
|
34
49
|
desc: 'WeDa构建的应用',
|
|
35
50
|
canUseVite: (0, util_1.canUseVite)(mode, devTool),
|
|
36
|
-
jsApis: (
|
|
51
|
+
jsApis: Array.from(new Set(jsApis.filter((item) => !!item))),
|
|
52
|
+
cssStyles: Array.from(new Set(cssStyles.filter((item) => !!item))),
|
|
37
53
|
mode,
|
|
38
54
|
isBuildApp,
|
|
39
55
|
isAdminPortal: (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList),
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -105,6 +105,7 @@ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraDat
|
|
|
105
105
|
await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
|
|
106
106
|
// 生成 webpack 配置
|
|
107
107
|
const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
|
|
108
|
+
cals,
|
|
108
109
|
appKey,
|
|
109
110
|
mainAppData,
|
|
110
111
|
subAppDataList,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { BuildAppProps } from '../core/index';
|
|
3
|
+
import { IPlatformApp } from '@cloudbase/cals';
|
|
3
4
|
interface IWebpackCoreProps extends BuildAppProps {
|
|
5
|
+
cals: IPlatformApp;
|
|
4
6
|
appBuildDir: string;
|
|
5
7
|
mpConfig: any;
|
|
6
8
|
mainAppData: IWebRuntimeAppData;
|
|
7
9
|
subAppDataList: IWebRuntimeAppData[];
|
|
8
10
|
assets: string[];
|
|
9
11
|
}
|
|
10
|
-
export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
|
|
12
|
+
export declare function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
|
|
11
13
|
export {};
|
|
@@ -4,7 +4,8 @@ exports.runWebpackCore = void 0;
|
|
|
4
4
|
const common_1 = require("../types/common");
|
|
5
5
|
const webpack_1 = require("../service/webpack");
|
|
6
6
|
const generate_1 = require("./generate");
|
|
7
|
-
|
|
7
|
+
const cals_1 = require("@cloudbase/cals");
|
|
8
|
+
async function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], mpConfig, assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, }) {
|
|
8
9
|
console.time('runWebpackCore');
|
|
9
10
|
console.time('webpackGenerate');
|
|
10
11
|
const allAppDataList = subAppDataList.concat(mainAppData);
|
|
@@ -28,7 +29,10 @@ async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, public
|
|
|
28
29
|
await (0, generate_1.generateHTML)({
|
|
29
30
|
appId: mainAppData.id || appKey,
|
|
30
31
|
appBuildDir,
|
|
31
|
-
|
|
32
|
+
externalResources: (cals.externalResources || []).concat(assets.map((url) => ({
|
|
33
|
+
type: cals_1.EExternalResourceType.CSSUrl,
|
|
34
|
+
url,
|
|
35
|
+
}))),
|
|
32
36
|
mode,
|
|
33
37
|
devTool,
|
|
34
38
|
isBuildApp: buildTypeList.includes(common_1.BuildType.APP),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@cloudbase/cals": "^0.5.
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.
|
|
41
|
+
"@cloudbase/cals": "^0.5.1",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.2.0",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
rel="stylesheet"
|
|
15
15
|
href="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.ba91c21b0d605c84ac7f.css"
|
|
16
16
|
/>
|
|
17
|
+
<% cssStyles.forEach(function(styleUrl){%>
|
|
18
|
+
<link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
|
|
19
|
+
<% })%>
|
|
20
|
+
|
|
17
21
|
<script crossorigin="anonymous" src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
|
|
18
22
|
<script>
|
|
19
23
|
<% if(!isAdminPortal){ %>
|
|
@@ -40,9 +44,7 @@
|
|
|
40
44
|
<% if(mode !== 'production'){ %>
|
|
41
45
|
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
|
|
42
46
|
<script>new VConsole()</script> -->
|
|
43
|
-
<% }%>
|
|
44
|
-
<script src="<%=jsApi %>"></script>
|
|
45
|
-
<% })%>
|
|
47
|
+
<% }%>
|
|
46
48
|
|
|
47
49
|
<!-- 重置浏览器样式 -->
|
|
48
50
|
<style type="text/css">
|
|
@@ -383,7 +385,9 @@
|
|
|
383
385
|
|
|
384
386
|
<body data-weui-theme="light">
|
|
385
387
|
<div id="root" class="main-wrap"></div>
|
|
386
|
-
<%
|
|
388
|
+
<% jsApis.forEach(function(jsApi){%>
|
|
389
|
+
<script src="<%=jsApi %>"></script>
|
|
390
|
+
<% })%> <% if(canUseVite){ %>
|
|
387
391
|
<script type="module" src="/src/index.jsx"></script>
|
|
388
392
|
<% } %> <% if(!isAdminPortal){ %>
|
|
389
393
|
<script src="/weda-config/weda-private.js"></script>
|
|
@@ -461,7 +465,7 @@
|
|
|
461
465
|
></script>
|
|
462
466
|
<script
|
|
463
467
|
crossorigin
|
|
464
|
-
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
468
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.1e31c84cddbb620d740f.bundle.js"
|
|
465
469
|
></script>
|
|
466
470
|
</body>
|
|
467
471
|
</html>
|