@cloudbase/lowcode-builder 1.8.79 → 1.8.80

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.
@@ -59,7 +59,115 @@ exports.buildWedaConfig = buildWedaConfig;
59
59
  async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appKey = 'test', runtime = types_1.RUNTIME.NONE, ignoreInstall = false, buildTypeList = [common_1.BuildType.WEB], mode = common_1.WebpackModeType.PRODUCTION, devTool = 'webpack', deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, generateMpType = common_1.GenerateMpType.APP, plugins = [], extraData = {
60
60
  isComposite: false,
61
61
  compProps: {},
62
- }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {}, }, cb) {
62
+ }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {
63
+ projectConfigJson: {
64
+ wedaRoot: '$weda_root',
65
+ miniprogramRoot: 'miniprogram/',
66
+ cloudfunctionRoot: 'cloudfunctions/',
67
+ setting: {
68
+ urlCheck: true,
69
+ es6: true,
70
+ enhance: true,
71
+ postcss: true,
72
+ preloadBackgroundData: false,
73
+ minified: true,
74
+ newFeature: true,
75
+ coverView: true,
76
+ nodeModules: false,
77
+ autoAudits: false,
78
+ showShadowRootInWxmlPanel: true,
79
+ scopeDataCheck: false,
80
+ uglifyFileName: false,
81
+ checkInvalidKey: true,
82
+ checkSiteMap: true,
83
+ uploadWithSourceMap: true,
84
+ compileHotReLoad: false,
85
+ useMultiFrameRuntime: true,
86
+ useApiHook: true,
87
+ useApiHostProcess: true,
88
+ babelSetting: {
89
+ ignore: [],
90
+ disablePlugins: [],
91
+ outputPath: '',
92
+ },
93
+ enableEngineNative: false,
94
+ useIsolateContext: true,
95
+ useCompilerModule: true,
96
+ userConfirmedUseCompilerModuleSwitch: false,
97
+ userConfirmedBundleSwitch: false,
98
+ packNpmManually: false,
99
+ packNpmRelationList: [
100
+ {
101
+ packageJsonPath: 'miniprogram/$weda_root/package.json',
102
+ miniprogramNpmDistDir: '232miniprogram/$weda_root',
103
+ },
104
+ {
105
+ packageJsonPath: 'miniprogram/$weda_root/packages/$wd_system/package.json',
106
+ miniprogramNpmDistDir: '2323miniprogram/$weda_root/packages/$wd_system',
107
+ },
108
+ {
109
+ packageJsonPath: '111$weda_root/package.json',
110
+ miniprogramNpmDistDir: '$weda_root',
111
+ },
112
+ {
113
+ packageJsonPath: '/$weda_root/packages/$wd_system/package.json',
114
+ miniprogramNpmDistDir: '$weda_root/packages/$wd_system',
115
+ },
116
+ ],
117
+ minifyWXSS: true,
118
+ },
119
+ appid: 'wxcf5102ada68a7ac9',
120
+ projectname: 'quickstart-wx-cloud',
121
+ libVersion: '2.20.1',
122
+ cloudfunctionTemplateRoot: 'cloudfunctionTemplate/',
123
+ condition: {
124
+ search: {
125
+ list: [],
126
+ },
127
+ conversation: {
128
+ list: [],
129
+ },
130
+ plugin: {
131
+ list: [],
132
+ },
133
+ game: {
134
+ list: [],
135
+ },
136
+ miniprogram: {
137
+ list: [
138
+ {
139
+ id: -1,
140
+ name: 'db guide',
141
+ pathName: 'pages/databaseGuide/databaseGuide',
142
+ },
143
+ ],
144
+ },
145
+ },
146
+ compileType: 'miniprogram',
147
+ srcMiniprogramRoot: 'miniprogram/',
148
+ packOptions: {
149
+ ignore: [],
150
+ include: [],
151
+ },
152
+ editorSetting: {
153
+ tabIndent: 'auto',
154
+ tabSize: 2,
155
+ },
156
+ },
157
+ appJson: {
158
+ pages: [],
159
+ window: {
160
+ backgroundColor: '#F6F6F6',
161
+ backgroundTextStyle: 'light',
162
+ navigationBarBackgroundColor: '#F6F6F6',
163
+ navigationBarTitleText: '云开发 QuickStart',
164
+ navigationBarTextStyle: 'black',
165
+ },
166
+ sitemapLocation: 'sitemap.json',
167
+ style: 'v2',
168
+ lazyCodeLoading: 'requiredComponents',
169
+ },
170
+ }, }, cb) {
63
171
  var _a, _b, _c, _d, _e, _f;
64
172
  if (!cals) {
65
173
  console.error('无效的应用配置');
@@ -53,6 +53,7 @@ const core_1 = require("../core");
53
53
  const theme_1 = require("../../utils/theme");
54
54
  const index_1 = require("../config/index");
55
55
  const mixMode_1 = require("./mixMode");
56
+ const axios_1 = __importDefault(require("axios"));
56
57
  const templateDir = `${config_1.appTemplateDir}/mp/`;
57
58
  const em = chalk_1.default.blue.bold;
58
59
  const error = chalk_1.default.redBright;
@@ -70,7 +71,7 @@ function patchBuildContext(ctx, calses) {
70
71
  return { used: used };
71
72
  }
72
73
  async function generateWxMp({ buildContext: _buildContext, weapps, calses, deployOptions, options, buildTypeList, ignoreInstall = false, cdnEndpoints = {}, mpConfig = {}, }) {
73
- var _a, _b, _c, _d;
74
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
74
75
  const operationLabel = em('Wexin MiniProgram Generated');
75
76
  console.time(operationLabel);
76
77
  console.log(`Generating ${em('Wexin MiniProgram')} to ${_buildContext.projDir}`);
@@ -140,6 +141,22 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
140
141
  map[key] = value;
141
142
  return map;
142
143
  }, {}) || {};
144
+ 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 })
147
+ : '';
148
+ if (loginConfigPathname) {
149
+ const url = `https://${domain}${loginConfigPathname}`;
150
+ try {
151
+ const { data } = await axios_1.default.get(url, { responseType: 'json' });
152
+ if (data) {
153
+ customLoginConfig = data;
154
+ }
155
+ }
156
+ catch (e) {
157
+ console.error('预置获取登录配置失败:', url, e);
158
+ }
159
+ }
143
160
  const wedaRootFileData = {
144
161
  'common/style.js': {},
145
162
  'common/util.js': {
@@ -148,6 +165,10 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
148
165
  expirationStartTimesnap,
149
166
  runtimeDynamicConfig: buildContext.runtimeDynamicConfig,
150
167
  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 })
