libmodulor 0.19.0 → 0.20.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/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/esm/apps/Helper/src/lib/project.js +6 -6
- package/dist/esm/convention.d.ts +2 -0
- package/dist/esm/convention.js +2 -0
- package/dist/esm/std/ShellCommandExecutor.d.ts +1 -0
- package/dist/esm/std/impl/NodeSpawnShellCommandExecutor.js +6 -0
- package/dist/esm/target/lib/react/UCContainer.js +1 -1
- package/dist/esm/testing/AppTester.d.ts +5 -2
- package/dist/esm/testing/AppTester.js +17 -4
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +132 -115
- package/dist/esm/testing/impl/VitestAppTestSuiteRunner.d.ts +2 -3
- package/dist/esm/testing/impl/VitestAppTestSuiteRunner.js +6 -8
- package/dist/esm/testing/workers/checkers/UCDefChecker.d.ts +2 -0
- package/dist/esm/testing/workers/checkers/UCDefChecker.js +4 -1
- package/package.json +13 -13
- package/pnpm-workspace.yaml +1 -1
- package/tsconfig.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v0.20.0 (2025-07-26)
|
|
4
|
+
|
|
5
|
+
**Added**
|
|
6
|
+
|
|
7
|
+
- Add ability to stream data in `ShellCommandExecutor`
|
|
8
|
+
- Stream output with color when using the `TestApp` command
|
|
9
|
+
- Check app sources before executing the test in `TestApp` : this allows to spot errors earlier and avoid cryptic exec errors when the sources are not valid (don't forget to re-generate the tests with `pnpm libmodulor GenerateAppsTests` and use `--updateSnapshots` the next time you call `TestApp --appName YourApp`)
|
|
10
|
+
|
|
11
|
+
**Misc**
|
|
12
|
+
|
|
13
|
+
- Add the `Toolbox` app to `examples` (for docs)
|
|
14
|
+
- Expose `UC_POLICY_FILE_NAME_EXT` and `UC_POLICY_FILE_NAME_SUFFIX` in the convention
|
|
15
|
+
- Move `examples/embedded` to `examples/standalone`
|
|
16
|
+
- Add the `GeocodeAddress` UCD to `Toolbox` (for docs)
|
|
17
|
+
- Add the `MyRunningMap` app to `examples` (for docs)
|
|
18
|
+
- Harmonize `examples` apps testing
|
|
19
|
+
|
|
3
20
|
## v0.19.0 (2025-06-20)
|
|
4
21
|
|
|
5
22
|
**BREAKING**
|
package/README.md
CHANGED
|
@@ -81,21 +81,21 @@ export const PACKAGE_JSON = (name) => `{
|
|
|
81
81
|
"test": "tsc && vitest run --passWithNoTests"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"inversify": "^7.
|
|
84
|
+
"inversify": "^7.6.1",
|
|
85
85
|
"libmodulor": "latest",
|
|
86
86
|
"reflect-metadata": "^0.2.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@biomejs/biome": "^2.
|
|
90
|
-
"@types/node": "^22.
|
|
89
|
+
"@biomejs/biome": "^2.1.2",
|
|
90
|
+
"@types/node": "^22.16.5",
|
|
91
91
|
"@vitest/coverage-v8": "^3.2.4",
|
|
92
92
|
"buffer": "^6.0.3",
|
|
93
93
|
"cookie-parser": "^1.4.7",
|
|
94
94
|
"express": "^5.1.0",
|
|
95
|
-
"express-fileupload": "^1.5.
|
|
96
|
-
"fast-check": "^4.
|
|
95
|
+
"express-fileupload": "^1.5.2",
|
|
96
|
+
"fast-check": "^4.2.0",
|
|
97
97
|
"helmet": "^8.1.0",
|
|
98
|
-
"jose": "^6.0.
|
|
98
|
+
"jose": "^6.0.12",
|
|
99
99
|
"typescript": "^5.8.3",
|
|
100
100
|
"vite": "^6.3.5",
|
|
101
101
|
"vitest": "^3.2.4"
|
package/dist/esm/convention.d.ts
CHANGED
|
@@ -44,3 +44,5 @@ export declare const UC_OPI_BASE: string;
|
|
|
44
44
|
export declare const UC_OPI_SUFFIX: string;
|
|
45
45
|
export declare const UC_POLICY_SUFFIX: string;
|
|
46
46
|
export declare const UC_POLICY_SUFFIX_FULL: string;
|
|
47
|
+
export declare const UC_POLICY_FILE_NAME_EXT: string;
|
|
48
|
+
export declare const UC_POLICY_FILE_NAME_SUFFIX: string;
|
package/dist/esm/convention.js
CHANGED
|
@@ -54,3 +54,5 @@ export const UC_OPI_BASE = 'UCOPIBase';
|
|
|
54
54
|
export const UC_OPI_SUFFIX = 'OPI';
|
|
55
55
|
export const UC_POLICY_SUFFIX = 'Policy';
|
|
56
56
|
export const UC_POLICY_SUFFIX_FULL = `UC${UC_POLICY_SUFFIX}`;
|
|
57
|
+
export const UC_POLICY_FILE_NAME_EXT = '.ts';
|
|
58
|
+
export const UC_POLICY_FILE_NAME_SUFFIX = `${UC_POLICY_SUFFIX_FULL}${UC_POLICY_FILE_NAME_EXT}`;
|
|
@@ -17,9 +17,15 @@ let NodeSpawnShellCommandExecutor = class NodeSpawnShellCommandExecutor {
|
|
|
17
17
|
});
|
|
18
18
|
proc.stderr.on('data', (chunk) => {
|
|
19
19
|
stderr += chunk;
|
|
20
|
+
if (opts?.streamData) {
|
|
21
|
+
process.stderr.write(chunk);
|
|
22
|
+
}
|
|
20
23
|
});
|
|
21
24
|
proc.stdout.on('data', (chunk) => {
|
|
22
25
|
stdout += chunk;
|
|
26
|
+
if (opts?.streamData) {
|
|
27
|
+
process.stdout.write(chunk);
|
|
28
|
+
}
|
|
23
29
|
});
|
|
24
30
|
proc.on('error', (err) => {
|
|
25
31
|
reject(err);
|
|
@@ -17,7 +17,7 @@ export function UCContainer({ children, uc, }) {
|
|
|
17
17
|
}, [uc, ucExecChecker]);
|
|
18
18
|
if (isAllowed === undefined) {
|
|
19
19
|
// TODO : Add some loader while we check if can do
|
|
20
|
-
return
|
|
20
|
+
return null;
|
|
21
21
|
}
|
|
22
22
|
if (isAllowed === false) {
|
|
23
23
|
return null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FilePath } from '../dt/index.js';
|
|
2
2
|
import type { ServerClientManagerSettings } from '../target/lib/client/ServerClientManager.js';
|
|
3
3
|
import type { ServerManager } from '../target/lib/server/ServerManager.js';
|
|
4
|
-
import { type UCAuth, UCBuilder, type UCDef, type UCInput, type UCOPIBase } from '../uc/index.js';
|
|
4
|
+
import { type UCAuth, UCBuilder, type UCDef, type UCInput, type UCName, type UCOPIBase } from '../uc/index.js';
|
|
5
5
|
import type { SrcImporter } from '../utils/index.js';
|
|
6
6
|
import type { AppTesterConfigurator } from './AppTesterConfigurator.js';
|
|
7
7
|
import type { AppTesterCtx, AppTesterUCDRef } from './ctx.js';
|
|
@@ -50,6 +50,7 @@ export declare class AppTester {
|
|
|
50
50
|
* This can happen in case of circular dependencies for example.
|
|
51
51
|
*/
|
|
52
52
|
private safeSrcImporter;
|
|
53
|
+
private ucds;
|
|
53
54
|
private testResults;
|
|
54
55
|
private testSummary;
|
|
55
56
|
private ucDefSourcesCheckerOutput;
|
|
@@ -59,13 +60,15 @@ export declare class AppTester {
|
|
|
59
60
|
checkAppIndex(): Promise<void>;
|
|
60
61
|
checkAppManifest(): Promise<void>;
|
|
61
62
|
checkUCDSources(): Promise<void>;
|
|
62
|
-
checkUC(ucdRef: AppTesterUCDRef): Promise<
|
|
63
|
+
checkUC(ucdRef: AppTesterUCDRef): Promise<void>;
|
|
63
64
|
execFlow(flow: AppTesterFlow): Promise<AppTesterFlowExecOutput>;
|
|
64
65
|
execMonkeyTest<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(ucd: UCDef<I, OPI0, OPI1>, input: I): Promise<UCExecutorExecOutput<I, OPI0, OPI1>>;
|
|
65
66
|
execUC<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(input: Omit<UCExecutorInput<I, OPI0, OPI1>, 'appManifest'>, flow?: AppTesterFlow): Promise<AppTestSuiteTestResult<I, OPI0, OPI1>>;
|
|
66
67
|
finalize(): Promise<void>;
|
|
67
68
|
getCtx(): AppTesterCtx;
|
|
69
|
+
getUCD<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(ucName: UCName): UCDef<I, OPI0, OPI1>;
|
|
68
70
|
init({ appPath, configurator, serverClientSettings, srcImporter, }: AppTesterInitArgs): Promise<void>;
|
|
71
|
+
initForUCExec(): Promise<void>;
|
|
69
72
|
ucTestData(ucdRef: AppTesterUCDRef): Promise<AppTesterUCTestData[]>;
|
|
70
73
|
private bindI18n;
|
|
71
74
|
private bindServerClientSettings;
|
|
@@ -29,6 +29,7 @@ import { AppManifestChecker } from './workers/checkers/AppManifestChecker.js';
|
|
|
29
29
|
import { UCDefChecker } from './workers/checkers/UCDefChecker.js';
|
|
30
30
|
import { UCDefSourcesChecker, } from './workers/checkers/UCDefSourcesChecker.js';
|
|
31
31
|
import { UCExecutor, } from './workers/UCExecutor.js';
|
|
32
|
+
const ERR_UCD_NOT_FOUND = (ucName) => `Could not find a ucd for ${ucName}`;
|
|
32
33
|
let AppTester = class AppTester {
|
|
33
34
|
appDocsEmitter;
|
|
34
35
|
appFolderChecker;
|
|
@@ -50,6 +51,8 @@ let AppTester = class AppTester {
|
|
|
50
51
|
*/
|
|
51
52
|
safeSrcImporter;
|
|
52
53
|
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
54
|
+
ucds;
|
|
55
|
+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
53
56
|
testResults;
|
|
54
57
|
testSummary;
|
|
55
58
|
ucDefSourcesCheckerOutput;
|
|
@@ -66,6 +69,7 @@ let AppTester = class AppTester {
|
|
|
66
69
|
this.ucDefChecker = ucDefChecker;
|
|
67
70
|
this.ucDefSourcesChecker = ucDefSourcesChecker;
|
|
68
71
|
this.ucExecutor = ucExecutor;
|
|
72
|
+
this.ucds = new Map();
|
|
69
73
|
this.testResults = [];
|
|
70
74
|
this.testSummary = {
|
|
71
75
|
counts: {
|
|
@@ -115,13 +119,13 @@ let AppTester = class AppTester {
|
|
|
115
119
|
});
|
|
116
120
|
}
|
|
117
121
|
async checkUC(ucdRef) {
|
|
118
|
-
const { errors } = await this.ucDefChecker.exec({ ucdRef });
|
|
122
|
+
const { errors, ucd } = await this.ucDefChecker.exec({ ucdRef });
|
|
119
123
|
if (errors.length > 0) {
|
|
120
124
|
throw new Error(errors[0]);
|
|
121
125
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
if (ucd) {
|
|
127
|
+
this.ucds.set(ucdRef.name, ucd);
|
|
128
|
+
}
|
|
125
129
|
}
|
|
126
130
|
async execFlow(flow) {
|
|
127
131
|
const output = [];
|
|
@@ -226,6 +230,13 @@ let AppTester = class AppTester {
|
|
|
226
230
|
getCtx() {
|
|
227
231
|
return this.ctx;
|
|
228
232
|
}
|
|
233
|
+
getUCD(ucName) {
|
|
234
|
+
const ucd = this.ucds.get(ucName);
|
|
235
|
+
if (!ucd) {
|
|
236
|
+
throw new Error(ERR_UCD_NOT_FOUND(ucName));
|
|
237
|
+
}
|
|
238
|
+
return ucd;
|
|
239
|
+
}
|
|
229
240
|
async init({ appPath, configurator, serverClientSettings, srcImporter, }) {
|
|
230
241
|
this.configurator = configurator;
|
|
231
242
|
this.safeSrcImporter = (path) => Promise.race([
|
|
@@ -243,6 +254,8 @@ let AppTester = class AppTester {
|
|
|
243
254
|
await this.configurator.seed(this.ctx);
|
|
244
255
|
await this.bindI18n();
|
|
245
256
|
await this.bindServerClientSettings(serverClientSettings);
|
|
257
|
+
}
|
|
258
|
+
async initForUCExec() {
|
|
246
259
|
await this.initI18n();
|
|
247
260
|
await this.initServer();
|
|
248
261
|
}
|
|
@@ -52,14 +52,14 @@ const template = (serverPortRangeStart, idx, monkeyTestingTimeoutInMs) => `/*
|
|
|
52
52
|
import { join } from 'node:path';
|
|
53
53
|
|
|
54
54
|
import {
|
|
55
|
-
assert,
|
|
56
55
|
type Arbitrary,
|
|
57
56
|
type AsyncCommand,
|
|
58
|
-
type ModelRunSetup,
|
|
59
57
|
anything,
|
|
58
|
+
assert,
|
|
60
59
|
asyncModelRun,
|
|
61
60
|
asyncProperty,
|
|
62
61
|
commands,
|
|
62
|
+
type ModelRunSetup,
|
|
63
63
|
record,
|
|
64
64
|
} from 'fast-check';
|
|
65
65
|
import {
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
type UCInput,
|
|
71
71
|
} from 'libmodulor';
|
|
72
72
|
import { newNodeAppTester } from 'libmodulor/node-test';
|
|
73
|
-
import { afterAll, afterEach, describe, expect, test } from 'vitest';
|
|
73
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
|
|
74
74
|
|
|
75
75
|
import { Configurator } from './Configurator.js';
|
|
76
76
|
|
|
@@ -84,116 +84,92 @@ const runner = await newNodeAppTester(${serverPortRangeStart}, ${idx}, {
|
|
|
84
84
|
const ctx = runner.getCtx();
|
|
85
85
|
const logger = ctx.container.get<Logger>('Logger');
|
|
86
86
|
|
|
87
|
+
const flows = await configurator.flows();
|
|
88
|
+
|
|
87
89
|
afterAll(async () => {
|
|
88
90
|
await runner.finalize();
|
|
89
91
|
});
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
test('Folder should be valid', async () => {
|
|
96
|
-
await runner.checkAppFolder();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('${APP_MANIFEST_NAME} should be valid', async () => {
|
|
100
|
-
await runner.checkAppManifest();
|
|
101
|
-
});
|
|
93
|
+
describe('Check', () => {
|
|
94
|
+
test('Sources should be valid', async () => {
|
|
95
|
+
await runner.checkUCDSources();
|
|
96
|
+
});
|
|
102
97
|
|
|
103
|
-
test('
|
|
104
|
-
|
|
105
|
-
});
|
|
98
|
+
test('Folder should be valid', async () => {
|
|
99
|
+
await runner.checkAppFolder();
|
|
100
|
+
});
|
|
106
101
|
|
|
107
|
-
test('${
|
|
108
|
-
|
|
109
|
-
});
|
|
102
|
+
test('${APP_MANIFEST_NAME} should be valid', async () => {
|
|
103
|
+
await runner.checkAppManifest();
|
|
104
|
+
});
|
|
110
105
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
afterEach(async () => {
|
|
114
|
-
await configurator.clearExecution(ctx);
|
|
106
|
+
test('${APP_I18N_NAME} should be valid', async () => {
|
|
107
|
+
await runner.checkAppI18n();
|
|
115
108
|
});
|
|
116
109
|
|
|
117
|
-
test
|
|
118
|
-
|
|
110
|
+
test('${APP_INDEX_NAME} should be valid', async () => {
|
|
111
|
+
await runner.checkAppIndex();
|
|
112
|
+
});
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
}
|
|
114
|
+
describe.runIf(ctx.ucdRefs.length > 0)('Use Cases', () => {
|
|
115
|
+
describe.each(ctx.ucdRefs)('$name', async (ucdRef) => {
|
|
116
|
+
test('should be valid', async () => {
|
|
117
|
+
await runner.checkUC(ucdRef);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
128
120
|
});
|
|
129
121
|
});
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
describe('Run', async () => {
|
|
124
|
+
beforeAll(async () => {
|
|
125
|
+
await runner.initForUCExec();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe.runIf(flows.length > 0)('Flows', async () => {
|
|
134
129
|
afterEach(async () => {
|
|
135
130
|
await configurator.clearExecution(ctx);
|
|
136
131
|
});
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
test('should be valid', async () => {
|
|
142
|
-
ucd = await runner.checkUC(ucdRef);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const data = await runner.ucTestData(ucdRef);
|
|
146
|
-
|
|
147
|
-
test.each(data)(
|
|
148
|
-
'should execute with auth $authName and input $inputFillerName',
|
|
149
|
-
async ({ auth, authName, inputFiller, inputFillerName }) => {
|
|
150
|
-
const { out, sideEffects } = await runner.execUC({
|
|
151
|
-
auth,
|
|
152
|
-
authName: authName as UCAuthSetterName,
|
|
153
|
-
inputFiller,
|
|
154
|
-
inputFillerName,
|
|
155
|
-
ucd,
|
|
156
|
-
});
|
|
133
|
+
test.each(flows)('should execute flow $name', async (flow) => {
|
|
134
|
+
const output = await runner.execFlow(flow);
|
|
157
135
|
|
|
136
|
+
for (const out of output) {
|
|
158
137
|
if (out.err !== null) {
|
|
159
138
|
if (!(out.err instanceof CustomError)) {
|
|
160
139
|
logger.error(out.err);
|
|
161
140
|
}
|
|
162
141
|
expect(out.err).toBeInstanceOf(CustomError);
|
|
163
142
|
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
164
146
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
\`hash = \${hash\}\`,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
test('should execute with monkey testing', async () => {
|
|
180
|
-
// Given
|
|
181
|
-
// biome-ignore lint/complexity/noBannedTypes: nothing for now
|
|
182
|
-
type Model = {};
|
|
183
|
-
// biome-ignore lint/complexity/noBannedTypes: nothing for now
|
|
184
|
-
type RealSystem = {};
|
|
185
|
-
|
|
186
|
-
class MyCommand<I extends UCInput | undefined = undefined>
|
|
187
|
-
implements AsyncCommand<Model, RealSystem>
|
|
188
|
-
{
|
|
189
|
-
constructor(private input: I) {}
|
|
190
|
-
|
|
191
|
-
public check(_m: Readonly<Model>): boolean {
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
147
|
+
describe.runIf(ctx.ucdRefs.length > 0)('Use Cases', () => {
|
|
148
|
+
describe.each(ctx.ucdRefs)('$name', async (ucdRef) => {
|
|
149
|
+
afterEach(async () => {
|
|
150
|
+
await configurator.clearExecution(ctx);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
154
|
+
let ucd: UCDef<any, any, any>;
|
|
194
155
|
|
|
195
|
-
|
|
196
|
-
|
|
156
|
+
beforeAll(() => {
|
|
157
|
+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
158
|
+
ucd = runner.getUCD<any, any, any>(ucdRef.name);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const data = await runner.ucTestData(ucdRef);
|
|
162
|
+
|
|
163
|
+
test.each(data)(
|
|
164
|
+
'should execute with auth $authName and input $inputFillerName',
|
|
165
|
+
async ({ auth, authName, inputFiller, inputFillerName }) => {
|
|
166
|
+
const { out, sideEffects } = await runner.execUC({
|
|
167
|
+
auth,
|
|
168
|
+
authName: authName as UCAuthSetterName,
|
|
169
|
+
inputFiller,
|
|
170
|
+
inputFillerName,
|
|
171
|
+
ucd,
|
|
172
|
+
});
|
|
197
173
|
|
|
198
174
|
if (out.err !== null) {
|
|
199
175
|
if (!(out.err instanceof CustomError)) {
|
|
@@ -201,41 +177,82 @@ describe.runIf(ucdRefs.length > 0)('Use Cases', () => {
|
|
|
201
177
|
}
|
|
202
178
|
expect(out.err).toBeInstanceOf(CustomError);
|
|
203
179
|
}
|
|
204
|
-
}
|
|
205
180
|
|
|
206
|
-
|
|
207
|
-
|
|
181
|
+
const { hash } = out;
|
|
182
|
+
const assertion = hash
|
|
183
|
+
? (await configurator.specificAssertions())?.get(hash)
|
|
184
|
+
: undefined;
|
|
185
|
+
if (assertion) {
|
|
186
|
+
expect(out).toSatisfy(assertion);
|
|
187
|
+
} else {
|
|
188
|
+
expect({ out, sideEffects }).toMatchSnapshot(
|
|
189
|
+
\`hash = \${hash\}\`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
test('should execute with monkey testing', async () => {
|
|
196
|
+
// Given
|
|
197
|
+
// biome-ignore lint/complexity/noBannedTypes: nothing for now
|
|
198
|
+
type Model = {};
|
|
199
|
+
// biome-ignore lint/complexity/noBannedTypes: nothing for now
|
|
200
|
+
type RealSystem = {};
|
|
201
|
+
|
|
202
|
+
class MyCommand<I extends UCInput | undefined = undefined>
|
|
203
|
+
implements AsyncCommand<Model, RealSystem>
|
|
204
|
+
{
|
|
205
|
+
constructor(private input: I) {}
|
|
206
|
+
|
|
207
|
+
public check(_m: Readonly<Model>): boolean {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public async run(_m: Model, _r: RealSystem): Promise<void> {
|
|
212
|
+
const out = await runner.execMonkeyTest(ucd, this.input);
|
|
213
|
+
|
|
214
|
+
if (out.err !== null) {
|
|
215
|
+
if (!(out.err instanceof CustomError)) {
|
|
216
|
+
logger.error(out.err);
|
|
217
|
+
}
|
|
218
|
+
expect(out.err).toBeInstanceOf(CustomError);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public toString(): string {
|
|
223
|
+
return \`\${ucd.metadata.name\}(\${JSON.stringify(this.input)\})\`;
|
|
224
|
+
}
|
|
208
225
|
}
|
|
209
|
-
}
|
|
210
226
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
const inputFields = ucd.io.i?.fields;
|
|
228
|
+
if (!inputFields || Object.keys(inputFields).length > 0) {
|
|
229
|
+
// Mainly to prevent monkey testing from running indefinitely
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
233
|
+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
234
|
+
const inputLike: Record<string, Arbitrary<any>> = {};
|
|
235
|
+
for (const k of Object.keys(inputFields)) {
|
|
236
|
+
inputLike[k] = anything();
|
|
237
|
+
}
|
|
238
|
+
const cmdArbs = record(inputLike, { requiredKeys: [] }).map(
|
|
239
|
+
(r) => new MyCommand(r),
|
|
240
|
+
);
|
|
225
241
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
242
|
+
const modelRunSetup: ModelRunSetup<Model, RealSystem> = () => ({
|
|
243
|
+
model: {},
|
|
244
|
+
real: {},
|
|
245
|
+
});
|
|
230
246
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
247
|
+
// When
|
|
248
|
+
const property = asyncProperty(commands([cmdArbs]), (cmds) =>
|
|
249
|
+
asyncModelRun(modelRunSetup, cmds),
|
|
250
|
+
);
|
|
235
251
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
252
|
+
// Then
|
|
253
|
+
await assert(property);
|
|
254
|
+
}, ${monkeyTestingTimeoutInMs});
|
|
255
|
+
});
|
|
239
256
|
});
|
|
240
257
|
});
|
|
241
258
|
`;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { FilePath } from '../../dt/index.js';
|
|
2
|
-
import type { FSManager,
|
|
2
|
+
import type { FSManager, ShellCommandExecutor } from '../../std/index.js';
|
|
3
3
|
import type { AppTestSuiteRunner, Input } from '../workers/AppTestSuiteRunner.js';
|
|
4
4
|
export declare class VitestAppTestSuiteRunner implements AppTestSuiteRunner {
|
|
5
5
|
private fsManager;
|
|
6
|
-
private logger;
|
|
7
6
|
private shellCommandExecutor;
|
|
8
|
-
constructor(fsManager: FSManager,
|
|
7
|
+
constructor(fsManager: FSManager, shellCommandExecutor: ShellCommandExecutor);
|
|
9
8
|
exec({ appPath, skipCoverage, updateSnapshots, }: Input): Promise<void>;
|
|
10
9
|
coverageReportEntrypointPath(appPath: FilePath): Promise<FilePath>;
|
|
11
10
|
private coverageReportPath;
|
|
@@ -14,17 +14,16 @@ import { inject, injectable } from 'inversify';
|
|
|
14
14
|
import { APP_TEST_DIR_NAME, APP_TEST_REPORTS_DIR_NAME, } from '../../convention.js';
|
|
15
15
|
let VitestAppTestSuiteRunner = class VitestAppTestSuiteRunner {
|
|
16
16
|
fsManager;
|
|
17
|
-
logger;
|
|
18
17
|
shellCommandExecutor;
|
|
19
|
-
constructor(fsManager,
|
|
18
|
+
constructor(fsManager, shellCommandExecutor) {
|
|
20
19
|
this.fsManager = fsManager;
|
|
21
|
-
this.logger = logger;
|
|
22
20
|
this.shellCommandExecutor = shellCommandExecutor;
|
|
23
21
|
}
|
|
24
22
|
async exec({ appPath, skipCoverage, updateSnapshots, }) {
|
|
25
23
|
const testPath = this.fsManager.path(appPath, APP_TEST_DIR_NAME);
|
|
26
24
|
const args = [
|
|
27
25
|
'run',
|
|
26
|
+
'--color',
|
|
28
27
|
'--dir',
|
|
29
28
|
appPath,
|
|
30
29
|
];
|
|
@@ -34,13 +33,13 @@ let VitestAppTestSuiteRunner = class VitestAppTestSuiteRunner {
|
|
|
34
33
|
if (updateSnapshots) {
|
|
35
34
|
args.push('--update');
|
|
36
35
|
}
|
|
37
|
-
|
|
36
|
+
await this.shellCommandExecutor.exec({
|
|
38
37
|
bin: './node_modules/.bin/vitest',
|
|
39
38
|
opts: {
|
|
40
39
|
args,
|
|
40
|
+
streamData: true,
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
|
-
this.logger.info(output);
|
|
44
43
|
}
|
|
45
44
|
async coverageReportEntrypointPath(appPath) {
|
|
46
45
|
return this.fsManager.path(this.coverageReportPath(appPath), 'index.html');
|
|
@@ -53,8 +52,7 @@ let VitestAppTestSuiteRunner = class VitestAppTestSuiteRunner {
|
|
|
53
52
|
VitestAppTestSuiteRunner = __decorate([
|
|
54
53
|
injectable(),
|
|
55
54
|
__param(0, inject('FSManager')),
|
|
56
|
-
__param(1, inject('
|
|
57
|
-
|
|
58
|
-
__metadata("design:paramtypes", [Object, Object, Object])
|
|
55
|
+
__param(1, inject('ShellCommandExecutor')),
|
|
56
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
59
57
|
], VitestAppTestSuiteRunner);
|
|
60
58
|
export { VitestAppTestSuiteRunner };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ErrorMessage } from '../../../dt/index.js';
|
|
2
2
|
import type { Worker } from '../../../std/index.js';
|
|
3
|
+
import type { UCDef } from '../../../uc/index.js';
|
|
3
4
|
import type { AppTesterUCDRef } from '../../ctx.js';
|
|
4
5
|
export interface Input {
|
|
5
6
|
ucdRef: AppTesterUCDRef;
|
|
6
7
|
}
|
|
7
8
|
export interface Output {
|
|
8
9
|
errors: ErrorMessage[];
|
|
10
|
+
ucd: UCDef | null;
|
|
9
11
|
}
|
|
10
12
|
export declare class UCDefChecker implements Worker<Input, Promise<Output>> {
|
|
11
13
|
private output;
|
|
@@ -15,7 +15,7 @@ const ERR_UCD_NAMES = (fileName, name, ucdKey) => `The file name and the const n
|
|
|
15
15
|
let UCDefChecker = class UCDefChecker {
|
|
16
16
|
output;
|
|
17
17
|
constructor() {
|
|
18
|
-
this.output = { errors: [] };
|
|
18
|
+
this.output = { errors: [], ucd: null };
|
|
19
19
|
}
|
|
20
20
|
async exec({ ucdRef }) {
|
|
21
21
|
const { fileName, source } = ucdRef;
|
|
@@ -35,6 +35,9 @@ let UCDefChecker = class UCDefChecker {
|
|
|
35
35
|
name !== ucdKey.replaceAll(UC_DEF_SUFFIX, '')) {
|
|
36
36
|
this.output.errors.push(ERR_UCD_NAMES(fileName, name, ucdKey));
|
|
37
37
|
}
|
|
38
|
+
if (this.output.errors.length === 0) {
|
|
39
|
+
this.output.ucd = ucd;
|
|
40
|
+
}
|
|
38
41
|
return this.output;
|
|
39
42
|
}
|
|
40
43
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libmodulor",
|
|
3
3
|
"description": "A TypeScript library to create platform-agnostic applications",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"license": "LGPL-3.0",
|
|
6
6
|
"author": "Chafik H'nini <chafik.hnini@gmail.com>",
|
|
7
7
|
"homepage": "https://libmodulor.c100k.eu",
|
|
@@ -81,27 +81,27 @@
|
|
|
81
81
|
"lint:ci": "biome check"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@biomejs/biome": "^2.
|
|
84
|
+
"@biomejs/biome": "^2.1.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@hono/node-server": "^1.
|
|
88
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
89
|
-
"@stricli/core": "^1.
|
|
87
|
+
"@hono/node-server": "^1.17.1",
|
|
88
|
+
"@modelcontextprotocol/sdk": "^1.16.0",
|
|
89
|
+
"@stricli/core": "^1.2.0",
|
|
90
90
|
"buffer": "^6.0.3",
|
|
91
91
|
"cookie-parser": "^1.4.7",
|
|
92
92
|
"express": "^5.1.0",
|
|
93
|
-
"express-fileupload": "^1.5.
|
|
94
|
-
"fast-check": "^4.
|
|
93
|
+
"express-fileupload": "^1.5.2",
|
|
94
|
+
"fast-check": "^4.2.0",
|
|
95
95
|
"helmet": "^8.1.0",
|
|
96
|
-
"hono": "^4.8.
|
|
97
|
-
"inversify": "^7.
|
|
98
|
-
"jose": "^6.0.
|
|
96
|
+
"hono": "^4.8.5",
|
|
97
|
+
"inversify": "^7.6.1",
|
|
98
|
+
"jose": "^6.0.12",
|
|
99
99
|
"knex": "^3.1.0",
|
|
100
|
-
"next": "^15.
|
|
101
|
-
"pg": "^8.16.
|
|
100
|
+
"next": "^15.4.2",
|
|
101
|
+
"pg": "^8.16.3",
|
|
102
102
|
"react": "^19.1.0",
|
|
103
103
|
"react-dom": "^19.1.0",
|
|
104
|
-
"react-native": "^0.79.
|
|
104
|
+
"react-native": "^0.79.5",
|
|
105
105
|
"reflect-metadata": "^0.2.2",
|
|
106
106
|
"sqlite3": "^5.1.7",
|
|
107
107
|
"typescript": "^5.8.3",
|
package/pnpm-workspace.yaml
CHANGED