@cloudbase/framework-plugin-low-code 0.7.15 → 0.7.16

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":"index.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AAQzB,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE;IACD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B,GAAG,OAAO,CAAC;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAgSvC;AAuLD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,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vC;AAsJD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,iBAuB9F;AAiBD,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;;;EA6BA"}
@@ -81,7 +81,7 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
81
81
  weapps,
82
82
  materials,
83
83
  });
84
- buildContext['miniprogramPlugins'] = (mainAppData.miniprogramPlugins || []).filter((plugin) => allAppUsedComps[plugin.name]);
84
+ buildContext.miniprogramPlugins = (mainAppData.miniprogramPlugins || []).filter((plugin) => allAppUsedComps[plugin.name]);
85
85
  yield (0, materials_1.installMaterials)(projDir, allAppUsedComps, weapps, buildContext);
86
86
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
87
87
  const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(weapps, buildContext);
@@ -105,7 +105,7 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
105
105
  yield (0, generateFiles_1.writeFile)(appJsPath, `import { app as wedaApp } from './app/weapps-api'\n${appJsContent}`);
106
106
  }
107
107
  appFileData = Object.assign(Object.assign({}, appFileData), { 'common/style.js': {}, 'common/utils.wxs': {
108
- domain: domain,
108
+ domain,
109
109
  }, 'common/util.js': {
110
110
  isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
111
111
  }, 'common/widget.js': {}, 'common/url.js': {}, 'common/weapp-sdk.js': {}, 'common/weapp-page.js': {
@@ -128,11 +128,9 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
128
128
  yield (0, generateFiles_1.writeFile)(appJsonPath, JSON.stringify(appJson, undefined, 2));
129
129
  }
130
130
  else {
131
- appFileData = Object.assign(Object.assign({}, appFileData), { 'common/wx_yypt_report_v2.js': {}, 'app.js': { yyptConfig: yyptConfig }, 'app.json': { content: appConfig }, 'app.wxss': {
131
+ appFileData = Object.assign(Object.assign({}, appFileData), { 'common/wx_yypt_report_v2.js': {}, 'app.js': { yyptConfig }, 'app.json': { content: appConfig }, 'app.wxss': {
132
132
  importStyles: materials.reduce((styles, lib) => {
133
- styles = styles.concat((lib.styles || []).map((stylePath) => stylePath && !stylePath.startsWith('/')
134
- ? `/${config_1.materialsDirName}/${lib.name}/${stylePath}`
135
- : stylePath) || []);
133
+ styles = styles.concat((lib.styles || []).map((stylePath) => stylePath && !stylePath.startsWith('/') ? `/${config_1.materialsDirName}/${lib.name}/${stylePath}` : stylePath) || []);
136
134
  return styles;
137
135
  }, []),
138
136
  }, 'package.json': {
@@ -140,14 +138,10 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
140
138
  extraDeps: resolveNpmDeps(),
141
139
  } });
142
140
  }
143
- console.log('Generating ' + em('miniprogramRoot') + ' files');
141
+ console.log(`Generating ${em('miniprogramRoot')} files`);
144
142
  yield (0, generateFiles_1.default)(appFileData, templateDir, miniprogramRoot, buildContext);
145
- if (miniprogramRoot !== path_1.default.join(projDir, '/') &&
146
- fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
147
- console.log('Move ' +
148
- em(config_1.materialsDirName) +
149
- ' from' +
150
- `${projDir} to ${miniprogramRoot}`);
143
+ if (miniprogramRoot !== path_1.default.join(projDir, '/') && fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
144
+ console.log(`Move ${em(config_1.materialsDirName)} from` + `${projDir} to ${miniprogramRoot}`);
151
145
  yield fs.move(path_1.default.join(projDir, config_1.materialsDirName), path_1.default.join(miniprogramRoot, config_1.materialsDirName));
152
146
  }
153
147
  if (weapps.find((item) => !item.mpPkgUrl)) {
@@ -170,7 +164,7 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
170
164
  datasetProfiles: (0, util_3.JsonToStringWithVariableName)((0, dataSource_1.getDatasetProfiles)(mainAppData, weapps)),
171
165
  },
172
166
  };
173
- console.log('Generating ' + em('datasources') + ' files');
167
+ console.log(`Generating ${em('datasources')} files`);
174
168
  yield (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot, buildContext);
175
169
  }
176
170
  yield Promise.all(weapps.map((app, index) => __awaiter(this, void 0, void 0, function* () {
@@ -225,7 +219,7 @@ exports.generateWxMp = generateWxMp;
225
219
  function generatePkg(weapp, appRoot, ctx, pageConfigs) {
226
220
  return __awaiter(this, void 0, void 0, function* () {
227
221
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
228
- console.log('Generating ' + em(weapp.rootPath ? 'subApp' : 'app') + ' to ' + appRoot);
222
+ console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
229
223
  if (weapp.mpPkgUrl) {
230
224
  console.log(`Removing ${appRoot}`);
231
225
  yield (0, generateFiles_1.cleanDir)(appRoot, ['materials']);
@@ -235,7 +229,7 @@ function generatePkg(weapp, appRoot, ctx, pageConfigs) {
235
229
  }
236
230
  }
237
231
  else {
238
- console.log('Generating ' + em('page') + ' files');
232
+ console.log(`Generating ${em('page')} files`);
239
233
  (0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
240
234
  yield Promise.all(weapp.pageInstanceList.map((page) => __awaiter(this, void 0, void 0, function* () {
241
235
  var _a, _b;
@@ -251,12 +245,10 @@ function generatePkg(weapp, appRoot, ctx, pageConfigs) {
251
245
  pageSource: page.data.src || '',
252
246
  eventHanlders: (0, util_2.createEventHanlders)(page.componentInstances, '$page', ctx),
253
247
  dataBinds: (0, util_2.createDataBinds)(page.componentInstances, ctx),
254
- pageAttributes: Object.assign({}, (((_a = page.data) === null || _a === void 0 ? void 0 : _a.appShareMessage)
255
- ? { appShareMessage: page.data.appShareMessage.value }
256
- : {})),
248
+ pageAttributes: Object.assign({}, (((_a = page.data) === null || _a === void 0 ? void 0 : _a.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {})),
257
249
  debug: !ctx.isProduction,
258
250
  stringifyObj: util_1.inspect,
259
- subLevelPath: rootPath ? path_1.default.relative(rootPath, '') + '/' : '',
251
+ subLevelPath: rootPath ? `${path_1.default.relative(rootPath, '')}/` : '',
260
252
  },
261
253
  [`index.json|${pageFileName}.json`]: {
262
254
  usingComponents,
@@ -314,9 +306,7 @@ function generateFramework(appData, outDir, ctx) {
314
306
  fileData = Object.assign(Object.assign({}, fileData), { 'app/app-global.js': {}, 'app/weapps-api.js': {
315
307
  appId: ctx.appId,
316
308
  domain: ctx.domain || '',
317
- subLevelPath: appData.rootPath
318
- ? path_1.default.relative(`${appData.rootPath}`, '') + '/'
319
- : '',
309
+ subLevelPath: appData.rootPath ? `${path_1.default.relative(`${appData.rootPath}`, '')}/` : '',
320
310
  subPackageName: appData.rootPath || '',
321
311
  isBare: false,
322
312
  appConfig: (0, util_3.JsonToStringWithVariableName)({
@@ -367,12 +357,12 @@ exports.writeLowCodeFiles = writeLowCodeFiles;
367
357
  function getAppendableJson(json) {
368
358
  const obj = Object.assign({}, json);
369
359
  if (obj.reachBottomDistance) {
370
- obj.onReachBottomDistance = obj.reachBottomDistance;
360
+ obj.onReachBottomDistance = parseInt(obj.reachBottomDistance) || 0;
371
361
  delete obj.reachBottomDistance;
372
362
  }
373
363
  if (obj && Object.keys(obj).length > 0) {
374
364
  const str = JSON.stringify(obj);
375
- return ',\n' + str.substr(1, str.length - 2);
365
+ return `,\n${str.substr(1, str.length - 2)}`;
376
366
  }
377
367
  return '';
378
368
  }
@@ -388,10 +378,7 @@ function handleUsedComponents({ buildContext, weapps, materials, }) {
388
378
  });
389
379
  let allAppUsedComps = appUsedComps.reduce((comps, item) => {
390
380
  Object.keys(item.usedComps).forEach((libName) => {
391
- comps[libName] = new Set([
392
- ...Array.from(item.usedComps[libName]),
393
- ...Array.from(comps[libName] || []),
394
- ]);
381
+ comps[libName] = new Set([...Array.from(item.usedComps[libName]), ...Array.from(comps[libName] || [])]);
395
382
  });
396
383
  return comps;
397
384
  }, {});
@@ -419,9 +406,7 @@ function cleanPkg(pkg, miniprogramRoot) {
419
406
  if (pkg.mpPkgUrl) {
420
407
  return;
421
408
  }
422
- const pkgDir = [miniprogramRoot, pkg.rootPath]
423
- .filter((p) => !!p)
424
- .join(path_1.default.sep);
409
+ const pkgDir = [miniprogramRoot, pkg.rootPath].filter((p) => !!p).join(path_1.default.sep);
425
410
  const pagesDir = path_1.default.join(pkgDir, 'pages');
426
411
  const lowcodesDir = path_1.default.join(pkgDir, 'lowcode');
427
412
  const existedPages = yield fs.readdir(pagesDir);
@@ -436,13 +421,11 @@ function cleanPkg(pkg, miniprogramRoot) {
436
421
  }
437
422
  else {
438
423
  const handlersDir = path_1.default.join(lowcodeDir, 'handler');
439
- const handlers = ((_d = (_c = (_b = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.pageInstanceList) === null || _a === void 0 ? void 0 : _a.find((p) => p.id === pageName)) === null || _b === void 0 ? void 0 : _b.lowCodes) === null || _c === void 0 ? void 0 : _c.filter((m) => m.type === 'handler-fn')) === null || _d === void 0 ? void 0 : _d.map((m) => m.name + '.js')) || [];
424
+ const handlers = ((_d = (_c = (_b = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.pageInstanceList) === null || _a === void 0 ? void 0 : _a.find((p) => p.id === pageName)) === null || _b === void 0 ? void 0 : _b.lowCodes) === null || _c === void 0 ? void 0 : _c.filter((m) => m.type === 'handler-fn')) === null || _d === void 0 ? void 0 : _d.map((m) => `${m.name}.js`)) || [];
440
425
  (0, generateFiles_1.cleanDir)(handlersDir, handlers);
441
426
  }
442
427
  });
443
- const commonModules = pkg.lowCodes
444
- .filter((m) => m.type === 'normal-module')
445
- .map((m) => m.name + '.js');
428
+ const commonModules = pkg.lowCodes.filter((m) => m.type === 'normal-module').map((m) => `${m.name}.js`);
446
429
  const commonDir = path_1.default.join(lowcodesDir, 'common');
447
430
  (0, generateFiles_1.cleanDir)(commonDir, commonModules);
448
431
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
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",