@tachybase/test 1.6.13-alpha.4 → 1.6.13-alpha.6
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/es/index.mjs +28 -13
- package/es/server/errors.d.ts +1 -0
- package/lib/server/errors.d.ts +1 -0
- package/lib/server/errors.js +33 -0
- package/lib/server/setupTestEnvironment.js +24 -13
- package/package.json +5 -5
package/es/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { createRequire } from "node:module";
|
|
|
12
12
|
import os from "node:os";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import { pathToFileURL } from "node:url";
|
|
15
|
+
import { require as require$1 } from "tsx/cjs/api";
|
|
15
16
|
class MockServer extends Application {
|
|
16
17
|
async loadAndInstall(options = {}) {
|
|
17
18
|
await this.load({ method: "install" });
|
|
@@ -208,6 +209,11 @@ async function createMockServer(options = {}) {
|
|
|
208
209
|
}
|
|
209
210
|
return app;
|
|
210
211
|
}
|
|
212
|
+
function moduleNotFound(request) {
|
|
213
|
+
const error = new Error(`Cannot find module '${request}'`);
|
|
214
|
+
error.code = "MODULE_NOT_FOUND";
|
|
215
|
+
return error;
|
|
216
|
+
}
|
|
211
217
|
const runtimeRequire = createRequire(path.resolve(process.cwd(), "package.json"));
|
|
212
218
|
const selfRequire = createRequire(require.resolve("@tachybase/test/package.json"));
|
|
213
219
|
const workspacePluginNameAliases = {
|
|
@@ -233,19 +239,28 @@ function getTachybaseGlobal(runtimeRequire2) {
|
|
|
233
239
|
throw error;
|
|
234
240
|
}
|
|
235
241
|
}
|
|
236
|
-
function getCoreModules() {
|
|
242
|
+
function getCoreModules(workspaceRoot, workspaceRequire = runtimeRequire) {
|
|
237
243
|
const cores = [];
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
const addCore = (loader) => {
|
|
245
|
+
try {
|
|
246
|
+
cores.push(loader());
|
|
247
|
+
} catch (e) {
|
|
248
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
addCore(() => selfRequire("@tego/core"));
|
|
252
|
+
addCore(() => workspaceRequire("@tego/core"));
|
|
253
|
+
addCore(() => {
|
|
254
|
+
const sourceEntry = path.resolve(workspaceRoot, "packages/core/src/index.ts");
|
|
255
|
+
if (!fs.existsSync(sourceEntry)) {
|
|
256
|
+
throw moduleNotFound(sourceEntry);
|
|
257
|
+
}
|
|
258
|
+
return require$1(sourceEntry, path.resolve(workspaceRoot, "package.json"));
|
|
259
|
+
});
|
|
260
|
+
addCore(() => selfRequire("@tego/server"));
|
|
261
|
+
addCore(() => workspaceRequire("@tego/server"));
|
|
262
|
+
addCore(() => createRequire(selfRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
263
|
+
addCore(() => createRequire(workspaceRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
249
264
|
return [...new Set(cores)];
|
|
250
265
|
}
|
|
251
266
|
function createTestDbStorage() {
|
|
@@ -577,7 +592,7 @@ function setupServerTestEnvironment(options = {}) {
|
|
|
577
592
|
TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
|
|
578
593
|
process.env.TEGO_RUNTIME_HOME = path.join(os.tmpdir(), "test-sqlite");
|
|
579
594
|
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
|
|
580
|
-
const coreModules = getCoreModules();
|
|
595
|
+
const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
|
|
581
596
|
for (const core of coreModules) {
|
|
582
597
|
patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
|
|
583
598
|
patchPluginManager(core, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function moduleNotFound(request: string): NodeJS.ErrnoException;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function moduleNotFound(request: string): NodeJS.ErrnoException;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
moduleNotFound: () => moduleNotFound
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
function moduleNotFound(request) {
|
|
25
|
+
const error = new Error(`Cannot find module '${request}'`);
|
|
26
|
+
error.code = "MODULE_NOT_FOUND";
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
__name(moduleNotFound, "moduleNotFound");
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
moduleNotFound
|
|
33
|
+
});
|
|
@@ -37,6 +37,8 @@ var import_node_os = __toESM(require("node:os"));
|
|
|
37
37
|
var import_node_path = __toESM(require("node:path"));
|
|
38
38
|
var import_node_url = require("node:url");
|
|
39
39
|
var import_globals = __toESM(require("@tachybase/globals"));
|
|
40
|
+
var import_api = require("tsx/cjs/api");
|
|
41
|
+
var import_errors = require("./errors");
|
|
40
42
|
const runtimeRequire = (0, import_node_module.createRequire)(import_node_path.default.resolve(process.cwd(), "package.json"));
|
|
41
43
|
const selfRequire = (0, import_node_module.createRequire)(require.resolve("@tachybase/test/package.json"));
|
|
42
44
|
const workspacePluginNameAliases = {
|
|
@@ -64,19 +66,28 @@ function getTachybaseGlobal(runtimeRequire2) {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
__name(getTachybaseGlobal, "getTachybaseGlobal");
|
|
67
|
-
function getCoreModules() {
|
|
69
|
+
function getCoreModules(workspaceRoot, workspaceRequire = runtimeRequire) {
|
|
68
70
|
const cores = [];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
const addCore = /* @__PURE__ */ __name((loader) => {
|
|
72
|
+
try {
|
|
73
|
+
cores.push(loader());
|
|
74
|
+
} catch (e) {
|
|
75
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
76
|
+
}
|
|
77
|
+
}, "addCore");
|
|
78
|
+
addCore(() => selfRequire("@tego/core"));
|
|
79
|
+
addCore(() => workspaceRequire("@tego/core"));
|
|
80
|
+
addCore(() => {
|
|
81
|
+
const sourceEntry = import_node_path.default.resolve(workspaceRoot, "packages/core/src/index.ts");
|
|
82
|
+
if (!import_node_fs.default.existsSync(sourceEntry)) {
|
|
83
|
+
throw (0, import_errors.moduleNotFound)(sourceEntry);
|
|
84
|
+
}
|
|
85
|
+
return (0, import_api.require)(sourceEntry, import_node_path.default.resolve(workspaceRoot, "package.json"));
|
|
86
|
+
});
|
|
87
|
+
addCore(() => selfRequire("@tego/server"));
|
|
88
|
+
addCore(() => workspaceRequire("@tego/server"));
|
|
89
|
+
addCore(() => (0, import_node_module.createRequire)(selfRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
90
|
+
addCore(() => (0, import_node_module.createRequire)(workspaceRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
80
91
|
return [...new Set(cores)];
|
|
81
92
|
}
|
|
82
93
|
__name(getCoreModules, "getCoreModules");
|
|
@@ -419,7 +430,7 @@ function setupServerTestEnvironment(options = {}) {
|
|
|
419
430
|
TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
|
|
420
431
|
process.env.TEGO_RUNTIME_HOME = import_node_path.default.join(import_node_os.default.tmpdir(), "test-sqlite");
|
|
421
432
|
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
|
|
422
|
-
const coreModules = getCoreModules();
|
|
433
|
+
const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
|
|
423
434
|
for (const core of coreModules) {
|
|
424
435
|
patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
|
|
425
436
|
patchPluginManager(core, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/test",
|
|
3
|
-
"version": "1.6.13-alpha.
|
|
3
|
+
"version": "1.6.13-alpha.6",
|
|
4
4
|
"homepage": "https://github.com/tegojs/tego#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/tegojs/tego/issues"
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
"vite": "^7.1.10",
|
|
114
114
|
"vitest": "^3.2.4",
|
|
115
115
|
"ws": "^8.18.3",
|
|
116
|
-
"@tachybase/database": "1.6.13-alpha.
|
|
117
|
-
"@tachybase/globals": "1.6.13-alpha.
|
|
118
|
-
"@tachybase/schema": "1.6.13-alpha.
|
|
119
|
-
"@tego/core": "1.6.13-alpha.
|
|
116
|
+
"@tachybase/database": "1.6.13-alpha.6",
|
|
117
|
+
"@tachybase/globals": "1.6.13-alpha.6",
|
|
118
|
+
"@tachybase/schema": "1.6.13-alpha.6",
|
|
119
|
+
"@tego/core": "1.6.13-alpha.6"
|
|
120
120
|
}
|
|
121
121
|
}
|