@equinor/fusion-framework-cli 0.1.15 → 0.2.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.
- package/CHANGELOG.md +11 -0
- package/bin/app-config.js +82 -0
- package/bin/create-config.js +18 -14
- package/bin/dev-portal/assets/index.3b2d2dca.js +390 -0
- package/bin/dev-portal/index.html +1 -1
- package/bin/main.js +5 -3
- package/bin/serve.js +78 -5
- package/package.json +6 -3
- package/bin/dev-portal/assets/index.ac378913.js +0 -363
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [0.2.1](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@0.2.0...@equinor/fusion-framework-cli@0.2.1) (2022-11-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @equinor/fusion-framework-cli
|
|
9
|
+
|
|
10
|
+
## [0.2.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@0.1.15...@equinor/fusion-framework-cli@0.2.0) (2022-11-14)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- add router and app loader ([f21661d](https://github.com/equinor/fusion-framework/commit/f21661d1255633848d1662dabb74e8e33ab629d5))
|
|
15
|
+
- **cli:** add proxy routing for app and config ([b923830](https://github.com/equinor/fusion-framework/commit/b9238309a2f15a470d63411d2da0b58a1eb63e90))
|
|
16
|
+
|
|
6
17
|
## 0.1.15 (2022-11-14)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @equinor/fusion-framework-cli
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
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
|
+
import path from 'path';
|
|
22
|
+
import fs from 'fs';
|
|
23
|
+
import { findUpSync } from 'find-up';
|
|
24
|
+
const supportedTypes = ['js', 'json'];
|
|
25
|
+
export const resolvePackageRoot = () => {
|
|
26
|
+
const pkgFile = findUpSync('package.json');
|
|
27
|
+
if (!pkgFile) {
|
|
28
|
+
throw Error('failed to resolve package');
|
|
29
|
+
}
|
|
30
|
+
return pkgFile;
|
|
31
|
+
};
|
|
32
|
+
export const resolvePackage = () => {
|
|
33
|
+
const pkgFile = resolvePackageRoot();
|
|
34
|
+
const pkgRaw = fs.readFileSync(pkgFile, 'utf8');
|
|
35
|
+
return { root: path.dirname(pkgFile), pkg: JSON.parse(pkgRaw) };
|
|
36
|
+
};
|
|
37
|
+
export const getConfigType = (root) => {
|
|
38
|
+
const base = path.join(root, 'app.config');
|
|
39
|
+
return supportedTypes
|
|
40
|
+
.map((type) => ({ type, file: [base, type].join('.') }))
|
|
41
|
+
.find((x) => fs.existsSync(x.file) && fs.statSync(x.file).isFile());
|
|
42
|
+
};
|
|
43
|
+
const loadConfigFromJavascript = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
return (yield import(file)).default();
|
|
45
|
+
});
|
|
46
|
+
const loadConfigFromJson = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
48
|
+
});
|
|
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) {
|
|
53
|
+
case 'js':
|
|
54
|
+
return loadConfigFromJavascript(resolved.file);
|
|
55
|
+
case 'json':
|
|
56
|
+
return loadConfigFromJson(resolved.file);
|
|
57
|
+
default:
|
|
58
|
+
return Promise.resolve({});
|
|
59
|
+
}
|
|
60
|
+
})(), { environment, endpoints } = _a, manifest = __rest(_a, ["environment", "endpoints"]);
|
|
61
|
+
return Object.assign(Object.assign({}, manifest), { environment, endpoints, configSource: resolved });
|
|
62
|
+
});
|
|
63
|
+
const validateConfig = (config) => {
|
|
64
|
+
if (!config.main) {
|
|
65
|
+
throw Error('missing `main` entry in package.json');
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const resolveAppConfig = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const { root, pkg } = resolvePackage();
|
|
70
|
+
const _b = yield loadConfig(root), { configSource } = _b, localConfig = __rest(_b, ["configSource"]);
|
|
71
|
+
const dev = { root, configSource };
|
|
72
|
+
const manifest = Object.assign({
|
|
73
|
+
appKey: pkg.name.replace(/^@|\w.*\//gm, ''),
|
|
74
|
+
}, localConfig.manifest, {
|
|
75
|
+
version: pkg.version,
|
|
76
|
+
name: pkg.name,
|
|
77
|
+
main: pkg.main,
|
|
78
|
+
__DEV__: dev,
|
|
79
|
+
});
|
|
80
|
+
validateConfig(manifest);
|
|
81
|
+
return Object.assign(Object.assign({}, localConfig), { manifest, dev });
|
|
82
|
+
});
|
package/bin/create-config.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { findUpSync } from 'find-up';
|
|
4
|
-
import { defineConfig } from 'vite';
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { defineConfig, createLogger } from 'vite';
|
|
5
3
|
import react from '@vitejs/plugin-react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { resolvePackage } from './app-config.js';
|
|
5
|
+
const createCustomLogger = () => {
|
|
6
|
+
const logger = createLogger();
|
|
7
|
+
const originalWarning = logger.warn;
|
|
8
|
+
logger.warn = (msg, options) => {
|
|
9
|
+
/** import of app file from framework */
|
|
10
|
+
if (msg.includes('import(manifest.entry)') &&
|
|
11
|
+
msg.includes('dynamic-import-vars#limitations'))
|
|
12
|
+
return;
|
|
13
|
+
originalWarning(msg, options);
|
|
14
|
+
};
|
|
15
|
+
return logger;
|
|
13
16
|
};
|
|
14
17
|
export const createConfig = () => {
|
|
15
|
-
const { root } = resolvePackage();
|
|
18
|
+
const { root, pkg } = resolvePackage();
|
|
16
19
|
return defineConfig({
|
|
17
20
|
plugins: [react()],
|
|
18
|
-
root:
|
|
21
|
+
root: root,
|
|
19
22
|
server: {
|
|
20
23
|
middlewareMode: true,
|
|
21
24
|
},
|
|
@@ -24,11 +27,12 @@ export const createConfig = () => {
|
|
|
24
27
|
build: {
|
|
25
28
|
outDir: resolve(root, 'dist'),
|
|
26
29
|
lib: {
|
|
27
|
-
entry: resolve(root,
|
|
30
|
+
entry: resolve(root, pkg.main),
|
|
28
31
|
fileName: 'app-bundle',
|
|
29
32
|
formats: ['es'],
|
|
30
33
|
},
|
|
31
34
|
},
|
|
35
|
+
customLogger: createCustomLogger(),
|
|
32
36
|
});
|
|
33
37
|
};
|
|
34
38
|
export default createConfig;
|