@cloudbase/lowcode-builder 1.9.3 → 1.9.5

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,6 +1,6 @@
1
1
  export declare function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }: {
2
- importJSSDK: boolean;
3
2
  mode: 'lib' | string;
3
+ importJSSDK?: boolean;
4
4
  officialLibVersion?: string;
5
5
  uin?: string;
6
6
  }): {
@@ -9,3 +9,11 @@ export declare function generatePackageDependencies({ importJSSDK, mode, officia
9
9
  'lodash.get': string;
10
10
  'lodash.set': string;
11
11
  };
12
+ export declare function generateLibDependencies(mode: 'mp' | 'h5', officialLibVersion?: any): {};
13
+ export declare function generateSystemPackageDependencies({ importJSSDK }: {
14
+ importJSSDK: any;
15
+ }): {
16
+ '@cloudbase/adapter-wx_mp': string;
17
+ '@cloudbase/auth': string;
18
+ '@cloudbase/ai': string;
19
+ };
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generatePackageDependencies = void 0;
3
+ exports.generateSystemPackageDependencies = exports.generateLibDependencies = exports.generatePackageDependencies = void 0;
4
4
  const cals_1 = require("@cloudbase/cals");
5
+ const CLOUDBASE_VERSION = '2.8.15-beta.0';
5
6
  const BASE_DEPS = {
6
7
  'miniprogram-gesture': '^1.0.6',
7
8
  mobx: '^5',
@@ -12,28 +13,24 @@ const BASE_DEPS = {
12
13
  * 注意锁版本
13
14
  */
14
15
  const CLOUDBASE_DEPS = {
15
- '@cloudbase/oauth': '0.1.1-alpha.15',
16
16
  '@cloudbase/weda-client': '1.1.6',
17
- '@cloudbase/weda-cloud-sdk': '1.0.76',
17
+ '@cloudbase/weda-cloud-sdk': '1.0.86',
18
+ };
19
+ const COMPONENT_DEPS = {
20
+ '@cloudbase/lowcode-render': '^1.1.4',
21
+ };
22
+ const SYS_CLOUDBASE_DEPS = {
23
+ '@cloudbase/adapter-wx_mp': '^1.0.3',
24
+ '@cloudbase/auth': CLOUDBASE_VERSION,
25
+ '@cloudbase/ai': CLOUDBASE_VERSION,
18
26
  };
19
27
  function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }) {
20
28
  const deps = {};
21
- if (importJSSDK) {
22
- deps['@cloudbase/js-sdk'] = '2.5.47-beta.0';
23
- }
24
- const mod = uin ? Number(uin) % 10 : undefined;
25
29
  if (mode === 'lib') {
26
- // eslint-disable-next-line no-restricted-syntax
27
- for (const key in CLOUDBASE_DEPS) {
28
- const version = CLOUDBASE_DEPS[key];
29
- /**
30
- * lib 模式下采用松散的引用
31
- */
32
- deps[key] = /^\d/.test(version) ? `^${version}` : version;
33
- }
34
- if (officialLibVersion) {
35
- deps[cals_1.OFFICIAL_LIB_MP_NPM_PACKAGENAME] = officialLibVersion;
30
+ if (importJSSDK) {
31
+ deps['@cloudbase/js-sdk'] = CLOUDBASE_VERSION;
36
32
  }
33
+ Object.assign(deps, generateLibDependencies('mp', officialLibVersion));
37
34
  }
38
35
  else {
39
36
  for (const key in CLOUDBASE_DEPS) {
@@ -46,3 +43,28 @@ function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, ui
46
43
  };
47
44
  }
48
45
  exports.generatePackageDependencies = generatePackageDependencies;
46
+ function generateLibDependencies(mode, officialLibVersion) {
47
+ const deps = {};
48
+ const modeDeps = mode === 'mp' ? { ...CLOUDBASE_DEPS, ...SYS_CLOUDBASE_DEPS } : COMPONENT_DEPS;
49
+ for (const key in modeDeps) {
50
+ const version = modeDeps[key];
51
+ deps[key] = /^\d/.test(version) ? `^${version}` : version;
52
+ }
53
+ if (officialLibVersion) {
54
+ const officialLibPackageName = mode === 'mp' ? cals_1.OFFICIAL_LIB_MP_NPM_PACKAGENAME : cals_1.OFFICIAL_LIB_NPM_PACKAGENAME;
55
+ deps[officialLibPackageName] = officialLibVersion;
56
+ }
57
+ return deps;
58
+ }
59
+ exports.generateLibDependencies = generateLibDependencies;
60
+ function generateSystemPackageDependencies({ importJSSDK }) {
61
+ const deps = {};
62
+ if (importJSSDK) {
63
+ deps['@cloudbase/js-sdk'] = CLOUDBASE_VERSION;
64
+ }
65
+ return {
66
+ ...deps,
67
+ ...SYS_CLOUDBASE_DEPS,
68
+ };
69
+ }
70
+ exports.generateSystemPackageDependencies = generateSystemPackageDependencies;
@@ -1,5 +1,5 @@
1
1
  export { REPLACE_SIGN, MP_CONFIG_MODULE_NAME, KBONE_PAGE_KEYS, npmRegistry, remConfig, rpxConfig, OFFICIAL_LIB_KEY, } from '@cloudbase/lowcode-generator/lib/generator/config/index';
2
- export { generatePackageDependencies } from './dependencies';
2
+ export { generatePackageDependencies, generateLibDependencies, generateSystemPackageDependencies, } from './dependencies';
3
3
  export declare const sharedMaterialsDir: string;
4
4
  export declare const appTemplateDir: string;
5
5
  export declare const materialsDirName = "materials";
@@ -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.getPrivatelinkJsUrl = exports.REPEATER = exports.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.systemSubpackageMiniprogramDir = exports.cloudbaseMiniprogramDir = exports.miniprogramDir = exports.RUNTIME_CONFIG_URL = exports.systemSubpackageMiniprogramURL = exports.cloudbaseMiniprogramURL = exports.miniprogramURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.generatePackageDependencies = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
29
+ exports.getPrivatelinkJsUrl = exports.REPEATER = exports.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.systemSubpackageMiniprogramDir = exports.cloudbaseMiniprogramDir = exports.miniprogramDir = exports.RUNTIME_CONFIG_URL = exports.systemSubpackageMiniprogramURL = exports.cloudbaseMiniprogramURL = exports.miniprogramURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.generateSystemPackageDependencies = exports.generateLibDependencies = exports.generatePackageDependencies = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
30
30
  const path = __importStar(require("path"));
31
31
  const os_1 = __importDefault(require("os"));
32
32
  const index_1 = require("@cloudbase/lowcode-generator/lib/generator/config/index");
@@ -40,6 +40,8 @@ Object.defineProperty(exports, "rpxConfig", { enumerable: true, get: function ()
40
40
  Object.defineProperty(exports, "OFFICIAL_LIB_KEY", { enumerable: true, get: function () { return index_2.OFFICIAL_LIB_KEY; } });
41
41
  var dependencies_1 = require("./dependencies");
42
42
  Object.defineProperty(exports, "generatePackageDependencies", { enumerable: true, get: function () { return dependencies_1.generatePackageDependencies; } });
43
+ Object.defineProperty(exports, "generateLibDependencies", { enumerable: true, get: function () { return dependencies_1.generateLibDependencies; } });
44
+ Object.defineProperty(exports, "generateSystemPackageDependencies", { enumerable: true, get: function () { return dependencies_1.generateSystemPackageDependencies; } });
43
45
  exports.sharedMaterialsDir = path.join(os_1.default.homedir(), '.weapps-materials');
44
46
  exports.appTemplateDir = path.resolve(__dirname, '../../../template');
45
47
  exports.materialsDirName = 'materials'; // materials diretory of current project
@@ -48,8 +50,8 @@ exports.materialsDirName = 'materials'; // materials diretory of current project
48
50
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-replace-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
49
51
  */
50
52
  const COMP_PUBLIC_DOMAIN = 'comp-public-replace-1303824488-cos.weda.tencent.com';
51
- exports.miniprogramURL = `https://${COMP_PUBLIC_DOMAIN}/lcap-builder/miniprogram_npm.1.8.107.zip`;
52
- exports.cloudbaseMiniprogramURL = `https://${COMP_PUBLIC_DOMAIN}/lcap-builder/cloudbase_miniprogram_npm.1.8.107.zip`;
53
+ exports.miniprogramURL = `https://${COMP_PUBLIC_DOMAIN}/lcap-builder/miniprogram_npm.1.9.5.zip`;
54
+ exports.cloudbaseMiniprogramURL = `https://${COMP_PUBLIC_DOMAIN}/lcap-builder/cloudbase_miniprogram_npm.1.9.5.zip`;
53
55
  exports.systemSubpackageMiniprogramURL = `https://${COMP_PUBLIC_DOMAIN}/lcap-builder/wd_system_miniprogram_npm.zip`;
54
56
  exports.RUNTIME_CONFIG_URL = `https://${COMP_PUBLIC_DOMAIN}/release_config/runtime/exp_runtime.json`;
55
57
  /**
@@ -4,6 +4,7 @@ import { DEPLOY_MODE, RUNTIME } from '../../types';
4
4
  import { IPlatformApp } from '@cloudbase/cals';
5
5
  import { ICDN_ENDPOINTS_COFIG } from '../config';
6
6
  import { ICommonBuildContext } from '../mp/BuildContext';
7
+ export { buildBlock } from '../h5/block2component';
7
8
  interface IBaseAppProps {
8
9
  appKey: string;
9
10
  dependencies?: IMaterialItem[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildComposite = exports.normalizeInputs = exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp = exports.buildWedaConfig = void 0;
6
+ exports.buildComposite = exports.normalizeInputs = exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp = exports.buildWedaConfig = exports.buildBlock = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const util_1 = require("../util");
@@ -18,6 +18,8 @@ const config_1 = require("../config");
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  const materials_1 = require("../mp/materials");
20
20
  const common_3 = require("@cloudbase/lowcode-generator/lib/generator/types/common");
21
+ var block2component_1 = require("../h5/block2component");
22
+ Object.defineProperty(exports, "buildBlock", { enumerable: true, get: function () { return block2component_1.buildBlock; } });
21
23
  const pkg = require('../../../package.json');
22
24
  async function buildWedaConfig({ output, domain = undefined, isPrivateMode = undefined, endpointType = undefined, buildTypeList = [common_1.BuildType.WEB], }) {
23
25
  if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
@@ -486,25 +488,10 @@ async function patchMpComponentNPM({ packageDir, name, version, packageMiniprogr
486
488
  version: version || packageJSON.version || '0.0.1',
487
489
  miniprogram: `./${packageMiniprogramEntry}`,
488
490
  keywords: ['微搭', '小程序', '区块组件', 'cloudbase', 'cloudbase-module', 'cloudbase-component'],
489
- scripts: {
490
- ...packageJSON.scripts,
491
- postinstall: 'node scripts/fixCloudSdk.js',
492
- },
493
491
  dependencies: {
494
492
  ...packageJSON.peerDependencies,
495
493
  ...BASE_DEPS,
496
494
  },
497
495
  };
498
- await Promise.all([
499
- fs_extra_1.default.writeFile(path_1.default.join(packageDir, 'scripts', 'fixCloudSdk.js'), `try {
500
- const cloudIndex = require.resolve('@cloudbase/weda-cloud-sdk') || '';
501
- const cloudFixPath = cloudIndex.replace(/@cloudbase\\/weda-cloud-sdk\\/.*$/, '@cloudbase/weda-cloud-sdk/scripts/fix-wx-none-private.js');
502
- const fix = require(cloudFixPath);
503
- fix()
504
- } catch(e) {
505
- console.log('run scripts error', e)
506
- }
507
- `),
508
- fs_extra_1.default.writeFile(packageJsonPath, JSON.stringify(packageJSON, undefined, 2)),
509
- ]);
496
+ await Promise.all([fs_extra_1.default.writeFile(packageJsonPath, JSON.stringify(packageJSON, undefined, 2))]);
510
497
  }
@@ -0,0 +1,2 @@
1
+ import { RUNTIME } from '../../types';
2
+ export declare function buildBlock(buildDir: any, dependencies: any, runtime?: RUNTIME): Promise<any>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBlock = void 0;
4
+ const cals_1 = require("@cloudbase/cals");
5
+ const util_1 = require("../util");
6
+ const types_1 = require("../../types");
7
+ const material_1 = require("./material");
8
+ const config_1 = require("../config");
9
+ const generate_1 = require("./generate");
10
+ async function buildBlock(buildDir, dependencies, runtime = types_1.RUNTIME.NONE) {
11
+ var _a, _b;
12
+ const { materialsDir } = (0, util_1.getCompileDirs)();
13
+ let usedComps;
14
+ const composite = dependencies.find((lib) => lib.isComposite);
15
+ if (composite) {
16
+ let id = 0;
17
+ const cals = {
18
+ items: [
19
+ {
20
+ id: '$page',
21
+ type: 'PAGE',
22
+ items: ((_b = (_a = composite.components) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (component) => {
23
+ id += 1;
24
+ return {
25
+ id: `id${id}`,
26
+ module: composite.name,
27
+ component: component.name,
28
+ attributes: {},
29
+ };
30
+ })) || [],
31
+ },
32
+ ],
33
+ };
34
+ usedComps = (0, cals_1.getUsedComps)([cals], dependencies, { streamline: true, withAction: true });
35
+ }
36
+ let processedDependencies = await (0, material_1.runHandleMaterial)(buildDir, dependencies.filter((lib) => {
37
+ var _a, _b;
38
+ // 注意需要包涵官方的(gsd),部分平台方法需要由其补充
39
+ return lib.name !== config_1.OFFICIAL_LIB_KEY && !!(((_a = usedComps.component) === null || _a === void 0 ? void 0 : _a[lib.name]) || ((_b = usedComps.action) === null || _b === void 0 ? void 0 : _b[lib.name]));
40
+ }),
41
+ // [dependence, ...dependencies],
42
+ materialsDir, runtime);
43
+ const officialDependence = dependencies.find((lib) => lib.name === config_1.OFFICIAL_LIB_KEY);
44
+ const componentDeps = (0, config_1.generateLibDependencies)('h5', officialDependence === null || officialDependence === void 0 ? void 0 : officialDependence.version);
45
+ processedDependencies.push(officialDependence);
46
+ try {
47
+ await (0, generate_1.generateBlockFiles)({
48
+ dependencies: processedDependencies,
49
+ appBuildDir: buildDir,
50
+ componentDeps,
51
+ });
52
+ }
53
+ catch (error) {
54
+ throw error;
55
+ }
56
+ return buildDir;
57
+ }
58
+ exports.buildBlock = buildBlock;
@@ -7,6 +7,7 @@ import { ICommonBuildContext } from '../mp/BuildContext';
7
7
  * 该函数从 @govcloud/generate 取到需要的模版文件
8
8
  */
9
9
  export declare function generateProjectFiles(buildData: BuildAppProps): Promise<void>;
10
+ export declare function generateBlockFiles(buildData: any): Promise<void>;
10
11
  export declare function generateHTML({ buildContext, appId, envId, description, appBuildDir, externalResources, mode, devTool, isBuildApp, buildTypeList, cdnEndpoints,
11
12
  /**
12
13
  * 由于存量兜底逻辑存在
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateThemeVarsFile = exports.handleAssets = exports.generateHTML = exports.generateProjectFiles = void 0;
6
+ exports.generateThemeVarsFile = exports.handleAssets = exports.generateHTML = exports.generateBlockFiles = exports.generateProjectFiles = void 0;
7
7
  const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
8
8
  const generateFiles_1 = require("../util/generateFiles");
9
9
  const path_1 = __importDefault(require("path"));
@@ -26,6 +26,20 @@ async function generateProjectFiles(buildData) {
26
26
  }));
27
27
  }
28
28
  exports.generateProjectFiles = generateProjectFiles;
29
+ async function generateBlockFiles(buildData) {
30
+ const { dependencies, appBuildDir, componentDeps } = buildData;
31
+ const fileCodeMap = {};
32
+ await (0, lowcode_generator_1.generateCompositeComponent)(dependencies, './', fileCodeMap, componentDeps);
33
+ try {
34
+ await Promise.all(Object.keys(fileCodeMap).map(async (filePath) => {
35
+ await (0, generateFiles_1.writeFile)(path_1.default.join(appBuildDir || '', filePath), fileCodeMap[filePath].code);
36
+ }));
37
+ }
38
+ catch (error) {
39
+ throw error;
40
+ }
41
+ }
42
+ exports.generateBlockFiles = generateBlockFiles;
29
43
  async function generateHTML({ buildContext, appId, envId, description = '', appBuildDir, externalResources = [], mode, devTool, isBuildApp, buildTypeList, cdnEndpoints,
30
44
  /**
31
45
  * 由于存量兜底逻辑存在
@@ -1,3 +1,3 @@
1
1
  import { IMaterialItem } from '@cloudbase/lowcode-generator/lib/weapps-core';
2
2
  import { RUNTIME } from '../../types';
3
- export declare function runHandleMaterial(appBuildDir: string, dependencies: IMaterialItem[] | undefined, materialsDir: string, runtime?: RUNTIME, ignoreInstall?: boolean): Promise<any[]>;
3
+ export declare function runHandleMaterial(appBuildDir: string, dependencies: IMaterialItem[] | undefined, materialsDir: string, runtime?: RUNTIME, ignoreInstall?: boolean): Promise<IMaterialItem[]>;
@@ -48,7 +48,7 @@ async function runHandleMaterial(appBuildDir, dependencies = [], materialsDir, r
48
48
  runtime,
49
49
  ignoreInstall,
50
50
  });
51
- return allMaterials.concat(compositeDependencies);
51
+ return compositeDependencies.concat(allMaterials);
52
52
  // TODO: 确认这里是否需要生成复合组件
53
53
  // await handleCompositeComponent({ dependencies, appBuildDir });
54
54
  }
@@ -213,7 +213,6 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
213
213
  appId,
214
214
  extraDeps: {
215
215
  ...(0, index_1.generatePackageDependencies)({
216
- importJSSDK: endpointType === 'tcb-api',
217
216
  mode: 'app',
218
217
  uin: buildContext.uin,
219
218
  }),
@@ -259,8 +258,16 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
259
258
  // 生成上报 & 系统子包模块模块
260
259
  const subpackageRootPath = path_1.default.join(localWedaRoot, 'packages', '$wd_system');
261
260
  const sysSubpackageFileData = {
262
- 'package.json': { cdnEndpoints, privatelink: !!buildContext.privatelinkConfig },
263
- 'index.js.tpl': { cdnEndpoints, privatelink: !!buildContext.privatelinkConfig },
261
+ 'package.json': {
262
+ cdnEndpoints,
263
+ privatelink: !!buildContext.privatelinkConfig,
264
+ extraDeps: (0, index_1.generateSystemPackageDependencies)({ importJSSDK: endpointType === 'tcb-api' }),
265
+ },
266
+ 'index.js.tpl': {
267
+ cdnEndpoints,
268
+ privatelink: !!buildContext.privatelinkConfig,
269
+ importJSSDK: endpointType === 'tcb-api',
270
+ },
264
271
  };
265
272
  console.log(`Generating ${em('system subpackage')} files`);
266
273
  function copyFilterTplRecursiveSync(src, dest, options) {
@@ -388,7 +395,6 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
388
395
  appId,
389
396
  extraDeps: {
390
397
  ...(0, index_1.generatePackageDependencies)({
391
- importJSSDK: endpointType === 'tcb-api',
392
398
  mode: 'app',
393
399
  uin: buildContext.uin,
394
400
  }),
@@ -428,7 +434,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
428
434
  else {
429
435
  await (0, webpack_1.installDependencies)(meta.path, {
430
436
  ignoreInstall,
431
- fixNodeModulesMap: { '@cloudbase/js-sdk': endpointType !== 'tcb-api', mobx: true },
437
+ fixNodeModulesMap: {
438
+ mobx: true,
439
+ },
432
440
  });
433
441
  }
434
442
  }
@@ -219,7 +219,7 @@ function createTemplateQuery(ctx, query = {}) {
219
219
  map[key] = {
220
220
  ...rest,
221
221
  handler: item.type === cals_1.EQueryType.GeneralFunc
222
- ? `(__data__,__params__) => (${(_b = (_a = handler['code']) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, /;\s*$/, '')})({params:__params__,data:__data__})`
222
+ ? `(__data__,__params__) => (\n${(_b = (_a = handler['code']) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, /;\s*$/, '')}\n)({params:__params__,data:__data__})`
223
223
  : `(...args) => $app.${handler === null || handler === void 0 ? void 0 : handler.name}(...args)`,
224
224
  data: staticProps,
225
225
  dataBinds: boundProps,
@@ -51,7 +51,7 @@ export declare function getMainAppDataByList(allAppDataList: IWebRuntimeAppData[
51
51
  export declare function getHomePageInstance(pageInstanceList: any): any;
52
52
  export declare function getPageName(name: string): string;
53
53
  export declare function downloadAndInstallDependencies(dependencies: IMaterialItem[] | undefined, materialsDir: string, installOptions?: IInstallOpts): Promise<void>;
54
- export declare function downloadDependencies(targetDir: string, srcZipUrl: string): Promise<void>;
54
+ export declare function downloadDependencies(targetDir: string, srcZipUrl: string, useBash?: boolean): Promise<void>;
55
55
  /**
56
56
  *
57
57
  * @param targetDir 目标目录
@@ -54,6 +54,7 @@ async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBui
54
54
  : mode !== common_1.WebpackModeType.PRODUCTION
55
55
  ? 'eval'
56
56
  : false,
57
+ vueVersion,
57
58
  }, null, 2);
58
59
  const webpackConfigContent = `params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
59
60
  await (0, generateFiles_1.writeFile)(webpackConfigPath, webpackConfigContent);
@@ -140,7 +141,7 @@ async function downloadAndInstallDependencies(dependencies = [], materialsDir, i
140
141
  }
141
142
  // 如果需要下载素材
142
143
  if (!(await fs_extra_1.default.pathExists(targetDir))) {
143
- const matched = srcZipUrl.match(/\/(cg-.*?)\//);
144
+ const matched = srcZipUrl === null || srcZipUrl === void 0 ? void 0 : srcZipUrl.match(/\/(cg-.*?)\//);
144
145
  const { appBuildDir } = (0, util_1.getCompileDirs)('app');
145
146
  if ((matched === null || matched === void 0 ? void 0 : matched[1]) && fs_extra_1.default.existsSync(path_1.default.resolve(appBuildDir, `.component_cache/web/${matched[1]}@${version}`))) {
146
147
  console.log(`link ${name}@${version} ...`);
@@ -161,7 +162,7 @@ async function downloadAndInstallDependencies(dependencies = [], materialsDir, i
161
162
  }
162
163
  else {
163
164
  console.log(`下载${name}@${version} ...`);
164
- await downloadDependencies(targetDir, srcZipUrl);
165
+ await downloadDependencies(targetDir, srcZipUrl, /^cloudbase-/.test(process.env.CCI_CURRENT_TEAM || ''));
165
166
  }
166
167
  }
167
168
  // 同步依赖
@@ -170,57 +171,54 @@ async function downloadAndInstallDependencies(dependencies = [], materialsDir, i
170
171
  // );
171
172
  // item.dependencies = packageJson.dependencies || {};
172
173
  }));
173
- await Promise.all(dependencies.map(async (item) => {
174
- const { name, version, srcZipUrl } = item;
175
- const materialNameVersion = `${name}@${version}`;
176
- const targetDir = path_1.default.join(materialsDir, materialNameVersion);
177
- console.log(`处理${name}@${version}依赖 ...`);
178
- await installDependencies(targetDir, {
179
- ...installOptions,
180
- isDependence: true,
181
- ignoreInstall: (0, common_2.isOfficialComponentLib)(name, version) || (installOptions === null || installOptions === void 0 ? void 0 : installOptions.ignoreInstall),
182
- dependenceMeta: {
183
- name,
184
- version,
185
- downloadUrl: srcZipUrl,
186
- },
187
- });
188
- }));
174
+ if (!process.env.IS_WEB_WORKER) {
175
+ await Promise.all(dependencies.map(async (item) => {
176
+ const { name, version, srcZipUrl } = item;
177
+ const materialNameVersion = `${name}@${version}`;
178
+ const targetDir = path_1.default.join(materialsDir, materialNameVersion);
179
+ console.log(`处理${name}@${version}依赖 ...`);
180
+ await installDependencies(targetDir, {
181
+ ...installOptions,
182
+ isDependence: true,
183
+ ignoreInstall: (0, common_2.isOfficialComponentLib)(name, version) || (installOptions === null || installOptions === void 0 ? void 0 : installOptions.ignoreInstall),
184
+ dependenceMeta: {
185
+ name,
186
+ version,
187
+ downloadUrl: srcZipUrl,
188
+ },
189
+ });
190
+ }));
191
+ }
189
192
  }
190
193
  exports.downloadAndInstallDependencies = downloadAndInstallDependencies;
191
- async function downloadDependencies(targetDir, srcZipUrl) {
194
+ async function downloadDependencies(targetDir, srcZipUrl, useBash = false) {
192
195
  const isExist = fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'package.json'));
193
196
  if (isExist || !srcZipUrl) {
194
197
  return;
195
198
  }
196
199
  try {
197
- let response = await (0, axios_1.default)({
198
- url: srcZipUrl,
199
- responseType: 'stream',
200
- // proxy: false
201
- });
202
- await fs_extra_1.default.ensureDir(targetDir);
203
- // let download = spawn(
204
- // 'curl',
205
- // ['-fsSL', srcZipUrl, '-o', `${targetDir}.zip`],
206
- // {
207
- // stdio: 'inherit',
208
- // }
209
- // );
210
- // await promisifyProcess(download);
211
- const tag = `uncompress ${srcZipUrl}`;
212
- console.time(tag);
213
- await compressing_1.default.zip.uncompress(response.data, targetDir);
214
- // let unzip = spawn(
215
- // 'unzip',
216
- // ['-q', '-o', `${targetDir}.zip`, '-d', targetDir],
217
- // {
218
- // stdio: 'inherit',
219
- // }
220
- // );
221
- // await promisifyProcess(unzip);
222
- // await fs.remove(`${targetDir}.zip`);
223
- console.timeEnd(tag);
200
+ if (useBash) {
201
+ const tag = `bash ${srcZipUrl}`;
202
+ console.time(tag);
203
+ await fs_extra_1.default.ensureDir(targetDir);
204
+ await spawnPromise(`wget -qO- ${srcZipUrl} | tar xvz -C ${targetDir}`, [], {
205
+ cwd: process.cwd(),
206
+ stdio: undefined,
207
+ });
208
+ console.timeEnd(tag);
209
+ }
210
+ else {
211
+ let response = await (0, axios_1.default)({
212
+ url: srcZipUrl,
213
+ responseType: 'stream',
214
+ // proxy: false
215
+ });
216
+ const tag = `uncompress ${srcZipUrl}`;
217
+ await fs_extra_1.default.ensureDir(targetDir);
218
+ console.time(tag);
219
+ await compressing_1.default.zip.uncompress(response.data, targetDir);
220
+ console.timeEnd(tag);
221
+ }
224
222
  }
225
223
  catch (e) {
226
224
  console.error(`Fail to download weapps material package ${srcZipUrl}`, e);
@@ -313,13 +311,6 @@ function fixNodeModules(projDir, options = { mobx: false, '@cloudbase/js-sdk': f
313
311
  }
314
312
  }
315
313
  }
316
- if (jsSDK) {
317
- const scriptPath = path_1.default.resolve(projDir, 'node_modules', '@cloudbase/weda-cloud-sdk/scripts/fix-wx-none-private.js');
318
- if (fs_extra_1.default.existsSync(scriptPath)) {
319
- const fix = require(scriptPath);
320
- fix();
321
- }
322
- }
323
314
  }
324
315
  function getMaterialNodeModulesPathList(dependencies = [], materialsDir, base) {
325
316
  const localPkg = (0, util_1.getCurrentPackageJson)();
@@ -370,3 +361,22 @@ async function downloadAssets(targetDir, assetUrl) {
370
361
  });
371
362
  }
372
363
  exports.downloadAssets = downloadAssets;
364
+ async function spawnPromise(command, args, options) {
365
+ return new Promise((resolve, reject) => {
366
+ var _a, _b;
367
+ const cm = (0, cross_spawn_1.default)(command, args, Object.assign({
368
+ shell: true,
369
+ stdio: 'inherit',
370
+ }, options));
371
+ let stdout = '';
372
+ (_a = cm.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
373
+ stdout += data;
374
+ });
375
+ let stderr = '';
376
+ (_b = cm.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
377
+ stderr += data;
378
+ });
379
+ cm.on('error', reject);
380
+ cm.on('close', (code) => (code === 0 ? resolve(stdout) : reject(stderr)));
381
+ });
382
+ }