170
+ : '',
171
+ customLoginConfig: customLoginConfig ? JSON.stringify(customLoginConfig, undefined, 2) : 'null',
151
172
  },
152
173
  'common/widget.js': {},
153
174
  'common/weapp-page.js': {
@@ -199,9 +220,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
199
220
  appID: appId,
200
221
  resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
201
222
  isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
202
- clientID: ((_c = mainAppData.extra) === null || _c === void 0 ? void 0 : _c.enableLoginStatusShare)
223
+ clientID: ((_l = mainAppData.extra) === null || _l === void 0 ? void 0 : _l.enableLoginStatusShare)
203
224
  ? mainAppData.envId
204
- : (_d = mainAppData.extra) === null || _d === void 0 ? void 0 : _d.clientId,
225
+ : (_m = mainAppData.extra) === null || _m === void 0 ? void 0 : _m.clientId,
205
226
  cdnEndpoints,
206
227
  builderVersion: core_1.version || '',
207
228
  officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
@@ -242,6 +263,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
242
263
  projectConfigJson.setting = {
243
264
  ...projectConfigJson.setting,
244
265
  ...projConfig.setting,
266
+ packNpmRelationList: ((_o = projConfig.setting) === null || _o === void 0 ? void 0 : _o.packNpmRelationList) || ((_p = projectConfigJson.setting) === null || _p === void 0 ? void 0 : _p.packNpmRelationList)
267
+ ? (0, mp_config_1.mergePackNpmRelationList)(projConfig.setting.packNpmRelationList, (_q = projectConfigJson.setting) === null || _q === void 0 ? void 0 : _q.packNpmRelationList)
268
+ : undefined,
245
269
  };
246
270
  const wedaRoot = path_1.default.posix.join('./', projectConfigJson.miniprogramRoot || '/', projectConfigJson.wedaRoot || '');
247
271
  if (!projectConfigJson.setting.packNpmManually) {
@@ -250,22 +274,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
250
274
  if (!projectConfigJson.setting.packNpmRelationList) {
251
275
  projectConfigJson.setting.packNpmRelationList = [];
252
276
  }
253
- projectConfigJson.setting.packNpmRelationList = [
254
- ...projectConfigJson.setting.packNpmRelationList.filter((item) => [
255
- './package.json',
256
- '/package.json',
257
- './packages/$wd_system/package.json',
258
- '/packages/$wd_system/package.json',
259
- ].includes(item.packageJsonPath)),
260
- {
261
- packageJsonPath: `./${path_1.default.posix.join(wedaRoot, 'package.json')}`,
262
- miniprogramNpmDistDir: `./${wedaRoot}`,
263
- },
264
- {
265
- packageJsonPath: `./${path_1.default.posix.join(wedaRoot, 'packages', '$wd_system', 'package.json')}`,
266
- miniprogramNpmDistDir: `./${path_1.default.posix.join(wedaRoot, 'packages', '$wd_system')}`,
267
- },
268
- ];
277
+ projectConfigJson.setting.packNpmRelationList = (0, mp_config_1.mergePackNpmRelationList)((0, mp_config_1.generateSystemPackNpmRelationList)(wedaRoot), projectConfigJson.setting.packNpmRelationList);
269
278
  await (0, generateFiles_1.writeFile)(projectConfigJsonPath, JSON.stringify(projectConfigJson, undefined, 2));
270
279
  // 有了 framework app 之后,并且是源码的方式,追加 app 引用
271
280
  if (hasLowcodePkg) {
@@ -24,4 +24,18 @@ interface ISubpackage {
24
24
  }>;
25
25
  }
26
26
  export declare function mergeSubPackages(base?: ISubpackage[], extra?: ISubpackage[]): ISubpackage[];
27
+ export declare function mergePackNpmRelationList(base?: {
28
+ packageJsonPath: string;
29
+ miniprogramNpmDistDir: string;
30
+ }[], extra?: {
31
+ packageJsonPath: string;
32
+ miniprogramNpmDistDir: string;
33
+ }[]): {
34
+ packageJsonPath: string;
35
+ miniprogramNpmDistDir: string;
36
+ }[];
37
+ export declare function generateSystemPackNpmRelationList(wedaRootProjectPath: any): {
38
+ packageJsonPath: string;
39
+ miniprogramNpmDistDir: any;
40
+ }[];
27
41
  export {};
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.mergeSubPackages = exports.generateMpConfig = void 0;
29
+ exports.generateSystemPackNpmRelationList = exports.mergePackNpmRelationList = exports.mergeSubPackages = exports.generateMpConfig = void 0;
30
30
  const path = __importStar(require("path"));
31
31
  const lodash_1 = require("lodash");
32
32
  const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
@@ -42,7 +42,7 @@ const util_1 = require("../util");
42
42
  * @param appConfigs app config from prop edit panel
43
43
  */
44
44
  function generateMpConfig(ctx, weapps, options) {
45
- var _a;
45
+ var _a, _b, _c;
46
46
  const appConfig = {
47
47
  useExtendedLib: { weui: true },
48
48
  };
@@ -69,7 +69,15 @@ function generateMpConfig(ctx, weapps, options) {
69
69
  // keep main app config only, ignore subapp config
70
70
  const configs = (kbConfig ? [eval(`(${kbConfig.code.replace(/export\s+default/, '')})`)] : []).concat([
71
71
  { appJson: mainAppConfig },
72
- options.mpConfig,
72
+ {
73
+ ...options.mpConfig,
74
+ appJson: ((_b = options.mpConfig) === null || _b === void 0 ? void 0 : _b.appJson)
75
+ ? {
76
+ ...(_c = options.mpConfig) === null || _c === void 0 ? void 0 : _c.appJson,
77
+ sitemapLocation: undefined,
78
+ }
79
+ : {},
80
+ },
73
81
  ]);
74
82
  configs.forEach((config) => {
75
83
  if (config) {
@@ -160,16 +168,12 @@ function generateMpConfig(ctx, weapps, options) {
160
168
  // projConfig.setting.compileHotReLoad = false;
161
169
  projConfig.setting.bigPackageSizeSupport = true;
162
170
  projConfig.setting.packNpmManually = true;
163
- projConfig.setting.packNpmRelationList = [
164
- {
165
- packageJsonPath: path.posix.join(projConfig.wedaRoot || './', 'package.json'),
166
- miniprogramNpmDistDir: projConfig.wedaRoot || './',
167
- },
168
- {
169
- packageJsonPath: path.posix.join(projConfig.wedaRoot || './', 'packages', '$wd_system', 'package.json'),
170
- miniprogramNpmDistDir: path.posix.join(projConfig.wedaRoot || './', 'packages', '$wd_system'),
171
- },
172
- ];
171
+ if (!projConfig.setting.packNpmRelationList) {
172
+ projConfig.setting.packNpmRelationList = [];
173
+ }
174
+ projConfig.setting.packNpmRelationList = mergePackNpmRelationList(generateSystemPackNpmRelationList(path.posix.join(projConfig.miniprogramRoot, projConfig.wedaRoot)), projConfig.setting.packNpmRelationList.filter((item) => {
175
+ return !/\/packages\/\$wd_system\/package.json/.test(item.packageJsonPath);
176
+ }));
173
177
  if (process.env.IS_WEB_WORKER) {
174
178
  projConfig.setting.ignoreUploadUnusedFiles = true;
175
179
  }
@@ -270,3 +274,31 @@ function mergeSubPackages(base = [], extra = []) {
270
274
  return base;
271
275
  }
272
276
  exports.mergeSubPackages = mergeSubPackages;
277
+ function mergePackNpmRelationList(base = [], extra = []) {
278
+ const baseMap = base.reduce((map, item) => {
279
+ map[path.posix.join('./', item.packageJsonPath, 'fake')] = true;
280
+ return map;
281
+ }, {});
282
+ const res = [...base];
283
+ extra.forEach((item) => {
284
+ const key = path.posix.join('./', item.packageJsonPath, 'fake');
285
+ if (!baseMap[key]) {
286
+ res.push(item);
287
+ }
288
+ });
289
+ return res;
290
+ }
291
+ exports.mergePackNpmRelationList = mergePackNpmRelationList;
292
+ function generateSystemPackNpmRelationList(wedaRootProjectPath) {
293
+ return [
294
+ {
295
+ packageJsonPath: path.posix.join(wedaRootProjectPath || './', 'package.json'),
296
+ miniprogramNpmDistDir: wedaRootProjectPath || './',
297
+ },
298
+ {
299
+ packageJsonPath: path.posix.join(wedaRootProjectPath || './', 'packages', '$wd_system', 'package.json'),
300
+ miniprogramNpmDistDir: path.posix.join(wedaRootProjectPath || './', 'packages', '$wd_system'),
301
+ },
302
+ ];
303
+ }
304
+ exports.generateSystemPackNpmRelationList = generateSystemPackNpmRelationList;