@equinor/fusion-framework-cli 11.1.4 → 11.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 +149 -0
- package/README.md +18 -0
- package/bin/build/cli.mjs +3 -3
- package/dist/esm/lib/utils/assert.js +70 -15
- package/dist/esm/lib/utils/assert.js.map +1 -1
- package/dist/esm/lib/utils/is-git-dir.js +19 -0
- package/dist/esm/lib/utils/is-git-dir.js.map +1 -0
- package/dist/esm/lib/utils/package-info.js +135 -0
- package/dist/esm/lib/utils/package-info.js.map +1 -0
- package/dist/esm/lib/utils/path-security.js +56 -0
- package/dist/esm/lib/utils/path-security.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/bin/helpers/ProjectTemplate.d.ts +61 -0
- package/dist/types/bin/helpers/ProjectTemplateRepository.d.ts +113 -0
- package/dist/types/bin/helpers/install-package-dependencies.d.ts +11 -0
- package/dist/types/bin/helpers/project-templates.schema.d.ts +301 -0
- package/dist/types/cli/commands/create/_helpers/check-target-directory.d.ts +12 -0
- package/dist/types/cli/commands/create/_helpers/cleanup-template-files.d.ts +15 -0
- package/dist/types/cli/commands/create/_helpers/install-dependencies.d.ts +14 -0
- package/dist/types/cli/commands/create/_helpers/open-in-ide.d.ts +15 -0
- package/dist/types/cli/commands/create/_helpers/resolve-workspace-dependencies.d.ts +27 -0
- package/dist/types/cli/commands/create/_helpers/select-template.d.ts +24 -0
- package/dist/types/cli/commands/create/_helpers/setup-repository.d.ts +23 -0
- package/dist/types/cli/commands/create/_helpers/start-dev-server.d.ts +17 -0
- package/dist/types/cli/commands/create/_helpers/update-package-json.d.ts +41 -0
- package/dist/types/cli/commands/create/app.d.ts +28 -0
- package/dist/types/cli/commands/create/index.d.ts +2 -0
- package/dist/types/lib/utils/assert.d.ts +61 -13
- package/dist/types/lib/utils/is-git-dir.d.ts +9 -0
- package/dist/types/lib/utils/package-info.d.ts +106 -0
- package/dist/types/lib/utils/path-security.d.ts +36 -0
- package/dist/types/version.d.ts +1 -1
- package/docs/creating-apps.md +275 -0
- package/docs/dev-server.md +367 -0
- package/docs/migration-v10-to-v11.md +13 -0
- package/package.json +14 -5
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
# Fusion Framework Dev Server
|
|
2
|
+
|
|
3
|
+
The Fusion Framework dev-server is your complete local development solution for building and testing Fusion Framework applications and portals. Whether you're developing a new application or working on an existing portal, the dev-server provides everything you need to get up and running quickly.
|
|
4
|
+
|
|
5
|
+
## What You Get
|
|
6
|
+
|
|
7
|
+
🚀 **Instant Development Environment** - Start coding immediately with hot module replacement, live reloading, and instant feedback
|
|
8
|
+
|
|
9
|
+
🔧 **Fusion Framework Integration** - Built-in support for service discovery, API proxying, and portal configuration
|
|
10
|
+
|
|
11
|
+
⚡ **Modern Tooling** - Powered by Vite for lightning-fast builds and optimal development experience
|
|
12
|
+
|
|
13
|
+
🛠️ **Flexible Configuration** - Easy setup for both applications and portals with environment-specific overrides
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# For applications
|
|
19
|
+
ffc app dev
|
|
20
|
+
|
|
21
|
+
# For portals
|
|
22
|
+
ffc portal dev
|
|
23
|
+
```
|
|
24
|
+
|
|
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
|
+
|
|
27
|
+
## Key Features
|
|
28
|
+
|
|
29
|
+
- **Service Discovery Integration** - Automatically connects to Fusion service discovery and enables local API mocking
|
|
30
|
+
- **Template Generation** - Dynamic HTML template generation with environment variable injection
|
|
31
|
+
- **API Proxying** - Seamless API integration with request/response transformation capabilities
|
|
32
|
+
- **Portal Support** - Full portal development with manifest loading and configuration management
|
|
33
|
+
- **Hot Module Replacement** - Instant updates as you code without losing application state
|
|
34
|
+
|
|
35
|
+
## Architecture Overview
|
|
36
|
+
|
|
37
|
+
The dev-server is built on a modular architecture that combines Vite's powerful development tooling with Fusion Framework-specific capabilities. Here's how the components work together:
|
|
38
|
+
|
|
39
|
+
```mermaid
|
|
40
|
+
flowchart TD
|
|
41
|
+
A[Start Dev Server] --> B[Generate Manifest]
|
|
42
|
+
B --> C[Create Vite Server]
|
|
43
|
+
C --> D[SPA Plugin]
|
|
44
|
+
C --> E[API Service Plugin]
|
|
45
|
+
D --> F[Portal Template]
|
|
46
|
+
E --> G[Service Discovery]
|
|
47
|
+
E --> H[API Routes]
|
|
48
|
+
F --> I[Development Server]
|
|
49
|
+
G --> I
|
|
50
|
+
H --> I
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Core Components
|
|
54
|
+
|
|
55
|
+
#### 🎯 CLI Orchestrator
|
|
56
|
+
**`@equinor/fusion-framework-cli`**
|
|
57
|
+
- **Role**: Command-line interface and project coordinator
|
|
58
|
+
- **Responsibilities**:
|
|
59
|
+
- Resolves project configuration from `package.json` and manifest files
|
|
60
|
+
- Generates application manifests and environment configs
|
|
61
|
+
- Initializes and configures the Vite development server
|
|
62
|
+
- Handles command-line options and project type detection
|
|
63
|
+
|
|
64
|
+
#### 🏗️ Development Server Core
|
|
65
|
+
**`@equinor/fusion-framework-dev-server`**
|
|
66
|
+
- **Role**: Core development infrastructure
|
|
67
|
+
- **Responsibilities**:
|
|
68
|
+
- Provides the base Vite development server
|
|
69
|
+
- Integrates Fusion Framework-specific plugins
|
|
70
|
+
- Manages hot module replacement and file watching
|
|
71
|
+
- Handles development-specific configurations and optimizations
|
|
72
|
+
|
|
73
|
+
#### 🎨 SPA Template Engine
|
|
74
|
+
**`@equinor/fusion-framework-vite-plugin-spa`**
|
|
75
|
+
- **Role**: HTML template generation and application bootstrapping
|
|
76
|
+
- **Responsibilities**:
|
|
77
|
+
- Generates dynamic HTML templates for applications and portals
|
|
78
|
+
- Injects environment variables and configuration data
|
|
79
|
+
- Manages portal-specific manifest loading
|
|
80
|
+
- Handles application-specific routing and navigation
|
|
81
|
+
|
|
82
|
+
#### 🔌 API Integration Layer
|
|
83
|
+
**`@equinor/fusion-framework-vite-plugin-api-service`**
|
|
84
|
+
- **Role**: API service discovery and request handling
|
|
85
|
+
- **Responsibilities**:
|
|
86
|
+
- Proxies requests to Fusion service discovery endpoints
|
|
87
|
+
- Enables local API mocking and development overrides
|
|
88
|
+
- Manages dynamic route mapping for discovered services
|
|
89
|
+
- Provides request/response transformation capabilities
|
|
90
|
+
|
|
91
|
+
#### 🏠 Development Portal
|
|
92
|
+
**`@equinor/fusion-framework-dev-portal`**
|
|
93
|
+
- **Role**: Portal source code for development
|
|
94
|
+
- **Responsibilities**:
|
|
95
|
+
- Provides minimal portal implementation for development
|
|
96
|
+
- Integrates with Fusion Framework for authentication and service discovery
|
|
97
|
+
- Acts as placeholder for testing applications in portal environment
|
|
98
|
+
- Enables development without full production portal setup
|
|
99
|
+
|
|
100
|
+
### How They Work Together
|
|
101
|
+
|
|
102
|
+
1. **CLI** analyzes your project and determines the appropriate configuration
|
|
103
|
+
2. **Dev Server Core** creates a Vite instance with Fusion Framework plugins
|
|
104
|
+
3. **SPA Plugin** generates the HTML template with your app's specific settings
|
|
105
|
+
4. **API Plugin** sets up service discovery and API proxying
|
|
106
|
+
5. **Dev Portal** provides portal source code when developing portal applications
|
|
107
|
+
6. **All components** work together to provide a seamless development experience
|
|
108
|
+
|
|
109
|
+
This modular approach ensures that each component has a clear responsibility while working together to provide a unified development environment tailored specifically for Fusion Framework applications.
|
|
110
|
+
|
|
111
|
+
> [!TIP]
|
|
112
|
+
> The **Developer Portal** serves as a minimal template for Fusion ecosystem development. It can be substituted with any portal implementation, including production portals from the portal store, enabling comprehensive testing across different portal configurations and environments.
|
|
113
|
+
|
|
114
|
+
## Development Environment Startup
|
|
115
|
+
|
|
116
|
+
The dev-server follows a systematic startup sequence that automatically configures your development environment through intelligent project analysis, configuration resolution, and plugin initialization. This comprehensive process ensures all Fusion Framework integrations are properly initialized, service discovery is configured, API proxying is established, and the development portal is ready for immediate use.
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
sequenceDiagram
|
|
120
|
+
participant Setup
|
|
121
|
+
participant DevServer as Dev Server
|
|
122
|
+
participant Plugins as Fusion Plugins
|
|
123
|
+
participant Browser as Browser
|
|
124
|
+
|
|
125
|
+
Setup->>Setup: Load package.json
|
|
126
|
+
Setup->>Setup: Load manifest files
|
|
127
|
+
Setup->>Setup: Load config files
|
|
128
|
+
Setup->>DevServer: Create Dev Server config
|
|
129
|
+
DevServer->>Plugins: Initialize plugins
|
|
130
|
+
Plugins->>Plugins: Setup API proxy
|
|
131
|
+
Plugins->>Plugins: Setup template env
|
|
132
|
+
DevServer->>Browser: Start dev server
|
|
133
|
+
Browser->>DevServer: Request resources
|
|
134
|
+
DevServer->>Plugins: Process requests
|
|
135
|
+
Plugins->>Browser: Return responses
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The development workflow follows a systematic process that ensures proper configuration and seamless integration:
|
|
139
|
+
|
|
140
|
+
1. **Start**: The development process begins when the CLI command (`ffc app dev` or `ffc portal dev`) is executed with user-specified options and parameters.
|
|
141
|
+
2. **Setup**: The system automatically discovers and loads project configuration files, including `package.json`, manifest files, and application configs, with environment-specific overrides.
|
|
142
|
+
3. **Dev Server Creation**: A development server is instantiated with Fusion Framework-specific plugins and configurations tailored for the project type.
|
|
143
|
+
4. **Plugin Initialization**: The SPA and API service plugins are configured with project-specific settings, including template environment variables and service discovery endpoints.
|
|
144
|
+
5. **Server Startup**: The development server becomes available with hot module replacement, file system access, and API proxy capabilities.
|
|
145
|
+
6. **Runtime Processing**: As developers interact with the application, requests are processed through the plugin system, which handles API proxying, template generation, and resource serving.
|
|
146
|
+
|
|
147
|
+
This workflow ensures that developers have immediate access to a fully functional development environment with all Fusion Framework integrations ready for use.
|
|
148
|
+
|
|
149
|
+
## Service Discovery
|
|
150
|
+
|
|
151
|
+
The API plugin (`@equinor/fusion-framework-vite-plugin-api-service`) acts as an intelligent proxy that intercepts and enriches service discovery requests, enabling flexible service integration and local development capabilities. This plugin transforms the development server into a sophisticated service gateway that can dynamically modify service endpoints, inject mock services, and provide seamless integration between local development and production services.
|
|
152
|
+
|
|
153
|
+
### Service Discovery Sequence
|
|
154
|
+
|
|
155
|
+
```mermaid
|
|
156
|
+
sequenceDiagram
|
|
157
|
+
participant Browser
|
|
158
|
+
participant DevServer as Dev Server
|
|
159
|
+
participant Plugin as API Plugin
|
|
160
|
+
participant Fusion as Fusion Service Discovery
|
|
161
|
+
|
|
162
|
+
Browser->>DevServer: Request service discovery
|
|
163
|
+
DevServer->>Plugin: Route to API plugin
|
|
164
|
+
Plugin->>Fusion: Proxy request to service discovery
|
|
165
|
+
Fusion->>Plugin: Return available services
|
|
166
|
+
Plugin->>Plugin: Intercept and enrich response
|
|
167
|
+
Plugin->>DevServer: Return enriched service list
|
|
168
|
+
DevServer->>Browser: Return enriched service list
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
1. **Browser Request**: The application or framework requests available services from the service discovery endpoint
|
|
172
|
+
2. **Plugin Interception**: The API plugin intercepts this request before it reaches the external service
|
|
173
|
+
3. **Proxy to Fusion**: The plugin forwards the request to the actual Fusion service discovery endpoint
|
|
174
|
+
4. **Response Interception**: When the response returns, the plugin intercepts it before sending it back to the user
|
|
175
|
+
5. **Service Enrichment**: The plugin enriches the response by:
|
|
176
|
+
- Adding mock services for local development
|
|
177
|
+
- Altering service endpoints for testing
|
|
178
|
+
- Injecting additional metadata or configuration
|
|
179
|
+
- Modifying service capabilities or scopes
|
|
180
|
+
6. **Enhanced Response**: The user receives an enriched list of services that may include both real and mock services
|
|
181
|
+
|
|
182
|
+
## Mocking
|
|
183
|
+
|
|
184
|
+
The API plugin implements a **middleware pattern** that creates dynamic processing routes for mocking API responses during development. While these middleware routes can handle various request processing tasks, their primary purpose is to provide mock data when backend services aren't available or when you need to test specific scenarios without hitting real APIs.
|
|
185
|
+
|
|
186
|
+
```mermaid
|
|
187
|
+
sequenceDiagram
|
|
188
|
+
participant DevServer as Dev Server
|
|
189
|
+
participant Middleware as Middleware
|
|
190
|
+
participant MockData as Mock Data
|
|
191
|
+
participant Browser
|
|
192
|
+
|
|
193
|
+
DevServer->>Middleware: Initialize middleware stack
|
|
194
|
+
|
|
195
|
+
Browser->>DevServer: Execute API request
|
|
196
|
+
DevServer->>Middleware: Route through middleware
|
|
197
|
+
Middleware->>Middleware: Process request
|
|
198
|
+
Middleware->>MockData: Fetch mock data
|
|
199
|
+
MockData->>Middleware: Return mock response
|
|
200
|
+
Middleware->>DevServer: Return processed response
|
|
201
|
+
DevServer->>Browser: Return mock data
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
1. **Middleware Initialization**: The dev-server initializes the middleware stack with configured routes and processing rules
|
|
205
|
+
2. **Request Interception**: API requests from the browser are routed through the middleware layer
|
|
206
|
+
3. **Request Processing**: The middleware processes the request according to its configured rules and logic
|
|
207
|
+
4. **Data Resolution**: The middleware fetches appropriate data (mock or real) based on the request and configuration
|
|
208
|
+
5. **Response Processing**: The middleware processes and transforms the response before returning it
|
|
209
|
+
6. **Response Delivery**: The processed response is returned to the browser through the dev-server
|
|
210
|
+
|
|
211
|
+
#### Usage Example
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import type { MiddlewareRoute } from '@equinor/fusion-framework-vite-plugin-api-service';
|
|
215
|
+
|
|
216
|
+
const mockDataRoute: MiddlewareRoute = {
|
|
217
|
+
match: '/api/users',
|
|
218
|
+
middleware: (req, res, next) => {
|
|
219
|
+
// Return mock data for users endpoint
|
|
220
|
+
res.setHeader('Content-Type', 'application/json');
|
|
221
|
+
res.end(JSON.stringify([
|
|
222
|
+
{ id: 1, name: 'John Doe' },
|
|
223
|
+
{ id: 2, name: 'Jane Smith' }
|
|
224
|
+
]));
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Re-Routing requests
|
|
230
|
+
|
|
231
|
+
The API plugin implements a **proxy pattern** that configures routes to be proxied to other services based on service discovery results. When your application makes API calls, these routes are automatically forwarded to the appropriate backend services. The service worker handles authentication by adding the necessary tokens to these proxied requests, ensuring your app can seamlessly communicate with Fusion services during development.
|
|
232
|
+
|
|
233
|
+
```mermaid
|
|
234
|
+
sequenceDiagram
|
|
235
|
+
participant DevServer as Dev Server
|
|
236
|
+
participant Proxy as Proxy Route
|
|
237
|
+
participant Target
|
|
238
|
+
participant Browser
|
|
239
|
+
|
|
240
|
+
DevServer->>Proxy: Initialize proxy routes
|
|
241
|
+
|
|
242
|
+
Browser->>DevServer: Execute API request
|
|
243
|
+
DevServer->>Proxy: Route through proxy
|
|
244
|
+
Proxy->>Proxy: Rewrite request path
|
|
245
|
+
Proxy->>Target: Forward to target service
|
|
246
|
+
Target->>Proxy: Return service response
|
|
247
|
+
Proxy->>Proxy: Transform response
|
|
248
|
+
Proxy->>DevServer: Return processed response
|
|
249
|
+
DevServer->>Browser: Return transformed data
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
1. **Proxy Initialization**: The dev-server initializes proxy routes with configured targets and rules
|
|
253
|
+
2. **Request Reception**: The browser sends an API request to the dev-server
|
|
254
|
+
3. **Proxy Routing**: The dev-server routes the request through the appropriate proxy configuration
|
|
255
|
+
4. **Path Rewriting**: The proxy rewrites the request path according to configured rules
|
|
256
|
+
5. **Target Forwarding**: The proxy forwards the rewritten request to the target service
|
|
257
|
+
6. **Response Reception**: The target service processes the request and returns a response
|
|
258
|
+
7. **Response Transformation**: The proxy transforms the response data according to configured rules
|
|
259
|
+
8. **Response Delivery**: The transformed response is returned to the browser through the dev-server
|
|
260
|
+
|
|
261
|
+
#### Usage Example
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import type { ProxyRoute } from '@equinor/fusion-framework-vite-plugin-api-service';
|
|
265
|
+
|
|
266
|
+
const apiProxyRoute: ProxyRoute = {
|
|
267
|
+
match: '/api/users',
|
|
268
|
+
proxy: {
|
|
269
|
+
target: 'https://api.example.com',
|
|
270
|
+
rewrite: (path) => path.replace('/api', '/v1'),
|
|
271
|
+
transformResponse: (data) => {
|
|
272
|
+
// Transform the response data
|
|
273
|
+
return {
|
|
274
|
+
...data,
|
|
275
|
+
transformed: true,
|
|
276
|
+
timestamp: new Date().toISOString()
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
configure: (proxy, options) => {
|
|
280
|
+
// Configure the proxy server
|
|
281
|
+
proxy.on('proxyReq', (proxyReq, req, res) => {
|
|
282
|
+
proxyReq.setHeader('X-Forwarded-For', req.socket.remoteAddress);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## SPA Template Concept
|
|
290
|
+
|
|
291
|
+
The SPA plugin (`@equinor/fusion-framework-vite-plugin-spa`) provides a sophisticated template system that automates HTML generation, environment variable injection, and application bootstrapping for Fusion Framework applications. This intelligent system dynamically generates HTML templates based on project configuration, injects environment-specific variables, and seamlessly integrates with the Fusion Framework initialization process. When developing portals, the plugin serves the **`@equinor/fusion-framework-dev-portal`** as the source code, providing a complete portal environment for testing and development.
|
|
292
|
+
|
|
293
|
+
```mermaid
|
|
294
|
+
sequenceDiagram
|
|
295
|
+
participant Browser
|
|
296
|
+
participant Vite as Vite Dev Server
|
|
297
|
+
participant Plugin as SPA Plugin
|
|
298
|
+
participant Framework as Fusion Framework
|
|
299
|
+
participant Portal as Portal Service
|
|
300
|
+
|
|
301
|
+
Browser->>Vite: Request index.html
|
|
302
|
+
Vite->>Plugin: Intercept HTML request
|
|
303
|
+
Plugin->>Plugin: Generate template with env vars
|
|
304
|
+
Plugin->>Plugin: Inject bootstrap.js path
|
|
305
|
+
Plugin->>Plugin: Resolve portal configuration
|
|
306
|
+
Plugin->>Browser: Return resolved HTML template
|
|
307
|
+
Browser->>Plugin: Load bootstrap.js
|
|
308
|
+
Plugin->>Framework: Initialize Fusion Framework
|
|
309
|
+
Framework->>Framework: Register Service Worker
|
|
310
|
+
Framework->>Portal: Fetch Portal Manifest
|
|
311
|
+
Portal->>Framework: Return manifest.build.config
|
|
312
|
+
Framework->>Portal: Fetch Portal Configuration
|
|
313
|
+
Portal->>Framework: Return configuration
|
|
314
|
+
Framework->>Portal: Import Portal Source
|
|
315
|
+
Portal->>Framework: Return portal code
|
|
316
|
+
Framework->>Browser: Render Portal
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
1. **HTML Request**: The browser requests the index.html file from the Vite dev server
|
|
320
|
+
2. **Template Interception**: The SPA plugin intercepts the HTML request before it reaches the file system
|
|
321
|
+
3. **Environment Injection**: The plugin generates the HTML template with environment variables and configuration data
|
|
322
|
+
4. **Bootstrap Injection**: The plugin injects the bootstrap.js path for Fusion Framework initialization
|
|
323
|
+
5. **Portal Resolution**: The plugin resolves portal configuration and determines the appropriate portal source
|
|
324
|
+
6. **Template Delivery**: The complete HTML template is returned to the browser
|
|
325
|
+
7. **Framework Initialization**: The browser loads bootstrap.js, which initializes the Fusion Framework
|
|
326
|
+
8. **Service Worker Registration**: The framework registers the service worker for API request handling
|
|
327
|
+
9. **Portal Manifest Fetch**: The framework fetches the portal manifest to understand available services
|
|
328
|
+
10. **Portal Configuration**: The framework retrieves portal-specific configuration settings
|
|
329
|
+
11. **Portal Source Import**: The framework imports the actual portal source code (dev-portal or custom portal)
|
|
330
|
+
12. **Portal Rendering**: The framework renders the portal in the browser, completing the application startup
|
|
331
|
+
|
|
332
|
+
### Service Worker
|
|
333
|
+
|
|
334
|
+
The service worker acts as a critical intermediary for API requests, providing seamless authentication and request transformation without requiring changes to application code. While we could inject MSAL tokens directly into the API plugin, this would break the production pattern where applications handle their own authentication. Additionally, the CLI uses a different app registration than web applications, making the service worker approach essential for maintaining consistent authentication patterns and enabling transparent API integration in the Fusion Framework ecosystem.
|
|
335
|
+
|
|
336
|
+
```mermaid
|
|
337
|
+
sequenceDiagram
|
|
338
|
+
participant App as Application
|
|
339
|
+
participant SW as Service Worker
|
|
340
|
+
participant Main as Fusion Framework
|
|
341
|
+
participant API as API Server
|
|
342
|
+
|
|
343
|
+
App->>SW: fetch('/app-proxy/assets/some-app/resource.json')
|
|
344
|
+
alt Route matches a registered resource
|
|
345
|
+
SW->>Main: Request auth tokens for scopes
|
|
346
|
+
Main-->>SW: Return tokens
|
|
347
|
+
SW->>SW: Rewrite URL to /@fusion-api/app/assets/some-app/resource.json
|
|
348
|
+
SW->>API: fetch with auth headers
|
|
349
|
+
API-->>SW: Response
|
|
350
|
+
SW-->>App: Return response
|
|
351
|
+
else Route does not match any resource
|
|
352
|
+
SW-->>App: Let request pass through (no interception)
|
|
353
|
+
end
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
1. **Request Initiation**: The application initiates a fetch request to a resource endpoint
|
|
357
|
+
2. **Service Worker Interception**: The service worker intercepts the request before it reaches the network
|
|
358
|
+
3. **Route Matching**: The service worker checks if the request matches any registered resource patterns
|
|
359
|
+
4. **Authentication Request**: If matched, the service worker requests authentication tokens from the Fusion Framework
|
|
360
|
+
5. **Token Retrieval**: The Fusion Framework returns the appropriate authentication tokens for the required scopes
|
|
361
|
+
6. **URL Rewriting**: The service worker rewrites the request URL to the proper API endpoint format
|
|
362
|
+
7. **Authenticated Request**: The service worker makes the request to the API server with authentication headers
|
|
363
|
+
8. **Response Processing**: The API server processes the request and returns the response
|
|
364
|
+
9. **Response Delivery**: The service worker delivers the response back to the application
|
|
365
|
+
10. **Pass-Through Handling**: If the route doesn't match any registered resources, the request passes through without interception
|
|
366
|
+
|
|
367
|
+
|
|
@@ -19,6 +19,18 @@ With v11, we switched to using the Fusion Framework itself for CLI operations. T
|
|
|
19
19
|
> }
|
|
20
20
|
> ```
|
|
21
21
|
|
|
22
|
+
### Vite Configuration File Naming
|
|
23
|
+
|
|
24
|
+
**Breaking Change:** The CLI now uses Vite's standard configuration file naming convention.
|
|
25
|
+
|
|
26
|
+
- **Old behavior (v10):** CLI looked for `app.vite.config.ts`
|
|
27
|
+
- **New behavior (v11):** CLI now looks for `vite.config.ts` (Vite's default)
|
|
28
|
+
|
|
29
|
+
> [!WARNING]
|
|
30
|
+
> **Action Required:** If you have a `app.vite.config.ts` file, rename it to `vite.config.ts` to ensure your Vite configurations are applied correctly in v11.
|
|
31
|
+
>
|
|
32
|
+
> **Important:** Using `vite.config.ts` should be a last resort for custom setups. Instead, prefer configuring your application through the dev-server configuration (`dev-server.config.js`) to avoid unexpected behavior. The CLI provides higher-level configuration options that are better integrated with the Fusion Framework ecosystem.
|
|
33
|
+
|
|
22
34
|
### Deprecated App Command Aliases
|
|
23
35
|
|
|
24
36
|
The following `fusion-framework-cli app` commands have been renamed:
|
|
@@ -51,6 +63,7 @@ Authentication behavior has been updated to improve security and consistency:
|
|
|
51
63
|
|
|
52
64
|
When upgrading from v10 to v11, ensure you:
|
|
53
65
|
|
|
66
|
+
- **Rename Vite configuration file** from `app.vite.config.ts` to `vite.config.ts`
|
|
54
67
|
- **Update command names** in all scripts and CI/CD pipelines:
|
|
55
68
|
- `build-pack` → `pack`
|
|
56
69
|
- `build-upload` → `upload`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Fusion",
|
|
6
6
|
"Fusion Framework",
|
|
@@ -94,16 +94,21 @@
|
|
|
94
94
|
"directory": "packages/cli"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
+
"@types/inquirer": "^9.0.9",
|
|
97
98
|
"commander": "^13.0.0",
|
|
98
99
|
"deepmerge": "^4.3.1",
|
|
100
|
+
"execa": "^9.6.0",
|
|
101
|
+
"inquirer": "^12.9.4",
|
|
102
|
+
"is-path-inside": "^4.0.0",
|
|
99
103
|
"ora": "^8.0.1",
|
|
100
104
|
"read-package-up": "^11.0.0",
|
|
105
|
+
"simple-git": "^3.28.0",
|
|
101
106
|
"vite": "^6.3.5",
|
|
102
107
|
"vite-tsconfig-paths": "^5.1.4",
|
|
103
108
|
"zod": "^3.25.76",
|
|
104
109
|
"@equinor/fusion-framework-dev-portal": "^1.0.2",
|
|
110
|
+
"@equinor/fusion-framework-module-msal-node": "^1.0.3",
|
|
105
111
|
"@equinor/fusion-framework-dev-server": "^1.0.2",
|
|
106
|
-
"@equinor/fusion-framework-module-msal-node": "^1.0.2",
|
|
107
112
|
"@equinor/fusion-imports": "^1.1.2"
|
|
108
113
|
},
|
|
109
114
|
"devDependencies": {
|
|
@@ -113,6 +118,7 @@
|
|
|
113
118
|
"@rollup/plugin-replace": "^6.0.2",
|
|
114
119
|
"@types/adm-zip": "^0.5.0",
|
|
115
120
|
"@types/normalize-package-data": "^2.4.4",
|
|
121
|
+
"@vitest/coverage-v8": "^2.0.1",
|
|
116
122
|
"adm-zip": "^0.5.10",
|
|
117
123
|
"ajv": "^8.17.1",
|
|
118
124
|
"chalk": "^5.6.0",
|
|
@@ -125,10 +131,11 @@
|
|
|
125
131
|
"rxjs": "^7.8.1",
|
|
126
132
|
"type-fest": "^4.40.0",
|
|
127
133
|
"typescript": "^5.8.2",
|
|
134
|
+
"vitest": "^2.0.5",
|
|
128
135
|
"@equinor/fusion-framework-module": "^5.0.0",
|
|
129
136
|
"@equinor/fusion-framework-module-app": "^6.1.18",
|
|
130
|
-
"@equinor/fusion-framework-module-
|
|
131
|
-
"@equinor/fusion-framework-module-
|
|
137
|
+
"@equinor/fusion-framework-module-service-discovery": "^8.0.18",
|
|
138
|
+
"@equinor/fusion-framework-module-http": "^6.3.4"
|
|
132
139
|
},
|
|
133
140
|
"peerDependenciesMeta": {
|
|
134
141
|
"typescript": {
|
|
@@ -138,6 +145,8 @@
|
|
|
138
145
|
"scripts": {
|
|
139
146
|
"prebuild": "tsc -b",
|
|
140
147
|
"build": "rollup -c rollup.config.js",
|
|
141
|
-
"build:clean": "rm -rf dist && rm -rf bin/build && rm -f tsconfig.tsbuildinfo && pnpm build"
|
|
148
|
+
"build:clean": "rm -rf dist && rm -rf bin/build && rm -f tsconfig.tsbuildinfo && pnpm build",
|
|
149
|
+
"test": "vitest",
|
|
150
|
+
"test:coverage": "vitest run --coverage"
|
|
142
151
|
}
|
|
143
152
|
}
|