@equinor/fusion-framework-cli 15.2.11 → 15.3.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 +44 -0
- package/README.md +9 -0
- package/bin/build/bin.mjs +1 -1
- package/bin/build/cli.mjs +3 -3
- package/dist/esm/lib/utils/assert-object.js +2 -1
- package/dist/esm/lib/utils/assert-object.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/bin/serve-application.d.ts +4 -0
- package/dist/types/bin/start-app-dev-server.d.ts +6 -1
- package/dist/types/bin/utils/__tests__/fixtures/dev-mocks/foo.mock.d.ts +6 -0
- package/dist/types/bin/utils/__tests__/fixtures/dev-mocks/service.mock.d.ts +6 -0
- package/dist/types/bin/utils/apply-dev-server-mocks.d.ts +12 -0
- package/dist/types/bin/utils/apply-dev-server-mocks.test.d.ts +1 -0
- package/dist/types/bin/utils/create-dev-server-config.d.ts +3 -1
- package/dist/types/bin/utils/create-dev-server-config.test.d.ts +1 -0
- package/dist/types/bin/utils/discover-dev-server-mocks.d.ts +20 -0
- package/dist/types/bin/utils/discover-dev-server-mocks.test.d.ts +1 -0
- package/dist/types/bin/utils/normalize-dev-server-config.d.ts +2 -0
- package/dist/types/cli/commands/app/dev.command.d.ts +4 -1
- package/dist/types/cli/commands/app/dev.command.test.d.ts +1 -0
- package/dist/types/cli/commands/app/serve.command.d.ts +1 -0
- package/dist/types/cli/commands/index.d.ts +5 -3
- package/dist/types/cli/commands/portal/dev.command.d.ts +1 -1
- package/dist/types/cli/commands/register-optional-mock-server-command.d.ts +13 -0
- package/dist/types/cli/commands/register-optional-mock-server-command.test.d.ts +1 -0
- package/dist/types/cli/plugins/is-module-not-found-error.d.ts +8 -0
- package/dist/types/cli/plugins/is-module-not-found-error.test.d.ts +1 -0
- package/dist/types/cli/plugins/resolve-optional-plugin.d.ts +14 -0
- package/dist/types/cli/plugins/resolve-optional-plugin.test.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/docs/application.md +17 -1
- package/docs/dev-server-config.md +132 -112
- package/docs/dev-server.md +39 -50
- package/package.json +14 -15
package/docs/dev-server.md
CHANGED
|
@@ -12,7 +12,7 @@ The Fusion Framework dev-server is your complete local development solution for
|
|
|
12
12
|
|
|
13
13
|
🛠️ **Flexible Configuration** - Easy setup for both applications and portals with environment-specific overrides
|
|
14
14
|
|
|
15
|
-
📝 **
|
|
15
|
+
📝 **Executable Service Mocks** - Reusable `mocks/<service>.mock.ts` modules for local development and browser tests
|
|
16
16
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
@@ -30,11 +30,17 @@ The dev-server automatically detects your project type, loads configuration file
|
|
|
30
30
|
|
|
31
31
|
For detailed information about configuring the dev-server, see [Dev Server Configuration](dev-server-config.md).
|
|
32
32
|
|
|
33
|
-
The dev
|
|
33
|
+
The dev server automatically discovers executable `mocks/<service>.mock.ts` modules. Define service
|
|
34
|
+
behavior there with `defineService`, run `ffc mock-server` in a foreground terminal, and use
|
|
35
|
+
`ffc app dev` for real discovery plus local overrides or `ffc app dev --mock` for an isolated mock
|
|
36
|
+
environment. See [Develop with mock services](../../dev-server/docs/mocking.md).
|
|
37
|
+
|
|
38
|
+
Use `dev-server.config.ts` for SPA environment values, logging, discovery endpoints, and shared
|
|
39
|
+
mock-server defaults. It is not the recommended place to handwrite service routes.
|
|
34
40
|
|
|
35
41
|
## Key Features
|
|
36
42
|
|
|
37
|
-
- **Service Discovery Integration** -
|
|
43
|
+
- **Service Discovery Integration** - Connects to real discovery and overlays visible executable mock modules by service key
|
|
38
44
|
- **Template Generation** - Dynamic HTML template generation with environment variable injection
|
|
39
45
|
- **API Proxying** - Seamless API integration with request/response transformation capabilities
|
|
40
46
|
- **Portal Support** - Full portal development with manifest loading and configuration management
|
|
@@ -92,7 +98,7 @@ flowchart TD
|
|
|
92
98
|
- **Role**: API service discovery and request handling
|
|
93
99
|
- **Responsibilities**:
|
|
94
100
|
- Proxies requests to Fusion service discovery endpoints
|
|
95
|
-
-
|
|
101
|
+
- Proxies discovered services and advanced server-owned development routes
|
|
96
102
|
- Manages dynamic route mapping for discovered services
|
|
97
103
|
- Provides request/response transformation capabilities
|
|
98
104
|
|
|
@@ -156,7 +162,9 @@ This workflow ensures that developers have immediate access to a fully functiona
|
|
|
156
162
|
|
|
157
163
|
## Service Discovery
|
|
158
164
|
|
|
159
|
-
The API plugin (`@equinor/fusion-framework-vite-plugin-api-service`)
|
|
165
|
+
The API plugin (`@equinor/fusion-framework-vite-plugin-api-service`) proxies discovered services
|
|
166
|
+
through the local origin. During normal app development, the CLI overlays discovery-visible
|
|
167
|
+
`mocks/<service>.mock.ts` definitions by key before the API plugin creates those proxy routes.
|
|
160
168
|
|
|
161
169
|
### Service Discovery Sequence
|
|
162
170
|
|
|
@@ -180,59 +188,40 @@ sequenceDiagram
|
|
|
180
188
|
2. **Plugin Interception**: The API plugin intercepts this request before it reaches the external service
|
|
181
189
|
3. **Proxy to Fusion**: The plugin forwards the request to the actual Fusion service discovery endpoint
|
|
182
190
|
4. **Response Interception**: When the response returns, the plugin intercepts it before sending it back to the user
|
|
183
|
-
5. **Service
|
|
184
|
-
|
|
185
|
-
- Altering service endpoints for testing
|
|
186
|
-
- Injecting additional metadata or configuration
|
|
187
|
-
- Modifying service capabilities or scopes
|
|
188
|
-
6. **Enhanced Response**: The user receives an enriched list of services that may include both real and mock services
|
|
189
|
-
|
|
190
|
-
## Mocking
|
|
191
|
+
5. **Service Processing**: The plugin rewrites service URIs to local proxy routes.
|
|
192
|
+
6. **Response**: The browser receives the processed service list and calls back through the dev server.
|
|
191
193
|
|
|
192
|
-
|
|
194
|
+
## Mocking services
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
sequenceDiagram
|
|
196
|
-
participant DevServer as Dev Server
|
|
197
|
-
participant Middleware as Middleware
|
|
198
|
-
participant MockData as Mock Data
|
|
199
|
-
participant Browser
|
|
196
|
+
Application mocks are executable service modules, not dev-server middleware declarations:
|
|
200
197
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
Middleware->>Middleware: Process request
|
|
206
|
-
Middleware->>MockData: Fetch mock data
|
|
207
|
-
MockData->>Middleware: Return mock response
|
|
208
|
-
Middleware->>DevServer: Return processed response
|
|
209
|
-
DevServer->>Browser: Return mock data
|
|
198
|
+
```text
|
|
199
|
+
mocks/
|
|
200
|
+
inventory.mock.ts
|
|
201
|
+
inventory.openapi.json
|
|
210
202
|
```
|
|
211
203
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
4. **Data Resolution**: The middleware fetches appropriate data (mock or real) based on the request and configuration
|
|
216
|
-
5. **Response Processing**: The middleware processes and transforms the response before returning it
|
|
217
|
-
6. **Response Delivery**: The processed response is returned to the browser through the dev-server
|
|
204
|
+
`defineService` keeps the service key, discovery intent, OpenAPI schema, deterministic component
|
|
205
|
+
values, operation routes, and request-aware middleware together. The same module works in local
|
|
206
|
+
development and browser tests.
|
|
218
207
|
|
|
219
|
-
|
|
208
|
+
```mermaid
|
|
209
|
+
flowchart LR
|
|
210
|
+
A["mocks/inventory.mock.ts"] --> B["ffc mock-server"]
|
|
211
|
+
B --> C["inventory.localhost:4010"]
|
|
212
|
+
B --> D["/@fusion-mock/discovery"]
|
|
213
|
+
E["ffc app dev"] --> F["real discovery + visible local modules"]
|
|
214
|
+
G["ffc app dev --mock"] --> H["preset + local modules only"]
|
|
215
|
+
F --> C
|
|
216
|
+
H --> C
|
|
217
|
+
```
|
|
220
218
|
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
The mock server is a standalone foreground process and never fetches remote discovery. Plain
|
|
220
|
+
`ffc app dev` still uses real discovery and overlays visible local definitions. `ffc app dev
|
|
221
|
+
--mock` points discovery at the standalone server and is intentionally isolated.
|
|
223
222
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
middleware: (req, res, next) => {
|
|
227
|
-
// Return mock data for users endpoint
|
|
228
|
-
res.setHeader('Content-Type', 'application/json');
|
|
229
|
-
res.end(JSON.stringify([
|
|
230
|
-
{ id: 1, name: 'John Doe' },
|
|
231
|
-
{ id: 2, name: 'Jane Smith' }
|
|
232
|
-
]));
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
```
|
|
223
|
+
See [Develop with mock services](../../dev-server/docs/mocking.md) for a copyable module and
|
|
224
|
+
discovery-mode guidance.
|
|
236
225
|
|
|
237
226
|
## Re-Routing requests
|
|
238
227
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Fusion",
|
|
6
6
|
"Fusion Framework",
|
|
@@ -111,11 +111,11 @@
|
|
|
111
111
|
"vite": "^8.0.0",
|
|
112
112
|
"vite-tsconfig-paths": "^6.0.4",
|
|
113
113
|
"zod": "^4.4.3",
|
|
114
|
-
"@equinor/fusion-framework-
|
|
115
|
-
"@equinor/fusion-
|
|
116
|
-
"@equinor/fusion-framework-
|
|
117
|
-
"@equinor/fusion-framework-
|
|
118
|
-
"@equinor/fusion-
|
|
114
|
+
"@equinor/fusion-framework-module-azure-identity": "0.3.0",
|
|
115
|
+
"@equinor/fusion-imports": "2.0.3",
|
|
116
|
+
"@equinor/fusion-framework-vite-plugin-raw-imports": "2.0.2",
|
|
117
|
+
"@equinor/fusion-framework-dev-portal": "11.0.4",
|
|
118
|
+
"@equinor/fusion-framework-dev-server": "2.1.0"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -126,7 +126,6 @@
|
|
|
126
126
|
"@types/adm-zip": "^0.5.0",
|
|
127
127
|
"@types/normalize-package-data": "^2.4.4",
|
|
128
128
|
"@types/semver": "^7.7.1",
|
|
129
|
-
"@vitest/coverage-v8": "^4.0.18",
|
|
130
129
|
"adm-zip": "^0.6.0",
|
|
131
130
|
"ajv": "^8.17.1",
|
|
132
131
|
"is-ci": "^4.1.0",
|
|
@@ -137,12 +136,13 @@
|
|
|
137
136
|
"rxjs": "^7.8.1",
|
|
138
137
|
"type-fest": "^5.0.0",
|
|
139
138
|
"typescript": "^7.0.2",
|
|
140
|
-
"vitest": "^4.1.
|
|
141
|
-
"@equinor/fusion-framework-module": "6.1.
|
|
142
|
-
"@equinor/fusion-framework-
|
|
143
|
-
"@equinor/fusion-framework-module-
|
|
144
|
-
"@equinor/fusion-framework-module-
|
|
145
|
-
"@equinor/fusion-framework-react-router": "2.4.
|
|
139
|
+
"vitest": "^4.1.10",
|
|
140
|
+
"@equinor/fusion-framework-module": "6.1.3",
|
|
141
|
+
"@equinor/fusion-framework-cli-plugin-mock-server": "^0.1.0",
|
|
142
|
+
"@equinor/fusion-framework-module-app": "8.1.0",
|
|
143
|
+
"@equinor/fusion-framework-module-http": "8.1.0",
|
|
144
|
+
"@equinor/fusion-framework-react-router": "2.4.1",
|
|
145
|
+
"@equinor/fusion-framework-module-service-discovery": "10.1.0"
|
|
146
146
|
},
|
|
147
147
|
"peerDependenciesMeta": {
|
|
148
148
|
"typescript": {
|
|
@@ -153,7 +153,6 @@
|
|
|
153
153
|
"prebuild": "tsc -b",
|
|
154
154
|
"build": "rollup -c rollup.config.js",
|
|
155
155
|
"build:clean": "rm -rf dist && rm -rf bin/build && rm -f tsconfig.tsbuildinfo && pnpm build",
|
|
156
|
-
"test": "vitest"
|
|
157
|
-
"test:coverage": "vitest run --coverage"
|
|
156
|
+
"test": "vitest"
|
|
158
157
|
}
|
|
159
158
|
}
|