Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@syntest/module

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syntest/module - npm Package Compare versions

Comparing version 0.2.0-beta.3 to 0.2.0-beta.4

dist/lib/Configuration.d.ts

3

dist/index.d.ts

@@ -10,6 +10,5 @@ export * from "./lib/extension/plugins/PluginType";

export * from "./lib/extension/Tool";
export * from "./lib/util/Configuration";
export * from "./lib/util/diagnostics";
export * from "./lib/Configuration";
export * from "./lib/util/extractArgumentValues";
export * from "./lib/ModuleManager";
//# sourceMappingURL=index.d.ts.map

@@ -43,6 +43,5 @@ "use strict";

__exportStar(require("./lib/extension/Tool"), exports);
__exportStar(require("./lib/util/Configuration"), exports);
__exportStar(require("./lib/util/diagnostics"), exports);
__exportStar(require("./lib/Configuration"), exports);
__exportStar(require("./lib/util/extractArgumentValues"), exports);
__exportStar(require("./lib/ModuleManager"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tool = void 0;
const diagnostics_1 = require("../util/diagnostics");
/*
* Copyright 2020-2023 SynTest contributors
*
* This file is part of SynTest Framework - SynTest Framework.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const diagnostics_1 = require("@syntest/diagnostics");
const Extension_1 = require("./Extension");

@@ -56,3 +73,8 @@ class Tool extends Extension_1.Extension {

if (!this.toolOptions.get(option).choices) {
throw new Error((0, diagnostics_1.cannotAddChoicesToOptionWithoutChoices)(option, plugin.name));
throw new diagnostics_1.IllegalStateError("Could not add choices to option as option does not have choices", {
context: {
option: option,
plugin: plugin.name,
},
});
}

@@ -79,3 +101,8 @@ const newOption = {

if (!command.options.get(option).choices) {
throw new Error((0, diagnostics_1.cannotAddChoicesToOptionWithoutChoices)(option, plugin.name));
throw new diagnostics_1.IllegalStateError("Could not add choices to option as option does not have choices", {
context: {
option: option,
plugin: plugin.name,
},
});
}

@@ -82,0 +109,0 @@ command.options.get(option).choices = [

@@ -38,3 +38,3 @@ import { UserInterface } from "@syntest/cli-graphics";

cleanup(): Promise<void>;
getModulePath(module: string): string;
protected getModulePath(module: string): string;
loadModule(moduleId: string, modulePath: string): Promise<void>;

@@ -41,0 +41,0 @@ loadModules(modulesIds: string[]): Promise<void>;

@@ -23,7 +23,7 @@ "use strict";

const path = require("node:path");
const diagnostics_1 = require("@syntest/diagnostics");
const logging_1 = require("@syntest/logging");
const globalModules = require("global-modules");
const Configuration_1 = require("./Configuration");
const PluginType_1 = require("./extension/plugins/PluginType");
const Configuration_1 = require("./util/Configuration");
const diagnostics_1 = require("./util/diagnostics");
class ModuleManager {

@@ -85,9 +85,9 @@ constructor(metricManager, storageManager, userInterface) {

getPlugin(type, name) {
if (!this._plugins.has(type)) {
throw new Error((0, diagnostics_1.pluginNotFound)(name, type));
const pluginsOfType = this.getPluginsOfType(type);
if (!pluginsOfType.has(name)) {
throw new diagnostics_1.IllegalStateError("Plugin not found", {
context: { type: type, name: name },
});
}
if (!this._plugins.get(type).has(name)) {
throw new Error((0, diagnostics_1.pluginNotFound)(name, type));
}
return this._plugins.get(type).get(name);
return pluginsOfType.get(name);
}

@@ -185,3 +185,5 @@ getPluginsOfType(type) {

if (!(0, node_fs_1.existsSync)(modulePath)) {
throw new Error((0, diagnostics_1.modulePathNotFound)(module));
throw new diagnostics_1.IOError("Could not find filepath of module", {
context: { module: module },
});
}

@@ -200,3 +202,5 @@ }

// TODO maybe auto install?
throw new Error((0, diagnostics_1.moduleNotInstalled)(module));
throw new diagnostics_1.IOError("Module is not installed locally nor globally", {
context: { module: module },
});
}

@@ -214,9 +218,13 @@ }

if (!moduleInstance.name) {
throw new Error((0, diagnostics_1.moduleNotCorrectlyImplemented)("name", moduleId));
throw new diagnostics_1.IOError("Incorrect module implementation", {
context: { moduleId: moduleId, missing: "name" },
});
}
if (!moduleInstance.register) {
throw new Error((0, diagnostics_1.moduleNotCorrectlyImplemented)("register", moduleId));
throw new diagnostics_1.IOError("Incorrect module implementation", {
context: { moduleId: moduleId, missing: "register" },
});
}
if (this.modules.has(moduleInstance.name)) {
throw new Error((0, diagnostics_1.moduleAlreadyLoaded)(moduleInstance.name, moduleId));
throw new diagnostics_1.IOError("Module already loaded, possible duplicate module name", { context: { moduleId: moduleId, name: moduleInstance.name } });
}

@@ -232,11 +240,5 @@ this._modules.set(moduleInstance.name, moduleInstance);

for (const module of modulesIds) {
try {
ModuleManager.LOGGER.info(`Loading module: ${module}`);
const modulePath = this.getModulePath(module);
await this.loadModule(module, modulePath);
}
catch (error) {
console.log(error);
throw new Error((0, diagnostics_1.moduleCannotBeLoaded)(module));
}
ModuleManager.LOGGER.info(`Loading module: ${module}`);
const modulePath = this.getModulePath(module);
await this.loadModule(module, modulePath);
}

@@ -250,3 +252,5 @@ const modules = [...this.modules.values()];

if (this._presets.has(preset.name)) {
throw new Error((0, diagnostics_1.presetAlreadyLoaded)(preset.name));
throw new diagnostics_1.IllegalArgumentError("Preset name already registered", {
context: { name: preset.name },
});
}

@@ -259,3 +263,5 @@ ModuleManager.LOGGER.info(`Preset loaded: ${preset.name}`);

if (this._tools.has(tool.name)) {
throw new Error((0, diagnostics_1.toolAlreadyLoaded)(tool.name));
throw new diagnostics_1.IllegalArgumentError("Tool name already registered", {
context: { name: tool.name },
});
}

@@ -271,3 +277,5 @@ ModuleManager.LOGGER.info(`Tool loaded: ${tool.name}`);

if (this._plugins.get(plugin.type).has(plugin.name)) {
throw new Error((0, diagnostics_1.pluginAlreadyLoaded)(plugin.name, plugin.type));
throw new diagnostics_1.IllegalArgumentError("Plugin name already registered", {
context: { name: plugin.name, type: plugin.type },
});
}

@@ -309,4 +317,5 @@ ModuleManager.LOGGER.info(`- Plugin loaded: ${plugin.type} - ${plugin.name}`);

if (!this._presets.has(presetChoice)) {
ModuleManager.LOGGER.error(`Preset not found: ${presetChoice}`);
throw new Error((0, diagnostics_1.presetNotFound)(presetChoice));
throw new diagnostics_1.IllegalArgumentError("Preset not found", {
context: { name: presetChoice },
});
}

@@ -313,0 +322,0 @@ const presetObject = this._presets.get(presetChoice);

{
"name": "@syntest/module",
"version": "0.2.0-beta.3",
"version": "0.2.0-beta.4",
"description": "SynTest library for a modular and extendable ecosystem",

@@ -51,6 +51,7 @@ "keywords": [

"dependencies": {
"@syntest/cli-graphics": "^0.3.0-beta.0",
"@syntest/logging": "^0.2.0-beta.1",
"@syntest/metric": "^0.1.2-beta.3",
"@syntest/storage": "^0.3.0-beta.1",
"@syntest/cli-graphics": "^0.3.0-beta.1",
"@syntest/diagnostics": "^0.1.0-beta.0",
"@syntest/logging": "^0.2.0-beta.2",
"@syntest/metric": "^0.2.0-beta.0",
"@syntest/storage": "^0.3.0-beta.2",
"global-modules": "2.0.0",

@@ -65,3 +66,3 @@ "yargs": "^17.7.1"

},
"gitHead": "20ce3f59489341e9e9ba8f3a441b516a5d625d9a"
"gitHead": "3f6b9612c030ffc79d5e79c5c1c126ca816a87a6"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc