Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Management V1 #2494

Merged
merged 13 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/cuddly-spoons-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@equinor/fusion-framework-cli': minor
---

Introduced `proxyRequestLogger` to log proxy requests in the CLI.

- Show the request URL and method in the console when a proxy request is made.
- Show proxy response status code
10 changes: 10 additions & 0 deletions .changeset/curvy-lies-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@equinor/fusion-framework-react-components-people-provider': patch
'@equinor/fusion-framework-cli': patch
---

Updating fusion-wc-person to fix issues when using selectedPerson = null in PersonSelect component.

Updated the following dependencies

- `@equinor/fusion-wc-person` from `^3.0.1` to `^3.0.3` in `packages/cli/package.json` and `packages/react/components/people-resolver/package.json`.
5 changes: 5 additions & 0 deletions .changeset/giant-points-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-framework-cli': patch
---

Generated base manifest from package will now include `StandardIncludeAssetExtensions` as `allowedExtensions`
5 changes: 5 additions & 0 deletions .changeset/good-wasps-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-framework-docs': minor
---

Documenting the new CLI commands in vue-press.
20 changes: 20 additions & 0 deletions .changeset/hot-ears-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@equinor/fusion-framework-cli': minor
---

Create a plugin `externalPublicPlugin` to fix the issue with serving the `index.html` file from the specified external public directory. Vite mode `spa` will not serve the `index.html` file from the specified external public directory.

- Enhanced the middleware to intercept requests and serve the `index.html` file from the specified external public directory.
- Transformed the HTML using Vite's `transformIndexHtml` method.
- Applied appropriate content headers and additional configured headers before sending the response.

```typescript
const viteConfig = defineConfig({
// vite configuration
root: './src', // this where vite will look for the index.html file
plugins: [
// path which contains the index.html file
externalPublicPlugin('./my-portal'),
],
});
```
19 changes: 19 additions & 0 deletions .changeset/nervous-cougars-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@equinor/fusion-framework-cookbook-app-react-environment-variables': patch
'@equinor/fusion-framework-cookbook-app-react-bookmark-advanced': patch
'@equinor/fusion-framework-cookbook-app-react-feature-flag': patch
'@equinor/fusion-framework-cookbook-app-react-bookmark': patch
'@equinor/fusion-framework-cookbook-app-react-ag-grid': patch
'@equinor/fusion-framework-cookbook-app-react-context': patch
'@equinor/fusion-framework-cookbook-app-react-module': patch
'@equinor/fusion-framework-cookbook-app-react-people': patch
'@equinor/fusion-framework-cookbook-app-react-msal': patch
'@equinor/fusion-framework-cookbook-app-vanilla': patch
'@equinor/fusion-framework-cookbook-app-react': patch
'@equinor/fusion-framework-cookbook-app-react-context-custom-error': patch
'@equinor/fusion-framework-cookbook-app-react-router': patch
---

Cleaned up app config

Removed `app.config.*` from the cookbook apps to prevent confusion when using the cookbook apps as a template for new apps.
15 changes: 15 additions & 0 deletions .changeset/pink-laws-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@equinor/fusion-framework-cli': minor
---

Updated commands in CLI to reflect purpose of the command:
- renamed `config` to `build-config` to generate build config of an application.
- renamed `pack`to `build-pack` to bundle an application.
- added `build-manifest` command to generate build manifest of an application.

> [!WARNING]
> Config callback for `manifest` and `config` now allows `void` return type.
> Return value from callback is now merged with default config instead of replacing it, this might be a breaking change for some applications.

> [!NOTE]
> This mean that `mergeAppConfig` and `mergeManifestConfig` functions are no longer needed and can be removed from the application.
64 changes: 64 additions & 0 deletions .changeset/quiet-scissors-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
'@equinor/fusion-framework-cli': minor
---

The `appProxyPlugin` is a Vite plugin designed to proxy requests to a Fusion app backend.
It sets up proxy rules for API and bundle requests and serves the app configuration and manifest based on the app key and version.

Key Features:

1. Proxy Configuration:

- Proxies API calls to the Fusion apps backend.
- Proxies bundle requests to the Fusion apps backend.
- Uses a base path `proxyPath` for proxying.
- Captures and reuses authorization tokens for asset requests.

