@equinor/roma-nx-plugin 1.0.0 → 1.1.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/.eslintrc.json +37 -0
- package/CHANGELOG.md +17 -0
- package/executors.json +5 -0
- package/generators.json +5 -0
- package/jest.config.ts +13 -0
- package/manifest-schema.json +80 -0
- package/package.json +4 -4
- package/project.json +65 -0
- package/src/executors/build/build.ts +100 -0
- package/src/executors/build/executor.spec.ts +13 -0
- package/src/executors/build/executor.ts +10 -0
- package/src/executors/build/minify.ts +20 -0
- package/src/executors/component-test/executor.spec.ts +18 -0
- package/src/executors/component-test/executor.ts +57 -0
- package/src/executors/component-test/schema.d.ts +5 -0
- package/src/executors/component-test/schema.json +25 -0
- package/src/executors/create-vite-config.ts +133 -0
- package/src/executors/executor-context.ts +102 -0
- package/src/executors/publish/executor.ts +29 -0
- package/src/executors/publish/manifest-model.ts +33 -0
- package/src/executors/publish/publish-script.spec.ts +118 -0
- package/src/executors/publish/publish-script.ts +210 -0
- package/src/executors/serve/executor.ts +19 -0
- package/src/executors/serve/get-manifest.ts +20 -0
- package/src/executors/serve/schema.d.ts +2 -0
- package/src/executors/serve/schema.json +7 -0
- package/src/executors/serve/server.ts +250 -0
- package/src/executors/utils/get-vite-config.ts +9 -0
- package/src/executors/utils/logger.ts +90 -0
- package/src/generators/app/data/modules.ts +19 -0
- package/src/generators/app/generator.spec.ts +86 -0
- package/src/generators/app/generator.ts +141 -0
- package/src/generators/component-test/files/cypress/fixtures/example.json +5 -0
- package/src/generators/component-test/files/cypress/screenshots/.gitkeep +0 -0
- package/src/generators/component-test/files/cypress/support/commands.ts +37 -0
- package/src/generators/component-test/files/cypress/support/component-index.html +12 -0
- package/src/generators/component-test/files/cypress/support/component.ts +39 -0
- package/src/generators/component-test/files/cypress/videos/.gitkeep +0 -0
- package/src/generators/component-test/files/cypress.config.ts.template +43 -0
- package/src/generators/component-test/generator.spec.ts +79 -0
- package/src/generators/component-test/generator.ts +67 -0
- package/src/generators/component-test/schema.d.ts +3 -0
- package/src/generators/component-test/schema.json +17 -0
- package/src/generators/preset/generator.spec.ts +38 -0
- package/src/generators/preset/generator.ts +18 -0
- package/src/index.ts +1 -0
- package/src/migrations/add-publish-target/add-publish-target.spec.ts +60 -0
- package/src/migrations/add-publish-target/add-publish-target.ts +28 -0
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.ts +35 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.ts +70 -0
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.spec.json +26 -0
- package/vite.config.ts +31 -0
- package/src/executors/build/build.d.ts +0 -4
- package/src/executors/build/build.js +0 -76
- package/src/executors/build/build.js.map +0 -1
- package/src/executors/build/executor.d.ts +0 -5
- package/src/executors/build/executor.js +0 -8
- package/src/executors/build/executor.js.map +0 -1
- package/src/executors/build/minify.d.ts +0 -2
- package/src/executors/build/minify.js +0 -22
- package/src/executors/build/minify.js.map +0 -1
- package/src/executors/create-vite-config.d.ts +0 -3
- package/src/executors/create-vite-config.js +0 -73
- package/src/executors/create-vite-config.js.map +0 -1
- package/src/executors/executor-context.d.ts +0 -2
- package/src/executors/executor-context.js +0 -101
- package/src/executors/executor-context.js.map +0 -1
- package/src/executors/publish/executor.d.ts +0 -5
- package/src/executors/publish/executor.js +0 -24
- package/src/executors/publish/executor.js.map +0 -1
- package/src/executors/publish/manifest-model.d.ts +0 -30
- package/src/executors/publish/manifest-model.js +0 -3
- package/src/executors/publish/manifest-model.js.map +0 -1
- package/src/executors/publish/publish-script.d.ts +0 -9
- package/src/executors/publish/publish-script.js +0 -185
- package/src/executors/publish/publish-script.js.map +0 -1
- package/src/executors/serve/executor.d.ts +0 -3
- package/src/executors/serve/executor.js +0 -8
- package/src/executors/serve/executor.js.map +0 -1
- package/src/executors/serve/get-manifest.d.ts +0 -2
- package/src/executors/serve/get-manifest.js +0 -20
- package/src/executors/serve/get-manifest.js.map +0 -1
- package/src/executors/serve/server.d.ts +0 -3
- package/src/executors/serve/server.js +0 -166
- package/src/executors/serve/server.js.map +0 -1
- package/src/executors/utils/get-vite-config.d.ts +0 -1
- package/src/executors/utils/get-vite-config.js +0 -13
- package/src/executors/utils/get-vite-config.js.map +0 -1
- package/src/executors/utils/logger.d.ts +0 -24
- package/src/executors/utils/logger.js +0 -68
- package/src/executors/utils/logger.js.map +0 -1
- package/src/generators/app/data/modules.d.ts +0 -19
- package/src/generators/app/data/modules.js +0 -23
- package/src/generators/app/data/modules.js.map +0 -1
- package/src/generators/app/generator.d.ts +0 -5
- package/src/generators/app/generator.js +0 -101
- package/src/generators/app/generator.js.map +0 -1
- package/src/generators/preset/generator.d.ts +0 -4
- package/src/generators/preset/generator.js +0 -13
- package/src/generators/preset/generator.js.map +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +0 -1
- package/src/migrations/add-publish-target/add-publish-target.d.ts +0 -2
- package/src/migrations/add-publish-target/add-publish-target.js +0 -32
- package/src/migrations/add-publish-target/add-publish-target.js.map +0 -1
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.d.ts +0 -2
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.js +0 -30
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.js.map +0 -1
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.d.ts +0 -2
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js +0 -48
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js.map +0 -1
- /package/src/{index.d.ts → generators/component-test/files/cypress/downloads/.gitkeep} +0 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*", "generators/**/files"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"files": ["*.json"],
|
|
19
|
+
"parser": "jsonc-eslint-parser",
|
|
20
|
+
"rules": {
|
|
21
|
+
"@nx/dependency-checks": "warn"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"files": [
|
|
26
|
+
"./package.json",
|
|
27
|
+
"./generators.json",
|
|
28
|
+
"./executors.json",
|
|
29
|
+
"./migrations.json"
|
|
30
|
+
],
|
|
31
|
+
"parser": "jsonc-eslint-parser",
|
|
32
|
+
"rules": {
|
|
33
|
+
"@nx/nx-plugin-checks": "error"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [1.1.0](https://github.com/equinor/tops-roma/compare/roma-1.0.0...roma-1.1.0) (2024-12-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **ROMA-183:** Some adjustments / fixes for ts ([#299](https://github.com/equinor/tops-roma/issues/299)) ([c6379b2](https://github.com/equinor/tops-roma/commit/c6379b2d5c29c3eabeb0b115756a2965bbdeaf01))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **ROMA-149:** Test filter function ([#284](https://github.com/equinor/tops-roma/issues/284)) ([b4b7857](https://github.com/equinor/tops-roma/commit/b4b7857778893fccb27ea2f5187b1dd2fb95a004))
|
|
16
|
+
* **ROMA-159:** cut release ([#240](https://github.com/equinor/tops-roma/issues/240)) ([b6061a0](https://github.com/equinor/tops-roma/commit/b6061a09797e5ef4ca557d8d1a8a973be1ad6edc))
|
|
17
|
+
* **ROMA-183:** Introduce Cypress capabilities ([#294](https://github.com/equinor/tops-roma/issues/294)) ([6135ca3](https://github.com/equinor/tops-roma/commit/6135ca321adfde5a873d533e4d4677eee87f77b2))
|
|
18
|
+
* **ROMA-187:** Enable application multi-serve ([#320](https://github.com/equinor/tops-roma/issues/320)) ([f992c4b](https://github.com/equinor/tops-roma/commit/f992c4bfdd375fa6856a4be0cae00abbdc2fa61a))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
5
22
|
# [1.0.0](https://github.com/equinor/tops-roma/compare/roma-0.0.30...roma-1.0.0) (2024-08-09)
|
|
6
23
|
|
|
7
24
|
|
package/executors.json
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"implementation": "./src/executors/publish/executor",
|
|
15
15
|
"schema": "./src/executors/publish/schema.json",
|
|
16
16
|
"description": "Executor that allows publishing applications to the roma workbench"
|
|
17
|
+
},
|
|
18
|
+
"component-test": {
|
|
19
|
+
"implementation": "./src/executors/component-test/executor",
|
|
20
|
+
"schema": "./src/executors/component-test/schema.json",
|
|
21
|
+
"description": "Run cypress component tests"
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
}
|
package/generators.json
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
"schema": "./src/generators/preset/schema.json",
|
|
11
11
|
"description": "Initialize a roma nx workspace",
|
|
12
12
|
"x-use-standalone-layout": true
|
|
13
|
+
},
|
|
14
|
+
"component-test": {
|
|
15
|
+
"factory": "./src/generators/component-test/generator",
|
|
16
|
+
"schema": "./src/generators/component-test/schema.json",
|
|
17
|
+
"description": "Generate component-test setup for project"
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
}
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: 'roma',
|
|
4
|
+
preset: '../../jest.preset.js',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
9
|
+
coverageDirectory: '../../coverage/plugins/roma',
|
|
10
|
+
globals: {
|
|
11
|
+
Uint8Array: Uint8Array,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://roma.equinor.com/schema.json",
|
|
4
|
+
"title": "Fusion manifest",
|
|
5
|
+
"description": "Schema defining fusion's manifest layout",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"key": {
|
|
9
|
+
"description": "Unique key for your application",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"example": "my-app-key"
|
|
12
|
+
},
|
|
13
|
+
"version": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"example": "0.0.1",
|
|
16
|
+
"description": "Required. Version of your application in semver (major.minor.patch)"
|
|
17
|
+
},
|
|
18
|
+
"shortName": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"example": "shortName",
|
|
21
|
+
"description": "Required. shortName for your application"
|
|
22
|
+
},
|
|
23
|
+
"name": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"example": "Application name",
|
|
26
|
+
"description": "Required. Name shown to users for your app"
|
|
27
|
+
},
|
|
28
|
+
"description": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"example": "Application description",
|
|
31
|
+
"description": "Required. A description of your application, shown in tooltips etc"
|
|
32
|
+
},
|
|
33
|
+
"tags": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"example": [],
|
|
36
|
+
"description": "A list of tags to group your applications. Will typically be used to show related apps"
|
|
37
|
+
},
|
|
38
|
+
"hide": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"example": false,
|
|
41
|
+
"description": "if the application should be navigated to via the sidebar, or if it can only be opened via other applications"
|
|
42
|
+
},
|
|
43
|
+
"order": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"example": 1,
|
|
46
|
+
"description": "Desired order within the category."
|
|
47
|
+
},
|
|
48
|
+
"type": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"example": "standalone",
|
|
51
|
+
"description": "standalone | widget. standalone is apps, widgets are meant to be embedded via the frontpage."
|
|
52
|
+
},
|
|
53
|
+
"accentColor": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"example": "#007079",
|
|
56
|
+
"description": "Not in use by us at the moment."
|
|
57
|
+
},
|
|
58
|
+
"icon": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"example": "M16...",
|
|
61
|
+
"description": "SVG path string from your app icon (not the entire svg, just the path). Falls back to category icon"
|
|
62
|
+
},
|
|
63
|
+
"categoryId": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"example": "guid",
|
|
66
|
+
"description": "Required. ID to categorize your application. TODO: Waiting for lookup list "
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": [
|
|
70
|
+
"key",
|
|
71
|
+
"version",
|
|
72
|
+
"shortName",
|
|
73
|
+
"name",
|
|
74
|
+
"description",
|
|
75
|
+
"hide",
|
|
76
|
+
"order",
|
|
77
|
+
"type",
|
|
78
|
+
"categoryId"
|
|
79
|
+
]
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/roma-nx-plugin",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"repository": "https://github.com/equinor/tops-roma",
|
|
6
6
|
"dependencies": {
|
|
7
|
+
"@nx/devkit": "19.5.6",
|
|
7
8
|
"get-port-cjs": "6.1.3",
|
|
8
9
|
"open": "^8.4.2",
|
|
9
10
|
"chalk": "^4.0.0",
|
|
@@ -34,6 +35,5 @@
|
|
|
34
35
|
"executors": "./executors.json",
|
|
35
36
|
"nx-migrations": {
|
|
36
37
|
"migrations": "./migrations.json"
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "roma",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "plugins/roma/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "@nx/js:tsc",
|
|
9
|
+
"outputs": ["{options.outputPath}"],
|
|
10
|
+
"options": {
|
|
11
|
+
"outputPath": "dist/plugins/roma",
|
|
12
|
+
"main": "plugins/roma/src/index.ts",
|
|
13
|
+
"tsConfig": "plugins/roma/tsconfig.lib.json",
|
|
14
|
+
"assets": [
|
|
15
|
+
"plugins/roma/*.md",
|
|
16
|
+
{
|
|
17
|
+
"input": "./plugins/roma/src",
|
|
18
|
+
"glob": "**/!(*.ts)",
|
|
19
|
+
"output": "./src"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"input": "./plugins/roma/src",
|
|
23
|
+
"glob": "**/*.d.ts",
|
|
24
|
+
"output": "./src"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"input": "./plugins/roma",
|
|
28
|
+
"glob": "generators.json",
|
|
29
|
+
"output": "."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"input": "./plugins/roma",
|
|
33
|
+
"glob": "executors.json",
|
|
34
|
+
"output": "."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"input": "./plugins/roma",
|
|
38
|
+
"glob": "migrations.json",
|
|
39
|
+
"output": "."
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"publish": {
|
|
45
|
+
"command": "node tools/scripts/publish.mjs roma {args.ver} {args.tag}",
|
|
46
|
+
"dependsOn": ["build"]
|
|
47
|
+
},
|
|
48
|
+
"lint": {
|
|
49
|
+
"executor": "@nx/eslint:lint",
|
|
50
|
+
"outputs": ["{options.outputFile}"]
|
|
51
|
+
},
|
|
52
|
+
"test": {
|
|
53
|
+
"executor": "@nx/vite:test",
|
|
54
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"]
|
|
55
|
+
},
|
|
56
|
+
"version": {
|
|
57
|
+
"executor": "@jscutlery/semver:version",
|
|
58
|
+
"options": {
|
|
59
|
+
"preset": "angular",
|
|
60
|
+
"push": true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"tags": ["plugin"]
|
|
65
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRomaViteConfig } from '../create-vite-config';
|
|
2
|
+
import { build, loadConfigFromFile } from 'vite';
|
|
3
|
+
import { parse as parseSemver } from 'semver';
|
|
4
|
+
import { readdirSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { ExecutorContext, readJsonFile } from '@nx/devkit';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { RollupWatcher } from 'rollup';
|
|
9
|
+
import { Logger } from '../utils/logger';
|
|
10
|
+
import { Manifest, ManifestFile } from '../publish/manifest-model';
|
|
11
|
+
import { PackageJson } from 'nx/src/utils/package-json';
|
|
12
|
+
|
|
13
|
+
const logger = new Logger();
|
|
14
|
+
|
|
15
|
+
function getViteConfig(root: string) {
|
|
16
|
+
const files = readdirSync(root);
|
|
17
|
+
const file = files.find((f) => f.startsWith('vite.config'));
|
|
18
|
+
if (!file) throw new Error(`No vite config found!`);
|
|
19
|
+
return resolve(root, file);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default async function (
|
|
23
|
+
context: ExecutorContext,
|
|
24
|
+
watch = false
|
|
25
|
+
): Promise<{ success: boolean }> {
|
|
26
|
+
const projectName = context.projectName;
|
|
27
|
+
const project = context.workspace.projects[projectName];
|
|
28
|
+
const base = resolve(context.root, project.root);
|
|
29
|
+
// const viteConfigPath = resolve(base, 'vite.config.ts');
|
|
30
|
+
const viteConfigPath = getViteConfig(base);
|
|
31
|
+
const userConfig = await loadConfigFromFile(
|
|
32
|
+
{
|
|
33
|
+
command: 'build',
|
|
34
|
+
mode: 'production',
|
|
35
|
+
},
|
|
36
|
+
viteConfigPath
|
|
37
|
+
);
|
|
38
|
+
const viteConfig = userConfig.config;
|
|
39
|
+
|
|
40
|
+
const config = createRomaViteConfig(viteConfig, context, watch);
|
|
41
|
+
console.log(JSON.stringify(config, null, 2));
|
|
42
|
+
|
|
43
|
+
const normalizeVersion = (version: string) => {
|
|
44
|
+
const semverVersion = parseSemver(version);
|
|
45
|
+
|
|
46
|
+
const { major, minor, patch } = semverVersion;
|
|
47
|
+
return { major, minor, patch };
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const result = await build(config).then((r) => {
|
|
51
|
+
const out = config.build.outDir;
|
|
52
|
+
let manifest: ManifestFile;
|
|
53
|
+
try {
|
|
54
|
+
const packageJson = readJsonFile(
|
|
55
|
+
join(config.root, 'package.json')
|
|
56
|
+
) as PackageJson & { roma?: Manifest };
|
|
57
|
+
if (packageJson.roma) {
|
|
58
|
+
manifest = {
|
|
59
|
+
...packageJson.roma,
|
|
60
|
+
version: packageJson.version,
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
manifest = readJsonFile(join(config.root, 'fusion-manifest.json'));
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
manifest = readJsonFile(join(config.root, 'fusion-manifest.json'));
|
|
67
|
+
}
|
|
68
|
+
const normalizedVersion = normalizeVersion(manifest.version);
|
|
69
|
+
writeFileSync(
|
|
70
|
+
join(out, 'manifest.json'),
|
|
71
|
+
JSON.stringify(
|
|
72
|
+
{
|
|
73
|
+
...manifest,
|
|
74
|
+
version: normalizedVersion,
|
|
75
|
+
},
|
|
76
|
+
null,
|
|
77
|
+
2
|
|
78
|
+
),
|
|
79
|
+
'utf8'
|
|
80
|
+
);
|
|
81
|
+
return r as unknown as RollupWatcher;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
if (watch) {
|
|
86
|
+
result.on('change', (e) => logger.info(e));
|
|
87
|
+
result.on('close', () => {
|
|
88
|
+
logger.info('Stopping watch');
|
|
89
|
+
resolve({ success: true });
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
resolve({ success: true });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
} catch (ex) {
|
|
96
|
+
logger.error(`Failed to build ${projectName}:`);
|
|
97
|
+
logger.error(ex);
|
|
98
|
+
return { success: false };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BuildExecutorSchema } from './schema';
|
|
2
|
+
import executor from './executor';
|
|
3
|
+
import { executorContext } from '../executor-context';
|
|
4
|
+
import { it, describe, expect } from 'vitest';
|
|
5
|
+
|
|
6
|
+
const options: BuildExecutorSchema = {};
|
|
7
|
+
|
|
8
|
+
describe('Build Executor', () => {
|
|
9
|
+
it('can build a project', async () => {
|
|
10
|
+
const output = await executor(options, executorContext);
|
|
11
|
+
expect(output.success).toBe(true);
|
|
12
|
+
}, 20_000); // Long timeout
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuildExecutorSchema } from './schema';
|
|
2
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
3
|
+
import build from './build';
|
|
4
|
+
|
|
5
|
+
export default async function runExecutor(
|
|
6
|
+
options: BuildExecutorSchema,
|
|
7
|
+
context: ExecutorContext
|
|
8
|
+
) {
|
|
9
|
+
return build(context, options.watch);
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { transform } from 'esbuild';
|
|
3
|
+
|
|
4
|
+
export function minifyEs() {
|
|
5
|
+
return {
|
|
6
|
+
name: 'minifyEs',
|
|
7
|
+
renderChunk: {
|
|
8
|
+
order: 'post',
|
|
9
|
+
async handler(code, chunk, outputOptions) {
|
|
10
|
+
if (outputOptions.format === 'es') {
|
|
11
|
+
return await transform(code, {
|
|
12
|
+
minifyWhitespace: true,
|
|
13
|
+
minifySyntax: true,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return code;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
} as Plugin;
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
|
|
3
|
+
import { ComponentTestExecutorSchema } from './schema';
|
|
4
|
+
import executor from './executor';
|
|
5
|
+
|
|
6
|
+
const options: ComponentTestExecutorSchema = {};
|
|
7
|
+
const context: ExecutorContext = {
|
|
8
|
+
root: '',
|
|
9
|
+
cwd: process.cwd(),
|
|
10
|
+
isVerbose: false,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe('ComponentTest Executor', () => {
|
|
14
|
+
it('can run', async () => {
|
|
15
|
+
const output = await executor(options, context);
|
|
16
|
+
expect(output.success).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { PromiseExecutor } from '@nx/devkit';
|
|
3
|
+
import { ComponentTestExecutorSchema } from './schema';
|
|
4
|
+
const cypress = require('cypress');
|
|
5
|
+
// import cypress from 'cypress';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { exec as execCb } from 'node:child_process';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { execCommand } from 'nx/src/command-line/release/utils/exec-command';
|
|
10
|
+
|
|
11
|
+
const exec = promisify(execCb);
|
|
12
|
+
|
|
13
|
+
const runExecutor: PromiseExecutor<ComponentTestExecutorSchema> = async (
|
|
14
|
+
options,
|
|
15
|
+
context
|
|
16
|
+
) => {
|
|
17
|
+
const { projectName, projectsConfigurations, root } = context;
|
|
18
|
+
const workdir = join(root, projectsConfigurations.projects[projectName].root);
|
|
19
|
+
let success = true;
|
|
20
|
+
const config = {
|
|
21
|
+
project: workdir,
|
|
22
|
+
quiet: options.quiet,
|
|
23
|
+
testingType: 'component',
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
const testRun = await (options.watch
|
|
27
|
+
? cypress.open(config)
|
|
28
|
+
: cypress.run(config));
|
|
29
|
+
if (testRun.totalFailed > 0) success = false;
|
|
30
|
+
const report = testRun.runs.map((run) => {
|
|
31
|
+
const { start, end, ...stats } = run.reporterStats;
|
|
32
|
+
return {
|
|
33
|
+
name: run.spec.name,
|
|
34
|
+
...stats,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
console.table(report);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error(err);
|
|
40
|
+
success = false;
|
|
41
|
+
}
|
|
42
|
+
if (success && options.coverage) {
|
|
43
|
+
process.chdir(workdir);
|
|
44
|
+
const r = await exec(`npx nyc report --reporter=text-summary`);
|
|
45
|
+
console.log(r.stdout);
|
|
46
|
+
}
|
|
47
|
+
console.log(
|
|
48
|
+
success
|
|
49
|
+
? `Successfully ran component tests`
|
|
50
|
+
: `Failed to run component tests`
|
|
51
|
+
);
|
|
52
|
+
return {
|
|
53
|
+
success,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default runExecutor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "ComponentTest executor",
|
|
5
|
+
"description": "",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"quiet": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"description": "Whether to suppress cypress output. Default false",
|
|
11
|
+
"default": false
|
|
12
|
+
},
|
|
13
|
+
"watch": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"description": "Whether to run the tests in headed mode. Default false",
|
|
16
|
+
"default": false
|
|
17
|
+
},
|
|
18
|
+
"coverage": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "Whether to log out coverage information. Default false",
|
|
21
|
+
"default": false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": []
|
|
25
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defineConfig, UserConfig, mergeConfig, LibraryOptions } from 'vite';
|
|
2
|
+
import ViteRestart from 'vite-plugin-restart';
|
|
3
|
+
import viteEnv from 'vite-plugin-environment';
|
|
4
|
+
import { resolve, join } from 'path';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import { Logger } from './utils/logger';
|
|
7
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
8
|
+
import { TargetConfiguration } from 'nx/src/config/workspace-json-project-json';
|
|
9
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
10
|
+
import { minifyEs } from './build/minify';
|
|
11
|
+
import { ServeExecutorSchema } from './serve/schema';
|
|
12
|
+
|
|
13
|
+
type BuildConfiguration = TargetConfiguration & {
|
|
14
|
+
outputPath?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const createRomaViteConfig = (
|
|
18
|
+
config: UserConfig,
|
|
19
|
+
context: ExecutorContext,
|
|
20
|
+
watch = false,
|
|
21
|
+
hmrPort = 42000
|
|
22
|
+
) => {
|
|
23
|
+
const isServe = context.targetName === 'serve';
|
|
24
|
+
const projectName = context.projectName;
|
|
25
|
+
const project = context.workspace.projects[projectName];
|
|
26
|
+
const workspaceRoot = context.root;
|
|
27
|
+
const serveConfig = project.targets.serve;
|
|
28
|
+
const options = serveConfig.options as ServeExecutorSchema;
|
|
29
|
+
let base: string;
|
|
30
|
+
let entry: string | Record<string, string>;
|
|
31
|
+
let viteConfigPath: string;
|
|
32
|
+
let projectRoot = project.root;
|
|
33
|
+
let appDir = '';
|
|
34
|
+
if (isServe) {
|
|
35
|
+
const [appDirectory, ...rest] = projectRoot.split('/');
|
|
36
|
+
projectRoot = rest.join('/');
|
|
37
|
+
appDir = appDirectory;
|
|
38
|
+
base = resolve(context.root, appDirectory);
|
|
39
|
+
entry = {
|
|
40
|
+
self: join(projectRoot, 'src/index.ts'),
|
|
41
|
+
};
|
|
42
|
+
viteConfigPath = resolve(base, projectRoot, 'vite.config.ts');
|
|
43
|
+
} else {
|
|
44
|
+
base = resolve(context.root, projectRoot);
|
|
45
|
+
entry = '/src/index.ts';
|
|
46
|
+
viteConfigPath = resolve(base, 'vite.config.ts');
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
isServe &&
|
|
50
|
+
options.additionalProjects &&
|
|
51
|
+
options.additionalProjects.length > 0
|
|
52
|
+
) {
|
|
53
|
+
options.additionalProjects.forEach((project) => {
|
|
54
|
+
const projectConfig = context.workspace.projects[project];
|
|
55
|
+
const path = join(
|
|
56
|
+
projectConfig.root.replace(appDir + '/', ''),
|
|
57
|
+
'src',
|
|
58
|
+
'index.ts'
|
|
59
|
+
);
|
|
60
|
+
console.log('Adding project', path, 'to server-list');
|
|
61
|
+
entry[`${project}`] = path;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const buildConfig = project.targets.build as BuildConfiguration;
|
|
65
|
+
const outputPath = buildConfig.outputPath ?? `dist/apps/${projectName}`;
|
|
66
|
+
|
|
67
|
+
const devPortalPath = resolve(
|
|
68
|
+
process.cwd(),
|
|
69
|
+
'node_modules/@equinor/roma-framework/dev-portal'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (!config.build) {
|
|
73
|
+
config.build = {
|
|
74
|
+
lib: {
|
|
75
|
+
entry: 'src/index.ts',
|
|
76
|
+
fileName: 'app-bundle',
|
|
77
|
+
formats: ['es'],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
(config.build.lib as LibraryOptions).entry = entry;
|
|
82
|
+
|
|
83
|
+
const minifyPlugin = [];
|
|
84
|
+
|
|
85
|
+
if (config.build.minify) {
|
|
86
|
+
minifyPlugin.push(minifyEs());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const build = context.targetName === 'build';
|
|
90
|
+
const romaConfig = {
|
|
91
|
+
customLogger: new Logger(),
|
|
92
|
+
cacheDir: resolve(
|
|
93
|
+
context.root,
|
|
94
|
+
'node_modules',
|
|
95
|
+
'.vite',
|
|
96
|
+
context.projectName
|
|
97
|
+
),
|
|
98
|
+
assetsInclude: [`${devPortalPath}/roma-framework.umd.js`],
|
|
99
|
+
root: base,
|
|
100
|
+
server: {
|
|
101
|
+
middlewareMode: true,
|
|
102
|
+
hmr: {
|
|
103
|
+
port: hmrPort,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
appType: 'custom',
|
|
107
|
+
define: {
|
|
108
|
+
'process.env': {},
|
|
109
|
+
},
|
|
110
|
+
build: {
|
|
111
|
+
outDir: resolve(workspaceRoot, outputPath),
|
|
112
|
+
watch: watch
|
|
113
|
+
? {
|
|
114
|
+
clearScreen: true,
|
|
115
|
+
}
|
|
116
|
+
: undefined,
|
|
117
|
+
},
|
|
118
|
+
plugins: [
|
|
119
|
+
react(),
|
|
120
|
+
nxViteTsPaths(),
|
|
121
|
+
viteEnv({
|
|
122
|
+
NODE_ENV: build ? 'production' : 'development',
|
|
123
|
+
}),
|
|
124
|
+
ViteRestart({
|
|
125
|
+
restart: ['package.json', viteConfigPath].filter(
|
|
126
|
+
(x): x is string => !!x
|
|
127
|
+
),
|
|
128
|
+
}),
|
|
129
|
+
...minifyPlugin,
|
|
130
|
+
],
|
|
131
|
+
} as UserConfig;
|
|
132
|
+
return defineConfig(mergeConfig(config, romaConfig));
|
|
133
|
+
};
|