Skip to content

Commit 18d079a

Browse files
authored
feat(mongodb-downloader)!: use a lockfile to prevent redundant parallel downloads MONGOSH-1875 (#580)
1 parent 98ad28a commit 18d079a

File tree

7 files changed

+791
-121
lines changed

7 files changed

+791
-121
lines changed

package-lock.json

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## mongodb-downloader
2+
3+
A simple library to download MongoDB binaries for different platforms and versions.
4+
5+
### Migrating from v0.5 to v0.6+
6+
7+
In v0.6.x, the library introduced lockfiles to prevent parallel downloads of the same MongoDB binary. It also changed the arguments for the `downloadMongoDb` and `downloadMongoDbWithVersionInfo` functions, introducing a new `useLockfile` field and using a single options object instead of separate parameters for different options. It is recommended to enable lockfiles to prevent redundant downloads unless you have a specific reason not to.
8+
9+
```ts
10+
// Before (v0.5.x)
11+
downloadMongoDb('/tmp/directory', '4.4.6', {
12+
platform: 'linux',
13+
arch: 'x64',
14+
});
15+
16+
downloadMongoDbWithVersionInfo('/tmp/directory', '4.4.6', {
17+
arch: 'x64',
18+
});
19+
20+
// After (v0.6.x)
21+
downloadMongoDb({
22+
directory: '/tmp/directory',
23+
version: '4.4.6',
24+
useLockfile: true, // New, required field.
25+
downloadOptions: {
26+
platform: 'linux',
27+
arch: 'x64',
28+
},
29+
});
30+
31+
downloadMongoDbWithVersionInfo({
32+
directory: '/tmp/directory',
33+
version: '4.4.6',
34+
useLockfile: true, // New, required field.
35+
downloadOptions: {
36+
arch: 'x64',
37+
},
38+
});
39+
```

packages/mongodb-downloader/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,31 @@
5656
"tar": "^6.1.15",
5757
"decompress": "^4.2.1",
5858
"mongodb-download-url": "^1.7.0",
59-
"node-fetch": "^2.7.0"
59+
"node-fetch": "^2.7.0",
60+
"proper-lockfile": "^4.1.2"
6061
},
6162
"devDependencies": {
6263
"@mongodb-js/eslint-config-devtools": "0.9.12",
6364
"@mongodb-js/mocha-config-devtools": "^1.0.5",
6465
"@mongodb-js/prettier-config-devtools": "^1.0.2",
66+
"@types/chai": "^4.2.21",
6567
"@mongodb-js/tsconfig-devtools": "^1.0.4",
6668
"@types/debug": "^4.1.8",
6769
"@types/decompress": "^4.2.4",
6870
"@types/mocha": "^9.1.1",
6971
"@types/node": "^22.15.30",
72+
"@types/proper-lockfile": "^4.1.4",
73+
"@types/sinon-chai": "^3.2.5",
7074
"@types/tar": "^6.1.5",
75+
"chai": "^4.5.0",
7176
"depcheck": "^1.4.7",
7277
"eslint": "^7.25.0",
7378
"gen-esm-wrapper": "^1.1.3",
7479
"mocha": "^8.4.0",
7580
"nyc": "^15.1.0",
7681
"prettier": "^3.5.3",
82+
"sinon": "^9.2.3",
83+
"sinon-chai": "^3.7.0",
7784
"typescript": "^5.0.4"
7885
}
7986
}

0 commit comments

Comments
 (0)