@cloudbase/lowcode-builder 1.8.89 → 1.8.91

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.
@@ -58,12 +58,8 @@ const templateDir = `${config_1.appTemplateDir}/mp/`;
58
58
  const em = chalk_1.default.blue.bold;
59
59
  const error = chalk_1.default.redBright;
60
60
  function patchBuildContext(ctx, calses) {
61
- var _a, _b;
62
61
  const { mainAppData } = ctx;
63
62
  const used = (0, cals_1.getUsedComps)(calses, ctx.materialLibs, { streamline: true, withAction: true });
64
- if ((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template']) {
65
- ctx.materialLibs = [...ctx.materialLibs, (0, cals_1.processTemplatesToDependiencies)((_b = calses === null || calses === void 0 ? void 0 : calses[0]) === null || _b === void 0 ? void 0 : _b.templates)];
66
- }
67
63
  /**
68
64
  * 修改 buildContext 进行 miniprogramPlugins 精简
69
65
  */
@@ -71,7 +67,7 @@ function patchBuildContext(ctx, calses) {
71
67
  return { used: used };
72
68
  }
73
69
  async function generateWxMp({ buildContext: _buildContext, weapps, calses, deployOptions, options, buildTypeList, ignoreInstall = false, cdnEndpoints = {}, mpConfig = {}, }) {
74
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
75
71
  const operationLabel = em('Wexin MiniProgram Generated');
76
72
  console.time(operationLabel);
77
73
  console.log(`Generating ${em('Wexin MiniProgram')} to ${_buildContext.projDir}`);
@@ -88,6 +84,26 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
88
84
  mpAppId: options.mpAppId,
89
85
  mpConfig,
90
86
  });
87
+ Object.values((appConfig === null || appConfig === void 0 ? void 0 : appConfig.usingComponents) || {}).forEach((path) => {
88
+ var _a;
89
+ const matched = path.match(new RegExp(`(?:\\.)?(?:\\/)?${config_1.materialsDirName}\\/\\$template\\/(.*)?\\/index`));
90
+ if (matched) {
91
+ const componentName = matched[1];
92
+ if (!((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template'])) {
93
+ used.component['$template'] = new Set();
94
+ }
95
+ used.component['$template'].add(componentName);
96
+ }
97
+ });
98
+ /**
99
+ * 此处逻辑分离自 patchBuildContext
100
+ * 因为 materialLibs 依赖 used 修正,used 依赖 generateMpConfig 后获取 appConfig 修正,generateMpConfig 有依赖 materialLibs 中源码组件库信息进行生成产生了循环
101
+ * 根据当前的逻辑牺牲封装在此继续修正
102
+ */
103
+ if ((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template']) {
104
+ const templateLib = (0, cals_1.processTemplatesToDependiencies)((_b = calses === null || calses === void 0 ? void 0 : calses[0]) === null || _b === void 0 ? void 0 : _b.templates);
105
+ _buildContext.materialLibs = [..._buildContext.materialLibs, templateLib];
106
+ }
91
107
  const { uin = '', appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = _buildContext;
92
108
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
93
109
  const hasLowcodePkg = weapps.find((item) => !item.mpPkgUrl);
@@ -132,7 +148,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
132
148
  endpointType,
133
149
  }, localWedaRoot);
134
150
  const expirationStartTimesnap = buildContext.enableExpiredTag ? Date.now() : 0;
135
- const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)((_b = (_a = calses[0]) === null || _a === void 0 ? void 0 : _a.theme) === null || _b === void 0 ? void 0 : _b.cssVarConfig, 'MP'))
151
+ const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)((_d = (_c = calses[0]) === null || _c === void 0 ? void 0 : _c.theme) === null || _d === void 0 ? void 0 : _d.cssVarConfig, 'MP'))
136
152
  .map(([key, _value]) => {
137
153
  const value = _value || '';
138
154
  return [key, value.replace(/;$/, '')];
@@ -142,8 +158,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
142
158
  return map;
143
159
  }, {}) || {};
144
160
  let customLoginConfig;
145
- let loginConfigPathname = ((_d = (_c = calses[0]) === null || _c === void 0 ? void 0 : _c.extra) === null || _d === void 0 ? void 0 : _d.loginConfigVersion)
146
- ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_f = (_e = calses[0]) === null || _e === void 0 ? void 0 : _e.extra) === null || _f === void 0 ? void 0 : _f.loginConfigVersion })
161
+ let loginConfigPathname = ((_f = (_e = calses[0]) === null || _e === void 0 ? void 0 : _e.extra) === null || _f === void 0 ? void 0 : _f.loginConfigVersion)
162
+ ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_h = (_g = calses[0]) === null || _g === void 0 ? void 0 : _g.extra) === null || _h === void 0 ? void 0 : _h.loginConfigVersion })
147
163
  : '';
