@cloudbase/framework-plugin-low-code 0.6.36 → 0.6.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/builder/mp/materials.d.ts.map +1 -1
- package/lib/builder/mp/materials.js +0 -80
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +48 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materials.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/materials.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EAIxB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,EAAE,EACpB,GAAG,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"materials.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/materials.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,uBAAuB,EAIxB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,EAAE,EACpB,GAAG,EAAE,aAAa,iBAoLnB;AAGD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,UAAU,EACjB,YAAY,EAAE,oBAAoB,EAAE,EACpC,cAAc,EAAE,aAAa,EAAE,EAC/B,WAAW,CAAC,EAAE,UAAU,cAsCzB;AA6ID,wBAAgB,UAAU,CACxB,GAAG,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,YAAY,CAAC,EACpD,GAAG,EAAE,aAAa,EAClB,WAAW,CAAC,EAAE,WAAW;;;;;;EA8D1B"}
|
|
@@ -86,17 +86,9 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
86
86
|
usingMaterialMap[targetDir] = true;
|
|
87
87
|
}
|
|
88
88
|
const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
|
|
89
|
-
const materialIndexJsonPath = path.join(materialsSrcDirPath, 'index.json');
|
|
90
|
-
const isCompGroupIndexJsonExist = fs.existsSync(materialIndexJsonPath);
|
|
91
89
|
let dirsToDelete = [];
|
|
92
90
|
let compGroupIndexJson = {};
|
|
93
91
|
let componentsJsonUsed = {};
|
|
94
|
-
if (isCompGroupIndexJsonExist) {
|
|
95
|
-
compGroupIndexJson = yield fs.readJSON(materialIndexJsonPath);
|
|
96
|
-
const result = yield getNotUsedMpComponentDirs(compGroupIndexJson.components, materialsSrcDirPath, targetDir, usedComps[name]);
|
|
97
|
-
dirsToDelete = result.dirsToDelete;
|
|
98
|
-
componentsJsonUsed = result.componentsJson;
|
|
99
|
-
}
|
|
100
92
|
if (libUpdated(targetDir, version)) {
|
|
101
93
|
if (fs.existsSync(materialsSrcDirPath)) {
|
|
102
94
|
console.log(`Copying material ${materialId} from ${materialsSrcDir}/src to ${targetDir}`);
|
|
@@ -119,12 +111,6 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
119
111
|
});
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
|
-
if (isCompGroupIndexJsonExist) {
|
|
123
|
-
yield fs.writeJSON(path.join(targetDir, 'index.json'), Object.assign(Object.assign({}, compGroupIndexJson), { components: componentsJsonUsed }), { spaces: 2 });
|
|
124
|
-
yield Promise.all(dirsToDelete.map((dir) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
fs.remove(dir);
|
|
126
|
-
})));
|
|
127
|
-
}
|
|
128
114
|
const libMeta = util_4.readComponentLibMata(targetDir);
|
|
129
115
|
if (!lib.components) {
|
|
130
116
|
lib.components = Object.keys((libMeta === null || libMeta === void 0 ? void 0 : libMeta.components) || {}).map((name) => {
|
|
@@ -350,69 +336,3 @@ function getWxmlTag(cmp, ctx, nameMangler) {
|
|
|
350
336
|
};
|
|
351
337
|
}
|
|
352
338
|
exports.getWxmlTag = getWxmlTag;
|
|
353
|
-
function getNotUsedMpComponentDirs(componentsPathMap, materialsSrcDirPath, targetDir, unsedCompsInGroup) {
|
|
354
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
355
|
-
const dirsToDelete = [];
|
|
356
|
-
const interalReferences = [];
|
|
357
|
-
const componentsJson = Object.keys(componentsPathMap).reduce((acc, compName) => {
|
|
358
|
-
const referencePath = componentsPathMap[compName];
|
|
359
|
-
if (unsedCompsInGroup.has(compName)) {
|
|
360
|
-
acc[compName] = referencePath;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
if (typeof referencePath === 'string') {
|
|
364
|
-
dirsToDelete.push(path.join(targetDir, path.dirname(referencePath)));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return acc;
|
|
368
|
-
}, {});
|
|
369
|
-
function guessDirFromPath(absReferencePath) {
|
|
370
|
-
if (fs.existsSync(path.join(absReferencePath, 'index.json'))) {
|
|
371
|
-
return absReferencePath;
|
|
372
|
-
}
|
|
373
|
-
if ((absReferencePath.endsWith('index') &&
|
|
374
|
-
fs.existsSync(absReferencePath + '.json')) ||
|
|
375
|
-
(absReferencePath.endsWith('index.json') &&
|
|
376
|
-
fs.existsSync(absReferencePath))) {
|
|
377
|
-
return path.dirname(absReferencePath);
|
|
378
|
-
}
|
|
379
|
-
return null;
|
|
380
|
-
}
|
|
381
|
-
const queue = [];
|
|
382
|
-
unsedCompsInGroup.forEach((compName) => {
|
|
383
|
-
const referencePath = componentsPathMap[compName];
|
|
384
|
-
if (typeof referencePath === 'string') {
|
|
385
|
-
const absCompDirPath = path.join(materialsSrcDirPath, path.dirname(referencePath));
|
|
386
|
-
queue.push(absCompDirPath);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
const visited = new Set();
|
|
390
|
-
while (queue.length > 0) {
|
|
391
|
-
const absCompDirPath = queue.shift();
|
|
392
|
-
if (visited.has(absCompDirPath)) {
|
|
393
|
-
continue;
|
|
394
|
-
}
|
|
395
|
-
visited.add(absCompDirPath);
|
|
396
|
-
const jsonPath = path.join(absCompDirPath, 'index.json');
|
|
397
|
-
const compIndexJson = yield fs.readJSON(jsonPath);
|
|
398
|
-
const usingComponents = compIndexJson.usingComponents;
|
|
399
|
-
if (typeof usingComponents === 'object' && Object.keys(usingComponents).length > 0) {
|
|
400
|
-
Object.values(usingComponents).forEach((referencePath) => {
|
|
401
|
-
if (referencePath.startsWith('.') || referencePath.startsWith('/')) {
|
|
402
|
-
const absReferencePath = path.join(absCompDirPath, referencePath);
|
|
403
|
-
const absInteralRefDirPath = guessDirFromPath(absReferencePath);
|
|
404
|
-
if (absInteralRefDirPath) {
|
|
405
|
-
interalReferences.push(absInteralRefDirPath.replace(materialsSrcDirPath, targetDir));
|
|
406
|
-
queue.push(absInteralRefDirPath);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
const result = {
|
|
413
|
-
componentsJson,
|
|
414
|
-
dirsToDelete: dirsToDelete.filter((i) => !interalReferences.includes(i)),
|
|
415
|
-
};
|
|
416
|
-
return result;
|
|
417
|
-
});
|
|
418
|
-
}
|
package/lib/index.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ declare class LowCodePlugin extends Plugin {
|
|
|
106
106
|
build(): Promise<string>;
|
|
107
107
|
compile(): Promise<any>;
|
|
108
108
|
deploy(): Promise<void>;
|
|
109
|
+
mpAnalyzeAndCleanCode(distDir: string): Promise<void>;
|
|
109
110
|
_getHostingInfoTask(envId: any, loose?: boolean): Promise<any[]>;
|
|
110
111
|
_getHostingInfo(envId: any, loose?: boolean): any;
|
|
111
112
|
_checkIsVersion(version: any): boolean;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,OAAO,EACL,SAAS,EAET,cAAc,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,OAAO,EACL,SAAS,EAET,cAAc,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYvD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAK7D,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,2BAA2B,IAAK,CAAC;AAoB9C,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC;AAEF,MAAM,WAAW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AAE,KAAK,GAAE,OAAe;IAqBnD,eAAe,CAAC,OAAO,KAAA;IAIjB,gBAAgB;IA4HhB,2BAA2B;IAuE3B,UAAU;IAwBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;IAejB,uBAAuB;IA2CvB,yBAAyB;CAyFhC;AAgCD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -59,6 +59,7 @@ const postProcess_1 = require("./utils/postProcess");
|
|
|
59
59
|
const lodash_1 = require("lodash");
|
|
60
60
|
const archiver_1 = __importDefault(require("archiver"));
|
|
61
61
|
const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
|
|
62
|
+
const mpci = __importStar(require("miniprogram-ci"));
|
|
62
63
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
63
64
|
const url_1 = __importDefault(require("url"));
|
|
64
65
|
const types_1 = require("./types");
|
|
@@ -484,6 +485,12 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
484
485
|
if (this._miniprogramePlugin) {
|
|
485
486
|
this._time("build mp plugin");
|
|
486
487
|
yield this._miniprogramePlugin.init();
|
|
488
|
+
try {
|
|
489
|
+
yield this.mpAnalyzeAndCleanCode(this._appPath);
|
|
490
|
+
}
|
|
491
|
+
catch (e) {
|
|
492
|
+
logger.info(`miniprogram stream line file: ${e}`);
|
|
493
|
+
}
|
|
487
494
|
yield this._miniprogramePlugin.build();
|
|
488
495
|
logger.debug(`miniprograme plugin build cost ${this._timeEnd("build mp plugin")}s`);
|
|
489
496
|
}
|
|
@@ -653,6 +660,47 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
653
660
|
return;
|
|
654
661
|
});
|
|
655
662
|
}
|
|
663
|
+
mpAnalyzeAndCleanCode(distDir) {
|
|
664
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
665
|
+
let { deployOptions } = this._resolvedInputs;
|
|
666
|
+
const project = new mpci.Project({
|
|
667
|
+
appid: deployOptions.mpAppId,
|
|
668
|
+
projectPath: distDir,
|
|
669
|
+
type: 'miniProgram',
|
|
670
|
+
privateKeyPath: `./private.${deployOptions.mpAppId}.key`,
|
|
671
|
+
});
|
|
672
|
+
const analyseRes = yield mpci.analyseCode(project);
|
|
673
|
+
if (analyseRes) {
|
|
674
|
+
const { files, modules } = analyseRes;
|
|
675
|
+
const allFiles = new Set();
|
|
676
|
+
const allUseedFiles = new Set();
|
|
677
|
+
files.forEach((f) => allFiles.add(f.path));
|
|
678
|
+
modules.forEach((m) => {
|
|
679
|
+
allUseedFiles.add(m.path);
|
|
680
|
+
m.deps.forEach((d) => {
|
|
681
|
+
if (d.path) {
|
|
682
|
+
allUseedFiles.add(d.path);
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
m.parentDeps.forEach((d) => {
|
|
686
|
+
if (d.path) {
|
|
687
|
+
allUseedFiles.add(d.path);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
if (allFiles.size !== allUseedFiles.size) {
|
|
692
|
+
const unusedFiles = [...allFiles].filter((f) => !allUseedFiles.has(f) && f.startsWith('materials/'));
|
|
693
|
+
this.api.logger.warn('-------------------', unusedFiles);
|
|
694
|
+
yield Promise.all(unusedFiles.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
695
|
+
yield fs_extra_1.default.remove(path_1.default.join(distDir, f));
|
|
696
|
+
})));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
this.api.logger.warn('小程序代码静态分析失败');
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
656
704
|
_getHostingInfoTask(envId, loose = false) {
|
|
657
705
|
return __awaiter(this, void 0, void 0, function* () {
|
|
658
706
|
let timeout = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.39",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"lodash.template": "^4.5.0",
|
|
59
59
|
"lodash.uniqby": "^4.7.0",
|
|
60
60
|
"merge-package-json": "^0.1.3",
|
|
61
|
-
"miniprogram-ci": "1.
|
|
61
|
+
"miniprogram-ci": "^1.8.0",
|
|
62
62
|
"postcss": "^8.3.6",
|
|
63
63
|
"postcss-pxtorem": "^6.0.0",
|
|
64
64
|
"prettier": "^2.0.5",
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
"jest": "^26.0.1",
|
|
88
88
|
"typescript": "^3.8.3"
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|