@equinor/roma-nx-plugin 1.1.0 → 1.1.1

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 (109) hide show
  1. package/package.json +4 -3
  2. package/src/executors/build/build.d.ts +4 -0
  3. package/src/executors/build/build.js +77 -0
  4. package/src/executors/build/build.js.map +1 -0
  5. package/src/executors/build/executor.d.ts +5 -0
  6. package/src/executors/build/executor.js +8 -0
  7. package/src/executors/build/executor.js.map +1 -0
  8. package/src/executors/build/minify.d.ts +2 -0
  9. package/src/executors/build/minify.js +22 -0
  10. package/src/executors/build/minify.js.map +1 -0
  11. package/src/executors/component-test/executor.d.ts +4 -0
  12. package/src/executors/component-test/executor.js +48 -0
  13. package/src/executors/component-test/executor.js.map +1 -0
  14. package/src/executors/create-vite-config.d.ts +3 -0
  15. package/src/executors/create-vite-config.js +106 -0
  16. package/src/executors/create-vite-config.js.map +1 -0
  17. package/src/executors/executor-context.d.ts +2 -0
  18. package/src/executors/executor-context.js +101 -0
  19. package/src/executors/executor-context.js.map +1 -0
  20. package/src/executors/publish/executor.d.ts +5 -0
  21. package/src/executors/publish/executor.js +24 -0
  22. package/src/executors/publish/executor.js.map +1 -0
  23. package/src/executors/publish/manifest-model.d.ts +30 -0
  24. package/src/executors/publish/manifest-model.js +3 -0
  25. package/src/executors/publish/manifest-model.js.map +1 -0
  26. package/src/executors/publish/publish-script.d.ts +9 -0
  27. package/src/executors/publish/publish-script.js +185 -0
  28. package/src/executors/publish/publish-script.js.map +1 -0
  29. package/src/executors/serve/executor.d.ts +3 -0
  30. package/src/executors/serve/executor.js +17 -0
  31. package/src/executors/serve/executor.js.map +1 -0
  32. package/src/executors/serve/get-manifest.d.ts +2 -0
  33. package/src/executors/serve/get-manifest.js +20 -0
  34. package/src/executors/serve/get-manifest.js.map +1 -0
  35. package/src/executors/serve/server.d.ts +3 -0
  36. package/src/executors/serve/server.js +175 -0
  37. package/src/executors/serve/server.js.map +1 -0
  38. package/src/executors/utils/get-vite-config.d.ts +1 -0
  39. package/src/executors/utils/get-vite-config.js +13 -0
  40. package/src/executors/utils/get-vite-config.js.map +1 -0
  41. package/src/executors/utils/logger.d.ts +24 -0
  42. package/src/executors/utils/logger.js +69 -0
  43. package/src/executors/utils/logger.js.map +1 -0
  44. package/src/generators/app/data/modules.d.ts +19 -0
  45. package/src/generators/app/data/modules.js +23 -0
  46. package/src/generators/app/data/modules.js.map +1 -0
  47. package/src/generators/app/generator.d.ts +5 -0
  48. package/src/generators/app/generator.js +101 -0
  49. package/src/generators/app/generator.js.map +1 -0
  50. package/src/generators/component-test/files/cypress/support/commands.d.ts +0 -0
  51. package/src/generators/component-test/files/cypress/support/{commands.ts → commands.js} +2 -1
  52. package/src/generators/component-test/files/cypress/support/commands.js.map +1 -0
  53. package/src/generators/component-test/files/cypress/support/component.d.ts +9 -0
  54. package/src/generators/component-test/files/cypress/support/{component.ts → component.js} +7 -21
  55. package/src/generators/component-test/files/cypress/support/component.js.map +1 -0
  56. package/src/generators/component-test/generator.d.ts +4 -0
  57. package/src/generators/component-test/generator.js +36 -0
  58. package/src/generators/component-test/generator.js.map +1 -0
  59. package/src/generators/preset/generator.d.ts +4 -0
  60. package/src/generators/preset/generator.js +13 -0
  61. package/src/generators/preset/generator.js.map +1 -0
  62. package/src/index.js +5 -0
  63. package/src/index.js.map +1 -0
  64. package/src/migrations/add-publish-target/add-publish-target.d.ts +2 -0
  65. package/src/migrations/add-publish-target/add-publish-target.js +32 -0
  66. package/src/migrations/add-publish-target/add-publish-target.js.map +1 -0
  67. package/src/migrations/move-fusion-manifest/move-fusion-manifest.d.ts +2 -0
  68. package/src/migrations/move-fusion-manifest/move-fusion-manifest.js +30 -0
  69. package/src/migrations/move-fusion-manifest/move-fusion-manifest.js.map +1 -0
  70. package/src/migrations/remove-fusion-cli/remove-fusion-cli.d.ts +2 -0
  71. package/src/migrations/remove-fusion-cli/remove-fusion-cli.js +48 -0
  72. package/src/migrations/remove-fusion-cli/remove-fusion-cli.js.map +1 -0
  73. package/.eslintrc.json +0 -37
  74. package/jest.config.ts +0 -13
  75. package/manifest-schema.json +0 -80
  76. package/project.json +0 -65
  77. package/src/executors/build/build.ts +0 -100
  78. package/src/executors/build/executor.spec.ts +0 -13
  79. package/src/executors/build/executor.ts +0 -10
  80. package/src/executors/build/minify.ts +0 -20
  81. package/src/executors/component-test/executor.spec.ts +0 -18
  82. package/src/executors/component-test/executor.ts +0 -57
  83. package/src/executors/create-vite-config.ts +0 -133
  84. package/src/executors/executor-context.ts +0 -102
  85. package/src/executors/publish/executor.ts +0 -29
  86. package/src/executors/publish/manifest-model.ts +0 -33
  87. package/src/executors/publish/publish-script.spec.ts +0 -118
  88. package/src/executors/publish/publish-script.ts +0 -210
  89. package/src/executors/serve/executor.ts +0 -19
  90. package/src/executors/serve/get-manifest.ts +0 -20
  91. package/src/executors/serve/server.ts +0 -250
  92. package/src/executors/utils/get-vite-config.ts +0 -9
  93. package/src/executors/utils/logger.ts +0 -90
  94. package/src/generators/app/data/modules.ts +0 -19
  95. package/src/generators/app/generator.spec.ts +0 -86
  96. package/src/generators/app/generator.ts +0 -141
  97. package/src/generators/component-test/generator.spec.ts +0 -79
  98. package/src/generators/component-test/generator.ts +0 -67
  99. package/src/generators/preset/generator.spec.ts +0 -38
  100. package/src/generators/preset/generator.ts +0 -18
  101. package/src/migrations/add-publish-target/add-publish-target.spec.ts +0 -60
  102. package/src/migrations/add-publish-target/add-publish-target.ts +0 -28
  103. package/src/migrations/move-fusion-manifest/move-fusion-manifest.ts +0 -35
  104. package/src/migrations/remove-fusion-cli/remove-fusion-cli.ts +0 -70
  105. package/tsconfig.json +0 -17
  106. package/tsconfig.lib.json +0 -20
  107. package/tsconfig.spec.json +0 -26
  108. package/vite.config.ts +0 -31
  109. /package/src/{index.ts → index.d.ts} +0 -0
