@terreno/test 57.4.0 → 57.6.1
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 +2 -2
- package/dist/cache/mongoTestCache.js +175 -427
- package/dist/env/setTerrenoTestEnv.js +15 -65
- package/dist/http/authAsUser.js +28 -153
- package/dist/http/getBaseServer.js +6 -7
- package/dist/logging/setupEnvironment.js +1 -1
- package/dist/logging/silenceLogs.js +36 -93
- package/dist/logging/testLogger.js +4 -4
- package/dist/mocks/sentryBun.js +39 -39
- package/dist/mongo/connection.js +31 -115
- package/dist/mongo/ensureMongoBinary.js +12 -92
- package/dist/mongo/mongoServer.js +142 -390
- package/dist/preload/defaultBackendPreload.js +1 -1
- package/dist/preload/memoryMongo.d.ts +1 -0
- package/dist/preload/memoryMongo.js +1 -0
- package/dist/preload/registerBackendPreload.js +87 -262
- package/dist/transaction/testTransaction.js +224 -444
- package/dist/utils/ensureAllIndexes.js +9 -76
- package/dist/utils/timeout.js +3 -41
- package/dist/utils/waitForDocuments.js +18 -115
- package/package.json +4 -4
- package/tsconfig.json +6 -22
- package/dist/cache/mongoTestCache.test.d.ts +0 -1
- package/dist/cache/mongoTestCache.test.js +0 -182
- package/dist/env/setTerrenoTestEnv.test.d.ts +0 -1
- package/dist/env/setTerrenoTestEnv.test.js +0 -24
- package/dist/http/authAsUser.test.d.ts +0 -1
- package/dist/http/authAsUser.test.js +0 -93
- package/dist/http/getBaseServer.test.d.ts +0 -1
- package/dist/http/getBaseServer.test.js +0 -91
- package/dist/logging/setupEnvironment.test.d.ts +0 -1
- package/dist/logging/setupEnvironment.test.js +0 -23
- package/dist/logging/silenceLogs.test.d.ts +0 -1
- package/dist/logging/silenceLogs.test.js +0 -51
- package/dist/logging/testLogger.test.d.ts +0 -1
- package/dist/logging/testLogger.test.js +0 -56
- package/dist/mocks/sentryBun.test.d.ts +0 -1
- package/dist/mocks/sentryBun.test.js +0 -207
- package/dist/mongo/connection.test.d.ts +0 -1
- package/dist/mongo/connection.test.js +0 -40
- package/dist/mongo/mongoServer.test.d.ts +0 -1
- package/dist/mongo/mongoServer.test.js +0 -196
- package/dist/preload/registerBackendPreload.test.d.ts +0 -1
- package/dist/preload/registerBackendPreload.test.js +0 -10
- package/dist/transaction/testTransaction.test.d.ts +0 -1
- package/dist/transaction/testTransaction.test.js +0 -142
- package/dist/utils/helpers.test.d.ts +0 -1
- package/dist/utils/helpers.test.js +0 -113
package/dist/mocks/sentryBun.js
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerSentryBunMock = void 0;
|
|
4
4
|
// noExplicitAny: test mock typing
|
|
5
5
|
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
6
|
-
|
|
6
|
+
const bun_test_1 = require("bun:test");
|
|
7
7
|
/** Registers a global `mock.module("@sentry/bun", ...)` for backend tests. */
|
|
8
|
-
|
|
9
|
-
bun_test_1.mock.module("@sentry/bun",
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const registerSentryBunMock = () => {
|
|
9
|
+
bun_test_1.mock.module("@sentry/bun", () => {
|
|
10
|
+
const mockFn = () => (0, bun_test_1.mock)(() => { });
|
|
11
|
+
const mockScope = {
|
|
12
12
|
addBreadcrumb: mockFn(),
|
|
13
13
|
clear: mockFn(),
|
|
14
14
|
getSpan: mockFn(),
|
|
@@ -21,20 +21,20 @@ var registerSentryBunMock = function () {
|
|
|
21
21
|
setTransactionName: mockFn(),
|
|
22
22
|
setUser: mockFn(),
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
const mockClient = {
|
|
25
25
|
captureException: mockFn(),
|
|
26
26
|
captureMessage: mockFn(),
|
|
27
|
-
close: (0, bun_test_1.mock)(
|
|
28
|
-
flush: (0, bun_test_1.mock)(
|
|
29
|
-
getOptions: (0, bun_test_1.mock)(
|
|
27
|
+
close: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
28
|
+
flush: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
29
|
+
getOptions: (0, bun_test_1.mock)(() => ({})),
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
const mockHub = {
|
|
32
32
|
addBreadcrumb: mockFn(),
|
|
33
33
|
captureException: mockFn(),
|
|
34
34
|
captureMessage: mockFn(),
|
|
35
35
|
configureScope: mockFn(),
|
|
36
|
-
getClient: (0, bun_test_1.mock)(
|
|
37
|
-
getScope: (0, bun_test_1.mock)(
|
|
36
|
+
getClient: (0, bun_test_1.mock)(() => mockClient),
|
|
37
|
+
getScope: (0, bun_test_1.mock)(() => mockScope),
|
|
38
38
|
popScope: mockFn(),
|
|
39
39
|
pushScope: mockFn(),
|
|
40
40
|
setContext: mockFn(),
|
|
@@ -43,30 +43,30 @@ var registerSentryBunMock = function () {
|
|
|
43
43
|
setUser: mockFn(),
|
|
44
44
|
withScope: mockFn(),
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
const mockSpan = {
|
|
47
47
|
finish: mockFn(),
|
|
48
48
|
setData: mockFn(),
|
|
49
49
|
setStatus: mockFn(),
|
|
50
50
|
setTag: mockFn(),
|
|
51
51
|
startChild: mockFn(),
|
|
52
|
-
toTraceparent: (0, bun_test_1.mock)(
|
|
52
|
+
toTraceparent: (0, bun_test_1.mock)(() => "mock-trace-parent"),
|
|
53
53
|
};
|
|
54
|
-
mockSpan.startChild = (0, bun_test_1.mock)(
|
|
55
|
-
|
|
54
|
+
mockSpan.startChild = (0, bun_test_1.mock)(() => mockSpan);
|
|
55
|
+
const mockTransaction = {
|
|
56
56
|
finish: mockFn(),
|
|
57
57
|
setData: mockFn(),
|
|
58
58
|
setName: mockFn(),
|
|
59
59
|
setStatus: mockFn(),
|
|
60
60
|
setTag: mockFn(),
|
|
61
|
-
startChild: (0, bun_test_1.mock)(
|
|
62
|
-
toTraceparent: (0, bun_test_1.mock)(
|
|
61
|
+
startChild: (0, bun_test_1.mock)(() => mockSpan),
|
|
62
|
+
toTraceparent: (0, bun_test_1.mock)(() => "mock-trace-parent"),
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
errorHandler: (0, bun_test_1.mock)(
|
|
66
|
-
requestHandler: (0, bun_test_1.mock)(
|
|
67
|
-
tracingHandler: (0, bun_test_1.mock)(
|
|
64
|
+
const handlers = {
|
|
65
|
+
errorHandler: (0, bun_test_1.mock)(() => (err, _req, _res, next) => next(err)),
|
|
66
|
+
requestHandler: (0, bun_test_1.mock)(() => (_req, _res, next) => next()),
|
|
67
|
+
tracingHandler: (0, bun_test_1.mock)(() => (_req, _res, next) => next()),
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
const structuredLogger = {
|
|
70
70
|
debug: mockFn(),
|
|
71
71
|
error: mockFn(),
|
|
72
72
|
fatal: mockFn(),
|
|
@@ -79,22 +79,22 @@ var registerSentryBunMock = function () {
|
|
|
79
79
|
captureException: mockFn(),
|
|
80
80
|
captureMessage: mockFn(),
|
|
81
81
|
clearScope: mockFn(),
|
|
82
|
-
close: (0, bun_test_1.mock)(
|
|
82
|
+
close: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
83
83
|
configureScope: mockFn(),
|
|
84
84
|
default: {
|
|
85
85
|
addBreadcrumb: mockFn(),
|
|
86
86
|
captureException: mockFn(),
|
|
87
87
|
captureMessage: mockFn(),
|
|
88
88
|
clearScope: mockFn(),
|
|
89
|
-
close: (0, bun_test_1.mock)(
|
|
89
|
+
close: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
90
90
|
configureScope: mockFn(),
|
|
91
|
-
flush: (0, bun_test_1.mock)(
|
|
92
|
-
getClient: (0, bun_test_1.mock)(
|
|
93
|
-
getCurrentHub: (0, bun_test_1.mock)(
|
|
94
|
-
getCurrentScope: (0, bun_test_1.mock)(
|
|
91
|
+
flush: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
92
|
+
getClient: (0, bun_test_1.mock)(() => mockClient),
|
|
93
|
+
getCurrentHub: (0, bun_test_1.mock)(() => mockHub),
|
|
94
|
+
getCurrentScope: (0, bun_test_1.mock)(() => mockScope),
|
|
95
95
|
Handlers: handlers,
|
|
96
96
|
init: mockFn(),
|
|
97
|
-
isInitialized: (0, bun_test_1.mock)(
|
|
97
|
+
isInitialized: (0, bun_test_1.mock)(() => true),
|
|
98
98
|
logger: structuredLogger,
|
|
99
99
|
popScope: mockFn(),
|
|
100
100
|
pushScope: mockFn(),
|
|
@@ -112,16 +112,16 @@ var registerSentryBunMock = function () {
|
|
|
112
112
|
setTags: mockFn(),
|
|
113
113
|
setUser: mockFn(),
|
|
114
114
|
setupExpressErrorHandler: mockFn(),
|
|
115
|
-
startTransaction: (0, bun_test_1.mock)(
|
|
116
|
-
withScope: (0, bun_test_1.mock)(
|
|
115
|
+
startTransaction: (0, bun_test_1.mock)(() => mockTransaction),
|
|
116
|
+
withScope: (0, bun_test_1.mock)((callback) => callback(mockScope)),
|
|
117
117
|
},
|
|
118
|
-
flush: (0, bun_test_1.mock)(
|
|
119
|
-
getClient: (0, bun_test_1.mock)(
|
|
120
|
-
getCurrentHub: (0, bun_test_1.mock)(
|
|
121
|
-
getCurrentScope: (0, bun_test_1.mock)(
|
|
118
|
+
flush: (0, bun_test_1.mock)(() => Promise.resolve(true)),
|
|
119
|
+
getClient: (0, bun_test_1.mock)(() => mockClient),
|
|
120
|
+
getCurrentHub: (0, bun_test_1.mock)(() => mockHub),
|
|
121
|
+
getCurrentScope: (0, bun_test_1.mock)(() => mockScope),
|
|
122
122
|
Handlers: handlers,
|
|
123
123
|
init: mockFn(),
|
|
124
|
-
isInitialized: (0, bun_test_1.mock)(
|
|
124
|
+
isInitialized: (0, bun_test_1.mock)(() => true),
|
|
125
125
|
logger: structuredLogger,
|
|
126
126
|
popScope: mockFn(),
|
|
127
127
|
pushScope: mockFn(),
|
|
@@ -139,8 +139,8 @@ var registerSentryBunMock = function () {
|
|
|
139
139
|
setTags: mockFn(),
|
|
140
140
|
setUser: mockFn(),
|
|
141
141
|
setupExpressErrorHandler: mockFn(),
|
|
142
|
-
startTransaction: (0, bun_test_1.mock)(
|
|
143
|
-
withScope: (0, bun_test_1.mock)(
|
|
142
|
+
startTransaction: (0, bun_test_1.mock)(() => mockTransaction),
|
|
143
|
+
withScope: (0, bun_test_1.mock)((callback) => callback(mockScope)),
|
|
144
144
|
};
|
|
145
145
|
});
|
|
146
146
|
};
|
package/dist/mongo/connection.js
CHANGED
|
@@ -1,134 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
4
|
};
|
|
66
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
6
|
exports.ensureTestMongooseConnected = exports.buildDatabaseUri = exports.splitMongoUri = exports.DEFAULT_LOCAL_MONGO_URI = void 0;
|
|
68
|
-
|
|
69
|
-
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const testLogger_1 = require("../logging/testLogger");
|
|
70
9
|
exports.DEFAULT_LOCAL_MONGO_URI = "mongodb://127.0.0.1/terreno?&connectTimeoutMS=360000";
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
10
|
+
const splitMongoUri = (uri) => {
|
|
11
|
+
const [uriWithoutQuery, query] = uri.split("?");
|
|
12
|
+
const lastSlashIndex = uriWithoutQuery.lastIndexOf("/");
|
|
13
|
+
const baseUri = lastSlashIndex > "mongodb://".length
|
|
75
14
|
? uriWithoutQuery.slice(0, lastSlashIndex)
|
|
76
15
|
: uriWithoutQuery;
|
|
77
|
-
|
|
78
|
-
return { baseUri
|
|
16
|
+
const uriOptions = query ? `?${query}` : "";
|
|
17
|
+
return { baseUri, uriOptions };
|
|
79
18
|
};
|
|
80
19
|
exports.splitMongoUri = splitMongoUri;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var normalizedUri = uriWithoutQuery.endsWith("/") ? uriWithoutQuery : "".concat(uriWithoutQuery, "/");
|
|
20
|
+
const buildDatabaseUri = ({ uri, databaseName, }) => {
|
|
21
|
+
const [uriWithoutQuery, queryParams] = uri.split("?");
|
|
22
|
+
const normalizedUri = uriWithoutQuery.endsWith("/") ? uriWithoutQuery : `${uriWithoutQuery}/`;
|
|
85
23
|
if (queryParams) {
|
|
86
|
-
return
|
|
24
|
+
return `${normalizedUri}${databaseName}?${queryParams}`;
|
|
87
25
|
}
|
|
88
|
-
return
|
|
26
|
+
return `${normalizedUri}${databaseName}`;
|
|
89
27
|
};
|
|
90
28
|
exports.buildDatabaseUri = buildDatabaseUri;
|
|
91
29
|
/** Ensures Mongoose is connected without replacing an existing test connection. */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
30
|
+
const ensureTestMongooseConnected = async (options = {}) => {
|
|
31
|
+
if (mongoose_1.default.connection.readyState === 1) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (mongoose_1.default.connection.readyState === 2) {
|
|
35
|
+
await mongoose_1.default.connection.asPromise();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const uri = process.env.TERRENO_TEST_MONGODB_URI?.trim() || options.defaultUri || exports.DEFAULT_LOCAL_MONGO_URI;
|
|
39
|
+
try {
|
|
40
|
+
await mongoose_1.default.connect(uri);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (options.onConnectError) {
|
|
44
|
+
options.onConnectError(error);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
testLogger_1.testLogger.catch(error);
|
|
96
48
|
}
|
|
97
|
-
return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (options) {
|
|
98
|
-
var uri, error_1;
|
|
99
|
-
var _a;
|
|
100
|
-
if (options === void 0) { options = {}; }
|
|
101
|
-
return __generator(this, function (_b) {
|
|
102
|
-
switch (_b.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
if (mongoose_1.default.connection.readyState === 1) {
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
if (!(mongoose_1.default.connection.readyState === 2)) return [3 /*break*/, 2];
|
|
108
|
-
return [4 /*yield*/, mongoose_1.default.connection.asPromise()];
|
|
109
|
-
case 1:
|
|
110
|
-
_b.sent();
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
case 2:
|
|
113
|
-
uri = ((_a = process.env.TERRENO_TEST_MONGODB_URI) === null || _a === void 0 ? void 0 : _a.trim()) || options.defaultUri || exports.DEFAULT_LOCAL_MONGO_URI;
|
|
114
|
-
_b.label = 3;
|
|
115
|
-
case 3:
|
|
116
|
-
_b.trys.push([3, 5, , 6]);
|
|
117
|
-
return [4 /*yield*/, mongoose_1.default.connect(uri)];
|
|
118
|
-
case 4:
|
|
119
|
-
_b.sent();
|
|
120
|
-
return [3 /*break*/, 6];
|
|
121
|
-
case 5:
|
|
122
|
-
error_1 = _b.sent();
|
|
123
|
-
if (options.onConnectError) {
|
|
124
|
-
options.onConnectError(error_1);
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
}
|
|
127
|
-
testLogger_1.testLogger.catch(error_1);
|
|
128
|
-
return [3 /*break*/, 6];
|
|
129
|
-
case 6: return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
49
|
};
|
|
134
50
|
exports.ensureTestMongooseConnected = ensureTestMongooseConnected;
|
|
@@ -1,73 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
3
|
exports.ensureMongoBinary = void 0;
|
|
73
4
|
/**
|
|
@@ -75,29 +6,18 @@ exports.ensureMongoBinary = void 0;
|
|
|
75
6
|
*
|
|
76
7
|
* Usage: bun ./src/mongo/ensureMongoBinary.ts
|
|
77
8
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
startTime = Date.now();
|
|
91
|
-
console.info("[ensureMongoBinary] Ensuring MongoDB binary is downloaded and cached...");
|
|
92
|
-
return [4 /*yield*/, MongoBinary.getPath()];
|
|
93
|
-
case 2:
|
|
94
|
-
binaryPath = _a.sent();
|
|
95
|
-
elapsed = Date.now() - startTime;
|
|
96
|
-
console.info("[ensureMongoBinary] MongoDB binary ready at: ".concat(binaryPath, " (").concat(elapsed, "ms)"));
|
|
97
|
-
return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); };
|
|
9
|
+
const ensureMongoBinary = async () => {
|
|
10
|
+
if (process.env.CI) {
|
|
11
|
+
console.info("[ensureMongoBinary] Skipping on CI (using external MongoDB when configured)");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const { MongoBinary } = await import("mongodb-memory-server-core");
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
console.info("[ensureMongoBinary] Ensuring MongoDB binary is downloaded and cached...");
|
|
17
|
+
const binaryPath = await MongoBinary.getPath();
|
|
18
|
+
const elapsed = Date.now() - startTime;
|
|
19
|
+
console.info(`[ensureMongoBinary] MongoDB binary ready at: ${binaryPath} (${elapsed}ms)`);
|
|
20
|
+
};
|
|
101
21
|
exports.ensureMongoBinary = ensureMongoBinary;
|
|
102
22
|
if (require.main === module) {
|
|
103
23
|
void (0, exports.ensureMongoBinary)();
|