@acmekit/test-utils 2.13.81 → 2.13.83
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/dist/acmekit-test-runner-utils/bootstrap-app.d.ts +3 -1
- package/dist/acmekit-test-runner-utils/bootstrap-app.d.ts.map +1 -1
- package/dist/acmekit-test-runner-utils/bootstrap-app.js +6 -2
- package/dist/acmekit-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/integration-test-runner.d.ts +54 -0
- package/dist/integration-test-runner.d.ts.map +1 -0
- package/dist/integration-test-runner.js +193 -0
- package/dist/integration-test-runner.js.map +1 -0
- package/dist/pipeline/errors.d.ts +13 -0
- package/dist/pipeline/errors.d.ts.map +1 -0
- package/dist/pipeline/errors.js +25 -0
- package/dist/pipeline/errors.js.map +1 -0
- package/dist/pipeline/pipeline.d.ts +31 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +92 -0
- package/dist/pipeline/pipeline.js.map +1 -0
- package/dist/pipeline/stages/config.d.ts +23 -0
- package/dist/pipeline/stages/config.d.ts.map +1 -0
- package/dist/pipeline/stages/config.js +148 -0
- package/dist/pipeline/stages/config.js.map +1 -0
- package/dist/pipeline/stages/database.d.ts +28 -0
- package/dist/pipeline/stages/database.d.ts.map +1 -0
- package/dist/pipeline/stages/database.js +276 -0
- package/dist/pipeline/stages/database.js.map +1 -0
- package/dist/pipeline/stages/http.d.ts +18 -0
- package/dist/pipeline/stages/http.d.ts.map +1 -0
- package/dist/pipeline/stages/http.js +67 -0
- package/dist/pipeline/stages/http.js.map +1 -0
- package/dist/pipeline/stages/module.d.ts +20 -0
- package/dist/pipeline/stages/module.d.ts.map +1 -0
- package/dist/pipeline/stages/module.js +104 -0
- package/dist/pipeline/stages/module.js.map +1 -0
- package/dist/pipeline/stages/plugin-resources.d.ts +13 -0
- package/dist/pipeline/stages/plugin-resources.d.ts.map +1 -0
- package/dist/pipeline/stages/plugin-resources.js +94 -0
- package/dist/pipeline/stages/plugin-resources.js.map +1 -0
- package/dist/pipeline/stages/proxy.d.ts +23 -0
- package/dist/pipeline/stages/proxy.d.ts.map +1 -0
- package/dist/pipeline/stages/proxy.js +99 -0
- package/dist/pipeline/stages/proxy.js.map +1 -0
- package/dist/pipeline/types.d.ts +133 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +29 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/plugin-test-runner.d.ts.map +1 -1
- package/dist/plugin-test-runner.js +27 -1
- package/dist/plugin-test-runner.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfigStage = void 0;
|
|
7
|
+
const utils_1 = require("@acmekit/framework/utils");
|
|
8
|
+
const mock_event_bus_service_1 = __importDefault(require("../../mock-event-bus-service"));
|
|
9
|
+
/**
|
|
10
|
+
* ConfigStage — resolves module configuration based on mode.
|
|
11
|
+
*
|
|
12
|
+
* App mode: reads acmekit-config.ts, overrides DB URL, disables admin.
|
|
13
|
+
* Plugin mode: uses defineConfig with plugin registered, discovers modules from plugin.
|
|
14
|
+
* Module mode: builds minimal config for a single module.
|
|
15
|
+
*/
|
|
16
|
+
class ConfigStage {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.name = "ConfigStage";
|
|
19
|
+
}
|
|
20
|
+
async setup(ctx) {
|
|
21
|
+
if (ctx.mode === "app") {
|
|
22
|
+
await this.setupAppConfig(ctx);
|
|
23
|
+
}
|
|
24
|
+
else if (ctx.mode === "plugin") {
|
|
25
|
+
await this.setupPluginConfig(ctx);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.setupModuleConfig(ctx);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async reset(_ctx) {
|
|
32
|
+
// Config doesn't change between tests
|
|
33
|
+
}
|
|
34
|
+
async destroy(_ctx) {
|
|
35
|
+
// No resources to clean up
|
|
36
|
+
}
|
|
37
|
+
// ── Private ──
|
|
38
|
+
async setupAppConfig(ctx) {
|
|
39
|
+
const { configLoaderOverride, applyEnvVarsToProcess } = await import("../../acmekit-test-runner-utils/index.js");
|
|
40
|
+
await configLoaderOverride(ctx.cwd, ctx.dbConfig);
|
|
41
|
+
applyEnvVarsToProcess(ctx.env);
|
|
42
|
+
}
|
|
43
|
+
async setupPluginConfig(ctx) {
|
|
44
|
+
const { defineConfig } = require("@acmekit/framework/utils");
|
|
45
|
+
const configModule = defineConfig({
|
|
46
|
+
plugins: [
|
|
47
|
+
{ resolve: ctx.pluginPath, options: ctx.pluginOptions ?? {} },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
// Discover plugin details
|
|
51
|
+
ctx.plugins = await (0, utils_1.getResolvedPlugins)(ctx.cwd, configModule);
|
|
52
|
+
// Build module configs from discovered plugins
|
|
53
|
+
const pluginModulesConfig = {};
|
|
54
|
+
const moduleSdkImports = require("@acmekit/framework/modules-sdk");
|
|
55
|
+
for (const plugin of ctx.plugins) {
|
|
56
|
+
if (!plugin.modules)
|
|
57
|
+
continue;
|
|
58
|
+
for (const mod of plugin.modules) {
|
|
59
|
+
const moduleName = this.resolveModuleName(mod);
|
|
60
|
+
pluginModulesConfig[moduleName] = {
|
|
61
|
+
definition: moduleSdkImports.ModulesDefinition[moduleName],
|
|
62
|
+
resolve: mod.resolve,
|
|
63
|
+
options: {
|
|
64
|
+
database: ctx.dbConfig,
|
|
65
|
+
...(ctx.pluginOptions ?? {}),
|
|
66
|
+
[utils_1.isSharedConnectionSymbol]: true,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
ctx.allModulesConfig = {
|
|
72
|
+
...pluginModulesConfig,
|
|
73
|
+
...(ctx.additionalModules ?? {}),
|
|
74
|
+
};
|
|
75
|
+
// Build initModules options
|
|
76
|
+
ctx.moduleOptionsConfig = {
|
|
77
|
+
injectedDependencies: {
|
|
78
|
+
[utils_1.ContainerRegistrationKeys.PG_CONNECTION]: ctx.pgConnection,
|
|
79
|
+
[utils_1.Modules.EVENT_BUS]: new mock_event_bus_service_1.default(),
|
|
80
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: console,
|
|
81
|
+
[utils_1.ContainerRegistrationKeys.CONFIG_MODULE]: {
|
|
82
|
+
modules: ctx.allModulesConfig,
|
|
83
|
+
},
|
|
84
|
+
...(ctx.injectedDependencies ?? {}),
|
|
85
|
+
},
|
|
86
|
+
modulesConfig: ctx.allModulesConfig,
|
|
87
|
+
databaseConfig: ctx.dbConfig,
|
|
88
|
+
joinerConfig: [],
|
|
89
|
+
preventConnectionDestroyWarning: true,
|
|
90
|
+
cwd: ctx.cwd,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
setupModuleConfig(ctx) {
|
|
94
|
+
const moduleSdkImports = require("@acmekit/framework/modules-sdk");
|
|
95
|
+
ctx.allModulesConfig = {
|
|
96
|
+
[ctx.moduleName]: {
|
|
97
|
+
definition: moduleSdkImports.ModulesDefinition[ctx.moduleName],
|
|
98
|
+
resolve: ctx.moduleResolve,
|
|
99
|
+
dependencies: ctx.moduleDependencies,
|
|
100
|
+
options: {
|
|
101
|
+
database: ctx.dbConfig,
|
|
102
|
+
...(ctx.moduleOptions ?? {}),
|
|
103
|
+
[utils_1.isSharedConnectionSymbol]: true,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
ctx.moduleOptionsConfig = {
|
|
108
|
+
injectedDependencies: {
|
|
109
|
+
[utils_1.ContainerRegistrationKeys.PG_CONNECTION]: ctx.pgConnection,
|
|
110
|
+
[utils_1.Modules.EVENT_BUS]: new mock_event_bus_service_1.default(),
|
|
111
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: console,
|
|
112
|
+
[utils_1.ContainerRegistrationKeys.CONFIG_MODULE]: {
|
|
113
|
+
modules: ctx.allModulesConfig,
|
|
114
|
+
},
|
|
115
|
+
...(ctx.injectedDependencies ?? {}),
|
|
116
|
+
},
|
|
117
|
+
modulesConfig: ctx.allModulesConfig,
|
|
118
|
+
databaseConfig: ctx.dbConfig,
|
|
119
|
+
joinerConfig: ctx.joinerConfig ?? [],
|
|
120
|
+
preventConnectionDestroyWarning: true,
|
|
121
|
+
cwd: ctx.cwd,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extract module service name from __joinerConfig.
|
|
126
|
+
* Same logic as plugin-test-runner.ts.
|
|
127
|
+
*/
|
|
128
|
+
resolveModuleName(mod) {
|
|
129
|
+
try {
|
|
130
|
+
const moduleExport = require(mod.resolve);
|
|
131
|
+
const defaultExport = moduleExport.default ?? moduleExport;
|
|
132
|
+
if (defaultExport?.service?.prototype?.__joinerConfig) {
|
|
133
|
+
const joinerConfig = typeof defaultExport.service.prototype.__joinerConfig === "function"
|
|
134
|
+
? defaultExport.service.prototype.__joinerConfig()
|
|
135
|
+
: defaultExport.service.prototype.__joinerConfig;
|
|
136
|
+
if (joinerConfig?.serviceName) {
|
|
137
|
+
return joinerConfig.serviceName;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Fall back to path-based key
|
|
143
|
+
}
|
|
144
|
+
return mod.resolve;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ConfigStage = ConfigStage;
|
|
148
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/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AC5B,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,EAAE;YACpC,+BAA+B,EAAE,IAAI;YACrC,GAAG,EAAE,GAAG,CAAC,GAAG;SACb,CAAA;IACH,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAC,GAAQ;QAChC,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzC,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAA;YAC1D,IAAI,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;gBACtD,MAAM,YAAY,GAChB,OAAO,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,KAAK,UAAU;oBAClE,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE;oBAClD,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAA;gBACpD,IAAI,YAAY,EAAE,WAAW,EAAE,CAAC;oBAC9B,OAAO,YAAY,CAAC,WAAW,CAAA;gBACjC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;QACD,OAAO,GAAG,CAAC,OAAO,CAAA;IACpB,CAAC;CACF;AA9ID,kCA8IC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BootstrapStage, PipelineContext } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* DatabaseStage — creates the DB connection and MikroORM wrapper.
|
|
4
|
+
*
|
|
5
|
+
* App mode: pg-god CREATE DATABASE + knex connection.
|
|
6
|
+
* Reset: TRUNCATE all tables.
|
|
7
|
+
* Destroy: pg-god DROP DATABASE.
|
|
8
|
+
*
|
|
9
|
+
* Plugin/Module mode: MikroORM schema sync from entities.
|
|
10
|
+
* Reset: clearDatabase() + setupDatabase() (matches existing plugin runner).
|
|
11
|
+
* Destroy: close connections.
|
|
12
|
+
*/
|
|
13
|
+
export declare class DatabaseStage implements BootstrapStage {
|
|
14
|
+
name: string;
|
|
15
|
+
setup(ctx: PipelineContext): Promise<void>;
|
|
16
|
+
reset(ctx: PipelineContext): Promise<void>;
|
|
17
|
+
destroy(ctx: PipelineContext): Promise<void>;
|
|
18
|
+
private setupAppMode;
|
|
19
|
+
private setupPluginOrModuleMode;
|
|
20
|
+
private discoverModels;
|
|
21
|
+
/**
|
|
22
|
+
* Plugin HTTP mode: boots the full framework, so needs all module tables.
|
|
23
|
+
* Uses pg-god + migrations (same as app mode) but with synthetic config.
|
|
24
|
+
*/
|
|
25
|
+
private setupPluginHttpMode;
|
|
26
|
+
private findModelsDir;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/pipeline/stages/database.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,IAAI,SAAkB;IAEhB,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB1C,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAyCpC,YAAY;YA4CZ,uBAAuB;IA6BrC,OAAO,CAAC,cAAc;IAuCtB;;;OAGG;YACW,mBAAmB;IAqEjC,OAAO,CAAC,aAAa;CAKtB"}
|
|
@@ -0,0 +1,276 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DatabaseStage = void 0;
|
|
37
|
+
const utils_1 = require("@acmekit/framework/utils");
|
|
38
|
+
const awilix_1 = require("@acmekit/framework/awilix");
|
|
39
|
+
const logger_1 = require("@acmekit/framework/logger");
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const database_1 = require("../../database");
|
|
42
|
+
const wait_workflow_executions_1 = require("../../acmekit-test-runner-utils/wait-workflow-executions");
|
|
43
|
+
/**
|
|
44
|
+
* DatabaseStage — creates the DB connection and MikroORM wrapper.
|
|
45
|
+
*
|
|
46
|
+
* App mode: pg-god CREATE DATABASE + knex connection.
|
|
47
|
+
* Reset: TRUNCATE all tables.
|
|
48
|
+
* Destroy: pg-god DROP DATABASE.
|
|
49
|
+
*
|
|
50
|
+
* Plugin/Module mode: MikroORM schema sync from entities.
|
|
51
|
+
* Reset: clearDatabase() + setupDatabase() (matches existing plugin runner).
|
|
52
|
+
* Destroy: close connections.
|
|
53
|
+
*/
|
|
54
|
+
class DatabaseStage {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.name = "DatabaseStage";
|
|
57
|
+
}
|
|
58
|
+
async setup(ctx) {
|
|
59
|
+
if (ctx.mode === "app") {
|
|
60
|
+
await this.setupAppMode(ctx);
|
|
61
|
+
}
|
|
62
|
+
else if (ctx.mode === "plugin" && ctx.http) {
|
|
63
|
+
await this.setupPluginHttpMode(ctx);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
await this.setupPluginOrModuleMode(ctx);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async reset(ctx) {
|
|
70
|
+
if (ctx.mode === "app" || (ctx.mode === "plugin" && ctx.http)) {
|
|
71
|
+
// App + plugin HTTP: TRUNCATE via dbUtils (framework is running)
|
|
72
|
+
if (ctx.container) {
|
|
73
|
+
await (0, wait_workflow_executions_1.waitWorkflowExecutions)(ctx.container);
|
|
74
|
+
}
|
|
75
|
+
if (!ctx.disableAutoTeardown && ctx.dbUtils) {
|
|
76
|
+
await ctx.dbUtils.teardown({ schema: ctx.dbConfig.schema });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Plugin/Module mode (non-HTTP): DROP SCHEMA + re-init
|
|
81
|
+
if (ctx.MikroOrmWrapper) {
|
|
82
|
+
await ctx.MikroOrmWrapper.clearDatabase();
|
|
83
|
+
await ctx.MikroOrmWrapper.setupDatabase();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async destroy(ctx) {
|
|
88
|
+
try {
|
|
89
|
+
if (ctx.mode === "app" || (ctx.mode === "plugin" && ctx.http)) {
|
|
90
|
+
// App + plugin HTTP: destroy knex connection + drop DB
|
|
91
|
+
await ctx.dbUtils?.shutdown(ctx.dbConfig.dbName);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Plugin/Module mode: close MikroORM (if still alive) + destroy pgConnection
|
|
95
|
+
// Note: clearDatabase() already calls orm.close() during the last reset,
|
|
96
|
+
// so the ORM may already be closed here. Only attempt if it's still alive.
|
|
97
|
+
if (ctx.MikroOrmWrapper) {
|
|
98
|
+
try {
|
|
99
|
+
const orm = ctx.MikroOrmWrapper.getOrm();
|
|
100
|
+
if (orm && (await orm.isConnected())) {
|
|
101
|
+
await orm.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// ORM already closed — safe to ignore
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// pgConnection is separate from MikroORM's internal connection —
|
|
109
|
+
// always destroy it. Order: context first, then connection.
|
|
110
|
+
try {
|
|
111
|
+
await ctx.pgConnection?.context?.destroy();
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Ignore context destroy errors
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
await ctx.pgConnection?.destroy();
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Ignore connection destroy errors
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
ctx.pgConnection = null;
|
|
126
|
+
ctx.dbUtils = null;
|
|
127
|
+
ctx.MikroOrmWrapper = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ── Private ──
|
|
131
|
+
async setupAppMode(ctx) {
|
|
132
|
+
// 1. Create framework loader and resolve plugins
|
|
133
|
+
const { container, AcmeKitAppLoader, Migrator } = await import("@acmekit/framework");
|
|
134
|
+
const appLoader = new AcmeKitAppLoader({
|
|
135
|
+
acmekitConfigPath: ctx.cwd,
|
|
136
|
+
cwd: ctx.cwd,
|
|
137
|
+
});
|
|
138
|
+
const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
|
|
139
|
+
const plugins = await (0, utils_1.getResolvedPlugins)(ctx.cwd, configModule);
|
|
140
|
+
(0, utils_1.mergePluginModules)(configModule, plugins);
|
|
141
|
+
container.register({
|
|
142
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: (0, awilix_1.asValue)(logger_1.logger),
|
|
143
|
+
});
|
|
144
|
+
// 2. Create database and init connection
|
|
145
|
+
const dbUtils = (0, database_1.dbTestUtilFactory)();
|
|
146
|
+
ctx.dbUtils = dbUtils;
|
|
147
|
+
await dbUtils.create(ctx.dbConfig.dbName);
|
|
148
|
+
const { initDb, migrateDatabase, syncLinks } = await import("../../acmekit-test-runner-utils/use-db.js");
|
|
149
|
+
dbUtils.pgConnection_ = await initDb();
|
|
150
|
+
// 3. Run migrations and sync links
|
|
151
|
+
const migrator = new Migrator({ container });
|
|
152
|
+
await migrator.ensureMigrationsTable();
|
|
153
|
+
await migrateDatabase(appLoader);
|
|
154
|
+
await syncLinks(appLoader, ctx.cwd, container, logger_1.logger);
|
|
155
|
+
// 4. Clear module instances from migration phase, then load app
|
|
156
|
+
const { clearInstances } = await import("../../acmekit-test-runner-utils/clear-instances.js");
|
|
157
|
+
await clearInstances();
|
|
158
|
+
ctx.loadedApplication = await appLoader.load();
|
|
159
|
+
}
|
|
160
|
+
async setupPluginOrModuleMode(ctx) {
|
|
161
|
+
// Create shared pg connection
|
|
162
|
+
ctx.pgConnection = utils_1.ModulesSdkUtils.createPgConnection(ctx.dbConfig);
|
|
163
|
+
// Patch pgConnection into moduleOptionsConfig (built by ConfigStage
|
|
164
|
+
// before pgConnection existed, so it captured null)
|
|
165
|
+
if (ctx.moduleOptionsConfig?.injectedDependencies) {
|
|
166
|
+
ctx.moduleOptionsConfig.injectedDependencies[utils_1.ContainerRegistrationKeys.PG_CONNECTION] = ctx.pgConnection;
|
|
167
|
+
}
|
|
168
|
+
// Discover models
|
|
169
|
+
const models = this.discoverModels(ctx);
|
|
170
|
+
ctx.discoveredModels = (0, utils_1.toMikroOrmEntities)(models);
|
|
171
|
+
// Create MikroORM wrapper
|
|
172
|
+
if (ctx.discoveredModels.length) {
|
|
173
|
+
ctx.MikroOrmWrapper = (0, database_1.getMikroOrmWrapper)({
|
|
174
|
+
mikroOrmEntities: ctx.discoveredModels,
|
|
175
|
+
clientUrl: ctx.dbConfig.clientUrl,
|
|
176
|
+
schema: ctx.dbConfig.schema,
|
|
177
|
+
});
|
|
178
|
+
// Initial schema setup (runs once in beforeAll)
|
|
179
|
+
await ctx.MikroOrmWrapper.setupDatabase();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
discoverModels(ctx) {
|
|
183
|
+
// If models were explicitly provided, use them
|
|
184
|
+
if (ctx.moduleModels?.length) {
|
|
185
|
+
return ctx.moduleModels;
|
|
186
|
+
}
|
|
187
|
+
const models = [];
|
|
188
|
+
if (ctx.mode === "module") {
|
|
189
|
+
// Single module — discover from resolve path
|
|
190
|
+
const basePath = (0, utils_1.normalizeImportPathWithSource)(ctx.moduleResolve ?? ctx.cwd);
|
|
191
|
+
const modelsPath = this.findModelsDir(basePath);
|
|
192
|
+
if (modelsPath) {
|
|
193
|
+
models.push(...(0, utils_1.loadModels)(`${basePath}${modelsPath}`));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (ctx.mode === "plugin") {
|
|
197
|
+
// Plugin — discover from all plugin modules
|
|
198
|
+
for (const plugin of ctx.plugins) {
|
|
199
|
+
if (plugin.modules) {
|
|
200
|
+
for (const mod of plugin.modules) {
|
|
201
|
+
const basePath = (0, utils_1.normalizeImportPathWithSource)(mod.resolve ?? ctx.cwd);
|
|
202
|
+
const modelsPath = this.findModelsDir(basePath);
|
|
203
|
+
if (modelsPath) {
|
|
204
|
+
models.push(...(0, utils_1.loadModels)(`${basePath}${modelsPath}`));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return models;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Plugin HTTP mode: boots the full framework, so needs all module tables.
|
|
214
|
+
* Uses pg-god + migrations (same as app mode) but with synthetic config.
|
|
215
|
+
*/
|
|
216
|
+
async setupPluginHttpMode(ctx) {
|
|
217
|
+
const { defineConfig } = require("@acmekit/framework/utils");
|
|
218
|
+
// Build synthetic config for the plugin
|
|
219
|
+
const syntheticConfig = defineConfig({
|
|
220
|
+
plugins: [
|
|
221
|
+
{ resolve: ctx.pluginPath, options: ctx.pluginOptions ?? {} },
|
|
222
|
+
],
|
|
223
|
+
projectConfig: {
|
|
224
|
+
databaseUrl: ctx.dbConfig.clientUrl,
|
|
225
|
+
databaseLogging: ctx.dbConfig.debug,
|
|
226
|
+
http: {
|
|
227
|
+
jwtSecret: "test-jwt-secret-for-plugin-integration-tests",
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
Object.assign(syntheticConfig.admin ?? {}, { disable: true });
|
|
232
|
+
// Store on context for HttpStage to use
|
|
233
|
+
ctx.syntheticConfig = syntheticConfig;
|
|
234
|
+
// Load config into framework's global configManager
|
|
235
|
+
const { configManager } = await import("@acmekit/framework/config");
|
|
236
|
+
configManager.loadConfig({
|
|
237
|
+
projectConfig: syntheticConfig,
|
|
238
|
+
baseDir: ctx.pluginPath,
|
|
239
|
+
throwOnError: false,
|
|
240
|
+
});
|
|
241
|
+
// Create framework loader (needed for migrations)
|
|
242
|
+
const { container, AcmeKitAppLoader, Migrator } = await import("@acmekit/framework");
|
|
243
|
+
const appLoader = new AcmeKitAppLoader({
|
|
244
|
+
acmekitConfigPath: ctx.pluginPath,
|
|
245
|
+
cwd: ctx.pluginPath,
|
|
246
|
+
});
|
|
247
|
+
const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
|
|
248
|
+
const plugins = await (0, utils_1.getResolvedPlugins)(ctx.pluginPath, configModule);
|
|
249
|
+
(0, utils_1.mergePluginModules)(configModule, plugins);
|
|
250
|
+
container.register({
|
|
251
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: (0, awilix_1.asValue)(logger_1.logger),
|
|
252
|
+
});
|
|
253
|
+
// Create database and init connection
|
|
254
|
+
const dbUtils = (0, database_1.dbTestUtilFactory)();
|
|
255
|
+
ctx.dbUtils = dbUtils;
|
|
256
|
+
await dbUtils.create(ctx.dbConfig.dbName);
|
|
257
|
+
const { initDb, migrateDatabase } = await import("../../acmekit-test-runner-utils/use-db.js");
|
|
258
|
+
dbUtils.pgConnection_ = await initDb();
|
|
259
|
+
// Run migrations (links are synced by the framework during HttpStage boot)
|
|
260
|
+
const migrator = new Migrator({ container });
|
|
261
|
+
await migrator.ensureMigrationsTable();
|
|
262
|
+
await migrateDatabase(appLoader);
|
|
263
|
+
// Clear module instances from migration phase
|
|
264
|
+
const { clearInstances } = await import("../../acmekit-test-runner-utils/clear-instances.js");
|
|
265
|
+
await clearInstances();
|
|
266
|
+
}
|
|
267
|
+
findModelsDir(basePath) {
|
|
268
|
+
if (fs.existsSync(`${basePath}/dist/models`))
|
|
269
|
+
return "/dist/models";
|
|
270
|
+
if (fs.existsSync(`${basePath}/models`))
|
|
271
|
+
return "/models";
|
|
272
|
+
return "";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.DatabaseStage = DatabaseStage;
|
|
276
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/pipeline/stages/database.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDASiC;AACjC,sDAAmD;AACnD,sDAAkD;AAClD,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,CAAC,QAAQ,CAAC;YACjB,CAAC,iCAAyB,CAAC,MAAM,CAAC,EAAE,IAAA,gBAAO,EAAC,eAAM,CAAC;SACpD,CAAC,CAAA;QAEF,sCAAsC;QACtC,MAAM,OAAO,GAAG,IAAA,4BAAiB,GAAE,CAAA;QACnC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAA;QACrB,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAEzC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAC9C,2CAA2C,CAC5C,CAAA;QACD,OAAO,CAAC,aAAa,GAAG,MAAM,MAAM,EAAE,CAAA;QAEtC,2EAA2E;QAC3E,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;QAC5C,MAAM,QAAQ,CAAC,qBAAqB,EAAE,CAAA;QACtC,MAAM,eAAe,CAAC,SAAS,CAAC,CAAA;QAEhC,8CAA8C;QAC9C,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CACrC,oDAAoD,CACrD,CAAA;QACD,MAAM,cAAc,EAAE,CAAA;IACxB,CAAC;IAEO,aAAa,CAAC,QAAgB;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,cAAc,CAAC;YAAE,OAAO,cAAc,CAAA;QACnE,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,SAAS,CAAC;YAAE,OAAO,SAAS,CAAA;QACzD,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAtQD,sCAsQC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BootstrapStage, PipelineContext } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* HttpStage — starts Express server and creates axios API client.
|
|
4
|
+
*
|
|
5
|
+
* App mode: startApp() with project's acmekit-config.ts.
|
|
6
|
+
* Plugin HTTP mode: uses syntheticConfig built by DatabaseStage,
|
|
7
|
+
* passes it to startApp() which calls loaders() — routes, auth,
|
|
8
|
+
* middleware all load naturally.
|
|
9
|
+
*/
|
|
10
|
+
export declare class HttpStage implements BootstrapStage {
|
|
11
|
+
name: string;
|
|
12
|
+
private expressShutdown;
|
|
13
|
+
private cancelTokenSource;
|
|
14
|
+
setup(ctx: PipelineContext): Promise<void>;
|
|
15
|
+
reset(_ctx: PipelineContext): Promise<void>;
|
|
16
|
+
destroy(ctx: PipelineContext): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/pipeline/stages/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1D;;;;;;;GAOG;AACH,qBAAa,SAAU,YAAW,cAAc;IAC9C,IAAI,SAAc;IAElB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,iBAAiB,CAAY;IAE/B,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B1C,KAAK,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3C,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBnD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpStage = void 0;
|
|
4
|
+
const bootstrap_app_1 = require("../../acmekit-test-runner-utils/bootstrap-app");
|
|
5
|
+
/**
|
|
6
|
+
* HttpStage — starts Express server and creates axios API client.
|
|
7
|
+
*
|
|
8
|
+
* App mode: startApp() with project's acmekit-config.ts.
|
|
9
|
+
* Plugin HTTP mode: uses syntheticConfig built by DatabaseStage,
|
|
10
|
+
* passes it to startApp() which calls loaders() — routes, auth,
|
|
11
|
+
* middleware all load naturally.
|
|
12
|
+
*/
|
|
13
|
+
class HttpStage {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.name = "HttpStage";
|
|
16
|
+
this.expressShutdown = null;
|
|
17
|
+
this.cancelTokenSource = null;
|
|
18
|
+
}
|
|
19
|
+
async setup(ctx) {
|
|
20
|
+
const { shutdown, container: appContainer, port, } = await (0, bootstrap_app_1.startApp)({
|
|
21
|
+
cwd: ctx.mode === "plugin" ? ctx.pluginPath : ctx.cwd,
|
|
22
|
+
env: ctx.env,
|
|
23
|
+
// Plugin HTTP: DatabaseStage built syntheticConfig and loaded it
|
|
24
|
+
// into configManager. Pass it here to bypass file-based config loading.
|
|
25
|
+
syntheticConfig: ctx.syntheticConfig ?? undefined,
|
|
26
|
+
// Plugin dirs are not AcmeKit projects — prevents the root dir from being
|
|
27
|
+
// added as a second "project-plugin" which causes duplicate subscribers.
|
|
28
|
+
isAcmeKitProject: ctx.mode !== "plugin",
|
|
29
|
+
});
|
|
30
|
+
ctx.container = appContainer;
|
|
31
|
+
ctx.expressPort = port;
|
|
32
|
+
this.expressShutdown = shutdown;
|
|
33
|
+
// Create axios instance
|
|
34
|
+
const { default: axios } = (await import("axios"));
|
|
35
|
+
this.cancelTokenSource = axios.CancelToken.source();
|
|
36
|
+
ctx.apiUtils = axios.create({
|
|
37
|
+
baseURL: `http://localhost:${port}`,
|
|
38
|
+
cancelToken: this.cancelTokenSource.token,
|
|
39
|
+
});
|
|
40
|
+
ctx.apiUtils.cancelToken = { source: this.cancelTokenSource };
|
|
41
|
+
}
|
|
42
|
+
async reset(_ctx) {
|
|
43
|
+
// HTTP server stays running between tests.
|
|
44
|
+
// DB truncation handles state reset.
|
|
45
|
+
}
|
|
46
|
+
async destroy(ctx) {
|
|
47
|
+
try {
|
|
48
|
+
if (this.cancelTokenSource) {
|
|
49
|
+
this.cancelTokenSource.cancel("Test cleanup");
|
|
50
|
+
}
|
|
51
|
+
if (this.expressShutdown) {
|
|
52
|
+
await this.expressShutdown();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Ignore shutdown errors
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
ctx.apiUtils = null;
|
|
60
|
+
ctx.expressPort = null;
|
|
61
|
+
this.expressShutdown = null;
|
|
62
|
+
this.cancelTokenSource = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.HttpStage = HttpStage;
|
|
67
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/pipeline/stages/http.ts"],"names":[],"mappings":";;;AAAA,iFAAwE;AAGxE;;;;;;;GAOG;AACH,MAAa,SAAS;IAAtB;QACE,SAAI,GAAG,WAAW,CAAA;QAEV,oBAAe,GAAiC,IAAI,CAAA;QACpD,sBAAiB,GAAQ,IAAI,CAAA;IAuDvC,CAAC;IArDC,KAAK,CAAC,KAAK,CAAC,GAAoB;QAC9B,MAAM,EACJ,QAAQ,EACR,SAAS,EAAE,YAAY,EACvB,IAAI,GACL,GAAG,MAAM,IAAA,wBAAQ,EAAC;YACjB,GAAG,EAAE,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG;YACrD,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,iEAAiE;YACjE,wEAAwE;YACxE,eAAe,EAAE,GAAG,CAAC,eAAe,IAAI,SAAS;YACjD,0EAA0E;YAC1E,yEAAyE;YACzE,gBAAgB,EAAE,GAAG,CAAC,IAAI,KAAK,QAAQ;SACxC,CAAC,CAAA;QAEF,GAAG,CAAC,SAAS,GAAG,YAAY,CAAA;QAC5B,GAAG,CAAC,WAAW,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAA;QAE/B,wBA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5
|
+
* Skipped when http: true in app mode (HttpStage handles module init
|
|
6
|
+
* via loaders()). Plugin non-http mode uses this for initModules.
|
|
7
|
+
*
|
|
8
|
+
* For plugin/module mode, reset() does a full shutdown + re-init cycle
|
|
9
|
+
* to match the existing runner behavior. This ensures modules get a
|
|
10
|
+
* clean state between tests.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ModuleStage implements BootstrapStage {
|
|
13
|
+
name: string;
|
|
14
|
+
setup(ctx: PipelineContext): Promise<void>;
|
|
15
|
+
reset(ctx: PipelineContext): Promise<void>;
|
|
16
|
+
destroy(ctx: PipelineContext): Promise<void>;
|
|
17
|
+
private initializeModules;
|
|
18
|
+
private shutdownModules;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/pipeline/stages/module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1D;;;;;;;;;GASG;AACH,qBAAa,WAAY,YAAW,cAAc;IAChD,IAAI,SAAgB;IAEd,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC1C,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAoBpC,iBAAiB;YAmBjB,eAAe;CAY9B"}
|