@equinor/fusion-framework-cli 0.1.5 → 0.1.6
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 +4 -0
- package/package.json +2 -2
- package/src/dev-portal/AppLoader.tsx +0 -41
- package/src/dev-portal/config.ts +0 -40
- package/src/dev-portal/index.html +0 -24
- package/src/dev-portal/main.tsx +0 -28
- package/src/index.tsx +0 -25
- package/src/scripts/create-config.ts +0 -37
- package/src/scripts/main.ts +0 -37
- package/src/scripts/serve.ts +0 -38
- package/tsconfig.json +0 -22
- package/tsconfig.scripts.json +0 -16
- package/vite.config.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.1.6](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@0.1.5...@equinor/fusion-framework-cli@0.1.6) (2022-11-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @equinor/fusion-framework-cli
|
|
9
|
+
|
|
6
10
|
## [0.1.5](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-cli@0.1.4...@equinor/fusion-framework-cli@0.1.5) (2022-11-03)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @equinor/fusion-framework-cli
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Fusion",
|
|
6
6
|
"Fusion Framework",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"typescript": "^4.8.4",
|
|
44
44
|
"vite": "^3.2.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "bb21836f3674173eb2809e6daa75d616c1dcf64e"
|
|
47
47
|
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFramework } from '@equinor/fusion-framework-react/hooks';
|
|
4
|
-
import { AppConfig, AppManifest, useAppEnv } from '@equinor/fusion-framework-react/app';
|
|
5
|
-
import { StarProgress } from '@equinor/fusion-react-progress-indicator';
|
|
6
|
-
|
|
7
|
-
export const AppLoader = (props: { appKey: string }) => {
|
|
8
|
-
const { appKey } = props;
|
|
9
|
-
const fusion = useFramework();
|
|
10
|
-
const ref = useRef<HTMLSpanElement>(null);
|
|
11
|
-
const renderRef = useRef<VoidFunction | undefined>(undefined);
|
|
12
|
-
|
|
13
|
-
const { config, manifest, isLoading } = useAppEnv(appKey);
|
|
14
|
-
|
|
15
|
-
const loadApp = useCallback(
|
|
16
|
-
async (manifest: AppManifest, config: AppConfig) => {
|
|
17
|
-
const url = new URL('/index.tsx', import.meta.url).href;
|
|
18
|
-
const { render } = await import(url);
|
|
19
|
-
if (ref.current) {
|
|
20
|
-
return render(ref.current, { fusion, env: { manifest, config } });
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
[ref, fusion]
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!isLoading && manifest && config) {
|
|
28
|
-
loadApp(manifest, config).then((x) => (renderRef.current = x));
|
|
29
|
-
}
|
|
30
|
-
return renderRef.current;
|
|
31
|
-
}, [loadApp, isLoading, manifest, config]);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
{isLoading && <StarProgress text="Loading Application" />}
|
|
36
|
-
<span ref={ref} style={{ display: isLoading ? 'none' : '' }}></span>;
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default AppLoader;
|
package/src/dev-portal/config.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { FusionConfigurator } from '@equinor/fusion-framework-react';
|
|
2
|
-
import { ConsoleLogger } from '@equinor/fusion-framework-module-msal/client';
|
|
3
|
-
|
|
4
|
-
export const configure = async (config: FusionConfigurator) => {
|
|
5
|
-
config.logger.level = 4;
|
|
6
|
-
|
|
7
|
-
config.configureServiceDiscovery({
|
|
8
|
-
client: {
|
|
9
|
-
baseUri: 'https://pro-s-portal-ci.azurewebsites.net',
|
|
10
|
-
defaultScopes: ['97978493-9777-4d48-b38a-67b0b9cd88d2/.default'],
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
config.configureMsal(
|
|
15
|
-
{
|
|
16
|
-
tenantId: '3aa4a235-b6e2-48d5-9195-7fcf05b459b0',
|
|
17
|
-
clientId: '9b707e3a-3e90-41ed-a47e-652a1e3b53d0',
|
|
18
|
-
redirectUri: '/authentication/login-callback',
|
|
19
|
-
},
|
|
20
|
-
{ requiresAuth: true }
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
config.onConfigured(() => {
|
|
24
|
-
console.log('framework config done');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
config.onInitialized(async (fusion) => {
|
|
28
|
-
fusion.auth.defaultClient.setLogger(new ConsoleLogger(0));
|
|
29
|
-
|
|
30
|
-
console.debug('📒 subscribing to all events');
|
|
31
|
-
fusion.event.subscribe((e) => console.debug(`🔔🌍 [${e.type}]`, e));
|
|
32
|
-
|
|
33
|
-
console.debug('📒 subscribing to [onReactAppLoaded]');
|
|
34
|
-
fusion.event.addEventListener('onReactAppLoaded', (e) =>
|
|
35
|
-
console.debug('🔔 [onReactAppLoaded]', e)
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default configure;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + React + TS</title>
|
|
8
|
-
<script type="module" crossorigin defer>
|
|
9
|
-
const url = new URL('/@react-refresh', import.meta.url).href;
|
|
10
|
-
import(url).then(({default: {injectIntoGlobalHook}}) => {
|
|
11
|
-
injectIntoGlobalHook(window)
|
|
12
|
-
window.$RefreshReg$ = () => { }
|
|
13
|
-
window.$RefreshSig$ = () => (type) => type
|
|
14
|
-
window.__vite_plugin_react_preamble_installed__ = true
|
|
15
|
-
});
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<body>
|
|
19
|
-
<div id="root"></div>
|
|
20
|
-
|
|
21
|
-
<script type="module" src="/main.tsx" crossorigin></script>
|
|
22
|
-
</body>
|
|
23
|
-
|
|
24
|
-
</html>
|
package/src/dev-portal/main.tsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import { Framework } from '@equinor/fusion-framework-react';
|
|
5
|
-
|
|
6
|
-
import { ThemeProvider, theme } from '@equinor/fusion-react-styles';
|
|
7
|
-
import { StarProgress } from '@equinor/fusion-react-progress-indicator';
|
|
8
|
-
|
|
9
|
-
import { configure } from './config';
|
|
10
|
-
|
|
11
|
-
import { AppLoader } from './AppLoader';
|
|
12
|
-
|
|
13
|
-
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
|
14
|
-
<React.StrictMode>
|
|
15
|
-
<ThemeProvider theme={theme}>
|
|
16
|
-
<Framework configure={configure} fallback={<StarProgress text="Loading framework" />}>
|
|
17
|
-
<div>
|
|
18
|
-
<section>
|
|
19
|
-
<header>
|
|
20
|
-
<h1>Fusion Dev Portal</h1>
|
|
21
|
-
</header>
|
|
22
|
-
</section>
|
|
23
|
-
<AppLoader appKey={'test-app'} />
|
|
24
|
-
</div>
|
|
25
|
-
</Framework>
|
|
26
|
-
</ThemeProvider>
|
|
27
|
-
</React.StrictMode>
|
|
28
|
-
);
|
package/src/index.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StrictMode } from 'react';
|
|
2
|
-
import * as ReactDOM from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
// import 'vite/modulepreload-polyfill';
|
|
5
|
-
|
|
6
|
-
const Test = (args) => {
|
|
7
|
-
return (
|
|
8
|
-
<div>
|
|
9
|
-
<p>Hello there this is all! good 🤙🏻</p>
|
|
10
|
-
<pre>{JSON.stringify(args, undefined, 4)}</pre>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const render = (el: HTMLElement, args) => {
|
|
16
|
-
const root = ReactDOM.createRoot(el);
|
|
17
|
-
root.render(
|
|
18
|
-
<StrictMode>
|
|
19
|
-
<Test env={args.env} />
|
|
20
|
-
</StrictMode>
|
|
21
|
-
);
|
|
22
|
-
return () => root.unmount();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default render;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { dirname, resolve } from 'path';
|
|
3
|
-
import { findUpSync } from 'find-up';
|
|
4
|
-
|
|
5
|
-
import { defineConfig, UserConfig } from 'vite';
|
|
6
|
-
import react from '@vitejs/plugin-react';
|
|
7
|
-
|
|
8
|
-
const resolvePackage = () => {
|
|
9
|
-
const pkgFile = findUpSync('package.json');
|
|
10
|
-
if (!pkgFile) {
|
|
11
|
-
throw Error('failed to resolve package');
|
|
12
|
-
}
|
|
13
|
-
const pkgRaw = readFileSync(pkgFile, 'utf8');
|
|
14
|
-
return { root: dirname(pkgFile), pkg: JSON.parse(pkgRaw) };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const createConfig = (): UserConfig => {
|
|
18
|
-
const { root } = resolvePackage();
|
|
19
|
-
return defineConfig({
|
|
20
|
-
plugins: [react()],
|
|
21
|
-
root: resolve(root, 'src'),
|
|
22
|
-
server: {
|
|
23
|
-
middlewareMode: true,
|
|
24
|
-
},
|
|
25
|
-
appType: 'custom',
|
|
26
|
-
build: {
|
|
27
|
-
outDir: resolve(root, 'dist'),
|
|
28
|
-
lib: {
|
|
29
|
-
entry: resolve(root, 'src/index.tsx'),
|
|
30
|
-
fileName: 'app-bundle',
|
|
31
|
-
formats: ['es'],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
}) as unknown as UserConfig;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default createConfig;
|
package/src/scripts/main.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
|
|
5
|
-
import ora from 'ora';
|
|
6
|
-
|
|
7
|
-
import { build, mergeConfig } from 'vite';
|
|
8
|
-
|
|
9
|
-
import startDevServer from './serve.js';
|
|
10
|
-
import createConfig from './create-config.js';
|
|
11
|
-
|
|
12
|
-
const program = new Command();
|
|
13
|
-
|
|
14
|
-
program.name('fusion-framework-cli');
|
|
15
|
-
program.description('CLI for Fusion Framework');
|
|
16
|
-
program.version('0.0.1-alpha');
|
|
17
|
-
|
|
18
|
-
const app = program
|
|
19
|
-
.command('app')
|
|
20
|
-
.description('Tooling for developing applications build on Fusion Framework');
|
|
21
|
-
|
|
22
|
-
app.command('dev')
|
|
23
|
-
.description('Create a development server')
|
|
24
|
-
|
|
25
|
-
.option('-p, --port <number>', 'devserver port', '3000')
|
|
26
|
-
.action(async (port) => {
|
|
27
|
-
const spinner = ora('Loading configuration').start();
|
|
28
|
-
const config = mergeConfig(await createConfig(), { server: port });
|
|
29
|
-
spinner.succeed('Configuration loaded');
|
|
30
|
-
startDevServer(mergeConfig(config, { server: port }));
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
app.command('build').action(() => {
|
|
34
|
-
build(createConfig());
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
program.parse();
|
package/src/scripts/serve.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'vite';
|
|
2
|
-
import type { UserConfig } from 'vite';
|
|
3
|
-
|
|
4
|
-
import express from 'express';
|
|
5
|
-
|
|
6
|
-
import dns from 'dns';
|
|
7
|
-
dns.setDefaultResultOrder('verbatim');
|
|
8
|
-
|
|
9
|
-
import path from 'path';
|
|
10
|
-
import kleur from 'kleur';
|
|
11
|
-
|
|
12
|
-
import ora from 'ora';
|
|
13
|
-
|
|
14
|
-
const resolveRelativePath = (relative: string) =>
|
|
15
|
-
path.resolve(new URL(relative, import.meta.url).pathname);
|
|
16
|
-
|
|
17
|
-
export const server = async (config: UserConfig) => {
|
|
18
|
-
const spinner = ora('Starting dev-server').start();
|
|
19
|
-
const app = express();
|
|
20
|
-
|
|
21
|
-
const port = config.server?.port ?? 3000;
|
|
22
|
-
|
|
23
|
-
const vite = await createServer(config);
|
|
24
|
-
|
|
25
|
-
app.use(vite.middlewares);
|
|
26
|
-
app.use(express.static(resolveRelativePath('dev-portal')));
|
|
27
|
-
app.use('*', async (_, res) => {
|
|
28
|
-
res.sendFile(resolveRelativePath('dev-portal/index.html'));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
app.listen(port);
|
|
32
|
-
|
|
33
|
-
spinner.succeed(
|
|
34
|
-
`dev-server started on: ${kleur.underline().green(['http://localhost', port].join(':'))}`
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default server;
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "bin",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"declarationDir": "./dist/types",
|
|
7
|
-
"baseUrl": "src",
|
|
8
|
-
"jsx": "react-jsx"
|
|
9
|
-
},
|
|
10
|
-
"references": [
|
|
11
|
-
{
|
|
12
|
-
"path": "../framework-react"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"include": [
|
|
16
|
-
"src/**/*",
|
|
17
|
-
],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"node_modules",
|
|
20
|
-
"lib"
|
|
21
|
-
],
|
|
22
|
-
}
|
package/tsconfig.scripts.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "bin",
|
|
4
|
-
"rootDir": "src/scripts",
|
|
5
|
-
"target": "ES6",
|
|
6
|
-
"module": "es2020",
|
|
7
|
-
"lib": ["ES6", "ES2015", "DOM"],
|
|
8
|
-
"strict": true,
|
|
9
|
-
"types": ["node"],
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"moduleResolution": "node"
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src/scripts",
|
|
15
|
-
],
|
|
16
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import react from '@vitejs/plugin-react';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [react()],
|
|
7
|
-
root: fileURLToPath(new URL('./src/dev-portal', import.meta.url)),
|
|
8
|
-
build: {
|
|
9
|
-
outDir: fileURLToPath(new URL('./bin/dev-portal', import.meta.url)),
|
|
10
|
-
emptyOutDir: true,
|
|
11
|
-
},
|
|
12
|
-
});
|