@cabloy/module-glob 5.0.1 → 5.0.3

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.
package/dist/index.js CHANGED
@@ -34,9 +34,9 @@ const boxenOptions = {
34
34
  borderColor: 'yellow',
35
35
  borderStyle: 'round',
36
36
  };
37
- // type: front/backend/all
37
+ // type: front/backend
38
38
  async function glob(options) {
39
- const { projectPath, disabledModules, disabledSuites, log, type, loadPackage } = options;
39
+ const { projectPath, disabledModules, disabledSuites, log, projectMode, loadPackage } = options;
40
40
  // context
41
41
  const context = {
42
42
  options,
@@ -54,13 +54,13 @@ async function glob(options) {
54
54
  //
55
55
  disabledModules: __getDisabledModules(disabledModules),
56
56
  disabledSuites: __getDisabledSuites(disabledSuites),
57
+ //
58
+ pathsMeta: (0, meta_js_1.getPathsMeta)(projectMode),
57
59
  };
58
- // cabloy config
59
- const cabloyConfig = await __loadCabloyConfig();
60
60
  // parse suites
61
- const suites = __parseSuites(projectPath);
61
+ const suites = __parseSuites(context, projectPath);
62
62
  // parse modules
63
- const modules = __parseModules(projectPath, cabloyConfig);
63
+ const modules = __parseModules(context, projectPath);
64
64
  // load package
65
65
  if (loadPackage !== false) {
66
66
  await __loadPackage(suites);
@@ -71,7 +71,7 @@ async function glob(options) {
71
71
  // check suites
72
72
  __checkSuites(context, suites);
73
73
  // order
74
- if (type === 'backend' && loadPackage !== false) {
74
+ if (projectMode === 'api' && loadPackage !== false) {
75
75
  __orderModules(context, modules);
76
76
  }
77
77
  else {
@@ -175,10 +175,9 @@ function __orderDependencies(context, modules, module, moduleRelativeName) {
175
175
  }
176
176
  return enabled;
177
177
  }
178
- function __parseModules(projectPath, cabloyConfig) {
179
- const entities = cabloyConfig.source?.entities;
178
+ function __parseModules(context, projectPath) {
180
179
  const modules = {};
181
- for (const __path of meta_js_1.__pathsModules) {
180
+ for (const __path of context.pathsMeta.modules) {
182
181
  const prefix = `${projectPath}/${__path.prefix}`;
183
182
  const filePkgs = egg_born_utils_1.default.tools.globbySync(`${prefix}*/package.json`);
184
183
  for (const filePkg of filePkgs) {
@@ -190,7 +189,7 @@ function __parseModules(projectPath, cabloyConfig) {
190
189
  continue;
191
190
  }
192
191
  // info
193
- const info = (0, module_info_1.parseInfo)(name, 'module');
192
+ const info = (0, module_info_1.parseInfoPro)(name, context.options.projectMode, 'module');
194
193
  if (!info) {
195
194
  throw new Error(`module name is not valid: ${name}`);
196
195
  }
@@ -199,14 +198,8 @@ function __parseModules(projectPath, cabloyConfig) {
199
198
  continue;
200
199
  // info
201
200
  info.vendor = __path.vendor;
202
- info.source = __path.source;
203
201
  info.node_modules = __path.node_modules;
204
202
  info.originalName = name;
205
- // source
206
- const entity = entities?.[info.relativeName];
207
- if (entity === true || entity === false) {
208
- info.source = entity;
209
- }
210
203
  // resource
211
204
  const root = path_1.default.dirname(filePkg);
212
205
  const module = {
@@ -294,9 +287,9 @@ function __getDisabledSuites(disabledSuites) {
294
287
  }
295
288
  return disabledSuitesMap;
296
289
  }
297
- function __parseSuites(projectPath) {
290
+ function __parseSuites(context, projectPath) {
298
291
  const suites = {};
299
- for (const __path of meta_js_1.__pathSuites) {
292
+ for (const __path of context.pathsMeta.suites) {
300
293
  const prefix = `${projectPath}/${__path.prefix}`;
301
294
  const filePkgs = egg_born_utils_1.default.tools.globbySync(`${prefix}*/package.json`);
302
295
  for (const filePkg of filePkgs) {
@@ -308,7 +301,7 @@ function __parseSuites(projectPath) {
308
301
  continue;
309
302
  }
310
303
  // info
311
- const info = (0, module_info_1.parseInfo)(name, 'suite');
304
+ const info = (0, module_info_1.parseInfoPro)(name, context.options.projectMode, 'suite');
312
305
  if (!info) {
313
306
  throw new Error(`suite name is not valid: ${name}`);
314
307
  }
@@ -376,9 +369,4 @@ function __checkSuites(context, suites) {
376
369
  }
377
370
  }
378
371
  }
379
- async function __loadCabloyConfig() {
380
- const __cabloyConfig = egg_born_utils_1.default.cabloyConfig;
381
- const { config } = await __cabloyConfig.load();
382
- return config;
383
- }
384
372
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
- import { IModule, ISuite } from '@cabloy/module-info';
1
+ import { IModule, ISuite, TypeProjectMode } from '@cabloy/module-info';
2
2
  export interface IModuleGlobOptions {
3
3
  projectPath: string;
4
4
  disabledModules?: string[];
5
5
  disabledSuites?: string[];
6
6
  log?: boolean;
7
- type: 'front' | 'backend';
7
+ projectMode: TypeProjectMode;
8
8
  loadPackage?: boolean;
9
9
  }
10
10
  export interface IModuleGlobContext {
@@ -20,5 +20,15 @@ export interface IModuleGlobContext {
20
20
  suitesVendor: Record<string, ISuite>;
21
21
  disabledModules: Record<string, boolean>;
22
22
  disabledSuites: Record<string, boolean>;
23
+ pathsMeta: IModuleGlobPathsMeta;
24
+ }
25
+ export interface IModuleGlobPathMetaItem {
26
+ prefix: string;
27
+ vendor: boolean;
28
+ node_modules?: boolean;
29
+ }
30
+ export interface IModuleGlobPathsMeta {
31
+ suites: IModuleGlobPathMetaItem[];
32
+ modules: IModuleGlobPathMetaItem[];
23
33
  }
24
34
  //# sourceMappingURL=interface.d.ts.map
package/dist/meta.d.ts CHANGED
@@ -1,27 +1,4 @@
1
- export declare const __pathSuites: ({
2
- prefix: string;
3
- vendor: boolean;
4
- node_modules?: undefined;
5
- } | {
6
- prefix: string;
7
- vendor: boolean;
8
- node_modules: boolean;
9
- })[];
10
- export declare const __pathsModules: ({
11
- prefix: string;
12
- vendor: boolean;
13
- source: boolean;
14
- fronts: {
15
- js: string;
16
- }[];
17
- node_modules?: undefined;
18
- } | {
19
- prefix: string;
20
- vendor: boolean;
21
- source: boolean;
22
- node_modules: boolean;
23
- fronts: {
24
- js: string;
25
- }[];
26
- })[];
1
+ import { TypeProjectMode } from '@cabloy/module-info';
2
+ import { IModuleGlobPathsMeta } from './interface.js';
3
+ export declare function getPathsMeta(projectMode: TypeProjectMode): IModuleGlobPathsMeta;
27
4
  //# sourceMappingURL=meta.d.ts.map
package/dist/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__pathsModules = exports.__pathSuites = void 0;
4
- exports.__pathSuites = [
3
+ exports.getPathsMeta = void 0;
4
+ const __pathSuites = [
5
5
  {
6
6
  prefix: 'src/suite/',
7
7
  vendor: false,
@@ -10,49 +10,45 @@ exports.__pathSuites = [
10
10
  prefix: 'src/suite-vendor/',
11
11
  vendor: true,
12
12
  },
13
- {
14
- prefix: 'node_modules/cabloy-suite-api-',
15
- vendor: true,
16
- node_modules: true,
17
- },
18
13
  ];
19
- exports.__pathsModules = [
14
+ const __pathsModules = [
20
15
  {
21
16
  prefix: 'src/module/',
22
17
  vendor: false,
23
- source: true,
24
- fronts: [{ js: 'front/src/main.js' }, { js: 'dist/front.js' }],
25
- },
26
- {
27
- prefix: 'src/module-system/',
28
- vendor: false,
29
- source: true,
30
- fronts: [{ js: 'front/src/main.js' }, { js: 'dist/front.js' }],
31
18
  },
32
19
  {
33
20
  prefix: 'src/suite/*/modules/',
34
21
  vendor: false,
35
- source: true,
36
- fronts: [{ js: 'front/src/main.js' }, { js: 'dist/front.js' }],
37
22
  },
38
23
  {
39
24
  prefix: 'src/module-vendor/',
40
25
  vendor: true,
41
- source: false,
42
- fronts: [{ js: 'dist/front.js' }, { js: 'front/src/main.js' }],
43
26
  },
44
27
  {
45
28
  prefix: 'src/suite-vendor/*/modules/',
46
29
  vendor: true,
47
- source: false,
48
- fronts: [{ js: 'dist/front.js' }, { js: 'front/src/main.js' }],
49
- },
50
- {
51
- prefix: 'node_modules/cabloy-module-api-',
52
- vendor: true,
53
- source: false,
54
- node_modules: true,
55
- fronts: [{ js: 'dist/front.js' }, { js: 'front/src/main.js' }],
56
30
  },
57
31
  ];
32
+ function getPathsMeta(projectMode) {
33
+ const suites = __pathSuites.concat([
34
+ {
35
+ prefix: `node_modules/cabloy-suite-${projectMode}-`,
36
+ vendor: true,
37
+ node_modules: true,
38
+ },
39
+ ]);
40
+ const modules = __pathsModules.concat([
41
+ {
42
+ prefix: `node_modules/cabloy-module-${projectMode}-`,
43
+ vendor: true,
44
+ node_modules: true,
45
+ },
46
+ ]);
47
+ const pathsMeta = {
48
+ suites,
49
+ modules,
50
+ };
51
+ return pathsMeta;
52
+ }
53
+ exports.getPathsMeta = getPathsMeta;
58
54
  //# sourceMappingURL=meta.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabloy/module-glob",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "cabloy module-glob",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "boxen": "^4.2.0",
33
33
  "egg-born-utils": "^1.1.9",
34
- "@cabloy/module-info": "^1.0.5"
34
+ "@cabloy/module-info": "^1.0.9"
35
35
  },
36
36
  "scripts": {
37
37
  "lint": "eslint ."