@equinor/roma-nx-plugin 1.1.0 → 2.0.0-BETA.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/migrations.json +80 -0
- package/package.json +7 -6
- package/src/executors/build/build.d.ts +4 -0
- package/src/executors/build/build.js +76 -0
- package/src/executors/build/build.js.map +1 -0
- package/src/executors/build/executor.d.ts +5 -0
- package/src/executors/build/executor.js +8 -0
- package/src/executors/build/executor.js.map +1 -0
- package/src/executors/build/minify.d.ts +2 -0
- package/src/executors/build/minify.js +22 -0
- package/src/executors/build/minify.js.map +1 -0
- package/src/executors/component-test/executor.d.ts +4 -0
- package/src/executors/component-test/executor.js +48 -0
- package/src/executors/component-test/executor.js.map +1 -0
- package/src/executors/create-vite-config.d.ts +3 -0
- package/src/executors/create-vite-config.js +106 -0
- package/src/executors/create-vite-config.js.map +1 -0
- package/src/executors/executor-context.d.ts +2 -0
- package/src/executors/executor-context.js +101 -0
- package/src/executors/executor-context.js.map +1 -0
- package/src/executors/publish/executor.d.ts +5 -0
- package/src/executors/publish/executor.js +24 -0
- package/src/executors/publish/executor.js.map +1 -0
- package/src/executors/publish/manifest-model.d.ts +29 -0
- package/src/executors/publish/manifest-model.js +3 -0
- package/src/executors/publish/manifest-model.js.map +1 -0
- package/src/executors/publish/publish-script.d.ts +8 -0
- package/src/executors/publish/publish-script.js +193 -0
- package/src/executors/publish/publish-script.js.map +1 -0
- package/src/executors/serve/executor.d.ts +3 -0
- package/src/executors/serve/executor.js +17 -0
- package/src/executors/serve/executor.js.map +1 -0
- package/src/executors/serve/get-manifest.d.ts +4 -0
- package/src/executors/serve/get-manifest.js +20 -0
- package/src/executors/serve/get-manifest.js.map +1 -0
- package/src/executors/serve/server.d.ts +3 -0
- package/src/executors/serve/server.js +179 -0
- package/src/executors/serve/server.js.map +1 -0
- package/src/executors/utils/get-vite-config.d.ts +1 -0
- package/src/executors/utils/get-vite-config.js +13 -0
- package/src/executors/utils/get-vite-config.js.map +1 -0
- package/src/executors/utils/logger.d.ts +24 -0
- package/src/executors/utils/logger.js +69 -0
- package/src/executors/utils/logger.js.map +1 -0
- package/src/generators/app/data/modules.d.ts +19 -0
- package/src/generators/app/data/modules.js +23 -0
- package/src/generators/app/data/modules.js.map +1 -0
- package/src/generators/app/generator.d.ts +5 -0
- package/src/generators/app/generator.js +101 -0
- package/src/generators/app/generator.js.map +1 -0
- package/src/generators/component-test/files/cypress/support/commands.d.ts +0 -0
- package/src/generators/component-test/files/cypress/support/{commands.ts → commands.js} +2 -1
- package/src/generators/component-test/files/cypress/support/commands.js.map +1 -0
- package/src/generators/component-test/files/cypress/support/component.d.ts +9 -0
- package/src/generators/component-test/files/cypress/support/{component.ts → component.js} +7 -21
- package/src/generators/component-test/files/cypress/support/component.js.map +1 -0
- package/src/generators/component-test/generator.d.ts +4 -0
- package/src/generators/component-test/generator.js +36 -0
- package/src/generators/component-test/generator.js.map +1 -0
- package/src/generators/preset/generator.d.ts +4 -0
- package/src/generators/preset/generator.js +13 -0
- package/src/generators/preset/generator.js.map +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/migrations/add-publish-target/add-publish-target.d.ts +2 -0
- package/src/migrations/add-publish-target/add-publish-target.js +32 -0
- package/src/migrations/add-publish-target/add-publish-target.js.map +1 -0
- package/src/migrations/migrate-fusion-manifest/migrate-fusion-manifest.d.ts +2 -0
- package/src/migrations/migrate-fusion-manifest/migrate-fusion-manifest.js +15 -0
- package/src/migrations/migrate-fusion-manifest/migrate-fusion-manifest.js.map +1 -0
- package/src/migrations/migrate-fusion-manifest/old-format.json +21 -0
- package/src/migrations/migrate-fusion-manifest/update-manifest.d.ts +6 -0
- package/src/migrations/migrate-fusion-manifest/update-manifest.js +26 -0
- package/src/migrations/migrate-fusion-manifest/update-manifest.js.map +1 -0
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.d.ts +2 -0
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.js +30 -0
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.js.map +1 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.d.ts +2 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js +48 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js.map +1 -0
- package/.eslintrc.json +0 -37
- package/jest.config.ts +0 -13
- package/manifest-schema.json +0 -80
- package/project.json +0 -65
- package/src/executors/build/build.ts +0 -100
- package/src/executors/build/executor.spec.ts +0 -13
- package/src/executors/build/executor.ts +0 -10
- package/src/executors/build/minify.ts +0 -20
- package/src/executors/component-test/executor.spec.ts +0 -18
- package/src/executors/component-test/executor.ts +0 -57
- package/src/executors/create-vite-config.ts +0 -133
- package/src/executors/executor-context.ts +0 -102
- package/src/executors/publish/executor.ts +0 -29
- package/src/executors/publish/manifest-model.ts +0 -33
- package/src/executors/publish/publish-script.spec.ts +0 -118
- package/src/executors/publish/publish-script.ts +0 -210
- package/src/executors/serve/executor.ts +0 -19
- package/src/executors/serve/get-manifest.ts +0 -20
- package/src/executors/serve/server.ts +0 -250
- package/src/executors/utils/get-vite-config.ts +0 -9
- package/src/executors/utils/logger.ts +0 -90
- package/src/generators/app/data/modules.ts +0 -19
- package/src/generators/app/generator.spec.ts +0 -86
- package/src/generators/app/generator.ts +0 -141
- package/src/generators/component-test/generator.spec.ts +0 -79
- package/src/generators/component-test/generator.ts +0 -67
- package/src/generators/preset/generator.spec.ts +0 -38
- package/src/generators/preset/generator.ts +0 -18
- package/src/migrations/add-publish-target/add-publish-target.spec.ts +0 -60
- package/src/migrations/add-publish-target/add-publish-target.ts +0 -28
- package/src/migrations/move-fusion-manifest/move-fusion-manifest.ts +0 -35
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.ts +0 -70
- package/tsconfig.json +0 -17
- package/tsconfig.lib.json +0 -20
- package/tsconfig.spec.json +0 -26
- package/vite.config.ts +0 -31
- /package/src/{index.ts → index.d.ts} +0 -0
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { LogErrorOptions, LogOptions, LogType } from 'vite';
|
|
2
|
-
import { RollupError } from 'rollup';
|
|
3
|
-
|
|
4
|
-
type ILogger = {
|
|
5
|
-
info(msg: string, options?: LogOptions): void;
|
|
6
|
-
warn(msg: string, options?: LogOptions): void;
|
|
7
|
-
warnOnce(msg: string, options?: LogOptions): void;
|
|
8
|
-
error(msg: string, options?: LogErrorOptions): void;
|
|
9
|
-
clearScreen(type: LogType): void;
|
|
10
|
-
hasErrorLogged(error: Error | RollupError): boolean;
|
|
11
|
-
hasWarned: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const timestamp = () => {
|
|
15
|
-
const date = new Date();
|
|
16
|
-
const year = date.getFullYear();
|
|
17
|
-
const month = date.getUTCMonth() + 1;
|
|
18
|
-
const day = date.getDate();
|
|
19
|
-
const hour = date.getHours();
|
|
20
|
-
const minutes = date.getMinutes();
|
|
21
|
-
const seconds = date.getSeconds();
|
|
22
|
-
return `[${year}-${String(month).padStart(
|
|
23
|
-
2,
|
|
24
|
-
'0'
|
|
25
|
-
)}-${day} ${hour}:${minutes}:${seconds}]`;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const logModes = {
|
|
29
|
-
error: () => {
|
|
30
|
-
return `${timestamp()}: [roma]:`;
|
|
31
|
-
},
|
|
32
|
-
warning: () => {
|
|
33
|
-
return `${timestamp()}: [roma]:`;
|
|
34
|
-
},
|
|
35
|
-
info: () => {
|
|
36
|
-
return `${timestamp()}: [roma]:`;
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Custom logger, for now ignores error on roma-framework.umd.js, but can be improved on further.
|
|
41
|
-
export class Logger implements ILogger {
|
|
42
|
-
private warnings: Set<string>;
|
|
43
|
-
private errors: Set<Error | RollupError>;
|
|
44
|
-
public hasWarned: boolean;
|
|
45
|
-
|
|
46
|
-
constructor() {
|
|
47
|
-
this.warnings = new Set();
|
|
48
|
-
this.errors = new Set();
|
|
49
|
-
this.hasWarned = false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
info(msg: string, options?: LogOptions): void {
|
|
53
|
-
if (options?.clear) this.clearScreen('info');
|
|
54
|
-
console.info(logModes.info(), msg);
|
|
55
|
-
// Additional logic can be added here to handle options
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
warn(msg: string, options?: LogOptions): void {
|
|
59
|
-
console.warn(logModes.warning(), msg);
|
|
60
|
-
if (options?.clear) this.clearScreen('warn');
|
|
61
|
-
this.hasWarned = true;
|
|
62
|
-
// Additional logic can be added here to handle options
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
warnOnce(msg: string, options?: LogOptions): void {
|
|
66
|
-
if (!this.warnings.has(msg)) {
|
|
67
|
-
this.warnings.add(msg);
|
|
68
|
-
this.warn(msg, options);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
error(msg: string, options?: LogErrorOptions): void {
|
|
73
|
-
if (
|
|
74
|
-
typeof msg === 'string' &&
|
|
75
|
-
msg.includes('resolved id: /roma-framework.umd.js')
|
|
76
|
-
)
|
|
77
|
-
return;
|
|
78
|
-
if (options?.clear) this.clearScreen('error');
|
|
79
|
-
console.error(logModes.error(), msg);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
clearScreen(type: LogType): void {
|
|
83
|
-
console.clear();
|
|
84
|
-
if (type === 'error') console.log(`Console cleared: ${type}`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
hasErrorLogged(error: Error | RollupError): boolean {
|
|
88
|
-
return this.errors.has(error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const modules = {
|
|
2
|
-
"fusion-framework-module-msal": "^4.0.5",
|
|
3
|
-
"fusion-framework-module-navigation": "^3.0.5",
|
|
4
|
-
"fusion-framework-module-context": "^4.0.13",
|
|
5
|
-
"fusion-framework-module-ag-grid": "^30.1.0",
|
|
6
|
-
"fusion-framework-module-bookmark": "1.0.10",
|
|
7
|
-
"fusion-framework-module-event": "^4.0.5",
|
|
8
|
-
"fusion-framework-module-http": "^5.0.6",
|
|
9
|
-
"fusion-framework-module-service-discovery": "^5.0.6",
|
|
10
|
-
"fusion-framework-module-services": "^3.1.5",
|
|
11
|
-
"fusion-framework-module-signalr": "^2.0.7",
|
|
12
|
-
"fusion-framework-module-telemetry": "^4.0.2",
|
|
13
|
-
"fusion-framework-module-widget": "^1.0.9",
|
|
14
|
-
"fusion-framework-react-module-bookmark": "^2.0.17",
|
|
15
|
-
"fusion-framework-react-module-http": "^3.0.5",
|
|
16
|
-
"fusion-framework-react-module-context": " ^6.0.12",
|
|
17
|
-
"fusion-framework-react-module-signalr": "^2.0.7",
|
|
18
|
-
"fusion-framework-react-module-event": "^3.1.2"
|
|
19
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
-
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
3
|
-
|
|
4
|
-
import { appGenerator } from './generator';
|
|
5
|
-
|
|
6
|
-
describe('app generator', () => {
|
|
7
|
-
let tree: Tree;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should run successfully when rootFormat is derived', async () => {
|
|
14
|
-
expect(() => readProjectConfiguration(tree, 'test')).toThrow();
|
|
15
|
-
await appGenerator(tree, {
|
|
16
|
-
name: 'test',
|
|
17
|
-
fusionModules: [],
|
|
18
|
-
projectName: 'test',
|
|
19
|
-
appProjectRoot: '',
|
|
20
|
-
e2eProjectName: '',
|
|
21
|
-
e2eProjectRoot: '',
|
|
22
|
-
parsedTags: [],
|
|
23
|
-
fileName: '',
|
|
24
|
-
styledModule: 'css',
|
|
25
|
-
minimal: false,
|
|
26
|
-
routing: false,
|
|
27
|
-
hasStyles: false,
|
|
28
|
-
unitTestRunner: 'none',
|
|
29
|
-
style: 'css',
|
|
30
|
-
e2eTestRunner: 'none',
|
|
31
|
-
linter: null,
|
|
32
|
-
projectNameAndRootFormat: 'derived',
|
|
33
|
-
});
|
|
34
|
-
const config = readProjectConfiguration(tree, 'test');
|
|
35
|
-
expect(config).toBeDefined();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should run successfully when rootFormat is as-provided', async () => {
|
|
39
|
-
expect(() => readProjectConfiguration(tree, 'test')).toThrow();
|
|
40
|
-
await appGenerator(tree, {
|
|
41
|
-
name: 'test',
|
|
42
|
-
fusionModules: [],
|
|
43
|
-
projectName: 'test',
|
|
44
|
-
appProjectRoot: '',
|
|
45
|
-
e2eProjectName: '',
|
|
46
|
-
e2eProjectRoot: '',
|
|
47
|
-
parsedTags: [],
|
|
48
|
-
fileName: '',
|
|
49
|
-
styledModule: 'css',
|
|
50
|
-
minimal: false,
|
|
51
|
-
routing: false,
|
|
52
|
-
hasStyles: false,
|
|
53
|
-
unitTestRunner: 'none',
|
|
54
|
-
style: 'css',
|
|
55
|
-
e2eTestRunner: 'none',
|
|
56
|
-
linter: null,
|
|
57
|
-
projectNameAndRootFormat: 'as-provided',
|
|
58
|
-
});
|
|
59
|
-
const config = readProjectConfiguration(tree, 'test');
|
|
60
|
-
expect(config).toBeDefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should run successfully when rootFormat is not set', async () => {
|
|
64
|
-
expect(() => readProjectConfiguration(tree, 'test')).toThrow();
|
|
65
|
-
await appGenerator(tree, {
|
|
66
|
-
name: 'test',
|
|
67
|
-
fusionModules: [],
|
|
68
|
-
projectName: 'test',
|
|
69
|
-
appProjectRoot: '',
|
|
70
|
-
e2eProjectName: '',
|
|
71
|
-
e2eProjectRoot: '',
|
|
72
|
-
parsedTags: [],
|
|
73
|
-
fileName: '',
|
|
74
|
-
styledModule: 'css',
|
|
75
|
-
minimal: false,
|
|
76
|
-
routing: false,
|
|
77
|
-
hasStyles: false,
|
|
78
|
-
unitTestRunner: 'none',
|
|
79
|
-
style: 'css',
|
|
80
|
-
e2eTestRunner: 'none',
|
|
81
|
-
linter: null,
|
|
82
|
-
});
|
|
83
|
-
const config = readProjectConfiguration(tree, 'test');
|
|
84
|
-
expect(config).toBeDefined();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addDependenciesToPackageJson,
|
|
3
|
-
formatFiles,
|
|
4
|
-
generateFiles,
|
|
5
|
-
getWorkspaceLayout,
|
|
6
|
-
installPackagesTask,
|
|
7
|
-
runTasksInSerial,
|
|
8
|
-
Tree,
|
|
9
|
-
updateProjectConfiguration,
|
|
10
|
-
readProjectConfiguration,
|
|
11
|
-
} from '@nx/devkit';
|
|
12
|
-
import * as path from 'path';
|
|
13
|
-
import { AppGeneratorSchema } from './schema';
|
|
14
|
-
import { applicationGenerator } from '@nx/react';
|
|
15
|
-
import { NormalizedSchema } from '@nx/react/src/generators/application/schema';
|
|
16
|
-
import { modules } from './data/modules';
|
|
17
|
-
import { getRelativeCwd } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
18
|
-
|
|
19
|
-
async function addDependencies(
|
|
20
|
-
tree: Tree,
|
|
21
|
-
options: AppGeneratorSchema & Omit<NormalizedSchema, 'bundler' | 'minimal'>
|
|
22
|
-
) {
|
|
23
|
-
const dependencies: Record<string, string> = {
|
|
24
|
-
'@equinor/roma-framework': '^0.0.12',
|
|
25
|
-
'@equinor/fusion-framework': '7.0.30',
|
|
26
|
-
'@equinor/fusion-framework-module-app': '5.2.13',
|
|
27
|
-
'@equinor/eds-core-react': '^0.39.0',
|
|
28
|
-
'@equinor/eds-data-grid-react': '^0.6.1',
|
|
29
|
-
'@equinor/eds-icons': '^0.21.0',
|
|
30
|
-
'@equinor/eds-tokens': '^0.9.2',
|
|
31
|
-
'@equinor/fusion-framework-react': '6.0.2',
|
|
32
|
-
'@equinor/fusion-framework-react-app': '4.3.3',
|
|
33
|
-
'@equinor/fusion-framework-react-module': '3.0.8',
|
|
34
|
-
'@equinor/fusion-framework-module-navigation': '3.1.4',
|
|
35
|
-
'styled-components': '^6.0.8',
|
|
36
|
-
};
|
|
37
|
-
options.fusionModules
|
|
38
|
-
.flatMap((module) => module.split(','))
|
|
39
|
-
.forEach((module) => {
|
|
40
|
-
dependencies[`@equinor/${module}`] = modules[module];
|
|
41
|
-
});
|
|
42
|
-
const devDependencies = {};
|
|
43
|
-
return runTasksInSerial(
|
|
44
|
-
...[
|
|
45
|
-
addDependenciesToPackageJson(
|
|
46
|
-
tree,
|
|
47
|
-
dependencies,
|
|
48
|
-
devDependencies,
|
|
49
|
-
undefined,
|
|
50
|
-
true
|
|
51
|
-
),
|
|
52
|
-
]
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function updateTargets(
|
|
57
|
-
tree: Tree,
|
|
58
|
-
options: AppGeneratorSchema & Omit<NormalizedSchema, 'bundler'>
|
|
59
|
-
) {
|
|
60
|
-
const existing = readProjectConfiguration(tree, options.name);
|
|
61
|
-
updateProjectConfiguration(tree, options.name, {
|
|
62
|
-
...existing,
|
|
63
|
-
targets: {
|
|
64
|
-
build: {
|
|
65
|
-
executor: '@equinor/roma-nx-plugin:build',
|
|
66
|
-
options: {},
|
|
67
|
-
},
|
|
68
|
-
serve: {
|
|
69
|
-
executor: '@equinor/roma-nx-plugin:serve',
|
|
70
|
-
options: {
|
|
71
|
-
port: options.devServerPort ?? 3000,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
portal: {
|
|
75
|
-
executor: '@equinor/roma-nx-plugin:portal',
|
|
76
|
-
options: {},
|
|
77
|
-
},
|
|
78
|
-
publish: {
|
|
79
|
-
executor: '@equinor/roma-nx-plugin:publish',
|
|
80
|
-
dependsOn: ['build'],
|
|
81
|
-
configurations: {
|
|
82
|
-
production: {
|
|
83
|
-
environment: 'production',
|
|
84
|
-
},
|
|
85
|
-
qa: {
|
|
86
|
-
environment: 'qa',
|
|
87
|
-
},
|
|
88
|
-
dev: {
|
|
89
|
-
environment: 'dev',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
defaultConfiguration: 'dev',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export async function appGenerator(
|
|
99
|
-
tree: Tree,
|
|
100
|
-
options: AppGeneratorSchema & Omit<NormalizedSchema, 'bundler'>
|
|
101
|
-
) {
|
|
102
|
-
const derived = options.projectNameAndRootFormat !== 'as-provided';
|
|
103
|
-
if (derived && options.directory) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
'You cannot provide a directory when using projectNameAndRootFormat = derived '
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
const config = getWorkspaceLayout(tree);
|
|
109
|
-
const outputDir = derived
|
|
110
|
-
? `${config.appsDir}/${options.name}`
|
|
111
|
-
: path.join(getRelativeCwd(), options.directory ?? options.name);
|
|
112
|
-
|
|
113
|
-
await applicationGenerator(tree, {
|
|
114
|
-
...options,
|
|
115
|
-
tags: [options.tags ?? '', 'roma-application'].join(','),
|
|
116
|
-
rootProject: false,
|
|
117
|
-
bundler: 'vite',
|
|
118
|
-
});
|
|
119
|
-
tree.delete(`${outputDir}/vite.config.ts`);
|
|
120
|
-
tree.delete(`${outputDir}/index.html`);
|
|
121
|
-
updateTargets(tree, options);
|
|
122
|
-
generateFiles(tree, path.join(__dirname, 'files'), outputDir, options);
|
|
123
|
-
await addDependencies(tree, options);
|
|
124
|
-
await formatFiles(tree);
|
|
125
|
-
tree.delete(`${outputDir}/src/app`);
|
|
126
|
-
tree.delete(`${outputDir}/src/assets`);
|
|
127
|
-
tree.delete(`${outputDir}/src/main.tsx`);
|
|
128
|
-
tree.delete(`${outputDir}/src/styles.css`);
|
|
129
|
-
tree.delete(`${outputDir}/index.html`);
|
|
130
|
-
tree.delete(`${outputDir}/public`);
|
|
131
|
-
|
|
132
|
-
if (options.skipPackageJson) {
|
|
133
|
-
return () => true;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return () => {
|
|
137
|
-
installPackagesTask(tree);
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export default appGenerator;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
-
import { Tree, readProjectConfiguration } from '@nx/devkit';
|
|
3
|
-
|
|
4
|
-
import { componentTestGenerator } from './generator';
|
|
5
|
-
import { Linter } from '@nx/eslint/src/generators/utils/linter';
|
|
6
|
-
import appGenerator from '../app/generator';
|
|
7
|
-
import { AppGeneratorSchema } from '../app/schema';
|
|
8
|
-
import { vi } from 'vitest';
|
|
9
|
-
|
|
10
|
-
describe('component-test generator', () => {
|
|
11
|
-
let tree: Tree;
|
|
12
|
-
|
|
13
|
-
vi.mock('@nx/devkit', async (importOriginal) => {
|
|
14
|
-
return {
|
|
15
|
-
...(await importOriginal<typeof import('@nx/devkit')>()),
|
|
16
|
-
installPackagesTask: vi.fn(() => {
|
|
17
|
-
/*intentionally left blank*/
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const appOptions: AppGeneratorSchema = {
|
|
23
|
-
e2ePort: 0,
|
|
24
|
-
e2eWebServerAddress: '',
|
|
25
|
-
e2eWebServerTarget: '',
|
|
26
|
-
appProjectRoot: '',
|
|
27
|
-
e2eProjectName: '',
|
|
28
|
-
e2eProjectRoot: '',
|
|
29
|
-
fileName: '',
|
|
30
|
-
hasStyles: false,
|
|
31
|
-
parsedTags: [],
|
|
32
|
-
projectName: '',
|
|
33
|
-
styledModule: undefined,
|
|
34
|
-
unitTestRunner: undefined,
|
|
35
|
-
style: 'styled-components',
|
|
36
|
-
linter: Linter.EsLint,
|
|
37
|
-
e2eTestRunner: 'none',
|
|
38
|
-
name: 'test',
|
|
39
|
-
minimal: true,
|
|
40
|
-
routing: false,
|
|
41
|
-
fusionModules: [],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
beforeEach(async () => {
|
|
45
|
-
tree = createTreeWithEmptyWorkspace();
|
|
46
|
-
await appGenerator(tree, appOptions);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should add the component-test execution target', async () => {
|
|
50
|
-
await componentTestGenerator(tree, {
|
|
51
|
-
project: 'test',
|
|
52
|
-
});
|
|
53
|
-
const config = readProjectConfiguration(tree, 'test');
|
|
54
|
-
expect(config).toBeDefined();
|
|
55
|
-
expect(config.targets).toHaveProperty('component-test');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should add the cypress-files', async () => {
|
|
59
|
-
await componentTestGenerator(tree, {
|
|
60
|
-
project: 'test',
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const changes = tree.listChanges();
|
|
64
|
-
const expectedChangePaths = [
|
|
65
|
-
'cypress/downloads/.gitkeep',
|
|
66
|
-
'cypress/fixtures/example.json',
|
|
67
|
-
'cypress/screenshots/.gitkeep',
|
|
68
|
-
'cypress/videos/.gitkeep',
|
|
69
|
-
'cypress/support/commands.ts',
|
|
70
|
-
'cypress/support/component.ts',
|
|
71
|
-
'cypress/support/component-index.html',
|
|
72
|
-
'cypress.config.ts',
|
|
73
|
-
];
|
|
74
|
-
expectedChangePaths.forEach((pa) => {
|
|
75
|
-
const change = changes.find((c) => c.path.endsWith(pa));
|
|
76
|
-
expect(change.type).toBe('CREATE');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readProjectConfiguration,
|
|
3
|
-
updateProjectConfiguration,
|
|
4
|
-
formatFiles,
|
|
5
|
-
generateFiles,
|
|
6
|
-
addDependenciesToPackageJson,
|
|
7
|
-
installPackagesTask,
|
|
8
|
-
Tree,
|
|
9
|
-
} from '@nx/devkit';
|
|
10
|
-
import * as path from 'path';
|
|
11
|
-
import { ComponentTestGeneratorSchema } from './schema';
|
|
12
|
-
|
|
13
|
-
export async function componentTestGenerator(
|
|
14
|
-
tree: Tree,
|
|
15
|
-
options: ComponentTestGeneratorSchema
|
|
16
|
-
) {
|
|
17
|
-
const name = options.project;
|
|
18
|
-
const currentConfiguration = readProjectConfiguration(tree, name);
|
|
19
|
-
if (currentConfiguration.projectType !== 'application') {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`Generator can only be run on applications - not supported for libraries`
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
if (
|
|
25
|
-
currentConfiguration.targets['build'].executor !==
|
|
26
|
-
'@equinor/roma-nx-plugin:build'
|
|
27
|
-
) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Generator can only be run on applications build with @equinor/roma-nx-plugin:build`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
if (currentConfiguration.targets['component-test']) {
|
|
33
|
-
throw new Error(`Component test target already exists`);
|
|
34
|
-
}
|
|
35
|
-
updateProjectConfiguration(tree, name, {
|
|
36
|
-
...currentConfiguration,
|
|
37
|
-
targets: {
|
|
38
|
-
...currentConfiguration.targets,
|
|
39
|
-
'component-test': {
|
|
40
|
-
executor: '@equinor/roma-nx-plugin:component-test',
|
|
41
|
-
options: {
|
|
42
|
-
quiet: true,
|
|
43
|
-
watch: false,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
addDependenciesToPackageJson(
|
|
49
|
-
tree,
|
|
50
|
-
{},
|
|
51
|
-
{
|
|
52
|
-
'@cypress/code-coverage': '^3.13.1',
|
|
53
|
-
cypress: '^13.14.2',
|
|
54
|
-
'vite-plugin-istanbul': '^6.0.2',
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
generateFiles(
|
|
58
|
-
tree,
|
|
59
|
-
path.join(__dirname, 'files'),
|
|
60
|
-
currentConfiguration.root,
|
|
61
|
-
options
|
|
62
|
-
);
|
|
63
|
-
await formatFiles(tree);
|
|
64
|
-
return installPackagesTask(tree);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default componentTestGenerator;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
-
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
3
|
-
|
|
4
|
-
import { presetGenerator } from './generator';
|
|
5
|
-
import { PresetGeneratorSchema } from './schema';
|
|
6
|
-
import { Linter } from '@nx/eslint/src/generators/utils/linter';
|
|
7
|
-
|
|
8
|
-
describe('preset generator', () => {
|
|
9
|
-
let tree: Tree;
|
|
10
|
-
const options: PresetGeneratorSchema = {
|
|
11
|
-
appProjectRoot: '',
|
|
12
|
-
e2eProjectName: '',
|
|
13
|
-
e2eProjectRoot: '',
|
|
14
|
-
fileName: '',
|
|
15
|
-
hasStyles: false,
|
|
16
|
-
parsedTags: [],
|
|
17
|
-
projectName: '',
|
|
18
|
-
styledModule: undefined,
|
|
19
|
-
unitTestRunner: undefined,
|
|
20
|
-
style: 'styled-components',
|
|
21
|
-
linter: Linter.EsLint,
|
|
22
|
-
e2eTestRunner: 'none',
|
|
23
|
-
name: 'test',
|
|
24
|
-
minimal: true,
|
|
25
|
-
routing: false,
|
|
26
|
-
fusionModules: [],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
tree = createTreeWithEmptyWorkspace();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should run successfully', async () => {
|
|
34
|
-
await presetGenerator(tree, options);
|
|
35
|
-
const config = readProjectConfiguration(tree, 'test');
|
|
36
|
-
expect(config).toBeDefined();
|
|
37
|
-
}, 20_000);
|
|
38
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { PresetGeneratorSchema } from './schema';
|
|
3
|
-
|
|
4
|
-
export async function presetGenerator(
|
|
5
|
-
tree: Tree,
|
|
6
|
-
options: PresetGeneratorSchema
|
|
7
|
-
) {
|
|
8
|
-
options.directory = 'apps';
|
|
9
|
-
options.name = options.appName || options.name;
|
|
10
|
-
options.projectName = options.appName || options.name;
|
|
11
|
-
options.style = options.style || options.styledModule || 'styled-components';
|
|
12
|
-
options.styledModule = options.style;
|
|
13
|
-
return await import('../app/generator').then(({ appGenerator }) =>
|
|
14
|
-
appGenerator(tree, { ...options })
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default presetGenerator;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
-
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
3
|
-
|
|
4
|
-
import update from './add-publish-target';
|
|
5
|
-
import appGenerator from '../../generators/app/generator';
|
|
6
|
-
|
|
7
|
-
describe('add-publish-target migration', () => {
|
|
8
|
-
let tree: Tree;
|
|
9
|
-
|
|
10
|
-
beforeEach(async () => {
|
|
11
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
12
|
-
await appGenerator(tree, {
|
|
13
|
-
name: 'test-app',
|
|
14
|
-
fusionModules: [],
|
|
15
|
-
projectName: 'test-app',
|
|
16
|
-
appProjectRoot: '',
|
|
17
|
-
e2eProjectName: '',
|
|
18
|
-
e2eProjectRoot: '',
|
|
19
|
-
parsedTags: [],
|
|
20
|
-
fileName: '',
|
|
21
|
-
styledModule: 'css',
|
|
22
|
-
minimal: false,
|
|
23
|
-
routing: false,
|
|
24
|
-
hasStyles: false,
|
|
25
|
-
unitTestRunner: 'none',
|
|
26
|
-
style: 'css',
|
|
27
|
-
e2eTestRunner: 'none',
|
|
28
|
-
linter: null,
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should have publish target by default', async () => {
|
|
33
|
-
const config = readProjectConfiguration(tree, 'test-app');
|
|
34
|
-
expect(config.targets.publish).toBeDefined();
|
|
35
|
-
update(tree);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should add publish target', async () => {
|
|
39
|
-
let config = readProjectConfiguration(tree, 'test-app');
|
|
40
|
-
config.targets.publish = undefined;
|
|
41
|
-
expect(config.targets.publish).toBeUndefined();
|
|
42
|
-
update(tree);
|
|
43
|
-
config = readProjectConfiguration(tree, 'test-app');
|
|
44
|
-
expect(config.targets.publish).toEqual({
|
|
45
|
-
executor: '@equinor/roma-nx-plugin:publish',
|
|
46
|
-
configurations: {
|
|
47
|
-
production: {
|
|
48
|
-
environment: 'production',
|
|
49
|
-
},
|
|
50
|
-
qa: {
|
|
51
|
-
environment: 'qa',
|
|
52
|
-
},
|
|
53
|
-
dev: {
|
|
54
|
-
environment: 'dev',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
defaultConfiguration: 'dev',
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { getProjects, Tree, updateProjectConfiguration } from '@nx/devkit';
|
|
3
|
-
|
|
4
|
-
export default function update(tree: Tree) {
|
|
5
|
-
const projects = getProjects(tree);
|
|
6
|
-
|
|
7
|
-
for (const [name, project] of projects) {
|
|
8
|
-
if (project.projectType !== 'application') continue;
|
|
9
|
-
if (!project.targets?.portal) {
|
|
10
|
-
project.targets.publish = {
|
|
11
|
-
executor: '@equinor/roma-nx-plugin:publish',
|
|
12
|
-
configurations: {
|
|
13
|
-
production: {
|
|
14
|
-
environment: 'production',
|
|
15
|
-
},
|
|
16
|
-
qa: {
|
|
17
|
-
environment: 'qa',
|
|
18
|
-
},
|
|
19
|
-
dev: {
|
|
20
|
-
environment: 'dev',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
defaultConfiguration: 'dev',
|
|
24
|
-
};
|
|
25
|
-
updateProjectConfiguration(tree, name, project);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import {
|
|
3
|
-
getProjects,
|
|
4
|
-
readJson,
|
|
5
|
-
Tree,
|
|
6
|
-
updateProjectConfiguration,
|
|
7
|
-
} from '@nx/devkit';
|
|
8
|
-
import { readdirSync } from 'fs';
|
|
9
|
-
|
|
10
|
-
export default function update(tree: Tree) {
|
|
11
|
-
const projects = getProjects(tree);
|
|
12
|
-
|
|
13
|
-
for (const [, project] of projects) {
|
|
14
|
-
const contents = readdirSync(project.root);
|
|
15
|
-
if (contents && contents.includes('fusion-manifest.json')) {
|
|
16
|
-
const manifest = readJson(tree, `${project.root}/fusion-manifest.json`);
|
|
17
|
-
const packageJson = readJson(tree, `${project.root}/package.json`);
|
|
18
|
-
const { version, ...rest } = manifest;
|
|
19
|
-
packageJson.version = version;
|
|
20
|
-
packageJson.roma = rest;
|
|
21
|
-
tree.exists(`${project.root}/fusion-manifest.json`) &&
|
|
22
|
-
tree.delete(`${project.root}/fusion-manifest.json`);
|
|
23
|
-
tree.exists(`${project.root}/src/version.ts`) &&
|
|
24
|
-
tree.delete(`${project.root}/src/version.ts`);
|
|
25
|
-
tree.exists(`${project.root}/app.config.js`) &&
|
|
26
|
-
tree.delete(`${project.root}/app.config.js`);
|
|
27
|
-
tree.exists(`${project.root}/.env.serve`) &&
|
|
28
|
-
tree.delete(`${project.root}/.env.serve`);
|
|
29
|
-
tree.write(
|
|
30
|
-
`${project.root}/package.json`,
|
|
31
|
-
JSON.stringify(packageJson, null, 2)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|