@artus/core
Advanced tools
Comparing version 1.0.0-beta.17 to 1.0.0-beta.18
@@ -28,3 +28,4 @@ "use strict"; | ||
if (pluginConfigItem.enable) { | ||
pluginConfigItem.path = plugin_1.ArtusPlugin.getPath(pluginConfigItem.package); | ||
const loaderState = item._loaderState; | ||
pluginConfigItem.path = plugin_1.ArtusPlugin.getPath(pluginConfigItem.package, [loaderState.baseDir]); | ||
} | ||
@@ -31,0 +32,0 @@ delete pluginConfigItem.package; |
import { Plugin, PluginConfigItem, PluginMetadata } from "./types"; | ||
declare type PluginMap = Map<string, BasePlugin>; | ||
export declare class BasePlugin implements Plugin { | ||
static getPath(packageName: string): string; | ||
static getPath(packageName: string, paths?: string[]): string; | ||
name: string; | ||
@@ -6,0 +6,0 @@ enable: boolean; |
@@ -28,4 +28,5 @@ "use strict"; | ||
} | ||
static getPath(packageName) { | ||
return path_1.default.resolve(require.resolve(packageName), '..'); | ||
static getPath(packageName, paths) { | ||
const opts = paths ? { paths } : undefined; | ||
return path_1.default.resolve(require.resolve(packageName, opts), '..'); | ||
} | ||
@@ -32,0 +33,0 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function |
@@ -8,2 +8,3 @@ "use strict"; | ||
const fs = tslib_1.__importStar(require("fs/promises")); | ||
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge")); | ||
const injection_1 = require("@artus/injection"); | ||
@@ -67,3 +68,3 @@ const constant_1 = require("../constant"); | ||
async scanManifestByEnv(root, env) { | ||
var _a; | ||
var _a, _b; | ||
// 0. init clean itemMap | ||
@@ -74,3 +75,4 @@ await this.initItemMap(); | ||
// 2. scan all file in framework | ||
const frameworkDirs = await this.getFrameworkDirs(config.framework, root, env); | ||
const frameworkConfig = (_a = this.options.framework) !== null && _a !== void 0 ? _a : config.framework; | ||
const frameworkDirs = await this.getFrameworkDirs(frameworkConfig, root, env); | ||
for (const frameworkDir of frameworkDirs) { | ||
@@ -81,7 +83,8 @@ await this.walk(frameworkDir, this.formatWalkOptions('framework', frameworkDir)); | ||
if (this.tmpConfigStore.has(env)) { | ||
const configList = (_a = this.tmpConfigStore.get(env)) !== null && _a !== void 0 ? _a : []; | ||
const configList = (_b = this.tmpConfigStore.get(env)) !== null && _b !== void 0 ? _b : []; | ||
configList.forEach(config => this.configHandle.setConfig(env, config)); | ||
} | ||
const { plugin } = this.configHandle.getMergedConfig(env); | ||
const pluginSortedList = await plugin_1.PluginFactory.createFromConfig(plugin || {}); | ||
const pluginConfig = deepmerge_1.default.all([plugin || {}, this.options.plugin || {}]); | ||
const pluginSortedList = await plugin_1.PluginFactory.createFromConfig(pluginConfig); | ||
for (const plugin of pluginSortedList) { | ||
@@ -148,2 +151,5 @@ if (!plugin.enable) | ||
source: 'config', | ||
_loaderState: { | ||
baseDir, | ||
}, | ||
}; | ||
@@ -150,0 +156,0 @@ })); |
import { BaseLoader, ManifestItem } from "../loader"; | ||
import { FrameworkConfig } from "../framework"; | ||
import { PluginConfigItem } from "../plugin/types"; | ||
export interface ScannerOptions { | ||
@@ -10,2 +12,4 @@ appName: string; | ||
envs?: string[]; | ||
framework?: FrameworkConfig; | ||
plugin?: Record<string, Partial<PluginConfigItem>>; | ||
loaderListGenerator: (defaultLoaderList: string[]) => (string | typeof BaseLoader)[]; | ||
@@ -12,0 +16,0 @@ } |
{ | ||
"name": "@artus/core", | ||
"version": "1.0.0-beta.17", | ||
"version": "1.0.0-beta.18", | ||
"description": "Core package of Artus", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
161734
2490