Socket
Socket
Sign inDemoInstall

@mocks-server/core

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mocks-server/core - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

src/Config.js

8

CHANGELOG.md

@@ -29,2 +29,10 @@ # Change Log

## [1.4.0] - 2020-01-06
### Added
- Add "addPlugins" configuration.
- Add "disableCommandLineArguments" configuration.
- Add "disableConfigFile" configuration.
- Load configuration and options from file.
- Options can also be passed to the Core Constructor, using the "options" key in the config object.
## [1.3.0] - 2020-01-03

@@ -31,0 +39,0 @@ ### Added

4

package.json
{
"name": "@mocks-server/core",
"version": "1.3.0",
"description": "Pluggable mocks server supporting multiple api behaviors",
"version": "1.4.0",
"description": "Pluggable mock server supporting multiple api behaviors",
"keywords": [

@@ -6,0 +6,0 @@ "mocks",

@@ -21,3 +21,3 @@ [![Build status][travisci-image]][travisci-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url]

* [Configuration](https://www.mocks-server.org/docs/configuration-options)
* [Plugins](https://www.mocks-server.org/docs/plugins-inquirer-cli)
* [Plugins](https://www.mocks-server.org/docs/plugins-adding-plugins)
* [Integrations](https://www.mocks-server.org/docs/integrations-cypress)

@@ -24,0 +24,0 @@ * [Api](https://www.mocks-server.org/docs/advanced-programmatic-usage)

@@ -16,2 +16,3 @@ /*

const Config = require("./Config");
const Orchestrator = require("./Orchestrator");

@@ -26,11 +27,12 @@ const Loaders = require("./Loaders");

class Core {
constructor(coreOptions = {}) {
constructor(config) {
this._eventEmitter = new EventEmitter();
this._settings = new Settings(this._eventEmitter, {
onlyProgrammaticOptions: coreOptions.onlyProgrammaticOptions
});
this._loaders = new Loaders(this);
this._plugins = new Plugins(coreOptions.plugins, this._loaders, this);
this._config = new Config(config);
this._settings = new Settings(this._eventEmitter, this._config);
this._plugins = new Plugins(this._config, this._loaders, this);
this._mocks = new Mocks(this._eventEmitter, this._settings, this._loaders, this);

@@ -42,2 +44,3 @@ this._server = new Server(this._eventEmitter, this._settings, this._mocks, this);

this._inited = false;
this._stopPluginsPromise = null;
this._startPluginsPromise = null;

@@ -50,2 +53,3 @@ }

}
await this._config.init(options);
this._inited = true;

@@ -55,3 +59,3 @@ // Register plugins, let them add their custom settings

// Init settings, read command line arguments, etc.
await this._settings.init(options);
await this._settings.init(this._config.options);
// Settings are ready, init all

@@ -58,0 +62,0 @@ await this._mocks.init();

@@ -20,6 +20,6 @@ /*

class Plugins {
constructor(plugins, loaders, core) {
constructor(config, loaders, core) {
this._config = config;
this._core = core;
this._loaders = loaders;
this._plugins = plugins || [];
this._pluginsInstances = [];

@@ -31,7 +31,7 @@ this._pluginsMethods = [];

this._pluginsStopped = 0;
this._plugins.unshift(FilesLoader);
}
register() {
this._plugins = this._config.coreOptions.plugins || [];
this._plugins.unshift(FilesLoader);
return this._registerPlugins().then(() => {

@@ -38,0 +38,0 @@ tracer.verbose(`Registered ${this._pluginsRegistered} plugins without errors`);

@@ -39,4 +39,4 @@ /*

class Options {
constructor(coreOptions = {}) {
this._onlyProgrammaticOptions = coreOptions.onlyProgrammaticOptions;
constructor(config) {
this._config = config;
this._options = {};

@@ -50,3 +50,3 @@ this._optionsNames = Object.keys(DEFAULT_OPTIONS);

async init(options) {
async init() {
if (!this._initialized) {

@@ -57,5 +57,5 @@ this._initialized = true;

...this._customDefaults,
...options
...this._config.options
};
if (!this._onlyProgrammaticOptions) {
if (!this._config.coreOptions.disableCommandLineArguments) {
await this._commandLineArguments.init();

@@ -62,0 +62,0 @@ this._options = this._getValidOptions(

@@ -18,5 +18,5 @@ /*

class Settings {
constructor(eventEmitter, coreOptions) {
constructor(eventEmitter, config) {
this._eventEmitter = eventEmitter;
this._optionsHandler = new Options(coreOptions);
this._optionsHandler = new Options(config);
this._emitChange = this._emitChange.bind(this); //Add debounce here to group change events

@@ -23,0 +23,0 @@ this._newSettings = {};

/*
Copyright 2019 XbyOrange
Copyright 2019 Javier Brea

@@ -4,0 +5,0 @@ 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

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