148
164
  if (loginConfigPathname) {
149
165
  const url = `https://${domain}${loginConfigPathname}`;
@@ -165,8 +181,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
165
181
  expirationStartTimesnap,
166
182
  runtimeDynamicConfig: buildContext.runtimeDynamicConfig,
167
183
  RUNTIME_CONFIG_URL: index_1.RUNTIME_CONFIG_URL,
168
- loginConfigPathname: ((_h = (_g = calses[0]) === null || _g === void 0 ? void 0 : _g.extra) === null || _h === void 0 ? void 0 : _h.loginConfigVersion)
169
- ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_k = (_j = calses[0]) === null || _j === void 0 ? void 0 : _j.extra) === null || _k === void 0 ? void 0 : _k.loginConfigVersion })
184
+ loginConfigPathname: ((_k = (_j = calses[0]) === null || _j === void 0 ? void 0 : _j.extra) === null || _k === void 0 ? void 0 : _k.loginConfigVersion)
185
+ ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_m = (_l = calses[0]) === null || _l === void 0 ? void 0 : _l.extra) === null || _m === void 0 ? void 0 : _m.loginConfigVersion })
170
186
  : '',
171
187
  customLoginConfig: customLoginConfig ? JSON.stringify(customLoginConfig, undefined, 2) : 'null',
172
188
  },
@@ -220,9 +236,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
220
236
  appID: appId,
221
237
  resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
222
238
  isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
223
- clientID: ((_l = mainAppData.extra) === null || _l === void 0 ? void 0 : _l.enableLoginStatusShare)
239
+ clientID: ((_o = mainAppData.extra) === null || _o === void 0 ? void 0 : _o.enableLoginStatusShare)
224
240
  ? mainAppData.envId
225
- : (_m = mainAppData.extra) === null || _m === void 0 ? void 0 : _m.clientId,
241
+ : (_p = mainAppData.extra) === null || _p === void 0 ? void 0 : _p.clientId,
226
242
  cdnEndpoints,
227
243
  builderVersion: core_1.version || '',
228
244
  officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
@@ -272,8 +288,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
272
288
  projectConfigJson.setting = {
273
289
  ...projectConfigJson.setting,
274
290
  ...projConfig.setting,
275
- packNpmRelationList: ((_o = projConfig.setting) === null || _o === void 0 ? void 0 : _o.packNpmRelationList) || ((_p = projectConfigJson.setting) === null || _p === void 0 ? void 0 : _p.packNpmRelationList)
276
- ? (0, mp_config_1.mergePackNpmRelationList)(projConfig.setting.packNpmRelationList, (_q = projectConfigJson.setting) === null || _q === void 0 ? void 0 : _q.packNpmRelationList)
291
+ packNpmRelationList: ((_q = projConfig.setting) === null || _q === void 0 ? void 0 : _q.packNpmRelationList) || ((_r = projectConfigJson.setting) === null || _r === void 0 ? void 0 : _r.packNpmRelationList)
292
+ ? (0, mp_config_1.mergePackNpmRelationList)(projConfig.setting.packNpmRelationList, (_s = projectConfigJson.setting) === null || _s === void 0 ? void 0 : _s.packNpmRelationList)
277
293
  : undefined,
278
294
  };
279
295
  const wedaRoot = path_1.default.posix.join('./', projectConfigJson.miniprogramRoot || '/', projectConfigJson.wedaRoot || '');
@@ -291,9 +307,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
291
307
  let appJsContent = await fs.readFile(appJsPath);
292
308
  await (0, generateFiles_1.writeFile)(appJsPath, `import { app as wedaApp } from './${path_1.default.posix.join('./', projectConfigJson.wedaRoot, 'app/weapps-api')}'\n${appJsContent}`);
293
309
  }
294
- let appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
295
- let appJson = await fs.readJson(appJsonPath);
296
- appJson.subpackages = (0, mp_config_1.mergeSubPackages)(((_s = (_r = appJson.subpackages) === null || _r === void 0 ? void 0 : _r.filter) === null || _s === void 0 ? void 0 : _s.call(_r, (item) => item.name !== 'wd-sys-module' && item.name !== 'wd-sys-materials')) || [], appConfig.subpackages);
310
+ const appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
311
+ const appJson = await fs.readJson(appJsonPath);
312
+ appJson.subpackages = (0, mp_config_1.mergeSubPackages)(((_u = (_t = appJson.subpackages) === null || _t === void 0 ? void 0 : _t.filter) === null || _u === void 0 ? void 0 : _u.call(_t, (item) => item.name !== 'wd-sys-module' && item.name !== 'wd-sys-materials')) || [], appConfig.subpackages);
297
313
  await (0, generateFiles_1.writeFile)(appJsonPath, JSON.stringify(appJson, undefined, 2));
298
314
  }
299
315
  else {
@@ -104,7 +104,7 @@ async function generateMpConfig(ctx, weapps, calses, options) {
104
104
  .reduce((arr, lib) => {
105
105
  arr.push({
106
106
  type: 'file',
107
- value: path.posix.join(projConfig.wedaRoot || '', `materials/${lib.name}/meta.json`),
107
+ value: path.posix.join(projConfig.wedaRoot || '', `${config_1.materialsDirName}/${lib.name}/meta.json`),
108
108
  });
109
109
  return arr;
110
110
  }, []));