@artus/core
Advanced tools
Comparing version 2.0.4-alpha.0 to 2.0.4
@@ -6,2 +6,3 @@ "use strict"; | ||
const impl_1 = require("./impl"); | ||
const is_1 = require("../utils/is"); | ||
const matchExceptionFilterClazz = (err, container) => { | ||
@@ -14,16 +15,19 @@ const filterMap = container.get(constant_1.EXCEPTION_FILTER_MAP_INJECT_ID, { | ||
} | ||
let targetFilterClazz = null; | ||
// handle ArtusStdError with code simply | ||
if (err instanceof impl_1.ArtusStdError && filterMap.has(err.code)) { | ||
// handle ArtusStdError with code simply | ||
targetFilterClazz = filterMap.get(err.code); | ||
return filterMap.get(err.code); | ||
} | ||
else if (filterMap.has(err['constructor'])) { | ||
// handle CustomErrorClazz | ||
targetFilterClazz = filterMap.get(err['constructor']); | ||
// handle CustomErrorClazz, loop inherit class | ||
let errConstructor = err['constructor']; | ||
while ((0, is_1.isClass)(errConstructor)) { // until parent/self is not class | ||
if (filterMap.has(errConstructor)) { | ||
return filterMap.get(errConstructor); | ||
} | ||
errConstructor = Object.getPrototypeOf(errConstructor); // get parent clazz by prototype | ||
} | ||
else if (filterMap.has(constant_1.EXCEPTION_FILTER_DEFAULT_SYMBOL)) { | ||
// handle default ExceptionFilter | ||
targetFilterClazz = filterMap.get(constant_1.EXCEPTION_FILTER_DEFAULT_SYMBOL); | ||
// handle default ExceptionFilter | ||
if (filterMap.has(constant_1.EXCEPTION_FILTER_DEFAULT_SYMBOL)) { | ||
return filterMap.get(constant_1.EXCEPTION_FILTER_DEFAULT_SYMBOL); | ||
} | ||
return targetFilterClazz; | ||
return null; | ||
}; | ||
@@ -30,0 +34,0 @@ exports.matchExceptionFilterClazz = matchExceptionFilterClazz; |
@@ -38,5 +38,7 @@ "use strict"; | ||
// A util function of get package path for plugin | ||
function getPackagePath(packageName, paths) { | ||
const opts = paths ? { paths } : undefined; | ||
return path_1.default.resolve(require.resolve(packageName, opts), '..'); | ||
function getPackagePath(packageName, paths = []) { | ||
const opts = { | ||
paths: paths.concat(__dirname), | ||
}; | ||
return path_1.default.dirname(require.resolve(packageName, opts)); | ||
} | ||
@@ -43,0 +45,0 @@ exports.getPackagePath = getPackagePath; |
@@ -48,8 +48,12 @@ "use strict"; | ||
checkDepExisted(pluginMap) { | ||
var _a, _b; | ||
for (const { name: pluginName, optional } of (_a = this.metadata.dependencies) !== null && _a !== void 0 ? _a : []) { | ||
var _a; | ||
if (!this.metadata.dependencies) { | ||
return; | ||
} | ||
for (let i = 0; i < this.metadata.dependencies.length; i++) { | ||
const { name: pluginName, optional } = this.metadata.dependencies[i]; | ||
const instance = pluginMap.get(pluginName); | ||
if (!instance || !instance.enable) { | ||
if (optional) { | ||
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.warn(`Plugin ${this.name} need have optional dependency: ${pluginName}.`); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.warn(`Plugin ${this.name} need have optional dependency: ${pluginName}.`); | ||
} | ||
@@ -60,2 +64,6 @@ else { | ||
} | ||
else { | ||
// Plugin exist and enabled, need calc edge | ||
this.metadata.dependencies[i]._enabled = true; | ||
} | ||
} | ||
@@ -65,3 +73,3 @@ } | ||
var _a, _b, _c; | ||
return (_c = (_b = (_a = this.metadata.dependencies) === null || _a === void 0 ? void 0 : _a.filter(({ optional }) => !optional)) === null || _b === void 0 ? void 0 : _b.map(({ name: depPluginName }) => [this.name, depPluginName])) !== null && _c !== void 0 ? _c : []; | ||
return (_c = (_b = (_a = this.metadata.dependencies) === null || _a === void 0 ? void 0 : _a.filter(({ optional, _enabled }) => !optional || _enabled)) === null || _b === void 0 ? void 0 : _b.map(({ name: depPluginName }) => [this.name, depPluginName])) !== null && _c !== void 0 ? _c : []; | ||
} | ||
@@ -68,0 +76,0 @@ async checkAndLoadMetadata() { |
@@ -15,2 +15,3 @@ import { LoggerType } from '../logger'; | ||
optional?: boolean; | ||
_enabled?: boolean; | ||
} | ||
@@ -17,0 +18,0 @@ export interface PluginConfigItem { |
{ | ||
"name": "@artus/core", | ||
"version": "2.0.4-alpha.0", | ||
"version": "2.0.4", | ||
"description": "Core package of Artus", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
9
101817
101
2461