@cloudbase/lowcode-builder 1.0.16 → 1.0.17
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/mp/index.js
CHANGED
|
@@ -44,14 +44,13 @@ const mp_config_1 = require("./mp_config");
|
|
|
44
44
|
const plugin_1 = require("./plugin");
|
|
45
45
|
const plugin_2 = require("../core/plugin");
|
|
46
46
|
const util_3 = require("../util");
|
|
47
|
+
const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style");
|
|
47
48
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
48
49
|
const types_1 = require("../../types");
|
|
49
50
|
const common_1 = require("../types/common");
|
|
50
51
|
const lodash_1 = require("lodash");
|
|
51
52
|
const junk = __importStar(require("../util/junk"));
|
|
52
53
|
const net_1 = require("../util/net");
|
|
53
|
-
const cals_1 = require("@cloudbase/cals");
|
|
54
|
-
const common_2 = require("@cloudbase/lowcode-generator/lib/generator/util/common");
|
|
55
54
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
56
55
|
const em = chalk_1.default.blue.bold;
|
|
57
56
|
const error = chalk_1.default.redBright;
|
|
@@ -74,7 +73,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
74
73
|
isBrowserMpBuilder,
|
|
75
74
|
};
|
|
76
75
|
const yyptConfig = await (0, util_3.getYyptConfigInfo)(extraData);
|
|
77
|
-
const { allAppUsedComps } = handleUsedComponents({
|
|
76
|
+
const { appUsedComps, allAppUsedComps } = handleUsedComponents({
|
|
78
77
|
buildContext,
|
|
79
78
|
weapps,
|
|
80
79
|
materials,
|
|
@@ -151,19 +150,16 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
151
150
|
await (0, generateFiles_1.writeFile)(appJsonPath, JSON.stringify(appJson, undefined, 2));
|
|
152
151
|
}
|
|
153
152
|
else {
|
|
154
|
-
const importor = (0, util_3.generateLowcodeImportor)(mainAppData.lowCodes || []);
|
|
155
153
|
appFileData = {
|
|
156
154
|
...appFileData,
|
|
157
155
|
'common/wx_yypt_report_v2.js': {},
|
|
158
|
-
'app.js': {
|
|
156
|
+
'app.js': { yyptConfig, appConfig },
|
|
159
157
|
'app.json': { content: appConfig },
|
|
160
158
|
'app.wxss': {
|
|
161
|
-
importStyles: materials
|
|
162
|
-
.reduce((styles, lib) => {
|
|
159
|
+
importStyles: materials.reduce((styles, lib) => {
|
|
163
160
|
styles = styles.concat((lib.styles || []).map((stylePath) => stylePath && !stylePath.startsWith('/') ? `/${config_1.materialsDirName}/${lib.name}/${stylePath}` : stylePath) || []);
|
|
164
161
|
return styles;
|
|
165
|
-
}, [])
|
|
166
|
-
.concat(importor.styles.map((mod) => path_1.default.join('lowcode', (0, weapps_core_1.getCodeModuleFilePath)('global', mod, { style: '.wxss' })))),
|
|
162
|
+
}, []),
|
|
167
163
|
},
|
|
168
164
|
'package.json': {
|
|
169
165
|
appId,
|
|
@@ -307,7 +303,6 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
307
303
|
const usingComponents = {};
|
|
308
304
|
const componentGenerics = {};
|
|
309
305
|
const wxml = (0, wxml_1.generateWxml)(page.componentInstances, `Page ${rootPath ? path_1.default.join(rootPath, 'pages') : ''}/${page.id}`, wxmlDataPrefix, { ...ctx, rootPath, isPage: true }, usingComponents, componentGenerics);
|
|
310
|
-
const importor = (0, util_3.generateLowcodeImportor)(page.lowCodes);
|
|
311
306
|
const pageFileName = (0, lodash_1.get)(pageConfigs, `${page.id}.pageFileName`, 'index');
|
|
312
307
|
const pageFileData = {
|
|
313
308
|
[`api.js|api.js`]: {},
|
|
@@ -324,7 +319,6 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
324
319
|
debug: ctx.debugMode,
|
|
325
320
|
stringifyObj: util_1.inspect,
|
|
326
321
|
subLevelPath: rootPath ? `${path_1.default.relative(rootPath, '')}/` : '',
|
|
327
|
-
importor,
|
|
328
322
|
},
|
|
329
323
|
[`index.json|${pageFileName}.json`]: {
|
|
330
324
|
usingComponents,
|
|
@@ -343,7 +337,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
343
337
|
toRem: false,
|
|
344
338
|
toRpx: true,
|
|
345
339
|
}), 'page'),
|
|
346
|
-
pageWxss:
|
|
340
|
+
pageWxss: `@import "../../lowcode/${page.id}/style.wxss"`,
|
|
347
341
|
},
|
|
348
342
|
};
|
|
349
343
|
// Generating file by template and data
|
|
@@ -364,7 +358,7 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
364
358
|
appId: ctx.appId,
|
|
365
359
|
subLevelPath: '',
|
|
366
360
|
subPackageName: '',
|
|
367
|
-
|
|
361
|
+
isBare: true,
|
|
368
362
|
domain: ctx.domain || '',
|
|
369
363
|
appConfig: JSON.stringify({}),
|
|
370
364
|
},
|
|
@@ -385,7 +379,6 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
385
379
|
// 子包混合模式 只在子包中生成 handlers
|
|
386
380
|
const isMixSubpackage = ctx.isMixMode && appData.rootPath;
|
|
387
381
|
if (!isMixSubpackage) {
|
|
388
|
-
const importor = (0, util_3.generateLowcodeImportor)(appData.lowCodes);
|
|
389
382
|
fileData = {
|
|
390
383
|
...fileData,
|
|
391
384
|
'app/app-global.js': {},
|
|
@@ -394,7 +387,7 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
394
387
|
domain: ctx.domain || '',
|
|
395
388
|
subLevelPath: appData.rootPath ? `${path_1.default.relative(`${appData.rootPath}`, '')}/` : '',
|
|
396
389
|
subPackageName: appData.rootPath || '',
|
|
397
|
-
|
|
390
|
+
isBare: false,
|
|
398
391
|
appConfig: (0, util_3.JsonToStringWithVariableName)({
|
|
399
392
|
id: ctx.appId,
|
|
400
393
|
envId: appData.envId,
|
|
@@ -423,23 +416,31 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
423
416
|
async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
424
417
|
console.log(`Writing ${em('lowcode')} files:`);
|
|
425
418
|
const lowcodeRootDir = path_1.default.join(outDir, 'lowcode');
|
|
426
|
-
const
|
|
427
|
-
const themeStyle = lowCodes.find((mod) => mod.type === cals_1.ECodeType.THEME);
|
|
419
|
+
const themeStyle = (0, style_1.generateDefaultTheme)(appData);
|
|
428
420
|
// 混合模式,子包不生成顶级(应用级)的 lowcodes
|
|
429
421
|
if (!(ctx.isMixMode && appData.rootPath)) {
|
|
430
|
-
await Promise.all(lowCodes
|
|
422
|
+
await Promise.all(appData.lowCodes
|
|
423
|
+
.filter((mod) => mod.name !== '____index____')
|
|
431
424
|
.filter((mod) => mod.type !== 'renderer')
|
|
432
425
|
.map((m) => {
|
|
433
426
|
(0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { appDir: outDir }, themeStyle.code);
|
|
434
427
|
}));
|
|
435
428
|
}
|
|
436
429
|
await Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, async (page) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
430
|
+
var _a;
|
|
431
|
+
(0, style_1.generateDefaultStyle)(page);
|
|
432
|
+
const codes = [...((page === null || page === void 0 ? void 0 : page.lowCodes) || [])];
|
|
433
|
+
if (!codes.find((m) => m.name === 'index')) {
|
|
434
|
+
// @ts-ignore
|
|
435
|
+
codes.push({
|
|
436
|
+
code: 'export default {}',
|
|
437
|
+
name: 'index',
|
|
438
|
+
path: 'xx/index',
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
await ((_a = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _a === void 0 ? void 0 : _a.filter((mod) => mod.name !== '____index____').filter((mod) => mod.type !== 'renderer').forEach((m) => {
|
|
441
442
|
(0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { pageId: page.id, appDir: outDir }, themeStyle.code, ctx);
|
|
442
|
-
});
|
|
443
|
+
}));
|
|
443
444
|
}));
|
|
444
445
|
}
|
|
445
446
|
exports.writeLowCodeFiles = writeLowCodeFiles;
|
|
@@ -8,17 +8,16 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
9
9
|
const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style");
|
|
10
10
|
const generateFiles_1 = require("../util/generateFiles");
|
|
11
|
-
const cals_1 = require("@cloudbase/cals");
|
|
12
11
|
async function writeCode2file(mod, lowcodeRootDir, opts = {}, themeCode, ctx) {
|
|
13
12
|
const { pageId = 'global', appDir, comp } = opts;
|
|
14
13
|
const file = path_1.default.join(lowcodeRootDir, (0, weapps_core_1.getCodeModuleFilePath)(pageId || 'global', mod, { style: '.wxss' }));
|
|
15
|
-
let
|
|
16
|
-
if (mod.type !==
|
|
14
|
+
let code = mod.code;
|
|
15
|
+
if (mod.type !== 'style' && mod.type !== 'theme') {
|
|
17
16
|
if (appDir) {
|
|
18
17
|
// Generate app lowcode
|
|
19
18
|
const baseDir = path_1.default.relative(path_1.default.dirname(file), appDir).replace(/\\/g, '/');
|
|
20
19
|
// 子包混合模式需要添加相对索引到根目录
|
|
21
|
-
const relativeRoot = (ctx === null || ctx === void 0 ? void 0 : ctx.isMixMode) && ctx.rootPath ?
|
|
20
|
+
const relativeRoot = (ctx === null || ctx === void 0 ? void 0 : ctx.isMixMode) && ctx.rootPath ? path_1.default.relative(ctx.rootPath, '') + '/' : '';
|
|
22
21
|
let weappsApiPrefix = [
|
|
23
22
|
`import { app, process } from '${relativeRoot}${baseDir}/app/weapps-api';`,
|
|
24
23
|
'const $app = app;',
|
|
@@ -36,11 +36,14 @@ const wxml_1 = require("./wxml");
|
|
|
36
36
|
const generateFiles_1 = __importStar(require("../util/generateFiles"));
|
|
37
37
|
const lowcode_1 = require("./lowcode");
|
|
38
38
|
const net_1 = require("../util/net");
|
|
39
|
+
const util_4 = require("../util");
|
|
39
40
|
const junk = __importStar(require("../util/junk"));
|
|
40
|
-
const templateDir =
|
|
41
|
+
const templateDir = config_1.appTemplateDir + '/mp/';
|
|
41
42
|
async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
42
43
|
let { materialLibs, isBrowserMpBuilder } = ctx;
|
|
43
|
-
const weappsList = ctx.isMixMode
|
|
44
|
+
const weappsList = ctx.isMixMode
|
|
45
|
+
? weapps
|
|
46
|
+
: weapps.filter((item) => !item.rootPath);
|
|
44
47
|
// #1 Download uploaded libs
|
|
45
48
|
const localPkg = (0, util_2.getCurrentPackageJson)();
|
|
46
49
|
await Promise.all(materialLibs
|
|
@@ -59,7 +62,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
59
62
|
await downloadMaterial(mpPkgUrl, materialsSrcDir, ctx.isBrowserMpBuilder);
|
|
60
63
|
}
|
|
61
64
|
function libUpdated(libDir, version) {
|
|
62
|
-
const meta = (0,
|
|
65
|
+
const meta = (0, util_4.readComponentLibMata)(libDir);
|
|
63
66
|
if (!meta) {
|
|
64
67
|
return true;
|
|
65
68
|
}
|
|
@@ -95,7 +98,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
95
98
|
// #3 copy 组件库代码文件到项目目录
|
|
96
99
|
!isBrowserMpBuilder
|
|
97
100
|
? await fs.copy(materialsSrcDirPath, targetDir, {
|
|
98
|
-
filter(src, dest) {
|
|
101
|
+
filter: function (src, dest) {
|
|
99
102
|
const path = src.split('/');
|
|
100
103
|
return !junk.is(path[path.length - 1]);
|
|
101
104
|
},
|
|
@@ -109,7 +112,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
109
112
|
// #2 link material to current project
|
|
110
113
|
!isBrowserMpBuilder
|
|
111
114
|
? await fs.copy(materialsSrcDir, targetDir, {
|
|
112
|
-
filter(src, dest) {
|
|
115
|
+
filter: function (src, dest) {
|
|
113
116
|
const path = src.split('/');
|
|
114
117
|
return !junk.is(path[path.length - 1]);
|
|
115
118
|
},
|
|
@@ -119,7 +122,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
119
122
|
});
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
|
-
const libMeta = (0,
|
|
125
|
+
const libMeta = (0, util_4.readComponentLibMata)(targetDir);
|
|
123
126
|
if (!lib.components) {
|
|
124
127
|
lib.components = Object.keys((libMeta === null || libMeta === void 0 ? void 0 : libMeta.components) || {}).map((name) => {
|
|
125
128
|
var _a;
|
|
@@ -160,7 +163,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
160
163
|
}
|
|
161
164
|
cmp.meta.platforms = {
|
|
162
165
|
mp: {
|
|
163
|
-
path:
|
|
166
|
+
path: cmp.name + '/index',
|
|
164
167
|
},
|
|
165
168
|
};
|
|
166
169
|
lib.dependencies = { ...lib.dependencies, ...cmp.npmDependencies };
|
|
@@ -168,8 +171,8 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
168
171
|
});
|
|
169
172
|
// #2 Generate composited libs
|
|
170
173
|
await Promise.all(compositedLibs.map(async (lib) => {
|
|
171
|
-
console.log(
|
|
172
|
-
await (0,
|
|
174
|
+
console.log('Generate composited library ' + lib.name);
|
|
175
|
+
await (0, util_4.writeLibCommonRes2file)(lib, path.join(ctx.projDir, config_1.materialsDirName, lib.name, 'libCommonRes'));
|
|
173
176
|
await Promise.all(lib.components.map(async (cmp) => {
|
|
174
177
|
return generateCompositeComponent(cmp, {
|
|
175
178
|
...ctx,
|
|
@@ -203,7 +206,7 @@ function extractUsedCompsRecursively(comps, checkedComps, compositedLibs, output
|
|
|
203
206
|
cmpNames.forEach((cmpName) => {
|
|
204
207
|
const cmp = lib.components.find((c) => c.name === cmpName);
|
|
205
208
|
if (!cmp) {
|
|
206
|
-
console.warn('Component not found',
|
|
209
|
+
console.warn('Component not found', libName + ':' + cmpName);
|
|
207
210
|
return;
|
|
208
211
|
}
|
|
209
212
|
if (checkedComps.indexOf(cmp) > -1)
|
|
@@ -234,20 +237,23 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
234
237
|
const { materialName } = compositedComp;
|
|
235
238
|
const outDir = path.join(ctx.projDir, ctx.rootPath || '', // 混合模式下,可能会有 rootPath
|
|
236
239
|
config_1.materialsDirName, materialName, compositedComp.name);
|
|
237
|
-
const LOWCODE_DIR_NAME = 'lowcode';
|
|
238
240
|
console.log(`Generating composited component ${materialName}:${compositedComp.name} to ${outDir}`);
|
|
239
241
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
240
242
|
// # Generating page
|
|
241
243
|
const usingComponents = {};
|
|
242
244
|
const componentGenerics = {};
|
|
243
245
|
const cmpContainer = Object.values(compositedComp.componentInstances)[0];
|
|
244
|
-
const wxml = (0, wxml_1.generateWxml)(compositedComp.componentInstances,
|
|
246
|
+
const wxml = (0, wxml_1.generateWxml)(compositedComp.componentInstances, 'Component ' + materialName + ':' + compositedComp.name, wxmlDataPrefix, { ...ctx, isPage: false }, usingComponents, componentGenerics, (cmp, node) => {
|
|
245
247
|
if (cmp === cmpContainer) {
|
|
246
248
|
// Set className & style passed from parent for root component
|
|
247
249
|
const { attributes } = node;
|
|
248
250
|
const classAttrName = (0, mp_1.getClassAttrName)(node.name);
|
|
249
251
|
const oldClass = attributes[classAttrName];
|
|
250
|
-
attributes[classAttrName] =
|
|
252
|
+
attributes[classAttrName] =
|
|
253
|
+
(0, weapps_core_1.getCompositedComponentClass)(compositedComp) +
|
|
254
|
+
' ' +
|
|
255
|
+
oldClass +
|
|
256
|
+
' {{className}}';
|
|
251
257
|
attributes.style += ';{{style}}';
|
|
252
258
|
}
|
|
253
259
|
});
|
|
@@ -269,10 +275,9 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
269
275
|
delete propDefs[p];
|
|
270
276
|
}
|
|
271
277
|
});
|
|
272
|
-
const importor = (0, util_2.generateLowcodeImportor)(compositedComp.lowCodes);
|
|
273
278
|
const pageFileData = {
|
|
274
279
|
'index.js': {
|
|
275
|
-
materialName,
|
|
280
|
+
materialName: materialName,
|
|
276
281
|
propDefs,
|
|
277
282
|
handlers: compositedComp.lowCodes
|
|
278
283
|
.filter((m) => m.type === 'handler-fn' && m.name !== '____index____')
|
|
@@ -283,14 +288,13 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
283
288
|
widgetProps: (0, util_3.createWidgetProps)(compositedComp.componentInstances, ctx),
|
|
284
289
|
compApi: weapps_core_1.COMPONENT_API_PREFIX,
|
|
285
290
|
jsonSchemaType2jsClass: mp_1.jsonSchemaType2jsClass,
|
|
286
|
-
key:
|
|
291
|
+
key: compositedComp.materialName + ':' + compositedComp.name,
|
|
287
292
|
dataBinds: (0, util_3.createDataBinds)(compositedComp.componentInstances, ctx),
|
|
288
293
|
debug: !ctx.isProduction,
|
|
289
294
|
stringifyObj: util_1.inspect,
|
|
290
295
|
// dataPropNames: wxmlDataPrefix,
|
|
291
296
|
formEvents: Object.keys(formEvents).length > 0 ? formEvents : null,
|
|
292
297
|
config: compositedComp.compConfig,
|
|
293
|
-
importor,
|
|
294
298
|
},
|
|
295
299
|
'index.json': { usingComponents, componentGenerics },
|
|
296
300
|
'index.wxml': {
|
|
@@ -298,12 +302,10 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
298
302
|
// wrapperClass: getCompositedComponentClass(compositedComp),
|
|
299
303
|
content: wxml,
|
|
300
304
|
},
|
|
301
|
-
'index.wxss': {
|
|
302
|
-
importStyles: importor.styles.map((mod) => path.join(LOWCODE_DIR_NAME, (0, weapps_core_1.getCodeModuleFilePath)('global', mod, { style: '.wxss' }))),
|
|
303
|
-
},
|
|
305
|
+
'index.wxss': {},
|
|
304
306
|
};
|
|
305
307
|
// Generating file by template and data
|
|
306
|
-
await (0, generateFiles_1.default)(pageFileData,
|
|
308
|
+
await (0, generateFiles_1.default)(pageFileData, templateDir + '/component', outDir, ctx);
|
|
307
309
|
// #3 writing lowcode files
|
|
308
310
|
const codes = [...compositedComp.lowCodes];
|
|
309
311
|
if (!codes.find((m) => m.name === 'index')) {
|
|
@@ -325,7 +327,7 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
325
327
|
${compLibCommonResource.theme.class || ''}
|
|
326
328
|
`;
|
|
327
329
|
}
|
|
328
|
-
return (0, lowcode_1.writeCode2file)(mod, path.join(outDir,
|
|
330
|
+
return (0, lowcode_1.writeCode2file)(mod, path.join(outDir, 'lowcode'), { comp: compositedComp }, themeCode, ctx);
|
|
329
331
|
});
|
|
330
332
|
// await writeLowCodeFiles(weapp, appRoot)
|
|
331
333
|
// await generateFramework(weapp, appRoot)
|
|
@@ -366,7 +368,7 @@ function getWxmlTag(cmp, ctx, nameMangler) {
|
|
|
366
368
|
compPath.startsWith('/') || compPath.indexOf('://') > 0
|
|
367
369
|
? compPath
|
|
368
370
|
: path.posix.join(
|
|
369
|
-
/*
|
|
371
|
+
/*ctx.isMixMode ? '/' + rootPath : */ '', `/${config_1.materialsDirName}/${cmp.moduleName}`, compPath);
|
|
370
372
|
tagName = `${moduleName}-${name}`;
|
|
371
373
|
if (nameMangler) {
|
|
372
374
|
tagName = nameMangler.mangle(tagName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
|
-
import { ICompositedComponent, IMaterialItem, IPageInstance, IWeAppComponentInstance
|
|
2
|
+
import { ICompositedComponent, IMaterialItem, IPageInstance, IWeAppComponentInstance } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
3
|
export { getMetaInfoBySourceKey, isArray, isPlainObject, deepDeal, simpleDeepClone, deepDealSchema, getFileNameByUrl, } from '@cloudbase/lowcode-generator/lib/generator/util/common';
|
|
4
4
|
export declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
@@ -50,10 +50,3 @@ interface ICompileDirs {
|
|
|
50
50
|
materialsDir: string;
|
|
51
51
|
}
|
|
52
52
|
export declare function getCompileDirs(appKey?: string): ICompileDirs;
|
|
53
|
-
export declare function generateLowcodeImportor(lowcodes?: IWeAppCode[]): {
|
|
54
|
-
state: boolean;
|
|
55
|
-
computed: boolean;
|
|
56
|
-
lifecycle: boolean;
|
|
57
|
-
common: boolean;
|
|
58
|
-
styles: IWeAppCode[];
|
|
59
|
-
};
|
|
@@ -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.deepDealComponentSchemaJson = exports.canUseVite = exports.gererateIndexAPI = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
7
7
|
// import * as R from 'ramda'
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -11,7 +11,6 @@ const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style")
|
|
|
11
11
|
const generateFiles_1 = require("./generateFiles");
|
|
12
12
|
const cals_1 = require("@cloudbase/cals");
|
|
13
13
|
const compare_versions_1 = __importDefault(require("compare-versions"));
|
|
14
|
-
const os_1 = __importDefault(require("os"));
|
|
15
14
|
var common_1 = require("@cloudbase/lowcode-generator/lib/generator/util/common");
|
|
16
15
|
Object.defineProperty(exports, "getMetaInfoBySourceKey", { enumerable: true, get: function () { return common_1.getMetaInfoBySourceKey; } });
|
|
17
16
|
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return common_1.isArray; } });
|
|
@@ -20,6 +19,7 @@ Object.defineProperty(exports, "deepDeal", { enumerable: true, get: function ()
|
|
|
20
19
|
Object.defineProperty(exports, "simpleDeepClone", { enumerable: true, get: function () { return common_1.simpleDeepClone; } });
|
|
21
20
|
Object.defineProperty(exports, "deepDealSchema", { enumerable: true, get: function () { return common_1.deepDealSchema; } });
|
|
22
21
|
Object.defineProperty(exports, "getFileNameByUrl", { enumerable: true, get: function () { return common_1.getFileNameByUrl; } });
|
|
22
|
+
const os_1 = __importDefault(require("os"));
|
|
23
23
|
const homeDir = os_1.default.homedir();
|
|
24
24
|
const commandConfigPath = path_1.default.join(homeDir, '.warc');
|
|
25
25
|
function promiseWrapper(p) {
|
|
@@ -56,8 +56,12 @@ function getSelfPackageJson() {
|
|
|
56
56
|
}
|
|
57
57
|
exports.getSelfPackageJson = getSelfPackageJson;
|
|
58
58
|
function JsonToStringWithVariableName(copyJson, options = {}) {
|
|
59
|
-
let variable = JSON.stringify(copyJson, null, 2).replace(/"%%%(.*?)%%%"/g, (match, expression)
|
|
60
|
-
return expression
|
|
59
|
+
let variable = JSON.stringify(copyJson, null, 2).replace(/"%%%(.*?)%%%"/g, function (match, expression) {
|
|
60
|
+
return expression
|
|
61
|
+
.replace(/\\"/g, '"')
|
|
62
|
+
.replace(/\\'/g, "'")
|
|
63
|
+
.replace(/\\r/g, '\r')
|
|
64
|
+
.replace(/\\n/g, '\n');
|
|
61
65
|
});
|
|
62
66
|
return variable;
|
|
63
67
|
}
|
|
@@ -84,7 +88,8 @@ function getInputProps(componentsMetaMap) {
|
|
|
84
88
|
let compItem = component;
|
|
85
89
|
Object.keys(compItem.dataForm || {}).forEach((key) => {
|
|
86
90
|
var _a, _b;
|
|
87
|
-
const inputProps = ((_a = compItem.dataForm[key]) === null || _a === void 0 ? void 0 : _a.inputProp) ||
|
|
91
|
+
const inputProps = ((_a = compItem.dataForm[key]) === null || _a === void 0 ? void 0 : _a.inputProp) ||
|
|
92
|
+
((_b = compItem.dataForm[key]) === null || _b === void 0 ? void 0 : _b.syncProps);
|
|
88
93
|
if (inputProps) {
|
|
89
94
|
outputObj[sourceKey] = {
|
|
90
95
|
[key]: inputProps,
|
|
@@ -172,7 +177,7 @@ async function getYyptConfigInfo(extraData) {
|
|
|
172
177
|
}
|
|
173
178
|
exports.getYyptConfigInfo = getYyptConfigInfo;
|
|
174
179
|
async function writeLibCommonRes2file(gItem, codeDir) {
|
|
175
|
-
const
|
|
180
|
+
const compLibCommonResource = gItem.compLibCommonResource;
|
|
176
181
|
const libCommonResFiles = [];
|
|
177
182
|
libCommonResFiles.push({
|
|
178
183
|
path: path_1.default.join(codeDir, `class.${codeDir.includes('/mp/') ? 'wxss' : 'less'}`),
|
|
@@ -222,11 +227,14 @@ const _OFFICIAL_COMPONENT_LIB = {
|
|
|
222
227
|
};
|
|
223
228
|
function isOfficialComponentLib(name, version) {
|
|
224
229
|
var _a, _b;
|
|
225
|
-
return !!((_a = _OFFICIAL_COMPONENT_LIB[name]) === null || _a === void 0 ? void 0 : _a.includes(version)) ||
|
|
230
|
+
return (!!((_a = _OFFICIAL_COMPONENT_LIB[name]) === null || _a === void 0 ? void 0 : _a.includes(version)) ||
|
|
231
|
+
((_b = _OFFICIAL_COMPONENT_LIB[name]) === null || _b === void 0 ? void 0 : _b.includes('*')));
|
|
226
232
|
}
|
|
227
233
|
exports.isOfficialComponentLib = isOfficialComponentLib;
|
|
228
234
|
function gererateIndexAPI(data, isComponent) {
|
|
229
|
-
const lowCodes = data.lowCodes ||
|
|
235
|
+
const lowCodes = data.lowCodes ||
|
|
236
|
+
data.codeModules ||
|
|
237
|
+
[];
|
|
230
238
|
if (!lowCodes.find(({ name }) => name === 'index')) {
|
|
231
239
|
// 补充组件不存在的 index 类型代码
|
|
232
240
|
lowCodes.push({
|
|
@@ -245,7 +253,9 @@ exports.gererateIndexAPI = gererateIndexAPI;
|
|
|
245
253
|
*/
|
|
246
254
|
function canUseVite(mode, devTool) {
|
|
247
255
|
return false;
|
|
248
|
-
return devTool === 'vite' &&
|
|
256
|
+
return (devTool === 'vite' &&
|
|
257
|
+
mode !== 'production' &&
|
|
258
|
+
(0, compare_versions_1.default)(process.version, '12.0.0') >= 0);
|
|
249
259
|
}
|
|
250
260
|
exports.canUseVite = canUseVite;
|
|
251
261
|
function deepDealComponentSchemaJson(schema, dealFn) {
|
|
@@ -272,38 +282,3 @@ function getCompileDirs(appKey = 'test') {
|
|
|
272
282
|
};
|
|
273
283
|
}
|
|
274
284
|
exports.getCompileDirs = getCompileDirs;
|
|
275
|
-
function generateLowcodeImportor(lowcodes = []) {
|
|
276
|
-
const importor = {
|
|
277
|
-
state: false,
|
|
278
|
-
computed: false,
|
|
279
|
-
lifecycle: false,
|
|
280
|
-
common: false,
|
|
281
|
-
styles: [],
|
|
282
|
-
};
|
|
283
|
-
lowcodes.forEach((mod) => {
|
|
284
|
-
switch (mod.type) {
|
|
285
|
-
case cals_1.ECodeType.STYLE: {
|
|
286
|
-
importor.styles.push(mod);
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
case cals_1.ECodeType.LIFECYCLE: {
|
|
290
|
-
importor.lifecycle = true;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
case cals_1.ECodeType.STATE: {
|
|
294
|
-
importor.state = true;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
case cals_1.ECodeType.COMPUTEDN: {
|
|
298
|
-
importor.computed = true;
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
case cals_1.ECodeType.NORMAL_MODULE: {
|
|
302
|
-
importor.common = true;
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
return importor;
|
|
308
|
-
}
|
|
309
|
-
exports.generateLowcodeImportor = generateLowcodeImportor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
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",
|