@equinor/roma-nx-plugin 1.0.0-BETA.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.
Files changed (114) hide show
  1. package/.eslintrc.json +37 -0
  2. package/CHANGELOG.md +42 -0
  3. package/executors.json +5 -0
  4. package/generators.json +5 -0
  5. package/jest.config.ts +13 -0
  6. package/manifest-schema.json +80 -0
  7. package/package.json +12 -11
  8. package/project.json +65 -0
  9. package/src/executors/build/build.ts +100 -0
  10. package/src/executors/build/executor.spec.ts +13 -0
  11. package/src/executors/build/executor.ts +10 -0
  12. package/src/executors/build/minify.ts +20 -0
  13. package/src/executors/component-test/executor.spec.ts +18 -0
  14. package/src/executors/component-test/executor.ts +57 -0
  15. package/src/executors/component-test/schema.d.ts +5 -0
  16. package/src/executors/component-test/schema.json +25 -0
  17. package/src/executors/create-vite-config.ts +133 -0
  18. package/src/executors/executor-context.ts +102 -0
  19. package/src/executors/publish/executor.ts +29 -0
  20. package/src/executors/publish/manifest-model.ts +33 -0
  21. package/src/executors/publish/publish-script.spec.ts +118 -0
  22. package/src/executors/publish/publish-script.ts +210 -0
  23. package/src/executors/serve/executor.ts +19 -0
  24. package/src/executors/serve/get-manifest.ts +20 -0
  25. package/src/executors/serve/schema.d.ts +2 -0
  26. package/src/executors/serve/schema.json +7 -0
  27. package/src/executors/serve/server.ts +250 -0
  28. package/src/executors/utils/get-vite-config.ts +9 -0
  29. package/src/executors/utils/logger.ts +90 -0
  30. package/src/generators/app/data/modules.ts +19 -0
  31. package/src/generators/app/generator.spec.ts +86 -0
  32. package/src/generators/app/generator.ts +141 -0
  33. package/src/generators/component-test/files/cypress/fixtures/example.json +5 -0
  34. package/src/generators/component-test/files/cypress/screenshots/.gitkeep +0 -0
  35. package/src/generators/component-test/files/cypress/support/commands.ts +37 -0
  36. package/src/generators/component-test/files/cypress/support/component-index.html +12 -0
  37. package/src/generators/component-test/files/cypress/support/component.ts +39 -0
  38. package/src/generators/component-test/files/cypress/videos/.gitkeep +0 -0
  39. package/src/generators/component-test/files/cypress.config.ts.template +43 -0
  40. package/src/generators/component-test/generator.spec.ts +79 -0
  41. package/src/generators/component-test/generator.ts +67 -0
  42. package/src/generators/component-test/schema.d.ts +3 -0
  43. package/src/generators/component-test/schema.json +17 -0
  44. package/src/generators/preset/generator.spec.ts +38 -0
  45. package/src/generators/preset/generator.ts +18 -0
  46. package/src/index.ts +1 -0
  47. package/src/migrations/add-publish-target/add-publish-target.spec.ts +60 -0
  48. package/src/migrations/add-publish-target/add-publish-target.ts +28 -0
  49. package/src/migrations/move-fusion-manifest/move-fusion-manifest.ts +35 -0
  50. package/src/migrations/remove-fusion-cli/remove-fusion-cli.ts +70 -0
  51. package/tsconfig.json +17 -0
  52. package/tsconfig.lib.json +20 -0
  53. package/tsconfig.spec.json +26 -0
  54. package/vite.config.ts +31 -0
  55. package/src/executors/build/build.d.ts +0 -4
  56. package/src/executors/build/build.js +0 -76
  57. package/src/executors/build/build.js.map +0 -1
  58. package/src/executors/build/executor.d.ts +0 -5
  59. package/src/executors/build/executor.js +0 -8
  60. package/src/executors/build/executor.js.map +0 -1
  61. package/src/executors/build/minify.d.ts +0 -2
  62. package/src/executors/build/minify.js +0 -22
  63. package/src/executors/build/minify.js.map +0 -1
  64. package/src/executors/create-vite-config.d.ts +0 -3
  65. package/src/executors/create-vite-config.js +0 -73
  66. package/src/executors/create-vite-config.js.map +0 -1
  67. package/src/executors/executor-context.d.ts +0 -2
  68. package/src/executors/executor-context.js +0 -101
  69. package/src/executors/executor-context.js.map +0 -1
  70. package/src/executors/publish/executor.d.ts +0 -5
  71. package/src/executors/publish/executor.js +0 -24
  72. package/src/executors/publish/executor.js.map +0 -1
  73. package/src/executors/publish/manifest-model.d.ts +0 -30
  74. package/src/executors/publish/manifest-model.js +0 -3
  75. package/src/executors/publish/manifest-model.js.map +0 -1
  76. package/src/executors/publish/publish-script.d.ts +0 -9
  77. package/src/executors/publish/publish-script.js +0 -185
  78. package/src/executors/publish/publish-script.js.map +0 -1
  79. package/src/executors/serve/executor.d.ts +0 -3
  80. package/src/executors/serve/executor.js +0 -8
  81. package/src/executors/serve/executor.js.map +0 -1
  82. package/src/executors/serve/get-manifest.d.ts +0 -2
  83. package/src/executors/serve/get-manifest.js +0 -20
  84. package/src/executors/serve/get-manifest.js.map +0 -1
  85. package/src/executors/serve/server.d.ts +0 -3
  86. package/src/executors/serve/server.js +0 -166
  87. package/src/executors/serve/server.js.map +0 -1
  88. package/src/executors/utils/get-vite-config.d.ts +0 -1
  89. package/src/executors/utils/get-vite-config.js +0 -13
  90. package/src/executors/utils/get-vite-config.js.map +0 -1
  91. package/src/executors/utils/logger.d.ts +0 -24
  92. package/src/executors/utils/logger.js +0 -68
  93. package/src/executors/utils/logger.js.map +0 -1
  94. package/src/generators/app/data/modules.d.ts +0 -19
  95. package/src/generators/app/data/modules.js +0 -23
  96. package/src/generators/app/data/modules.js.map +0 -1
  97. package/src/generators/app/generator.d.ts +0 -5
  98. package/src/generators/app/generator.js +0 -101
  99. package/src/generators/app/generator.js.map +0 -1
  100. package/src/generators/preset/generator.d.ts +0 -4
  101. package/src/generators/preset/generator.js +0 -13
  102. package/src/generators/preset/generator.js.map +0 -1
  103. package/src/index.js +0 -1
  104. package/src/index.js.map +0 -1
  105. package/src/migrations/add-publish-target/add-publish-target.d.ts +0 -2
  106. package/src/migrations/add-publish-target/add-publish-target.js +0 -32
  107. package/src/migrations/add-publish-target/add-publish-target.js.map +0 -1
  108. package/src/migrations/move-fusion-manifest/move-fusion-manifest.d.ts +0 -2
  109. package/src/migrations/move-fusion-manifest/move-fusion-manifest.js +0 -30
  110. package/src/migrations/move-fusion-manifest/move-fusion-manifest.js.map +0 -1
  111. package/src/migrations/remove-fusion-cli/remove-fusion-cli.d.ts +0 -2
  112. package/src/migrations/remove-fusion-cli/remove-fusion-cli.js +0 -48
  113. package/src/migrations/remove-fusion-cli/remove-fusion-cli.js.map +0 -1
  114. /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,48 @@
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
+
22
+ # [1.0.0](https://github.com/equinor/tops-roma/compare/roma-0.0.30...roma-1.0.0) (2024-08-09)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Add fusion-manifest to package.json in generator ([c099108](https://github.com/equinor/tops-roma/commit/c099108b4cdcafde2abb071c205cde286a95bc1c))
28
+ * Change how dependencies are resolved, fix outdir ([66995a1](https://github.com/equinor/tops-roma/commit/66995a1adb5dc03ce093c653e76590de0df0db18))
29
+ * Ensure generator works with derived & as-provided ([#225](https://github.com/equinor/tops-roma/issues/225)) ([fbca449](https://github.com/equinor/tops-roma/commit/fbca449c60c4e7a4581373c40c4baeb27b8ab4c5))
30
+ * lint ([e2df57e](https://github.com/equinor/tops-roma/commit/e2df57e5ee01a32a39859b35904ea3e9a7a51e80))
31
+
32
+
33
+ * chore(ROMA-159)!: Upgrade dependencies (#239) ([a8cb2dd](https://github.com/equinor/tops-roma/commit/a8cb2ddf5302b0f6b35fd998d1df897cdc778ceb)), closes [#239](https://github.com/equinor/tops-roma/issues/239)
34
+
35
+
36
+ ### Features
37
+
38
+ * **ROMA-130:** end user feedback ([#229](https://github.com/equinor/tops-roma/issues/229)) ([010ca6a](https://github.com/equinor/tops-roma/commit/010ca6af27d749dc033215a8b68e10edf40b46bd))
39
+
40
+
41
+ ### BREAKING CHANGES
42
+
43
+ * This won't work with older version of nx, and there might also be some breaking in fusion-modules
44
+
45
+
46
+
5
47
  ## [0.0.31](https://github.com/equinor/tops-roma/compare/roma-0.0.30...roma-0.0.31) (2024-07-02)
6
48
 
7
49
 
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,31 +1,33 @@
1
1
  {
2
2
  "name": "@equinor/roma-nx-plugin",
3
3
  "private": false,
4
- "version": "1.0.0-BETA.0",
4
+ "version": "1.1.0",
5
5
  "repository": "https://github.com/equinor/tops-roma",
6
6
  "dependencies": {
7
7
  "@nx/devkit": "19.5.6",
8
8
  "get-port-cjs": "6.1.3",
9
9
  "open": "^8.4.2",
10
10
  "chalk": "^4.0.0",
11
- "@nx/react": "19.5.6",
12
- "nx": "19.5.6",
13
11
  "tslib": "^2.3.0",
14
- "@azure/identity": "^3.3.0",
12
+ "@azure/identity": "^4.4.1",
15
13
  "@equinor/fusion-framework-module-service-discovery": "7.1.10",
14
+ "@equinor/fusion-framework-module-app": "^5.2.4",
16
15
  "vite": "5.2.7",
17
16
  "@vitejs/plugin-react": "4.2.1",
18
- "@nx/vite": "19.5.6",
19
17
  "vite-plugin-restart": "^0.4.0",
20
18
  "vite-plugin-environment": "^1.1.3",
21
19
  "semver": "7.6.3",
22
- "rollup": "4.14.0",
20
+ "rollup": "^4.20.0",
23
21
  "express": "^4.18.3",
24
22
  "http-proxy-middleware": "^2.0.6",
25
- "@equinor/fusion-framework-module-app": "^5.2.4",
26
23
  "esbuild": "0.20.2"
27
24
  },
28
- "peerDependencies": {},
25
+ "peerDependencies": {
26
+ "@nx/devkit": "^19.5.6",
27
+ "@nx/vite": "^19.5.6",
28
+ "@nx/react": "^19.5.6",
29
+ "nx": "^19.5.6"
30
+ },
29
31
  "type": "commonjs",
30
32
  "main": "./src/index.js",
31
33
  "typings": "./src/index.d.ts",
@@ -33,6 +35,5 @@
33
35
  "executors": "./executors.json",
34
36
  "nx-migrations": {
35
37
  "migrations": "./migrations.json"
36
- },
37
- "types": "./src/index.d.ts"
38
- }
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,5 @@
1
+ export type ComponentTestExecutorSchema = {
2
+ quiet?: boolean;
3
+ watch?: boolean;
4
+ coverage?: boolean;
5
+ };
@@ -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
+ }