@equinor/fusion-framework-cli 12.1.3 → 12.2.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 +36 -0
- package/bin/build/bin.mjs +1 -1
- package/bin/build/cli.mjs +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/bin/app-check.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/docs/dev-server-config.md +382 -0
- package/docs/dev-server.md +4 -0
- package/package.json +9 -9
package/dist/esm/version.js
CHANGED
|
@@ -27,5 +27,5 @@ type AppCheckOptions = {
|
|
|
27
27
|
* @returns A promise that resolves when the check is complete.
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
|
-
export declare const checkApp: (options: AppCheckOptions) => Promise<
|
|
30
|
+
export declare const checkApp: (options: AppCheckOptions) => Promise<boolean>;
|
|
31
31
|
export default checkApp;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "12.
|
|
1
|
+
export declare const version = "12.2.0";
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
The dev-server supports optional configuration through a `dev-server.config.ts` file in your project root. This allows you to customize how your application interacts with the Fusion Framework during development.
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> Basic server options like `port`, `host`, and `open` are configured via CLI flags or Vite configuration, not through `dev-server.config.ts`.
|
|
5
|
+
|
|
6
|
+
## Why Configure the Dev Server?
|
|
7
|
+
|
|
8
|
+
The default dev-server configuration works for most applications, but you may want to customize it when:
|
|
9
|
+
|
|
10
|
+
- **Testing API integrations**: Mock services or override API responses during development
|
|
11
|
+
- **Debugging service discovery**: Filter or modify discovered services for testing
|
|
12
|
+
- **Customizing the development environment**: Adjust template variables, CLI logging, or browser console logging
|
|
13
|
+
- **Isolating development scenarios**: Configure different behaviors for different development stages
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
Create a `dev-server.config.ts` file in your project root. Start simple with object configuration:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// Simple object configuration
|
|
21
|
+
export default {
|
|
22
|
+
api: {
|
|
23
|
+
routes: [{
|
|
24
|
+
match: '/my-api/test',
|
|
25
|
+
middleware: (req, res) => res.end('OK')
|
|
26
|
+
}]
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For conditional configuration based on environment or other runtime logic, use function configuration:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { defineDevServerConfig } from '@equinor/fusion-framework-cli';
|
|
35
|
+
|
|
36
|
+
export default defineDevServerConfig(({ base }) => {
|
|
37
|
+
// Access to base config and environment for advanced logic
|
|
38
|
+
const isLocalDev = process.env.USER === 'your-username'; // Example condition
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
api: {
|
|
42
|
+
routes: [
|
|
43
|
+
// Different routes based on conditions
|
|
44
|
+
isLocalDev && { match: '/api/local-dev', middleware: localHandler }
|
|
45
|
+
].filter(Boolean) // Remove falsy values
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> [!TIP]
|
|
52
|
+
> Start with object config. Use function config only when you need conditional logic or access to the base configuration.
|
|
53
|
+
|
|
54
|
+
## TypeScript Integration
|
|
55
|
+
|
|
56
|
+
For full TypeScript support and intellisense, import the configuration types:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { defineDevServerConfig, type DevServerConfig } from '@equinor/fusion-framework-cli';
|
|
60
|
+
|
|
61
|
+
// Fully typed configuration
|
|
62
|
+
export default defineDevServerConfig(({ base }): DevServerConfig => ({
|
|
63
|
+
...base,
|
|
64
|
+
api: {
|
|
65
|
+
...base.api,
|
|
66
|
+
routes: [
|
|
67
|
+
{
|
|
68
|
+
match: '/api/users',
|
|
69
|
+
middleware: (req, res) => {
|
|
70
|
+
// req and res are properly typed
|
|
71
|
+
res.setHeader('Content-Type', 'application/json');
|
|
72
|
+
res.end(JSON.stringify([]));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The configuration object supports full TypeScript intellisense, including:
|
|
81
|
+
- Auto-completion for all configuration options
|
|
82
|
+
- Type checking for middleware functions
|
|
83
|
+
- Proper typing for service discovery responses
|
|
84
|
+
|
|
85
|
+
## Configuration Overview
|
|
86
|
+
|
|
87
|
+
The dev-server configuration supports these main areas:
|
|
88
|
+
|
|
89
|
+
| Area | Purpose | Common Use Cases |
|
|
90
|
+
|------|---------|------------------|
|
|
91
|
+
| `api.routes` | Mock API endpoints | Testing UI without backend, error scenarios |
|
|
92
|
+
| `api.processServices` | Modify service discovery | Add mock services, override endpoints |
|
|
93
|
+
| `api.serviceDiscoveryUrl` | Change discovery endpoint | Custom/dev environments |
|
|
94
|
+
| `spa.templateEnv` | Override Fusion config | Portal settings, MSAL config, telemetry |
|
|
95
|
+
| `log` | Control CLI logging verbosity | Debug dev-server issues, reduce terminal noise |
|
|
96
|
+
|
|
97
|
+
## How Configuration Works
|
|
98
|
+
|
|
99
|
+
The `dev-server.config.ts` file is designed for **overriding** the default dev-server behavior. You only specify what you want to change - the system automatically merges your overrides with the defaults.
|
|
100
|
+
|
|
101
|
+
### Object Configuration (Recommended)
|
|
102
|
+
Just export the properties you want to override:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
export default {
|
|
106
|
+
// Only override what you need to change
|
|
107
|
+
api: {
|
|
108
|
+
routes: [{
|
|
109
|
+
match: '/api/users',
|
|
110
|
+
middleware: (req, res) => res.end(JSON.stringify([]))
|
|
111
|
+
}]
|
|
112
|
+
},
|
|
113
|
+
spa: {
|
|
114
|
+
templateEnv: {
|
|
115
|
+
telemetry: { consoleLevel: 0 } // Only override telemetry
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The dev-server automatically merges this with its default configuration.
|
|
122
|
+
|
|
123
|
+
### Function Configuration (Advanced)
|
|
124
|
+
Use functions when you need conditional logic or access to runtime values:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
export default defineDevServerConfig(({ base }) => {
|
|
128
|
+
// You have access to base config and runtime environment
|
|
129
|
+
return {
|
|
130
|
+
api: {
|
|
131
|
+
routes: [
|
|
132
|
+
// Your routes automatically merge with any existing ones
|
|
133
|
+
{ match: '/api/test', middleware: testHandler }
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Key Point**: You don't need to manually spread/merge anything. Just provide the overrides you want - the merging happens automatically.
|
|
141
|
+
|
|
142
|
+
## Array Merging Behavior
|
|
143
|
+
|
|
144
|
+
The dev-server uses intelligent array merging:
|
|
145
|
+
|
|
146
|
+
- **Routes**: Merged by `match` path - routes with identical paths are replaced (yours wins)
|
|
147
|
+
- **Other arrays**: Deduplicated using `Set` - removes exact duplicates
|
|
148
|
+
- **Services**: In service discovery, arrays are typically replaced rather than merged
|
|
149
|
+
|
|
150
|
+
Example route merging:
|
|
151
|
+
```typescript
|
|
152
|
+
// Base config has:
|
|
153
|
+
routes: [{ match: '/api/users', middleware: baseHandler }]
|
|
154
|
+
|
|
155
|
+
// Your config has:
|
|
156
|
+
routes: [{ match: '/api/users', middleware: yourHandler }]
|
|
157
|
+
|
|
158
|
+
// Result: yourHandler replaces baseHandler for /api/users
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Quick Start Examples
|
|
162
|
+
|
|
163
|
+
### I Need To...
|
|
164
|
+
| I want to... | Configuration | Example |
|
|
165
|
+
|--------------|---------------|---------|
|
|
166
|
+
| Mock an API endpoint | `api.routes` | `routes: [{ match: '/api/users', middleware: (req, res) => res.end('[]') }]` |
|
|
167
|
+
| Add a mock service | `api.processServices` | Add services to the service discovery response |
|
|
168
|
+
| Override MSAL config | `spa.templateEnv.msal` | `msal: { clientId: 'dev-client-id' }` |
|
|
169
|
+
| Change telemetry logging | `spa.templateEnv.telemetry` | `telemetry: { consoleLevel: 0 }` |
|
|
170
|
+
| Reduce CLI noise | `log.level` | `log: { level: 2 }` |
|
|
171
|
+
|
|
172
|
+
## Essential Configurations
|
|
173
|
+
|
|
174
|
+
### API Mocking
|
|
175
|
+
|
|
176
|
+
**When you need it**: Your application depends on backend services that aren't available during development, or you want to test specific API responses without hitting real services.
|
|
177
|
+
|
|
178
|
+
**How it works**: Add custom routes that intercept API calls and return mock data.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
export default defineDevServerConfig(() => ({
|
|
182
|
+
api: {
|
|
183
|
+
routes: [
|
|
184
|
+
{
|
|
185
|
+
match: '/api/users',
|
|
186
|
+
middleware: (req, res) => {
|
|
187
|
+
res.setHeader('Content-Type', 'application/json');
|
|
188
|
+
res.end(JSON.stringify([
|
|
189
|
+
{ id: 1, name: 'John Doe', role: 'developer' },
|
|
190
|
+
{ id: 2, name: 'Jane Smith', role: 'designer' }
|
|
191
|
+
]));
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
// Mock error responses
|
|
195
|
+
{
|
|
196
|
+
match: '/api/users/404',
|
|
197
|
+
middleware: (req, res) => {
|
|
198
|
+
res.statusCode = 404;
|
|
199
|
+
res.end(JSON.stringify({ error: 'User not found' }));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Benefits**: Develop UI components and user flows without backend dependencies. Test error handling scenarios easily.
|
|
208
|
+
|
|
209
|
+
### Service Discovery Customization
|
|
210
|
+
|
|
211
|
+
**When you need it**: You're developing against a service that doesn't exist yet in the remote service discovery, or you want to override service endpoints for local development.
|
|
212
|
+
|
|
213
|
+
**How it works**: Add mock services to the service discovery response that your application can use during development.
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
export default defineDevServerConfig(() => ({
|
|
217
|
+
api: {
|
|
218
|
+
processServices: (dataResponse) => {
|
|
219
|
+
const { data, routes } = dataResponse;
|
|
220
|
+
|
|
221
|
+
// Add mock services for development
|
|
222
|
+
const mockServices = [
|
|
223
|
+
{
|
|
224
|
+
key: 'my-new-service',
|
|
225
|
+
name: 'My New Service (Mock)',
|
|
226
|
+
uri: '/api/mock-service' // This will be proxied by the dev server
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: 'beta-feature-api',
|
|
230
|
+
name: 'Beta Feature API (Mock)',
|
|
231
|
+
uri: 'https://beta-api.example.com'
|
|
232
|
+
}
|
|
233
|
+
];
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
data: [...data, ...mockServices],
|
|
237
|
+
routes
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}));
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Benefits**: Develop against planned services before they're deployed. Test integration scenarios with mock endpoints.
|
|
245
|
+
|
|
246
|
+
### Template Environment Variables
|
|
247
|
+
|
|
248
|
+
**When you need it**: You need to override default Fusion Framework template configuration for development.
|
|
249
|
+
|
|
250
|
+
**How it works**: Modify the template environment variables that control the SPA bootstrap process.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
export default defineDevServerConfig(() => ({
|
|
254
|
+
spa: {
|
|
255
|
+
templateEnv: {
|
|
256
|
+
// Override document title
|
|
257
|
+
title: 'My Custom App Title',
|
|
258
|
+
|
|
259
|
+
// Override portal configuration
|
|
260
|
+
portal: {
|
|
261
|
+
id: 'my-custom-portal',
|
|
262
|
+
tag: 'development'
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
// Modify service discovery
|
|
266
|
+
serviceDiscovery: {
|
|
267
|
+
url: 'https://custom-service-discovery.example.com',
|
|
268
|
+
scopes: ['api://custom-scope/.default']
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
// Override MSAL configuration
|
|
272
|
+
msal: {
|
|
273
|
+
tenantId: 'custom-tenant-id',
|
|
274
|
+
clientId: 'custom-client-id',
|
|
275
|
+
redirectUri: 'https://localhost:3000/auth-callback',
|
|
276
|
+
requiresAuth: 'true'
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
// Configure telemetry logging level
|
|
280
|
+
telemetry: {
|
|
281
|
+
consoleLevel: 0 // Debug level (most verbose)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Benefits**: Customize the Fusion Framework bootstrap behavior and control browser console logging verbosity for your specific development needs.
|
|
289
|
+
|
|
290
|
+
**Available telemetry levels:**
|
|
291
|
+
- `0`: Debug (shows all telemetry including debug messages)
|
|
292
|
+
- `1`: Information (shows info, warnings, errors, critical)
|
|
293
|
+
- `2`: Warning (shows warnings, errors, critical - default)
|
|
294
|
+
- `3`: Error (shows only errors and critical messages)
|
|
295
|
+
- `4`: Critical (shows only critical messages - least verbose)
|
|
296
|
+
|
|
297
|
+
### CLI Logging
|
|
298
|
+
|
|
299
|
+
**When you need it**: You want to control the verbosity of dev-server output in your terminal/console.
|
|
300
|
+
|
|
301
|
+
**How it works**: Configure the logger level or provide a custom logger instance for CLI output.
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
export default defineDevServerConfig(() => ({
|
|
305
|
+
log: {
|
|
306
|
+
// Info level (default) - shows info, warnings, and errors
|
|
307
|
+
level: 3,
|
|
308
|
+
}
|
|
309
|
+
}));
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Available levels:**
|
|
313
|
+
- `0`: Silent (no logging)
|
|
314
|
+
- `1`: Error (errors only)
|
|
315
|
+
- `2`: Warning (warnings and errors)
|
|
316
|
+
- `3`: Info (info, warnings, and errors - **default**)
|
|
317
|
+
- `4`: Debug (debug, info, warnings, and errors - most verbose)
|
|
318
|
+
|
|
319
|
+
**Quick reference:**
|
|
320
|
+
```typescript
|
|
321
|
+
// Quiet development (reduce noise)
|
|
322
|
+
log: { level: 2 }
|
|
323
|
+
|
|
324
|
+
// Default logging (recommended)
|
|
325
|
+
log: { level: 3 }
|
|
326
|
+
|
|
327
|
+
// Debug dev-server issues
|
|
328
|
+
log: { level: 4 }
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Common Patterns
|
|
332
|
+
|
|
333
|
+
### Override MSAL for Local Development
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
export default {
|
|
337
|
+
spa: {
|
|
338
|
+
templateEnv: {
|
|
339
|
+
msal: {
|
|
340
|
+
clientId: 'dev-client-id',
|
|
341
|
+
redirectUri: 'http://localhost:3000/auth-callback'
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
## Troubleshooting
|
|
352
|
+
|
|
353
|
+
### Configuration Not Loading
|
|
354
|
+
- Verify file name: `dev-server.config.ts` in project root
|
|
355
|
+
- Ensure default export: `export default { ... }`
|
|
356
|
+
- Check for TypeScript errors in config file
|
|
357
|
+
|
|
358
|
+
### Services Not Appearing
|
|
359
|
+
- Ensure `processServices` returns `{ data: Service[], routes: Route[] }`
|
|
360
|
+
- Verify you're not accidentally filtering out needed services
|
|
361
|
+
|
|
362
|
+
### Template Variables Not Available
|
|
363
|
+
- Variables are injected as `import.meta.env.FUSION_SPA_*`
|
|
364
|
+
- Access them as `import.meta.env.FUSION_SPA_MY_VAR`
|
|
365
|
+
|
|
366
|
+
## Advanced Usage
|
|
367
|
+
|
|
368
|
+
### Custom Service Discovery Endpoint
|
|
369
|
+
|
|
370
|
+
For custom environments with different service discovery URLs:
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
export default {
|
|
374
|
+
api: {
|
|
375
|
+
serviceDiscoveryUrl: 'https://custom-discovery.example.com/api/service-discovery'
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
> [!WARNING]
|
|
381
|
+
> Only use when working with non-standard environments. The default Fusion service discovery endpoint is usually correct.
|
|
382
|
+
|
package/docs/dev-server.md
CHANGED
|
@@ -24,6 +24,10 @@ ffc portal dev
|
|
|
24
24
|
|
|
25
25
|
The dev-server automatically detects your project type, loads configuration files, and starts a development server with all Fusion Framework features ready to use. No complex setup required - just run the command and start building.
|
|
26
26
|
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
For detailed information about configuring the dev-server, see [Dev Server Configuration](dev-server-config.md).
|
|
30
|
+
|
|
27
31
|
## Key Features
|
|
28
32
|
|
|
29
33
|
- **Service Discovery Integration** - Automatically connects to Fusion service discovery and enables local API mocking
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Fusion",
|
|
6
6
|
"Fusion Framework",
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
"ora": "^9.0.0",
|
|
104
104
|
"read-package-up": "^11.0.0",
|
|
105
105
|
"simple-git": "^3.28.0",
|
|
106
|
-
"vite": "^7.1.
|
|
106
|
+
"vite": "^7.1.9",
|
|
107
107
|
"vite-tsconfig-paths": "^5.1.4",
|
|
108
108
|
"zod": "^4.1.8",
|
|
109
|
-
"@equinor/fusion-framework-dev-
|
|
110
|
-
"@equinor/fusion-framework-dev-server": "1.1.3",
|
|
109
|
+
"@equinor/fusion-framework-dev-server": "1.1.4",
|
|
111
110
|
"@equinor/fusion-framework-module-msal-node": "1.0.7",
|
|
112
|
-
"@equinor/fusion-imports": "1.1.4"
|
|
111
|
+
"@equinor/fusion-imports": "1.1.4",
|
|
112
|
+
"@equinor/fusion-framework-dev-portal": "1.2.0"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
@@ -132,10 +132,10 @@
|
|
|
132
132
|
"type-fest": "^5.0.0",
|
|
133
133
|
"typescript": "^5.8.2",
|
|
134
134
|
"vitest": "^3.2.4",
|
|
135
|
-
"@equinor/fusion-framework-module": "5.0.
|
|
136
|
-
"@equinor/fusion-framework-module-app": "7.0.
|
|
137
|
-
"@equinor/fusion-framework-module-http": "7.0.
|
|
138
|
-
"@equinor/fusion-framework-module-service-discovery": "9.0.
|
|
135
|
+
"@equinor/fusion-framework-module": "5.0.3",
|
|
136
|
+
"@equinor/fusion-framework-module-app": "7.0.2",
|
|
137
|
+
"@equinor/fusion-framework-module-http": "7.0.2",
|
|
138
|
+
"@equinor/fusion-framework-module-service-discovery": "9.0.2"
|
|
139
139
|
},
|
|
140
140
|
"peerDependenciesMeta": {
|
|
141
141
|
"typescript": {
|