@cloudbase/framework-plugin-low-code 0.6.33 → 0.6.36

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.
@@ -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,iBAkNnB;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"}
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,iBAuMnB;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,20 +86,17 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
86
86
  usingMaterialMap[targetDir] = true;
87
87
  }
88
88
  const materialsSrcDirPath = path.join(materialsSrcDir, 'src');
89
- const compGroupIndexJson = yield fs.readJSON(path.join(materialsSrcDirPath, 'index.json'));
90
- const componentsPathMap = compGroupIndexJson.components;
91
- const dirsToDelete = [];
92
- const componentsJson = Object.keys(componentsPathMap).reduce((acc, compName) => {
93
- if (usedComps[name].has(compName)) {
94
- acc[compName] = componentsPathMap[compName];
95
- }
96
- else {
97
- if (typeof componentsPathMap[compName] === 'string') {
98
- dirsToDelete.push(path.join(targetDir, path.dirname(componentsPathMap[compName])));
99
- }
100
- }
101
- return acc;
102
- }, {});
89
+ const materialIndexJsonPath = path.join(materialsSrcDirPath, 'index.json');
90
+ const isCompGroupIndexJsonExist = fs.existsSync(materialIndexJsonPath);
91
+ let dirsToDelete = [];
92
+ let compGroupIndexJson = {};
93
+ 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
+ }
103
100
  if (libUpdated(targetDir, version)) {
104
101
  if (fs.existsSync(materialsSrcDirPath)) {
105
102
  console.log(`Copying material ${materialId} from ${materialsSrcDir}/src to ${targetDir}`);
@@ -122,10 +119,12 @@ function installMaterials(projDir, usedComps, weapps, ctx) {
122
119
  });
123
120
  }
124
121
  }
125
- yield fs.writeJSON(path.join(targetDir, 'index.json'), Object.assign(Object.assign({}, compGroupIndexJson), { components: componentsJson }), { spaces: 2 });
126
- yield Promise.all(dirsToDelete.map((dir) => __awaiter(this, void 0, void 0, function* () {
127
- fs.remove(dir);
128
- })));
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
+ }
129
128
  const libMeta = util_4.readComponentLibMata(targetDir);
130
129
  if (!lib.components) {
131
130
  lib.components = Object.keys((libMeta === null || libMeta === void 0 ? void 0 : libMeta.components) || {}).map((name) => {
@@ -351,3 +350,69 @@ function getWxmlTag(cmp, ctx, nameMangler) {
351
350
  };
352
351
  }
353
352
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.6.33",
3
+ "version": "0.6.36",
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",
@@ -247,6 +247,7 @@ module.exports = function (options) {
247
247
  options: {
248
248
  lessOptions: {
249
249
  modifyVars: themeVars,
250
+ javascriptEnabled: true,
250
251
  },
251
252
  },
252
253
  },