redis-memory-server 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -52,8 +52,6 @@ On install, this package auto-downloads and compiles version `stable` of the `re
|
|
|
52
52
|
|
|
53
53
|
### Requirements
|
|
54
54
|
|
|
55
|
-
- NodeJS: 16+
|
|
56
|
-
- Typescript: 3.8+ (if used)
|
|
57
55
|
- `make`
|
|
58
56
|
|
|
59
57
|
### Windows
|
|
@@ -80,9 +78,9 @@ If this is a concern, either:
|
|
|
80
78
|
1. specify a `version` other than `stable`
|
|
81
79
|
2. forcibly update the `stable` binary on demand using a command like:
|
|
82
80
|
```bash
|
|
83
|
-
REDISMS_IGNORE_DOWNLOAD_CACHE=
|
|
81
|
+
REDISMS_IGNORE_DOWNLOAD_CACHE=true yarn rebuild redis-memory-server
|
|
84
82
|
# OR
|
|
85
|
-
REDISMS_IGNORE_DOWNLOAD_CACHE=
|
|
83
|
+
REDISMS_IGNORE_DOWNLOAD_CACHE=true npm rebuild redis-memory-server
|
|
86
84
|
```
|
|
87
85
|
3. specify the `ignoreDownloadCache` option
|
|
88
86
|
(NOTE: this will make installs/runs slower)
|
|
@@ -149,14 +147,16 @@ const redisServer = new RedisMemoryServer({
|
|
|
149
147
|
```sh
|
|
150
148
|
REDISMS_DOWNLOAD_DIR=/path/to/redis/binaries # default target download directory
|
|
151
149
|
REDISMS_VERSION=6.0.10 # default version to download
|
|
152
|
-
REDISMS_IGNORE_DOWNLOAD_CACHE=
|
|
153
|
-
REDISMS_DEBUG=
|
|
150
|
+
REDISMS_IGNORE_DOWNLOAD_CACHE=true
|
|
151
|
+
REDISMS_DEBUG=true
|
|
154
152
|
REDISMS_DOWNLOAD_MIRROR=host # your mirror host to download the redis binary
|
|
155
153
|
REDISMS_DOWNLOAD_URL=url # full URL to download the redis binary
|
|
156
|
-
REDISMS_DISABLE_POSTINSTALL=
|
|
154
|
+
REDISMS_DISABLE_POSTINSTALL=true
|
|
157
155
|
REDISMS_SYSTEM_BINARY=/usr/local/bin/redis-server # if you want to use an existing binary already on your system.
|
|
158
156
|
```
|
|
159
157
|
|
|
158
|
+
NOTE: Boolean-ish values can be any of these (case-insensitive): `true`, `on`, `yes`, `1`.
|
|
159
|
+
|
|
160
160
|
### Options which can be set via `package.json`
|
|
161
161
|
|
|
162
162
|
You can also use `package.json` to configure the installation process.
|
|
@@ -168,15 +168,18 @@ Environment variables have higher priority than contents of `package.json` files
|
|
|
168
168
|
"redisMemoryServer": {
|
|
169
169
|
"downloadDir": "/path/to/redis/binaries",
|
|
170
170
|
"version": "6.0.10",
|
|
171
|
-
"ignoreDownloadCache":
|
|
172
|
-
"debug":
|
|
171
|
+
"ignoreDownloadCache": true,
|
|
172
|
+
"debug": true,
|
|
173
173
|
"downloadMirror": "url",
|
|
174
|
-
"disablePostinstall":
|
|
175
|
-
"systemBinary": "/usr/local/bin/redis-server"
|
|
174
|
+
"disablePostinstall": true,
|
|
175
|
+
"systemBinary": "/usr/local/bin/redis-server",
|
|
176
|
+
"configProvider": "some-package/redisMemoryServerConfig.js"
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
```
|
|
179
180
|
|
|
181
|
+
NOTE: Boolean-ish values can be any of these (case-insensitive): `true`, `"true"`, `"on"`, `"yes"`, `1`, `"1"`.
|
|
182
|
+
|
|
180
183
|
By default, it starts looking for `package.json` files at `process.cwd()`.
|
|
181
184
|
To change this:
|
|
182
185
|
|
|
@@ -186,6 +189,14 @@ import { findPackageJson } from 'redis-memory-server/lib/util/resolve-config';
|
|
|
186
189
|
findPackageJson('/custom/path');
|
|
187
190
|
```
|
|
188
191
|
|
|
192
|
+
The `configProvider` configuration can be used to dynamically load configurations from another package (e.g. `some-package/redisMemoryServerConfig.js`) or file (e.g. `./redisMemoryServerConfig.js`), where the target file looks like this:
|
|
193
|
+
```js
|
|
194
|
+
module.exports = {
|
|
195
|
+
version: '6.0.10',
|
|
196
|
+
// ...
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
189
200
|
### Simple test with `ioredis`
|
|
190
201
|
|
|
191
202
|
Take a look at this [test file](https://github.com/mhassan1/redis-memory-server/blob/main/src/__tests__/singleDB-test.ts).
|
|
@@ -195,7 +206,7 @@ Take a look at this [test file](https://github.com/mhassan1/redis-memory-server/
|
|
|
195
206
|
Debug mode can be enabled with an environment variable or in `package.json`:
|
|
196
207
|
|
|
197
208
|
```sh
|
|
198
|
-
REDISMS_DEBUG=
|
|
209
|
+
REDISMS_DEBUG=true
|
|
199
210
|
```
|
|
200
211
|
|
|
201
212
|
or
|
|
@@ -203,7 +214,7 @@ or
|
|
|
203
214
|
```json
|
|
204
215
|
{
|
|
205
216
|
"redisMemoryServer": {
|
|
206
|
-
"debug":
|
|
217
|
+
"debug": true
|
|
207
218
|
}
|
|
208
219
|
}
|
|
209
220
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/util/resolve-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/util/resolve-config.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAKD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAiCxD;AAGD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM9E;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAW,GAAG,OAAO,CAEnD"}
|
|
@@ -11,7 +11,6 @@ const camelcase_1 = __importDefault(require("camelcase"));
|
|
|
11
11
|
const find_package_json_1 = __importDefault(require("find-package-json"));
|
|
12
12
|
const debug_1 = __importDefault(require("debug"));
|
|
13
13
|
const path_1 = require("path");
|
|
14
|
-
const lodash_defaultsdeep_1 = __importDefault(require("lodash.defaultsdeep"));
|
|
15
14
|
const log = (0, debug_1.default)('RedisMS:ResolveConfig');
|
|
16
15
|
const ENV_CONFIG_PREFIX = 'REDISMS_';
|
|
17
16
|
const defaultValues = new Map();
|
|
@@ -30,7 +29,7 @@ let packageJsonConfig = {};
|
|
|
30
29
|
* @param directory Set an custom directory to search the config in (default: process.cwd())
|
|
31
30
|
*/
|
|
32
31
|
function findPackageJson(directory) {
|
|
33
|
-
|
|
32
|
+
let _packageJsonConfig = {};
|
|
34
33
|
const finderIterator = (0, find_package_json_1.default)(directory || process.cwd());
|
|
35
34
|
let foundPackageJson;
|
|
36
35
|
while ((foundPackageJson = finderIterator.next())) {
|
|
@@ -40,13 +39,21 @@ function findPackageJson(directory) {
|
|
|
40
39
|
const { value, filename } = foundPackageJson;
|
|
41
40
|
log(`Found package.json at "${filename}"`);
|
|
42
41
|
const ourConfig = (value === null || value === void 0 ? void 0 : value.redisMemoryServer) || {};
|
|
42
|
+
// resolve dynamic config
|
|
43
|
+
if (ourConfig.configProvider) {
|
|
44
|
+
const configProviderPath = require.resolve(ourConfig.configProvider, {
|
|
45
|
+
paths: [(0, path_1.dirname)(filename)],
|
|
46
|
+
});
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
48
|
+
Object.assign(ourConfig, require(configProviderPath));
|
|
49
|
+
}
|
|
43
50
|
// resolve relative paths
|
|
44
51
|
for (const relativePathProp of ['downloadDir', 'systemBinary']) {
|
|
45
52
|
if (ourConfig[relativePathProp]) {
|
|
46
53
|
ourConfig[relativePathProp] = (0, path_1.resolve)((0, path_1.dirname)(filename), ourConfig[relativePathProp]);
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
|
-
|
|
56
|
+
_packageJsonConfig = Object.assign({}, ourConfig, _packageJsonConfig);
|
|
50
57
|
}
|
|
51
58
|
packageJsonConfig = _packageJsonConfig;
|
|
52
59
|
}
|
|
@@ -56,8 +63,8 @@ findPackageJson();
|
|
|
56
63
|
* @param variableName The variable to use
|
|
57
64
|
*/
|
|
58
65
|
function resolveConfig(variableName) {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
return ((_b = (_a = process.env[`${ENV_CONFIG_PREFIX}${variableName}`]) !== null && _a !== void 0 ? _a : packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig[(0, camelcase_1.default)(variableName)]) !== null && _b !== void 0 ? _b : defaultValues.get(variableName));
|
|
66
|
+
var _a, _b, _c;
|
|
67
|
+
return (_c = ((_b = (_a = process.env[`${ENV_CONFIG_PREFIX}${variableName}`]) !== null && _a !== void 0 ? _a : packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig[(0, camelcase_1.default)(variableName)]) !== null && _b !== void 0 ? _b : defaultValues.get(variableName))) === null || _c === void 0 ? void 0 : _c.toString();
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Convert "1, on, yes, true" to true (otherwise false)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/util/resolve-config.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/util/resolve-config.ts"],"names":[],"mappings":";;;;;AAgBA,0CAEC;AASD,0CAiCC;AAOD,gCAMC;AAMD,8BAEC;AAjFD,0DAAkC;AAClC,0EAAuC;AACvC,kDAA0B;AAC1B,+BAAwC;AAExC,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,uBAAuB,CAAC,CAAC;AAE3C,MAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,GAAW,EAAE,KAAa;IACxD,aAAa,CAAC,GAAG,CAAC,GA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xF,CAAC;QACH,CAAC;QAED,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACxE,CAAC;IACD,iBAAiB,GAAG,kBAAkB,CAAC;AACzC,CAAC;AACD,eAAe,EAAE,CAAC;AAElB;;;GAGG;AACH,SAAwB,aAAa,CAAC,YAAoB;;IACxD,OAAO,MAAA,CACL,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,iBAAiB,GAAG,YAAY,EAAE,CAAC,mCAClD,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,IAAA,mBAAS,EAAC,YAAY,CAAC,CAAC,mCAC5C,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAChC,0CAAE,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE;IACxC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,0CAA0C;AAC1C,IAAI,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACtC,eAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redis-memory-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Redis Server for testing. The server will allow you to connect your favorite client library to the Redis Server and run parallel integration tests isolated from each other.",
|
|
5
5
|
"bin": "bin/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@types/ioredis": "^5.0.0",
|
|
40
40
|
"@types/jest": "^30.0.0",
|
|
41
41
|
"@types/lockfile": "^1.0.2",
|
|
42
|
-
"@types/lodash.defaultsdeep": "^4.6.7",
|
|
43
42
|
"@types/node": "^18.11.9",
|
|
44
43
|
"@types/rimraf": "^4.0.5",
|
|
45
44
|
"@types/semver": "^7.5.0",
|
|
@@ -77,7 +76,6 @@
|
|
|
77
76
|
"get-port": "^5.1.1",
|
|
78
77
|
"https-proxy-agent": "^7.0.0",
|
|
79
78
|
"lockfile": "^1.0.4",
|
|
80
|
-
"lodash.defaultsdeep": "^4.6.1",
|
|
81
79
|
"rimraf": "^5.0.1",
|
|
82
80
|
"semver": "^7.5.3",
|
|
83
81
|
"tar": "^7.5.4",
|
package/scripts/postinstall.js
CHANGED
|
@@ -29,7 +29,7 @@ rc.findPackageJson(process.env.INIT_CWD);
|
|
|
29
29
|
|
|
30
30
|
const envDisablePostinstall = rc.default('DISABLE_POSTINSTALL');
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (rc.envToBool(envDisablePostinstall)) {
|
|
33
33
|
console.log('Download is skipped by REDISMS_DISABLE_POSTINSTALL variable');
|
|
34
34
|
process.exit(0);
|
|
35
35
|
}
|