@cloudbase/lowcode-builder 1.1.5 → 1.1.7
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/core/index.js +3 -1
- package/lib/builder/mp/index.d.ts +3 -1
- package/lib/builder/mp/index.js +3 -3
- package/lib/builder/mp/mp_config.d.ts +3 -1
- package/lib/builder/mp/mp_config.js +2 -1
- package/lib/builder/service/webpack.js +8 -1
- package/lib/builder/util/generateFiles.d.ts +1 -0
- package/lib/builder/util/generateFiles.js +16 -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/package.json +3 -3
- package/template/mp/app/common.js +2 -2
- package/template/mp/app/handlers.js +1 -1
- package/template/mp/package.json +1 -1
- package/template/mp/page/index.js +1 -1
|
@@ -58,9 +58,11 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
58
58
|
options: {
|
|
59
59
|
isCrossAccount: resourceAppId !== deployOptions.targetMpAppId,
|
|
60
60
|
resourceAppId,
|
|
61
|
+
mpAppId: deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mpAppId,
|
|
61
62
|
},
|
|
62
63
|
buildTypeList,
|
|
63
64
|
isBrowserMpBuilder,
|
|
65
|
+
ignoreInstall,
|
|
64
66
|
});
|
|
65
67
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
66
68
|
// 针对 app.json / package.json 则采用 merge 的操作
|
|
@@ -81,7 +83,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
81
83
|
});
|
|
82
84
|
// 如果是代开发的模式,则写入ext.json
|
|
83
85
|
await (0, postProcess_1.postprocessDeployExtraJson)(outDir, deployOptions);
|
|
84
|
-
if (!isBrowserMpBuilder && generateMpType === common_1.GenerateMpType.APP) {
|
|
86
|
+
if (!isBrowserMpBuilder && generateMpType === common_1.GenerateMpType.APP && !ignoreInstall) {
|
|
85
87
|
// 模板拷入的 miniprogram_npm 有问题,直接删除使用重新构建的版本
|
|
86
88
|
// 模板需要占位保证 mp 文件夹存在
|
|
87
89
|
fs_extra_1.default.removeSync(path_1.default.resolve(outDir, 'miniprogram_npm'));
|
|
@@ -2,7 +2,7 @@ import { IMaterialItem, IWeAppData, IPlugin } from '@cloudbase/lowcode-generator
|
|
|
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({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder, }: {
|
|
5
|
+
export declare function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder, ignoreInstall, }: {
|
|
6
6
|
weapps: IWeAppData[];
|
|
7
7
|
projDir: string;
|
|
8
8
|
appId: string;
|
|
@@ -15,10 +15,12 @@ export declare function generateWxMp({ weapps, projDir, appId, domain, materials
|
|
|
15
15
|
isMixMode: boolean;
|
|
16
16
|
options: {
|
|
17
17
|
resourceAppId?: string;
|
|
18
|
+
mpAppId?: string;
|
|
18
19
|
isCrossAccount: boolean;
|
|
19
20
|
};
|
|
20
21
|
buildTypeList: BuildType[];
|
|
21
22
|
isBrowserMpBuilder: boolean;
|
|
23
|
+
ignoreInstall: boolean;
|
|
22
24
|
}): Promise<{
|
|
23
25
|
miniprogramRoot: string;
|
|
24
26
|
}>;
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -54,7 +54,7 @@ const cals_1 = require("@cloudbase/cals");
|
|
|
54
54
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
55
55
|
const em = chalk_1.default.blue.bold;
|
|
56
56
|
const error = chalk_1.default.redBright;
|
|
57
|
-
async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, }) {
|
|
57
|
+
async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, ignoreInstall = false, }) {
|
|
58
58
|
var _a;
|
|
59
59
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
60
60
|
console.time(operationLabel);
|
|
@@ -82,7 +82,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
82
82
|
// 安装依赖库,生成 materials 目录
|
|
83
83
|
await (0, materials_1.installMaterials)(projDir, allAppUsedComps, weapps, buildContext);
|
|
84
84
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
|
|
85
|
-
const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(weapps, buildContext);
|
|
85
|
+
const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(weapps, buildContext, { mpAppId: options === null || options === void 0 ? void 0 : options.mpAppId });
|
|
86
86
|
// #1 generate project files
|
|
87
87
|
if (!mainAppData.mpPkgUrl) {
|
|
88
88
|
const projectFileData = {
|
|
@@ -228,7 +228,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
228
228
|
}
|
|
229
229
|
}));
|
|
230
230
|
if (!isBrowserMpBuilder && fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
231
|
-
await (0, webpack_1.installDependencies)(miniprogramRoot);
|
|
231
|
+
await (0, webpack_1.installDependencies)(miniprogramRoot, { ignoreInstall });
|
|
232
232
|
}
|
|
233
233
|
await handleMpPlugins();
|
|
234
234
|
console.timeEnd(operationLabel);
|
|
@@ -6,7 +6,9 @@ import { IBuildContext } from './BuildContext';
|
|
|
6
6
|
* @param kboneConfig https://wechat-miniprogram.github.io/kbone/docs/config/
|
|
7
7
|
* @param appConfigs app config from prop edit panel
|
|
8
8
|
*/
|
|
9
|
-
export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext
|
|
9
|
+
export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext, options?: {
|
|
10
|
+
mpAppId?: string;
|
|
11
|
+
}): {
|
|
10
12
|
appConfig: any;
|
|
11
13
|
projConfig: any;
|
|
12
14
|
pageConfigs: {}[];
|
|
@@ -40,7 +40,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
40
40
|
* @param kboneConfig https://wechat-miniprogram.github.io/kbone/docs/config/
|
|
41
41
|
* @param appConfigs app config from prop edit panel
|
|
42
42
|
*/
|
|
43
|
-
function generateMpConfig(weapps, ctx) {
|
|
43
|
+
function generateMpConfig(weapps, ctx, options) {
|
|
44
44
|
var _a;
|
|
45
45
|
const appConfig = {
|
|
46
46
|
useExtendedLib: { weui: true },
|
|
@@ -48,6 +48,7 @@ function generateMpConfig(weapps, ctx) {
|
|
|
48
48
|
const { miniprogramPlugins = [] } = ctx;
|
|
49
49
|
const projConfig = (0, lodash_1.merge)({}, mp_1.defaultProjConfig, {
|
|
50
50
|
projectname: (ctx.mainAppData && ctx.mainAppData.label) || `WeDa-${ctx.appId}`,
|
|
51
|
+
appid: (options === null || options === void 0 ? void 0 : options.mpAppId) || mp_1.defaultProjConfig.appid,
|
|
51
52
|
});
|
|
52
53
|
const pageConfigs = weapps.map((app) => {
|
|
53
54
|
var _a;
|
|
@@ -456,7 +456,14 @@ async function installDependencies(targetDir, options = {}) {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
catch (e) { }
|
|
459
|
-
|
|
459
|
+
const packageJsonPath = path_1.default.resolve(targetDir, 'package.json');
|
|
460
|
+
/**
|
|
461
|
+
* 无 cacheMeta 或 cacheMeta.once 时 遵循 options?.ignoreInstall 配置
|
|
462
|
+
* 否则认为文件发生了更改,应该忽略参数强制安装
|
|
463
|
+
*/
|
|
464
|
+
const cacheMeta = generateFiles_1.generatedFileContents[packageJsonPath];
|
|
465
|
+
const isPkgModify = !cacheMeta || cacheMeta.once ? false : generateFiles_1.generatedFileContents[path_1.default.resolve(targetDir, 'package.json')].modify;
|
|
466
|
+
if ((options === null || options === void 0 ? void 0 : options.ignoreInstall) && fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'node_modules')) && !isPkgModify) {
|
|
460
467
|
console.log(`ignore install dependencies in ${targetDir}`);
|
|
461
468
|
return;
|
|
462
469
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IBuildContext } from '../mp/BuildContext';
|
|
3
3
|
import { OutputType } from 'jszip';
|
|
4
|
+
export declare const generatedFileContents: {};
|
|
4
5
|
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string, ctx: IBuildContext): Promise<string[]>;
|
|
5
6
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
6
7
|
export declare function removeFile(file: string): void;
|
|
@@ -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.strToBuf = exports.fileToZip = exports.getFiles = exports.copyRecursiveSync = exports.copyFileSync = exports.copy = exports.copyFiles = exports.cleanDir = exports.removeFile = exports.writeFile = void 0;
|
|
29
|
+
exports.strToBuf = exports.fileToZip = exports.getFiles = exports.copyRecursiveSync = exports.copyFileSync = exports.copy = exports.copyFiles = exports.cleanDir = exports.removeFile = exports.writeFile = exports.generatedFileContents = void 0;
|
|
30
30
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const lodash_1 = require("lodash");
|
|
@@ -34,7 +34,7 @@ const junk = __importStar(require("../util/junk"));
|
|
|
34
34
|
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
38
|
async function generateFiles(appFileData, srcDir, dstDir, ctx) {
|
|
39
39
|
const filesGenerated = [];
|
|
40
40
|
// Generating file by template and data
|
|
@@ -67,22 +67,32 @@ async function generateFiles(appFileData, srcDir, dstDir, ctx) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.default = generateFiles;
|
|
69
69
|
async function writeFile(outFile, content) {
|
|
70
|
-
|
|
70
|
+
if (!exports.generatedFileContents[outFile]) {
|
|
71
|
+
exports.generatedFileContents[outFile] = {
|
|
72
|
+
once: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
exports.generatedFileContents[outFile].once = false;
|
|
77
|
+
}
|
|
78
|
+
const meta = exports.generatedFileContents[outFile];
|
|
79
|
+
const generated = meta.content;
|
|
71
80
|
if (generated === content && fs_extra_1.default.existsSync(outFile)) {
|
|
81
|
+
exports.generatedFileContents[outFile].modify = false;
|
|
72
82
|
return false;
|
|
73
83
|
}
|
|
74
84
|
// console.log(outFile);
|
|
75
85
|
await fs_extra_1.default.ensureFile(outFile);
|
|
76
86
|
await fs_extra_1.default.writeFile(outFile, content);
|
|
77
|
-
generatedFileContents[outFile] = content;
|
|
87
|
+
exports.generatedFileContents[outFile] = { ...meta, content, modify: true };
|
|
78
88
|
return true;
|
|
79
89
|
}
|
|
80
90
|
exports.writeFile = writeFile;
|
|
81
91
|
function removeFile(file) {
|
|
82
92
|
console.log(`Removing ${file}`);
|
|
83
|
-
Object.keys(generatedFileContents).map((cachedFile) => {
|
|
93
|
+
Object.keys(exports.generatedFileContents).map((cachedFile) => {
|
|
84
94
|
if (cachedFile.indexOf(file) === 0) {
|
|
85
|
-
delete generatedFileContents[cachedFile];
|
|
95
|
+
delete exports.generatedFileContents[cachedFile];
|
|
86
96
|
}
|
|
87
97
|
});
|
|
88
98
|
return fs_extra_1.default.removeSync(file);
|
package/lib/builder/util/junk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.not = exports.is = void 0;
|
|
3
|
+
exports.isFilePath = exports.not = exports.is = void 0;
|
|
4
4
|
const ignoreList = [
|
|
5
5
|
// # All
|
|
6
6
|
'^npm-debug\\.log$',
|
|
@@ -25,8 +25,14 @@ const ignoreList = [
|
|
|
25
25
|
'^readme.md$',
|
|
26
26
|
'^README.md$',
|
|
27
27
|
];
|
|
28
|
+
const filePathIgnoreList = [
|
|
29
|
+
'__MACOSX', // 路径有__MACOSX就过滤
|
|
30
|
+
];
|
|
28
31
|
const regex = new RegExp(ignoreList.join('|'));
|
|
32
|
+
const filePathRegex = new RegExp(filePathIgnoreList.join('|'));
|
|
29
33
|
const is = (filename) => regex.test(filename);
|
|
30
34
|
exports.is = is;
|
|
31
35
|
const not = (filename) => !(0, exports.is)(filename);
|
|
32
36
|
exports.not = not;
|
|
37
|
+
const isFilePath = (filename) => filePathRegex.test(filename);
|
|
38
|
+
exports.isFilePath = isFilePath;
|
package/lib/builder/util/net.js
CHANGED
|
@@ -34,6 +34,7 @@ const compressing_1 = __importDefault(require("compressing"));
|
|
|
34
34
|
const jszip_1 = __importDefault(require("jszip"));
|
|
35
35
|
const config_1 = require("../config");
|
|
36
36
|
const generateFiles_1 = require("../util/generateFiles");
|
|
37
|
+
const junk_1 = require("../util/junk");
|
|
37
38
|
async function downloadFile(url, filePath) {
|
|
38
39
|
await fs_extra_1.default.ensureDir(path.dirname(filePath));
|
|
39
40
|
const res = await axios_1.default.get(url, { responseType: 'stream' });
|
|
@@ -91,6 +92,9 @@ async function saveFiles(files, dstDir) {
|
|
|
91
92
|
try {
|
|
92
93
|
for (const fileName of Object.keys(files)) {
|
|
93
94
|
const dest = path.join(dstDir, fileName);
|
|
95
|
+
if ((0, junk_1.isFilePath)(dest)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
94
98
|
if (files[fileName].dir) { // 如果该文件为目录需先创建文件夹
|
|
95
99
|
fs_extra_1.default.mkdirSync(dest, {
|
|
96
100
|
recursive: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
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.4.
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.1.
|
|
41
|
+
"@cloudbase/cals": "^0.4.11",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.1.3",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% mods.forEach((mod) => {%>
|
|
2
|
-
import * as
|
|
2
|
+
import * as $$<%= mod %> from '../lowcode/common/<%= mod %>'<%}) %>
|
|
3
3
|
|
|
4
4
|
const _weapps_app_common = {}
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ Object.defineProperties(_weapps_app_common, {
|
|
|
18
18
|
<% mods.forEach((mod) => {%>
|
|
19
19
|
<%= mod %>: {
|
|
20
20
|
get() {
|
|
21
|
-
return getDefaultModule(
|
|
21
|
+
return getDefaultModule($$<%= mod %>)
|
|
22
22
|
}
|
|
23
23
|
},<%}) %>
|
|
24
24
|
})
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
<% pageModules.forEach(({id: pageId, lowCodes}) => { %>
|
|
10
|
-
export const
|
|
10
|
+
export const $$<%=pageId %> = {
|
|
11
11
|
<% lowCodes.filter(mod => mod.type === 'handler-fn' && mod.name !== '____index____').forEach(mod => {%>
|
|
12
12
|
['<%= mod.name%>']: <%= pageId%>_<%= mod.name%>,
|
|
13
13
|
<% }) %>
|
package/template/mp/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { observable } from 'mobx';
|
|
|
2
2
|
import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
|
|
3
3
|
import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
|
|
4
4
|
import { app } from '<%= subLevelPath %>../../app/weapps-api'
|
|
5
|
-
import {
|
|
5
|
+
import { $$<%= pageName %> as handlers } from '../../app/handlers'
|
|
6
6
|
<%= importor.lifecycle? `import lifecyle from '../../lowcode/${pageName}/lifecycle'` : "const lifecyle = {}" %>
|
|
7
7
|
<%= importor.state? `import state from '../../lowcode/${pageName}/state'` : "const state = {}" %>
|
|
8
8
|
<%= importor.computed? `import computed from '../../lowcode/${pageName}/computed'` : "const computed = {}" %>
|