@equinor/roma-nx-plugin 6.0.0-beta.0 → 6.0.0-beta.10

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 +76 -0
  2. package/generators.json +5 -0
  3. package/migrations.json +106 -22
  4. package/package.json +4 -4
  5. package/src/executors/build/build.js +1 -1
  6. package/src/executors/build/build.js.map +1 -1
  7. package/src/executors/create-vite-config.d.ts +1 -1
  8. package/src/executors/create-vite-config.js +14 -5
  9. package/src/executors/create-vite-config.js.map +1 -1
  10. package/src/executors/serve/server.js +15 -8
  11. package/src/executors/serve/server.js.map +1 -1
  12. package/src/executors/utils/get-version.d.ts +1 -0
  13. package/src/executors/utils/get-version.js +12 -0
  14. package/src/executors/utils/get-version.js.map +1 -0
  15. package/src/executors/utils/load-services.js.map +1 -1
  16. package/src/executors/utils/logger.js +2 -1
  17. package/src/executors/utils/logger.js.map +1 -1
  18. package/src/generators/app/data/generated-dependencies.json +23 -0
  19. package/src/generators/app/generator.js +7 -17
  20. package/src/generators/app/generator.js.map +1 -1
  21. package/src/generators/preset/generator.js.map +1 -1
  22. package/src/generators/preset/schema.d.ts +1 -0
  23. package/src/generators/skill/files/roma-app-development/SKILL.md +34 -0
  24. package/src/generators/skill/files/roma-app-development/generators.md +357 -0
  25. package/src/generators/skill/files/roma-app-development/services.md +471 -0
  26. package/src/generators/skill/generator.d.ts +4 -0
  27. package/src/generators/skill/generator.js +14 -0
  28. package/src/generators/skill/generator.js.map +1 -0
  29. package/src/generators/skill/schema.d.ts +3 -0
  30. package/src/generators/skill/schema.json +14 -0
  31. package/src/migrations/migrate-fusion-manifest/update-manifest.d.ts +5 -2
  32. package/src/migrations/migrate-fusion-manifest/update-manifest.js.map +1 -1
  33. package/src/generators/app/data/modules.d.ts +0 -19
  34. package/src/generators/app/data/modules.js +0 -23
  35. package/src/generators/app/data/modules.js.map +0 -1
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: roma-app-development
3
+ description: Skill for developing Roma applications and widgets. Covers app scaffolding via the Roma NX plugin generators, service configuration, data fetching with React Query + Fusion HTTP clients, and the patterns used across the Roma workbench.
4
+ ---
5
+
6
+ # Roma App Development
7
+
8
+ Use this skill when you need to:
9
+
10
+ - Create a new Roma application or widget
11
+ - Add services / API clients to an app
12
+ - Implement data fetching hooks (queries, mutations, infinite queries)
13
+ - Configure caching and persistence
14
+ - Set up Cypress component tests
15
+ - Add this skill to another repository
16
+ - Understand how the Roma framework, Fusion, and React Query work together
17
+
18
+ ## Installation
19
+
20
+ This skill was added via the Roma NX plugin generator:
21
+
22
+ ```sh
23
+ nx g @equinor/roma-nx-plugin:skill
24
+ ```
25
+
26
+ Re-run the command to update the skill files to the latest version.
27
+
28
+ ## Files
29
+
30
+ | File | Contents |
31
+ |-----------------|--------------------------------------------------------------|
32
+ | `SKILL.md` | This file — overview and quick reference |
33
+ | `generators.md` | Full NX plugin generator source, schemas, and templates |
34
+ | `services.md` | Service registration, data fetching, caching, error handling |
@@ -0,0 +1,357 @@
1
+ # Roma NX Plugin Generators
2
+
3
+ ## Overview
4
+
5
+ The Roma NX plugin (`@equinor/roma-nx-plugin`) provides four generators for scaffolding Roma-compatible projects:
6
+
7
+ | Generator | Command | Purpose |
8
+ |-----------|---------|---------|
9
+ | **app** | `nx g @equinor/roma-nx-plugin:app {name}` | Scaffold a new Roma application or widget |
10
+ | **preset** | `nx g @equinor/roma-nx-plugin:preset {name}` | Initialize a new Roma NX workspace (wraps the app generator) |
11
+ | **component-test** | `nx g @equinor/roma-nx-plugin:component-test --project={name}` | Add Cypress component testing to an existing Roma app |
12
+ | **skill** | `nx g @equinor/roma-nx-plugin:skill` | Add the Roma development skill for AI assistants |
13
+
14
+ ---
15
+
16
+ ## App Generator
17
+
18
+ ### Usage
19
+
20
+ ```sh
21
+ nx g @equinor/roma:app my-app
22
+ nx g @equinor/roma:app my-app --routing # with React Router
23
+ nx g @equinor/roma:app my-app --minimal # minimal scaffolding
24
+ ```
25
+
26
+ ### What It Does
27
+
28
+ 1. Runs `@nx/react`'s `applicationGenerator` with `bundler: 'vite'`, `style: 'none'`, and tags `roma-application`
29
+ 2. Deletes the default vite config, index.html, main.tsx, styles, assets, and public folder
30
+ 3. Replaces them with Roma-specific templates (see below)
31
+ 4. Configures project targets to use Roma executors (`@equinor/roma-nx-plugin:build`, `:serve`, `:portal`, `:publish`)
32
+ 5. Adds Roma + Fusion + EDS dependencies
33
+
34
+ ### Schema Options
35
+
36
+ ```json
37
+ {
38
+ "name": "string (required) — App name, pattern: ^[a-zA-Z][^:]*$",
39
+ "directory": "string — Target directory (default: same as name)",
40
+ "routing": "boolean (default: false) — Include React Router",
41
+ "unitTestRunner": "jest | vitest | none (default: vitest)",
42
+ "e2eTestRunner": "cypress | playwright | none (default: none)",
43
+ "linter": "eslint | none (default: eslint)",
44
+ "minimal": "boolean (default: false) — Minimal scaffolding",
45
+ "tags": "string — Comma-separated NX tags"
46
+ }
47
+ ```
48
+
49
+ ### Dependencies Added
50
+
51
+ ```json
52
+ {
53
+ "@equinor/roma-framework": "^5.0.0",
54
+ "@equinor/fusion-framework": "^7.4.2",
55
+ "@equinor/fusion-framework-app": "^10.1.2",
56
+ "@equinor/eds-core-react": "^0.49.0",
57
+ "@equinor/eds-data-grid-react": "^0.9.1",
58
+ "@equinor/eds-icons": "^0.22.0",
59
+ "@equinor/eds-tokens": "^0.10.0",
60
+ "@equinor/fusion-framework-react": "^7.4.19",
61
+ "@equinor/fusion-framework-react-app": "^7.0.1",
62
+ "@equinor/fusion-framework-react-module": "^3.1.13",
63
+ "@equinor/fusion-framework-module-navigation": "^6.0.0",
64
+ "styled-components": "^6.1.0",
65
+ "ajv": "^8.18.0",
66
+ "is-mergeable-object": "^1.1.1",
67
+ "@equinor/fusion-framework-module-msal": "^5.1.2"
68
+ }
69
+ ```
70
+
71
+ ### Generated Project Targets
72
+
73
+ ```json
74
+ {
75
+ "build": { "executor": "@equinor/roma-nx-plugin:build" },
76
+ "serve": { "executor": "@equinor/roma-nx-plugin:serve", "options": { "port": 3000 } },
77
+ "portal": { "executor": "@equinor/roma-nx-plugin:portal" },
78
+ "publish": {
79
+ "executor": "@equinor/roma-nx-plugin:publish",
80
+ "dependsOn": ["build"],
81
+ "configurations": {
82
+ "production": { "environment": "production" },
83
+ "qa": { "environment": "qa" },
84
+ "dev": { "environment": "dev" }
85
+ },
86
+ "defaultConfiguration": "dev"
87
+ }
88
+ }
89
+ ```
90
+
91
+ ### Generated Files
92
+
93
+ #### `package.json`
94
+
95
+ Contains a `roma` metadata section used by the workbench to register the app:
96
+
97
+ ```json
98
+ {
99
+ "main": "src/index.ts",
100
+ "type": "module",
101
+ "name": "<app-name>",
102
+ "version": "0.0.1",
103
+ "roma": {
104
+ "key": "<app-name>",
105
+ "shortName": "<app-name>",
106
+ "name": "<app-name>",
107
+ "description": "",
108
+ "tags": ["roma"],
109
+ "hide": false,
110
+ "order": 1,
111
+ "type": "standalone",
112
+ "accentColor": null,
113
+ "icon": null,
114
+ "categoryId": ""
115
+ }
116
+ }
117
+ ```
118
+
119
+ #### `vite.config.ts`
120
+
121
+ ```typescript
122
+ import { defineConfig } from 'vite';
123
+
124
+ export default defineConfig({
125
+ build: {
126
+ lib: {
127
+ entry: 'src/index.ts',
128
+ fileName: 'app-bundle',
129
+ formats: ['es'],
130
+ },
131
+ },
132
+ });
133
+ ```
134
+
135
+ #### `src/index.ts` — App Entry Point
136
+
137
+ This is the Fusion-compatible render function that the workbench calls to mount the app:
138
+
139
+ ```typescript
140
+ import { createElement } from 'react';
141
+ import { createRoot } from 'react-dom/client';
142
+
143
+ import {
144
+ RomaComponentRenderArgs as ComponentRenderArgs,
145
+ makeComponent,
146
+ } from '@equinor/roma-framework';
147
+
148
+ import configure from './config';
149
+ import App from './App';
150
+
151
+ export const renderApp = (el: HTMLElement, args: ComponentRenderArgs) => {
152
+ const appComponent = createElement(App, args.env);
153
+ const createApp = (args: ComponentRenderArgs) => makeComponent(appComponent, args, configure);
154
+ const app = createApp(args);
155
+ const root = createRoot(el);
156
+ root.render(createElement(app));
157
+
158
+ /** Teardown */
159
+ return () => root.unmount();
160
+ };
161
+
162
+ export default renderApp;
163
+ ```
164
+
165
+ #### `src/config.ts` — Service Configuration
166
+
167
+ This is where services are registered. See `services.md` for full details.
168
+
169
+ ```typescript
170
+ import type { AppModuleInitiator } from '@equinor/fusion-framework-react-app';
171
+ // With routing:
172
+ // import { enableNavigation } from '@equinor/fusion-framework-module-navigation';
173
+
174
+ export const configure: AppModuleInitiator = (configurator, env) => {
175
+ /** enable portal service */
176
+ configurator.useFrameworkServiceClient('portal');
177
+
178
+ // With routing:
179
+ // enableNavigation(configurator, '/apps/<app-name>');
180
+
181
+ configurator.onConfigured((config) => {
182
+ console.log('application config created', config);
183
+ });
184
+
185
+ configurator.onInitialized((instance) => {
186
+ console.log('application config initialized', instance);
187
+ });
188
+ };
189
+
190
+ export default configure;
191
+ ```
192
+
193
+ #### `src/App.tsx` — Root Component
194
+
195
+ The default template (non-minimal, no routing) uses EDS components:
196
+
197
+ ```tsx
198
+ import { Card, Typography, Button, Icon } from '@equinor/eds-core-react';
199
+ import { more_vertical } from '@equinor/eds-icons';
200
+
201
+ export const App = (props: Record<string, unknown>) => {
202
+ return (
203
+ <Card>
204
+ <Card.Header>
205
+ <Card.HeaderTitle>
206
+ <Typography variant="h5">
207
+ Welcome to <app-name>
208
+ </Typography>
209
+ </Card.HeaderTitle>
210
+ <Button variant="ghost_icon">
211
+ <Icon data={more_vertical} size={24} title="more action" />
212
+ </Button>
213
+ </Card.Header>
214
+ <Card.Content>
215
+ <Typography variant="body_short">
216
+ This application is built with
217
+ <Typography variant="body_short_link" as="a" href="https://nx.dev/">NX</Typography>
218
+ to work within
219
+ <Typography variant="body_short_link" as="a" href="https://roma.equinor.com">Roma Workbench</Typography>
220
+ using
221
+ <Typography variant="body_short_link" as="a" href="https://equinor.github.io/fusion-framework/">Fusion</Typography>
222
+ </Typography>
223
+ </Card.Content>
224
+ </Card>
225
+ )
226
+ }
227
+
228
+ export default App;
229
+ ```
230
+
231
+ With `--routing`, uses `useAppModule<NavigationModule>('navigation')` and `RouterProvider`.
232
+
233
+ #### `eslint.config.js`
234
+
235
+ Full flat ESLint config with:
236
+ - `@nx/eslint-plugin` base, typescript, javascript, react configs
237
+ - React version pinned to `18`
238
+ - Prettier integration
239
+ - Rules: `type` over `interface`, generic array syntax, PascalCase JSX, destructure props, no array index keys
240
+ - Module boundary enforcement
241
+
242
+ ---
243
+
244
+ ## Preset Generator
245
+
246
+ Wraps the app generator to initialize a full Roma NX workspace. Delegates entirely to the app generator after normalizing options:
247
+
248
+ ```sh
249
+ nx g @equinor/roma:preset my-workspace
250
+ ```
251
+
252
+ Sets `directory` to `apps/{name}`, style to `styled-components`, and adds React `^18.3.1` as a dependency.
253
+
254
+ ---
255
+
256
+ ## Component Test Generator
257
+
258
+ Adds Cypress component testing to an existing Roma app:
259
+
260
+ ```sh
261
+ nx g @equinor/roma:component-test --project=my-app
262
+ ```
263
+
264
+ ### Preconditions
265
+
266
+ - Project must be an **application** (not a library)
267
+ - Must use `@equinor/roma-nx-plugin:build` executor
268
+ - Must not already have a `component-test` target
269
+
270
+ ### What It Generates
271
+
272
+ 1. A `component-test` target using `@equinor/roma-nx-plugin:component-test`
273
+ 2. `cypress.config.ts` with Vite bundler, istanbul code coverage, and React support
274
+ 3. `cypress/support/` directory with commands, component setup, and `@cypress/code-coverage`
275
+ 4. `cypress/fixtures/example.json`
276
+ 5. Empty directories for downloads, screenshots, and videos
277
+
278
+ ### Dependencies Added
279
+
280
+ ```json
281
+ {
282
+ "@cypress/code-coverage": "^3.13.1",
283
+ "cypress": "^13.14.2",
284
+ "vite-plugin-istanbul": "^6.0.2"
285
+ }
286
+ ```
287
+
288
+ ### Cypress Config
289
+
290
+ ```typescript
291
+ import { defineConfig } from 'cypress';
292
+ import react from '@vitejs/plugin-react';
293
+ import istanbul from 'vite-plugin-istanbul';
294
+ import cc from '@cypress/code-coverage/task';
295
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
296
+
297
+ export default defineConfig({
298
+ component: {
299
+ video: true,
300
+ setupNodeEvents(on, config) {
301
+ cc(on, config);
302
+ return config;
303
+ },
304
+ devServer: {
305
+ framework: 'react',
306
+ bundler: 'vite',
307
+ viteConfig: { /* ... */ },
308
+ },
309
+ },
310
+ });
311
+ ```
312
+
313
+ ### Test Wrapper
314
+
315
+ For component tests that need the Fusion framework context, use the test wrapper exported from `@equinor/roma-framework/cypress`:
316
+
317
+ ```typescript
318
+ import { mount } from 'cypress/react18';
319
+ // Cypress.Commands.add('mount', mount) is set up in support/component.ts
320
+ ```
321
+
322
+ ---
323
+
324
+ ## Skill Generator
325
+
326
+ Adds the Roma development skill files for AI assistants (Claude, Copilot, etc.) to the repository:
327
+
328
+ ```sh
329
+ nx g @equinor/roma-nx-plugin:skill
330
+ ```
331
+
332
+ ### Options
333
+
334
+ | Option | Default | Description |
335
+ |--------|---------|-------------|
336
+ | `directory` | `.claude/skills` | Target directory for the skill files |
337
+
338
+ ### What It Generates
339
+
340
+ Creates `{directory}/roma-app-development/` containing:
341
+
342
+ - `SKILL.md` — Skill entry point and overview
343
+ - `generators.md` — This file (generator reference)
344
+ - `services.md` — Service registration and data fetching patterns
345
+
346
+ Re-running the generator overwrites existing files, which is the intended way to update the skill to the latest version.
347
+
348
+ ---
349
+
350
+ ## Post-Generation Steps
351
+
352
+ After generating a new app:
353
+
354
+ 1. **Register it** in `apps/workbench/mock/app-registry.ts` (for local development)
355
+ 2. **Add services** in `src/config.ts` (see `services.md`)
356
+ 3. **Run the workbench** (`nx serve workbench`) before serving the app
357
+ 4. **Serve the app**: `nx serve <app-name>`