@cloudbase/lowcode-builder 0.1.4 → 0.1.5-mp-beta
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 +14 -0
- package/lib/builder/config/index.js +16 -1
- package/lib/builder/core/index.d.ts +4 -1
- package/lib/builder/core/index.js +15 -3
- package/lib/builder/mp/BuildContext.d.ts +1 -0
- package/lib/builder/mp/index.d.ts +2 -1
- package/lib/builder/mp/index.js +7 -5
- package/lib/builder/mp/materials.js +12 -14
- package/lib/builder/mp/mp_config.js +1 -1
- package/lib/builder/service/webpack.js +10 -10
- package/lib/builder/util/common.js +5 -4
- package/lib/builder/util/generateFiles.d.ts +33 -0
- package/lib/builder/util/generateFiles.js +120 -1
- package/lib/builder/util/net.d.ts +20 -1
- package/lib/builder/util/net.js +72 -3
- package/lib/types.d.ts +1 -0
- package/lib/types.js +3 -1
- package/package.json +20 -7
- package/template/mp/component/index.js +6 -2
- package/template/mp/page/index.js +6 -2
|
@@ -2,3 +2,17 @@ export { REPLACE_SIGN, MP_CONFIG_MODULE_NAME, KBONE_PAGE_KEYS, npmRegistry, remC
|
|
|
2
2
|
export declare const sharedMaterialsDir: string;
|
|
3
3
|
export declare const appTemplateDir: string;
|
|
4
4
|
export declare const materialsDirName = "materials";
|
|
5
|
+
/**
|
|
6
|
+
* src/template的代码,在IDE编辑器插件中构建builder
|
|
7
|
+
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
8
|
+
*/
|
|
9
|
+
export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.zip";
|
|
10
|
+
/**
|
|
11
|
+
* miniprogram的代码,IDE插件后续会提供端功能
|
|
12
|
+
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
13
|
+
*/
|
|
14
|
+
export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm.zip";
|
|
15
|
+
/**
|
|
16
|
+
* miniprogram_npm存放目录。IDE插件builder用到
|
|
17
|
+
*/
|
|
18
|
+
export declare const miniprogramDir: string;
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
|
|
25
|
+
exports.miniprogramDir = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
|
|
26
26
|
const path = __importStar(require("path"));
|
|
27
27
|
const os_1 = __importDefault(require("os"));
|
|
28
28
|
var index_1 = require("@cloudbase/lowcode-generator/lib/generator/config/index");
|
|
@@ -35,3 +35,18 @@ Object.defineProperty(exports, "rpxConfig", { enumerable: true, get: function ()
|
|
|
35
35
|
exports.sharedMaterialsDir = path.join(os_1.default.homedir(), '.weapps-materials');
|
|
36
36
|
exports.appTemplateDir = path.resolve(__dirname, '../../../template');
|
|
37
37
|
exports.materialsDirName = 'materials'; // materials diretory of current project
|
|
38
|
+
/**
|
|
39
|
+
* src/template的代码,在IDE编辑器插件中构建builder
|
|
40
|
+
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
41
|
+
*/
|
|
42
|
+
exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.zip';
|
|
43
|
+
/**
|
|
44
|
+
* miniprogram的代码,IDE插件后续会提供端功能
|
|
45
|
+
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
46
|
+
*/
|
|
47
|
+
// export const miniprogramURL = 'https://cos-1252394733.cos.ap-nanjing.myqcloud.com/miniprogram_npm.zip';
|
|
48
|
+
exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm.zip';
|
|
49
|
+
/**
|
|
50
|
+
* miniprogram_npm存放目录。IDE插件builder用到
|
|
51
|
+
*/
|
|
52
|
+
exports.miniprogramDir = path.join(os_1.default.homedir(), exports.sharedMaterialsDir, 'miniprogram_npm');
|
|
@@ -36,9 +36,12 @@ export interface IBuildWedaApp extends IBaseAppProps {
|
|
|
36
36
|
output?: {
|
|
37
37
|
path?: string;
|
|
38
38
|
};
|
|
39
|
+
isBrowserMpBuilder?: boolean;
|
|
39
40
|
}
|
|
40
|
-
export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
|
|
41
|
+
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>;
|
|
41
42
|
export declare function cleanComponentDir(): Promise<void>;
|
|
42
43
|
export declare function installDep(dir: any, opts?: IInstallOpts): Promise<void>;
|
|
43
44
|
export declare const version: any;
|
|
45
|
+
export { getFiles, fileToZip, strToBuf } from '../util/generateFiles';
|
|
46
|
+
export { downloadZip } from '../util/net';
|
|
44
47
|
export default buildWedaApp;
|
|
@@ -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.version = exports.installDep = exports.cleanComponentDir = exports.buildWedaApp = exports.getCompileDirs = void 0;
|
|
6
|
+
exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.installDep = exports.cleanComponentDir = exports.buildWedaApp = exports.getCompileDirs = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const webpack_1 = require("../service/webpack");
|
|
9
9
|
const util_1 = require("../util");
|
|
@@ -18,11 +18,12 @@ const index_2 = require("../h5/index");
|
|
|
18
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
19
|
const common_2 = require("../../utils/common");
|
|
20
20
|
const postProcess_1 = require("../../utils/postProcess");
|
|
21
|
+
const net_1 = require("../util/net");
|
|
21
22
|
const pkg = require('../../../package.json');
|
|
22
23
|
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 = {
|
|
23
24
|
isComposite: false,
|
|
24
25
|
compProps: {},
|
|
25
|
-
}, resourceAppId = undefined, domain = '', output, }, cb) {
|
|
26
|
+
}, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, }, cb) {
|
|
26
27
|
var _a, _b;
|
|
27
28
|
if (!cals) {
|
|
28
29
|
console.error('无效的应用配置');
|
|
@@ -44,6 +45,10 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
44
45
|
appBuildDir = (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp');
|
|
45
46
|
const isMixMode = generateMpType === common_1.GenerateMpType.SUBPACKAGE;
|
|
46
47
|
const apps = [mainAppSerializeData, ...subAppSerializeDataList];
|
|
48
|
+
if (isBrowserMpBuilder) {
|
|
49
|
+
// 尽早下载物料
|
|
50
|
+
await (0, net_1.downloadBrowserMaterial)(output && output.path);
|
|
51
|
+
}
|
|
47
52
|
try {
|
|
48
53
|
const result = await (0, index_1.generateWxMp)({
|
|
49
54
|
weapps: apps,
|
|
@@ -61,6 +66,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
61
66
|
resourceAppId,
|
|
62
67
|
},
|
|
63
68
|
buildTypeList,
|
|
69
|
+
isBrowserMpBuilder,
|
|
64
70
|
});
|
|
65
71
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
66
72
|
// 针对 app.json / package.json 则采用 merge 的操作
|
|
@@ -81,7 +87,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
81
87
|
});
|
|
82
88
|
// 如果是代开发的模式,则写入ext.json
|
|
83
89
|
await (0, postProcess_1.postprocessDeployExtraJson)(outDir, deployOptions);
|
|
84
|
-
if (generateMpType === common_1.GenerateMpType.APP) {
|
|
90
|
+
if (!isBrowserMpBuilder && generateMpType === common_1.GenerateMpType.APP) {
|
|
85
91
|
// 模板拷入的 miniprogram_npm 有问题,直接删除使用重新构建的版本
|
|
86
92
|
// 模板需要占位保证 mp 文件夹存在
|
|
87
93
|
fs_extra_1.default.removeSync(path_1.default.resolve(outDir, 'miniprogram_npm'));
|
|
@@ -133,4 +139,10 @@ function installDep(dir, opts = {}) {
|
|
|
133
139
|
}
|
|
134
140
|
exports.installDep = installDep;
|
|
135
141
|
exports.version = pkg.version;
|
|
142
|
+
var generateFiles_1 = require("../util/generateFiles");
|
|
143
|
+
Object.defineProperty(exports, "getFiles", { enumerable: true, get: function () { return generateFiles_1.getFiles; } });
|
|
144
|
+
Object.defineProperty(exports, "fileToZip", { enumerable: true, get: function () { return generateFiles_1.fileToZip; } });
|
|
145
|
+
Object.defineProperty(exports, "strToBuf", { enumerable: true, get: function () { return generateFiles_1.strToBuf; } });
|
|
146
|
+
var net_2 = require("../util/net");
|
|
147
|
+
Object.defineProperty(exports, "downloadZip", { enumerable: true, get: function () { return net_2.downloadZip; } });
|
|
136
148
|
exports.default = buildWedaApp;
|
|
@@ -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, }: {
|
|
5
|
+
export declare function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder, }: {
|
|
6
6
|
weapps: IWeAppData[];
|
|
7
7
|
projDir: string;
|
|
8
8
|
appId: string;
|
|
@@ -18,6 +18,7 @@ export declare function generateWxMp({ weapps, projDir, appId, domain, materials
|
|
|
18
18
|
isCrossAccount: boolean;
|
|
19
19
|
};
|
|
20
20
|
buildTypeList: BuildType[];
|
|
21
|
+
isBrowserMpBuilder: boolean;
|
|
21
22
|
}): Promise<{
|
|
22
23
|
miniprogramRoot: string;
|
|
23
24
|
}>;
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const net_1 = require("../util/net");
|
|
|
51
51
|
const templateDir = config_1.appTemplateDir + '/mp/';
|
|
52
52
|
const em = chalk_1.default.blue.bold;
|
|
53
53
|
const error = chalk_1.default.redBright;
|
|
54
|
-
async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, }) {
|
|
54
|
+
async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, }) {
|
|
55
55
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
56
56
|
console.time(operationLabel);
|
|
57
57
|
console.log('Generating ' + em('Wexin MiniProgram') + ' to ' + projDir);
|
|
@@ -66,6 +66,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
66
66
|
isMixMode,
|
|
67
67
|
mainAppData,
|
|
68
68
|
domain,
|
|
69
|
+
isBrowserMpBuilder,
|
|
69
70
|
};
|
|
70
71
|
const yyptConfig = await (0, util_3.getYyptConfigInfo)(extraData);
|
|
71
72
|
const { appUsedComps, allAppUsedComps } = handleUsedComponents({
|
|
@@ -233,13 +234,14 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
}));
|
|
236
|
-
if (fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
237
|
+
if (!isBrowserMpBuilder && fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
237
238
|
await (0, webpack_1.installDependencies)(miniprogramRoot);
|
|
238
239
|
}
|
|
239
240
|
await handleMpPlugins();
|
|
240
241
|
console.timeEnd(operationLabel);
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
// web端的builder不需要清除
|
|
243
|
+
!isBrowserMpBuilder && cleanProj(weapps, miniprogramRoot);
|
|
244
|
+
!isBrowserMpBuilder && cleanMaterils(path_1.default.join(miniprogramRoot, config_1.materialsDirName), allAppUsedComps);
|
|
243
245
|
return { miniprogramRoot };
|
|
244
246
|
function resolveNpmDeps() {
|
|
245
247
|
var _a;
|
|
@@ -295,7 +297,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
295
297
|
// 清空历史文件,使用zip覆盖
|
|
296
298
|
console.log(`Removing ${appRoot}`);
|
|
297
299
|
await (0, generateFiles_1.cleanDir)(appRoot, ['materials']);
|
|
298
|
-
await (0, net_1.downloadZip)(weapp.mpPkgUrl, appRoot);
|
|
300
|
+
await (0, net_1.downloadZip)(weapp.mpPkgUrl, appRoot, ctx.isBrowserMpBuilder);
|
|
299
301
|
if (fs.existsSync(path_1.default.join(appRoot, '__MACOSX'))) {
|
|
300
302
|
await fs.remove(path_1.default.join(appRoot, '__MACOSX'));
|
|
301
303
|
}
|
|
@@ -18,9 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.getWxmlTag = exports.extractUsedCompsRecursively = exports.installMaterials = void 0;
|
|
26
23
|
const path = __importStar(require("path"));
|
|
@@ -32,14 +29,14 @@ const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
|
|
|
32
29
|
const util_2 = require("../util");
|
|
33
30
|
const util_3 = require("./util");
|
|
34
31
|
const wxml_1 = require("./wxml");
|
|
35
|
-
const generateFiles_1 =
|
|
32
|
+
const generateFiles_1 = __importStar(require("../util/generateFiles"));
|
|
36
33
|
const lowcode_1 = require("./lowcode");
|
|
37
34
|
const net_1 = require("../util/net");
|
|
38
35
|
const util_4 = require("../util");
|
|
39
36
|
const junk = __importStar(require("../util/junk"));
|
|
40
37
|
const templateDir = config_1.appTemplateDir + '/mp/';
|
|
41
38
|
async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
42
|
-
let { materialLibs } = ctx;
|
|
39
|
+
let { materialLibs, isBrowserMpBuilder } = ctx;
|
|
43
40
|
const weappsList = ctx.isMixMode
|
|
44
41
|
? weapps
|
|
45
42
|
: weapps.filter((item) => !item.rootPath);
|
|
@@ -58,7 +55,7 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
58
55
|
}
|
|
59
56
|
else {
|
|
60
57
|
materialsSrcDir = path.join(config_1.sharedMaterialsDir, `${name}-mp@${version}`);
|
|
61
|
-
await downloadMaterial(mpPkgUrl, materialsSrcDir);
|
|
58
|
+
await downloadMaterial(mpPkgUrl, materialsSrcDir, ctx.isBrowserMpBuilder);
|
|
62
59
|
}
|
|
63
60
|
function libUpdated(libDir, version) {
|
|
64
61
|
const meta = (0, util_4.readComponentLibMata)(libDir);
|
|
@@ -86,29 +83,30 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
86
83
|
if (libUpdated(targetDir, version)) {
|
|
87
84
|
const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
|
|
88
85
|
if (fs.existsSync(materialsSrcDirPath)) {
|
|
89
|
-
console.log(`Copying material ${materialId} from ${materialsSrcDir}/src to ${targetDir}`);
|
|
86
|
+
console.log(`Copying material ${materialId} from ${isBrowserMpBuilder ? materialsSrcDirPath : materialsSrcDir}/src to ${targetDir}`);
|
|
90
87
|
// #2 从根目录 copy meta 文件
|
|
91
88
|
const metaJosnPath = path.join(materialsSrcDir, 'meta.json');
|
|
92
89
|
if (fs.existsSync(metaJosnPath)) {
|
|
93
|
-
await fs.copy(metaJosnPath, path.join(targetDir, 'meta.json'));
|
|
90
|
+
!isBrowserMpBuilder ? await fs.copy(metaJosnPath, path.join(targetDir, 'meta.json')) : (0, generateFiles_1.copyRecursiveSync)(metaJosnPath, path.join(targetDir, 'meta.json'));
|
|
91
|
+
;
|
|
94
92
|
}
|
|
95
93
|
// #3 copy 组件库代码文件到项目目录
|
|
96
|
-
await fs.copy(materialsSrcDirPath, targetDir, {
|
|
94
|
+
!isBrowserMpBuilder ? await fs.copy(materialsSrcDirPath, targetDir, {
|
|
97
95
|
filter: function (src, dest) {
|
|
98
96
|
const path = src.split('/');
|
|
99
97
|
return !junk.is(path[path.length - 1]);
|
|
100
98
|
},
|
|
101
|
-
});
|
|
99
|
+
}) : (0, generateFiles_1.copyRecursiveSync)(materialsSrcDirPath, targetDir);
|
|
102
100
|
}
|
|
103
101
|
else {
|
|
104
102
|
console.log(`Copying material ${materialId} from ${materialsSrcDir} to ${targetDir}`);
|
|
105
103
|
// #2 link material to current project
|
|
106
|
-
await fs.copy(materialsSrcDir, targetDir, {
|
|
104
|
+
!isBrowserMpBuilder ? await fs.copy(materialsSrcDir, targetDir, {
|
|
107
105
|
filter: function (src, dest) {
|
|
108
106
|
const path = src.split('/');
|
|
109
107
|
return !junk.is(path[path.length - 1]);
|
|
110
108
|
},
|
|
111
|
-
});
|
|
109
|
+
}) : (0, generateFiles_1.copyRecursiveSync)(materialsSrcDir, targetDir);
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
const libMeta = (0, util_4.readComponentLibMata)(targetDir);
|
|
@@ -206,10 +204,10 @@ function extractUsedCompsRecursively(comps, checkedComps, compositedLibs, output
|
|
|
206
204
|
return usedComps;
|
|
207
205
|
}
|
|
208
206
|
exports.extractUsedCompsRecursively = extractUsedCompsRecursively;
|
|
209
|
-
async function downloadMaterial(zipUrl, dstFolder) {
|
|
207
|
+
async function downloadMaterial(zipUrl, dstFolder, isBrowser = false) {
|
|
210
208
|
if (fs.existsSync(path.join(dstFolder, 'meta.json')))
|
|
211
209
|
return;
|
|
212
|
-
await (0, net_1.downloadZip)(zipUrl, dstFolder);
|
|
210
|
+
await (0, net_1.downloadZip)(zipUrl, dstFolder, isBrowser);
|
|
213
211
|
}
|
|
214
212
|
async function generateCompositeComponent(compositedComp, ctx, compLibCommonResource) {
|
|
215
213
|
const { materialName } = compositedComp;
|
|
@@ -43,7 +43,7 @@ function generateMpConfig(weapps, ctx) {
|
|
|
43
43
|
};
|
|
44
44
|
const { miniprogramPlugins = [] } = ctx;
|
|
45
45
|
const projConfig = (0, lodash_1.merge)({}, mp_1.defaultProjConfig, {
|
|
46
|
-
projectname: 'WeDa-' + ctx.appId,
|
|
46
|
+
projectname: (ctx.mainAppData && ctx.mainAppData.label) || ('WeDa-' + ctx.appId),
|
|
47
47
|
});
|
|
48
48
|
const pageConfigs = weapps.map((app) => {
|
|
49
49
|
var _a;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getAllPageMpEntryPath = exports.getWebpackMpBuildParams = exports.getWebpackWebBuildParams = exports.getMpAllRouterConfig = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.generateMpJsonConfigFile = exports.generateKboneAppConfig = exports.generateKbonePageConfig = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateAppConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = void 0;
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
@@ -20,15 +19,6 @@ const config_2 = require("../config");
|
|
|
20
19
|
const common_2 = require("../util/common");
|
|
21
20
|
const types_1 = require("../../types");
|
|
22
21
|
const generateFiles_1 = require("../util/generateFiles");
|
|
23
|
-
let yarnExists = false;
|
|
24
|
-
try {
|
|
25
|
-
let { stdout } = cross_spawn_1.default.sync('yarn', ['-v']);
|
|
26
|
-
let str = stdout.toString();
|
|
27
|
-
if (Number((_a = str.split('.')) === null || _a === void 0 ? void 0 : _a[0]) <= 1) {
|
|
28
|
-
yarnExists = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) { }
|
|
32
22
|
async function fixAppJson(appBuildDir) {
|
|
33
23
|
const appJsonPath = path_1.default.resolve(appBuildDir, 'dist/mp/app.json');
|
|
34
24
|
if (!fs_extra_1.default.existsSync(appJsonPath)) {
|
|
@@ -407,6 +397,16 @@ async function downloadDependencies(targetDir, srcZipUrl) {
|
|
|
407
397
|
exports.downloadDependencies = downloadDependencies;
|
|
408
398
|
// TODO use yarn if installed
|
|
409
399
|
async function installDependencies(targetDir, options = {}) {
|
|
400
|
+
var _a;
|
|
401
|
+
let yarnExists = false;
|
|
402
|
+
try {
|
|
403
|
+
let { stdout } = cross_spawn_1.default.sync('yarn', ['-v']);
|
|
404
|
+
let str = stdout.toString();
|
|
405
|
+
if (Number((_a = str.split('.')) === null || _a === void 0 ? void 0 : _a[0]) <= 1) {
|
|
406
|
+
yarnExists = true;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
catch (e) { }
|
|
410
410
|
if ((options === null || options === void 0 ? void 0 : options.ignoreInstall) &&
|
|
411
411
|
fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'node_modules'))) {
|
|
412
412
|
console.log('ignore install dependencies in ' + targetDir);
|
|
@@ -57,11 +57,12 @@ function getSelfPackageJson() {
|
|
|
57
57
|
exports.getSelfPackageJson = getSelfPackageJson;
|
|
58
58
|
function JsonToStringWithVariableName(copyJson, options = {}) {
|
|
59
59
|
let variable = JSON.stringify(copyJson, null, 2).replace(/"%%%(.*?)%%%"/g, function (match, expression) {
|
|
60
|
-
return expression
|
|
60
|
+
return expression
|
|
61
|
+
.replace(/\\"/g, '"')
|
|
62
|
+
.replace(/\\'/g, "'")
|
|
63
|
+
.replace(/\\r/g, '\r')
|
|
64
|
+
.replace(/\\n/g, '\n');
|
|
61
65
|
});
|
|
62
|
-
if (options.EOL) {
|
|
63
|
-
variable = variable.replace(/\\n/g, '\n').replace(/\\r/g, '\r');
|
|
64
|
-
}
|
|
65
66
|
return variable;
|
|
66
67
|
}
|
|
67
68
|
exports.JsonToStringWithVariableName = JsonToStringWithVariableName;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { IBuildContext } from '../mp/BuildContext';
|
|
3
|
+
import { OutputType } from 'jszip';
|
|
2
4
|
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string, ctx: IBuildContext): Promise<string[]>;
|
|
3
5
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
4
6
|
export declare function removeFile(file: string): void;
|
|
@@ -14,3 +16,34 @@ export declare function cleanDir(dir: string, allowedFiles: string[]): void;
|
|
|
14
16
|
*/
|
|
15
17
|
export declare function copyFiles(copyFiles: string[], srcDir: string, dstDir: string): Promise<void[]>;
|
|
16
18
|
export declare function copy(src: string, dest: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 复制文件
|
|
21
|
+
* @param source 源文件
|
|
22
|
+
* @param target 目标文件
|
|
23
|
+
*/
|
|
24
|
+
export declare function copyFileSync(source: any, target: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* 根据源文件目录,输出目录,递归复制文件
|
|
27
|
+
* @param {string} src 源文件目录
|
|
28
|
+
* @param {string} dest 输出目录
|
|
29
|
+
*/
|
|
30
|
+
export declare const copyRecursiveSync: (src: any, dest: any) => void;
|
|
31
|
+
/**
|
|
32
|
+
* 返回指定目录的文件列表内容,返回map格式
|
|
33
|
+
* @param dir 指定目录
|
|
34
|
+
* @param files_ 文件列表
|
|
35
|
+
* @param replacePath 去掉前面路径
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export declare function getFiles(dir: string, files_: any, replacePath?: string): any;
|
|
39
|
+
/**
|
|
40
|
+
* 将文件压缩为zip包
|
|
41
|
+
* 参考JSZip例子:https://stuk.github.io/jszip/documentation/examples/download-zip-file.html
|
|
42
|
+
* @param files
|
|
43
|
+
* @param type
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export declare function fileToZip(files: {
|
|
47
|
+
[key: string]: Uint8Array;
|
|
48
|
+
}, type: OutputType): Promise<string | Buffer | Uint8Array | number[] | ArrayBuffer | Blob>;
|
|
49
|
+
export declare function strToBuf(str: any): Buffer;
|
|
@@ -22,12 +22,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.copy = exports.copyFiles = exports.cleanDir = exports.removeFile = exports.writeFile = void 0;
|
|
25
|
+
exports.strToBuf = exports.fileToZip = exports.getFiles = exports.copyRecursiveSync = exports.copyFileSync = exports.copy = exports.copyFiles = exports.cleanDir = exports.removeFile = exports.writeFile = void 0;
|
|
26
26
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
28
|
const lodash_template_1 = __importDefault(require("lodash.template"));
|
|
29
29
|
const junk = __importStar(require("../util/junk"));
|
|
30
30
|
const glob_1 = __importDefault(require("glob"));
|
|
31
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
32
|
+
const buffer_1 = require("buffer");
|
|
31
33
|
const generatedFileContents = {}; // generated files for incrmental build
|
|
32
34
|
async function generateFiles(appFileData, srcDir, dstDir, ctx) {
|
|
33
35
|
const filesGenerated = [];
|
|
@@ -120,3 +122,120 @@ async function copy(src, dest) {
|
|
|
120
122
|
await copyFiles(needCopyFiles, src, dest);
|
|
121
123
|
}
|
|
122
124
|
exports.copy = copy;
|
|
125
|
+
/**
|
|
126
|
+
* 复制文件
|
|
127
|
+
* @param source 源文件
|
|
128
|
+
* @param target 目标文件
|
|
129
|
+
*/
|
|
130
|
+
function copyFileSync(source, target) {
|
|
131
|
+
let targetFile = target;
|
|
132
|
+
// If target is a directory, a new file with the same name will be created
|
|
133
|
+
if (fs_extra_1.default.existsSync(target)) {
|
|
134
|
+
if (fs_extra_1.default.lstatSync(target).isDirectory()) {
|
|
135
|
+
targetFile = path_1.default.join(target, path_1.default.basename(source));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
fs_extra_1.default.writeFileSync(targetFile, fs_extra_1.default.readFileSync(source));
|
|
139
|
+
}
|
|
140
|
+
exports.copyFileSync = copyFileSync;
|
|
141
|
+
/**
|
|
142
|
+
* 根据源文件目录,输出目录,递归复制文件
|
|
143
|
+
* @param {string} src 源文件目录
|
|
144
|
+
* @param {string} dest 输出目录
|
|
145
|
+
*/
|
|
146
|
+
const copyRecursiveSync = function (src, dest) {
|
|
147
|
+
var exists = fs_extra_1.default.existsSync(src);
|
|
148
|
+
var stats = exists && fs_extra_1.default.statSync(src);
|
|
149
|
+
var isDirectory = exists && stats.isDirectory();
|
|
150
|
+
if (!fs_extra_1.default.existsSync(dest)) {
|
|
151
|
+
mkDirByPathSync(path_1.default.parse(dest).dir);
|
|
152
|
+
}
|
|
153
|
+
if (isDirectory) {
|
|
154
|
+
const files = fs_extra_1.default.readdirSync(src);
|
|
155
|
+
files.forEach(function (childItemName) {
|
|
156
|
+
(0, exports.copyRecursiveSync)(path_1.default.join(src, childItemName), path_1.default.join(dest, childItemName));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
copyFileSync(src, dest);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
exports.copyRecursiveSync = copyRecursiveSync;
|
|
164
|
+
/**
|
|
165
|
+
* 参考:https://stackoverflow.com/questions/31645738/how-to-create-full-path-with-nodes-fs-mkdirsync
|
|
166
|
+
* @param targetDir
|
|
167
|
+
* @param param1
|
|
168
|
+
* @returns
|
|
169
|
+
*/
|
|
170
|
+
function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) {
|
|
171
|
+
const sep = path_1.default.sep;
|
|
172
|
+
const initDir = path_1.default.isAbsolute(targetDir) ? sep : '';
|
|
173
|
+
const baseDir = isRelativeToScript ? __dirname : '.';
|
|
174
|
+
return targetDir.split(sep).reduce((parentDir, childDir) => {
|
|
175
|
+
const curDir = path_1.default.resolve(baseDir, parentDir, childDir);
|
|
176
|
+
try {
|
|
177
|
+
fs_extra_1.default.mkdirSync(curDir);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
if (err.code === 'EEXIST') { // curDir already exists!
|
|
181
|
+
return curDir;
|
|
182
|
+
}
|
|
183
|
+
// To avoid `EISDIR` error on Mac and `EACCES`-->`ENOENT` and `EPERM` on Windows.
|
|
184
|
+
if (err.code === 'ENOENT') { // Throw the original parentDir error on curDir `ENOENT` failure.
|
|
185
|
+
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
186
|
+
}
|
|
187
|
+
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
|
188
|
+
if (!caughtErr || caughtErr && curDir === path_1.default.resolve(targetDir)) {
|
|
189
|
+
throw err; // Throw if it's just the last created dir.
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return curDir;
|
|
193
|
+
}, initDir);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 返回指定目录的文件列表内容,返回map格式
|
|
197
|
+
* @param dir 指定目录
|
|
198
|
+
* @param files_ 文件列表
|
|
199
|
+
* @param replacePath 去掉前面路径
|
|
200
|
+
* @returns
|
|
201
|
+
*/
|
|
202
|
+
function getFiles(dir, files_, replacePath = '') {
|
|
203
|
+
files_ = files_ || {};
|
|
204
|
+
const files = fs_extra_1.default.readdirSync(dir);
|
|
205
|
+
let mapName;
|
|
206
|
+
for (let i in files) {
|
|
207
|
+
const name = path_1.default.join(dir, files[i]);
|
|
208
|
+
if (fs_extra_1.default.statSync(name).isDirectory()) {
|
|
209
|
+
getFiles(name, files_, replacePath);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
mapName = name;
|
|
213
|
+
// 替换根路径
|
|
214
|
+
if (name.indexOf(replacePath) === 0) {
|
|
215
|
+
mapName = name.replace(replacePath, '');
|
|
216
|
+
}
|
|
217
|
+
files_[mapName] = fs_extra_1.default.readFileSync(name);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return files_;
|
|
221
|
+
}
|
|
222
|
+
exports.getFiles = getFiles;
|
|
223
|
+
/**
|
|
224
|
+
* 将文件压缩为zip包
|
|
225
|
+
* 参考JSZip例子:https://stuk.github.io/jszip/documentation/examples/download-zip-file.html
|
|
226
|
+
* @param files
|
|
227
|
+
* @param type
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
async function fileToZip(files, type) {
|
|
231
|
+
var zip = new jszip_1.default();
|
|
232
|
+
for (let prop in files) {
|
|
233
|
+
zip.file(prop, files[prop]);
|
|
234
|
+
}
|
|
235
|
+
return zip.generateAsync({ type });
|
|
236
|
+
}
|
|
237
|
+
exports.fileToZip = fileToZip;
|
|
238
|
+
function strToBuf(str) {
|
|
239
|
+
return buffer_1.Buffer.from(str);
|
|
240
|
+
}
|
|
241
|
+
exports.strToBuf = strToBuf;
|
|
@@ -4,4 +4,23 @@ export declare function downloadFile(url: string, filePath: string): Promise<voi
|
|
|
4
4
|
* @param url
|
|
5
5
|
* @param dstDir folder to hold the extract zip content
|
|
6
6
|
*/
|
|
7
|
-
export declare function downloadZip(url: string, dstDir: string): Promise<void>;
|
|
7
|
+
export declare function downloadZip(url: string, dstDir: string, isBrowser?: boolean): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* node中下载和保存zip文件
|
|
10
|
+
* @param url 下载的url
|
|
11
|
+
* @param dstDir 存放文件夹
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadZipInNode(url: string, dstDir: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 浏览器中下载和保存zip文件
|
|
16
|
+
* @param url 下载的url
|
|
17
|
+
* @param dstDir 存放文件夹
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function downloadZipInBrowser(url: string, dstDir: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* 微信IDE builder需要下载template文件和miniprogram_npm
|
|
23
|
+
* miniprogram_npm待微信提供端能力
|
|
24
|
+
* @param output
|
|
25
|
+
*/
|
|
26
|
+
export declare function downloadBrowserMaterial(output?: string): Promise<void>;
|
package/lib/builder/util/net.js
CHANGED
|
@@ -22,11 +22,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.downloadZip = exports.downloadFile = void 0;
|
|
25
|
+
exports.downloadBrowserMaterial = exports.downloadZipInBrowser = exports.downloadZipInNode = exports.downloadZip = exports.downloadFile = void 0;
|
|
26
26
|
const axios_1 = __importDefault(require("axios"));
|
|
27
27
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const compressing_1 = __importDefault(require("compressing"));
|
|
30
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
31
|
+
const config_1 = require("../config");
|
|
32
|
+
const generateFiles_1 = require("../util/generateFiles");
|
|
30
33
|
async function downloadFile(url, filePath) {
|
|
31
34
|
await fs_extra_1.default.ensureDir(path.dirname(filePath));
|
|
32
35
|
const res = await axios_1.default.get(url, { responseType: 'stream' });
|
|
@@ -38,9 +41,75 @@ exports.downloadFile = downloadFile;
|
|
|
38
41
|
* @param url
|
|
39
42
|
* @param dstDir folder to hold the extract zip content
|
|
40
43
|
*/
|
|
41
|
-
async function downloadZip(url, dstDir) {
|
|
44
|
+
async function downloadZip(url, dstDir, isBrowser = false) {
|
|
45
|
+
// TODO 待加上平台判断
|
|
46
|
+
if (isBrowser) {
|
|
47
|
+
await downloadZipInBrowser(url, dstDir);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await downloadZipInNode(url, dstDir);
|
|
51
|
+
}
|
|
52
|
+
exports.downloadZip = downloadZip;
|
|
53
|
+
/**
|
|
54
|
+
* node中下载和保存zip文件
|
|
55
|
+
* @param url 下载的url
|
|
56
|
+
* @param dstDir 存放文件夹
|
|
57
|
+
*/
|
|
58
|
+
async function downloadZipInNode(url, dstDir) {
|
|
42
59
|
await fs_extra_1.default.ensureDir(dstDir);
|
|
43
60
|
const res = await axios_1.default.get(url, { responseType: 'stream' });
|
|
44
61
|
await compressing_1.default.zip.uncompress(res.data, dstDir);
|
|
45
62
|
}
|
|
46
|
-
exports.
|
|
63
|
+
exports.downloadZipInNode = downloadZipInNode;
|
|
64
|
+
/**
|
|
65
|
+
* 浏览器中下载和保存zip文件
|
|
66
|
+
* @param url 下载的url
|
|
67
|
+
* @param dstDir 存放文件夹
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
async function downloadZipInBrowser(url, dstDir) {
|
|
71
|
+
// IMPORTANT 防止保存的时候保存
|
|
72
|
+
if (fs_extra_1.default.existsSync(dstDir)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
fs_extra_1.default.ensureDirSync(dstDir);
|
|
76
|
+
const res = await axios_1.default.get(url, { responseType: 'arraybuffer' });
|
|
77
|
+
const data = await jszip_1.default.loadAsync(res.data);
|
|
78
|
+
await saveFiles(data.files, dstDir);
|
|
79
|
+
}
|
|
80
|
+
exports.downloadZipInBrowser = downloadZipInBrowser;
|
|
81
|
+
/**
|
|
82
|
+
* 保存JSZip解压的文件内容
|
|
83
|
+
* @param files 文件
|
|
84
|
+
* @param dstDir 指定目录
|
|
85
|
+
*/
|
|
86
|
+
async function saveFiles(files, dstDir) {
|
|
87
|
+
try {
|
|
88
|
+
for (const fileName of Object.keys(files)) {
|
|
89
|
+
const dest = path.join(dstDir, fileName);
|
|
90
|
+
if (files[fileName].dir) { // 如果该文件为目录需先创建文件夹
|
|
91
|
+
fs_extra_1.default.mkdirSync(dest, {
|
|
92
|
+
recursive: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const ret = await files[fileName].async('nodebuffer'); // 由于这里有await,不能用forEach
|
|
97
|
+
fs_extra_1.default.writeFileSync(dest, ret);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.error('saveFiles catch error:', err);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 微信IDE builder需要下载template文件和miniprogram_npm
|
|
107
|
+
* miniprogram_npm待微信提供端能力
|
|
108
|
+
* @param output
|
|
109
|
+
*/
|
|
110
|
+
async function downloadBrowserMaterial(output = '.weapps-build') {
|
|
111
|
+
await Promise.all([downloadZip(config_1.builderTemplateURL, config_1.appTemplateDir, true), downloadZip(config_1.miniprogramURL, config_1.miniprogramDir, true)]);
|
|
112
|
+
// 必须先下载到.weapps-materials目录,因为.weapps-materials是默认下载目录,共享组件逻辑sharedMaterialsDir时会读取文件
|
|
113
|
+
(0, generateFiles_1.copyRecursiveSync)(config_1.miniprogramDir, path.join(output, 'miniprogram_npm'));
|
|
114
|
+
}
|
|
115
|
+
exports.downloadBrowserMaterial = downloadBrowserMaterial;
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HISTORY_TYPE = exports.RUNTIME = exports.DEPLOY_MODE = void 0;
|
|
3
|
+
exports.PropBindType = exports.HISTORY_TYPE = exports.RUNTIME = exports.DEPLOY_MODE = void 0;
|
|
4
4
|
var DEPLOY_MODE;
|
|
5
5
|
(function (DEPLOY_MODE) {
|
|
6
6
|
DEPLOY_MODE["PREVIEW"] = "preview";
|
|
@@ -17,3 +17,5 @@ var HISTORY_TYPE;
|
|
|
17
17
|
HISTORY_TYPE["BROWSER"] = "BROWSER";
|
|
18
18
|
HISTORY_TYPE["HASH"] = "HASH";
|
|
19
19
|
})(HISTORY_TYPE = exports.HISTORY_TYPE || (exports.HISTORY_TYPE = {}));
|
|
20
|
+
var cals_1 = require("@cloudbase/cals");
|
|
21
|
+
Object.defineProperty(exports, "PropBindType", { enumerable: true, get: function () { return cals_1.PropBindType; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5-mp-beta",
|
|
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",
|
|
@@ -25,32 +25,43 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"dev": "tsc -w",
|
|
27
27
|
"develop": "tsc -w",
|
|
28
|
-
"build": "tsc",
|
|
28
|
+
"build": "rm -rf lib && tsc",
|
|
29
29
|
"test": "jest",
|
|
30
|
-
"test:build": "ts-node ./__test__/build.ts"
|
|
30
|
+
"test:build": "ts-node ./__test__/build.ts",
|
|
31
|
+
"dev:mpweb": "rm -rf dist && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/mpweb.config.js",
|
|
32
|
+
"build:mpweb": "rm -rf dist && cross-env NODE_ENV=production webpack --config ./webpack/mpweb.config.js"
|
|
31
33
|
},
|
|
32
34
|
"bugs": {
|
|
33
35
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@cloudbase/cals": "^0.3.3",
|
|
37
|
-
"@cloudbase/lowcode-generator": "
|
|
39
|
+
"@cloudbase/lowcode-generator": "0.4.22-mp-beta",
|
|
38
40
|
"axios": "^0.21.0",
|
|
41
|
+
"browserfs": "^1.4.3",
|
|
42
|
+
"browserify-zlib": "^0.2.0",
|
|
39
43
|
"chalk": "^2.4.2",
|
|
40
44
|
"compare-versions": "^3.6.0",
|
|
41
45
|
"compressing": "^1.4.0",
|
|
42
46
|
"cross-spawn": "^6.0.5",
|
|
43
47
|
"fs-extra": "^7.0.1",
|
|
48
|
+
"constants-browserify": "^1.0.0",
|
|
49
|
+
"crypto-browserify": "^3.12.0",
|
|
50
|
+
"jszip": "^3.7.1",
|
|
44
51
|
"lodash": "^4.17.11",
|
|
45
52
|
"lodash.clone": "^4.5.0",
|
|
46
53
|
"lodash.get": "^4.4.2",
|
|
47
54
|
"lodash.set": "^4.3.2",
|
|
48
55
|
"lodash.template": "^4.5.0",
|
|
49
56
|
"lodash.uniqby": "^4.7.0",
|
|
57
|
+
"os-browserify": "^0.3.0",
|
|
58
|
+
"stream-browserify": "^3.0.0",
|
|
50
59
|
"webpack": "^4.41.4",
|
|
51
60
|
"xml-js": "^1.6.11"
|
|
52
61
|
},
|
|
53
62
|
"devDependencies": {
|
|
63
|
+
"worker-loader": "^3.0.8",
|
|
64
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
54
65
|
"@types/archiver": "^3.1.0",
|
|
55
66
|
"@types/command-exists": "^1.2.0",
|
|
56
67
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -64,8 +75,10 @@
|
|
|
64
75
|
"@types/weixin-app": "^2.9.0",
|
|
65
76
|
"csstype": "^2.6.10",
|
|
66
77
|
"jest": "^26.0.1",
|
|
67
|
-
"ts-
|
|
78
|
+
"ts-loader": "^8.3.0",
|
|
68
79
|
"ts-node": "^10.4.0",
|
|
69
|
-
"typescript": "^4.4.2"
|
|
80
|
+
"typescript": "^4.4.2",
|
|
81
|
+
"webpack-cli": "^4.9.1",
|
|
82
|
+
"webpack-dev-server": "^4.7.3"
|
|
70
83
|
}
|
|
71
|
-
}
|
|
84
|
+
}
|
|
@@ -20,7 +20,9 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
|
|
|
20
20
|
key: '<%= l.key %>',
|
|
21
21
|
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else if (l.type === 'inline') {%> function({event, lists, forItems}, $comp){ <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
22
22
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
23
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($comp, lists, forItems, event) => {const $for=forItems;return
|
|
23
|
+
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($comp, lists, forItems, event) => {const $for=forItems;return (
|
|
24
|
+
<%= expr %>
|
|
25
|
+
)},
|
|
24
26
|
<%}) %>}
|
|
25
27
|
},<%})%>
|
|
26
28
|
],<%})%>
|
|
@@ -48,7 +50,9 @@ const handler = {<% handlers.forEach(h => {%>
|
|
|
48
50
|
|
|
49
51
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
50
52
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
51
|
-
<%= prop %>: function ($comp, lists, forItems, event) {const $for=forItems; return
|
|
53
|
+
<%= prop %>: function ($comp, lists, forItems, event) {const $for=forItems; return (
|
|
54
|
+
<%= expr %>
|
|
55
|
+
); },<% }) %>
|
|
52
56
|
},<%}) %>
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -17,14 +17,18 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
|
|
|
17
17
|
key: '<%= l.key %>',
|
|
18
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 if (l.type == 'inline') {%> function({event, lists, forItems}, $page){const $for = forItems; return <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
19
19
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
20
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($page, lists, forItems, event) => {const $for = forItems; return
|
|
20
|
+
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($page, lists, forItems, event) => {const $for = forItems; return (
|
|
21
|
+
<%= expr %>
|
|
22
|
+
)},
|
|
21
23
|
<%}) %>}
|
|
22
24
|
},<%})%>
|
|
23
25
|
],<%})%>
|
|
24
26
|
}
|
|
25
27
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
26
28
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
27
|
-
<%= prop %>: function ($page, lists, forItems, event) {const $for = forItems; return
|
|
29
|
+
<%= prop %>: function ($page, lists, forItems, event) {const $for = forItems; return (
|
|
30
|
+
<%= expr %>
|
|
31
|
+
); },<% }) %>
|
|
28
32
|
},<%}) %>
|
|
29
33
|
}
|
|
30
34
|
|