@cloudbase/lowcode-builder 0.0.3 → 0.1.1

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,4 +1,5 @@
1
1
  import { IInstallOpts } from '../service/webpack';
2
+ export { getCompileDirs } from '../util';
2
3
  import { IMaterialItem, IWeAppData, IPlugin, IExtraData } from '@cloudbase/lowcode-generator/lib/weapps-core';
3
4
  import { BuildType, GenerateMpType, WebpackBuildCallBack, WebpackModeType } from '../types/common';
4
5
  import { DEPLOY_MODE, RUNTIME } from '../../types';
@@ -37,6 +38,7 @@ export interface IBuildWedaApp extends IBaseAppProps {
37
38
  };
38
39
  }
39
40
  export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
41
+ export declare function cleanComponentDir(): Promise<void>;
40
42
  export declare function installDep(dir: any, opts?: IInstallOpts): Promise<void>;
41
43
  export declare const version: any;
42
44
  export default buildWedaApp;
@@ -3,10 +3,12 @@ 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.version = exports.installDep = exports.buildWedaApp = void 0;
6
+ exports.version = exports.installDep = exports.cleanComponentDir = exports.buildWedaApp = exports.getCompileDirs = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const webpack_1 = require("../service/webpack");
9
9
  const util_1 = require("../util");
10
+ var util_2 = require("../util");
11
+ Object.defineProperty(exports, "getCompileDirs", { enumerable: true, get: function () { return util_2.getCompileDirs; } });
10
12
  const common_1 = require("../types/common");
11
13
  const index_1 = require("../mp/index");
12
14
  const path_1 = __importDefault(require("path"));
@@ -122,6 +124,10 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
122
124
  }
123
125
  }
124
126
  exports.buildWedaApp = buildWedaApp;
127
+ async function cleanComponentDir() {
128
+ return fs_extra_1.default.emptyDir((0, util_1.getCompileDirs)().materialsDir);
129
+ }
130
+ exports.cleanComponentDir = cleanComponentDir;
125
131
  function installDep(dir, opts = {}) {
126
132
  return (0, webpack_1.installDependencies)(dir, opts);
127
133
  }
@@ -159,19 +159,17 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
159
159
  });
160
160
  });
161
161
  // #2 Generate composited libs
162
- compositedLibs.map(async (lib) => {
162
+ await Promise.all(compositedLibs.map(async (lib) => {
163
163
  console.log('Generate composited library ' + lib.name);
164
164
  await (0, util_4.writeLibCommonRes2file)(lib, path.join(ctx.projDir, config_1.materialsDirName, lib.name, 'libCommonRes'));
165
- return lib.components.map((cmp) => {
166
- weappsList.forEach((app) => {
167
- generateCompositeComponent(cmp, {
168
- ...ctx,
169
- // 只生成在主目录中,减少冗余
170
- // rootPath: app.rootPath || '', // 主包是没有 rootPath 的
171
- }, lib.compLibCommonResource);
172
- });
173
- });
174
- });
165
+ await Promise.all(lib.components.map(async (cmp) => {
166
+ return generateCompositeComponent(cmp, {
167
+ ...ctx,
168
+ // 只生成在主目录中,减少冗余
169
+ // rootPath: app.rootPath || '', // 主包是没有 rootPath 的
170
+ }, lib.compLibCommonResource);
171
+ }));
172
+ }));
175
173
  }
176
174
  exports.installMaterials = installMaterials;
177
175
  // 递归查询复合组件所使用的组件
@@ -62,7 +62,7 @@ async function generateFiles(appFileData, srcDir, dstDir, ctx) {
62
62
  exports.default = generateFiles;
63
63
  async function writeFile(outFile, content) {
64
64
  const generated = generatedFileContents[outFile];
65
- if (generated === content) {
65
+ if (generated === content && fs_extra_1.default.existsSync(outFile)) {
66
66
  return false;
67
67
  }
68
68
  // console.log(outFile);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const index_1 = require("../index");
7
+ const data_1 = __importDefault(require("./data"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const common_1 = require("../src/builder/types/common");
11
+ const outPath = path_1.default.resolve(__dirname, '.temp');
12
+ fs_extra_1.default.emptyDirSync(outPath);
13
+ (0, index_1.buildWedaApp)({
14
+ ...data_1.default,
15
+ buildTypeList: [common_1.BuildType.WEB],
16
+ output: { path: outPath },
17
+ }).then((dir) => {
18
+ console.log(dir);
19
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const index_1 = require("../index");
7
+ const data_1 = __importDefault(require("./data"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const common_1 = require("../lib/builder/types/common");
11
+ describe('build', () => {
12
+ it('needs tests', async () => {
13
+ const outPath = path_1.default.resolve(__dirname, './temp');
14
+ fs_extra_1.default.emptyDir(outPath);
15
+ let dir = await (0, index_1.buildWedaApp)({
16
+ ...data_1.default,
17
+ buildTypeList: [common_1.BuildType.WEB],
18
+ output: { path: outPath },
19
+ });
20
+ console.log(dir);
21
+ });
22
+ });
@@ -0,0 +1,18 @@
1
+ import { BuildType } from '../builder/types/common';
2
+ import { DEPLOY_MODE } from '../types';
3
+ export declare const test: {
4
+ appKey: string;
5
+ cals: any;
6
+ subAppCalsList: never[];
7
+ dependencies: any[];
8
+ buildTypeList: BuildType[];
9
+ deployOptions: {
10
+ mode: DEPLOY_MODE;
11
+ mpAppId: string;
12
+ targetMpAppId: string;
13
+ };
14
+ domain: string;
15
+ resourceAppId: string;
16
+ };
17
+ declare const _default: any;
18
+ export default _default;