2. **App Configuration and Manifest**:

- Serves the app configuration if the request matches the current app and version.
- Serves the app manifest if the request matches the current app.

3. **Middleware Setup**:
- Sets up middleware to handle requests for app configuration, manifest, and local bundles.

This plugin is used by the CLI for local development, but design as exportable for custom CLI to consume applications from other API`s

example configuration:
```typescript
const viteConfig = defineConfig({
// vite configuration
plugins: [
appProxyPlugin({
proxy: {
path: '/app-proxy',
target: 'https://fusion-s-apps-ci.azurewebsites.net/',
// optional callback when matched request is proxied
onProxyReq: (proxyReq, req, res) => {
proxyReq.on('response', (res) => { console.log(res.statusCode) });
},
},
// optional, but required for serving local app configuration, manifest and resources
app: {
key: 'my-app',
version: '1.0.0',
generateConfig: async () => ({}),
generateManifest: async () => ({}),
},
}),
],
});
```

example usage:
```typescript
// Example API calls
fetch('/app-proxy/apps/my-app/builds/1.0.0/config'); // local
fetch('/app-proxy/apps/my-app/builds/0.0.9/config'); // proxy
fetch('/app-proxy/apps/other-app/builds/1.0.0/config'); // proxy

// Example asset calls
fetch('/app-proxy/bundles/my-app/builds/1.0.0/index.js'); // local
fetch('/app-proxy/bundles/my-app/builds/0.0.9/index.js'); // proxy
```

84 changes: 84 additions & 0 deletions .changeset/rare-carrots-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
"@equinor/fusion-framework-cli": major
---

Adding new commands for app management, `build-publish`, `build-pack`, `build-upload`, `build-config`, `build-manifest` and `build-tag`.

Introduces new parameters to the `build-config` command for publishing the app config to a build version.

Commands:

- `build-pack` - Bundle the app for distribution
- `-o, --output <output>` - Output directory for the packed app
- `-a, --archive` - Archive name for the packed app
- `build-upload` - Upload the packed app to the Fusion App Store
- `-b, --bundle <bundle>` - Path to the packed app bundle
- `-e, --env <ci | fqa | tr | fprd>` - Environment to upload the app to
- `-s, --service <service>` - Custom app service
- `build-tag` - Tag the uploaded app with a version
- `-t, --tag <tag>` - Tag to apply to the uploaded app
- `-v, --version <version>` - Version to attach to the tag
- `-e, --env <ci | fqa | tr | fprd>` - Environment to tag the app in
- `-s, --service <service>` - Custom app service
- `build-publish` - Publish the app config to a build version
- `-t, --tag <tag>` - Tag to apply to the uploaded app
- `-e, --env <ci | fqa | tr | fprd>` - Environment to tag the app in
- `-s, --service <service>` - Custom app service
- `build-config` - Generate app config for an environment
- `-o, --output <output>` - Output file for the app config
- `-c, --config <config>` - Path to the app config file (for config generation)
- `-p, --publish` - Flag for upload the generated config
- `-v, --version<semver | current | latest | preview>` - Publish the app config to version
- `-e, --env <ci | fqa | tr | fprd>` - Environment to publish the app config to
- `-s, --service <service>` - Custom app service
- `upload-config` - Upload the app config to a build version
- `-c, --config <config>` - Path to the app config json file to upload
- `-p, --publish<semver | current | latest | preview>` - Publish the app config to the build version
- `-e, --env <ci | fqa | tr | fprd>` - Environment to publish the app config to
- `-s, --service <service>` - Custom app service
- `build-manifest` - Creates the build manifest to publish with app
- `-o, --output <output>` - Output file for manifest
- `-c, --config <config>` - Manifest config file

simple usage:
```sh
fusion-framework-cli app build-publish -e ci
```

complex usage:
```sh
fusion-framework-cli app build-pack -o ./dist -a my-app.zip
fusion-framework-cli app build-upload -b ./dist/my-app.zip -e ci
fusion-framework-cli app build-tag -t my-tag -v 1.0.0 -e ci
```

After publishing a build of an app, the app config should be uploaded to the build version. This is done by running the `build-config` command.

```sh
# Publish the app config to the build version
fusion-framework-cli app build-config -p -e ci

