@cloudbase/framework-plugin-low-code 1.7.0 → 1.7.2
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/package.json +3 -3
- package/lib/builder/config/common.d.ts +0 -2
- package/lib/builder/config/common.d.ts.map +0 -1
- package/lib/builder/config/common.js +0 -13
- package/lib/builder/config/index.d.ts +0 -3
- package/lib/builder/config/index.d.ts.map +0 -1
- package/lib/builder/config/index.js +0 -29
- package/lib/builder/config/mp.d.ts +0 -2
- package/lib/builder/config/mp.d.ts.map +0 -1
- package/lib/builder/config/mp.js +0 -13
- package/lib/builder/core/copy.d.ts +0 -5
- package/lib/builder/core/copy.d.ts.map +0 -1
- package/lib/builder/core/copy.js +0 -62
- package/lib/builder/core/generate.d.ts +0 -9
- package/lib/builder/core/generate.d.ts.map +0 -1
- package/lib/builder/core/generate.js +0 -128
- package/lib/builder/core/index.d.ts +0 -32
- package/lib/builder/core/index.d.ts.map +0 -1
- package/lib/builder/core/index.js +0 -149
- package/lib/builder/core/material.d.ts +0 -4
- package/lib/builder/core/material.d.ts.map +0 -1
- package/lib/builder/core/material.js +0 -80
- package/lib/builder/core/plugin.d.ts +0 -4
- package/lib/builder/core/plugin.d.ts.map +0 -1
- package/lib/builder/core/plugin.js +0 -30
- package/lib/builder/core/prepare.d.ts +0 -8
- package/lib/builder/core/prepare.d.ts.map +0 -1
- package/lib/builder/core/prepare.js +0 -108
- package/lib/builder/core/webpack.d.ts +0 -15
- package/lib/builder/core/webpack.d.ts.map +0 -1
- package/lib/builder/core/webpack.js +0 -58
- package/lib/builder/mp/BuildContext.d.ts +0 -13
- package/lib/builder/mp/BuildContext.d.ts.map +0 -1
- package/lib/builder/mp/BuildContext.js +0 -2
- package/lib/builder/mp/index.d.ts +0 -33
- package/lib/builder/mp/index.d.ts.map +0 -1
- package/lib/builder/mp/index.js +0 -450
- package/lib/builder/mp/lowcode.d.ts +0 -8
- package/lib/builder/mp/lowcode.d.ts.map +0 -1
- package/lib/builder/mp/lowcode.js +0 -54
- package/lib/builder/mp/materials.d.ts +0 -15
- package/lib/builder/mp/materials.d.ts.map +0 -1
- package/lib/builder/mp/materials.js +0 -338
- package/lib/builder/mp/mixMode.d.ts +0 -10
- package/lib/builder/mp/mixMode.d.ts.map +0 -1
- package/lib/builder/mp/mixMode.js +0 -215
- package/lib/builder/mp/mp_config.d.ts +0 -18
- package/lib/builder/mp/mp_config.d.ts.map +0 -1
- package/lib/builder/mp/mp_config.js +0 -206
- package/lib/builder/mp/util.d.ts +0 -20
- package/lib/builder/mp/util.d.ts.map +0 -1
- package/lib/builder/mp/util.js +0 -243
- package/lib/builder/mp/wxml.d.ts +0 -16
- package/lib/builder/mp/wxml.d.ts.map +0 -1
- package/lib/builder/mp/wxml.js +0 -300
- package/lib/builder/service/builder/copy.d.ts +0 -14
- package/lib/builder/service/builder/copy.d.ts.map +0 -1
- package/lib/builder/service/builder/copy.js +0 -189
- package/lib/builder/service/builder/generate.d.ts +0 -52
- package/lib/builder/service/builder/generate.d.ts.map +0 -1
- package/lib/builder/service/builder/generate.js +0 -792
- package/lib/builder/service/builder/index.d.ts +0 -16
- package/lib/builder/service/builder/index.d.ts.map +0 -1
- package/lib/builder/service/builder/index.js +0 -69
- package/lib/builder/service/builder/plugin.d.ts +0 -8
- package/lib/builder/service/builder/plugin.d.ts.map +0 -1
- package/lib/builder/service/builder/plugin.js +0 -149
- package/lib/builder/service/builder/webpack.d.ts +0 -91
- package/lib/builder/service/builder/webpack.d.ts.map +0 -1
- package/lib/builder/service/builder/webpack.js +0 -589
- package/lib/builder/types/common.d.ts +0 -12
- package/lib/builder/types/common.d.ts.map +0 -1
- package/lib/builder/types/common.js +0 -7
- package/lib/builder/util/common.d.ts +0 -36
- package/lib/builder/util/common.d.ts.map +0 -1
- package/lib/builder/util/common.js +0 -257
- package/lib/builder/util/console.d.ts +0 -2
- package/lib/builder/util/console.d.ts.map +0 -1
- package/lib/builder/util/console.js +0 -13
- package/lib/builder/util/generateFiles.d.ts +0 -6
- package/lib/builder/util/generateFiles.d.ts.map +0 -1
- package/lib/builder/util/generateFiles.js +0 -94
- package/lib/builder/util/index.d.ts +0 -2
- package/lib/builder/util/index.d.ts.map +0 -1
- package/lib/builder/util/index.js +0 -13
- package/lib/builder/util/junk.d.ts +0 -3
- package/lib/builder/util/junk.d.ts.map +0 -1
- package/lib/builder/util/junk.js +0 -25
- package/lib/builder/util/mp.d.ts +0 -5
- package/lib/builder/util/mp.d.ts.map +0 -1
- package/lib/builder/util/mp.js +0 -99
- package/lib/builder/util/name-mangler.d.ts +0 -3
- package/lib/builder/util/name-mangler.d.ts.map +0 -1
- package/lib/builder/util/name-mangler.js +0 -7
- package/lib/builder/util/net.d.ts +0 -3
- package/lib/builder/util/net.d.ts.map +0 -1
- package/lib/builder/util/net.js +0 -54
- package/lib/builder/util/process.d.ts +0 -9
- package/lib/builder/util/process.d.ts.map +0 -1
- package/lib/builder/util/process.js +0 -28
- package/lib/builder/util/style.d.ts +0 -2
- package/lib/builder/util/style.d.ts.map +0 -1
- package/lib/builder/util/style.js +0 -13
- package/lib/builder/util/weapp.d.ts +0 -2
- package/lib/builder/util/weapp.d.ts.map +0 -1
- package/lib/builder/util/weapp.js +0 -13
- package/lib/config/private.d.ts +0 -3
- package/lib/config/private.d.ts.map +0 -1
- package/lib/config/private.js +0 -14
- package/lib/generate.d.ts +0 -2
- package/lib/generate.d.ts.map +0 -1
- package/lib/generate.js +0 -49
- package/lib/generator/config/common.d.ts +0 -6
- package/lib/generator/config/common.d.ts.map +0 -1
- package/lib/generator/config/common.js +0 -25
- package/lib/generator/config/index.d.ts +0 -18
- package/lib/generator/config/index.d.ts.map +0 -1
- package/lib/generator/config/index.js +0 -43
- package/lib/generator/config/mp.d.ts +0 -56
- package/lib/generator/config/mp.d.ts.map +0 -1
- package/lib/generator/config/mp.js +0 -104
- package/lib/generator/core/generate.d.ts +0 -59
- package/lib/generator/core/generate.d.ts.map +0 -1
- package/lib/generator/core/generate.js +0 -663
- package/lib/generator/core/index.d.ts +0 -25
- package/lib/generator/core/index.d.ts.map +0 -1
- package/lib/generator/core/index.js +0 -102
- package/lib/generator/core/material.d.ts +0 -14
- package/lib/generator/core/material.d.ts.map +0 -1
- package/lib/generator/core/material.js +0 -230
- package/lib/generator/template.d.ts +0 -3
- package/lib/generator/template.d.ts.map +0 -1
- package/lib/generator/template.js +0 -3
- package/lib/generator/types/common.d.ts +0 -69
- package/lib/generator/types/common.d.ts.map +0 -1
- package/lib/generator/types/common.js +0 -21
- package/lib/generator/util/common.d.ts +0 -36
- package/lib/generator/util/common.d.ts.map +0 -1
- package/lib/generator/util/common.js +0 -238
- package/lib/generator/util/console.d.ts +0 -3
- package/lib/generator/util/console.d.ts.map +0 -1
- package/lib/generator/util/console.js +0 -17
- package/lib/generator/util/index.d.ts +0 -2
- package/lib/generator/util/index.d.ts.map +0 -1
- package/lib/generator/util/index.js +0 -13
- package/lib/generator/util/name-mangler.d.ts +0 -17
- package/lib/generator/util/name-mangler.d.ts.map +0 -1
- package/lib/generator/util/name-mangler.js +0 -63
- package/lib/generator/util/postcss-rpx.d.ts +0 -11
- package/lib/generator/util/postcss-rpx.d.ts.map +0 -1
- package/lib/generator/util/postcss-rpx.js +0 -16
- package/lib/generator/util/style.d.ts +0 -6
- package/lib/generator/util/style.d.ts.map +0 -1
- package/lib/generator/util/style.js +0 -92
- package/lib/generator/util/weapp.d.ts +0 -5
- package/lib/generator/util/weapp.d.ts.map +0 -1
- package/lib/generator/util/weapp.js +0 -17
- package/lib/types.d.ts +0 -14
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -19
- package/lib/utils/dataSource.d.ts +0 -28
- package/lib/utils/dataSource.d.ts.map +0 -1
- package/lib/utils/dataSource.js +0 -171
- package/lib/utils/postProcess.d.ts +0 -3
- package/lib/utils/postProcess.d.ts.map +0 -1
- package/lib/utils/postProcess.js +0 -48
- package/lib/weapps-core/config/index.d.ts +0 -2
- package/lib/weapps-core/config/index.d.ts.map +0 -1
- package/lib/weapps-core/config/index.js +0 -13
- package/lib/weapps-core/config/style.d.ts +0 -7
- package/lib/weapps-core/config/style.d.ts.map +0 -1
- package/lib/weapps-core/config/style.js +0 -70
- package/lib/weapps-core/index.d.ts +0 -6
- package/lib/weapps-core/index.d.ts.map +0 -1
- package/lib/weapps-core/index.js +0 -31
- package/lib/weapps-core/types/action.d.ts +0 -25
- package/lib/weapps-core/types/action.d.ts.map +0 -1
- package/lib/weapps-core/types/action.js +0 -28
- package/lib/weapps-core/types/app.d.ts +0 -142
- package/lib/weapps-core/types/app.d.ts.map +0 -1
- package/lib/weapps-core/types/app.js +0 -21
- package/lib/weapps-core/types/appbuild.d.ts +0 -63
- package/lib/weapps-core/types/appbuild.d.ts.map +0 -1
- package/lib/weapps-core/types/appbuild.js +0 -78
- package/lib/weapps-core/types/code_types.d.ts +0 -26
- package/lib/weapps-core/types/code_types.d.ts.map +0 -1
- package/lib/weapps-core/types/code_types.js +0 -2
- package/lib/weapps-core/types/git.d.ts +0 -7
- package/lib/weapps-core/types/git.d.ts.map +0 -1
- package/lib/weapps-core/types/git.js +0 -2
- package/lib/weapps-core/types/index.d.ts +0 -11
- package/lib/weapps-core/types/index.d.ts.map +0 -1
- package/lib/weapps-core/types/index.js +0 -22
- package/lib/weapps-core/types/lowcode.d.ts +0 -26
- package/lib/weapps-core/types/lowcode.d.ts.map +0 -1
- package/lib/weapps-core/types/lowcode.js +0 -25
- package/lib/weapps-core/types/material.d.ts +0 -90
- package/lib/weapps-core/types/material.d.ts.map +0 -1
- package/lib/weapps-core/types/material.js +0 -9
- package/lib/weapps-core/types/plugins.d.ts +0 -17
- package/lib/weapps-core/types/plugins.d.ts.map +0 -1
- package/lib/weapps-core/types/plugins.js +0 -2
- package/lib/weapps-core/types/style.d.ts +0 -93
- package/lib/weapps-core/types/style.d.ts.map +0 -1
- package/lib/weapps-core/types/style.js +0 -2
- package/lib/weapps-core/types/web.d.ts +0 -120
- package/lib/weapps-core/types/web.d.ts.map +0 -1
- package/lib/weapps-core/types/web.js +0 -2
- package/lib/weapps-core/utils/appbuild.d.ts +0 -6
- package/lib/weapps-core/utils/appbuild.d.ts.map +0 -1
- package/lib/weapps-core/utils/appbuild.js +0 -40
- package/lib/weapps-core/utils/common.d.ts +0 -16
- package/lib/weapps-core/utils/common.d.ts.map +0 -1
- package/lib/weapps-core/utils/common.js +0 -90
- package/lib/weapps-core/utils/file.d.ts +0 -12
- package/lib/weapps-core/utils/file.d.ts.map +0 -1
- package/lib/weapps-core/utils/file.js +0 -142
- package/lib/weapps-core/utils/formily.d.ts +0 -5
- package/lib/weapps-core/utils/formily.d.ts.map +0 -1
- package/lib/weapps-core/utils/formily.js +0 -416
- package/lib/weapps-core/utils/index.d.ts +0 -7
- package/lib/weapps-core/utils/index.d.ts.map +0 -1
- package/lib/weapps-core/utils/index.js +0 -18
- package/lib/weapps-core/utils/lowcdoe.d.ts +0 -4
- package/lib/weapps-core/utils/lowcdoe.d.ts.map +0 -1
- package/lib/weapps-core/utils/lowcdoe.js +0 -69
- package/lib/weapps-core/utils/style.d.ts +0 -17
- package/lib/weapps-core/utils/style.d.ts.map +0 -1
- package/lib/weapps-core/utils/style.js +0 -330
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.getWxmlTag = exports.extractUsedCompsRecursively = exports.installMaterials = void 0;
|
|
35
|
-
const path = __importStar(require("path"));
|
|
36
|
-
const util_1 = require("util");
|
|
37
|
-
const fs = __importStar(require("fs-extra"));
|
|
38
|
-
const weapps_core_1 = require("../../weapps-core");
|
|
39
|
-
const config_1 = require("../config");
|
|
40
|
-
const mp_1 = require("../config/mp");
|
|
41
|
-
const util_2 = require("../util");
|
|
42
|
-
const util_3 = require("./util");
|
|
43
|
-
const wxml_1 = require("./wxml");
|
|
44
|
-
const generateFiles_1 = __importDefault(require("../util/generateFiles"));
|
|
45
|
-
const lowcode_1 = require("./lowcode");
|
|
46
|
-
const net_1 = require("../util/net");
|
|
47
|
-
const util_4 = require("../util");
|
|
48
|
-
const junk = __importStar(require("../util/junk"));
|
|
49
|
-
const templateDir = config_1.appTemplateDir + '/mp/';
|
|
50
|
-
function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
let { materialLibs } = ctx;
|
|
53
|
-
const weappsList = ctx.isMixMode
|
|
54
|
-
? weapps
|
|
55
|
-
: weapps.filter((item) => !item.rootPath);
|
|
56
|
-
const localPkg = (0, util_2.getCurrentPackageJson)();
|
|
57
|
-
yield Promise.all(materialLibs
|
|
58
|
-
.filter((lib) => !lib.isComposite && usedComps[lib.name])
|
|
59
|
-
.map((lib) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const { name, version, mpPkgUrl } = lib;
|
|
61
|
-
let materialsSrcDir = '';
|
|
62
|
-
const materialId = `${name}@${version}`;
|
|
63
|
-
if (localPkg && localPkg.name === name) {
|
|
64
|
-
materialsSrcDir = path.join(process.cwd(), 'build', 'mp');
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
materialsSrcDir = path.join(config_1.sharedMaterialsDir, `${name}-mp@${version}`);
|
|
68
|
-
yield downloadMaterial(mpPkgUrl, materialsSrcDir);
|
|
69
|
-
}
|
|
70
|
-
function libUpdated(libDir, version) {
|
|
71
|
-
const meta = (0, util_4.readComponentLibMata)(libDir);
|
|
72
|
-
if (!meta) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
if (meta.version !== lib.version) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const usingMaterialMap = {};
|
|
80
|
-
yield Promise.all(weappsList.map((app) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const targetDir = path.join(projDir, config_1.materialsDirName, name);
|
|
82
|
-
if (usingMaterialMap[targetDir]) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
usingMaterialMap[targetDir] = true;
|
|
87
|
-
}
|
|
88
|
-
const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
|
|
89
|
-
let dirsToDelete = [];
|
|
90
|
-
let compGroupIndexJson = {};
|
|
91
|
-
let componentsJsonUsed = {};
|
|
92
|
-
if (libUpdated(targetDir, version)) {
|
|
93
|
-
if (fs.existsSync(materialsSrcDirPath)) {
|
|
94
|
-
console.log(`Copying material ${materialId} from ${materialsSrcDir}/src to ${targetDir}`);
|
|
95
|
-
const metaJosnPath = path.join(materialsSrcDir, 'meta.json');
|
|
96
|
-
if (fs.existsSync(metaJosnPath)) {
|
|
97
|
-
yield fs.copy(metaJosnPath, path.join(targetDir, 'meta.json'));
|
|
98
|
-
}
|
|
99
|
-
yield fs.copy(materialsSrcDirPath, targetDir, {
|
|
100
|
-
filter: function (src, dest) {
|
|
101
|
-
return !junk.is(path.basename(src));
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.log(`Copying material ${materialId} from ${materialsSrcDir} to ${targetDir}`);
|
|
107
|
-
yield fs.copy(materialsSrcDir, targetDir, {
|
|
108
|
-
filter: function (src, dest) {
|
|
109
|
-
return !junk.is(path.basename(src));
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const libMeta = (0, util_4.readComponentLibMata)(targetDir);
|
|
115
|
-
if (!lib.components) {
|
|
116
|
-
lib.components = Object.keys((libMeta === null || libMeta === void 0 ? void 0 : libMeta.components) || {}).map((name) => {
|
|
117
|
-
var _a;
|
|
118
|
-
return ({
|
|
119
|
-
name,
|
|
120
|
-
meta: (_a = libMeta === null || libMeta === void 0 ? void 0 : libMeta.components[name]) === null || _a === void 0 ? void 0 : _a.meta,
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
lib.styles = libMeta === null || libMeta === void 0 ? void 0 : libMeta.styles;
|
|
125
|
-
lib.dependencies = libMeta === null || libMeta === void 0 ? void 0 : libMeta.dependencies;
|
|
126
|
-
})));
|
|
127
|
-
})));
|
|
128
|
-
materialLibs = ctx.materialLibs.filter((lib) => usedComps[lib.name]);
|
|
129
|
-
ctx.materialLibs = materialLibs;
|
|
130
|
-
materialLibs.map((lib) => {
|
|
131
|
-
lib.components = lib.components.filter((comp) => usedComps[lib.name].has(comp.name));
|
|
132
|
-
});
|
|
133
|
-
materialLibs.map((lib) => {
|
|
134
|
-
lib.components.map((comp) => {
|
|
135
|
-
comp.materialName = lib.name;
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
|
|
139
|
-
compositedLibs.map((lib) => {
|
|
140
|
-
lib.dependencies = lib.dependencies || {};
|
|
141
|
-
lib.components.map((cmp) => {
|
|
142
|
-
cmp.meta.syncProps = {};
|
|
143
|
-
const { dataForm = {} } = cmp;
|
|
144
|
-
for (const prop in dataForm) {
|
|
145
|
-
const { inputProp, syncProp } = dataForm[prop];
|
|
146
|
-
if (syncProp || inputProp) {
|
|
147
|
-
cmp.meta.syncProps[prop] = syncProp || inputProp;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
cmp.meta.platforms = {
|
|
151
|
-
mp: {
|
|
152
|
-
path: cmp.name + '/index',
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
lib.dependencies = Object.assign(Object.assign({}, lib.dependencies), cmp.npmDependencies);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
compositedLibs.map((lib) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
console.log('Generate composited library ' + lib.name);
|
|
160
|
-
yield (0, util_4.writeLibCommonRes2file)(lib, path.join(ctx.projDir, config_1.materialsDirName, lib.name, 'libCommonRes'));
|
|
161
|
-
return lib.components.map((cmp) => {
|
|
162
|
-
weappsList.forEach((app) => {
|
|
163
|
-
generateCompositeComponent(cmp, Object.assign({}, ctx), lib.compLibCommonResource);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}));
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
exports.installMaterials = installMaterials;
|
|
170
|
-
function extractUsedCompsRecursively(comps, checkedComps, compositedLibs, outputComps) {
|
|
171
|
-
let usedComps = (outputComps || comps);
|
|
172
|
-
const libsUsedByApp = Object.keys(comps);
|
|
173
|
-
libsUsedByApp.forEach((libName) => {
|
|
174
|
-
const cmpNames = comps[libName];
|
|
175
|
-
const lib = compositedLibs.find((lib) => lib.name == libName);
|
|
176
|
-
if (!lib || !lib.isComposite)
|
|
177
|
-
return;
|
|
178
|
-
cmpNames.forEach((cmpName) => {
|
|
179
|
-
const cmp = lib.components.find((c) => c.name === cmpName);
|
|
180
|
-
if (!cmp) {
|
|
181
|
-
console.warn('Component not found', libName + ':' + cmpName);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (checkedComps.indexOf(cmp) > -1)
|
|
185
|
-
return;
|
|
186
|
-
checkedComps.push(cmp);
|
|
187
|
-
const cmpsUsedByThisComp = (0, wxml_1.getUsedComponents)(cmp.componentInstances);
|
|
188
|
-
const libs = Object.keys(cmpsUsedByThisComp);
|
|
189
|
-
libs.forEach((libName) => {
|
|
190
|
-
if (!usedComps[libName]) {
|
|
191
|
-
usedComps[libName] = cmpsUsedByThisComp[libName];
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
cmpsUsedByThisComp[libName].forEach((n) => usedComps[libName].add(n));
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
extractUsedCompsRecursively(cmpsUsedByThisComp, checkedComps, compositedLibs, usedComps);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
return usedComps;
|
|
201
|
-
}
|
|
202
|
-
exports.extractUsedCompsRecursively = extractUsedCompsRecursively;
|
|
203
|
-
function downloadMaterial(zipUrl, dstFolder) {
|
|
204
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
if (fs.existsSync(path.join(dstFolder, 'meta.json')))
|
|
206
|
-
return;
|
|
207
|
-
yield (0, net_1.downloadZip)(zipUrl, dstFolder);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function generateCompositeComponent(compositedComp, ctx, compLibCommonResource) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
const { materialName } = compositedComp;
|
|
213
|
-
const outDir = path.join(ctx.projDir, ctx.rootPath || '', config_1.materialsDirName, materialName, compositedComp.name);
|
|
214
|
-
console.log(`Generating composited component ${materialName}:${compositedComp.name} to ${outDir}`);
|
|
215
|
-
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
216
|
-
const usingComponents = {};
|
|
217
|
-
const cmpContainer = Object.values(compositedComp.componentInstances)[0];
|
|
218
|
-
const wxml = (0, wxml_1.generateWxml)(compositedComp.componentInstances, 'Component ' + materialName + ':' + compositedComp.name, wxmlDataPrefix, Object.assign(Object.assign({}, ctx), { isPage: false }), usingComponents, (cmp, node) => {
|
|
219
|
-
if (cmp === cmpContainer) {
|
|
220
|
-
const { attributes } = node;
|
|
221
|
-
const classAttrName = (0, mp_1.getClassAttrName)(node.name);
|
|
222
|
-
const oldClass = attributes[classAttrName];
|
|
223
|
-
attributes[classAttrName] =
|
|
224
|
-
(0, weapps_core_1.getCompositedComponentClass)(compositedComp) +
|
|
225
|
-
' ' +
|
|
226
|
-
oldClass +
|
|
227
|
-
' {{className}}';
|
|
228
|
-
attributes.style += ';{{style}}';
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
const { syncProps } = compositedComp.meta;
|
|
232
|
-
const formEvents = {};
|
|
233
|
-
Object.keys(syncProps).map((prop) => {
|
|
234
|
-
const config = syncProps[prop];
|
|
235
|
-
const configs = Array.isArray(config) ? config : [config];
|
|
236
|
-
configs.forEach(({ changeEvent, valueFromEvent, isFormField }) => {
|
|
237
|
-
if (isFormField) {
|
|
238
|
-
formEvents[changeEvent] = valueFromEvent;
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
const pageFileData = {
|
|
243
|
-
'index.js': {
|
|
244
|
-
materialName: materialName,
|
|
245
|
-
propDefs: compositedComp.dataForm,
|
|
246
|
-
handlers: compositedComp.lowCodes
|
|
247
|
-
.filter((m) => m.type === 'handler-fn' && m.name !== '____index____')
|
|
248
|
-
.map((m) => m.name),
|
|
249
|
-
eventHandlers: (0, util_3.createEventHanlders)(compositedComp.componentInstances, weapps_core_1.COMPONENT_API_PREFIX, ctx),
|
|
250
|
-
emitEvents: compositedComp.emitEvents.map((evt) => evt.eventName),
|
|
251
|
-
widgetProps: (0, util_3.createWidgetProps)(compositedComp.componentInstances, ctx),
|
|
252
|
-
compApi: weapps_core_1.COMPONENT_API_PREFIX,
|
|
253
|
-
jsonSchemaType2jsClass: mp_1.jsonSchemaType2jsClass,
|
|
254
|
-
key: compositedComp.materialName + ':' + compositedComp.name,
|
|
255
|
-
dataBinds: (0, util_3.createDataBinds)(compositedComp.componentInstances, ctx),
|
|
256
|
-
debug: !ctx.isProduction,
|
|
257
|
-
stringifyObj: util_1.inspect,
|
|
258
|
-
formEvents: Object.keys(formEvents).length > 0 ? formEvents : null,
|
|
259
|
-
config: compositedComp.compConfig,
|
|
260
|
-
},
|
|
261
|
-
'index.json': { usingComponents },
|
|
262
|
-
'index.wxml': {
|
|
263
|
-
content: wxml,
|
|
264
|
-
},
|
|
265
|
-
'index.wxss': {},
|
|
266
|
-
};
|
|
267
|
-
yield (0, generateFiles_1.default)(pageFileData, templateDir + '/component', outDir, ctx);
|
|
268
|
-
const codes = [...compositedComp.lowCodes];
|
|
269
|
-
if (!codes.find((m) => m.name === 'index')) {
|
|
270
|
-
codes.push({
|
|
271
|
-
code: 'export default {}',
|
|
272
|
-
name: 'index',
|
|
273
|
-
path: 'index',
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
codes
|
|
277
|
-
.filter((mod) => mod.name !== '____index____')
|
|
278
|
-
.map((mod) => {
|
|
279
|
-
let themeCode;
|
|
280
|
-
if (mod.type === 'style' && compLibCommonResource) {
|
|
281
|
-
themeCode = `
|
|
282
|
-
${compLibCommonResource.theme.variable || ''}
|
|
283
|
-
${compLibCommonResource.class || ''}
|
|
284
|
-
${compLibCommonResource.theme.class || ''}
|
|
285
|
-
`;
|
|
286
|
-
}
|
|
287
|
-
return (0, lowcode_1.writeCode2file)(mod, path.join(outDir, 'lowcode'), { comp: compositedComp }, themeCode, ctx);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
function getWxmlTag(cmp, ctx, nameMangler) {
|
|
292
|
-
var _a, _b, _c, _d, _e, _f;
|
|
293
|
-
const { moduleName, name } = cmp;
|
|
294
|
-
const materialLib = ctx.materialLibs.find((lib) => lib.name === moduleName);
|
|
295
|
-
const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === moduleName);
|
|
296
|
-
let tagName = name.toLocaleUpperCase();
|
|
297
|
-
let compPath;
|
|
298
|
-
const components = (materialLib === null || materialLib === void 0 ? void 0 : materialLib.components) || (miniprogramPlugin === null || miniprogramPlugin === void 0 ? void 0 : miniprogramPlugin.componentConfigs);
|
|
299
|
-
const findComponent = components === null || components === void 0 ? void 0 : components.find((comp) => comp.name === name);
|
|
300
|
-
if (!findComponent) {
|
|
301
|
-
return { tagName };
|
|
302
|
-
}
|
|
303
|
-
if (materialLib) {
|
|
304
|
-
let cmpMeta = (findComponent === null || findComponent === void 0 ? void 0 : findComponent.meta) || { platforms: undefined };
|
|
305
|
-
if (!cmpMeta.platforms) {
|
|
306
|
-
return { tagName };
|
|
307
|
-
}
|
|
308
|
-
compPath = (_c = (_b = cmpMeta === null || cmpMeta === void 0 ? void 0 : cmpMeta.platforms) === null || _b === void 0 ? void 0 : _b.mp) === null || _c === void 0 ? void 0 : _c.path;
|
|
309
|
-
if ((_e = (_d = cmpMeta === null || cmpMeta === void 0 ? void 0 : cmpMeta.platforms) === null || _d === void 0 ? void 0 : _d.mp) === null || _e === void 0 ? void 0 : _e.tagName) {
|
|
310
|
-
tagName = (_f = cmpMeta === null || cmpMeta === void 0 ? void 0 : cmpMeta.platforms) === null || _f === void 0 ? void 0 : _f.mp.tagName;
|
|
311
|
-
}
|
|
312
|
-
if (compPath) {
|
|
313
|
-
const rootPath = ctx.rootPath || '';
|
|
314
|
-
compPath = compPath.startsWith('/')
|
|
315
|
-
? compPath
|
|
316
|
-
: path.posix.join('', `/${config_1.materialsDirName}/${cmp.moduleName}`, compPath);
|
|
317
|
-
tagName = `${moduleName}-${name}`;
|
|
318
|
-
if (nameMangler) {
|
|
319
|
-
tagName = nameMangler.mangle(tagName);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
compPath = `plugin://${miniprogramPlugin === null || miniprogramPlugin === void 0 ? void 0 : miniprogramPlugin.name}/${name}`;
|
|
325
|
-
tagName = `${moduleName}-${name}`;
|
|
326
|
-
if (nameMangler) {
|
|
327
|
-
tagName = nameMangler.mangle(tagName);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (!tagName) {
|
|
331
|
-
tagName = name.toLocaleUpperCase();
|
|
332
|
-
}
|
|
333
|
-
return {
|
|
334
|
-
tagName,
|
|
335
|
-
path: compPath,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
exports.getWxmlTag = getWxmlTag;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IWeAppData, IPlugin, IMaterialItem } from '../../weapps-core';
|
|
2
|
-
import { IAppUsedComp } from '../types/common';
|
|
3
|
-
export declare function handleMixMode({ apps, generateMpPath, miniprogramRoot, plugins, }: {
|
|
4
|
-
apps: IWeAppData[];
|
|
5
|
-
generateMpPath: string;
|
|
6
|
-
miniprogramRoot: string;
|
|
7
|
-
plugins: IPlugin[];
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
export declare function handleMixMaterials(projDir: string, apps: IWeAppData[], appUsedComps: IAppUsedComp[], compositedLibs: IMaterialItem[]): Promise<void[]>;
|
|
10
|
-
//# sourceMappingURL=mixMode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixMode.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/mixMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAUvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAO/C,wBAAsB,aAAa,CAAC,EAClC,IAAS,EACT,cAAc,EACd,eAAe,EACf,OAAY,GACb,EAAE;IACD,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,iBA6LA;AAGD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAAE,EAClB,YAAY,EAAE,YAAY,EAAE,EAC5B,cAAc,EAAE,aAAa,EAAE,mBA0ChC"}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.handleMixMaterials = exports.handleMixMode = void 0;
|
|
35
|
-
const path_1 = __importDefault(require("path"));
|
|
36
|
-
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
37
|
-
const mp_1 = require("../util/mp");
|
|
38
|
-
const plugin_1 = require("../service/builder/plugin");
|
|
39
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
40
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
-
const generateFiles_1 = require("../util/generateFiles");
|
|
42
|
-
const webpack_1 = require("../service/builder/webpack");
|
|
43
|
-
function handleMixMode({ apps = [], generateMpPath, miniprogramRoot, plugins = [], }) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
yield handleSubApps();
|
|
46
|
-
yield (0, webpack_1.installDependencies)(miniprogramRoot);
|
|
47
|
-
yield handlePlugins();
|
|
48
|
-
function handleMainApp() {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const aloneDirs = ['common', 'app', 'lowcode', 'materials'];
|
|
51
|
-
const dirs = aloneDirs;
|
|
52
|
-
yield Promise.all(dirs.map((dirname) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const srcDir = path_1.default.join(miniprogramRoot, dirname);
|
|
54
|
-
if (yield fs_extra_1.default.pathExists(srcDir)) {
|
|
55
|
-
const distDir = path_1.default.join(generateMpPath, dirname);
|
|
56
|
-
if (aloneDirs.includes(dirname)) {
|
|
57
|
-
yield fs_extra_1.default.remove(distDir);
|
|
58
|
-
}
|
|
59
|
-
yield fs_extra_1.default.copy(srcDir, distDir);
|
|
60
|
-
}
|
|
61
|
-
})));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function handleAppPages() {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const srcDir = path_1.default.join(miniprogramRoot, 'pages');
|
|
67
|
-
const distDir = path_1.default.join(generateMpPath, 'pages');
|
|
68
|
-
const pageList = yield fs_extra_1.default.readdir(srcDir);
|
|
69
|
-
yield Promise.all(pageList.map((page) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const srcPageDir = path_1.default.join(srcDir, page);
|
|
71
|
-
const srcDistDir = path_1.default.join(distDir, page);
|
|
72
|
-
if (yield fs_extra_1.default.pathExists(srcDistDir)) {
|
|
73
|
-
console.log(chalk_1.default.yellow(`【混合模式】 WeApps 中的 pages/${page} 与小程序 pages/${page} 重复,会以 WeApps 的为主`));
|
|
74
|
-
}
|
|
75
|
-
yield fs_extra_1.default.copy(srcPageDir, srcDistDir);
|
|
76
|
-
})));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function handleSubApps() {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
let modifiedAppJson = false;
|
|
82
|
-
const rootAppJosnPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
83
|
-
let rootAppJosn = yield fs_extra_1.default.readJSON(rootAppJosnPath);
|
|
84
|
-
let modifiedPackageJosn = false;
|
|
85
|
-
const rootPackageJosnPath = path_1.default.join(miniprogramRoot, 'package.json');
|
|
86
|
-
let rootPackageJson = fs_extra_1.default.existsSync(rootPackageJosnPath)
|
|
87
|
-
? yield fs_extra_1.default.readJson(rootPackageJosnPath)
|
|
88
|
-
: {
|
|
89
|
-
name: 'WeDa-app',
|
|
90
|
-
version: '1.0.0',
|
|
91
|
-
};
|
|
92
|
-
let mergeDependencies = {};
|
|
93
|
-
yield Promise.all(apps
|
|
94
|
-
.filter((app) => app.rootPath)
|
|
95
|
-
.map((app) => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const subAppPath = path_1.default.join(miniprogramRoot, app.rootPath || '');
|
|
97
|
-
const appJsonPath = path_1.default.join(subAppPath, 'app.json');
|
|
98
|
-
if (fs_extra_1.default.existsSync(appJsonPath)) {
|
|
99
|
-
let appJson = yield fs_extra_1.default.readJson(appJsonPath);
|
|
100
|
-
if (appJson) {
|
|
101
|
-
let { subpackages = [] } = rootAppJosn;
|
|
102
|
-
const find = subpackages.find((item) => item.root == app.rootPath);
|
|
103
|
-
if (find) {
|
|
104
|
-
find.pages = appJson.pages;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
if (!rootAppJosn.subpackages) {
|
|
108
|
-
rootAppJosn.subpackages = [];
|
|
109
|
-
}
|
|
110
|
-
rootAppJosn.subpackages.push({
|
|
111
|
-
root: app.rootPath,
|
|
112
|
-
pages: appJson.pages,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
modifiedAppJson = true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const packageJosnPath = path_1.default.join(subAppPath, 'package.json');
|
|
119
|
-
if (fs_extra_1.default.existsSync(packageJosnPath)) {
|
|
120
|
-
mergeDependencies = Object.assign(Object.assign({}, mergeDependencies), (yield (0, mp_1.mergePackageDependiences)(mergeDependencies, yield fs_extra_1.default.readJson(packageJosnPath))));
|
|
121
|
-
modifiedPackageJosn = true;
|
|
122
|
-
}
|
|
123
|
-
yield Promise.all([
|
|
124
|
-
'app.json',
|
|
125
|
-
'app.js',
|
|
126
|
-
'app.wxss',
|
|
127
|
-
'project.config.json',
|
|
128
|
-
'package.json',
|
|
129
|
-
'node_modules',
|
|
130
|
-
'miniprograme_npm',
|
|
131
|
-
].map((name) => {
|
|
132
|
-
let clearPath = path_1.default.join(subAppPath, name);
|
|
133
|
-
return name.includes('.')
|
|
134
|
-
? (0, generateFiles_1.removeFile)(clearPath)
|
|
135
|
-
: (0, generateFiles_1.cleanDir)(clearPath, []);
|
|
136
|
-
}));
|
|
137
|
-
})));
|
|
138
|
-
if (modifiedAppJson) {
|
|
139
|
-
yield (0, fs_extra_1.writeFile)(rootAppJosnPath, JSON.stringify(rootAppJosn, undefined, 2));
|
|
140
|
-
}
|
|
141
|
-
if (modifiedPackageJosn) {
|
|
142
|
-
yield (0, fs_extra_1.writeFile)(rootPackageJosnPath, JSON.stringify(Object.assign(Object.assign({}, rootPackageJson), (0, mp_1.mergePackageDependiences)(mergeDependencies, rootPackageJson)), undefined, 2));
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function handlePlugins() {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
const mpPlugins = (yield (0, plugin_1.getPluginType)(generateMpPath, plugins)).filter((item) => item.type === 'mp');
|
|
149
|
-
return Promise.all(mpPlugins.map((plugin) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const pluginModule = plugin.module;
|
|
151
|
-
const pluginNodeModuleDir = path_1.default.resolve(generateMpPath, 'node_modules', pluginModule);
|
|
152
|
-
const pluginPkgJson = yield fs_extra_1.default.readJson(path_1.default.join(pluginNodeModuleDir, 'package.json'));
|
|
153
|
-
const { pluginName } = pluginPkgJson;
|
|
154
|
-
const pluginDir = path_1.default.join(miniprogramRoot, pluginName);
|
|
155
|
-
const distDir = path_1.default.join(generateMpPath, pluginName);
|
|
156
|
-
yield fs_extra_1.default.copy(pluginDir, distDir, { overwrite: true });
|
|
157
|
-
})));
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function handleAppJson() {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const baseAppJsonPath = path_1.default.join(generateMpPath, 'app.json');
|
|
163
|
-
const mergeAppJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
164
|
-
yield (0, mp_1.mergePages)(baseAppJsonPath, mergeAppJsonPath);
|
|
165
|
-
yield (0, mp_1.mergeSubPackages)(baseAppJsonPath, mergeAppJsonPath);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function handlePkgJson() {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
const basePkgJsonPath = path_1.default.join(generateMpPath, 'package.json');
|
|
171
|
-
const mergePkgJsonPath = path_1.default.join(miniprogramRoot, 'package.json');
|
|
172
|
-
yield (0, mp_1.mergePackageJson)(basePkgJsonPath, mergePkgJsonPath);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
exports.handleMixMode = handleMixMode;
|
|
178
|
-
function handleMixMaterials(projDir, apps, appUsedComps, compositedLibs) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
return Promise.all(apps.map((app) => __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
var _a;
|
|
182
|
-
const rootPath = app.rootPath || '';
|
|
183
|
-
const materialsDirPath = path_1.default.join(projDir, rootPath, 'materials');
|
|
184
|
-
const usedComps = ((_a = appUsedComps.find((item) => item.rootPath === rootPath)) === null || _a === void 0 ? void 0 : _a.usedComps) ||
|
|
185
|
-
{};
|
|
186
|
-
const materialsLib = yield readDirs(materialsDirPath);
|
|
187
|
-
const cleanLibs = lodash_1.default.difference(materialsLib, Object.keys(usedComps));
|
|
188
|
-
yield removeDirs(cleanLibs.map((libName) => path_1.default.join(materialsDirPath, libName)));
|
|
189
|
-
yield Promise.all(Object.keys(usedComps).map((libName) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
if (!compositedLibs.find((item) => item.name === libName)) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const libComponents = usedComps[libName];
|
|
194
|
-
const materialsLibComps = yield readDirs(path_1.default.join(materialsDirPath, libName));
|
|
195
|
-
const cleanComps = lodash_1.default.difference(materialsLibComps, Array.from(libComponents));
|
|
196
|
-
yield removeDirs(cleanComps.map((compName) => path_1.default.join(materialsDirPath, libName, compName)));
|
|
197
|
-
})));
|
|
198
|
-
})));
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
exports.handleMixMaterials = handleMixMaterials;
|
|
202
|
-
function removeDirs(dirs) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
return Promise.all(dirs.map((dir) => {
|
|
205
|
-
console.log('【MIX MODE 清理】', dir);
|
|
206
|
-
return fs_extra_1.default.remove(dir);
|
|
207
|
-
}));
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function readDirs(dirPath) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
const isDirectory = (source) => (0, fs_extra_1.lstatSync)(source).isDirectory();
|
|
213
|
-
return ((yield fs_extra_1.default.readdir(dirPath)) || []).filter((name) => isDirectory(path_1.default.join(dirPath, name)));
|
|
214
|
-
});
|
|
215
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IWeAppData } from '../../weapps-core';
|
|
2
|
-
import { IBuildContext } from './BuildContext';
|
|
3
|
-
export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext): {
|
|
4
|
-
appConfig: any;
|
|
5
|
-
projConfig: any;
|
|
6
|
-
pageConfigs: {}[];
|
|
7
|
-
};
|
|
8
|
-
interface ISubpackage {
|
|
9
|
-
root: string;
|
|
10
|
-
pages?: string[];
|
|
11
|
-
plugins?: Record<string, {
|
|
12
|
-
version?: string;
|
|
13
|
-
provider?: string;
|
|
14
|
-
}>;
|
|
15
|
-
}
|
|
16
|
-
export declare function mergeSubPackages(base?: ISubpackage[], extra?: ISubpackage[]): ISubpackage[];
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=mp_config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mp_config.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/mp_config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAA8B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAW/C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,aAAa;;;;EAoGxE;AAyFD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,GAAE,WAAW,EAAO,EACxB,KAAK,GAAE,WAAW,EAAO,iBAoB1B"}
|