@equinor/roma-nx-plugin 0.0.20 → 0.0.22
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/executors.json +0 -5
- package/migrations.json +32 -5
- package/package.json +17 -7
- package/src/executors/build/build.d.ts +4 -0
- package/src/executors/build/build.js +63 -0
- package/src/executors/build/build.js.map +1 -0
- package/src/executors/build/executor.js +2 -71
- package/src/executors/build/executor.js.map +1 -1
- package/src/executors/build/minify.d.ts +2 -0
- package/src/executors/build/minify.js +23 -0
- package/src/executors/build/minify.js.map +1 -0
- package/src/executors/build/schema.d.ts +1 -1
- package/src/executors/create-vite-config.d.ts +3 -0
- package/src/executors/create-vite-config.js +73 -0
- package/src/executors/create-vite-config.js.map +1 -0
- package/src/executors/executor-context.js +11 -9
- package/src/executors/executor-context.js.map +1 -1
- package/src/executors/publish/environment.d.ts +1 -0
- package/src/executors/publish/executor.js +1 -1
- package/src/executors/publish/executor.js.map +1 -1
- package/src/executors/publish/manifest-model.d.ts +2 -2
- package/src/executors/publish/publish-script.d.ts +1 -2
- package/src/executors/publish/publish-script.js +3 -3
- package/src/executors/publish/publish-script.js.map +1 -1
- package/src/executors/publish/schema.d.ts +1 -1
- package/src/executors/serve/executor.d.ts +1 -3
- package/src/executors/serve/executor.js +2 -50
- package/src/executors/serve/executor.js.map +1 -1
- package/src/executors/serve/schema.d.ts +3 -3
- package/src/executors/serve/schema.json +3 -3
- package/src/executors/serve/server.d.ts +3 -0
- package/src/executors/serve/server.js +162 -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 +14 -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/files/.eslintrc.json +130 -0
- package/src/generators/app/files/fusion-manifest.json.template +1 -1
- package/src/generators/app/files/src/App.tsx.template +10 -13
- package/src/generators/app/files/src/config.ts.template +8 -11
- package/src/generators/app/files/src/index.ts.template +19 -15
- package/src/generators/app/files/vite.config.d.ts +2 -0
- package/src/generators/app/files/vite.config.js +12 -15
- package/src/generators/app/files/vite.config.js.map +1 -0
- package/src/generators/app/generator.js +46 -60
- package/src/generators/app/generator.js.map +1 -1
- package/src/generators/app/schema.d.ts +2 -2
- package/src/generators/preset/generator.js +1 -24
- package/src/generators/preset/generator.js.map +1 -1
- package/src/generators/preset/schema.d.ts +2 -2
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.d.ts +2 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js +45 -0
- package/src/migrations/remove-fusion-cli/remove-fusion-cli.js.map +1 -0
- package/src/executors/portal/executor.d.ts +0 -5
- package/src/executors/portal/executor.js +0 -16
- package/src/executors/portal/executor.js.map +0 -1
- package/src/executors/portal/proxy.d.ts +0 -19
- package/src/executors/portal/proxy.js +0 -179
- package/src/executors/portal/proxy.js.map +0 -1
- package/src/executors/portal/schema.d.ts +0 -10
- package/src/executors/portal/schema.json +0 -36
- package/src/migrations/add-portal-proxy-target/add-portal-proxy-target.d.ts +0 -2
- package/src/migrations/add-portal-proxy-target/add-portal-proxy-target.js +0 -23
- package/src/migrations/add-portal-proxy-target/add-portal-proxy-target.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/serve/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/serve/executor.ts"],"names":[],"mappings":";;AAEA,qCAAwC;AAEzB,KAAK,UAAU,WAAW,CACvC,OAA4B,EAC5B,OAAwB;IAExB,OAAO,IAAA,qBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AALD,8BAKC"}
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "Path to custom dev-portal (from workspace root) (default: use ROMA dev-portal)"
|
|
20
20
|
},
|
|
21
|
-
"
|
|
21
|
+
"open": {
|
|
22
22
|
"type": "boolean",
|
|
23
|
-
"description": "Whether
|
|
24
|
-
"default":
|
|
23
|
+
"description": "Whether to open the application in your default browser. Default false",
|
|
24
|
+
"default": false
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"required": []
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createServer = void 0;
|
|
4
|
+
const openBrowser = require('open');
|
|
5
|
+
const express = require('express');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
const getPort = require('get-port-cjs');
|
|
8
|
+
const vite_1 = require("vite");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
12
|
+
const create_vite_config_1 = require("../create-vite-config");
|
|
13
|
+
const get_vite_config_1 = require("../utils/get-vite-config");
|
|
14
|
+
async function loadServices(portalTarget) {
|
|
15
|
+
try {
|
|
16
|
+
const req = await fetch(`${portalTarget}/_discovery/environments/current`);
|
|
17
|
+
const res = (await req.json());
|
|
18
|
+
return res.services
|
|
19
|
+
.filter((s) => s.uri.startsWith(portalTarget))
|
|
20
|
+
.map((s) => new URL(s.uri).pathname)
|
|
21
|
+
.filter((path) => path.length >= 3);
|
|
22
|
+
}
|
|
23
|
+
catch (ex) {
|
|
24
|
+
console.error(ex);
|
|
25
|
+
process.exit();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function createServer({ port: requestedPort = 3000, devPortal = 'node_modules/@equinor/roma-framework/dev-portal', portal: portalTarget = 'https://romadev.equinor.com', open, }, context) {
|
|
29
|
+
// Get path to dev-portal, this would be a flag from executor.
|
|
30
|
+
const devPortalPath = (0, path_1.resolve)(process.cwd(), devPortal);
|
|
31
|
+
// Get available port, prefers requestedPort but falls back to another free port
|
|
32
|
+
const ports = Array.from(new Set([requestedPort, ...getPort.portNumbers(3000, 30009)]));
|
|
33
|
+
const port = (await getPort({ port: ports }));
|
|
34
|
+
if (!ports.includes(port)) {
|
|
35
|
+
throw new Error(`All valid ports (3000-3009) are closed`);
|
|
36
|
+
}
|
|
37
|
+
console.clear();
|
|
38
|
+
if (port !== requestedPort) {
|
|
39
|
+
console.log(chalk.yellow(`Port ${requestedPort} is taken, using ${port}`));
|
|
40
|
+
}
|
|
41
|
+
const projectName = context.projectName;
|
|
42
|
+
const project = context.workspace.projects[projectName];
|
|
43
|
+
const base = (0, path_1.resolve)(context.root, project.root);
|
|
44
|
+
// Load user-defined viteConfig
|
|
45
|
+
const viteConfigPath = (0, get_vite_config_1.getViteConfig)(base);
|
|
46
|
+
const userConfig = await (0, vite_1.loadConfigFromFile)({
|
|
47
|
+
command: 'build',
|
|
48
|
+
mode: 'production',
|
|
49
|
+
}, viteConfigPath);
|
|
50
|
+
const viteConfig = userConfig.config;
|
|
51
|
+
// Create express application
|
|
52
|
+
const app = express();
|
|
53
|
+
app.set('x-powered-by', false);
|
|
54
|
+
app.use(express.static(devPortalPath));
|
|
55
|
+
// Load Roma services
|
|
56
|
+
const services = await loadServices(portalTarget);
|
|
57
|
+
// Add proxy middleware for all roma-services
|
|
58
|
+
services.forEach((p) => app.use(p, (0, http_proxy_middleware_1.createProxyMiddleware)(p, { target: portalTarget, changeOrigin: true })));
|
|
59
|
+
// Range of port numbers for hmr, otherwise HMR won't work for multiple apps at the same time
|
|
60
|
+
const hmrPorts = getPort.portNumbers(40000, 45000);
|
|
61
|
+
const hmrPort = await getPort(hmrPorts);
|
|
62
|
+
// Create Vite server in middleware mode
|
|
63
|
+
const vite = await (0, vite_1.createServer)((0, create_vite_config_1.createRomaViteConfig)(viteConfig, context, false, hmrPort));
|
|
64
|
+
// Apply vite-middleware to the express app
|
|
65
|
+
app.use(vite.middlewares);
|
|
66
|
+
app.use(
|
|
67
|
+
// Custom proxy-setup for service discovery endpoint
|
|
68
|
+
'/_discovery*', (0, http_proxy_middleware_1.createProxyMiddleware)('/_discovery', {
|
|
69
|
+
target: portalTarget,
|
|
70
|
+
changeOrigin: true, // Avoid API errors due to origin-conflicts
|
|
71
|
+
selfHandleResponse: true, // Tell the proxy we want to override the response
|
|
72
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
73
|
+
const body = [];
|
|
74
|
+
proxyRes.on('data', function (chunk) {
|
|
75
|
+
body.push(chunk);
|
|
76
|
+
});
|
|
77
|
+
proxyRes.on('end', function () {
|
|
78
|
+
const bodyStr = Buffer.concat(body).toString();
|
|
79
|
+
const environment = JSON.parse(bodyStr);
|
|
80
|
+
// Override the services, and direct all api's from <target> to go via this proxy.
|
|
81
|
+
environment.services.forEach((s) => {
|
|
82
|
+
if (s.uri.includes(portalTarget)) {
|
|
83
|
+
s.uri = s.uri.replace(portalTarget, `http://localhost:${port}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
res.end(JSON.stringify(environment));
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
}));
|
|
90
|
+
// Extract entrypoint-url
|
|
91
|
+
const entry = `/${vite.config.build.lib.entry}`;
|
|
92
|
+
// Custom proxy for app-list to add the current application
|
|
93
|
+
app.get('/api/apps', (0, http_proxy_middleware_1.createProxyMiddleware)('/api/apps', {
|
|
94
|
+
target: portalTarget,
|
|
95
|
+
changeOrigin: true,
|
|
96
|
+
selfHandleResponse: true,
|
|
97
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
98
|
+
const body = [];
|
|
99
|
+
proxyRes.on('data', function (chunk) {
|
|
100
|
+
body.push(chunk);
|
|
101
|
+
});
|
|
102
|
+
proxyRes.on('end', function () {
|
|
103
|
+
var _a;
|
|
104
|
+
const bodyStr = Buffer.concat(body).toString();
|
|
105
|
+
const data = JSON.parse(bodyStr);
|
|
106
|
+
const atIndex = (_a = data === null || data === void 0 ? void 0 : data.findIndex((manifest) => manifest.key === projectName)) !== null && _a !== void 0 ? _a : -1;
|
|
107
|
+
// If existing app, we need to change the entry-point.
|
|
108
|
+
if (atIndex > -1) {
|
|
109
|
+
data[atIndex].entry = entry;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// New app, so adding it to the app-list
|
|
113
|
+
try {
|
|
114
|
+
// Read and parse fusion-manifest
|
|
115
|
+
const manifest = JSON.parse((0, node_fs_1.readFileSync)((0, path_1.join)(vite.config.root, 'fusion-manifest.json'), 'utf8'));
|
|
116
|
+
manifest.entry = entry;
|
|
117
|
+
data.push(manifest);
|
|
118
|
+
}
|
|
119
|
+
catch (ex) {
|
|
120
|
+
throw new Error(chalk.red(`Fatal error: Failed to read fusion-manifest.json in ${vite.config.root}
|
|
121
|
+
Application will now exit.`));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
res.json(data);
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
}));
|
|
128
|
+
// Roma portal api
|
|
129
|
+
app.use('/api/*', (0, http_proxy_middleware_1.createProxyMiddleware)('/api', {
|
|
130
|
+
target: portalTarget,
|
|
131
|
+
changeOrigin: true,
|
|
132
|
+
}));
|
|
133
|
+
// Roma SSE api
|
|
134
|
+
app.use('/eventstream/*', (0, http_proxy_middleware_1.createProxyMiddleware)('/eventstream', {
|
|
135
|
+
target: portalTarget,
|
|
136
|
+
changeOrigin: true,
|
|
137
|
+
proxyTimeout: 1000 * 60 * 30,
|
|
138
|
+
}));
|
|
139
|
+
// SPA-style routing
|
|
140
|
+
app.use('*', async (req, res) => {
|
|
141
|
+
const htmlRaw = (0, node_fs_1.readFileSync)((0, path_1.join)(devPortalPath + '/index.html'), 'utf-8');
|
|
142
|
+
const html = await vite.transformIndexHtml(req.url, htmlRaw);
|
|
143
|
+
res.send(html);
|
|
144
|
+
});
|
|
145
|
+
return new Promise((resolve) => {
|
|
146
|
+
app.listen(port, () => {
|
|
147
|
+
console.log(chalk.green('Roma dev server listening on port ' + port));
|
|
148
|
+
if (open) {
|
|
149
|
+
console.log(chalk.green(`Opening the application at http://localhost:${port}/apps/${projectName}`));
|
|
150
|
+
openBrowser(`http://localhost:${port}/apps/${projectName}`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log(chalk.green(`Open the application at http://localhost:${port}/apps/${projectName}`));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
app.on('close', () => {
|
|
157
|
+
resolve({ success: true });
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
exports.createServer = createServer;
|
|
162
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/serve/server.ts"],"names":[],"mappings":";;;AAGA,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACxC,+BAIc;AACd,+BAAqC;AACrC,qCAAuC;AACvC,iEAA8D;AAG9D,8DAA6D;AAE7D,8DAAyD;AAEzD,KAAK,UAAU,YAAY,CAAC,YAAoB;IAC9C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,YAAY,kCAAkC,CAAC,CAAC;QAC3E,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwB,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ;aAChB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,EA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AoC,GAAG,IAAI,CAAC,CAAC,CAAC;YACtE,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,KAAK,CACT,+CAA+C,IAAI,SAAS,WAAW,EAAE,CAC1E,CACF,CAAC;gBACF,WAAW,CAAC,oBAAoB,IAAI,SAAS,WAAW,EAAE,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,KAAK,CACT,4CAA4C,IAAI,SAAS,WAAW,EAAE,CACvE,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACnB,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAjMD,oCAiMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getViteConfig(root: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getViteConfig = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
function getViteConfig(root) {
|
|
7
|
+
const files = (0, node_fs_1.readdirSync)(root);
|
|
8
|
+
const file = files.find((f) => f.startsWith('vite.config'));
|
|
9
|
+
if (!file)
|
|
10
|
+
throw new Error(`No vite config found!`);
|
|
11
|
+
return (0, path_1.resolve)(root, file);
|
|
12
|
+
}
|
|
13
|
+
exports.getViteConfig = getViteConfig;
|
|
14
|
+
//# sourceMappingURL=get-vite-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-vite-config.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/utils/get-vite-config.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,+BAA+B;AAE/B,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5D,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACpD,OAAO,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AALD,sCAKC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LogErrorOptions, LogOptions, LogType } from 'vite';
|
|
2
|
+
import { RollupError } from 'rollup';
|
|
3
|
+
type ILogger = {
|
|
4
|
+
info(msg: string, options?: LogOptions): void;
|
|
5
|
+
warn(msg: string, options?: LogOptions): void;
|
|
6
|
+
warnOnce(msg: string, options?: LogOptions): void;
|
|
7
|
+
error(msg: string, options?: LogErrorOptions): void;
|
|
8
|
+
clearScreen(type: LogType): void;
|
|
9
|
+
hasErrorLogged(error: Error | RollupError): boolean;
|
|
10
|
+
hasWarned: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class Logger implements ILogger {
|
|
13
|
+
private warnings;
|
|
14
|
+
private errors;
|
|
15
|
+
hasWarned: boolean;
|
|
16
|
+
constructor();
|
|
17
|
+
info(msg: string, options?: LogOptions): void;
|
|
18
|
+
warn(msg: string, options?: LogOptions): void;
|
|
19
|
+
warnOnce(msg: string, options?: LogOptions): void;
|
|
20
|
+
error(msg: string, options?: LogErrorOptions): void;
|
|
21
|
+
clearScreen(type: LogType): void;
|
|
22
|
+
hasErrorLogged(error: Error | RollupError): boolean;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const timestamp = () => {
|
|
6
|
+
const date = new Date();
|
|
7
|
+
const year = date.getFullYear();
|
|
8
|
+
const month = date.getUTCMonth() + 1;
|
|
9
|
+
const day = date.getDate();
|
|
10
|
+
const hour = date.getHours();
|
|
11
|
+
const minutes = date.getMinutes();
|
|
12
|
+
const seconds = date.getSeconds();
|
|
13
|
+
return `[${year}-${String(month).padStart(2, '0')}-${day} ${hour}:${minutes}:${seconds}]`;
|
|
14
|
+
};
|
|
15
|
+
const logModes = {
|
|
16
|
+
error: () => {
|
|
17
|
+
return chalk.red(`${timestamp()}: [roma]:`);
|
|
18
|
+
},
|
|
19
|
+
warning: () => {
|
|
20
|
+
return chalk.yellow(`${timestamp()}: [roma]:`);
|
|
21
|
+
},
|
|
22
|
+
info: () => {
|
|
23
|
+
return chalk.green(`${timestamp()}: [roma]:`);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// Custom logger, for now ignores error on roma-framework.umd.js, but can be improved on further.
|
|
27
|
+
class Logger {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.warnings = new Set();
|
|
30
|
+
this.errors = new Set();
|
|
31
|
+
this.hasWarned = false;
|
|
32
|
+
}
|
|
33
|
+
info(msg, options) {
|
|
34
|
+
if (options === null || options === void 0 ? void 0 : options.clear)
|
|
35
|
+
this.clearScreen('info');
|
|
36
|
+
console.info(logModes.info(), msg);
|
|
37
|
+
// Additional logic can be added here to handle options
|
|
38
|
+
}
|
|
39
|
+
warn(msg, options) {
|
|
40
|
+
console.warn(logModes.warning(), msg);
|
|
41
|
+
if (options === null || options === void 0 ? void 0 : options.clear)
|
|
42
|
+
this.clearScreen('warn');
|
|
43
|
+
this.hasWarned = true;
|
|
44
|
+
// Additional logic can be added here to handle options
|
|
45
|
+
}
|
|
46
|
+
warnOnce(msg, options) {
|
|
47
|
+
if (!this.warnings.has(msg)) {
|
|
48
|
+
this.warnings.add(msg);
|
|
49
|
+
this.warn(msg, options);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
error(msg, options) {
|
|
53
|
+
if (msg.includes('resolved id: /roma-framework.umd.js'))
|
|
54
|
+
return;
|
|
55
|
+
if (options === null || options === void 0 ? void 0 : options.clear)
|
|
56
|
+
this.clearScreen('error');
|
|
57
|
+
console.error(logModes.error(), msg);
|
|
58
|
+
}
|
|
59
|
+
clearScreen(type) {
|
|
60
|
+
console.clear();
|
|
61
|
+
if (type === 'error')
|
|
62
|
+
console.log(`Console cleared: ${type}`);
|
|
63
|
+
}
|
|
64
|
+
hasErrorLogged(error) {
|
|
65
|
+
return this.errors.has(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Logger = Logger;
|
|
69
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/utils/logger.ts"],"names":[],"mappings":";;;AAEA,+BAA+B;AAY/B,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAClC,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CACvC,CAAC,EACD,GAAG,CACJ,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,IAAI,OAAO,GAAG,CAAC;AA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C,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAyB;QAC1C,IAAI,GAAG,CAAC,QAAQ,CAAC,qCAAqC,CAAC;YAAE,OAAO;QAChE,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK;YAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,WAAW,CAAC,IAAa;QACvB,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,cAAc,CAAC,KAA0B;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AA7CD,wBA6CC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*", "vite.config.js", "app.config.js", "**/*.spec.tsx"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": [
|
|
7
|
+
"*.ts",
|
|
8
|
+
"*.tsx"
|
|
9
|
+
],
|
|
10
|
+
"excludedFiles": [
|
|
11
|
+
"*.spec.ts",
|
|
12
|
+
"*.spec.tsx",
|
|
13
|
+
"*.e2e-spec.ts",
|
|
14
|
+
"*.e2e-spec.tsx",
|
|
15
|
+
"*.cy.ts",
|
|
16
|
+
"*.cy.tsx",
|
|
17
|
+
"*vite.config.*"
|
|
18
|
+
],
|
|
19
|
+
"extends": [
|
|
20
|
+
"plugin:@nrwl/nx/typescript",
|
|
21
|
+
"eslint:recommended",
|
|
22
|
+
"plugin:prettier/recommended",
|
|
23
|
+
"prettier"
|
|
24
|
+
],
|
|
25
|
+
"rules": {
|
|
26
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
27
|
+
"@typescript-eslint/consistent-type-definitions": [
|
|
28
|
+
"warn",
|
|
29
|
+
"type"
|
|
30
|
+
],
|
|
31
|
+
"@typescript-eslint/array-type": [
|
|
32
|
+
"warn",
|
|
33
|
+
{
|
|
34
|
+
"default": "generic"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"prettier/prettier": [
|
|
38
|
+
"error"
|
|
39
|
+
],
|
|
40
|
+
"no-underscore-dangle": [
|
|
41
|
+
"off"
|
|
42
|
+
],
|
|
43
|
+
"no-undef": "warn",
|
|
44
|
+
"no-use-before-define": [
|
|
45
|
+
"off"
|
|
46
|
+
],
|
|
47
|
+
// Disabled because of Typescript
|
|
48
|
+
"react/prop-types": [
|
|
49
|
+
"off"
|
|
50
|
+
],
|
|
51
|
+
"no-unused-vars": [
|
|
52
|
+
"off"
|
|
53
|
+
],
|
|
54
|
+
// '@typescript-eslint/no-unused-vars': ['warn'],
|
|
55
|
+
// Disabled because of react not having default export
|
|
56
|
+
"import/default": [
|
|
57
|
+
"off"
|
|
58
|
+
],
|
|
59
|
+
"import/newline-after-import": [
|
|
60
|
+
"error"
|
|
61
|
+
],
|
|
62
|
+
"import/prefer-default-export": [
|
|
63
|
+
"off"
|
|
64
|
+
],
|
|
65
|
+
"import/namespace": [
|
|
66
|
+
"error",
|
|
67
|
+
{
|
|
68
|
+
"allowComputed": true
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"react/require-default-props": [
|
|
72
|
+
"off",
|
|
73
|
+
{
|
|
74
|
+
"forbidDefaultForRequired": true,
|
|
75
|
+
"functions": "defaultArguments"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"react/react-in-jsx-scope": "off",
|
|
79
|
+
// 'react/jsx-boolean-value': ['warn'],
|
|
80
|
+
"react/jsx-pascal-case": [
|
|
81
|
+
"error"
|
|
82
|
+
],
|
|
83
|
+
// 'react/no-danger': ['warn'],
|
|
84
|
+
"react/prefer-stateless-function": [
|
|
85
|
+
"error"
|
|
86
|
+
],
|
|
87
|
+
"react/no-unused-prop-types": [
|
|
88
|
+
"error"
|
|
89
|
+
],
|
|
90
|
+
"react/no-array-index-key": [
|
|
91
|
+
"error"
|
|
92
|
+
],
|
|
93
|
+
"react/no-typos": [
|
|
94
|
+
"error"
|
|
95
|
+
],
|
|
96
|
+
"react/destructuring-assignment": [
|
|
97
|
+
"error",
|
|
98
|
+
"always"
|
|
99
|
+
],
|
|
100
|
+
// 'jsx-a11y/accessible-emoji': ['warn'],
|
|
101
|
+
// 'jsx-a11y/control-has-associated-label': ['warn'],
|
|
102
|
+
"jsx-a11y/label-has-associated-control": [
|
|
103
|
+
"warn",
|
|
104
|
+
{
|
|
105
|
+
"labelComponents": [],
|
|
106
|
+
"labelAttributes": [],
|
|
107
|
+
"controlComponents": [],
|
|
108
|
+
"assert": "either",
|
|
109
|
+
"depth": 25
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
// '@typescript-eslint/restrict-plus-operands': ['warn'],
|
|
113
|
+
// '@typescript-eslint/ban-ts-comment': ['warn'],
|
|
114
|
+
"@typescript-eslint/no-empty-interface": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
"allowSingleExtends": true
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"files": [
|
|
124
|
+
"*.js",
|
|
125
|
+
"*.jsx"
|
|
126
|
+
],
|
|
127
|
+
"rules": {}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
<% if (!minimal) { %>
|
|
1
|
+
<% if (!minimal && !routing) { %>
|
|
2
2
|
import { Card, Typography, Button, Icon } from '@equinor/eds-core-react';
|
|
3
3
|
import { more_vertical } from '@equinor/eds-icons';
|
|
4
4
|
<% } else { %>
|
|
5
5
|
import { Typography } from '@equinor/eds-core-react';
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (routing) { %>
|
|
8
|
-
import {
|
|
8
|
+
import { RouterProvider, Link, RouteObject } from 'react-router-dom';
|
|
9
|
+
import { NavigationModule } from '@equinor/fusion-framework-module-navigation';
|
|
10
|
+
import { useAppModule } from '@equinor/fusion-framework-react-app';
|
|
9
11
|
|
|
10
12
|
const Root = () => <>
|
|
11
13
|
<Typography variant="body_short_link" as={Link} to="/sub">
|
|
@@ -23,21 +25,16 @@
|
|
|
23
25
|
);
|
|
24
26
|
|
|
25
27
|
|
|
26
|
-
const router = createBrowserRouter([
|
|
27
|
-
{ path: '/', element:
|
|
28
|
-
<Root/> },
|
|
29
|
-
{ path: '/sub', element:
|
|
30
|
-
<SubRoot/> },
|
|
31
|
-
], {
|
|
32
|
-
basename: '/apps/<%= name %>',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
28
|
<% } %>
|
|
37
29
|
|
|
38
30
|
|
|
39
|
-
export const App = (
|
|
31
|
+
export const App = (props: Record<string, unknown>) => {
|
|
40
32
|
<% if (!minimal && routing) { %>
|
|
33
|
+
const module = useAppModule<NavigationModule>('navigation');
|
|
34
|
+
const router = module.createRouter([
|
|
35
|
+
{ path: '/', element: <Root /> },
|
|
36
|
+
{ path: '/sub', element: <SubRoot /> },
|
|
37
|
+
] as Array<RouteObject>);
|
|
41
38
|
return (<>
|
|
42
39
|
<Typography variant="h1">Hello <%= name %>!</Typography>
|
|
43
40
|
<RouterProvider router={router}/>
|
|
@@ -2,24 +2,21 @@ import type { AppModuleInitiator } from '@equinor/fusion-framework-react-app';
|
|
|
2
2
|
<% if (fusionModules.includes("fusion-framework-module-context,fusion-framework-react-module-context")) { %>
|
|
3
3
|
import {enableContext} from '@equinor/fusion-framework-module-context';
|
|
4
4
|
<% } %>
|
|
5
|
+
<% if (routing) { %>
|
|
6
|
+
import { enableNavigation } from '@equinor/fusion-framework-module-navigation';
|
|
7
|
+
<% } %>
|
|
5
8
|
|
|
6
9
|
export const configure: AppModuleInitiator = (configurator, env) => {
|
|
7
10
|
|
|
8
11
|
<% if (fusionModules.includes("fusion-framework-module-context,fusion-framework-react-module-context")) { %>
|
|
9
12
|
enableContext(configurator);
|
|
10
13
|
<% } %>
|
|
11
|
-
<% if (fusionModules.includes("fusion-framework-module-auth")) { %>
|
|
12
|
-
configurator.configureMsal(
|
|
13
|
-
{
|
|
14
|
-
tenantId: '3aa4a235-b6e2-48d5-9195-7fcf05b459b0',
|
|
15
|
-
clientId: 'ROMA_CLIENT_ID_HERE',
|
|
16
|
-
redirectUri: '/authentication/login-callback',
|
|
17
|
-
},
|
|
18
|
-
{ requiresAuth: true },
|
|
19
|
-
);
|
|
20
|
-
<% } %>
|
|
21
|
-
/** print render environment arguments */
|
|
22
14
|
|
|
15
|
+
/** enable portal service */
|
|
16
|
+
configurator.useFrameworkServiceClient('portal');
|
|
17
|
+
<% if (routing) { %>
|
|
18
|
+
enableNavigation(configurator, '/apps/<%= name %>');
|
|
19
|
+
<% } %>
|
|
23
20
|
/** callback when configurations is created */
|
|
24
21
|
configurator.onConfigured((config) => {
|
|
25
22
|
console.log('application config created', config);
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
RomaComponentRenderArgs as ComponentRenderArgs,
|
|
6
|
+
makeComponent,
|
|
7
|
+
} from '@equinor/roma-framework';
|
|
5
8
|
|
|
6
9
|
import configure from './config';
|
|
7
10
|
import App from './App';
|
|
8
11
|
|
|
9
|
-
/** create a render component */
|
|
10
|
-
const appComponent = createElement(App);
|
|
11
|
-
|
|
12
|
-
/** create React render root component */
|
|
13
|
-
const createApp = (args: ComponentRenderArgs) => makeComponent(appComponent, args, configure);
|
|
14
|
-
|
|
15
12
|
/** Render function */
|
|
16
13
|
export const renderApp = (el: HTMLElement, args: ComponentRenderArgs) => {
|
|
17
|
-
/** make render element */
|
|
18
|
-
const app = createApp(args);
|
|
19
14
|
|
|
20
|
-
/** create render
|
|
21
|
-
const
|
|
15
|
+
/** create a render component */
|
|
16
|
+
const appComponent = createElement(App, args.env);
|
|
17
|
+
|
|
18
|
+
/** create React render root component */
|
|
19
|
+
const createApp = (args: ComponentRenderArgs) => makeComponent(appComponent, args, configure);
|
|
20
|
+
|
|
21
|
+
/** make render element */
|
|
22
|
+
const app = createApp(args);
|
|
23
|
+
|
|
24
|
+
/** create render root from provided element */
|
|
25
|
+
const root = createRoot(el);
|
|
22
26
|
|
|
23
|
-
/** render Application */
|
|
24
|
-
root.render(createElement(app));
|
|
27
|
+
/** render Application */
|
|
28
|
+
root.render(createElement(app));
|
|
25
29
|
|
|
26
|
-
/** Teardown */
|
|
27
|
-
return () => root.unmount();
|
|
30
|
+
/** Teardown */
|
|
31
|
+
return () => root.unmount();
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
export default renderApp;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vite_1 = require("vite");
|
|
4
|
+
exports.default = (0, vite_1.defineConfig)({
|
|
5
|
+
build: {
|
|
6
|
+
lib: {
|
|
7
|
+
entry: 'src/index.ts',
|
|
8
|
+
fileName: 'app-bundle',
|
|
9
|
+
formats: ['es'],
|
|
10
|
+
},
|
|
10
11
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
setupFiles: ['@equinor/roma-testing-utils/lib/override-imports.tsx'],
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
};
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=vite.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.config.js","sourceRoot":"","sources":["../../../../../../../plugins/roma/src/generators/app/files/vite.config.ts"],"names":[],"mappings":";;AAAA,+BAAoC;AAEpC,kBAAe,IAAA,mBAAY,EAAC;IAC1B,KAAK,EAAE;QACL,GAAG,EAAE;YACH,KAAK,EAAE,cAAc;YACrB,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,CAAC,IAAI,CAAC;SAChB;KACF;CACF,CAAC,CAAC"}
|