@equinor/fusion-framework-cli-plugin-mock-server 0.1.0-next.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -0
  4. package/dist/esm/__tests__/create-mock-server-command.test.js +95 -0
  5. package/dist/esm/__tests__/create-mock-server-command.test.js.map +1 -0
  6. package/dist/esm/__tests__/index.test.js +66 -0
  7. package/dist/esm/__tests__/index.test.js.map +1 -0
  8. package/dist/esm/create-mock-server-command.js +77 -0
  9. package/dist/esm/create-mock-server-command.js.map +1 -0
  10. package/dist/esm/dev-server-options.js +2 -0
  11. package/dist/esm/dev-server-options.js.map +1 -0
  12. package/dist/esm/index.js +24 -0
  13. package/dist/esm/index.js.map +1 -0
  14. package/dist/esm/load-mock-server-config.js +45 -0
  15. package/dist/esm/load-mock-server-config.js.map +1 -0
  16. package/dist/esm/version.js +3 -0
  17. package/dist/esm/version.js.map +1 -0
  18. package/dist/tsconfig.tsbuildinfo +1 -0
  19. package/dist/types/__tests__/create-mock-server-command.test.d.ts +1 -0
  20. package/dist/types/__tests__/index.test.d.ts +1 -0
  21. package/dist/types/create-mock-server-command.d.ts +48 -0
  22. package/dist/types/dev-server-options.d.ts +23 -0
  23. package/dist/types/index.d.ts +22 -0
  24. package/dist/types/load-mock-server-config.d.ts +13 -0
  25. package/dist/types/version.d.ts +1 -0
  26. package/package.json +54 -0
  27. package/src/__tests__/create-mock-server-command.test.ts +113 -0
  28. package/src/__tests__/index.test.ts +88 -0
  29. package/src/create-mock-server-command.ts +126 -0
  30. package/src/dev-server-options.ts +26 -0
  31. package/src/index.ts +36 -0
  32. package/src/load-mock-server-config.ts +75 -0
  33. package/src/version.ts +2 -0
  34. package/tsconfig.json +26 -0
  35. package/vitest.config.ts +9 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ # @equinor/fusion-framework-cli-plugin-mock-server
