@syntest/module
Advanced tools
Comparing version 0.1.0-beta.2 to 0.1.0-beta.3
@@ -6,2 +6,3 @@ export * from "./module/plugins/PluginType"; | ||
export * from "./module/Plugin"; | ||
export * from "./module/Preset"; | ||
export * from "./module/Tool"; | ||
@@ -8,0 +9,0 @@ export * from "./util/Configuration"; |
@@ -39,2 +39,3 @@ "use strict"; | ||
__exportStar(require("./module/Plugin"), exports); | ||
__exportStar(require("./module/Preset"), exports); | ||
__exportStar(require("./module/Tool"), exports); | ||
@@ -41,0 +42,0 @@ __exportStar(require("./util/Configuration"), exports); |
import { Plugin } from "./Plugin"; | ||
import { Preset } from "./Preset"; | ||
import { Tool } from "./Tool"; | ||
@@ -16,2 +17,3 @@ import { UserInterface } from "@syntest/cli-graphics"; | ||
abstract getPlugins(): Promise<Plugin[]> | Plugin[]; | ||
abstract getPresets(): Promise<Preset[]> | Preset[]; | ||
} | ||
@@ -18,0 +20,0 @@ /** |
@@ -6,2 +6,3 @@ import Yargs = require("yargs"); | ||
import { UserInterface } from "@syntest/cli-graphics"; | ||
import { Preset } from "./module/Preset"; | ||
export declare class ModuleManager { | ||
@@ -15,2 +16,3 @@ static LOGGER: any; | ||
private _plugins; | ||
private _presets; | ||
constructor(); | ||
@@ -20,2 +22,3 @@ get modules(): Map<string, Module>; | ||
get plugins(): Map<string, Map<string, Plugin>>; | ||
get presets(): Map<string, Preset>; | ||
getPlugin(type: string, name: string): Plugin; | ||
@@ -28,6 +31,7 @@ getPluginsOfType(type: string): Map<string, Plugin>; | ||
loadModules(modules: string[], userInterface: UserInterface): Promise<void>; | ||
loadPreset(preset: Preset): void; | ||
loadTool(tool: Tool): void; | ||
loadPlugin(plugin: Plugin): void; | ||
configureModules(yargs: Yargs.Argv): Promise<Yargs.Argv<{}>>; | ||
configureModules(yargs: Yargs.Argv, preset: string): Promise<Yargs.Argv<{}>>; | ||
} | ||
//# sourceMappingURL=ModuleManager.d.ts.map |
@@ -53,2 +53,3 @@ "use strict"; | ||
this._plugins = new Map(); | ||
this._presets = new Map(); | ||
} | ||
@@ -64,2 +65,5 @@ get modules() { | ||
} | ||
get presets() { | ||
return this._presets; | ||
} | ||
getPlugin(type, name) { | ||
@@ -178,5 +182,16 @@ if (!this._plugins.has(type)) { | ||
} | ||
// Load presets | ||
for (const preset of yield module.getPresets()) { | ||
this.loadPreset(preset); | ||
} | ||
} | ||
}); | ||
} | ||
loadPreset(preset) { | ||
if (this.presets.has(preset.name)) { | ||
throw new Error((0, diagnostics_1.presetAlreadyLoaded)(preset.name)); | ||
} | ||
ModuleManager.LOGGER.info(`Preset loaded: ${preset.name}`); | ||
this.presets.set(preset.name, preset); | ||
} | ||
loadTool(tool) { | ||
@@ -199,3 +214,3 @@ if (this.tools.has(tool.name)) { | ||
} | ||
configureModules(yargs) { | ||
configureModules(yargs, preset) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -213,2 +228,7 @@ ModuleManager.LOGGER.info("Configuring modules"); | ||
} | ||
ModuleManager.LOGGER.info("Setting preset"); | ||
if (!this.presets.has(preset)) { | ||
throw new Error((0, diagnostics_1.presetNotFound)(preset)); | ||
} | ||
yargs = yargs.middleware(this.presets.get(preset).modifyArgs); | ||
return yargs; | ||
@@ -215,0 +235,0 @@ }); |
@@ -5,2 +5,3 @@ import Yargs = require("yargs"); | ||
config: string; | ||
preset: string; | ||
}; | ||
@@ -25,2 +26,4 @@ export type StorageOptions = { | ||
} & { | ||
preset: string; | ||
} & { | ||
modules: any[] | string[]; | ||
@@ -27,0 +30,0 @@ } & { |
@@ -45,2 +45,11 @@ "use strict"; | ||
}) | ||
.option("preset", { | ||
alias: [], | ||
choices: ["none"], | ||
default: "none", | ||
description: "The preset you want to use", | ||
group: OptionGroups.General, | ||
hidden: false, | ||
type: "string", | ||
}) | ||
.option("modules", { | ||
@@ -47,0 +56,0 @@ alias: ["m"], |
@@ -15,4 +15,6 @@ /** | ||
export declare const cannotAddChoicesToOptionWithoutChoices: (option: string, plugin: string) => string; | ||
export declare const presetAlreadyLoaded: (name: string) => string; | ||
export declare const presetNotFound: (name: string) => string; | ||
export declare const singletonNotSet: (name: string) => string; | ||
export declare const singletonAlreadySet: (name: string) => string; | ||
//# sourceMappingURL=diagnostics.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.singletonAlreadySet = exports.singletonNotSet = exports.cannotAddChoicesToOptionWithoutChoices = exports.toolAlreadyLoaded = exports.pluginAlreadyLoaded = exports.pluginRequiresOptions = exports.pluginNotFound = exports.pluginsNotFound = exports.moduleAlreadyLoaded = exports.moduleCannotBeLoaded = exports.moduleNotCorrectlyImplemented = exports.moduleNotInstalled = exports.modulePathNotFound = void 0; | ||
exports.singletonAlreadySet = exports.singletonNotSet = exports.presetNotFound = exports.presetAlreadyLoaded = exports.cannotAddChoicesToOptionWithoutChoices = exports.toolAlreadyLoaded = exports.pluginAlreadyLoaded = exports.pluginRequiresOptions = exports.pluginNotFound = exports.pluginsNotFound = exports.moduleAlreadyLoaded = exports.moduleCannotBeLoaded = exports.moduleNotCorrectlyImplemented = exports.moduleNotInstalled = exports.modulePathNotFound = void 0; | ||
/** | ||
@@ -50,2 +50,7 @@ * This file is meant to provide consistent error messages throughout the tool. | ||
exports.cannotAddChoicesToOptionWithoutChoices = cannotAddChoicesToOptionWithoutChoices; | ||
// Presets | ||
const presetAlreadyLoaded = (name) => `Could not load preset\nPreset with name '${name}' is already loaded.`; | ||
exports.presetAlreadyLoaded = presetAlreadyLoaded; | ||
const presetNotFound = (name) => `Could not load preset\nPreset with name '${name}' not found.`; | ||
exports.presetNotFound = presetNotFound; | ||
// Singletons | ||
@@ -52,0 +57,0 @@ const singletonNotSet = (name) => `The ${name} singleton has not been set yet!`; |
{ | ||
"name": "@syntest/module", | ||
"version": "0.1.0-beta.2", | ||
"version": "0.1.0-beta.3", | ||
"description": "The module library of the SynTest Framework", | ||
@@ -55,3 +55,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "62181fd9d2f6977c808271acd5fd66d5838aeb25" | ||
"gitHead": "8cc8c8eff9b686364ff41bd96f23a63272077b32" | ||
} |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
96855
49
853