# Publish the app config to a specific build tag
fusion-framework-cli app build-config -p preview -e ci

# Publish the app config to a specific build version
fusion-framework-cli app build-config -p 1.0.0 -e ci
```

__breaking changes:__

- renaming all commands accociated with build.
- The app-config endpoints is now an object containing url and scopes, where name is the object key:

```ts
environment: {
myProp: 'foobar',
},
endpoints: {
api: {
url: 'https://foo.bars'
scopes: ['foobar./default']
},
},
```
- The `config` command has been removed, use `build-config` instead
5 changes: 5 additions & 0 deletions .changeset/real-kiwis-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-framework-cli': minor
---

when building an application the `AppAssetExportPlugin` is now added to the `ViteConfig` and configure to include `manifest.build.allowedExtensions`
65 changes: 65 additions & 0 deletions .changeset/slimy-buses-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
'@equinor/fusion-framework-module-app': major
'@equinor/fusion-framework-react-app': patch
'@equinor/fusion-framework-react-components-bookmark': patch
'@equinor/fusion-framework-react': minor
'@equinor/fusion-framework-legacy-interopt': patch
---

Adjusted module to the new app service API.

> [!WARNING]
> This will introduce breaking changes to the configuration of `AppConfigurator.client`.

**Added**

- Introduced `AppClient` class to handle application manifest and configuration queries.
- Added `zod` to validate the application manifest.

**Changed**

- Updated `AppModuleProvider` to use `AppClient` for fetching application manifests and configurations.
- Modified `AppConfigurator` to utilize `AppClient` for client configuration.
- Updated `useApps` hook with new input parameter for `filterByCurrentUser` in `fusion-framework-react`.

**Migration**

before:

```ts
configurator.setClient({
getAppManifest: {
client: {
fn: ({ appKey }) => httpClient.json$<ApiApp>(`/apps/${appKey}`),
},
key: ({ appKey }) => appKey,
},
getAppManifests: {
client: {
fn: () => httpClient.json$<ApiApp[]>(`/apps`),
},
key: () => `all-apps`,
},
getAppConfig: {
client: {
fn: ({ appKey }) => httpClient.json$<ApiApp>(`/apps/${appKey}/config`),
},
key: ({ appKey }) => appKey,
},
});
```

after:

```ts
import { AppClient } from `@equinor/fusion-framework-module-app`;
configurator.setClient(new AppClient());
```

custom client implementation:

```ts
import { AppClient } from `@equinor/fusion-framework-module-app`;
class CustomAppClient implements IAppClient { ... }
configurator.setClient(new CustomAppClient());
```
22 changes: 22 additions & 0 deletions .changeset/slow-apes-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@equinor/fusion-framework-cli': minor
---

**App Assets Export Plugin**

Create a plugin that exports assets from the app's source code.
This plugin resolves the issue where assets are not extracted from the app's source code since the app is in `lib` mode.

```typescript
export default {
plugins: [
AppAssetExportPlugin(
include: createExtensionFilterPattern(
manifest.build.allowedExtensions
),
),
]
}
```

see readme for more information.
13 changes: 0 additions & 13 deletions cookbooks/app-react-ag-grid/app.config.js

This file was deleted.

7 changes: 7 additions & 0 deletions cookbooks/app-react-assets/app.manifest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineAppManifest } from '@equinor/fusion-framework-cli';

export default defineAppManifest(async (env) => {
return {
appKey: 'test-assets',
};
});
24 changes: 24 additions & 0 deletions cookbooks/app-react-assets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@equinor/fusion-framework-cookbook-app-react-assets",
"version": "0.0.1",
"description": "",
"private": true,
"type": "module",
"main": "src/index.ts",
"scripts": {
"build": "fusion-framework-cli app build",
"dev": "fusion-framework-cli app dev",
"docker": "cd .. && sh docker-script.sh app-react"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@equinor/fusion-framework-cli": "workspace:^",
"@equinor/fusion-framework-react-app": "workspace:^",
"@types/react": "^18.2.50",
"@types/react-dom": "^18.2.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.5.4"
}
}
9 changes: 9 additions & 0 deletions cookbooks/app-react-assets/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import memeUrl from './mount_batur.jpg';

export const App = () => (
<div>
<img src={memeUrl} />
</div>
);

export default App;
Loading
Loading