@cloudbase/lowcode-builder 1.1.5-alpha.2 → 1.1.6
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/lib/builder/config/index.d.ts +0 -8
- package/lib/builder/config/index.js +1 -16
- package/lib/builder/core/index.d.ts +2 -32
- package/lib/builder/core/index.js +30 -147
- package/lib/builder/h5/generate.d.ts +1 -3
- package/lib/builder/h5/generate.js +1 -2
- package/lib/builder/h5/index.d.ts +6 -6
- package/lib/builder/h5/index.js +14 -20
- package/lib/builder/h5/webpack.d.ts +1 -3
- package/lib/builder/h5/webpack.js +1 -2
- package/lib/builder/mp/BuildContext.d.ts +0 -4
- package/lib/builder/mp/index.d.ts +14 -5
- package/lib/builder/mp/index.js +28 -17
- package/lib/builder/mp/materials.js +0 -6
- package/lib/builder/mp/mixMode.d.ts +2 -3
- package/lib/builder/mp/mixMode.js +2 -5
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +2 -4
- package/lib/builder/mp/util.js +1 -1
- package/lib/builder/service/webpack.d.ts +0 -7
- package/lib/builder/service/webpack.js +21 -31
- package/lib/builder/util/generateFiles.d.ts +1 -0
- package/lib/builder/util/generateFiles.js +8 -6
- package/lib/builder/util/junk.d.ts +1 -0
- package/lib/builder/util/junk.js +7 -1
- package/lib/builder/util/net.js +4 -0
- package/lib/builder.web.js +21 -13
- package/package.json +2 -2
- package/template/html/index.html.ejs +11 -23
- package/template/mp/common/util.js +9 -5
- package/template/mp/common/widget.js +2 -2
- package/template/mp/common/wx_yypt_report_v2.js +460 -0
- package/template/mp/datasources/config.js.tpl +0 -1
- package/template/mp/package.json +6 -6
- package/template/package.json +1 -1
|
@@ -16,11 +16,3 @@ export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-sha
|
|
|
16
16
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
17
17
|
*/
|
|
18
18
|
export declare const miniprogramDir: string;
|
|
19
|
-
export interface ICDN_ENDPOINTS_COFIG {
|
|
20
|
-
common?: string;
|
|
21
|
-
cloudbase?: string;
|
|
22
|
-
cdngo?: string;
|
|
23
|
-
aegis?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare const CDN_ENDPONTS_CONFIG: ICDN_ENDPOINTS_COFIG;
|
|
26
|
-
export declare function generateCdnEndpoints(endpoints?: ICDN_ENDPOINTS_COFIG): ICDN_ENDPOINTS_COFIG;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.miniprogramDir = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const os_1 = __importDefault(require("os"));
|
|
32
32
|
var index_1 = require("@cloudbase/lowcode-generator/lib/generator/config/index");
|
|
@@ -54,18 +54,3 @@ exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqclou
|
|
|
54
54
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
55
55
|
*/
|
|
56
56
|
exports.miniprogramDir = path.join(os_1.default.homedir(), exports.sharedMaterialsDir, 'miniprogram_npm');
|
|
57
|
-
exports.CDN_ENDPONTS_CONFIG = {
|
|
58
|
-
common: '',
|
|
59
|
-
cloudbase: '//static.cloudbase.net',
|
|
60
|
-
cdngo: 'https://qbase.cdn-go.cn',
|
|
61
|
-
aegis: 'https://cdn-go.cn',
|
|
62
|
-
};
|
|
63
|
-
function generateCdnEndpoints(endpoints = exports.CDN_ENDPONTS_CONFIG) {
|
|
64
|
-
for (const key in exports.CDN_ENDPONTS_CONFIG) {
|
|
65
|
-
if (!Object.prototype.hasOwnProperty.call(endpoints, key)) {
|
|
66
|
-
endpoints[key] = endpoints.common ? endpoints.common : exports.CDN_ENDPONTS_CONFIG[key];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return endpoints;
|
|
70
|
-
}
|
|
71
|
-
exports.generateCdnEndpoints = generateCdnEndpoints;
|
|
@@ -2,8 +2,7 @@ import { IMaterialItem, IWeAppData, IPlugin, IExtraData } from '@cloudbase/lowco
|
|
|
2
2
|
import { BuildType, GenerateMpType, WebpackBuildCallBack, WebpackModeType } from '../types/common';
|
|
3
3
|
import { DEPLOY_MODE, RUNTIME } from '../../types';
|
|
4
4
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
5
|
-
|
|
6
|
-
interface IBaseAppProps {
|
|
5
|
+
export interface IBaseAppProps {
|
|
7
6
|
appKey: string;
|
|
8
7
|
dependencies?: IMaterialItem[];
|
|
9
8
|
publicPath?: string;
|
|
@@ -36,40 +35,11 @@ export interface IBuildWedaApp extends IBaseAppProps {
|
|
|
36
35
|
path?: string;
|
|
37
36
|
};
|
|
38
37
|
isBrowserMpBuilder?: boolean;
|
|
39
|
-
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
40
|
-
isPrivateMode?: boolean;
|
|
41
38
|
}
|
|
42
|
-
export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder,
|
|
39
|
+
export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
|
|
43
40
|
export declare function cleanComponentDir(): Promise<void>;
|
|
44
41
|
export declare const version: any;
|
|
45
42
|
export { getFiles, fileToZip, strToBuf } from '../util/generateFiles';
|
|
46
43
|
export { downloadZip } from '../util/net';
|
|
47
44
|
export { getCompileDirs } from '../util';
|
|
48
45
|
export default buildWedaApp;
|
|
49
|
-
interface INormalizeInput {
|
|
50
|
-
appId?: string;
|
|
51
|
-
appKey?: string;
|
|
52
|
-
dependencies?: IBuildWedaApp['dependencies'];
|
|
53
|
-
buildTypeList: IBuildWedaApp['buildTypeList'];
|
|
54
|
-
mainAppSerializeData?: IBuildWedaApp['cals'];
|
|
55
|
-
cals?: IBuildWedaApp['cals'];
|
|
56
|
-
subAppSerializeDataList?: IBuildWedaApp['subAppCalsList'];
|
|
57
|
-
subAppCalsList?: IBuildWedaApp['subAppCalsList'];
|
|
58
|
-
deployOptions: IBuildWedaApp['deployOptions'];
|
|
59
|
-
mpAppId?: string;
|
|
60
|
-
extraData?: {
|
|
61
|
-
isComposite: boolean;
|
|
62
|
-
compProps: {};
|
|
63
|
-
};
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
}
|
|
66
|
-
interface InormalizeOutput extends INormalizeInput {
|
|
67
|
-
dependencies: Required<INormalizeInput['dependencies']>;
|
|
68
|
-
}
|
|
69
|
-
export declare function normalizeInputs(inputs: INormalizeInput, { envId, getWebRootPath, }: {
|
|
70
|
-
envId: string;
|
|
71
|
-
getWebRootPath?: ({ appId, deployOptions }: {
|
|
72
|
-
appId: any;
|
|
73
|
-
deployOptions: any;
|
|
74
|
-
}) => string;
|
|
75
|
-
}): InormalizeOutput;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -20,7 +20,7 @@ const pkg = require('../../../package.json');
|
|
|
20
20
|
async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appKey = 'test', runtime = types_1.RUNTIME.NONE, ignoreInstall = false, buildTypeList = [common_1.BuildType.WEB], mode = common_1.WebpackModeType.PRODUCTION, devTool = 'webpack', deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, generateMpType = common_1.GenerateMpType.APP, plugins = [], extraData = {
|
|
21
21
|
isComposite: false,
|
|
22
22
|
compProps: {},
|
|
23
|
-
}, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false,
|
|
23
|
+
}, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, }, cb) {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
if (!cals) {
|
|
26
26
|
console.error('无效的应用配置');
|
|
@@ -28,17 +28,6 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
28
28
|
}
|
|
29
29
|
const { mode: deployMode = types_1.DEPLOY_MODE.PREVIEW } = deployOptions;
|
|
30
30
|
let appBuildDir = (output === null || output === void 0 ? void 0 : output.path) || (runtime === types_1.RUNTIME.CI ? (_a = (0, util_1.getCompileDirs)('app')) === null || _a === void 0 ? void 0 : _a.appBuildDir : (_b = (0, util_1.getCompileDirs)(appKey)) === null || _b === void 0 ? void 0 : _b.appBuildDir);
|
|
31
|
-
const buildContext = {
|
|
32
|
-
projDir: appBuildDir,
|
|
33
|
-
appId: appKey,
|
|
34
|
-
isProduction: mode === common_1.WebpackModeType.PRODUCTION,
|
|
35
|
-
materialLibs: dependencies,
|
|
36
|
-
debugMode: mode !== common_1.WebpackModeType.PRODUCTION && !!process.env.WEAPPS_DEBUG,
|
|
37
|
-
isMixMode: generateMpType === common_1.GenerateMpType.SUBPACKAGE,
|
|
38
|
-
domain,
|
|
39
|
-
isBrowserMpBuilder,
|
|
40
|
-
isPrivateMode,
|
|
41
|
-
};
|
|
42
31
|
console.log('domain', domain);
|
|
43
32
|
console.log('应用名', appKey);
|
|
44
33
|
console.log('生成模式', generateMpType);
|
|
@@ -48,40 +37,45 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
48
37
|
if (buildTypeList.includes(common_1.BuildType.MP)) {
|
|
49
38
|
const mainAppSerializeData = (0, common_2.processCals2WeappsData)(cals, dependencies);
|
|
50
39
|
const subAppSerializeDataList = (subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map((item) => (0, common_2.processCals2WeappsData)(item, dependencies))) || [];
|
|
40
|
+
appBuildDir = (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp');
|
|
41
|
+
const isMixMode = generateMpType === common_1.GenerateMpType.SUBPACKAGE;
|
|
51
42
|
const apps = [mainAppSerializeData, ...subAppSerializeDataList];
|
|
52
43
|
if (isBrowserMpBuilder) {
|
|
53
44
|
// 尽早下载物料
|
|
54
45
|
await (0, net_1.downloadBrowserMaterial)(output === null || output === void 0 ? void 0 : output.path);
|
|
55
46
|
}
|
|
56
|
-
const mpBuildContext = {
|
|
57
|
-
...buildContext,
|
|
58
|
-
projDir: (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp'),
|
|
59
|
-
mainAppData: mainAppSerializeData,
|
|
60
|
-
};
|
|
61
47
|
const result = await (0, index_1.generateWxMp)({
|
|
62
48
|
weapps: apps,
|
|
63
|
-
|
|
49
|
+
projDir: appBuildDir,
|
|
50
|
+
appId: appKey,
|
|
51
|
+
domain: domain,
|
|
52
|
+
materials: dependencies,
|
|
64
53
|
plugins,
|
|
54
|
+
isProduction: mode === common_1.WebpackModeType.PRODUCTION,
|
|
65
55
|
deployMode,
|
|
56
|
+
extraData,
|
|
57
|
+
isMixMode,
|
|
66
58
|
options: {
|
|
67
59
|
isCrossAccount: resourceAppId !== deployOptions.targetMpAppId,
|
|
68
|
-
mpAppId: deployOptions.mpAppId || '',
|
|
69
60
|
resourceAppId,
|
|
61
|
+
mpAppId: deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mpAppId,
|
|
70
62
|
},
|
|
71
63
|
buildTypeList,
|
|
64
|
+
isBrowserMpBuilder,
|
|
65
|
+
ignoreInstall,
|
|
72
66
|
});
|
|
73
67
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
74
68
|
// 针对 app.json / package.json 则采用 merge 的操作
|
|
75
|
-
if (
|
|
76
|
-
console.log(chalk_1.default.green('【混合模式】'),
|
|
69
|
+
if (isMixMode) {
|
|
70
|
+
console.log(chalk_1.default.green('【混合模式】'), appBuildDir);
|
|
77
71
|
await (0, mixMode_1.handleMixMode)({
|
|
78
|
-
buildContext: mpBuildContext,
|
|
79
72
|
apps,
|
|
73
|
+
generateMpPath: appBuildDir,
|
|
80
74
|
miniprogramRoot: result.miniprogramRoot,
|
|
81
75
|
plugins,
|
|
82
76
|
});
|
|
83
77
|
}
|
|
84
|
-
const outDir =
|
|
78
|
+
const outDir = appBuildDir;
|
|
85
79
|
let projectJsonPath = path_1.default.resolve(outDir, 'project.config.json');
|
|
86
80
|
await (0, postProcess_1.postprocessProjectConfig)(projectJsonPath, {
|
|
87
81
|
appid: deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mpAppId,
|
|
@@ -89,21 +83,23 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
89
83
|
});
|
|
90
84
|
// 如果是代开发的模式,则写入ext.json
|
|
91
85
|
await (0, postProcess_1.postprocessDeployExtraJson)(outDir, deployOptions);
|
|
92
|
-
if (!isBrowserMpBuilder && generateMpType === common_1.GenerateMpType.APP) {
|
|
86
|
+
if (!isBrowserMpBuilder && generateMpType === common_1.GenerateMpType.APP && !ignoreInstall) {
|
|
93
87
|
// 模板拷入的 miniprogram_npm 有问题,直接删除使用重新构建的版本
|
|
94
88
|
// 模板需要占位保证 mp 文件夹存在
|
|
95
89
|
fs_extra_1.default.removeSync(path_1.default.resolve(outDir, 'miniprogram_npm'));
|
|
96
90
|
}
|
|
97
|
-
|
|
91
|
+
cb === null || cb === void 0 ? void 0 : cb(null, {
|
|
98
92
|
...result,
|
|
99
93
|
outDir,
|
|
100
94
|
timeElapsed: Date.now() - startTime,
|
|
101
|
-
})
|
|
95
|
+
});
|
|
102
96
|
return outDir;
|
|
103
97
|
}
|
|
104
98
|
else {
|
|
105
99
|
const h5BuildDir = await (0, index_2.buildH5App)({
|
|
106
|
-
|
|
100
|
+
appKey,
|
|
101
|
+
buildDir: appBuildDir,
|
|
102
|
+
dependencies,
|
|
107
103
|
cals,
|
|
108
104
|
subAppCalsList,
|
|
109
105
|
extraData,
|
|
@@ -113,36 +109,18 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
113
109
|
runtime,
|
|
114
110
|
deployMode,
|
|
115
111
|
ignoreInstall,
|
|
116
|
-
|
|
112
|
+
domain,
|
|
117
113
|
});
|
|
118
|
-
|
|
114
|
+
cb === null || cb === void 0 ? void 0 : cb(null, {
|
|
119
115
|
outDir: h5BuildDir,
|
|
120
116
|
timeElapsed: Date.now() - startTime,
|
|
121
|
-
})
|
|
117
|
+
});
|
|
122
118
|
return h5BuildDir;
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
|
-
catch (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
let lineIndex = 0;
|
|
129
|
-
let reg = /node_modules\/@babel/;
|
|
130
|
-
messageList.find((str, index) => {
|
|
131
|
-
if (reg.test(str)) {
|
|
132
|
-
lineIndex = index;
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
if (lineIndex) {
|
|
140
|
-
messageList = messageList.slice(0, lineIndex);
|
|
141
|
-
}
|
|
142
|
-
err = new Error(messageList.join('\n'));
|
|
143
|
-
}
|
|
144
|
-
cb === null || cb === void 0 ? void 0 : cb(err);
|
|
145
|
-
throw err;
|
|
121
|
+
catch (e) {
|
|
122
|
+
cb === null || cb === void 0 ? void 0 : cb(e);
|
|
123
|
+
throw e;
|
|
146
124
|
}
|
|
147
125
|
}
|
|
148
126
|
exports.buildWedaApp = buildWedaApp;
|
|
@@ -160,98 +138,3 @@ Object.defineProperty(exports, "downloadZip", { enumerable: true, get: function
|
|
|
160
138
|
var util_2 = require("../util");
|
|
161
139
|
Object.defineProperty(exports, "getCompileDirs", { enumerable: true, get: function () { return util_2.getCompileDirs; } });
|
|
162
140
|
exports.default = buildWedaApp;
|
|
163
|
-
function normalizeInputs(inputs, { envId, getWebRootPath, }) {
|
|
164
|
-
const { extraData = { isComposite: false, compProps: {} } } = inputs;
|
|
165
|
-
/**
|
|
166
|
-
* 过滤处理 dependencies
|
|
167
|
-
*/
|
|
168
|
-
let map = {};
|
|
169
|
-
inputs.dependencies = (inputs.dependencies || []).reduce((list, item) => {
|
|
170
|
-
if (!map[`${item.name}@${item.version}`]) {
|
|
171
|
-
map[`${item.name}@${item.version}`] = true;
|
|
172
|
-
list.push(item);
|
|
173
|
-
}
|
|
174
|
-
return list;
|
|
175
|
-
}, []);
|
|
176
|
-
const normalizeCalsOptions = {
|
|
177
|
-
buildTypeList: inputs.buildTypeList,
|
|
178
|
-
envId,
|
|
179
|
-
deployOptions: inputs.deployOptions,
|
|
180
|
-
appId: inputs.appId || inputs.appKey,
|
|
181
|
-
getWebRootPath: getWebRootPath || _getWebRootPath,
|
|
182
|
-
};
|
|
183
|
-
if (inputs.mainAppSerializeData) {
|
|
184
|
-
inputs.mainAppSerializeData = normalizeCals(inputs.mainAppSerializeData, normalizeCalsOptions);
|
|
185
|
-
if ((0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
|
|
186
|
-
inputs.subAppSerializeDataList = [];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (inputs.cals) {
|
|
190
|
-
inputs.cals = normalizeCals(inputs.cals, normalizeCalsOptions);
|
|
191
|
-
if ((0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
|
|
192
|
-
inputs.subAppCalsList = [];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!(0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
|
|
196
|
-
// 小程序构建
|
|
197
|
-
const { mpAppId, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW } } = inputs;
|
|
198
|
-
inputs.deployOptions = {
|
|
199
|
-
...deployOptions,
|
|
200
|
-
mpAppId: deployOptions.mpAppId || mpAppId,
|
|
201
|
-
};
|
|
202
|
-
if (!inputs.deployOptions.targetMpAppId) {
|
|
203
|
-
inputs.deployOptions.targetMpAppId = inputs.deployOptions.mpAppId;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (extraData.isComposite) {
|
|
207
|
-
Object.keys(extraData.compProps.events).forEach((eName) => {
|
|
208
|
-
extraData.compProps.events[eName] = `$$EVENT_${eName}$$`;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return inputs;
|
|
212
|
-
}
|
|
213
|
-
exports.normalizeInputs = normalizeInputs;
|
|
214
|
-
function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath }) {
|
|
215
|
-
var _a, _b;
|
|
216
|
-
if (!cals.extra) {
|
|
217
|
-
cals.extra = {};
|
|
218
|
-
}
|
|
219
|
-
if (!cals.mpPkgUrl) {
|
|
220
|
-
if (buildTypeList.includes(common_1.BuildType.APP) ||
|
|
221
|
-
buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
|
|
222
|
-
buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
|
|
223
|
-
cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (!((_a = cals === null || cals === void 0 ? void 0 : cals.extra) === null || _a === void 0 ? void 0 : _a.envId)) {
|
|
227
|
-
cals.extra.envId = envId;
|
|
228
|
-
}
|
|
229
|
-
if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
|
|
230
|
-
// web 构建不处理小程序插件
|
|
231
|
-
if (cals.extra.miniprogramPlugins) {
|
|
232
|
-
cals.extra.miniprogramPlugins = [];
|
|
233
|
-
}
|
|
234
|
-
let { appConfig = {} } = cals.extra;
|
|
235
|
-
let { window = {} } = appConfig;
|
|
236
|
-
let path = getWebRootPath({ appId, deployOptions });
|
|
237
|
-
cals.extra.appConfig = {
|
|
238
|
-
...appConfig,
|
|
239
|
-
window: {
|
|
240
|
-
...window,
|
|
241
|
-
// Todo: 处理自定义域名逻辑
|
|
242
|
-
publicPath: (0, common_1.buildAsXPageByBuildType)(buildTypeList)
|
|
243
|
-
? (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.publicPath) || `https://${(_b = cals.extra) === null || _b === void 0 ? void 0 : _b.domain}${path}`
|
|
244
|
-
: path,
|
|
245
|
-
basename: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList)
|
|
246
|
-
? `app/${appId}${(deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) !== types_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
|
|
247
|
-
: (0, common_1.buildAsXPageByBuildType)(buildTypeList)
|
|
248
|
-
? '/'
|
|
249
|
-
: path,
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return cals;
|
|
254
|
-
}
|
|
255
|
-
function _getWebRootPath({ appId, deployOptions }) {
|
|
256
|
-
return (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.PREVIEW ? `/${appId}/preview/` : `/${appId}/production/`;
|
|
257
|
-
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { BuildAppProps } from '@cloudbase/lowcode-generator';
|
|
2
|
-
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
3
2
|
import { BuildType } from '../types/common';
|
|
4
3
|
/**
|
|
5
4
|
* 该函数从 @govcloud/generate 取到需要的模版文件
|
|
6
5
|
*/
|
|
7
6
|
export declare function generateProjectFiles(buildData: BuildAppProps): Promise<void>;
|
|
8
|
-
export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList,
|
|
7
|
+
export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, }: {
|
|
9
8
|
appId: string;
|
|
10
9
|
jsApis: string[];
|
|
11
10
|
appBuildDir: string;
|
|
@@ -13,7 +12,6 @@ export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool
|
|
|
13
12
|
devTool: string;
|
|
14
13
|
isBuildApp: boolean;
|
|
15
14
|
buildTypeList: BuildType[];
|
|
16
|
-
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
17
15
|
}): Promise<void>;
|
|
18
16
|
export declare function handleAssets({ appBuildDir, buildTypeList, assets, }: {
|
|
19
17
|
appBuildDir: string;
|
|
@@ -24,7 +24,7 @@ async function generateProjectFiles(buildData) {
|
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
26
|
exports.generateProjectFiles = generateProjectFiles;
|
|
27
|
-
async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList,
|
|
27
|
+
async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, }) {
|
|
28
28
|
const templatePath = path_1.default.join(config_1.appTemplateDir, 'html', 'index.html.ejs');
|
|
29
29
|
const dstFilePath = path_1.default.join(appBuildDir, 'index.html');
|
|
30
30
|
const packageTpl = await fs_extra_1.default.readFile(templatePath, { encoding: 'utf8' });
|
|
@@ -37,7 +37,6 @@ async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuild
|
|
|
37
37
|
mode,
|
|
38
38
|
isBuildApp,
|
|
39
39
|
isAdminPortal: (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList),
|
|
40
|
-
cdnEndpoints: (0, config_1.generateCdnEndpoints)(cdnEndpoints),
|
|
41
40
|
}));
|
|
42
41
|
}
|
|
43
42
|
exports.generateHTML = generateHTML;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { II18nConfig, IExtraData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
1
|
+
import { IMaterialItem, II18nConfig, IExtraData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { BuildType, WebpackModeType } from '../types/common';
|
|
3
3
|
import { DEPLOY_MODE, RUNTIME } from '../../types';
|
|
4
4
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
buildContext: Omit<IBuildContext, 'mainAppData'>;
|
|
5
|
+
export declare function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployMode, ignoreInstall, domain, }: {
|
|
6
|
+
appKey: string;
|
|
7
|
+
buildDir: string;
|
|
9
8
|
cals: IPlatformApp;
|
|
10
9
|
subAppCalsList: IPlatformApp[];
|
|
10
|
+
dependencies: IMaterialItem[];
|
|
11
11
|
i18nConfig?: II18nConfig;
|
|
12
12
|
buildTypeList: BuildType[];
|
|
13
13
|
extraData: IExtraData;
|
|
@@ -16,5 +16,5 @@ export declare function buildH5App({ buildContext, i18nConfig, extraData, cals,
|
|
|
16
16
|
runtime?: RUNTIME;
|
|
17
17
|
deployMode?: DEPLOY_MODE;
|
|
18
18
|
ignoreInstall?: boolean;
|
|
19
|
-
|
|
19
|
+
domain: string;
|
|
20
20
|
}): Promise<string>;
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -19,31 +19,31 @@ const types_1 = require("../../types");
|
|
|
19
19
|
const mp_1 = require("../mp");
|
|
20
20
|
const common_2 = require("../../utils/common");
|
|
21
21
|
const config_1 = require("../config");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _a, _b, _c;
|
|
25
|
-
const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode } = buildContext;
|
|
22
|
+
async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployMode = types_1.DEPLOY_MODE.PREVIEW, ignoreInstall = false, domain = '', }) {
|
|
23
|
+
var _a, _b;
|
|
26
24
|
try {
|
|
27
25
|
const { materialsDir } = runtime === types_1.RUNTIME.CI ? (0, util_1.getCompileDirs)(appKey) : (0, util_1.getCompileDirs)('app');
|
|
28
26
|
const h5BuildDir = path_1.default.join(buildDir, 'h5');
|
|
29
|
-
if (buildTypeList.includes(common_1.BuildType.APP) ||
|
|
30
|
-
buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
|
|
31
|
-
buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
|
|
32
|
-
if (!cals.extra) {
|
|
33
|
-
cals.extra = {};
|
|
34
|
-
}
|
|
35
|
-
cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
|
|
36
|
-
}
|
|
37
27
|
const mainAppSerializeData = (0, common_2.processCals2WeappsData)(cals, dependencies);
|
|
38
28
|
const subAppSerializeDataList = (subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map((item) => (0, common_2.processCals2WeappsData)(item, dependencies))) || [];
|
|
29
|
+
const buildContext = {
|
|
30
|
+
projDir: buildDir,
|
|
31
|
+
appId: appKey,
|
|
32
|
+
isProduction: mode === common_1.WebpackModeType.PRODUCTION,
|
|
33
|
+
materialLibs: dependencies,
|
|
34
|
+
isMixMode: false,
|
|
35
|
+
mainAppData: mainAppSerializeData,
|
|
36
|
+
domain,
|
|
37
|
+
};
|
|
39
38
|
const { allAppUsedComps } = (0, mp_1.handleUsedComponents)({
|
|
40
|
-
buildContext
|
|
39
|
+
buildContext,
|
|
41
40
|
weapps: [mainAppSerializeData, ...subAppSerializeDataList],
|
|
41
|
+
materials: dependencies,
|
|
42
42
|
});
|
|
43
43
|
// 处理应用数据
|
|
44
44
|
const mainAppData = (0, weapps_core_1.deserialize)(mainAppSerializeData);
|
|
45
45
|
if (!mainAppData.extra) {
|
|
46
|
-
mainAppData.extra = { domain };
|
|
46
|
+
mainAppData.extra = { domain: domain };
|
|
47
47
|
}
|
|
48
48
|
if (!((_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.domain)) {
|
|
49
49
|
mainAppData.extra.domain = domain;
|
|
@@ -88,7 +88,6 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
88
88
|
runtime,
|
|
89
89
|
deployMode,
|
|
90
90
|
_indexPage,
|
|
91
|
-
isPrivateMode,
|
|
92
91
|
});
|
|
93
92
|
console.timeEnd(runGenerateTag);
|
|
94
93
|
// // 构建 NPM 包
|
|
@@ -117,7 +116,6 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
117
116
|
devTool,
|
|
118
117
|
publicPath,
|
|
119
118
|
domain,
|
|
120
|
-
cdnEndpoints,
|
|
121
119
|
});
|
|
122
120
|
await new Promise((resolve, reject) => {
|
|
123
121
|
// 开始编译前清理一下 lowcode 内容
|
|
@@ -135,10 +133,6 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
|
|
|
135
133
|
}
|
|
136
134
|
});
|
|
137
135
|
});
|
|
138
|
-
// 普通 web 模式,且非hash模式,根据页面生成多份入口
|
|
139
|
-
if (!((_c = cals.extra) === null || _c === void 0 ? void 0 : _c.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
|
|
140
|
-
await Promise.all((cals.items || []).map((page) => fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, page.id, 'index.html'))));
|
|
141
|
-
}
|
|
142
136
|
return h5BuildDir;
|
|
143
137
|
}
|
|
144
138
|
catch (e) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { BuildAppProps } from '../core/index';
|
|
3
|
-
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
4
3
|
interface IWebpackCoreProps extends BuildAppProps {
|
|
5
4
|
appBuildDir: string;
|
|
6
5
|
mpConfig: any;
|
|
7
6
|
mainAppData: IWebRuntimeAppData;
|
|
8
7
|
subAppDataList: IWebRuntimeAppData[];
|
|
9
8
|
assets: string[];
|
|
10
|
-
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
11
9
|
}
|
|
12
|
-
export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType,
|
|
10
|
+
export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
|
|
13
11
|
export {};
|
|
@@ -4,7 +4,7 @@ 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
|
-
async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], mpConfig, assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP,
|
|
7
|
+
async function runWebpackCore({ 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
8
|
console.time('runWebpackCore');
|
|
9
9
|
console.time('webpackGenerate');
|
|
10
10
|
const allAppDataList = subAppDataList.concat(mainAppData);
|
|
@@ -33,7 +33,6 @@ async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, public
|
|
|
33
33
|
devTool,
|
|
34
34
|
isBuildApp: buildTypeList.includes(common_1.BuildType.APP),
|
|
35
35
|
buildTypeList,
|
|
36
|
-
cdnEndpoints,
|
|
37
36
|
});
|
|
38
37
|
if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
|
|
39
38
|
if (mode !== common_1.WebpackModeType.PRODUCTION) {
|
|
@@ -3,9 +3,6 @@ import { IMaterialItem, IWeAppData, IMiniprogramPlugin } from '@cloudbase/lowcod
|
|
|
3
3
|
* All build parameters and intermediate data to be share across processes
|
|
4
4
|
*/
|
|
5
5
|
export interface IBuildContext {
|
|
6
|
-
/**
|
|
7
|
-
* 应用id
|
|
8
|
-
*/
|
|
9
6
|
appId: string;
|
|
10
7
|
domain: string;
|
|
11
8
|
projDir: string;
|
|
@@ -17,5 +14,4 @@ export interface IBuildContext {
|
|
|
17
14
|
miniprogramPlugins?: IMiniprogramPlugin[];
|
|
18
15
|
debugMode?: boolean;
|
|
19
16
|
isBrowserMpBuilder?: boolean;
|
|
20
|
-
isPrivateMode?: boolean;
|
|
21
17
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import { IWeAppData, IPlugin } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
1
|
+
import { IMaterialItem, IWeAppData, IPlugin } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { IBuildContext } from './BuildContext';
|
|
3
3
|
import { DEPLOY_MODE } from '../../types';
|
|
4
4
|
import { BuildType, IAppUsedComp, IUsedComps } from '../types/common';
|
|
5
|
-
export declare function generateWxMp({
|
|
6
|
-
buildContext: IBuildContext;
|
|
5
|
+
export declare function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder, ignoreInstall, }: {
|
|
7
6
|
weapps: IWeAppData[];
|
|
7
|
+
projDir: string;
|
|
8
|
+
appId: string;
|
|
9
|
+
domain: string;
|
|
10
|
+
materials: IMaterialItem[];
|
|
8
11
|
plugins: IPlugin[];
|
|
12
|
+
isProduction: boolean;
|
|
9
13
|
deployMode: DEPLOY_MODE;
|
|
14
|
+
extraData: any;
|
|
15
|
+
isMixMode: boolean;
|
|
10
16
|
options: {
|
|
11
|
-
mpAppId: string;
|
|
12
17
|
resourceAppId?: string;
|
|
18
|
+
mpAppId?: string;
|
|
13
19
|
isCrossAccount: boolean;
|
|
14
20
|
};
|
|
15
21
|
buildTypeList: BuildType[];
|
|
22
|
+
isBrowserMpBuilder: boolean;
|
|
23
|
+
ignoreInstall: boolean;
|
|
16
24
|
}): Promise<{
|
|
17
25
|
miniprogramRoot: string;
|
|
18
26
|
}>;
|
|
@@ -21,9 +29,10 @@ export declare function writeLowCodeFiles(appData: IWeAppData, outDir: string, c
|
|
|
21
29
|
* TODO: 与 cals 里的实现进行整合
|
|
22
30
|
* 关键点在于 appUsedComps 分组, 与 generic componen 的实现
|
|
23
31
|
*/
|
|
24
|
-
export declare function handleUsedComponents({ buildContext, weapps }: {
|
|
32
|
+
export declare function handleUsedComponents({ buildContext, weapps, materials, }: {
|
|
25
33
|
buildContext: IBuildContext;
|
|
26
34
|
weapps: IWeAppData[];
|
|
35
|
+
materials: IMaterialItem[];
|
|
27
36
|
}): {
|
|
28
37
|
appUsedComps: IAppUsedComp[];
|
|
29
38
|
allAppUsedComps: IUsedComps;
|