@equinor/fusion-framework-cli 5.0.8 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.1.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@5.0.8...@equinor/fusion-framework-cli@5.1.0) (2023-03-20)
7
+
8
+ ### Features
9
+
10
+ - **cli:** allow configuring portal host in cli ([9641b21](https://github.com/equinor/fusion-framework/commit/9641b215a1bff957687e9eda661679f000588a47))
11
+
6
12
  ## [5.0.8](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@5.0.7...@equinor/fusion-framework-cli@5.0.8) (2023-03-20)
7
13
 
8
14
  **Note:** Version bump only for package @equinor/fusion-framework-cli
package/bin/app-config.js CHANGED
@@ -7,17 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
10
  import path from 'path';
22
11
  import fs from 'fs';
23
12
  import { findUpSync } from 'find-up';
@@ -46,19 +35,19 @@ const loadConfigFromJavascript = (file) => __awaiter(void 0, void 0, void 0, fun
46
35
  const loadConfigFromJson = (file) => __awaiter(void 0, void 0, void 0, function* () {
47
36
  return JSON.parse(fs.readFileSync(file, 'utf-8'));
48
37
  });
49
- export const loadConfig = (root) => __awaiter(void 0, void 0, void 0, function* () {
50
- const resolved = getConfigType(root);
51
- const _a = yield (() => {
52
- switch (resolved === null || resolved === void 0 ? void 0 : resolved.type) {
38
+ export const loadConfig = (path) => __awaiter(void 0, void 0, void 0, function* () {
39
+ const configSource = getConfigType(path);
40
+ const customConfig = yield (() => {
41
+ switch (configSource === null || configSource === void 0 ? void 0 : configSource.type) {
53
42
  case 'js':
54
- return loadConfigFromJavascript(resolved.file);
43
+ return loadConfigFromJavascript(configSource.file);
55
44
  case 'json':
56
- return loadConfigFromJson(resolved.file);
45
+ return loadConfigFromJson(configSource.file);
57
46
  default:
58
47
  return Promise.resolve({});
59
48
  }
60
- })(), { environment, endpoints } = _a, manifest = __rest(_a, ["environment", "endpoints"]);
61
- return Object.assign(Object.assign({}, manifest), { environment, endpoints, configSource: resolved });
49
+ })();
50
+ return Object.assign(Object.assign({}, customConfig), { configSource });
62
51
  });
63
52
  const validateConfig = (config) => {
64
53
  if (!config.main) {
@@ -67,16 +56,15 @@ const validateConfig = (config) => {
67
56
  };
68
57
  export const resolveAppConfig = () => __awaiter(void 0, void 0, void 0, function* () {
69
58
  const { root, pkg } = resolvePackage();
70
- const _b = yield loadConfig(root), { configSource } = _b, localConfig = __rest(_b, ["configSource"]);
71
- const dev = { root, configSource };
59
+ const appConfig = yield loadConfig(root);
72
60
  const manifest = Object.assign({
73
61
  key: pkg.name.replace(/^@|\w.*\//gm, ''),
74
- }, localConfig.manifest, {
62
+ }, appConfig.manifest, {
75
63
  version: pkg.version,
76
64
  name: pkg.name,
77
65
  main: pkg.main,
78
- __DEV__: dev,
66
+ __DEV__: { root, configSource: appConfig.configSource, portal: appConfig.portalHost },
79
67
  });
80
68
  validateConfig(manifest);
81
- return Object.assign(Object.assign({}, localConfig), { manifest, dev });
69
+ return Object.assign(Object.assign({}, appConfig), { manifest, pkg, root });
82
70
  });
package/bin/main.js CHANGED
@@ -24,10 +24,17 @@ const app = program
24
24
  app.command('dev')
25
25
  .description('Create a development server')
26
26
  .option('-p, --port <number>', 'dev-server port', '3000')
27
- .action((port) => __awaiter(void 0, void 0, void 0, function* () {
27
+ .option('--portal <string>', 'fusion portal host')
28
+ .action(({ port, portal }) => __awaiter(void 0, void 0, void 0, function* () {
29
+ var _a;
28
30
  const spinner = ora('Loading configuration').start();
29
- const viteConfig = mergeConfig(yield createConfig(), { server: port });
31
+ const viteConfig = mergeConfig(yield createConfig(), { server: { port } });
30
32
  const appConfig = yield resolveAppConfig();
33
+ if (portal) {
34
+ appConfig.portalHost = portal
35
+ ? portal
36
+ : (_a = process.env.FUSION_PORTAL_HOST) !== null && _a !== void 0 ? _a : 'https://fusion-s-portal-ci.azurewebsites.net';
37
+ }
31
38
  spinner.succeed('Configuration loaded');
32
39
  startDevServer({ viteConfig, appConfig });
33
40
  }));
package/bin/serve.js CHANGED
@@ -29,13 +29,14 @@ export const server = (config) => __awaiter(void 0, void 0, void 0, function* ()
29
29
  host.port = String((_c = (_b = config.viteConfig.server) === null || _b === void 0 ? void 0 : _b.port) !== null && _c !== void 0 ? _c : 3000);
30
30
  const spinner = ora('Configuring dev-server').start();
31
31
  const vite = yield createServer(config.viteConfig);
32
+ const { portalHost } = config.appConfig;
32
33
  spinner.succeed('Configured dev-server');
33
34
  /** expose middlewares from vite (dev-server) */
34
35
  app.use(vite.middlewares);
35
36
  /** serve static files (portal prebuild) */
36
37
  app.use(express.static(resolveRelativePath('dev-portal'), { index: false }));
37
38
  app.use(createProxyMiddleware('/_discovery/environments/current', {
38
- target: 'https://pro-s-portal-ci.azurewebsites.net',
39
+ target: portalHost,
39
40
  changeOrigin: true,
40
41
  selfHandleResponse: true,
41
42
  onProxyRes: responseInterceptor((responseBuffer, _proxyRes, req) => __awaiter(void 0, void 0, void 0, function* () {
@@ -52,7 +53,7 @@ export const server = (config) => __awaiter(void 0, void 0, void 0, function* ()
52
53
  app.get('/api/apps/:appKey/config',
53
54
  // '/api/widget/:appKey/config',
54
55
  createProxyMiddleware('/api/apps/*/config', {
55
- target: 'https://pro-s-portal-ci.azurewebsites.net',
56
+ target: portalHost,
56
57
  changeOrigin: true,
57
58
  selfHandleResponse: true,
58
59
  onProxyRes: responseInterceptor((responseBuffer, proxyRes, req, res) => __awaiter(void 0, void 0, void 0, function* () {
@@ -72,7 +73,7 @@ export const server = (config) => __awaiter(void 0, void 0, void 0, function* ()
72
73
  })),
73
74
  }));
74
75
  app.get('/api/apps/:appKey', createProxyMiddleware('/api/apps/*', {
75
- target: 'https://pro-s-portal-ci.azurewebsites.net',
76
+ target: portalHost,
76
77
  changeOrigin: true,
77
78
  selfHandleResponse: true,
78
79
  onProxyRes: responseInterceptor((responseBuffer, proxyRes, req, res) => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-cli",
3
- "version": "5.0.8",
3
+ "version": "5.1.0",
4
4
  "keywords": [
5
5
  "Fusion",
6
6
  "Fusion Framework",
@@ -56,5 +56,5 @@
56
56
  "typescript": "^4.9.3",
57
57
  "vite-plugin-environment": "^1.1.3"
58
58
  },
59
- "gitHead": "a59959b7f25df08c9f93b05f1ea46980ff9e1303"
59
+ "gitHead": "4bb6a70e2acb5c22a9a953da23c98565b8ef28d2"
60
60
  }