Skip to content

Commit

Permalink
refactor: using Lerna multiple packages
Browse files Browse the repository at this point in the history
See #159 (comment)

BREAKING CHANGE: Remove `MomgoMemoryServer.getInstanceData()` method. Use `MomgoMemoryServer.ensureInstance()` instead.
  • Loading branch information
nodkz committed Apr 10, 2019
1 parent c039b8e commit e80e0f2
Show file tree
Hide file tree
Showing 69 changed files with 132 additions and 48 deletions.
13 changes: 9 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"packages": [
"packages/*"
],
"version": "0.0.0"
"lerna": "2.11.0",
"version": "4.2.2",
"command": {
"publish": {
"allowBranch": ["master", "lerna"],
"conventionalCommits": true,
"githubRelease": true
}
}
}
9 changes: 9 additions & 0 deletions packages/mongodb-memory-server-core/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2017-present Pavel Chertorogov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions packages/mongodb-memory-server-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "mongodb-memory-server-core",
"version": "4.2.2",
"description": "In-memory MongoDB Server. Designed with testing in mind, the server will allow you to connect your favourite ODM or client library to the MongoDB Server and run integration tests isolated from each other.",
"main": "lib/index",
"types": "lib/index.d.ts",
"repository": "https://github.com/nodkz/mongodb-memory-server",
"files": [
"lib",
"scripts"
],
"keywords": [
"mongodb",
"mongoose",
"mock",
"stub",
"mockgoose",
"mongodb-prebuilt",
"mongomem"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nodkz/mongodb-memory-server/issues"
},
"homepage": "https://github.com/nodkz/mongodb-memory-server",
"dependencies": {
"debug": "^4.1.1",
"decompress": "^4.2.0",
"dedent": "^0.7.0",
"find-cache-dir": "^2.0.0",
"get-port": "^4.2.0",
"getos": "^3.1.1",
"https-proxy-agent": "^2.2.1",
"lockfile": "^1.0.4",
"md5-file": "^4.0.0",
"mkdirp": "^0.5.1",
"tmp": "^0.0.33",
"uuid": "^3.2.1"
},
"optionalDependencies": {
"mongodb": ">=3.0.0"
},
"scripts": {
"build": "npm-run-all build:*",
"build:ts": "rimraf ./lib && tsc -p ../../tsconfig.build.json",
"disabled-build:flow": "find ./lib -name \"*.d.ts\" -exec bash -c './node_modules/.bin/flowgen --add-flow-header \"$1\" -o \"${1%.d.ts}\".js.flow' - '{}' \\;",
"watch": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --watch",
"coverage": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --coverage",
"lint": "eslint 'src/**/*.{js,ts}'",
"test": "npm run lint && npm run tscheck && npm run coverage",
"tscheck": "tsc --noEmit"
}
}
34 changes: 34 additions & 0 deletions packages/mongodb-memory-server-core/scripts/mongo_killer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Make sure every few seconds that `parent` and `child` are alive:
- if `parent` is dead:
- kill child
- kill itself
- if `child` is dead:
- kill itself
*/

const parentPid = parseInt(process.argv[2], 10);
const childPid = parseInt(process.argv[3], 10);

if (parentPid && childPid) {
setInterval(() => {
// if parent dead
try {
process.kill(parentPid, 0);
} catch (e) {
try {
process.kill(childPid);
} catch (ee) {
// doesnt matter if it is dead
}
process.exit();
}

// if child dead
try {
process.kill(childPid, 0);
} catch (e) {
process.exit();
}
}, 2000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SpawnOptions,
} from './types';
import { SynchrounousResult } from 'tmp';
import { deprecate } from './util/deprecate';
// import { deprecate } from './util/deprecate';

tmp.setGracefulCleanup();

Expand Down Expand Up @@ -169,14 +169,6 @@ export default class MongoMemoryServer {
return this.instanceInfoSync || false;
}

/* @deprecated 5.0.0 */
async getInstanceData(): Promise<MongoInstanceDataT> {
deprecate(
`method MongoMemoryServer.getInstanceData() will be deprecated. Please use 'MongoMemoryServer.ensureInstance()' method instead.`
);
return this.ensureInstance();
}

async ensureInstance(): Promise<MongoInstanceDataT> {
this.debug('Called MongoMemoryServer.ensureInstance() method:');
if (!this.runningInstance) {
Expand Down
7 changes: 7 additions & 0 deletions packages/mongodb-memory-server-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MongoBinary from './util/MongoBinary';
import MongoInstance from './util/MongoInstance';
import MongoMemoryServer from './MongoMemoryServer';
import MongoMemoryReplSet from './MongoMemoryReplSet';

export default MongoMemoryServer;
export { MongoBinary, MongoInstance, MongoMemoryServer, MongoMemoryReplSet };
File renamed without changes.
16 changes: 16 additions & 0 deletions packages/mongodb-memory-server-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib",
"noEmit": false,
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": false
},
"include": ["src/**/*"],
"exclude": ["**/__tests__"]
}
30 changes: 2 additions & 28 deletions packages/mongodb-memory-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,11 @@
},
"homepage": "https://github.com/nodkz/mongodb-memory-server",
"dependencies": {
"debug": "^4.1.1",
"decompress": "^4.2.0",
"dedent": "^0.7.0",
"find-cache-dir": "^2.0.0",
"get-port": "^4.2.0",
"getos": "^3.1.1",
"https-proxy-agent": "^2.2.1",
"lockfile": "^1.0.4",
"md5-file": "^4.0.0",
"mkdirp": "^0.5.1",
"tmp": "^0.0.33",
"uuid": "^3.2.1"
},
"optionalDependencies": {
"mongodb": ">=3.0.0"
"mongodb-memory-server-core": "^4.2.2"
},
"scripts": {
"build": "npm-run-all build:*",
"build:ts": "rimraf ./lib && tsc -p ./tsconfig.build.json",
"disabled-build:flow": "find ./lib -name \"*.d.ts\" -exec bash -c './node_modules/.bin/flowgen --add-flow-header \"$1\" -o \"${1%.d.ts}\".js.flow' - '{}' \\;",
"watch": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --watch",
"coverage": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --coverage",
"lint": "eslint 'src/**/*.{js,ts}'",
"test": "npm run lint && npm run tscheck && npm run coverage",
"tscheck": "tsc --noEmit",
"semantic-release": "semantic-release",
"build:ts": "rimraf ./lib && tsc -p ../../tsconfig.build.json",
"postinstall": "node ./scripts/postinstall.js"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
8 changes: 1 addition & 7 deletions packages/mongodb-memory-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import MongoBinary from './util/MongoBinary';
import MongoInstance from './util/MongoInstance';
import MongoMemoryServer from './MongoMemoryServer';
import MongoMemoryReplSet from './MongoMemoryReplSet';

export default MongoMemoryServer;
export { MongoBinary, MongoInstance, MongoMemoryServer, MongoMemoryReplSet };
export * from 'mongodb-memory-server-core';

0 comments on commit e80e0f2

Please sign in to comment.