Skip to content

Commit 9599563

Browse files
committed
Merge branch 'beta'
2 parents 9fffce7 + 982c19d commit 9599563

File tree

8 files changed

+174
-59
lines changed

8 files changed

+174
-59
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@
1515
* **semver:** upgrade to version 7.5.4 ([f7c4837](https://github.com/nodkz/mongodb-memory-server/commit/f7c483743fdc90ed1eda0fec901d5673d14827f5))
1616
* **tslib:** upgrade to version 2.6.1 ([db16d8f](https://github.com/nodkz/mongodb-memory-server/commit/db16d8fcc6bd9a6735a3f1414d1d3f4420dd9890))
1717

18+
## [8.14.0-beta.1](https://github.com/nodkz/mongodb-memory-server/compare/v8.13.0...v8.14.0-beta.1) (2023-07-07)
19+
20+
Note: this beta was not actually merged into 8.14.0, use 8.15.0 instead
21+
22+
### Features
23+
24+
* **MongoBinaryDownloadUrl:** add ability to overwrite distro used ([826c72e](https://github.com/nodkz/mongodb-memory-server/commit/826c72e1d56d409bc760949797d62fd10dc8eaf8)), closes [#753](https://github.com/nodkz/mongodb-memory-server/issues/753)
25+
26+
27+
### Dependencies
28+
29+
* **@typescript-eslint/*:** upgrade to version 5.61.0 ([121f0fc](https://github.com/nodkz/mongodb-memory-server/commit/121f0fcfb06919dbe3a778db520031f394aa4ea7))
30+
* **eslint:** upgrade to version 8.44.0 ([f7487b1](https://github.com/nodkz/mongodb-memory-server/commit/f7487b1027eead475f3e1057d2990a624e2d7ba4))
31+
* **semver:** upgrade to version 7.5.3 ([3498c33](https://github.com/nodkz/mongodb-memory-server/commit/3498c33929b54aa9d09c63021d4d2393401ce5f7))
32+
* **tslib:** upgrade to version 2.6.0 ([2cbd3dc](https://github.com/nodkz/mongodb-memory-server/commit/2cbd3dc6d68154295bc572dce2e5b120c629ddb1))
33+
34+
35+
### Style
36+
37+
* **MongoBinaryDownload:** fix comment ([615b681](https://github.com/nodkz/mongodb-memory-server/commit/615b681138dc4e23bb44c94c88fa413268eb26a5))
38+
39+
1840
## [8.13.0](https://github.com/nodkz/mongodb-memory-server/compare/v8.12.2...v8.13.0) (2023-06-09)
1941

2042

docs/api/config-options.md

+16
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ Valid Options are `x64`, `arm64`, ~~`ia32`~~([will be removed in 9.0](../guides/
4949

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

52+
### DISTRO
53+
54+
| Environment Variable | PackageJson |
55+
| :------------------: | :---------: |
56+
| `MONGOMS_DISTRO` | `distro` |
57+
58+
Option `DISTRO` is used to overwrite the Distribution used instead of the detected one.
59+
60+
Only works for when [`PLATFORM`](#platform) (automatic or manually set) is `linux`.
61+
62+
Format is `distro-release`, both distro and release need to be always defined.
63+
64+
Example: `ubuntu-18.04`
65+
66+
[See here for what versions are available for what distros](https://www.mongodb.com/download-center/community/releases/archive)
67+
5268
### VERSION
5369

5470
| Environment Variable | PackageJson |

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"@semantic-release/release-notes-generator": "9.0.3",
1717
"@types/jest": "^28.1.8",
1818
"@types/node": "~14.14.45",
19-
"@typescript-eslint/eslint-plugin": "5.59.9",
20-
"@typescript-eslint/parser": "5.59.9",
19+
"@typescript-eslint/eslint-plugin": "5.61.0",
20+
"@typescript-eslint/parser": "5.61.0",
2121
"commitlint": "16.2.4",
2222
"conventional-changelog-conventionalcommits": "5.0.0",
2323
"cross-env": "7.0.3",

packages/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class MongoBinaryDownload {
3434
dlProgress: MongoBinaryDownloadProgress;
3535
_downloadingUrl?: string;
3636

37-
/**These options are kind of raw, they are not run through DryMongoBinary.generateOptions */
37+
/** These options are kind of raw, they are not run through DryMongoBinary.generateOptions */
3838
binaryOpts: Required<MongoBinaryOpts>;
3939

4040
// TODO: for an major version, remove the compat get/set

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

+38-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as semver from 'semver';
55
import { isNullOrUndefined } from './utils';
66
import { URL } from 'url';
77
import {
8+
GenericMMSError,
89
KnownVersionIncompatibilityError,
910
UnknownArchitectureError,
1011
UnknownPlatformError,
@@ -161,10 +162,14 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
161162

162163
// the highest version for "i686" seems to be 3.3
163164
if (this.arch !== 'i686') {
164-
if (!this.os) {
165+
if (!this.os && resolveConfig(ResolveConfigVariables.DISTRO)) {
165166
this.os = await getOS();
166167
}
167168

169+
if (resolveConfig(ResolveConfigVariables.DISTRO)) {
170+
this.overwriteDistro();
171+
}
172+
168173
osString = this.getLinuxOSVersionString(this.os as LinuxOS);
169174
}
170175

@@ -180,6 +185,38 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
180185
return name;
181186
}
182187

188+
/**
189+
* Parse and apply config option DISTRO
190+
*/
191+
protected overwriteDistro() {
192+
const env = resolveConfig(ResolveConfigVariables.DISTRO);
193+
194+
if (isNullOrUndefined(env)) {
195+
return;
196+
}
197+
198+
const split = env.split('-');
199+
200+
const distro = split[0];
201+
const release = split[1];
202+
203+
if (isNullOrUndefined(distro)) {
204+
throw new GenericMMSError('Expected DISTRO option to have a distro like "ubuntu-18.04"');
205+
}
206+
207+
if (isNullOrUndefined(release)) {
208+
throw new GenericMMSError(
209+
'Expected DISTRO option to have a release like "ubuntu-18.04" (delimited by "-")'
210+
);
211+
}
212+
213+
this.os = {
214+
os: 'linux',
215+
dist: distro,
216+
release: release,
217+
} as LinuxOS;
218+
}
219+
183220
/**
184221
* Get the version string (with distro)
185222
* @param os LinuxOS Object

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts

+35
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,41 @@ describe('MongoBinaryDownloadUrl', () => {
17661766
expect(du.getLegacyVersionString).toHaveBeenCalledTimes(1);
17671767
expect(ret).toBe('');
17681768
});
1769+
1770+
describe('wrap config options', () => {
1771+
const originalEnv = process.env;
1772+
1773+
beforeEach(() => {
1774+
process.env = originalEnv;
1775+
});
1776+
1777+
afterAll(() => {
1778+
process.env = originalEnv;
1779+
});
1780+
1781+
it('should apply config option DISTRO', async () => {
1782+
const du = new MongoBinaryDownloadUrl({
1783+
platform: 'linux',
1784+
arch: 'x64',
1785+
version: '5.0.0',
1786+
os: {
1787+
os: 'linux',
1788+
dist: 'unknown',
1789+
release: '0',
1790+
codename: 'unknown',
1791+
},
1792+
});
1793+
// @ts-expect-error "overwriteDistro" is protected
1794+
jest.spyOn(du, 'overwriteDistro');
1795+
1796+
process.env[envName(ResolveConfigVariables.DISTRO)] = 'ubuntu-18.04';
1797+
1798+
expect((await du.getArchiveNameLinux()).includes('ubuntu1804')).toBeTruthy();
1799+
1800+
// @ts-expect-error "overwriteDistro" is protected
1801+
expect(du.overwriteDistro).toBeCalledTimes(1);
1802+
});
1803+
});
17691804
});
17701805

17711806
describe('translateArch()', () => {

packages/mongodb-memory-server-core/src/util/resolveConfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum ResolveConfigVariables {
2626
SYSTEM_BINARY_VERSION_CHECK = 'SYSTEM_BINARY_VERSION_CHECK',
2727
USE_ARCHIVE_NAME_FOR_BINARY_NAME = 'USE_ARCHIVE_NAME_FOR_BINARY_NAME',
2828
MAX_REDIRECTS = 'MAX_REDIRECTS',
29+
DISTRO = 'DISTRO',
2930
}
3031

3132
/** The Prefix for Environmental values */

yarn.lock

+59-55
Original file line numberDiff line numberDiff line change
@@ -2198,88 +2198,88 @@
21982198
dependencies:
21992199
"@types/node" "*"
22002200

2201-
"@typescript-eslint/eslint-plugin@5.59.9":
2202-
version "5.59.9"
2203-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz#2604cfaf2b306e120044f901e20c8ed926debf15"
2204-
integrity sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==
2201+
"@typescript-eslint/eslint-plugin@5.61.0":
2202+
version "5.61.0"
2203+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.61.0.tgz#a1a5290cf33863b4db3fb79350b3c5275a7b1223"
2204+
integrity sha512-A5l/eUAug103qtkwccSCxn8ZRwT+7RXWkFECdA4Cvl1dOlDUgTpAOfSEElZn2uSUxhdDpnCdetrf0jvU4qrL+g==
22052205
dependencies:
22062206
"@eslint-community/regexpp" "^4.4.0"
2207-
"@typescript-eslint/scope-manager" "5.59.9"
2208-
"@typescript-eslint/type-utils" "5.59.9"
2209-
"@typescript-eslint/utils" "5.59.9"
2207+
"@typescript-eslint/scope-manager" "5.61.0"
2208+
"@typescript-eslint/type-utils" "5.61.0"
2209+
"@typescript-eslint/utils" "5.61.0"
22102210
debug "^4.3.4"
2211-
grapheme-splitter "^1.0.4"
2211+
graphemer "^1.4.0"
22122212
ignore "^5.2.0"
22132213
natural-compare-lite "^1.4.0"
22142214
semver "^7.3.7"
22152215
tsutils "^3.21.0"
22162216

2217-
"@typescript-eslint/parser@5.59.9":
2218-
version "5.59.9"
2219-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.9.tgz#a85c47ccdd7e285697463da15200f9a8561dd5fa"
2220-
integrity sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==
2217+
"@typescript-eslint/parser@5.61.0":
2218+
version "5.61.0"
2219+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.61.0.tgz#7fbe3e2951904bb843f8932ebedd6e0635bffb70"
2220+
integrity sha512-yGr4Sgyh8uO6fSi9hw3jAFXNBHbCtKKFMdX2IkT3ZqpKmtAq3lHS4ixB/COFuAIJpwl9/AqF7j72ZDWYKmIfvg==
22212221
dependencies:
2222-
"@typescript-eslint/scope-manager" "5.59.9"
2223-
"@typescript-eslint/types" "5.59.9"
2224-
"@typescript-eslint/typescript-estree" "5.59.9"
2222+
"@typescript-eslint/scope-manager" "5.61.0"
2223+
"@typescript-eslint/types" "5.61.0"
2224+
"@typescript-eslint/typescript-estree" "5.61.0"
22252225
debug "^4.3.4"
22262226

2227-
"@typescript-eslint/scope-manager@5.59.9":
2228-
version "5.59.9"
2229-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz#eadce1f2733389cdb58c49770192c0f95470d2f4"
2230-
integrity sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==
2227+
"@typescript-eslint/scope-manager@5.61.0":
2228+
version "5.61.0"
2229+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.61.0.tgz#b670006d069c9abe6415c41f754b1b5d949ef2b2"
2230+
integrity sha512-W8VoMjoSg7f7nqAROEmTt6LoBpn81AegP7uKhhW5KzYlehs8VV0ZW0fIDVbcZRcaP3aPSW+JZFua+ysQN+m/Nw==
22312231
dependencies:
2232-
"@typescript-eslint/types" "5.59.9"
2233-
"@typescript-eslint/visitor-keys" "5.59.9"
2232+
"@typescript-eslint/types" "5.61.0"
2233+
"@typescript-eslint/visitor-keys" "5.61.0"
22342234

2235-
"@typescript-eslint/type-utils@5.59.9":
2236-
version "5.59.9"
2237-
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz#53bfaae2e901e6ac637ab0536d1754dfef4dafc2"
2238-
integrity sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==
2235+
"@typescript-eslint/type-utils@5.61.0":
2236+
version "5.61.0"
2237+
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.61.0.tgz#e90799eb2045c4435ea8378cb31cd8a9fddca47a"
2238+
integrity sha512-kk8u//r+oVK2Aj3ph/26XdH0pbAkC2RiSjUYhKD+PExemG4XSjpGFeyZ/QM8lBOa7O8aGOU+/yEbMJgQv/DnCg==
22392239
dependencies:
2240-
"@typescript-eslint/typescript-estree" "5.59.9"
2241-
"@typescript-eslint/utils" "5.59.9"
2240+
"@typescript-eslint/typescript-estree" "5.61.0"
2241+
"@typescript-eslint/utils" "5.61.0"
22422242
debug "^4.3.4"
22432243
tsutils "^3.21.0"
22442244

2245-
"@typescript-eslint/types@5.59.9":
2246-
version "5.59.9"
2247-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.9.tgz#3b4e7ae63718ce1b966e0ae620adc4099a6dcc52"
2248-
integrity sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==
2245+
"@typescript-eslint/types@5.61.0":
2246+
version "5.61.0"
2247+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.61.0.tgz#e99ff11b5792d791554abab0f0370936d8ca50c0"
2248+
integrity sha512-ldyueo58KjngXpzloHUog/h9REmHl59G1b3a5Sng1GfBo14BkS3ZbMEb3693gnP1k//97lh7bKsp6/V/0v1veQ==
22492249

2250-
"@typescript-eslint/typescript-estree@5.59.9":
2251-
version "5.59.9"
2252-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz#6bfea844e468427b5e72034d33c9fffc9557392b"
2253-
integrity sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==
2250+
"@typescript-eslint/typescript-estree@5.61.0":
2251+
version "5.61.0"
2252+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.61.0.tgz#4c7caca84ce95bb41aa585d46a764bcc050b92f3"
2253+
integrity sha512-Fud90PxONnnLZ36oR5ClJBLTLfU4pIWBmnvGwTbEa2cXIqj70AEDEmOmpkFComjBZ/037ueKrOdHuYmSFVD7Rw==
22542254
dependencies:
2255-
"@typescript-eslint/types" "5.59.9"
2256-
"@typescript-eslint/visitor-keys" "5.59.9"
2255+
"@typescript-eslint/types" "5.61.0"
2256+
"@typescript-eslint/visitor-keys" "5.61.0"
22572257
debug "^4.3.4"
22582258
globby "^11.1.0"
22592259
is-glob "^4.0.3"
22602260
semver "^7.3.7"
22612261
tsutils "^3.21.0"
22622262

2263-
"@typescript-eslint/utils@5.59.9":
2264-
version "5.59.9"
2265-
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.9.tgz#adee890107b5ffe02cd46fdaa6c2125fb3c6c7c4"
2266-
integrity sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==
2263+
"@typescript-eslint/utils@5.61.0":
2264+
version "5.61.0"
2265+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.61.0.tgz#5064838a53e91c754fffbddd306adcca3fe0af36"
2266+
integrity sha512-mV6O+6VgQmVE6+xzlA91xifndPW9ElFW8vbSF0xCT/czPXVhwDewKila1jOyRwa9AE19zKnrr7Cg5S3pJVrTWQ==
22672267
dependencies:
22682268
"@eslint-community/eslint-utils" "^4.2.0"
22692269
"@types/json-schema" "^7.0.9"
22702270
"@types/semver" "^7.3.12"
2271-
"@typescript-eslint/scope-manager" "5.59.9"
2272-
"@typescript-eslint/types" "5.59.9"
2273-
"@typescript-eslint/typescript-estree" "5.59.9"
2271+
"@typescript-eslint/scope-manager" "5.61.0"
2272+
"@typescript-eslint/types" "5.61.0"
2273+
"@typescript-eslint/typescript-estree" "5.61.0"
22742274
eslint-scope "^5.1.1"
22752275
semver "^7.3.7"
22762276

2277-
"@typescript-eslint/visitor-keys@5.59.9":
2278-
version "5.59.9"
2279-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz#9f86ef8e95aca30fb5a705bb7430f95fc58b146d"
2280-
integrity sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==
2277+
"@typescript-eslint/visitor-keys@5.61.0":
2278+
version "5.61.0"
2279+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.61.0.tgz#c79414fa42158fd23bd2bb70952dc5cdbb298140"
2280+
integrity sha512-50XQ5VdbWrX06mQXhy93WywSFZZGsv3EOjq+lqp6WC2t+j3mb6A9xYVdrRxafvK88vg9k9u+CT4l6D8PEatjKg==
22812281
dependencies:
2282-
"@typescript-eslint/types" "5.59.9"
2282+
"@typescript-eslint/types" "5.61.0"
22832283
eslint-visitor-keys "^3.3.0"
22842284

22852285
JSONStream@^1.0.4:
@@ -3549,7 +3549,16 @@ [email protected]:
35493549
strip-ansi "^6.0.1"
35503550
text-table "^0.2.0"
35513551

3552-
espree@^9.6.0, espree@^9.6.1:
3552+
espree@^9.6.0:
3553+
version "9.6.0"
3554+
resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.0.tgz#80869754b1c6560f32e3b6929194a3fe07c5b82f"
3555+
integrity sha512-1FH/IiruXZ84tpUlm0aCUEwMl2Ho5ilqVh0VvQXw+byAz/4SAciyHLlfmL5WYqsvD38oymdUwBss0LtK8m4s/A==
3556+
dependencies:
3557+
acorn "^8.9.0"
3558+
acorn-jsx "^5.3.2"
3559+
eslint-visitor-keys "^3.4.1"
3560+
3561+
espree@^9.6.1:
35533562
version "9.6.1"
35543563
resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f"
35553564
integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==
@@ -4057,11 +4066,6 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.3,
40574066
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
40584067
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==
40594068

4060-
grapheme-splitter@^1.0.4:
4061-
version "1.0.4"
4062-
resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e"
4063-
integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==
4064-
40654069
graphemer@^1.4.0:
40664070
version "1.4.0"
40674071
resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6"

0 commit comments

Comments
 (0)