@@ -1,210 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { DefaultAzureCredential } from '@azure/identity';
4
- import { Manifest } from './manifest-model';
5
- import type { PublishExecutorSchema } from './schema';
6
- import { brotliCompress } from 'node:zlib';
7
- import { promisify } from 'node:util';
8
-
9
- const brotli = promisify(brotliCompress);
10
-
11
- /**
12
- * An enum representing the status of the publish operation.
13
- * @enum {number}
14
- */
15
- enum Status {
16
- SUCCESS,
17
- ERROR,
18
- }
19
-
20
- /**
21
- * An object representing the configuration for the publish script.
22
- *
23
- * @property apiScopes - An array of API scopes.
24
- * @property romaUri - The URI of the API.
25
- * @property randomVersion - Whether we should generate a random version number.
26
- */
27
- type Config = {
28
- romaUri: string;
29
- apiScopes: Array<string>;
30
- randomVersion: boolean;
31
- };
32
-
33
- /**
34
- * A map of environment names to their respective configurations.
35
- */
36
- const configMap: Record<string, Config> = {
37
- dev: {
38
- romaUri: 'https://romadev.equinor.com',
39
- randomVersion: true,
40
- apiScopes: ['api://RomaWorkbenchApiNonProd/.default'],
41
- },
42
- qa: {
43
- romaUri: 'https://romaqa.equinor.com',
44
- randomVersion: true,
45
- apiScopes: ['api://RomaWorkbenchApiNonProd/.default'],
46
- },
47
- production: {
48
- romaUri: 'https://roma.equinor.com',
49
- randomVersion: false,
50
- apiScopes: ['api://RomaWorkbenchApi/.default'],
51
- },
52
- };
53
-
54
- /**
55
- * Auth token to publish the application
56
- */
57
- let token: string;
58
-
59
- /**
60
- * Publishes the application to the specified environment.
61
- *
62
- * @param pathToOutput - The path to the output directory.
63
- * @param options - The options for the publish operation.
64
- * @param version - The version of the application.
65
- */
66
- export const publishApplication = async (
67
- pathToOutput: string,
68
- options: PublishExecutorSchema
69
- ) => {
70
- let env = options.environment;
71
- // @ts-expect-error Need to rewrite this as nx expects production, not prod.
72
- if (env === 'prod') env = 'production';
73
- const config = configMap[env];
74
- config.randomVersion = options.randomVersion ?? config.randomVersion;
75
- const bundle = await readFile(join(pathToOutput, 'app-bundle.js'));
76
- const manifest = await readFile(join(pathToOutput, 'manifest.json'));
77
- const manifestJsonString = manifest.toString('utf-8');
78
- const parsedManifest = JSON.parse(manifestJsonString) as Manifest;
79
- const appName = parsedManifest.key;
80
- const categories = await getCategories(config);
81
- const categoryIds = categories.map((c) => c.id);
82
- if (!categoryIds.includes(parsedManifest.categoryId)) {
83
- console.log(
84
- `Manifest validation failed: categoryId ${parsedManifest.categoryId} is not in list of categories`
85
- );
86
- console.log(`Valid categories:`);
87
- console.table(categories, ['id', 'name']);
88
- console.log(`Publish will now exit.`);
89
- throw new Error(`ManifestValidationError`);
90
- }
91
- console.log(`Reading & uploading bundle for ${appName}`);
92
- const bundleResult = await uploadBundle(appName, bundle, config);
93
- if (bundleResult === Status.ERROR) {
94
- throw new Error('Failed to upload application');
95
- }
96
- console.log(`Reading & uploading application manifest to ${config.romaUri}`);
97
-
98
- const status = await publishManifest(parsedManifest, config);
99
- if (status === Status.ERROR) {
100
- throw new Error(`Failed to publish application ${appName}`);
101
- } else {
102
- console.log(`Successfully published application ${appName}`);
103
- }
104
- };
105
-
106
- /**
107
- * Authenticates the user and returns the authentication token.
108
- *
109
- * @returns The authentication token.
110
- */
111
- async function authenticate(config: Config) {
112
- if (token) return token;
113
- const auth = new DefaultAzureCredential();
114
- const tokenHolder = await auth.getToken(config.apiScopes);
115
- token = tokenHolder.token;
116
-
117
- return token;
118
- }
119
-
120
- /**
121
- * Gets a list of valid roma categories
122
- *
123
- * @param config - The configuration for the environment.
124
- * @returns The categories for roma.
125
- */
126
- async function getCategories(
127
- config: Config
128
- ): Promise<Array<{ id: string; name: string }>> {
129
- const token = await authenticate(config);
130
- const req = await fetch(`${config.romaUri}/api/apps/categories`, {
131
- headers: {
132
- Authorization: `Bearer ${token}`,
133
- 'Content-Type': 'application/json',
134
- },
135
- });
136
- if (req.status >= 400) {
137
- console.error('Failure', req.status);
138
- return [];
139
- } else {
140
- return await req.json();
141
- }
142
- }
143
-
144
- /**
145
- * Publishes the manifest for the application.
146
- *
147
- * @param manifest - The manifest for the application.
148
- * @param config - The configuration for the application.
149
- * @returns The status of the publish operation.
150
- */
151
- async function publishManifest(manifest: Manifest, config: Config) {
152
- manifest.description = manifest.description || manifest.name;
153
- const { major, minor, patch } = manifest.version;
154
- const version = config.randomVersion
155
- ? Date.now()
156
- : `${major}.${minor}.${patch}`;
157
- manifest.entry = `${config.romaUri}/cdn/applications/bundle/${manifest.key}/app-bundle.js?version=${version}`;
158
- const token = await authenticate(config);
159
- const req = await fetch(`${config.romaUri}/api/apps`, {
160
- method: 'POST',
161
- headers: {
162
- Authorization: `Bearer ${token}`,
163
- 'Content-Type': 'application/json',
164
- },
165
- body: JSON.stringify(manifest),
166
- });
167
- if (req.status < 400) {
168
- return Status.SUCCESS;
169
- } else {
170
- console.error(
171
- `Encountered a problem when publishing application: Received statuscode ${req.status}`
172
- );
173
- const err = await req.json();
174
- console.error(err);
175
- return Status.ERROR;
176
- }
177
- }
178
-
179
- /**
180
- * Uploads the bundle for the application to Azure Blob Storage.
181
- *
182
- * @param appName - The name of the application.
183
- * @param bundle - The bundle for the application.
184
- * @param config - The active config
185
- */
186
- async function uploadBundle(appName: string, bundle: Buffer, config: Config) {
187
- const fd = new FormData();
188
- const br = await brotli(bundle);
189
- fd.set('bundleFile', new Blob([br.buffer]));
190
-
191
- const token = await authenticate(config);
192
- const req = await fetch(`${config.romaUri}/api/apps/key/${appName}/bundle`, {
193
- method: 'PUT',
194
- headers: {
195
- Authorization: `Bearer ${token}`,
196
- },
197
- body: fd,
198
- });
199
- if (req.status < 400) {
200
- console.log(`Successfully uploaded bundle to ${appName}/app-bundle.js`);
201
- return Status.SUCCESS;
202
- } else {
203
- console.error(
204
- `Encountered a problem when publishing application: Received statuscode ${req.status}`
205
- );
206
- const err = await req.json();
207
- console.error(err);
208
- return Status.ERROR;
209
- }
210
- }
@@ -1,19 +0,0 @@
1
- import { ServeExecutorSchema } from './schema';
2
- import { ExecutorContext } from '@nx/devkit';
3
- import { createServer } from './server';
4
-
5
- export default async function runExecutor(
6
- options: ServeExecutorSchema,
7
- context: ExecutorContext
8
- ) {
9
- const configs = [];
10
- if (options.additionalProjects) {
11
- options.additionalProjects.forEach((project) => {
12
- const config = context.workspace.projects[project].targets.serve
13
- .options as ServeExecutorSchema;
14
- config.name = project;
15
- configs.push(config);
16
- });
17
- }
18
- return createServer(options, context, configs);
19
- }
@@ -1,20 +0,0 @@
1
- import { join } from 'path';
2
- import { AppManifest } from '@equinor/fusion-framework-module-app';
3
- import { readJsonFile } from '@nx/devkit';
4
-
5
- export function getManifest(root: string) {
6
- let manifest: AppManifest;
7
- try {
8
- const packageJson = readJsonFile(join(root, 'package.json'));
9
- const pkgManifest = packageJson.roma;
10
- if (pkgManifest) {
11
- manifest = {
12
- ...pkgManifest,
13
- version: packageJson.version,
14
- };
15
- }
16
- } catch {
17
- manifest = readJsonFile(join(root, 'fusion-manifest.json')) as AppManifest;
18
- }
19
- return manifest;
20
- }
@@ -1,250 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- import { ServeExecutorSchema } from './schema';
3
-
4
- const openBrowser = require('open');
5
- const express = require('express');
6
- const chalk = require('chalk');
7
- const getPort = require('get-port-cjs');
8
- import {
9
- createServer as createViteServer,
10
- LibraryOptions,
11
- loadConfigFromFile,
12
- } from 'vite';
13
- import { resolve, join } from 'path';
14
- import { readFileSync } from 'node:fs';
15
- import { createProxyMiddleware } from 'http-proxy-middleware';
16
- import { EnvironmentResponse } from '@equinor/fusion-framework-module-service-discovery';
17
- import { AppManifest } from '@equinor/fusion-framework-module-app';
18
- import { createRomaViteConfig } from '../create-vite-config';
19
- import type { ExecutorContext } from '@nx/devkit';
20
- import { getViteConfig } from '../utils/get-vite-config';
21
- import { getManifest } from './get-manifest';
22
-
23
- async function loadServices(portalTarget: string) {
24
- try {
25
- const req = await fetch(`${portalTarget}/_discovery/environments/current`);
26
- const res = (await req.json()) as EnvironmentResponse;
27
- return res.services
28
- .filter((s) => s.uri.startsWith(portalTarget))
29
- .map((s) => new URL(s.uri).pathname)
30
- .filter((path) => path.length >= 3 && !path.startsWith('/apim/'));
31
- } catch (ex) {
32
- console.error(ex);
33
- process.exit();
34
- }
35
- }
36
-
37
- export async function createServer(
38
- {
39
- port: requestedPort = 3000,
40
- devPortal = 'node_modules/@equinor/roma-framework/dev-portal',
41
- portal: portalTarget = 'https://romadev.equinor.com',
42
- open,
43
- }: ServeExecutorSchema,
44
- context: ExecutorContext,
45
- additionalProjects?: Array<ServeExecutorSchema>
46
- ) {
47
- // Get path to dev-portal, this would be a flag from executor.
48
- const devPortalPath = resolve(process.cwd(), devPortal);
49
-
50
- // Get available port, prefers requestedPort but falls back to another free port
51
- const ports = Array.from(
52
- new Set([requestedPort, ...getPort.portNumbers(3000, 30009)])
53
- );
54
- const port = (await getPort({ port: ports })) as number;
55
- if (!ports.includes(port)) {
56
- throw new Error(`All valid ports (3000-3009) are closed`);
57
- }
58
- console.clear();
59
-
60
- if (port !== requestedPort) {
61
- console.log(chalk.yellow(`Port ${requestedPort} is taken, using ${port}`));
62
- }
63
-
64
- const projectName = context.projectName;
65
- const project = context.workspace.projects[projectName];
66
- const base = resolve(context.root, project.root);
67
-
68
- // Load user-defined viteConfig
69
- const viteConfigPath = getViteConfig(base);
70
- const userConfig = await loadConfigFromFile(
71
- {
72
- command: 'build',
73
- mode: 'production',
74
- },
75
- viteConfigPath
76
- );
77
-
78
- // Create express application
79
- const app = express();
80
- app.set('x-powered-by', false);
81
- app.use(express.static(devPortalPath));
82
-
83
- // Load Roma services
84
- const services = await loadServices(portalTarget);
85
- // Add proxy middleware for all roma-services
86
- services.forEach((p) =>
87
- app.use(
88
- p,
89
- createProxyMiddleware(p, { target: portalTarget, changeOrigin: true })
90
- )
91
- );
92
-
93
- // Range of port numbers for hmr, otherwise HMR won't work for multiple apps at the same time
94
- const hmrPorts = getPort.portNumbers(40000, 45000);
95
- const hmrPort = await getPort(hmrPorts);
96
-
97
- const viteConfig = createRomaViteConfig(
98
- userConfig.config,
99
- context,
100
- false,
101
- hmrPort
102
- );
103
- // Create Vite server in middleware mode
104
- const vite = await createViteServer(viteConfig);
105
-
106
- // Apply vite-middleware to the express app
107
- app.use(vite.middlewares);
108
-
109
- app.use(
110
- '/apim*',
111
- createProxyMiddleware('/apim', { target: portalTarget, changeOrigin: true })
112
- );
113
-
114
- app.use(
115
- // Custom proxy-setup for service discovery endpoint
116
- '/_discovery*',
117
- createProxyMiddleware('/_discovery', {
118
- target: portalTarget,
119
- changeOrigin: true, // Avoid API errors due to origin-conflicts
120
- secure: false,
121
- selfHandleResponse: true, // Tell the proxy we want to override the response
122
- onProxyRes: (proxyRes, req, res) => {
123
- const body: Array<Uint8Array> = [];
124
- proxyRes.on('data', function (chunk: Uint8Array) {
125
- body.push(chunk);
126
- });
127
- proxyRes.on('end', function () {
128
- const bodyStr = Buffer.concat(body).toString();
129
- const environment = JSON.parse(bodyStr) as EnvironmentResponse;
130
- // Override the services, and direct all api's from <target> to go via this proxy.
131
- environment.services.forEach((s) => {
132
- if (s.uri.includes(portalTarget)) {
133
- s.uri = s.uri.replace(portalTarget, `http://localhost:${port}`);
134
- }
135
- });
136
- res.end(JSON.stringify(environment));
137
- });
138
- },
139
- })
140
- );
141
-
142
- // Extract entrypoint-url
143
- const libConfig = vite.config.build.lib as LibraryOptions;
144
- const entry = libConfig.entry as Record<string, string>;
145
-
146
- // Custom proxy for app-list to add the current application
147
- app.get(
148
- '/api/apps',
149
- createProxyMiddleware('/api/apps', {
150
- target: portalTarget,
151
- changeOrigin: true,
152
- selfHandleResponse: true,
153
- onProxyRes: (proxyRes, req, res) => {
154
- const body: Array<Uint8Array> = [];
155
- proxyRes.on('data', function (chunk: Uint8Array) {
156
- body.push(chunk);
157
- });
158
- proxyRes.on('end', function () {
159
- const bodyStr = Buffer.concat(body).toString();
160
- const data = JSON.parse(bodyStr) as Array<AppManifest>;
161
- const atIndex =
162
- data?.findIndex((manifest) => manifest.key === projectName) ?? -1;
163
- // If existing app, we need to change the entry-point.
164
- if (atIndex > -1) {
165
- data[atIndex].entry = `/${entry.self}`;
166
- } else {
167
- // New app, so adding it to the app-list
168
- try {
169
- // Read and parse fusion-manifest
170
- const manifest = getManifest(vite.config.root);
171
- manifest.entry = `/${entry.self}`;
172
- data.push(manifest);
173
- } catch (ex) {
174
- throw new Error(
175
- chalk.red(
176
- `Fatal error: Failed to read fusion-manifest.json in ${vite.config.root}
177
- Application will now exit.`
178
- )
179
- );
180
- }
181
- }
182
- if (additionalProjects) {
183
- additionalProjects.forEach((project) => {
184
- const atIndex =
185
- data?.findIndex((manifest) => manifest.key === project.name) ??
186
- -1;
187
- if (atIndex >= 0) {
188
- data[atIndex] = {
189
- ...data[atIndex],
190
- entry: `/${entry[project.name]}`,
191
- };
192
- }
193
- });
194
- }
195
- res.json(data);
196
- });
197
- },
198
- })
199
- );
200
-
201
- // Roma portal api
202
- app.use(
203
- '/api/*',
204
- createProxyMiddleware('/api', {
205
- target: portalTarget,
206
- changeOrigin: true,
207
- })
208
- );
209
-
210
- // Roma SSE api
211
- app.use(
212
- '/eventstream/*',
213
- createProxyMiddleware('/eventstream', {
214
- target: portalTarget,
215
- changeOrigin: true,
216
- proxyTimeout: 1000 * 60 * 30,
217
- })
218
- );
219
-
220
- // SPA-style routing
221
- app.use('*', async (req, res) => {
222
- const htmlRaw = readFileSync(join(devPortalPath + '/index.html'), 'utf-8');
223
- const html = await vite.transformIndexHtml(req.url, htmlRaw);
224
- res.send(html);
225
- });
226
-
227
- return new Promise((resolve) => {
228
- // listen to requested port
229
- app.listen(port, () => {
230
- console.log(chalk.green('Roma dev server listening on port ' + port));
231
- if (open) {
232
- console.log(
233
- chalk.green(
234
- `Opening the application at http://localhost:${port}/apps/${projectName}`
235
- )
236
- );
237
- openBrowser(`http://localhost:${port}/apps/${projectName}`);
238
- } else {
239
- console.log(
240
- chalk.green(
241
- `Open the application at http://localhost:${port}/apps/${projectName}`
242
- )
243
- );
244
- }
245
- });
246
- app.on('close', () => {
247
- resolve({ success: true });
248
- });
249
- });
250
- }
@@ -1,9 +0,0 @@
1
- import { readdirSync } from 'node:fs';
2
- import { resolve } from 'path';
3
-
4
- export function getViteConfig(root: string) {
5
- const files = readdirSync(root);
6
- const file = files.find((f) => f.startsWith('vite.config'));
7
- if (!file) throw new Error(`No vite config found!`);
8
- return resolve(root, file);
9
- }
@@ -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
- }