@artus/core
Advanced tools
Comparing version 2.1.0-alpha.0 to 2.1.0
@@ -1,5 +0,5 @@ | ||
import { PluginType } from './types'; | ||
import { LoggerType } from '../logger'; | ||
import { PluginType } from "./types"; | ||
import { LoggerType } from "../logger"; | ||
export declare function sortPlugins(pluginInstanceMap: Map<string, PluginType>, logger: LoggerType): PluginType[]; | ||
export declare function getPackagePath(packageName: string, paths?: string[]): string; | ||
export declare function getInlinePackageEntryPath(packagePath: string): Promise<string>; |
@@ -8,12 +8,14 @@ "use strict"; | ||
function sortPlugins(pluginInstanceMap, logger) { | ||
var _a; | ||
const sortedPlugins = []; | ||
const visited = {}; | ||
while (sortedPlugins.length < pluginInstanceMap.size) { | ||
let added = false; | ||
for (const [pluginName, plugin] of pluginInstanceMap) { | ||
if (visited[pluginName]) { | ||
continue; | ||
} | ||
let depsSatisfied = true; | ||
const visit = (pluginName, depChain = []) => { | ||
var _a; | ||
if (depChain.includes(pluginName)) { | ||
throw new Error(`Circular dependency found in plugins: ${depChain.join(", ")}`); | ||
} | ||
if (visited[pluginName]) | ||
return; | ||
visited[pluginName] = true; | ||
const plugin = pluginInstanceMap.get(pluginName); | ||
if (plugin) { | ||
for (const dep of (_a = plugin.metadata.dependencies) !== null && _a !== void 0 ? _a : []) { | ||
@@ -29,22 +31,12 @@ const depPlugin = pluginInstanceMap.get(dep.name); | ||
} | ||
else if (!visited[dep.name]) { // Plugin exist and enabled, need check visited | ||
depsSatisfied = false; | ||
else { | ||
// Plugin exist and enabled, need visit | ||
visit(dep.name, depChain.concat(pluginName)); | ||
} | ||
} | ||
if (depsSatisfied) { | ||
sortedPlugins.push(plugin); | ||
visited[plugin.name] = true; | ||
added = true; | ||
} | ||
sortedPlugins.push(plugin); | ||
} | ||
if (!added) { | ||
const cyclePluginNames = []; | ||
const sortedPluginSet = new Set(sortedPlugins.map(p => p.name)); | ||
for (const pluginName of pluginInstanceMap.keys()) { | ||
if (!sortedPluginSet.has(pluginName)) { | ||
cyclePluginNames.push(pluginName); | ||
} | ||
} | ||
throw new Error(`Circular dependency found in plugins: ${cyclePluginNames.join(', ')}`); | ||
} | ||
}; | ||
for (const pluginName of pluginInstanceMap.keys()) { | ||
visit(pluginName); | ||
} | ||
@@ -65,3 +57,3 @@ return sortedPlugins; | ||
const pkgJson = await (0, compatible_require_1.default)(`${packagePath}/package.json`); | ||
let entryFilePath = ''; | ||
let entryFilePath = ""; | ||
if (pkgJson.exports) { | ||
@@ -71,7 +63,7 @@ if (Array.isArray(pkgJson.exports)) { | ||
} | ||
else if (typeof pkgJson.exports === 'string') { | ||
else if (typeof pkgJson.exports === "string") { | ||
entryFilePath = pkgJson.exports; | ||
} | ||
else if ((_a = pkgJson.exports) === null || _a === void 0 ? void 0 : _a['.']) { | ||
entryFilePath = pkgJson.exports['.']; | ||
else if ((_a = pkgJson.exports) === null || _a === void 0 ? void 0 : _a["."]) { | ||
entryFilePath = pkgJson.exports["."]; | ||
} | ||
@@ -83,4 +75,6 @@ } | ||
// will use package root path if no entry file found | ||
return entryFilePath ? path_1.default.resolve(packagePath, entryFilePath, '..') : packagePath; | ||
return entryFilePath | ||
? path_1.default.resolve(packagePath, entryFilePath, "..") | ||
: packagePath; | ||
} | ||
exports.getInlinePackageEntryPath = getInlinePackageEntryPath; |
{ | ||
"name": "@artus/core", | ||
"version": "2.1.0-alpha.0", | ||
"version": "2.1.0", | ||
"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
99865
101
2423