@cloudbase/lowcode-builder 1.3.15-private.0 → 1.3.15
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.js +1 -1
- package/lib/builder/core/index.d.ts +0 -7
- package/lib/builder/core/index.js +1 -40
- package/lib/builder/h5/generate.js +2 -3
- package/lib/builder/mp/index.d.ts +0 -5
- package/lib/builder/mp/index.js +17 -28
- package/lib/builder/mp/materials.js +12 -10
- package/lib/builder/mp/util.js +2 -1
- package/lib/builder/util/generateFiles.d.ts +2 -1
- package/lib/builder/util/generateFiles.js +13 -1
- package/package.json +3 -3
- package/template/html/index.html.ejs +2 -2
- package/template/mp/app/weapps-api.js +2 -6
- package/template/mp/app.wxss +1 -1
- package/template/mp/common/util.js +2 -3
- package/template/mp/common/utils.wxs +1 -3
- package/template/mp/common/widget.js +4 -0
- package/template/mp/component/index.js +1 -0
- package/template/mp/datasources/config.js.tpl +3 -4
- package/template/mp/package.json +1 -1
- package/template/mp/page/index.js +1 -0
- package/dist/builder.web.js +0 -71
- package/lib/.turbo/turbo-build.log +0 -0
- package/lib/.turbo/turbo-develop.log +0 -0
- package/lib/builder.web.js +0 -71
- package/lib/test.d.ts +0 -11
- package/lib/test.js +0 -717
- package/template/mp/common/config.js +0 -9
- package/template/mp/common/config.wxs +0 -3
|
@@ -59,7 +59,7 @@ exports.CDN_ENDPONTS_CONFIG = {
|
|
|
59
59
|
common: '',
|
|
60
60
|
cloudbase: '//static.cloudbase.net',
|
|
61
61
|
cdngo: 'https://qbase.cdn-go.cn',
|
|
62
|
-
aegis: 'https://
|
|
62
|
+
aegis: 'https://cdn-go.cn',
|
|
63
63
|
};
|
|
64
64
|
function generateCdnEndpoints(endpoints = exports.CDN_ENDPONTS_CONFIG) {
|
|
65
65
|
for (const key in exports.CDN_ENDPONTS_CONFIG) {
|
|
@@ -40,13 +40,6 @@ export interface IBuildWedaApp extends IBaseAppProps {
|
|
|
40
40
|
isPrivateMode?: boolean;
|
|
41
41
|
endpointType?: 'tcb-api' | 'wechat-service';
|
|
42
42
|
}
|
|
43
|
-
export declare function buildWedaConfig({ output, domain, isPrivateMode, endpointType, buildTypeList, }: {
|
|
44
|
-
output: Required<IBuildWedaApp['output']>;
|
|
45
|
-
domain?: string;
|
|
46
|
-
isPrivateMode?: boolean;
|
|
47
|
-
endpointType?: IBuildWedaApp['endpointType'];
|
|
48
|
-
buildTypeList?: IBuildWedaApp['buildTypeList'];
|
|
49
|
-
}): Promise<void>;
|
|
50
43
|
export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints, isPrivateMode, endpointType, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
|
|
51
44
|
export declare function cleanComponentDir(): Promise<void>;
|
|
52
45
|
export declare const version: any;
|
|
@@ -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.normalizeInputs = exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp =
|
|
6
|
+
exports.normalizeInputs = 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"));
|
|
@@ -18,45 +18,6 @@ const postProcess_1 = require("../../utils/postProcess");
|
|
|
18
18
|
const cals_1 = require("@cloudbase/cals");
|
|
19
19
|
const net_1 = require("../util/net");
|
|
20
20
|
const pkg = require('../../../package.json');
|
|
21
|
-
async function buildWedaConfig({ output, domain = undefined, isPrivateMode = undefined, endpointType = undefined, buildTypeList = [common_1.BuildType.WEB], }) {
|
|
22
|
-
if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
|
|
23
|
-
throw new Error('构建类型仅支持 MP');
|
|
24
|
-
}
|
|
25
|
-
let outDir = output === null || output === void 0 ? void 0 : output.path;
|
|
26
|
-
if (!outDir) {
|
|
27
|
-
throw new Error('无效的项目输出路径');
|
|
28
|
-
}
|
|
29
|
-
let miniprogramRoot = outDir;
|
|
30
|
-
let projectJsonPath = path_1.default.resolve(outDir, 'project.config.json');
|
|
31
|
-
if (fs_extra_1.default.existsSync(projectJsonPath)) {
|
|
32
|
-
const projectConfigJson = await fs_extra_1.default.readJson(projectJsonPath);
|
|
33
|
-
miniprogramRoot = path_1.default.join(outDir, projectConfigJson.miniprogramRoot || '/');
|
|
34
|
-
}
|
|
35
|
-
const configPath = path_1.default.resolve(miniprogramRoot, 'common/config.js');
|
|
36
|
-
let data = { domain, isPrivateMode, endpointType };
|
|
37
|
-
if (fs_extra_1.default.existsSync(configPath)) {
|
|
38
|
-
try {
|
|
39
|
-
let config = require(configPath);
|
|
40
|
-
let current = {};
|
|
41
|
-
if (config.__esModule) {
|
|
42
|
-
current = config.default || {};
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
current = config || {};
|
|
46
|
-
}
|
|
47
|
-
for (const key in data) {
|
|
48
|
-
if (data[key] === undefined) {
|
|
49
|
-
data[key] = current[key];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
console.error('parse current file error, overwrite current config', e);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
await (0, index_1.generateConfig)(data, outDir);
|
|
58
|
-
}
|
|
59
|
-
exports.buildWedaConfig = buildWedaConfig;
|
|
60
21
|
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 = {
|
|
61
22
|
isComposite: false,
|
|
62
23
|
compProps: {},
|
|
@@ -74,15 +74,14 @@ async function handleAssets({ appBuildDir, buildTypeList, assets, }) {
|
|
|
74
74
|
if (assetsArr && assetsArr.length > 0) {
|
|
75
75
|
if (buildTypeList.includes('app')) {
|
|
76
76
|
const targetDir = path_1.default.resolve(appBuildDir, './assets');
|
|
77
|
-
|
|
77
|
+
assetsArr.forEach(async (assetUrl) => {
|
|
78
78
|
console.log('============>>>>>> getWebpackWebBuildParams assetUrl', assetUrl);
|
|
79
79
|
if (assetUrl) {
|
|
80
80
|
const fileName = (0, common_1.getFileNameByUrl)(assetUrl);
|
|
81
81
|
jsApis.push(`./${fileName}`);
|
|
82
82
|
await (0, webpack_1.downloadAssets)(targetDir, assetUrl);
|
|
83
|
-
return `./${fileName}`;
|
|
84
83
|
}
|
|
85
|
-
})
|
|
84
|
+
});
|
|
86
85
|
}
|
|
87
86
|
else {
|
|
88
87
|
jsApis = jsApis.concat(assetsArr);
|
|
@@ -17,11 +17,6 @@ export declare function generateWxMp({ buildContext, weapps, plugins, deployMode
|
|
|
17
17
|
}): Promise<{
|
|
18
18
|
miniprogramRoot: string;
|
|
19
19
|
}>;
|
|
20
|
-
export declare function generateConfig(data: {
|
|
21
|
-
domain?: string;
|
|
22
|
-
isPrivateMode?: boolean;
|
|
23
|
-
endpointType?: IBuildContext['endpointType'] | '';
|
|
24
|
-
}, root: string): Promise<void>;
|
|
25
20
|
export declare function writeLowCodeFiles(ctx: IBuildContext, appData: IWeAppData, outDir: string): Promise<void>;
|
|
26
21
|
/**
|
|
27
22
|
* TODO: 与 cals 里的实现进行整合
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -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.handleUsedComponents = exports.writeLowCodeFiles = exports.
|
|
29
|
+
exports.handleUsedComponents = exports.writeLowCodeFiles = exports.generateWxMp = void 0;
|
|
30
30
|
const chalk_1 = __importDefault(require("chalk"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const util_1 = require("util");
|
|
@@ -76,7 +76,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
76
76
|
'project.config.json': { content: projConfig },
|
|
77
77
|
};
|
|
78
78
|
console.log(`Generating ${em('project')} files`);
|
|
79
|
-
await (0, generateFiles_1.default)(projectFileData, templateDir, projDir);
|
|
79
|
+
await (0, generateFiles_1.default)(buildContext, projectFileData, templateDir, projDir);
|
|
80
80
|
}
|
|
81
81
|
// #2 生成主包
|
|
82
82
|
await generatePkg({ ...buildContext, rootPath: mainAppData.rootPath }, mainAppData, path_1.default.join(projDir, '/'), pageConfigs[0]);
|
|
@@ -94,15 +94,12 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
94
94
|
let appJsContent = await fs.readFile(appJsPath);
|
|
95
95
|
await (0, generateFiles_1.writeFile)(appJsPath, `import { app as wedaApp } from './app/weapps-api'\n${appJsContent}`);
|
|
96
96
|
}
|
|
97
|
-
await generateConfig({
|
|
98
|
-
domain,
|
|
99
|
-
isPrivateMode,
|
|
100
|
-
endpointType,
|
|
101
|
-
}, miniprogramRoot);
|
|
102
97
|
appFileData = {
|
|
103
98
|
...appFileData,
|
|
104
99
|
'common/style.js': {},
|
|
105
|
-
'common/utils.wxs': {
|
|
100
|
+
'common/utils.wxs': {
|
|
101
|
+
domain,
|
|
102
|
+
},
|
|
106
103
|
'common/util.js': {
|
|
107
104
|
isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
|
|
108
105
|
},
|
|
@@ -167,7 +164,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
167
164
|
};
|
|
168
165
|
}
|
|
169
166
|
console.log(`Generating ${em('miniprogramRoot')} files`);
|
|
170
|
-
await (0, generateFiles_1.default)(appFileData, templateDir, miniprogramRoot);
|
|
167
|
+
await (0, generateFiles_1.default)(buildContext, appFileData, templateDir, miniprogramRoot);
|
|
171
168
|
// 若项目目录与小程序根目录不同,则拷贝素材到小程序根目录
|
|
172
169
|
if (miniprogramRoot !== path_1.default.join(projDir, '/') && fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
|
|
173
170
|
console.log(`Move ${em(config_1.materialsDirName)} from` + `${projDir} to ${miniprogramRoot}`);
|
|
@@ -183,6 +180,9 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
183
180
|
resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
|
|
184
181
|
isProd: deployMode === types_1.DEPLOY_MODE.UPLOAD,
|
|
185
182
|
clientID: (_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.clientId,
|
|
183
|
+
isPrivateMode,
|
|
184
|
+
endpointType,
|
|
185
|
+
tcbApiOrigin: endpointType === 'tcb-api' && isPrivateMode && domain ? `https://${domain}` : '',
|
|
186
186
|
},
|
|
187
187
|
'datasources/datasource-profiles.js.tpl': {
|
|
188
188
|
datasourceProfiles: (0, util_3.JsonToStringWithVariableName)((0, lowcode_generator_1.getDatasourceProfiles)(
|
|
@@ -196,7 +196,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
196
196
|
},
|
|
197
197
|
};
|
|
198
198
|
console.log(`Generating ${em('datasources')} files`);
|
|
199
|
-
await (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot);
|
|
199
|
+
await (0, generateFiles_1.default)(buildContext, datasourceFileData, templateDir, miniprogramRoot);
|
|
200
200
|
}
|
|
201
201
|
// 生成子包
|
|
202
202
|
await Promise.all(weapps.map(async (app, index) => {
|
|
@@ -214,7 +214,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
214
214
|
// 生成package.json
|
|
215
215
|
let packageJsonPath = path_1.default.join(subpackageRootPath, 'package.json');
|
|
216
216
|
if (!fs.existsSync(packageJsonPath)) {
|
|
217
|
-
await (0, generateFiles_1.default)({
|
|
217
|
+
await (0, generateFiles_1.default)(buildContext, {
|
|
218
218
|
'package.json': {
|
|
219
219
|
appId,
|
|
220
220
|
importJSSDK: endpointType === 'tcb-api',
|
|
@@ -283,20 +283,6 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
exports.generateWxMp = generateWxMp;
|
|
286
|
-
async function generateConfig(data, root) {
|
|
287
|
-
const { domain = '', isPrivateMode = false, endpointType = '' } = data;
|
|
288
|
-
await (0, generateFiles_1.default)({
|
|
289
|
-
'common/config.js': {
|
|
290
|
-
domain,
|
|
291
|
-
isPrivateMode,
|
|
292
|
-
endpointType,
|
|
293
|
-
},
|
|
294
|
-
'common/config.wxs': {
|
|
295
|
-
domain,
|
|
296
|
-
},
|
|
297
|
-
}, templateDir, root);
|
|
298
|
-
}
|
|
299
|
-
exports.generateConfig = generateConfig;
|
|
300
286
|
async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
301
287
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
302
288
|
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
@@ -362,7 +348,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
362
348
|
},
|
|
363
349
|
};
|
|
364
350
|
// Generating file by template and data
|
|
365
|
-
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
|
|
351
|
+
await (0, generateFiles_1.default)(ctx, pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
|
|
366
352
|
}));
|
|
367
353
|
// #3 writing lowcode files
|
|
368
354
|
await writeLowCodeFiles(ctx, weapp, appRoot);
|
|
@@ -380,6 +366,7 @@ async function generateFramework(ctx, appData, outDir) {
|
|
|
380
366
|
subLevelPath: '',
|
|
381
367
|
subPackageName: '',
|
|
382
368
|
importor: (0, util_3.generateLowcodeImportor)([]),
|
|
369
|
+
domain: ctx.domain || '',
|
|
383
370
|
appConfig: JSON.stringify({}),
|
|
384
371
|
},
|
|
385
372
|
};
|
|
@@ -405,12 +392,14 @@ async function generateFramework(ctx, appData, outDir) {
|
|
|
405
392
|
'app/app-global.js': {},
|
|
406
393
|
'app/weapps-api.js': {
|
|
407
394
|
appId: ctx.appId,
|
|
395
|
+
domain: ctx.domain || '',
|
|
408
396
|
subLevelPath: appData.rootPath ? `${path_1.default.posix.relative(`${appData.rootPath}`, '')}/` : '',
|
|
409
397
|
subPackageName: appData.rootPath || '',
|
|
410
398
|
importor,
|
|
411
399
|
appConfig: (0, util_3.JsonToStringWithVariableName)({
|
|
412
400
|
id: ctx.appId,
|
|
413
401
|
envId: appData.envId,
|
|
402
|
+
staticResourceDomain: ctx.domain || '',
|
|
414
403
|
envVersion: (ctx === null || ctx === void 0 ? void 0 : ctx.isProduction) ? 'production' : 'preview',
|
|
415
404
|
pages: appData.pageInstanceList
|
|
416
405
|
.sort((item) => (item.isHome ? -1 : 1))
|
|
@@ -422,7 +411,7 @@ async function generateFramework(ctx, appData, outDir) {
|
|
|
422
411
|
},
|
|
423
412
|
'app/common.js': {
|
|
424
413
|
mods: appData.lowCodes
|
|
425
|
-
.filter((m) => m.type === cals_1.ECodeType.NORMAL_MODULE && m.name !==
|
|
414
|
+
.filter((m) => m.type === cals_1.ECodeType.NORMAL_MODULE && m.name !== '____index____')
|
|
426
415
|
.map((m) => m.name)
|
|
427
416
|
.sort(),
|
|
428
417
|
},
|
|
@@ -430,7 +419,7 @@ async function generateFramework(ctx, appData, outDir) {
|
|
|
430
419
|
}
|
|
431
420
|
}
|
|
432
421
|
console.log('Generate app framework');
|
|
433
|
-
await (0, generateFiles_1.default)(fileData, templateDir, outDir);
|
|
422
|
+
await (0, generateFiles_1.default)(ctx, fileData, templateDir, outDir);
|
|
434
423
|
}
|
|
435
424
|
async function writeLowCodeFiles(ctx, appData, outDir) {
|
|
436
425
|
console.log(`Writing ${em('lowcode')} files:`);
|
|
@@ -146,9 +146,7 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
|
|
|
146
146
|
comp.materialName = lib.name;
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
|
-
|
|
150
|
-
const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
|
|
151
|
-
compositedLibs.map((lib) => {
|
|
149
|
+
materialLibs.map((lib) => {
|
|
152
150
|
lib.dependencies = lib.dependencies || {};
|
|
153
151
|
lib.components.map((cmp) => {
|
|
154
152
|
cmp.meta.syncProps = {};
|
|
@@ -159,14 +157,18 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
|
|
|
159
157
|
cmp.meta.syncProps[prop] = syncProp || inputProp;
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
if (lib.isComposite) {
|
|
161
|
+
cmp.meta.platforms = {
|
|
162
|
+
mp: {
|
|
163
|
+
path: `${cmp.name}/index`,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
lib.dependencies = { ...lib.dependencies, ...cmp.npmDependencies };
|
|
167
|
+
}
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
// Collection infomation from components to lib meta
|
|
171
|
+
const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
|
|
170
172
|
// #2 Generate composited libs
|
|
171
173
|
await Promise.all(compositedLibs.map(async (lib) => {
|
|
172
174
|
console.log(`Generate composited library ${lib.name}`);
|
|
@@ -311,7 +313,7 @@ async function generateCompositeComponent(ctx, compositedComp, compLibCommonReso
|
|
|
311
313
|
},
|
|
312
314
|
};
|
|
313
315
|
// Generating file by template and data
|
|
314
|
-
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/component`, outDir);
|
|
316
|
+
await (0, generateFiles_1.default)(compositeCtx, pageFileData, `${templateDir}/component`, outDir);
|
|
315
317
|
// #3 writing lowcode files
|
|
316
318
|
/**
|
|
317
319
|
* 低码没有开放 index 类别,直接去掉
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -220,7 +220,7 @@ function getListenersHandlers(listeners, id, componentApi) {
|
|
|
220
220
|
return {};
|
|
221
221
|
const eventHandlers = {};
|
|
222
222
|
listeners.forEach((l) => {
|
|
223
|
-
var _a, _b, _c;
|
|
223
|
+
var _a, _b, _c, _d, _e;
|
|
224
224
|
const handlerName = (0, wxml_1.getMpEventHanlderName)(id, l.trigger, l);
|
|
225
225
|
eventHandlers[handlerName] = eventHandlers[handlerName] || [];
|
|
226
226
|
const params = generatedDynamicData(l.data);
|
|
@@ -243,6 +243,7 @@ function getListenersHandlers(listeners, id, componentApi) {
|
|
|
243
243
|
key: l.key || '',
|
|
244
244
|
handler,
|
|
245
245
|
handlerModule: (_c = l.handler) === null || _c === void 0 ? void 0 : _c.moduleName,
|
|
246
|
+
sourceKey: `${((_d = l.handler) === null || _d === void 0 ? void 0 : _d.moduleName) || ''}:${((_e = l.handler) === null || _e === void 0 ? void 0 : _e.name) || ''}`,
|
|
246
247
|
data: params.staticProps,
|
|
247
248
|
boundData: params.boundProps,
|
|
248
249
|
type: l.type,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { IBuildContext } from '../mp/BuildContext';
|
|
2
3
|
import { OutputType } from 'jszip';
|
|
3
4
|
export declare const generatedFileContents: {};
|
|
4
|
-
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
|
|
5
|
+
export default function generateFiles(ctx: IBuildContext, appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
|
|
5
6
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
6
7
|
export declare function removeFile(file: string): void;
|
|
7
8
|
/**
|
|
@@ -35,7 +35,7 @@ const glob_1 = __importDefault(require("glob"));
|
|
|
35
35
|
const jszip_1 = __importDefault(require("jszip"));
|
|
36
36
|
const buffer_1 = require("buffer");
|
|
37
37
|
exports.generatedFileContents = {}; // generated files for incrmental build
|
|
38
|
-
async function generateFiles(appFileData, srcDir, dstDir) {
|
|
38
|
+
async function generateFiles(ctx, appFileData, srcDir, dstDir) {
|
|
39
39
|
const filesGenerated = [];
|
|
40
40
|
// Generating file by template and data
|
|
41
41
|
for (const file in appFileData) {
|
|
@@ -46,6 +46,18 @@ async function generateFiles(appFileData, srcDir, dstDir) {
|
|
|
46
46
|
encoding: 'utf8',
|
|
47
47
|
});
|
|
48
48
|
let generatedCode = (0, lodash_1.template)(tplStr, { interpolate: /<%=([\s\S]+?)%>/ })(appFileData[file]);
|
|
49
|
+
// 混合模式下,引用公共路径要多增加一层,并加多一层命名
|
|
50
|
+
// 混合子包直接在对应目录上生成,而不采用替换的方式 @royhyang
|
|
51
|
+
// if (ctx?.isMixMode && ctx?.rootPath) {
|
|
52
|
+
// generatedCode = generatedCode.replace(
|
|
53
|
+
// /..\/..\/..\/common\//g,
|
|
54
|
+
// '../../../../common/'
|
|
55
|
+
// )
|
|
56
|
+
// generatedCode = generatedCode.replace(
|
|
57
|
+
// /..\/..\/..\/app\//g,
|
|
58
|
+
// '../../../../app/'
|
|
59
|
+
// )
|
|
60
|
+
// }
|
|
49
61
|
const outFile = path_1.default.resolve(dstDir, outFileName.replace(/\.tpl$/, ''));
|
|
50
62
|
if (await writeFile(outFile, generatedCode)) {
|
|
51
63
|
filesGenerated.push(outFileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.3.15
|
|
3
|
+
"version": "1.3.15",
|
|
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.3.
|
|
41
|
+
"@cloudbase/cals": "^0.5.12",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.3.6",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<% cssStyles.forEach(function(styleUrl){%>
|
|
20
20
|
<link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
|
|
21
21
|
<% })%> <% if(cdnEndpoints.aegis){ %>
|
|
22
|
-
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
|
|
22
|
+
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
|
|
23
23
|
<script>
|
|
24
24
|
<% if(!isAdminPortal){ %>
|
|
25
25
|
const _aegis = new Aegis({
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
crossorigin
|
|
476
476
|
src="<%=
|
|
477
477
|
cdnEndpoints.cdngo
|
|
478
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
478
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.2b07a569d23a6eba7136.bundle.js"
|
|
479
479
|
></script>
|
|
480
480
|
</body>
|
|
481
481
|
</html>
|
|
@@ -4,7 +4,6 @@ import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../c
|
|
|
4
4
|
import appGlobal from '<%= subLevelPath %>../app/app-global'
|
|
5
5
|
import { createDataset } from '<%= subLevelPath %>../datasources/index'
|
|
6
6
|
import lodashGet from 'lodash.get';
|
|
7
|
-
import config from '<%= subLevelPath %>../common/config';
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
<%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
|
|
@@ -26,14 +25,11 @@ export const $w = new Proxy(
|
|
|
26
25
|
|
|
27
26
|
function createGlboalApi() {
|
|
28
27
|
const mpApp = createMpApp({
|
|
29
|
-
appConfig:
|
|
30
|
-
staticResourceDomain: config.domain,
|
|
31
|
-
...(<%= appConfig %>)
|
|
32
|
-
}
|
|
28
|
+
appConfig: <%= appConfig %>
|
|
33
29
|
});
|
|
34
30
|
const globalAPI = Object.assign(mpApp, {
|
|
35
31
|
id: '<%= appId %>',
|
|
36
|
-
domain:
|
|
32
|
+
domain: '<%= domain %>',
|
|
37
33
|
pages: {},
|
|
38
34
|
session: {
|
|
39
35
|
//configure: sdk.configure,
|
package/template/mp/app.wxss
CHANGED
|
@@ -70,7 +70,6 @@ export function createEventHandlers(
|
|
|
70
70
|
const { lists = [], forItems = {} } = forContext;
|
|
71
71
|
const dataContext = untracked(() => generateDataContext(currentTarget));
|
|
72
72
|
const $w = untracked(() => generateWidgetAPIContext(owner?.__internal__?.$w, currentTarget, forContext));
|
|
73
|
-
|
|
74
73
|
listeners.forEach(async (l) => {
|
|
75
74
|
let { data = {}, boundData = {} } = l;
|
|
76
75
|
data = { ...data };
|
|
@@ -79,11 +78,11 @@ export function createEventHandlers(
|
|
|
79
78
|
set(data, k, boundData[k].call(owner, owner, lists, forItems, event, dataContext, $w));
|
|
80
79
|
}
|
|
81
80
|
let res = await l.handler.call(owner, { event, data });
|
|
82
|
-
let eventName = prefix && l.key ? `${prefix}$${l.key}_success` : '';
|
|
81
|
+
let eventName = prefix && l.key ? `${prefix}$${l.key}${(l.sourceKey !== 'platform:utils.If') ? '_success' : (res ? '_success' : '_fail')}` : '';
|
|
83
82
|
self[eventName] &&
|
|
84
83
|
self[eventName]({
|
|
85
84
|
...event,
|
|
86
|
-
detail: res,
|
|
85
|
+
detail: l.sourceKey === 'platform:utils.If' ? event.detail : res,
|
|
87
86
|
});
|
|
88
87
|
} catch (e) {
|
|
89
88
|
let eventName = l.key ? `${prefix}$${l.key}_fail` : '';
|
|
@@ -18,6 +18,7 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
|
|
|
18
18
|
<%= handlerName%>: [
|
|
19
19
|
<%listeners.map(l=> { %>{
|
|
20
20
|
key: '<%= l.key %>',
|
|
21
|
+
sourceKey: '<%= l.sourceKey %>',
|
|
21
22
|
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
|
|
22
23
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
23
24
|
boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($comp, lists, forItems, event, $context, $w) => {<%= bindMeta.imports %> return (
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import datasetProfiles from './dataset-profiles'
|
|
2
2
|
const dataSourceProfiles = require('./datasource-profiles.js')
|
|
3
|
-
import config from '../common/config'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* 数据源基本配置
|
|
@@ -26,14 +25,14 @@ export default {
|
|
|
26
25
|
/**
|
|
27
26
|
* 确定调用链路
|
|
28
27
|
*/
|
|
29
|
-
endpointType:
|
|
28
|
+
endpointType: '<%= endpointType %>',
|
|
30
29
|
/**
|
|
31
30
|
* 调用链路为 tcb-api 时有效
|
|
32
31
|
* 私有化需要设置
|
|
33
32
|
*/
|
|
34
|
-
tcbApiOrigin:
|
|
33
|
+
tcbApiOrigin: '<%= tcbApiOrigin %>',
|
|
35
34
|
/**
|
|
36
35
|
* 是否是处于私有化版本
|
|
37
36
|
*/
|
|
38
|
-
isPrivate:
|
|
37
|
+
isPrivate: <%= isPrivateMode %>
|
|
39
38
|
}
|
package/template/mp/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {<% if(importJSSDK) {%>
|
|
6
6
|
"@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
|
|
7
7
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
8
|
-
"@cloudbase/weda-client": "0.2.
|
|
8
|
+
"@cloudbase/weda-client": "0.2.47",
|
|
9
9
|
"@cloudbase/weda-cloud-sdk": "1.0.26",
|
|
10
10
|
"mobx": "^5.15.4",
|
|
11
11
|
"lodash.get": "^4.4.2",
|
|
@@ -14,6 +14,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
|
|
|
14
14
|
<%= handlerName%>: [
|
|
15
15
|
<%listeners.map(l=> { %>{
|
|
16
16
|
key: '<%= l.key %>',
|
|
17
|
+
sourceKey: '<%= l.sourceKey %>',
|
|
17
18
|
handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
|
|
18
19
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
19
20
|
boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($page, lists, forItems, event, $context, $w) => {<%= bindMeta.imports %> return (
|