Skip to content

Commit

Permalink
Merge branch 'feature/9.0' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Aug 15, 2023
2 parents 78011de + 6e9a9cc commit e257bcd
Show file tree
Hide file tree
Showing 51 changed files with 3,677 additions and 4,107 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Top Level; Everything that is not convered by anything below
* @nodkz @AJRdev @hasezoey
* @nodkz @hasezoey

**/LICENSE.md @nodkz
website/ @hasezoey
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
if: github.event.inputs.git-ref == ''
Expand Down
6 changes: 5 additions & 1 deletion .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
{type: "perf", release: "patch"},
{type: "test", release: false},
{type: "chore", release: false},
{type: "deps", release: "minor"},
// backwards compatability, remove after 9.0 has been published
{type: "dependencies", release: "minor"},
// dont trigger another release on release commit
{type: "release", release: false}
Expand All @@ -37,6 +39,8 @@ module.exports = {
{type: "perf", section: "Performance"},
{type: "test", hidden: true},
{type: "chore", hidden: true},
{type: "deps", section: "Dependencies"},
// backwards compatability, remove after 9.0 has been published
{type: "dependencies", section: "Dependencies"},
{type: "revert", section: "Reverts"},
{type: "release", hidden: true}
Expand All @@ -46,7 +50,7 @@ module.exports = {
],
[
// Update versions in sub-packages dependencies
"@google/semantic-release-replace-plugin",
"semantic-release-replace-plugin",
{
"replacements": [
{
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Choose any package, because they are the same. They differ only in the default c

### Requirements

- NodeJS: 12.22+
- Typescript: 4.4+ (if used)
- NodeJS: 14.20.1+
- Typescript: 5.0+ (if used)

And one of those (on Linux):

Expand Down Expand Up @@ -124,7 +124,6 @@ const mongod = new MongoMemoryServer({
dbPath?: string, // by default create in temp directory
storageEngine?: string, // by default `ephemeralForTest`, available engines: [ 'ephemeralForTest', 'wiredTiger' ]
replSet?: string, // by default no replica set, replica set name
auth?: boolean, // by default `mongod` is started with '--noauth', start `mongod` with '--auth'
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
},
binary: {
Expand Down Expand Up @@ -173,7 +172,7 @@ const replSet = new MongoMemoryReplSet({
// unless otherwise noted below these values will be in common with all instances spawned:
replSet: {
name, // replica set name (default: 'testset')
auth, // enable auth support? (default: false)
auth, // enable auth support? (default: undefined / disabled)
args, // any args specified here will be combined with any per instance args from `instanceOpts`
count, // number of additional `mongod` processes to start (will not start any extra if instanceOpts.length > replSet.count); (default: 1)
dbName, // default database for db URI strings. (default: uuid.v4())
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
'test',
'chore',
'revert',
'dependencies',
'deps',
'release',
],
],
Expand Down
4 changes: 2 additions & 2 deletions docs/api/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Valid Options are `win32`, `darwin`, `linux`, ~~`sunos`~~(never actually support

Option `ARCH` is used to overwrite the Architecture to download for

Valid Options are `x64`, `arm64`, ~~`ia32`~~([will be removed in 9.0](../guides/error-warning-details.md#mms001))
Valid Options are `x64`, `arm64`

[See here for what versions are available for what architectures](https://www.mongodb.com/download-center/community/releases/archive)

Expand Down Expand Up @@ -171,7 +171,7 @@ Default: `true`

Option `MD5_CHECK` is used to enable an md5 check after download

Default: `false`
Default: `true`

### ARCHIVE_NAME

Expand Down
4 changes: 1 addition & 3 deletions docs/api/interfaces/mongo-memory-instance-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ Only has a effect when started with [`MongoMemoryReplSet`](../classes/mongo-memo

## Helper Type `StorageEngine`

Typings: `StorageEngine = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'`
Typings: `StorageEngine = 'ephemeralForTest' | 'wiredTiger'`

Storage Engines supported by mongodb, see [MongoDB Storage Engines](https://www.mongodb.com/docs/manual/core/storage-engines/).

Custom Explanation:

- `devnull` is a storage engine which discards everything and cannot be read from.
- `ephemeralForTest` is a in-memory storage engine, which stores everything in RAM, which is great to use when wanting a simple database testing backend, is not the same as the Enterprise In-Memory Engine
- `mmapv1` is storage engine which stores data on disk, was removed in mongodb 4.2
- `wiredTiger` is a storage engine which stores data on disk.
7 changes: 3 additions & 4 deletions docs/api/interfaces/mongo-memory-server-automaticauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ API Documentation of `AutomaticAuth`-Interface

## Values

### disable
### enable

Typings: `disable?: boolean`
Typings: `enable?: boolean`
Default: `false`

Disable Authentication creation.
Normally authentication is enabled when the `auth` field a object, but with this option it can be explicitly disabled.
Enable or disable Authentication creation.

### extraUsers

Expand Down
6 changes: 4 additions & 2 deletions docs/api/interfaces/mongo-memory-server-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ API Documentation of `MongoMemoryServerOpts`-Interface

### instance

Typings: `instance?: MongoMemoryInstanceOpts`
Typings: `instance?: MemoryServerInstanceOpts`

Set custom options for the instance, uses [`MongoMemoryInstanceOpts`](./mongo-memory-instance-opts.md).
Set custom options based on [`MongoMemoryInstanceOpts`](./mongo-memory-instance-opts.md), but ignores some properties:

- `auth` is ignored because it is set via [auth](#auth) property.

### binary

Expand Down
6 changes: 3 additions & 3 deletions docs/api/interfaces/replset-opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ API Documentation of `ReplSetOpts`-Interface

### auth

Typings: `auth?: boolean | AutomaticAuth`
Default: `false`
Typings: `auth?: AutomaticAuth`
Default: `{ enable: false }`

Set wheter to enable Authentication, with configuration from [`AutomaticAuth`](./mongo-memory-server-automaticauth.md).
Set whether to enable Authentication, with configuration from [`AutomaticAuth`](./mongo-memory-server-automaticauth.md).

Also see [`MongoMemoryInstanceOpts.auth`](./mongo-memory-instance-opts.md#auth).

Expand Down
11 changes: 11 additions & 0 deletions docs/guides/error-warning-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Default Timeout: `1000 * 30` (30 seconds)

## EnsureInstanceError

:::note
Merged into [`InstanceInfoError`](#instanceinfoerror) in 9.0.0
:::

Example:

- `${baseMesasge} state was "running" but "instanceInfo" was undefined!`
Expand Down Expand Up @@ -168,6 +172,13 @@ Example: `ReplSet Count needs to be 1 or higher! (specified count: "${count}")`
Details:
ReplSet count (like `new MongoMemoryReplSet({ replSet: { count: 0 } })`) needs to be `1` or higher

## UnknownLinuxDistro

Example: `Unknown/unsupported linux "${distro}" id_like's: [${id_like?.join(', ')}]`

Details:
The Linux distro in use does not have a mapping for a mongodb version, please report this issue if the distro / idlike is not mentioned in [Supported Systems](./supported-systems.md).

## Deprecation Codes

### MMS001
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/migration/migrate7.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This Guide is written for migration from version `6.9.6` to `7.0.0`, for version

## Requirement Changes

- Nodejs `10` & `11` are now unsupported, lowest supported version is now `12.22`
- Nodejs `10` & `11` are now unsupported, lowest supported version is now `14.0`

## Breaking Changes

Expand Down
111 changes: 111 additions & 0 deletions docs/guides/migration/migrate9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
id: migrate9
title: 'Migrate to version 9.0.0'
---

Here are the Important changes made for 9.0.0

:::caution Important, Read this first
This Guide is written for migration from version `8.15.0` to `9.0.0`, for versions `>9.0.0 <10.0.0`, please consult the [CHANGELOG](https://github.com/nodkz/mongodb-memory-server/blob/master/CHANGELOG.md)
:::

## Breaking Changes

### Minimal NodeJS version is now `14`

With 9.0.0 the minimal nodejs required is `14.20.1`.

### Mongodb Driver Version upgraded to 5.x

The used MongoDB Driver version is now `5.6.0`.

### Removed platform translations

Some platform translations have been removed, because they are either not needed anymore or werent supported in the first place:

- `sunos` -> `linux`
- `elementary OS` -> `linux`

### Removed architectures

Some architectures were removed because they were not being build by mongodb anymore and support in mongodb-memory-server has been largely untested:

- `ia32` -> `i686` / `i386`

### MongoMemoryServer `instance.auth` option is now ignored

With 9.0.0 the option `instance.auth` option is going to be ignored, because its set via the `auth` option directly.

Example:

`new MongoMemoryServer({ instance: { auth: true } })` is going to be ignored, use `new MongoMemoryServer({ auth: { enable: true } })`

### `AutomaticAuth` changes

`AutomaticAuth` has been changed to **not** be enabled anymore by just having a empty object. Also property `disable` has been removed and `enable` has been added.

Replace `auth: {}` with `auth: { enable: true }`.
Replace `auth: { disable: true }` with `auth: { enable: false }`.
Replace `auth: { disable: false }` with `auth: { enable: true }`.

### MongoMemoryServer and MongoReplSet `.cleanup(boolean)` and `.stop(boolean)` have been removed

Previously `boolean` was the only option for the `.cleanup` and `.stop` function, but they behaved differently between those 2 function and were replaced with `Cleanup` options and now have been completely removed.

Replace `.stop(true)` with `.stop({ doCleanup: true })`.
Replace `.cleanup(true)` with `.stop({ doCleanup: true, force: true })`.

Default is still for both `{ doCleanup: true }`.

### `MD5_CHECK` is now enabled by default

The config option [`MD5_CHECK`](../../api/config-options.md#md5_check) has been enabled by default now, resulting in always comparing the downloaded archive with a md5.

### Merged Error types

Some error classes have been merged:

- `EnsureInstanceError` & `InstanceInfoError` -> `InstanceInfoError`
- `NoSystemBinaryFoundError` & `BinaryNotFoundError` -> `BinaryNotFoundError`

### Removed Storage engine `devnull` and `mmapv1`

Storage Engines `devnull` and `mmapv1` have been removed because they are not supported in newer versions of mongodb anymore, `wiredTiger` should be used instead.

### Linux fallback binary has been removed

Previously there was a code-path for a fallback linux binary, but this has been removed because mongodb has stopped shipping generic linux binaries since versions after 4.0.

If a fallback is still required, try to use the ubuntu binary via [Config Options `DISTRO`](../../api/config-options.md#distro).

### Ubuntu fallback year has been updated

The ubuntu fallback year has been updated to `22`, instead of the previous `14`, because newer versions of mongodb dont ship for any EOL ubuntu version anymore.

This fallback is only used if the ubuntu year could not be parsed from the os-file.
This can also be overwritten with [Config Option `DISTRO`](../../api/config-options.md#distro).

## Non-Breaking changes / Additions

### Compiler target is now `es2019`

The tsconfig `target` option has been updated to `es2019`, which will result in less polyfills.
This should be a non-breaking change

## Crypto function have been changed to use nodejs internals

Crypto functions like for the md5 check and uuidv4 generation have been moved to use the `node:crypto` support, resulting in dropping 2 dependencies.

Dropped dependencies are `md5-file` and `uuid`.

## Binary childprocess is now also `.unref()`

The Mongodb Binary childprocess is now also `.unref()`, like the killer process has been for some time.

This *should* help with non-closed instances not exiting the nodejs process.

## The port testing has been replaced

Previously MMS used `get-port`, but it caused some big memory-leakage across big projects, so it has been replaced with one that uses less maps.

It also has been replaced because newer versions were ESM only, but we couldnt switch to ESM yet (and using ESM in CommonJS is not a great experience)
4 changes: 2 additions & 2 deletions docs/guides/quick-start-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ If Top-Level async-await is not available for your case, the code can in most ca

## Requirements

- NodeJS: 12.22+
- Typescript: 4.4+ (if used)
- NodeJS: 14.20.1+
- Typescript: 5.0+ (if used)

When on Linux, one of the following are required:

Expand Down
3 changes: 1 addition & 2 deletions docs/guides/supported-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Officially Supported Architectures:
<!--Platfrom taken from "MongoBinaryDownloadUrl.translateArch"-->
- `x64` / `x86_64`
- `arm64` / `aarch64` (only some linux distros have binaries)
- ~~`ia32` / `i686` / `i386`~~ (There are only binaries up to ~3.2 and [will be removed with the next MMS version](https://github.com/nodkz/mongodb-memory-server/issues/638))

:::note
On systems that have native arch translation (like ARM MacOS), the architecture will need to be overwritten with `MONGOMS_ARCH=x64`.
Expand Down Expand Up @@ -55,7 +54,7 @@ Depends on the distribution, many common ones should just work right out of the
(uses mongodb's `ubuntu` release)<br/>
Lowest supported Distribution version is `1404`<br/>
Highest version is `2204`<br/>
Default version is `1404`<br/>
Default version is `2204`<br/>
Architectures Supported: `x86_64`, `arm64`(`aarch64`)

:::note
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
"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.",
"repository": "https://github.com/nodkz/mongodb-memory-server",
"devDependencies": {
"@commitlint/cli": "16.2.4",
"@commitlint/config-conventional": "16.2.4",
"@google/semantic-release-replace-plugin": "1.2.0",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/commit-analyzer": "8.0.1",
"@semantic-release/git": "9.0.0",
"@semantic-release/github": "7.2.3",
"@semantic-release/npm": "7.1.3",
"@semantic-release/release-notes-generator": "9.0.3",
"@types/jest": "^28.1.8",
"@types/node": "~14.14.45",
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0",
"commitlint": "16.2.4",
"conventional-changelog-conventionalcommits": "5.0.0",
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^9.0.2",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/jest": "^29.5.2",
"@types/node": "~14.18.45",
"@typescript-eslint/eslint-plugin": "5.59.9",
"@typescript-eslint/parser": "5.59.9",
"commitlint": "17.7.1",
"conventional-changelog-conventionalcommits": "6.1.0",
"cross-env": "7.0.3",
"doctoc": "2.2.1",
"eslint": "8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "7.0.4",
"jest": "28.1.3",
"lint-staged": "11.2.6",
"prettier": "2.8.8",
"semantic-release": "17.4.7",
"ts-jest": "28.0.8",
"typescript": "4.4.4"
"eslint": "8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "5.0.0",
"husky": "8.0.3",
"jest": "29.6.2",
"lint-staged": "13.2.3",
"prettier": "3.0.1",
"semantic-release": "^19.0.5",
"semantic-release-replace-plugin": "1.2.6",
"ts-jest": "29.1.1",
"typescript": "5.0.4"
},
"workspaces": {
"packages": [
Expand Down
Loading

0 comments on commit e257bcd

Please sign in to comment.