Skip to content

Commit

Permalink
feat: add additional packages with specific default configs
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Apr 10, 2019
1 parent e80e0f2 commit 9cca8f6
Show file tree
Hide file tree
Showing 84 changed files with 434 additions and 2,365 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ node_modules
.node_repl_history

# Transpiled code
/es
/lib
lib
packages/mongodb-memory-server-core/lib

coverage
.nyc_output
package-lock.json
package-lock.json
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cache:
notifications:
email: true
node_js:
- "10"
- "8"
- '10'
- '8'
script:
- yarn run test
- yarn run build
Expand All @@ -17,7 +17,7 @@ after_success:
- python travis_after_all.py
- export $(cat .to_export_back) &> /dev/null
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then npm run semantic-release; fi
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then npm run publish; fi
branches:
except:
- /^v\d+\.\d+\.\d+$/
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,69 @@ This package spins up a actual/real MongoDB Server programmatically from node fo

This package on first start downloads the latest MongoDB binaries and save it to `node_modules/.cache/mongodb-memory-server/mongodb-binaries` folder. So first run may take a time. All further runs will fast, because use already downloaded binaries.

This package automatically downloads binaries from [https://fastdl.mongodb.org/](https://fastdl.mongodb.org/) according to your operation system. You can see all available versions by the following links [Linux](https://www.mongodb.org/dl/linux) (Ubuntu, RHEL, Debian, SUSE, Amazon), [OSX](https://www.mongodb.org/dl/osx), [Win](https://www.mongodb.org/dl/win32).

Every `MongoMemoryServer` instance creates and starts fresh MongoDB server on some free port. You may start up several mongod simultaneously. When you terminate your script or call `stop()` MongoDB server(s) will be automatically shutdown.

Perfectly [works with Travis CI](https://github.com/nodkz/graphql-compose-mongoose/commit/7a6ac2de747d14281f9965f418065e97a57cfb37) without additional `services` and `addons` options in `.travis.yml`.

## Installation

This tool provides several packages for different purposes:

- with auto-download mongod binary on npm install (5 different ways)
- without auto-download (core package)

Choose any package, because they are the same. Differs only by default configuration, which you may override (see section [Available options](#available-options)).

### With auto-download `latest` Mongod binary on npm install to `node_modules/.cache`

```bash
yarn add mongodb-memory-server --dev
OR
npm install mongodb-memory-server --save-dev
```

### With auto-download `latest` Mongod binary on npm install to `%HOMEDIR`

```bash
yarn add mongodb-memory-server-global --dev
OR
npm install mongodb-memory-server-global --save-dev
```

### With auto-download `v4.0` Mongod binary on npm install to `%HOMEDIR`

```bash
yarn add mongodb-memory-server-global-4.0 --dev
OR
npm install mongodb-memory-server-global-4.0 --save-dev
```

### With auto-download `v3.6` Mongod binary on npm install to `%HOMEDIR`

```bash
yarn add mongodb-memory-server-global-3.6 --dev
OR
npm install mongodb-memory-server-global-3.6 --save-dev
```

### With auto-download `v3.4` Mongod binary on npm install to `%HOMEDIR`

```bash
yarn add mongodb-memory-server-global-3.4 --dev
OR
npm install mongodb-memory-server-global-3.4 --save-dev
```

### Without auto-download

```bash
yarn add mongodb-memory-server-core --dev
OR
npm install mongodb-memory-server-core --save-dev
```

## Usage

### Simple server start:
Expand Down
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"command": {
"publish": {
"allowBranch": ["master", "lerna"],
"exact": true,
"conventionalCommits": true,
"githubRelease": true
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"test": "jest --projects packages/*",
"watch": "npm test -- --watchAll",
"coverage": "npm test -- --coverage",
"compile": "tsc --build tsconfig.build.json"
"build": "tsc --build tsconfig.build.json",
"publish": "lerna publish",
"postinstall": "lerna run prepare && npm run build"
}
}
5 changes: 5 additions & 0 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Packages

**The main package with source code is [mongodb-memory-server-core](./mongodb-memory-server-core).**

All other packages just include `postinstall` script which downloads mongod binary on npm install with provided default configuration.
46 changes: 46 additions & 0 deletions packages/mongodb-memory-server-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
tmp

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# IntelliJ Files
*.iml
*.ipr
*.iws
/out/
.idea/
.idea_modules/

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Transpiled code
lib

coverage
.nyc_output
package-lock.json
83 changes: 0 additions & 83 deletions packages/mongodb-memory-server-core/lib/MongoMemoryReplSet.d.ts

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9cca8f6

Please sign in to comment.