@cabloy/module-glob 5.1.9 → 5.1.11

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
@@ -26,7 +26,9 @@ const boxen_1 = __importDefault(require("boxen"));
26
26
  const egg_born_utils_1 = __importDefault(require("egg-born-utils"));
27
27
  const meta_js_1 = require("./meta.js");
28
28
  const module_info_1 = require("@cabloy/module-info");
29
+ const utils_1 = require("@cabloy/utils");
29
30
  __exportStar(require("./interface.js"), exports);
31
+ const SymbolModuleOrdering = Symbol('SymbolModuleOrdering');
30
32
  const boxenOptions = {
31
33
  padding: 1,
32
34
  margin: 1,
@@ -36,7 +38,7 @@ const boxenOptions = {
36
38
  };
37
39
  // type: front/backend
38
40
  async function glob(options) {
39
- const { projectPath, disabledModules, disabledSuites, log, projectMode } = options;
41
+ const { projectPath, disabledModules, disabledSuites, log, projectMode, meta } = options;
40
42
  // context
41
43
  const context = {
42
44
  options,
@@ -56,6 +58,7 @@ async function glob(options) {
56
58
  //
57
59
  disabledModules: __getDisabledModules(disabledModules),
58
60
  disabledSuites: __getDisabledSuites(disabledSuites),
61
+ meta,
59
62
  //
60
63
  pathsMeta: (0, meta_js_1.getPathsMeta)(projectMode),
61
64
  };
@@ -128,14 +131,19 @@ function __orderModules(context, modules) {
128
131
  }
129
132
  }
130
133
  function __pushModule(context, modules, moduleRelativeName) {
134
+ // module
135
+ const module = modules[moduleRelativeName];
131
136
  // check if disable
132
137
  if (context.disabledModules[moduleRelativeName])
133
138
  return false;
134
- // module
135
- const module = modules[moduleRelativeName];
136
- if (module.__ordering)
139
+ // check meta
140
+ const capabilities = module.package.zovaModule?.capabilities ?? module.package.vonaModule?.capabilities;
141
+ if (context.meta && capabilities && !(0, utils_1.checkMeta)(capabilities.meta, context.meta))
142
+ return false;
143
+ // ordering
144
+ if (module[SymbolModuleOrdering])
137
145
  return true;
138
- module.__ordering = true;
146
+ module[SymbolModuleOrdering] = true;
139
147
  // dependencies
140
148
  if (!__orderDependencies(context, modules, module, moduleRelativeName)) {
141
149
  context.disabledModules[moduleRelativeName] = true;
@@ -382,7 +390,7 @@ function __checkSuites(context, suites) {
382
390
  for (const key in suites) {
383
391
  const suite = suites[key];
384
392
  // check if disable
385
- if (!context.disabledSuites[key]) {
393
+ if (_checkSuiteValid(context, suites, key)) {
386
394
  context.suites[key] = suite;
387
395
  }
388
396
  else {
@@ -393,4 +401,17 @@ function __checkSuites(context, suites) {
393
401
  }
394
402
  }
395
403
  }
404
+ function _checkSuiteValid(context, suites, suiteRelativeName) {
405
+ // suite
406
+ const suite = suites[suiteRelativeName];
407
+ // check if disable
408
+ if (context.disabledSuites[suiteRelativeName])
409
+ return false;
410
+ // check meta
411
+ const capabilities = suite.package.zovaModule?.capabilities ?? suite.package.vonaModule?.capabilities;
412
+ if (context.meta && capabilities && !(0, utils_1.checkMeta)(capabilities.meta, context.meta))
413
+ return false;
414
+ // ok
415
+ return true;
416
+ }
396
417
  //# sourceMappingURL=index.js.map
@@ -5,6 +5,8 @@ export interface IModuleGlobOptions {
5
5
  disabledModules?: string[] | string;
6
6
  disabledSuites?: string[] | string;
7
7
  log?: boolean;
8
+ meta?: {};
9
+ disableCheckDependencies?: boolean;
8
10
  }
9
11
  export interface IModuleGlobContext {
10
12
  options: IModuleGlobOptions;
@@ -21,6 +23,7 @@ export interface IModuleGlobContext {
21
23
  suitesVendor: Record<string, ISuite>;
22
24
  disabledModules: Record<string, boolean>;
23
25
  disabledSuites: Record<string, boolean>;
26
+ meta?: {};
24
27
  pathsMeta: IModuleGlobPathsMeta;
25
28
  }
26
29
  export interface IModuleGlobPathMetaItem {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabloy/module-glob",
3
- "version": "5.1.9",
3
+ "version": "5.1.11",
4
4
  "description": "cabloy module-glob",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,7 +32,8 @@
32
32
  "boxen": "^4.2.0",
33
33
  "chalk": "^3.0.0",
34
34
  "egg-born-utils": "^1.2.0",
35
- "@cabloy/module-info": "^1.2.3"
35
+ "@cabloy/module-info": "^1.2.5",
36
+ "@cabloy/utils": "^1.0.2"
36
37
  },
37
38
  "gitHead": "2d40c063c115b230fdbc89f5a78b4412ebd0dfc9",
38
39
  "scripts": {