Skip to content

Commit d90c6c7

Browse files
committed
Merge branch 'master' into beta
2 parents 40f4ea6 + 09cb5ae commit d90c6c7

File tree

22 files changed

+395
-72
lines changed

22 files changed

+395
-72
lines changed

.eslintignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
flow-typed/*
2-
lib/*
3-
.eslintrc.js
1+
**/flow-typed/*
2+
**/lib/*
3+
**/build/*
4+
#website/* #dont ignore website (like sidebars.js)
5+
website/build/*
6+
**/coverage/*
7+
#*.js # dont ignore top-level js files

.eslintrc.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
12
const path = require('path');
23

34
module.exports = {
45
parser: '@typescript-eslint/parser',
56
plugins: ['@typescript-eslint', 'prettier'],
6-
extends: [
7-
'plugin:@typescript-eslint/recommended',
8-
'plugin:prettier/recommended',
9-
],
7+
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
108
parserOptions: {
119
sourceType: 'module',
1210
useJSXTextNode: true,
13-
project: [
14-
path.resolve(__dirname, 'tsconfig.test.json'),
15-
path.resolve(__dirname, 'packages/mongodb-memory-server-core/tsconfig.json'),
16-
],
11+
project: [path.resolve(__dirname, 'tsconfig.test.json')],
1712
},
1813
rules: {
1914
'no-underscore-dangle': 0,
@@ -42,37 +37,55 @@ module.exports = {
4237
'@typescript-eslint/explicit-function-return-type': 0,
4338
'@typescript-eslint/no-use-before-define': 0,
4439
'@typescript-eslint/no-empty-function': 0,
45-
'curly': ['error', 'all'],
40+
curly: ['error', 'all'],
4641
'padding-line-between-statements': [
47-
"warn",
42+
'warn',
4843
{
49-
blankLine: 'always', prev: '*', next: 'return' // add blank line *before* all returns (if there are statements before)
44+
blankLine: 'always',
45+
prev: '*',
46+
next: 'return', // add blank line *before* all returns (if there are statements before)
5047
},
5148
{
52-
blankLine: 'always', prev: '*', next: 'if' // add blank line *before* all ifs
49+
blankLine: 'always',
50+
prev: '*',
51+
next: 'if', // add blank line *before* all ifs
5352
},
5453
{
55-
blankLine: 'always', prev: 'if', next: '*' // add blank line *after* all ifs
54+
blankLine: 'always',
55+
prev: 'if',
56+
next: '*', // add blank line *after* all ifs
5657
},
5758
{
58-
blankLine: 'any', prev: 'if', next: 'if' // allow blank line between ifs, but not enforce either
59+
blankLine: 'any',
60+
prev: 'if',
61+
next: 'if', // allow blank line between ifs, but not enforce either
5962
},
6063
{
61-
blankLine: 'always', prev: '*', next: ['function', 'class'] // add blank line *before* all functions and classes
64+
blankLine: 'always',
65+
prev: '*',
66+
next: ['function', 'class'], // add blank line *before* all functions and classes
6267
},
6368
{
64-
blankLine: 'always', prev: ['function', 'class'], next: '*' // add blank line *after* all functions and classes
69+
blankLine: 'always',
70+
prev: ['function', 'class'],
71+
next: '*', // add blank line *after* all functions and classes
6572
},
6673
{
67-
blankLine: 'always', prev: '*', next: 'import' // add blank line *before* all imports
74+
blankLine: 'always',
75+
prev: '*',
76+
next: 'import', // add blank line *before* all imports
6877
},
6978
{
70-
blankLine: 'always', prev: 'import', next: '*' // add blank line *after* all imports
79+
blankLine: 'always',
80+
prev: 'import',
81+
next: '*', // add blank line *after* all imports
7182
},
7283
{
73-
blankLine: 'never', prev: 'import', next: 'import' // dont allow blank line between imports
84+
blankLine: 'never',
85+
prev: 'import',
86+
next: 'import', // dont allow blank line between imports
7487
},
75-
]
88+
],
7689
},
7790
env: {
7891
node: true,

.github/ISSUE_TEMPLATE/distribution-support.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ List of currently [Supported Systems](https://nodkz.github.io/mongodb-memory-ser
1414

1515
## Versions
1616

17-
- Wanted System: `Linux Mint 20.1`
18-
- Architecture: `x86_64`
17+
<!--
18+
"Wanted System" formatting like: "Windows 10 1804" / "Ubuntu 20.04" / "MacOS 10"
19+
Possible "Architecture": "x86_64" / "aarch64" / "arm64"
20+
-->
21+
22+
- Wanted System: `Distro / System here`
23+
- Architecture: `arch here`
1924

2025
## Detection
2126

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: TSCheck
3838
run: yarn --cwd packages/mongodb-memory-server-core run tscheck
3939
- name: ESLint
40-
run: yarn --cwd packages/mongodb-memory-server-core run eslint
40+
run: yarn run lint
4141
- name: Tests
4242
run: yarn --cwd packages/mongodb-memory-server-core run coverage --colors
4343
env:

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,40 @@
6767
* **tslib:** upgrade to version 2.3.1 ([1a36352](https://github.com/nodkz/mongodb-memory-server/commit/1a36352fcaaa6c45796cb1d1c2a0e4b509acbfdd))
6868
* **typescript:** upgrade to version 4.4.3 ([84e407b](https://github.com/nodkz/mongodb-memory-server/commit/84e407b6b14ae986ab9d4ac6a1d5caa3f694861b))
6969

70+
### [7.4.5](https://github.com/nodkz/mongodb-memory-server/compare/v7.4.4...v7.4.5) (2021-10-19)
71+
72+
73+
### Fixes
74+
75+
* add "@types/mongodb" to dependencies, because of exposing a mongodb type ([6346922](https://github.com/nodkz/mongodb-memory-server/commit/634692225201ed38e4fa306e40497a434ad6a4be)), closes [#558](https://github.com/nodkz/mongodb-memory-server/issues/558)
76+
77+
### [7.4.4](https://github.com/nodkz/mongodb-memory-server/compare/v7.4.3...v7.4.4) (2021-10-14)
78+
79+
80+
### Fixes
81+
82+
* **MongoMemoryServer:** change that "instance.auth" is not required to be set for enabling auth ([4e4a41d](https://github.com/nodkz/mongodb-memory-server/commit/4e4a41d8d9975f8739ac0e92cdce040917e4d9cd))
83+
* **MongoMemoryServer:** change to log value "createAuth" ([9c3fea0](https://github.com/nodkz/mongodb-memory-server/commit/9c3fea0f08e875382c0c1e9dfd62a315aee8a2e1))
84+
85+
86+
### Style
87+
88+
* **MongoInstance:** add more tsdoc ([36c1971](https://github.com/nodkz/mongodb-memory-server/commit/36c19715e7820a902f6533899b4a9ecd3cb91348))
89+
90+
### [7.4.3](https://github.com/nodkz/mongodb-memory-server/compare/v7.4.2...v7.4.3) (2021-10-05)
91+
92+
93+
### Fixes
94+
95+
* **resolveConfig::findPackageJson:** actually apply processing to path options ([25c4119](https://github.com/nodkz/mongodb-memory-server/commit/25c41195a245a0c22bba65c91b798cb088c5e885)), closes [#548](https://github.com/nodkz/mongodb-memory-server/issues/548)
96+
97+
### [7.4.2](https://github.com/nodkz/mongodb-memory-server/compare/v7.4.1...v7.4.2) (2021-09-29)
98+
99+
100+
### Fixes
101+
102+
* **resolveConfig:** fix debug enable ([aff6838](https://github.com/nodkz/mongodb-memory-server/commit/aff68382cb681b55516c053e9d4864d0b590ab25))
103+
70104
### [7.4.1](https://github.com/nodkz/mongodb-memory-server/compare/v7.4.0...v7.4.1) (2021-09-20)
71105

72106

commitlint.config.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
module.exports = {
2-
"extends": [
3-
"@commitlint/config-conventional"
4-
],
5-
"rules": {
6-
"scope-case": [0, "never"],
7-
"body-min-length": [2, "always", 3],
8-
"type-enum": [2, "always", ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'revert', 'dependencies', 'release']],
9-
"subject-case": [0, "never"]
10-
}
11-
}
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'scope-case': [0, 'never'],
5+
'body-min-length': [2, 'always', 3],
6+
'type-enum': [
7+
2,
8+
'always',
9+
[
10+
'feat',
11+
'fix',
12+
'docs',
13+
'style',
14+
'refactor',
15+
'perf',
16+
'test',
17+
'chore',
18+
'revert',
19+
'dependencies',
20+
'release',
21+
],
22+
],
23+
'subject-case': [0, 'never'],
24+
},
25+
};

docs/guides/enable-debug-mode.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ MONGOMS_DEBUG=1 npm run command
2525
}
2626
}
2727
```
28+
29+
## Extra Notes
30+
31+
### npm quirks
32+
33+
Starting with NPM 7, scripts (like `postinstall`) will run in parallel and will not output any logging, but sometimes in `mongodb-memory-server` it is required to provide the Debug Log from a `postinstall` script.
34+
35+
Temporarly this can be change to use:
36+
37+
```sh
38+
# Change scripts to be executed on the NPM main proccess instead of workers AND log script output
39+
MONGOMS_DEBUG=1 npm install --foreground-scripts
40+
```
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
id: docker
3+
title: 'Integration with Docker'
4+
---
5+
6+
This Guide will show how `mongodb-memory-server` can be used with Docker & dockefiles.
7+
8+
## Important Notes before Starting
9+
10+
:::caution
11+
It is common that images like `node:16-alpine` are used, which will not work with this package, because mongodb does not provide binaries for Alpine yet.
12+
It is recommended to switch to images like `node:16` (or `node:16-buster`) for Debian builds.
13+
14+
See [No Build available for Alpine Linux](../known-issues.md#no-build-available-for-alpine-linux).
15+
:::
16+
17+
:::caution
18+
Docker Debian builds (at least with `debian:11`), extra packages have to be installed:
19+
20+
```sh
21+
apt-get install libcurl4 # for Debian 10+ to fix CURL_OPENSSL_4
22+
# OR
23+
apt-get install libcurl3 # for Debian 9 (and before) to fix CURL_OPENSSL_3
24+
```
25+
26+
:::
27+
28+
## Writing a dockerfile with mongodb binary caching
29+
30+
Sometimes you want to have the tests isolated from the host system and also have caching working for mongodb-memory-server.
31+
32+
### `.dockerignore`
33+
34+
If no `.dockerignore` is specified or the following instructions added to the `dockerfile`, some cases may happen:
35+
36+
- Best case is just added bloat if the host system is not debian (like having the host's mongodb binary copied into the image)
37+
- If the host system is Debian (and to that not matching version), then the host's mongodb binary is copied in and will be used instead of downloading the actual required mongodb binary
38+
39+
It is not required to have, but preferred over having a additional step in the dockerfile:
40+
41+
```dockerignore
42+
# ignore all node_modules, no matter where, like when having a monorepo
43+
**/node_modules
44+
```
45+
46+
If a dockerignore is not specified, a additional instruction can be used instead:
47+
48+
```dockerfile
49+
# ...
50+
COPY node:node . /project
51+
52+
# Put this Instruction between the 2 other instructions mentioned in this example
53+
# The following deleted all directories it finds that are a directory AND have a name matching "node_modules" (also removes nested directories)
54+
RUN find . -type d -iname "node_modules" -exec rm -rf {} \;
55+
56+
RUN npm install
57+
# ...
58+
```
59+
60+
### `dockefile`
61+
62+
The following is the recommended way to make a image with mongodb-memory-server
63+
64+
:::note
65+
The following `dockerfile` has examples for 2 package managers: `npm` and `yarn`, be sure to remove the one that will not be used.
66+
:::
67+
68+
```dockerfile
69+
# Using a Debian build
70+
FROM node:16
71+
72+
# Installing "libcurl4" because some Debian images may not come with this package installed, but is required by the mongodb binaries
73+
RUN apt-get install libcurl4
74+
75+
# Settings the CWD (Current Work Directory) to "/project" to have a isolated folder for the project
76+
# Note: it is not recommended to set it to "/home/dockeruser", but to use "/home/dockeruser/project"
77+
WORKDIR /project
78+
79+
# Copy the project (all files) into the image into "/project" as user "node:node"
80+
# User "node:node" is the default nodejs user in the docker images
81+
COPY node:node . /project
82+
83+
# Explicitly set the user that will be used for the next Instructions and ENTRYPOINT
84+
USER node
85+
86+
# Install all required dependencies locked to the package-lock (or yarn.lock)
87+
# Replace "npm install" with your package manager command of choice
88+
RUN npm install --ci
89+
# OR
90+
RUN yarn install --frozen-lockfile
91+
92+
# Set the default command that will be used when running the image
93+
# Replace this with your command / package manager command of choice
94+
ENTRYPOINT ["npm", "run", "test"]
95+
# OR
96+
ENTRYPOINT ["yarn", "run", "test"]
97+
```

docs/guides/integration-examples.md renamed to docs/guides/integration-examples/test-runners.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
id: integration-examples
3-
title: 'Integration Examples'
2+
id: test-runners
3+
title: 'Integration with Test Runners'
44
---
55

66
This Guide will show how `mongodb-memory-server` can be used with different frameworks

docs/guides/migrate7.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Example:
2424
```ts
2525
// this no longer works
2626
const mongo = new MongoMemoryServer();
27-
const uri = await getUri(); // ERROR: instance not started
27+
const uri = await mongo.getUri(); // ERROR: instance not started
2828

2929
// it is now
3030
const mongo = await MongoMemoryServer.create();
31-
const uri = getUri();
31+
const uri = mongo.getUri();
3232
```
3333

3434
### getUri is no longer async

0 commit comments

Comments
 (0)