2
+
3
+ ## 0.1.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 09a9bcc: Add a CLI plugin for running the standalone OpenAPI mock server through `ffc mock-server`.
8
+
9
+ The command layers bundled presets and local executable mock modules, reads `mockServer` defaults
10
+ from `dev-server.config.ts`, and accepts command-line host, port, and seed overrides. The standalone
11
+ server resolves only predefined and local mocks; it never fetches remote service discovery.
12
+
13
+ Installing the plugin augments `DevServerOptions` with typed `mockServer` settings for the module
14
+ directory, host, port, and deterministic seed without coupling the base dev-server package to the
15
+ optional plugin.
16
+
17
+ ```ts
18
+ // fusion-cli.config.ts
19
+ import { defineFusionCli } from '@equinor/fusion-framework-cli';
20
+ import mockServerPlugin from '@equinor/fusion-framework-cli-plugin-mock-server';
21
+
22
+ export default defineFusionCli(() => ({
23
+ plugins: [mockServerPlugin()],
24
+ }));
25
+ ```
26
+
27
+ ```sh
28
+ ffc mock-server ./mocks --port 4010
29
+ ```
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [09a9bcc]
34
+ - Updated dependencies [09a9bcc]
35
+ - Updated dependencies [09a9bcc]
36
+ - @equinor/fusion-framework-dev-server@2.1.0-next.2
37
+ - @equinor/fusion-openapi-mock-server@0.1.0-next.1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Equinor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @equinor/fusion-framework-cli-plugin-mock-server
2
+
3
+ Optional Fusion Framework CLI plugin for running local OpenAPI-backed services with
4
+ `ffc mock-server`. Use it when development or browser tests need deterministic APIs, an
5
+ unavailable backend, or a service that has not entered Fusion service discovery yet.
6
+
7
+ > [!IMPORTANT]
8
+ > The command runs a standalone foreground HTTP server. It never fetches remote service discovery
9
+ > and never starts automatically with `ffc app dev`.
10
+
11
+ ## Quick start
12
+
13
+ Install the plugin:
14
+
15
+ ```sh
16
+ pnpm add -D @equinor/fusion-framework-cli-plugin-mock-server
17
+ ```
18
+
19
+ Create one executable module per service:
20
+
21
+ ```text
22
+ mocks/
23
+ inventory.mock.ts
24
+ inventory.openapi.json
25
+ ```
26
+
27
+ ```typescript
28
+ import schema from './inventory.openapi.json' with { type: 'json' };
29
+ import { defineService } from '@equinor/fusion-openapi-mock-server/discovery';
30
+
31
+ export default defineService({
32
+ key: 'inventory',
33
+ serviceDiscovery: 'new',
34
+ schema,
35
+ components: {
36
+ InventoryItem: { name: () => 'Local item' },
37
+ },
38
+ });
39
+ ```
40
+
41
+ This file is the service mock. Do not duplicate the service in `dev-server.config.ts` with
42
+ `api.routes` or `api.processServices`; those low-level hooks are not required for the normal mock
43
+ workflow.
44
+
45
+ `'new'` models a pre-production service and rejects collisions if the key becomes registered. See
46
+ [Choose a discovery mode](../../dev-server/docs/mocking.md#choose-a-discovery-mode) for existing
47
+ services, pre-production services, and direct-only app endpoints.
48
+
49
+ Start the server manually:
50
+
51
+ ```sh
52
+ ffc mock-server
53
+ ```
54
+
55
+ Installing the package makes the command available through the Fusion CLI. If the plugin is not
56
+ installed, `ffc mock-server` prints an installation hint. Explicit `mockServerPlugin()`
57
+ registration remains useful when `fusion-cli.config.ts` supplies command defaults.
58
+
59
+ ## Connect an application
60
+
61
+ Keep the mock server running, then choose one app-development mode in another terminal:
62
+
63
+ ```sh
64
+ # Keep real discovery and overlay selected local definitions
65
+ ffc app dev
66
+
67
+ # Use only bundled presets and local mock definitions
68
+ ffc app dev --mock http://localhost:4010
69
+ ```
70
+
71
+ The standalone server uses only configured presets and local modules. `--mock` therefore gives an
72
+ isolated environment with no remote discovery dependency.
73
+
74
+ > [!WARNING]
75
+ > `ffc app dev --mock` does not fall back to real service discovery. Include every service the app
76
+ > needs through a preset or local mock module.
77
+
78
+ See [Develop with mock services](../../dev-server/docs/mocking.md) for discovery modes,
79
+ direct-only endpoints, and the difference between normal and isolated development.
80
+
81
+ ## Configure defaults
82
+
83
+ The plugin augments `DevServerOptions` with a typed `mockServer` section. Import its types in
84
+ `dev-server.config.ts` so TypeScript loads the augmentation:
85
+
86
+ ```typescript
87
+ import type {} from '@equinor/fusion-framework-cli-plugin-mock-server';
88
+ import { defineDevServerConfig } from '@equinor/fusion-framework-cli';
89
+
90
+ export default defineDevServerConfig(() => ({
91
+ mockServer: {
92
+ path: 'mocks',
93
+ host: 'localhost',
94
+ port: 4010,
95
+ seed: 42,
96
+ },
97
+ }));
98
+ ```
99
+
100
+ Command-line arguments override config defaults. `path` is relative to the project root.
101
+
102
+ > [!TIP]
103
+ > Put shared team defaults in `dev-server.config.ts`; reserve command-line flags for temporary
104
+ > local or CI overrides.
105
+
106
+ Register the plugin explicitly when command defaults belong in `fusion-cli.config.ts`:
107
+
108
+ ```typescript
109
+ import { defineFusionCli } from '@equinor/fusion-framework-cli';
110
+ import mockServerPlugin from '@equinor/fusion-framework-cli-plugin-mock-server';
111
+
112
+ export default defineFusionCli(() => ({
113
+ plugins: [mockServerPlugin({ preset: ['fusion'], port: 4010 })],
114
+ }));
115
+ ```
116
+
117
+ ## Command reference
118
+
119
+ ```text
120
+ ffc mock-server [dirs...] [options]
121
+ ```
122
+
123
+ | Argument or option | Behavior |
124
+ | --- | --- |
125
+ | `[dirs...]` | Directories of `<name>.mock.ts` modules in ascending precedence. Later definitions are resolved by service key and discovery mode. |
126
+ | `--preset <name>` | Bundled preset layered before local directories. Repeatable; defaults to `fusion`. The first explicit flag replaces the default. |
127
+ | `--port <port>` | Listening port. Uses config, then plugin defaults, then `4010`. |
128
+ | `--host <host>` | Bind hostname. Uses config, then plugin defaults, then `localhost`. |
129
+ | `--seed <seed>` | Deterministic seed for generated OpenAPI responses. Without a seed, generated values are random. |
130
+
131
+ The process shuts down on `SIGINT` and `SIGTERM`. Let Playwright `webServer`, `concurrently`, or a
132
+ developer terminal own it instead of starting an unowned background process.
133
+
134
+ ## Related documentation
135
+
136
+ - [OpenAPI mock-server getting started](../../utils/openapi-mock-server/docs/getting-started.md)
137
+ - [Testing with Playwright](../../utils/openapi-mock-server/docs/testing-with-playwright.md)
138
+ - [Mock API and Playwright cookbook](../../../cookbooks/app-react-mock-playwright/README.md)
139
+
140
+ ## License
141
+
142
+ ISC
@@ -0,0 +1,95 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ const mocks = vi.hoisted(() => ({
3
+ close: vi.fn().mockResolvedValue(undefined),
4
+ createMockServer: vi.fn(),
5
+ discoverServices: vi.fn(),
6
+ loadMockServerConfig: vi.fn(),
7
+ start: vi.fn(),
8
+ use: vi.fn(),
9
+ }));
10
+ vi.mock('@equinor/fusion-openapi-mock-server', () => ({
11
+ createMockServer: mocks.createMockServer,
12
+ }));
13
+ vi.mock('@equinor/fusion-openapi-mock-server/discovery', () => ({
14
+ discoverServices: mocks.discoverServices,
15
+ }));
16
+ vi.mock('../load-mock-server-config.js', () => ({
17
+ loadMockServerConfig: mocks.loadMockServerConfig,
18
+ }));
19
+ import { createMockServerCommand } from '../create-mock-server-command.js';
20
+ describe('createMockServerCommand', () => {
21
+ beforeEach(() => {
22
+ vi.clearAllMocks();
23
+ vi.spyOn(process, 'on').mockReturnValue(process);
24
+ mocks.createMockServer.mockReturnValue({
25
+ close: mocks.close,
26
+ start: mocks.start,
27
+ use: mocks.use,
28
+ });
29
+ mocks.discoverServices.mockResolvedValue([]);
30
+ mocks.start.mockResolvedValue({ url: 'http://localhost:4010' });
31
+ });
32
+ afterEach(() => {
33
+ vi.restoreAllMocks();
34
+ });
35
+ it('uses project config before plugin defaults', async () => {
36
+ mocks.loadMockServerConfig.mockResolvedValue({
37
+ path: 'config-mocks',
38
+ port: 4010,
39
+ host: '127.0.0.1',
40
+ seed: 42,
41
+ });
42
+ const command = createMockServerCommand({
43
+ path: 'plugin-mocks',
44
+ port: 4020,
45
+ host: 'localhost',
46
+ seed: 7,
47
+ });
48
+ await command.parseAsync(['node', 'test']);
49
+ expect(mocks.discoverServices).toHaveBeenCalledWith('config-mocks');
50
+ expect(mocks.createMockServer).toHaveBeenCalledWith({ seed: 42 });
51
+ expect(mocks.start).toHaveBeenCalledWith({ port: 4010, host: '127.0.0.1' });
52
+ });
53
+ it('uses explicit arguments and flags before project config', async () => {
54
+ mocks.loadMockServerConfig.mockResolvedValue({
55
+ path: 'config-mocks',
56
+ port: 4010,
57
+ host: '127.0.0.1',
58
+ seed: 42,
59
+ });
60
+ const command = createMockServerCommand();
61
+ await command.parseAsync([
62
+ 'node',
63
+ 'test',
64
+ 'cli-mocks',
65
+ '--port=5000',
66
+ '--host=0.0.0.0',
67
+ '--seed=99',
68
+ ]);
69
+ expect(mocks.discoverServices).toHaveBeenCalledWith('cli-mocks');
70
+ expect(mocks.createMockServer).toHaveBeenCalledWith({ seed: 99 });
71
+ expect(mocks.start).toHaveBeenCalledWith({ port: 5000, host: '0.0.0.0' });
72
+ });
73
+ it('uses plugin defaults before built-in conventions', async () => {
74
+ mocks.loadMockServerConfig.mockResolvedValue({});
75
+ const command = createMockServerCommand({
76
+ path: 'plugin-mocks',
77
+ port: 4020,
78
+ host: '127.0.0.1',
79
+ seed: 7,
80
+ });
81
+ await command.parseAsync(['node', 'test']);
82
+ expect(mocks.discoverServices).toHaveBeenCalledWith('plugin-mocks');
83
+ expect(mocks.createMockServer).toHaveBeenCalledWith({ seed: 7 });
84
+ expect(mocks.start).toHaveBeenCalledWith({ port: 4020, host: '127.0.0.1' });
85
+ });
86
+ it('uses built-in conventions when no other values are provided', async () => {
87
+ mocks.loadMockServerConfig.mockResolvedValue({});
88
+ const command = createMockServerCommand();
89
+ await command.parseAsync(['node', 'test']);
90
+ expect(mocks.discoverServices).toHaveBeenCalledWith('mocks');
91
+ expect(mocks.createMockServer).toHaveBeenCalledWith({ seed: undefined });
92
+ expect(mocks.start).toHaveBeenCalledWith({ port: 4010, host: 'localhost' });
93
+ });
94
+ });
95
+ //# sourceMappingURL=create-mock-server-command.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mock-server-command.test.js","sourceRoot":"","sources":["../../../src/__tests__/create-mock-server-command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9B,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;IAC3C,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;IACzB,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;IACzB,oBAAoB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC7B,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;CACb,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,qCAAqC,EAAE,GAA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AAC,KAAK,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { Command } from 'commander';
2
+ import { describe, expect, it } from 'vitest';
3
+ import mockServerPlugin from '../index.js';
4
+ describe('mockServerPlugin', () => {
5
+ it('augments DevServerOptions with mock-server configuration', () => {
6
+ const config = {
7
+ api: { serviceDiscoveryUrl: 'https://discovery.example.com' },
8
+ mockServer: { path: 'api-mocks', port: 4010, seed: 42 },
9
+ };
10
+ expect(config.mockServer).toEqual({ path: 'api-mocks', port: 4010, seed: 42 });
11
+ });
12
+ it('registers a top-level "mock-server" command', () => {
13
+ const program = new Command();
14
+ mockServerPlugin()(program);
15
+ // every registered command's name, to check "mock-server" is among them
16
+ expect(program.commands.map((command) => command.name())).toContain('mock-server');
17
+ });
18
+ it('applies every --preset before any positional directory', () => {
19
+ const program = new Command();
20
+ mockServerPlugin()(program);
21
+ // locate the command this plugin registered, by name
22
+ const mockServerCommand = program.commands.find((command) => command.name() === 'mock-server');
23
+ // parse() invokes the command's action; capture what it would pass to createMockServer via the parsed options
24
+ const parsed = mockServerCommand?.parseOptions([
25
+ '--preset=fusion',
26
+ '--preset=extra',
27
+ './mocks',
28
+ './overrides',
29
+ ]);
30
+ expect(parsed?.operands).toEqual(['./mocks', './overrides']);
31
+ expect(mockServerCommand?.opts().preset).toEqual(['fusion', 'extra']);
32
+ });
33
+ it('defaults to the "fusion" preset when --preset is omitted', () => {
34
+ const program = new Command();
35
+ mockServerPlugin()(program);
36
+ // locate the command this plugin registered, by name
37
+ const mockServerCommand = program.commands.find((command) => command.name() === 'mock-server');
38
+ mockServerCommand?.parseOptions(['./mocks']);
39
+ expect(mockServerCommand?.opts().preset).toEqual(['fusion']);
40
+ });
41
+ it('replaces the default preset instead of appending to it, on the first explicit --preset', () => {
42
+ const program = new Command();
43
+ mockServerPlugin()(program);
44
+ // locate the command this plugin registered, by name
45
+ const mockServerCommand = program.commands.find((command) => command.name() === 'mock-server');
46
+ mockServerCommand?.parseOptions(['--preset=other', './mocks']);
47
+ expect(mockServerCommand?.opts().preset).toEqual(['other']);
48
+ });
49
+ it('applies caller-provided preset defaults during option parsing', () => {
50
+ const program = new Command();
51
+ mockServerPlugin({ preset: ['other'], port: 4010, host: '0.0.0.0' })(program);
52
+ // locate the command this plugin registered, by name
53
+ const mockServerCommand = program.commands.find((command) => command.name() === 'mock-server');
54
+ mockServerCommand?.parseOptions([]);
55
+ expect(mockServerCommand?.opts()).toEqual({ preset: ['other'] });
56
+ });
57
+ it('lets an explicit flag override a caller-provided default', () => {
58
+ const program = new Command();
59
+ mockServerPlugin({ preset: ['other'], port: 4010 })(program);
60
+ // locate the command this plugin registered, by name
61
+ const mockServerCommand = program.commands.find((command) => command.name() === 'mock-server');
62
+ mockServerCommand?.parseOptions(['--port=5000']);
63
+ expect(mockServerCommand?.opts().port).toBe(5000);
64
+ });
65
+ });
66
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAI9C,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAE3C,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,MAAM,GAAqB;YAC/B,GAAG,EAAE,EAAE,mBAAmB,EAAE,+BAA+B,EAAE;YAC7D,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;SACxD,CAAC;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AM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,aAAa,CAAC,CAAC;QAE/F,iBAAiB,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;QAEpC,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7D,qDAAqD;QACrD,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,aAAa,CAAC,CAAC;QAE/F,iBAAiB,EAAE,YAAY,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { createCommand, createOption } from 'commander';
2
+ import { createMockServer } from '@equinor/fusion-openapi-mock-server';
3
+ import { discoverServices } from '@equinor/fusion-openapi-mock-server/discovery';
4
+ import { loadMockServerConfig } from './load-mock-server-config.js';
5
+ /**
6
+ * Builds the `ffc mock-server` command definition.
7
+ *
8
+ * Serves every service discovered from one or more directories of `<name>.mock.ts`
9
+ * modules (plus any bundled presets) over HTTP, using
10
+ * `@equinor/fusion-openapi-mock-server`'s `createMockServer`. Presets and
11
+ * directories are both layered in ascending precedence — a later `--preset`
12
+ * or directory replaces an earlier one's services by key — with every
13
+ * `--preset` applied before every positional directory, regardless of their
14
+ * order on the command line.
15
+ *
16
+ * Defaults to the bundled `fusion` preset when `--preset` isn't given at
17
+ * all — a Fusion app's default framework modules resolve several
18
+ * service-discovery keys eagerly at startup and fail hard without them. The
19
+ * first explicit `--preset` fully replaces that default rather than
20
+ * appending to it; repeat the flag (`--preset=fusion --preset=other`) to
21
+ * combine it with something else. Pass {@link defaults} to change any of
22
+ * these built-in defaults (e.g. a fixed port for a specific app).
23
+ *
24
+ * Keeps the server running in the foreground until `SIGINT`/`SIGTERM`, so it
25
+ * dies with whatever started it (e.g. Playwright's `webServer`) rather than
26
+ * lingering as an orphaned process.
27
+ *
28
+ * @param defaults - Overrides for the command's own built-in path, preset, port, host, and seed defaults.
29
+ * @returns A fresh `Command` instance — a factory rather than a shared singleton, since
30
+ * Commander stores parsed option values on the `Command` instance itself.
31
+ *
32
+ * @example
33
+ * ```sh
34
+ * ffc mock-server ./mocks --port 4010
35
+ * ```
36
+ */
37
+ export function createMockServerCommand(defaults = {}) {
38
+ // sentinel default for --preset, so the first explicit flag replaces it instead of appending to it
39
+ const defaultPresets = defaults.preset ?? ['fusion'];
40
+ return createCommand('mock-server')
41
+ .description('Serve OpenAPI-fake responses over HTTP, from bundled presets and/or mock modules')
42
+ .argument('[dirs...]', 'directories of <name>.mock.ts modules, in ascending precedence')
43
+ .addOption(createOption('--preset <name>', `bundled preset to layer in, in ascending precedence (repeatable; defaults to ${JSON.stringify(defaultPresets)}, replaced by the first explicit flag)`)
44
+ .default(defaultPresets)
45
+ .argParser((value, previous) => previous === defaultPresets ? [value] : [...previous, value]))
46
+ .addOption(createOption('--port <port>', `port to listen on (default: config or ${defaults.port ?? 4010})`).argParser(Number))
47
+ .addOption(createOption('--host <host>', 'hostname to bind to (default: config or localhost)'))
48
+ .addOption(createOption('--seed <seed>', `seeds every service's faked responses, for reproducible output (default: ${defaults.seed ?? 'unseeded/random'})`).argParser(Number))
49
+ .action(async (dirs, options) => {
50
+ const config = await loadMockServerConfig(process.cwd());
51
+ const sourceDirs = dirs.length ? dirs : [config.path ?? defaults.path ?? 'mocks'];
52
+ const definitionGroups = await Promise.all(sourceDirs
53
+ // Resolve every configured layer before startup so discovery requirements are known.
54
+ .map((dir) => discoverServices(dir)));
55
+ const server = createMockServer({
56
+ seed: options.seed ?? config.seed ?? defaults.seed,
57
+ });
58
+ // presets always apply before directories, regardless of flag position on the command line
59
+ for (const preset of options.preset)
60
+ server.use(preset);
61
+ // Resolved directory groups are the highest-precedence layers, applied after every preset.
62
+ for (const definitions of definitionGroups)
63
+ server.use(definitions);
64
+ const { url } = await server.start({
65
+ port: options.port ?? config.port ?? defaults.port ?? 4010,
66
+ host: options.host ?? config.host ?? defaults.host ?? 'localhost',
67
+ });
68
+ console.log(`mock server listening at ${url}`);
69
+ const shutdown = () => {
70
+ void server.close().finally(() => process.exit(0));
71
+ };
72
+ process.on('SIGINT', shutdown);
73
+ process.on('SIGTERM', shutdown);
74
+ });
75
+ }
76
+ export default createMockServerCommand;
77
+ //# sourceMappingURL=create-mock-server-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mock-server-command.js","sourceRoot":"","sources":["../../src/create-mock-server-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AA4BpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAQ,GAA8B,EAAE;IAC9E,mGAAmG;IACnG,MAAM,cAAc,GAAa,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,C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,MAAM,MAAM,GAAG,gBAAgB,CAAC;YAC9B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI;SACnD,CAAC,CAAC;QACH,2FAA2F;QAC3F,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxD,2FAA2F;QAC3F,KAAK,MAAM,WAAW,IAAI,gBAAgB;YAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEpE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;YACjC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI;YAC1D,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,IAAI,WAAW;SAClE,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,GAAS,EAAE;YAC1B,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dev-server-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-server-options.js","sourceRoot":"","sources":["../../src/dev-server-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { createMockServerCommand, } from './create-mock-server-command.js';
2
+ /**
3
+ * Creates the `ffc mock-server` CLI plugin, for a `fusion-cli.config.ts`'s `plugins` array.
4
+ *
5
+ * @param defaults - Overrides for the command's own built-in `--preset`/`--port`/`--host` defaults.
6
+ * @returns A plugin function that registers the `mock-server` command on the CLI program.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { defineFusionCli } from '@equinor/fusion-framework-cli';
11
+ * import mockServerPlugin from '@equinor/fusion-framework-cli-plugin-mock-server';
12
+ *
13
+ * export default defineFusionCli(() => ({
14
+ * plugins: [mockServerPlugin({ preset: ['fusion'], port: 4010 })],
15
+ * }));
16
+ * ```
17
+ */
18
+ export function mockServerPlugin(defaults) {
19
+ return (program) => {
20
+ program.addCommand(createMockServerCommand(defaults));
21
+ };
22
+ }
23
+ export default mockServerPlugin;
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,GAExB,MAAM,iCAAiC,CAAC;AAQzC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAoC;IACnE,OAAO,CAAC,OAAgB,EAAQ,EAAE;QAChC,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { FileNotFoundError, importConfig } from '@equinor/fusion-imports';
2
+ /**
3
+ * Loads standalone mock-server settings from a project's `dev-server.config.ts`.
4
+ *
5
+ * @param root - Project root used to resolve the config file and relative mock path.
6
+ * @returns Mock-server settings explicitly resolved from the project config.
7
+ * @throws {Error} When an existing config cannot be imported or returns an invalid value.
8
+ */
9
+ export async function loadMockServerConfig(root) {
10
+ const base = {
11
+ mockServer: { path: 'mocks' },
12
+ api: { serviceDiscoveryUrl: '' },
13
+ };
14
+ try {
15
+ const { config } = await importConfig('dev-server.config', {
16
+ baseDir: root,
17
+ script: {
18
+ // Config factories receive the same runtime shape as ordinary development serving.
19
+ resolve: async (module) => {
20
+ const exported = module.default;
21
+ // Factory configs may derive settings from the supplied base configuration.
22
+ if (typeof exported === 'function') {
23
+ return ((await exported({ command: 'serve', environment: 'local', mode: 'development', root }, { base })) ?? {});
24
+ }
25
+ return exported ?? {};
26
+ },
27
+ },
28
+ });
29
+ return {
30
+ path: config.mockServer?.path ?? base.mockServer?.path,
31
+ port: config.mockServer?.port,
32
+ host: config.mockServer?.host,
33
+ seed: config.mockServer?.seed,
34
+ };
35
+ }
36
+ catch (error) {
37
+ // An absent config is a supported convention-only setup; import and evaluation failures are not.
38
+ if (error instanceof FileNotFoundError) {
39
+ return {};
40
+ }
41
+ throw error;
42
+ }
43
+ }
44
+ export default loadMockServerConfig;
45
+ //# sourceMappingURL=load-mock-server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-mock-server-config.js","sourceRoot":"","sources":["../../src/load-mock-server-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAkB,MAAM,yBAAyB,CAAC;AAsB1F;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAY;IACrD,MAAM,IAAI,GAAqB;QAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC7B,GAAG,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE;KACjC,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,YAAY,CACnC,mBAAmB,EACnB;YACE,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,mFAAmF;gBACnF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;oBACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;oBAChC,4EAA4E;oBAC5E,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;wBACnC,OAAO,CACL,CAAC,MAAM,QAAQ,CACb,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EACrE,EAAE,IAAI,EAAE,CACT,CAAC,IAAI,EAAE,CACT,CAAC;oBACJ,CAAC;oBACD,OAAO,QAAQ,IAAI,EAAE,CAAC;gBACxB,CAAC;aACF;SACF,CACF,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI;YACtD,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI;YAC7B,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI;YAC7B,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI;SAC9B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iGAAiG;QACjG,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Generated by genversion.
2
+ export const version = '0.1.0-next.1';
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC"}