Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.

Commit 41355ff

Browse files
authored
Merge pull request #28 from mocks-server/v1.3.0
V1.3.0
2 parents 8b6fbfe + 8fd563f commit 41355ff

127 files changed

Lines changed: 6976 additions & 2485 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# tests
1010
/coverage
1111
/mocks
12+
/test/acceptance/main/fixtures/files-watch
1213

1314
# misc
1415
.DS_Store

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [To be deprecated]
88
- Deprecate options "features" and "feature".
99
- Remove "/features" api path.
10+
- Remove "features" getter from Server
11+
- Remove Server and Cli constructors. Use @mocks-server/core instead
1012

1113
## [unreleased]
1214
### Added
1315
### Changed
1416
### Fixed
1517
### Removed
1618

19+
## [1.3.0] - 2019-11-17
20+
### Added
21+
- Add programmatic Classes end-to-end tests
22+
- Add files watcher end-to-end tests
23+
24+
### Changed
25+
- Full refactor for making it pluggable.
26+
- Split code into core, cli and api main Classes, which are intended to be published separately.
27+
1728
## [1.2.0] - 2019-11-13
1829
### Added
1930
- Add api acceptance tests

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Please refer to the [project documentation website][website-url]:
1515

1616
* [Get started](https://www.mocks-server.org/docs/get-started-intro)
1717
* [Tutorials](https://www.mocks-server.org/docs/tutorials-static)
18-
* [configuration](https://www.mocks-server.org/docs/configuration-command-line-arguments)
18+
* [Configuration](https://www.mocks-server.org/docs/configuration-command-line-arguments)
1919

2020
## Why a mocks server?
2121

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Unless required by applicable law or agreed to in writing, software distributed
1111

1212
"use strict";
1313

14-
const Cli = require("./lib/Cli");
15-
const Server = require("./lib/Server");
16-
const Feature = require("./lib/features/Feature");
14+
const ProgrammaticCli = require("./lib/ProgrammaticCli");
15+
const ProgrammaticServer = require("./lib/ProgrammaticServer");
16+
const Behavior = require("./lib/core/mocks/Behavior");
1717

1818
module.exports = {
19-
Cli,
20-
Server,
21-
Feature,
22-
Behavior: Feature
19+
Cli: ProgrammaticCli,
20+
Server: ProgrammaticServer,
21+
Feature: Behavior,
22+
Behavior
2323
};

jest.acceptance.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
clearMocks: true,
77

88
testMatch: ["**/test/acceptance/**/?(*.)+(spec|test).js?(x)"],
9+
//testMatch: ["**/test/acceptance/main/programmatic-cli.spec.js"],
910

1011
// Indicates whether the coverage information should be collected while executing the test
1112
collectCoverage: false,

jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ module.exports = {
2424
}
2525
},
2626

27-
// The test environment that will be used for testing
28-
testEnvironment: "node",
29-
3027
// The glob patterns Jest uses to detect test files
31-
testMatch: ["**/test/unit/**/?(*.)+(spec|test).js?(x)"]
32-
//testMatch: ["**/test/unit/**/options.spec.js"]
28+
testMatch: ["**/test/unit/**/?(*.)+(spec|test).js?(x)"],
29+
//testMatch: ["**/test/unit/core/Plugins.spec.js"],
30+
31+
// The test environment that will be used for testing
32+
testEnvironment: "node"
3333
};

lib/Cli.js

Lines changed: 0 additions & 214 deletions
This file was deleted.

lib/ProgrammaticCli.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2019 Javier Brea
3+
4+
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
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
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.
9+
*/
10+
11+
"use strict";
12+
13+
// TODO, deprecate this programmatic initialization. Use Core instead.
14+
15+
const Core = require("./core/Core");
16+
const AdminApi = require("./api/Api");
17+
const InquirerCli = require("./cli/Cli");
18+
19+
class ProgrammaticCli {
20+
constructor(options = {}) {
21+
const createInquirerCli = core => {
22+
this._inquirerCli = new InquirerCli(core);
23+
return this._inquirerCli;
24+
};
25+
26+
this._core = new Core({
27+
onlyProgrammaticOptions: true,
28+
plugins: [AdminApi, createInquirerCli]
29+
});
30+
this._options = { ...options };
31+
this._cliStarted = false;
32+
this._coreStarted = false;
33+
this._core.tracer.warn(
34+
"Deprecation warning: Cli constructor will be deprecated. Use @mocks-server/core instead"
35+
);
36+
}
37+
38+
async _startCore(cliEnabled) {
39+
if (!this._coreStarted) {
40+
this._coreStarted = true;
41+
await this._core.init(this._options);
42+
this._core.settings.set("cli", cliEnabled);
43+
return this._core.start();
44+
}
45+
return Promise.resolve();
46+
}
47+
48+
async start() {
49+
await this._startCore(true);
50+
if (!this._cliStarted && !this._core.settings.get("cli")) {
51+
this._core.settings.set("cli", true);
52+
this._cliStarted = true;
53+
return this._inquirerCli.start();
54+
}
55+
return Promise.resolve();
56+
}
57+
58+
async initServer() {
59+
return this._startCore(false);
60+
}
61+
62+
stopListeningServerWatch() {
63+
return this._inquirerCli.stopListeningServerWatch();
64+
}
65+
}
66+
67+
module.exports = ProgrammaticCli;

0 commit comments

Comments
 (0)