@equinor/roma-nx-plugin 0.0.13 → 0.0.15
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/package.json +2 -3
- package/src/executors/build/executor.js +6 -0
- package/src/executors/build/executor.js.map +1 -1
- package/src/executors/portal/proxy.d.ts +10 -0
- package/src/executors/portal/proxy.js +62 -4
- package/src/executors/portal/proxy.js.map +1 -1
- package/src/executors/portal/schema.json +1 -1
- package/src/executors/publish/publish-script.d.ts +7 -0
- package/src/executors/publish/publish-script.js +90 -23
- package/src/executors/publish/publish-script.js.map +1 -1
- package/src/executors/publish/readme.md +49 -0
- package/src/executors/serve/executor.js +6 -2
- package/src/executors/serve/executor.js.map +1 -1
- package/src/executors/serve/readme.md +12 -0
- package/src/generators/app/files/vite.config.js +1 -1
- package/src/generators/app/generator.js +5 -2
- package/src/generators/app/generator.js.map +1 -1
- package/src/generators/app/readme.md +13 -0
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/roma-nx-plugin",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"repository": "https://github.com/equinor/tops-roma",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@nx/devkit": "16.8.1",
|
|
8
8
|
"@nx/react": "16.8.1",
|
|
9
9
|
"@nx/linter": "16.8.1",
|
|
10
10
|
"@equinor/fusion-framework-cli": "~9.2.0",
|
|
11
|
-
"@equinor/roma-framework": "^0.0.
|
|
11
|
+
"@equinor/roma-framework": "^0.0.6",
|
|
12
12
|
"nx": "16.8.1",
|
|
13
13
|
"tslib": "^2.3.0",
|
|
14
14
|
"@azure/identity": "^3.3.0",
|
|
15
|
-
"@azure/storage-blob": "^12.16.0",
|
|
16
15
|
"http-proxy": "^1.18.1"
|
|
17
16
|
},
|
|
18
17
|
"type": "commonjs",
|
|
@@ -45,6 +45,12 @@ async function runExecutor(options, context) {
|
|
|
45
45
|
const outputPath = (_a = buildConfig.outputPath) !== null && _a !== void 0 ? _a : `dist/apps/${projectName}`;
|
|
46
46
|
const build = () => {
|
|
47
47
|
validateManifest(`${projectPath}/fusion-manifest.json`);
|
|
48
|
+
/**
|
|
49
|
+
* Build happens in two stages:
|
|
50
|
+
* - First we call the build-command from fusion's CLI
|
|
51
|
+
* - Once complete, we call the manifest command, converting the manifest to the expected format.
|
|
52
|
+
* This prepares the files to uploaded via the publish command.
|
|
53
|
+
*/
|
|
48
54
|
return (0, run_commands_impl_1.default)({
|
|
49
55
|
commands: [
|
|
50
56
|
`fusion-framework-cli app build -o ${context.root}/${outputPath}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/build/executor.ts"],"names":[],"mappings":";;;AAEA,uCAA0C;AAE1C,gHAA0E;AAC1E,mDAA6B;AAG7B;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAI,KAAQ,EAAE,KAAa;IACnD,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC,CAAC;IAChE,MAAM,UAAU,GAAW,KAAK,KAAK,EAAE,CAAC;IACxC,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,eAAe,CAAC,CAAC;KAC7D;IACD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,WAAW,CAAC,CAAC;KACzD;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,kGAAkG;IAClG,MAAM,QAAQ,GAAG,IAAA,qBAAY,EAAc,YAAY,CAAC,CAAC;IACzD,iBAAiB,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvC,iBAAiB,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C;QACjG,MAAM,KAAK,GAAG,uBAAuB,OAAO,CAAC,WAAW,OAAO,WAAW,EAAE,CAAC;QAC7E,OAAO,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CACvB,IAAA,2BAAW,EACT;YACE,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,EAAE;SACjB,EACD,OAAO,CACR,CACF,CAAC;KACH;SAAM;QACL,OAAO,KAAK,EAAE,CAAC;KAChB;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/build/executor.ts"],"names":[],"mappings":";;;AAEA,uCAA0C;AAE1C,gHAA0E;AAC1E,mDAA6B;AAG7B;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAI,KAAQ,EAAE,KAAa;IACnD,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC,CAAC;IAChE,MAAM,UAAU,GAAW,KAAK,KAAK,EAAE,CAAC;IACxC,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,eAAe,CAAC,CAAC;KAC7D;IACD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,WAAW,CAAC,CAAC;KACzD;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,kGAAkG;IAClG,MAAM,QAAQ,GAAG,IAAA,qBAAY,EAAc,YAAY,CAAC,CAAC;IACzD,iBAAiB,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACrD,IAAI,QAAQ,CA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,GAAG,EAAE,CACvB,IAAA,2BAAW,EACT;YACE,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,EAAE;SACjB,EACD,OAAO,CACR,CACF,CAAC;KACH;SAAM;QACL,OAAO,KAAK,EAAE,CAAC;KAChB;AACH,CAAC;AA7CD,8BA6CC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ServerOptions } from 'http-proxy';
|
|
3
3
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
/**
|
|
5
|
+
* This is a TypeScript function that creates a proxy server to forward HTTP requests to another server.
|
|
6
|
+
* @param port The port number on which the proxy server should listen for incoming requests.
|
|
7
|
+
* @param target The URL of the target server to which the HTTP requests should be forwarded.
|
|
8
|
+
* @param additionalTarget An optional object containing additional target servers that should be used for specific URLs. Each key in this object is a URL prefix that should be matched against the incoming request URL, and the corresponding value is an object containing the options to be passed to the http-proxy library for that URL prefix.
|
|
9
|
+
*
|
|
10
|
+
* @returns Object
|
|
11
|
+
* server: An instance of the Node.js http.Server class that represents the proxy server.
|
|
12
|
+
* proxy: An instance of the http-proxy library that is used to forward the HTTP requests to the target server.
|
|
13
|
+
*/
|
|
4
14
|
export declare const proxyServer: (port: number, target: string, additionalTarget?: Record<string, ServerOptions & {
|
|
5
15
|
ignoreTargetPath?: boolean;
|
|
6
16
|
}>) => {
|
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.proxyServer = void 0;
|
|
4
4
|
const http_proxy_1 = require("http-proxy");
|
|
5
5
|
const http_1 = require("http");
|
|
6
|
+
/**
|
|
7
|
+
* Function that sets up cors-handling locally, to ensure the proxy works as expected on any / all endpoints.
|
|
8
|
+
* @param req
|
|
9
|
+
* @param res
|
|
10
|
+
*/
|
|
6
11
|
const enableCors = (req, res) => {
|
|
7
12
|
var _a;
|
|
8
13
|
res.setHeader('access-control-allow-origin', (_a = req.headers.origin) !== null && _a !== void 0 ? _a : 'http://localhost:3001');
|
|
@@ -12,12 +17,28 @@ const enableCors = (req, res) => {
|
|
|
12
17
|
if (req.headers['access-control-request-headers']) {
|
|
13
18
|
res.setHeader('access-control-allow-headers', req.headers['access-control-request-headers']);
|
|
14
19
|
}
|
|
20
|
+
else {
|
|
21
|
+
res.setHeader('access-control-allow-headers', 'Last-Event-Id');
|
|
22
|
+
}
|
|
15
23
|
if (req.headers.origin) {
|
|
16
24
|
res.setHeader('access-control-allow-credentials', 'true');
|
|
17
25
|
}
|
|
18
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* This is a TypeScript function that creates a proxy server to forward HTTP requests to another server.
|
|
29
|
+
* @param port The port number on which the proxy server should listen for incoming requests.
|
|
30
|
+
* @param target The URL of the target server to which the HTTP requests should be forwarded.
|
|
31
|
+
* @param additionalTarget An optional object containing additional target servers that should be used for specific URLs. Each key in this object is a URL prefix that should be matched against the incoming request URL, and the corresponding value is an object containing the options to be passed to the http-proxy library for that URL prefix.
|
|
32
|
+
*
|
|
33
|
+
* @returns Object
|
|
34
|
+
* server: An instance of the Node.js http.Server class that represents the proxy server.
|
|
35
|
+
* proxy: An instance of the http-proxy library that is used to forward the HTTP requests to the target server.
|
|
36
|
+
*/
|
|
19
37
|
const proxyServer = (port, target, additionalTarget) => {
|
|
20
38
|
const asUri = new URL(target);
|
|
39
|
+
/**
|
|
40
|
+
* creates a new instance of createProxyServer() method from the http-proxy module, passing in an object with various configuration options.
|
|
41
|
+
*/
|
|
21
42
|
const proxy = (0, http_proxy_1.createProxyServer)({
|
|
22
43
|
target,
|
|
23
44
|
secure: false,
|
|
@@ -27,9 +48,13 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
27
48
|
followRedirects: true,
|
|
28
49
|
headers: {
|
|
29
50
|
'Sec-Fetch-Site': 'same-origin',
|
|
30
|
-
Accept: 'application/json',
|
|
51
|
+
// Accept: 'application/json',
|
|
31
52
|
},
|
|
32
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* This sets up an event listener for the proxyReq event, which is emitted when a request is received by the proxy server.
|
|
56
|
+
* It logs the request details to the console, removes the origin header from the request, removes the origin header from the response, and enables CORS.
|
|
57
|
+
*/
|
|
33
58
|
proxy.on('proxyReq', function (proxyReq, req, res) {
|
|
34
59
|
console.log(
|
|
35
60
|
// @ts-ignore
|
|
@@ -38,9 +63,19 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
38
63
|
res.removeHeader('origin');
|
|
39
64
|
enableCors(req, res);
|
|
40
65
|
});
|
|
66
|
+
/**
|
|
67
|
+
* This sets up an event listener for the proxyRes event, which is emitted when a response is received by the proxy server.
|
|
68
|
+
* It logs the response details to the console, enables CORS, and checks if the request URL matches /_discovery/environments/current.
|
|
69
|
+
* If it does, it reads the response body, replaces the target server URL with http://localhost:${port}, and sends the modified response to the original requester.
|
|
70
|
+
*/
|
|
41
71
|
proxy.on('proxyRes', function (proxyRes, req, res) {
|
|
42
72
|
console.log(`[RES] Response from ${req.url}`);
|
|
43
73
|
enableCors(req, res);
|
|
74
|
+
if (proxyRes.statusCode >= 400) {
|
|
75
|
+
console.log(req.rawHeaders);
|
|
76
|
+
console.error(proxyRes.rawHeaders);
|
|
77
|
+
console.error(proxyRes.statusMessage);
|
|
78
|
+
}
|
|
44
79
|
if (req.url === '/_discovery/environments/current') {
|
|
45
80
|
const body = [];
|
|
46
81
|
proxyRes.on('data', function (chunk) {
|
|
@@ -61,20 +96,28 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
61
96
|
proxy.on('open', () => {
|
|
62
97
|
console.log(`Proxy opened to ${target}`);
|
|
63
98
|
});
|
|
99
|
+
/**
|
|
100
|
+
* creates a new HTTP server instance using createServer() method from the http module, which listens for incoming requests and forwards them to the proxy server using proxy.web() method.
|
|
101
|
+
* It also sets up some default headers for CORS and checks if the incoming request method is OPTIONS.
|
|
102
|
+
* If it is, it sends a 204 response with the CORS headers and ends the response.
|
|
103
|
+
*/
|
|
64
104
|
const server = (0, http_1.createServer)((req, res) => {
|
|
65
105
|
var _a;
|
|
66
106
|
const headers = {
|
|
67
107
|
'Access-Control-Allow-Origin': (_a = req.headers.origin) !== null && _a !== void 0 ? _a : '*',
|
|
68
108
|
'Access-Control-Allow-Methods': 'OPTIONS, POST, GET, PUT, DELETE',
|
|
69
109
|
'Access-Control-Max-Age': 2592000,
|
|
70
|
-
'Access-Control-Allow-Headers': 'authorization,content-type',
|
|
110
|
+
'Access-Control-Allow-Headers': 'authorization,content-type,last-event-id',
|
|
71
111
|
};
|
|
72
112
|
if (req.method === 'OPTIONS') {
|
|
73
113
|
res.writeHead(204, headers);
|
|
74
114
|
res.end();
|
|
75
115
|
return;
|
|
76
116
|
}
|
|
77
|
-
|
|
117
|
+
/**
|
|
118
|
+
* checks if the incoming request URL matches /_discovery/environments/current.
|
|
119
|
+
* If it does, it logs a message to the console, and forwards the request to the proxy server with the target and selfHandleResponse options set.
|
|
120
|
+
*/
|
|
78
121
|
if (req.url === '/_discovery/environments/current') {
|
|
79
122
|
console.log(`[REWRITE] Rewriting all ROMA apis to use localhost:${port} as portal-url`);
|
|
80
123
|
proxy.web(req, res, {
|
|
@@ -83,6 +126,13 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
83
126
|
});
|
|
84
127
|
return;
|
|
85
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if the incoming request method is GET, POST, PUT, or DELETE.
|
|
131
|
+
* If it is, it checks if there are any additional configuration options for the incoming request URL.
|
|
132
|
+
* If there are, it reads the configuration options, replaces any environment variables in the headers, and removes the target path if necessary.
|
|
133
|
+
* It then forwards the request to the proxy server with the configuration options.
|
|
134
|
+
* If there are no additional configuration options, it forwards the request to the proxy server with the default target option.
|
|
135
|
+
*/
|
|
86
136
|
if (['GET', 'POST', 'PUT', 'DELETE'].indexOf(req.method) > -1) {
|
|
87
137
|
let targetKeys = Object.keys(additionalTarget !== null && additionalTarget !== void 0 ? additionalTarget : {});
|
|
88
138
|
const manualConfig = targetKeys.find((v) => req.url.startsWith(v));
|
|
@@ -97,7 +147,7 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
97
147
|
});
|
|
98
148
|
}
|
|
99
149
|
if (config.ignoreTargetPath && typeof config.target === 'string') {
|
|
100
|
-
req.url = req.url.replace(
|
|
150
|
+
req.url = req.url.replace(manualConfig, '');
|
|
101
151
|
}
|
|
102
152
|
proxy.web(req, res, config);
|
|
103
153
|
}
|
|
@@ -108,9 +158,17 @@ const proxyServer = (port, target, additionalTarget) => {
|
|
|
108
158
|
}
|
|
109
159
|
return;
|
|
110
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* If no match above, we return a 405 Method not allowed error.
|
|
163
|
+
*/
|
|
111
164
|
res.writeHead(405, headers);
|
|
112
165
|
res.end(`${req.method} is not allowed for the request.`);
|
|
113
166
|
});
|
|
167
|
+
/**
|
|
168
|
+
* @return an object with two properties:
|
|
169
|
+
* server, which is the HTTP server instance created by createServer() method.
|
|
170
|
+
* proxy, which is the HTTP proxy instance created by createProxyServer() method.
|
|
171
|
+
*/
|
|
114
172
|
return {
|
|
115
173
|
server,
|
|
116
174
|
proxy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/portal/proxy.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,+BAAqE;AAErE,MAAM,UAAU,GAAG,CACjB,GAAoB,EACpB,GAAoC,EACpC,EAAE;;IACF,GAAG,CAAC,SAAS,CACX,6BAA6B,EAC7B,MAAA,GAAG,CAAC,OAAO,CAAC,MAAM,mCAAI,uBAAuB,CAC9C,CAAC;IAEF,IAAI,GAAG,CAAC,OAAO,CAAC,+BAA+B,CAAC,EAAE;QAChD,GAAG,CAAC,SAAS,CACX,8BAA8B,EAC9B,GAAG,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAC7C,CAAC;KACH;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,gCAAgC,CAAC,EAAE;QACjD,GAAG,CAAC,SAAS,CACX,8BAA8B,EAC9B,GAAG,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAC9C,CAAC;KACH;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE;QACtB,GAAG,CAAC,SAAS,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;KAC3D;AACH,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/portal/proxy.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,+BAAqE;AAErE;;;;GAIG;AACH,MAAM,UAAU,GAAG,CACjB,GAAoB,EACpB,GAAoC,EACpC,EAAE;;IACF,GAAG,CAAC,SAAS,CACX,6BAA6B,EAC7B,MAAA,GAAG,CAAC,OAAO,CAAC,MAAM,mCAAI,uBAAuB,CAC9C,CAAC;IAEF,IAAI,GAAG,CAAC,OAAO,CAAC,+BAA+B,CAAC,EAAE;QAChD,GAAG,CAAC,SAAS,CACX,8BAA8B,EAC9B,GAAG,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAC7C,CAAC;KACH;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,gCAAgC,CAAC,EAAE;QACjD,GAAG,CAAC,SAAS,CACX,8BAA8B,EAC9B,GAAG,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAC9C,CAAC;KACH;SAAM;QACL,GAAG,CAAC,SAAS,CAAC,8BAA8B,EAAE,eAAe,CAAC,CAAC;KAChE;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE;QACtB,GAAG,CAAC,SAAS,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;KAC3D;AACH,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACI,MAAM,WAAW,GAAG,CACzB,IAAY,EACZ,MAAc,EACd,gBAGC,EACD,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,C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AG,CAAC,CAAC,CAAC;yBACxD;oBACH,CAAC,CAAC,CAAC;iBACJ;gBACD,IAAI,MAAM,CAAC,gBAAgB,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;oBAChE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;iBAC7C;gBACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;aAC7B;iBAAM;gBACL,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE;oBAClB,MAAM;iBACP,CAAC,CAAC;aACJ;YACD,OAAO;SACR;QAED;;WAEG;QACH,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,kCAAkC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH;;;;OAIG;IACH,OAAO;QACL,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AA9JW,QAAA,WAAW,eA8JtB"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { PublishExecutorSchema } from './schema';
|
|
2
|
+
/**
|
|
3
|
+
* Publishes the application to the specified environment.
|
|
4
|
+
*
|
|
5
|
+
* @param appName - The name of the application to publish.
|
|
6
|
+
* @param pathToOutput - The path to the output directory.
|
|
7
|
+
* @param options - The options for the publish operation.
|
|
8
|
+
*/
|
|
2
9
|
export declare const publishApplication: (appName: string, pathToOutput: string, options: PublishExecutorSchema) => Promise<void>;
|
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.publishApplication = void 0;
|
|
5
4
|
const promises_1 = require("node:fs/promises");
|
|
6
5
|
const node_path_1 = require("node:path");
|
|
7
6
|
const identity_1 = require("@azure/identity");
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* An enum representing the status of the publish operation.
|
|
9
|
+
* @enum {number}
|
|
10
|
+
*/
|
|
9
11
|
var Status;
|
|
10
12
|
(function (Status) {
|
|
11
13
|
Status[Status["SUCCESS"] = 0] = "SUCCESS";
|
|
12
14
|
Status[Status["ERROR"] = 1] = "ERROR";
|
|
13
15
|
})(Status || (Status = {}));
|
|
16
|
+
/**
|
|
17
|
+
* A map of environment names to their respective configurations.
|
|
18
|
+
*/
|
|
14
19
|
const configMap = {
|
|
15
20
|
dev: {
|
|
16
|
-
azureFdUrl:
|
|
21
|
+
azureFdUrl: `https://workbench-dev-d4huf3epb4fvfubz.a03.azurefd.net`,
|
|
22
|
+
romaUri: 'https://romadev.equinor.com',
|
|
17
23
|
apiScopes: ['83c0f0fa-eff6-4199-87a0-c25f28ca4bb3/.default'],
|
|
18
|
-
apiUri: (_a = process.env.API_URL) !== null && _a !== void 0 ? _a : 'https://workbench-enhgbqb2h2c9ana8.z01.azurefd.net',
|
|
19
24
|
},
|
|
20
25
|
qa: {
|
|
21
|
-
azureFdUrl:
|
|
26
|
+
azureFdUrl: ``,
|
|
27
|
+
romaUri: 'https://romaqa.equinor.com',
|
|
22
28
|
apiScopes: ['83c0f0fa-eff6-4199-87a0-c25f28ca4bb3/.default'],
|
|
23
|
-
apiUri: (_b = process.env.API_URL) !== null && _b !== void 0 ? _b : 'https://workbench-enhgbqb2h2c9ana8.z01.azurefd.net',
|
|
24
29
|
},
|
|
25
30
|
production: {
|
|
26
|
-
azureFdUrl:
|
|
31
|
+
azureFdUrl: ``,
|
|
32
|
+
romaUri: 'https://roma.equinor.com',
|
|
27
33
|
apiScopes: ['83c0f0fa-eff6-4199-87a0-c25f28ca4bb3/.default'],
|
|
28
|
-
apiUri: (_c = process.env.API_URL) !== null && _c !== void 0 ? _c : 'https://workbench-enhgbqb2h2c9ana8.z01.azurefd.net',
|
|
29
34
|
},
|
|
30
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Auth token to publish the application
|
|
38
|
+
*/
|
|
31
39
|
let token;
|
|
40
|
+
/**
|
|
41
|
+
* Publishes the application to the specified environment.
|
|
42
|
+
*
|
|
43
|
+
* @param appName - The name of the application to publish.
|
|
44
|
+
* @param pathToOutput - The path to the output directory.
|
|
45
|
+
* @param options - The options for the publish operation.
|
|
46
|
+
*/
|
|
32
47
|
const publishApplication = async (appName, pathToOutput, options) => {
|
|
33
48
|
const env = options.environment;
|
|
34
49
|
const config = configMap[env];
|
|
@@ -46,8 +61,11 @@ const publishApplication = async (appName, pathToOutput, options) => {
|
|
|
46
61
|
throw new Error(`ManifestValidationError`);
|
|
47
62
|
}
|
|
48
63
|
console.log(`Reading & uploading bundle for ${appName}`);
|
|
49
|
-
await uploadBundle(appName, bundle);
|
|
50
|
-
|
|
64
|
+
const bundleResult = await uploadBundle(appName, bundle, config);
|
|
65
|
+
if (bundleResult === Status.ERROR) {
|
|
66
|
+
throw new Error('Failed to upload application');
|
|
67
|
+
}
|
|
68
|
+
console.log(`Reading & uploading application manifest to ${config.romaUri}`);
|
|
51
69
|
const status = await publishManifest(parsedManifest, config);
|
|
52
70
|
if (status === Status.ERROR) {
|
|
53
71
|
throw new Error(`Failed to publish application ${appName}`);
|
|
@@ -57,6 +75,11 @@ const publishApplication = async (appName, pathToOutput, options) => {
|
|
|
57
75
|
}
|
|
58
76
|
};
|
|
59
77
|
exports.publishApplication = publishApplication;
|
|
78
|
+
/**
|
|
79
|
+
* Authenticates the user and returns the authentication token.
|
|
80
|
+
*
|
|
81
|
+
* @returns The authentication token.
|
|
82
|
+
*/
|
|
60
83
|
async function authenticate() {
|
|
61
84
|
if (token)
|
|
62
85
|
return token;
|
|
@@ -65,9 +88,15 @@ async function authenticate() {
|
|
|
65
88
|
token = tokenHolder.token;
|
|
66
89
|
return token;
|
|
67
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Gets a list of valid roma categories
|
|
93
|
+
*
|
|
94
|
+
* @param config - The configuration for the environment.
|
|
95
|
+
* @returns The categories for roma.
|
|
96
|
+
*/
|
|
68
97
|
async function getCategories(config) {
|
|
69
98
|
const token = await authenticate();
|
|
70
|
-
const req = await fetch(`${config.
|
|
99
|
+
const req = await fetch(`${config.romaUri}/api/apps/categories`, {
|
|
71
100
|
headers: {
|
|
72
101
|
Authorization: `Bearer ${token}`,
|
|
73
102
|
'Content-Type': 'application/json',
|
|
@@ -81,13 +110,19 @@ async function getCategories(config) {
|
|
|
81
110
|
return await req.json();
|
|
82
111
|
}
|
|
83
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Publishes the manifest for the application.
|
|
115
|
+
*
|
|
116
|
+
* @param manifest - The manifest for the application.
|
|
117
|
+
* @param config - The configuration for the application.
|
|
118
|
+
* @returns The status of the publish operation.
|
|
119
|
+
*/
|
|
84
120
|
async function publishManifest(manifest, config) {
|
|
85
121
|
manifest.description = manifest.description || manifest.name;
|
|
86
|
-
manifest.categoryId = 'f07e5ff3-05d6-4d8b-a056-68c3c1968279';
|
|
87
122
|
const { major, minor, patch } = manifest.version;
|
|
88
123
|
manifest.entry = `${config.azureFdUrl}/applications/bundle/${manifest.key}/app-bundle.js?version=${major}.${minor}.${patch}`;
|
|
89
124
|
const token = await authenticate();
|
|
90
|
-
const req = await fetch(`${config.
|
|
125
|
+
const req = await fetch(`${config.romaUri}/api/apps`, {
|
|
91
126
|
method: 'POST',
|
|
92
127
|
headers: {
|
|
93
128
|
Authorization: `Bearer ${token}`,
|
|
@@ -105,21 +140,53 @@ async function publishManifest(manifest, config) {
|
|
|
105
140
|
return Status.ERROR;
|
|
106
141
|
}
|
|
107
142
|
}
|
|
108
|
-
|
|
109
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Uploads the bundle for the application to Azure Blob Storage.
|
|
145
|
+
*
|
|
146
|
+
* @param appName - The name of the application.
|
|
147
|
+
* @param bundle - The bundle for the application.
|
|
148
|
+
*/
|
|
149
|
+
async function uploadBundle(appName, bundle, config) {
|
|
150
|
+
const fd = new FormData();
|
|
151
|
+
fd.set('bundleFile', new Blob([bundle.toString('utf-8')]));
|
|
152
|
+
const token = await authenticate();
|
|
153
|
+
const req = await fetch(`${config.romaUri}/api/apps/key/${appName}/bundle`, {
|
|
154
|
+
method: 'PUT',
|
|
155
|
+
headers: {
|
|
156
|
+
Authorization: `Bearer ${token}`,
|
|
157
|
+
},
|
|
158
|
+
body: fd,
|
|
159
|
+
});
|
|
160
|
+
if (req.status < 400) {
|
|
161
|
+
console.log(`Successfully uploaded bundle to ${appName}/app-bundle.js`);
|
|
162
|
+
return Status.SUCCESS;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
console.error(`Encountered a problem when publishing application: Received statuscode ${req.status}`);
|
|
166
|
+
const err = await req.json();
|
|
167
|
+
console.error(err);
|
|
168
|
+
return Status.ERROR;
|
|
169
|
+
}
|
|
170
|
+
/* const blobServiceClient = new BlobServiceClient(
|
|
171
|
+
`https://topsroma.blob.core.windows.net`,
|
|
172
|
+
new DefaultAzureCredential()
|
|
173
|
+
);
|
|
110
174
|
const client = blobServiceClient.getContainerClient('$web');
|
|
111
175
|
const blobName = `${appName}/app-bundle.js`;
|
|
112
176
|
const cl = client.getBlockBlobClient(blobName);
|
|
113
|
-
const res = await cl.upload(
|
|
177
|
+
const res = await cl.upload(
|
|
178
|
+
bundle.toString('utf-8'),
|
|
179
|
+
bundle.toString().length,
|
|
180
|
+
{
|
|
114
181
|
blobHTTPHeaders: {
|
|
115
|
-
|
|
182
|
+
blobContentType: 'application/javascript',
|
|
116
183
|
},
|
|
117
|
-
|
|
184
|
+
}
|
|
185
|
+
);
|
|
118
186
|
if (res.errorCode) {
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
187
|
+
console.error('Failed to upload file to storage account', res.errorCode);
|
|
188
|
+
} else {
|
|
189
|
+
console.log(`Successfully uploaded bundle to ${appName}/app-bundle.js`);
|
|
190
|
+
}*/
|
|
124
191
|
}
|
|
125
192
|
//# sourceMappingURL=publish-script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-script.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/publish/publish-script.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish-script.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/publish/publish-script.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,yCAAiC;AACjC,8CAAyD;AAIzD;;;GAGG;AACH,IAAK,MAGJ;AAHD,WAAK,MAAM;IACT,yCAAO,CAAA;IACP,qCAAK,CAAA;AACP,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAeD;;GAEG;AACH,MAAM,SAAS,GAA2B;IACxC,GAAG,EAAE;QACH,UAAU,EAAE,wDAAwD;QACpE,OAAO,EAAE,6BAA6B;QACtC,SAAS,EAAE,CAAC,+CAA+C,CAAC;KAC7D;IACD,EAAE,EAAE;QACF,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,4BAA4B;QACrC,SAAS,EAAE,CAAC,+CAA+C,CAAC;KAC7D;IACD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,0BAA0B;QACnC,SAAS,EAAE,CAAC,+CAA+C,CAAC;KAC7D;CACF,CAAC;AAEF;;GAEG;AACH,IAAI,KAAa,CAAC;AAElB;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,KAAK,EACrC,OAAe,EACf,YAAoB,EACpB,OAA8B,EAC9B,EAAE;IACF,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;IAChC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAA,gBAAI,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAA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AE;KACT,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,mCAAmC,OAAO,gBAAgB,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;SAAM;QACL,OAAO,CAAC,KAAK,CACX,0EAA0E,GAAG,CAAC,MAAM,EAAE,CACvF,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC,KAAK,CAAC;KACrB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;AACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Roma Publish Script
|
|
2
|
+
|
|
3
|
+
This is a NX executor script for publishing Roma applications to Azure Blob Storage and the Roma API.
|
|
4
|
+
|
|
5
|
+
Usage of this executor is documented further in [confluence](https://oiltradeent.atlassian.net/wiki/spaces/LS/pages/3781885953/Developer+tooling+for+Roma+applications)
|
|
6
|
+
|
|
7
|
+
## Code Explanation
|
|
8
|
+
|
|
9
|
+
This script exports a default asynchronous function `runExecutor` which is what NX calls on executors.
|
|
10
|
+
|
|
11
|
+
The function reads the configuration of the project and builds the project to the specified output directory. It then reads the built application bundle and manifest and publishes the application to the specified environment using the Roma API.
|
|
12
|
+
|
|
13
|
+
The `publishApplication` function is responsible for publishing the application to the specified environment. It takes the following parameters:
|
|
14
|
+
- `appName`: The name of the application to publish.
|
|
15
|
+
- `pathToOutput`: The path to the output directory.
|
|
16
|
+
- `options`: The options for the publish operation.
|
|
17
|
+
|
|
18
|
+
The function reads the built application bundle and manifest and publishes the application to the specified environment using the Roma API. It also validates the manifest to ensure that the categoryId is valid.
|
|
19
|
+
|
|
20
|
+
The `authenticate` function is responsible for authenticating the user and returning the authentication token. It uses the `DefaultAzureCredential` class from the `@azure/identity` package to authenticate the user.
|
|
21
|
+
|
|
22
|
+
The `getCategories` function is responsible for getting a list of valid Roma categories. It takes the following parameter:
|
|
23
|
+
- `config`: The configuration for the environment.
|
|
24
|
+
|
|
25
|
+
The function uses the `fetch` function to make a request to the Roma API to get the list of categories.
|
|
26
|
+
|
|
27
|
+
The `publishManifest` function is responsible for publishing the manifest for the application. It takes the following parameters:
|
|
28
|
+
- `manifest`: The manifest for the application.
|
|
29
|
+
- `config`: The configuration for the application.
|
|
30
|
+
|
|
31
|
+
The function uses the `fetch` function to make a request to the Roma API to publish the manifest.
|
|
32
|
+
|
|
33
|
+
The `uploadBundle` function is responsible for uploading the bundle for the application to Azure Blob Storage. It takes the following parameters:
|
|
34
|
+
- `appName`: The name of the application.
|
|
35
|
+
- `bundle`: The bundle for the application.
|
|
36
|
+
|
|
37
|
+
The function uses the `@azure/storage-blob` package to upload the bundle to Azure Blob Storage.
|
|
38
|
+
## Code Explanation (continued)
|
|
39
|
+
|
|
40
|
+
The script also defines a few types and interfaces:
|
|
41
|
+
- `BuildConfiguration`: An interface that extends `ProjectConfiguration` and adds an optional `outputPath` property.
|
|
42
|
+
- `Config`: An interface that represents the configuration for the publish script.
|
|
43
|
+
- `Status`: An enum that represents the status of the publish operation.
|
|
44
|
+
- `Manifest`: An interface that represents the manifest for the application.
|
|
45
|
+
- `PublishExecutorSchema`: An interface that represents the options for the publish operation.
|
|
46
|
+
|
|
47
|
+
The script uses the `node:fs/promises` and `node:path` modules to read files and join paths. It also uses the `@azure/identity` and `@azure/storage-blob` packages to authenticate the user and upload the application bundle to Azure Blob Storage.
|
|
48
|
+
|
|
49
|
+
Overall, this script provides a convenient way to publish Roma applications to Azure Blob Storage and the Roma API.
|
|
@@ -7,19 +7,23 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
7
7
|
// const depPath = require.resolve('@equinor-roma/framework');
|
|
8
8
|
async function runExecutor(options, context) {
|
|
9
9
|
var _a;
|
|
10
|
+
// Get the name and root directory of the project.
|
|
10
11
|
const projectName = context.projectName;
|
|
11
12
|
const project = context.workspace.projects[projectName];
|
|
12
13
|
const cwd = path.resolve(context.root, project.root);
|
|
14
|
+
// Set up extra arguments for the Fusion CLI command.
|
|
13
15
|
const extraFusionArgs = [];
|
|
14
16
|
if (options.portal) {
|
|
15
17
|
extraFusionArgs.push(`--portal=${options.portal}`);
|
|
16
18
|
}
|
|
17
19
|
if (options.devPortal) {
|
|
20
|
+
// If a custom dev-portal is specified, use it.
|
|
18
21
|
const portalPath = path.join(context.root, options.devPortal);
|
|
19
22
|
const relativePath = path.relative(cwd, portalPath);
|
|
20
23
|
extraFusionArgs.push(`--dev-portal ${relativePath}`);
|
|
21
24
|
}
|
|
22
25
|
else {
|
|
26
|
+
// If no custom dev-portal is specified, we use the default one.
|
|
23
27
|
// This is a relative path to the dev-portal (see comment on l#5)
|
|
24
28
|
// const relative = path.relative(projectPath, depPath);
|
|
25
29
|
// Change this to the dependency dev portal location.
|
|
@@ -30,8 +34,9 @@ async function runExecutor(options, context) {
|
|
|
30
34
|
`fusion-framework-cli app dev ${extraFusionArgs.join(' ')} -p ${(_a = options.port) !== null && _a !== void 0 ? _a : 3000}`,
|
|
31
35
|
];
|
|
32
36
|
if (options.proxy) {
|
|
37
|
+
// If the `--proxy` flag is set, run the portal target.
|
|
33
38
|
if (!project.targets.portal) {
|
|
34
|
-
//
|
|
39
|
+
// But not if we dont have a portal-target
|
|
35
40
|
console.error(`\x1b[31m Proxy Error: Target "portal" not defined for project, portal-proxy will not run. \x1b[0m`);
|
|
36
41
|
}
|
|
37
42
|
else {
|
|
@@ -40,7 +45,6 @@ async function runExecutor(options, context) {
|
|
|
40
45
|
}
|
|
41
46
|
const manifestPath = path.relative(cwd, path.resolve(project.root, 'fusion-manifest.json'));
|
|
42
47
|
extraFusionArgs.push(`--manifest ${manifestPath}`);
|
|
43
|
-
const { projectsConfigurations, nxJsonConfiguration, workspace } = context, rest = tslib_1.__rest(context, ["projectsConfigurations", "nxJsonConfiguration", "workspace"]);
|
|
44
48
|
return (0, run_commands_impl_1.default)({
|
|
45
49
|
commands,
|
|
46
50
|
parallel: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/serve/executor.ts"],"names":[],"mappings":";;;AAEA,gHAA0E;AAC1E,mDAA6B;AAC7B,wEAAwE;AACxE,8DAA8D;AAE/C,KAAK,UAAU,WAAW,CACvC,OAA4B,EAC5B,OAAwB;;IAExB,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD,MAAM,eAAe,GAAkB,EAAE,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;KACpD;IACD,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACpD,eAAe,CAAC,IAAI,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;KACtD;SAAM;QACL,iEAAiE;QACjE,wDAAwD;QACxD,qDAAqD;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAC5B,GAAG,EACH,IAAI,CAAC,OAAO,CACV,OAAO,CAAC,IAAI,EACZ,iDAAiD,CAClD,CACF,CAAC;QACF,eAAe,CAAC,IAAI,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC;KAClD;IACD,MAAM,QAAQ,GAAG;QACf,gCAAgC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,OACvD,MAAA,OAAO,CAAC,IAAI,mCAAI,IAClB,EAAE;KACH,CAAC;IACF,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE;YAC3B,
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/executors/serve/executor.ts"],"names":[],"mappings":";;;AAEA,gHAA0E;AAC1E,mDAA6B;AAC7B,wEAAwE;AACxE,8DAA8D;AAE/C,KAAK,UAAU,WAAW,CACvC,OAA4B,EAC5B,OAAwB;;IAExB,kDAAkD;IAClD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD,qDAAqD;IACrD,MAAM,eAAe,GAAkB,EAAE,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;KACpD;IACD,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,+CAA+C;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACpD,eAAe,CAAC,IAAI,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;KACtD;SAAM;QACL,gEAAgE;QAChE,iEAAiE;QACjE,wDAAwD;QACxD,qDAAqD;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAC5B,GAAG,EACH,IAAI,CAAC,OAAO,CACV,OAAO,CAAC,IAAI,EACZ,iDAAiD,CAClD,CACF,CAAC;QACF,eAAe,CAAC,IAAI,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC;KAClD;IACD,MAAM,QAAQ,GAAG;QACf,gCAAgC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,OACvD,MAAA,OAAO,CAAC,IAAI,mCAAI,IAClB,EAAE;KACH,CAAC;IACF,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,uDAAuD;QACvD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE;YAC3B,0CAA0C;YAC1C,OAAO,CAAC,KAAK,CACX,mGAAmG,CACpG,CAAC;SACH;aAAM;YACL,QAAQ,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC;SAChD;KACF;IACD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAChC,GAAG,EACH,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,sBAAsB,CAAC,CACnD,CAAC;IACF,eAAe,CAAC,IAAI,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IACnD,OAAO,IAAA,2BAAW,EAChB;QACE,QAAQ;QACR,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,EAAE;KACjB,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AA/DD,8BA+DC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
The `runExecutor` function is an async function that serves the application using the Fusion CLI. It takes two parameters:
|
|
2
|
+
|
|
3
|
+
- `options` - The options for serving the application. This is an object that conforms to the `ServeExecutorSchema` interface.
|
|
4
|
+
- `context` - The context for serving the application. This is an object that conforms to the `ExecutorContext` interface.
|
|
5
|
+
|
|
6
|
+
The function starts by getting the name and root directory of the project from the `context` object.
|
|
7
|
+
It then sets up extra arguments for the Fusion CLI command based on the `options` object.
|
|
8
|
+
If a custom dev-portal is specified, it is used instead of the default one.
|
|
9
|
+
If the `--proxy` flag is set, the `portal` target is run.
|
|
10
|
+
Finally, the function sets up the path to the manifest file and removes unnecessary properties from the `context` object.
|
|
11
|
+
|
|
12
|
+
The function then runs the command using the `runCommands` function and returns a `Promise<void>`
|
|
@@ -4,7 +4,7 @@ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
|
4
4
|
|
|
5
5
|
export default ({ mode, command }) => {
|
|
6
6
|
return defineConfig({
|
|
7
|
-
plugins:
|
|
7
|
+
plugins: [react(), nxViteTsPaths()],
|
|
8
8
|
resolve: {
|
|
9
9
|
alias: {},
|
|
10
10
|
},
|
|
@@ -9,7 +9,7 @@ const modules_1 = require("./data/modules");
|
|
|
9
9
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
10
10
|
async function addDependencies(tree, options) {
|
|
11
11
|
let dependencies = {
|
|
12
|
-
'@equinor/roma-framework': '^0.0.
|
|
12
|
+
'@equinor/roma-framework': '^0.0.6',
|
|
13
13
|
'@equinor/fusion-framework': '^7.0.19',
|
|
14
14
|
'@equinor/fusion-framework-module-app': '^5.2.4',
|
|
15
15
|
'@equinor/eds-core-react': '^0.32.4',
|
|
@@ -18,7 +18,7 @@ async function addDependencies(tree, options) {
|
|
|
18
18
|
'@equinor/fusion-framework-react': '^5.2.3',
|
|
19
19
|
'@equinor/fusion-framework-react-app': '^4.1.2',
|
|
20
20
|
'@equinor/fusion-framework-react-module': '^3.0.5',
|
|
21
|
-
'styled-components': '^
|
|
21
|
+
'styled-components': '^6.0.8',
|
|
22
22
|
};
|
|
23
23
|
options.fusionModules
|
|
24
24
|
.flatMap((module) => module.split(','))
|
|
@@ -104,6 +104,9 @@ async function appGenerator(tree, options) {
|
|
|
104
104
|
// See: https://eslint.org/docs/latest/extend/shareable-configs
|
|
105
105
|
// addExtendsToLintConfig(tree, options.appProjectRoot, '@equinor/roma');
|
|
106
106
|
}
|
|
107
|
+
if (options.skipPackageJson) {
|
|
108
|
+
return () => true;
|
|
109
|
+
}
|
|
107
110
|
return () => {
|
|
108
111
|
(0, devkit_1.installPackagesTask)(tree);
|
|
109
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../plugins/roma/src/generators/app/generator.ts"],"names":[],"mappings":";;;;AAAA,uCAWoB;AACpB,mDAA6B;AAE7B,qCAAiD;AAEjD,4CAAyC;AACzC,6EAAsF;AAEtF,KAAK,UAAU,eAAe,CAC5B,IAAU,EACV,OAA2E;IAE3E,IAAI,YAAY,GAA2B;QACzC,yBAAyB,EAAE,QAAQ;QACnC,2BAA2B,EAAE,SAAS;QACtC,sCAAsC,EAAE,QAAQ;QAChD,yBAAyB,EAAE,SAAS;QACpC,oBAAoB,EAAE,SAAS;QAC/B,qBAAqB,EAAE,QAAQ;QAC/B,iCAAiC,EAAE,QAAQ;QAC3C,qCAAqC,EAAE,QAAQ;QAC/C,wCAAwC,EAAE,QAAQ;QAClD,mBAAmB,EAAE,QAAQ;KAC9B,CAAC;IACF,OAAO,CAAC,aAAa;SAClB,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACtC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAClB,YAAY,CAAC,YAAY,MAAM,EAAE,CAAC,GAAG,iBAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACL,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,YAAY,mCACP,YAAY,KACf,6CAA6C,EAAE,QAAQ,GACxD,CAAC;KACH;IACD,MAAM,eAAe,GAAG;QACtB,+BAA+B,EAAE,QAAQ;QACzC,qBAAqB,EAAE,QAAQ;KAChC,CAAC;IACF,OAAO,IAAA,yBAAgB,EACrB,GAAG;QACD,IAAA,0CAAiC,EAC/B,IAAI,EACJ,MAAM,CAA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AC;IACrC,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,eAAe,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,iBAAiB,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,SAAS,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,iBAAiB,CAAC,CAAC;IAE7C,IAAI,OAAO,CAAC,MAAM,IAAI,IAAA,qCAAuB,EAAC,IAAI,CAAC,EAAE;QACnD,oDAAoD;QACpD,2DAA2D;QAC3D,+DAA+D;QAC/D,yEAAyE;KAC1E;IAED,IAAI,OAAO,CAAC,eAAe,EAAE;QAC3B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;KACnB;IAED,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAnDD,oCAmDC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Readme for Roma Application Generator
|
|
2
|
+
|
|
3
|
+
## Code Explanation
|
|
4
|
+
|
|
5
|
+
The generator is implemented in `app-generator.ts` and exports a single `appGenerator` function.
|
|
6
|
+
|
|
7
|
+
The `appGenerator` function takes two arguments: a `Tree` object representing the file system of the Nx workspace, and an `AppGeneratorSchema` object representing the options passed to the generator.
|
|
8
|
+
|
|
9
|
+
The function first calls the `applicationGenerator` function from the `@nx/react` package to generate a new React application using the options passed to the generator. It then updates the `targets` section of the `project.json` file for the new application to include the Roma-specific targets (build, serve, portal, and publish), and adds the necessary dependencies to the `package.json` file.
|
|
10
|
+
|
|
11
|
+
The function then generates several files based on the options passed to the generator, including a `fusion-manifest.json` file, a `tsconfig.json` file, and a `vite.config.ts` file. It also deletes several files and directories that are not needed for a Roma application, but that are generated by `@nx/react`'s generator.
|
|
12
|
+
|
|
13
|
+
Finally, the function returns a function that installs the necessary packages using the `installPackagesTask` function from the `@nx/devkit` package. If the `skipPackageJson` option is set to `true`, the function returns a function that does nothing instead.
|