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

chore(doop): migrate to vite/vitest #464

Merged
merged 26 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cdc3f5c
feat(ci): adds test composite action test
ArtieReus Sep 25, 2024
a7cb3ab
chore(doop): clean up tests from template app
ArtieReus Sep 25, 2024
1536835
chore(doop): remove logs
ArtieReus Sep 25, 2024
9d6d433
chore(doop): uses global ignore
ArtieReus Sep 25, 2024
19ef585
chore(doop): switch to appProps
ArtieReus Sep 25, 2024
0f8cc21
chore(doop): vite and vitest integration
ArtieReus Sep 25, 2024
57d060d
chore(doop): runs build static from root and clean up
ArtieReus Sep 25, 2024
a8da01d
chore(doop): removes obsolet helper
ArtieReus Sep 25, 2024
7f29641
chore(ci): adapts doop preview with temporary solution
ArtieReus Sep 25, 2024
6befeab
chore(ci): adds comment
ArtieReus Sep 25, 2024
5f6e9aa
Merge branch 'main' into artie-doop-vite
ArtieReus Sep 25, 2024
9b47d77
chore(doop): builds dependencies before static
ArtieReus Sep 25, 2024
28ec5f1
chore(doop): copies the build content to the target folder without build
ArtieReus Sep 25, 2024
3ea645b
chore(ci): copies just the content of build to the target
ArtieReus Sep 25, 2024
8d3d2e9
chore(doop): copies just the content!!
ArtieReus Sep 25, 2024
faac305
chore(doop): makes entry point relative
ArtieReus Sep 25, 2024
e9eb853
Merge branch 'main' into artie-doop-vite
ArtieReus Sep 27, 2024
7f12b39
Merge branch 'main' into artie-doop-vite
ArtieReus Sep 27, 2024
8e4b748
chore(doop): moveds test workflow to another PR
ArtieReus Sep 27, 2024
eaa22a4
chore(doop): add new line
ArtieReus Sep 27, 2024
97c1015
chore(doop): refactors app test
ArtieReus Sep 27, 2024
18df889
Merge branch 'main' into artie-doop-vite
ArtieReus Sep 27, 2024
bb60b49
Merge branch 'main' into artie-doop-vite
ArtieReus Sep 30, 2024
fd9656f
chore(ci): adds build dependencies on build:static
ArtieReus Sep 30, 2024
475636b
chore(ci): deletes not needed global build:static
ArtieReus Sep 30, 2024
1ad3bc8
chore(ci): renames preview to serve
ArtieReus Sep 30, 2024
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
15 changes: 14 additions & 1 deletion .github/workflows/deploy-pr-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,20 @@ jobs:
- name: Build DOOP if changes detected
if: github.event.action != 'closed' && contains(needs.run-detect-changes.outputs.changes, 'doop')
run: |
./.github/scripts/build-app.sh
# collect the necessary information
entry_file=$(jq -r '.module // .main' $PACKAGE_PATH/package.json)
build_folder=$(dirname $entry_file)
package_name=$(jq -r '.name' $PACKAGE_PATH/package.json)

# Run build using turbo
npx turbo run build:static --filter $package_name

# Copy build folder to deploy path
mkdir -p "$DEPLOY_PATH/$TARGET_FOLDER"
cp -r "$PACKAGE_PATH/$build_folder/." "$DEPLOY_PATH/$TARGET_FOLDER"

# Generate appProps.json
echo "$APP_PROPS_BASE64" | base64 -d > "$DEPLOY_PATH/$TARGET_FOLDER/appProps.json"
env:
PACKAGE_PATH: apps/doop
TARGET_FOLDER: doop
Expand Down
15 changes: 0 additions & 15 deletions apps/doop/.gitignore

This file was deleted.

62 changes: 62 additions & 0 deletions apps/doop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,65 @@
[![Built with Juno](https://cloudoperators.github.io/juno/built-with-juno.svg)](https://github.com/cloudoperators/juno)

This UI offers a dashboard to aggregate all policy violations reported by the Gatekeeper instances in each cluster.

# Usage

## Standalone Mode

To create a static, runnable build, execute the following commands:

```bash
cd apps/doop
npx turbo build:static
```

This will generate an `index.html` file along with the necessary assets in the dist folder. You’ll need to copy a `appProps.json` file containing the required props into the dist folder.

## As a Micro Frontend (MFE)

To build a library version for dynamic import, use the following commands:

```bash
cd apps/doop
npx turbo build
```

This will create a build folder with all assets. You can host this folder and load it as an MFE using dynamic import:

```html
<div id="root"></div>

<script type="module">
import("PATH_TO_HOST/doop/build/index.js").then((app) => {
app.mount(document.getElementById("root"), { props: /* PROPS JSON */ })
})
</script>
```

## Development Mode

First, create an `appProps.json` file in the root directory of the application (apps/doop), using appProps.template.json as a reference. Customize the file with the necessary properties. Once completed, run the following commands:

```bash
cd apps/doop
npx turbo dev
```

### Testing

```bash
cd apps/doop
npx turbo test
```

## App Props

These are the customizable application properties (appProps) that you can define in your appProps.json file:

- **id** (optional): Use unique IDs if you need to instantiate multiple instances of the app on the same page.
- **theme** (optional): Overrides the default theme. Acceptable values are `"theme-light"` or `"theme-dark"` (default).
- **displayName** (optional): The name to be displayed in the app's header.
- **apiEndpoint** (required): The URL of the API endpoint the app will interact with.
- **embedded** (optional): Set to `true` if the app will be embedded within another app or page. When `true`, the app will not display the header or footer, rendering only the content. Default is `false`.
- **isMock** (optional): Use mocked data for development purposes. Default is `false`.
- **showDebugSeverities** (optional): Display debug severity levels in the log. Default is `false`.
9 changes: 0 additions & 9 deletions apps/doop/__mocks__/client.js

This file was deleted.

6 changes: 0 additions & 6 deletions apps/doop/__mocks__/fileMock.js

This file was deleted.

6 changes: 0 additions & 6 deletions apps/doop/__mocks__/styleMock.js

This file was deleted.

9 changes: 9 additions & 0 deletions apps/doop/appProps.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "app-instance-1",
"theme": "theme-dark",
"displayName": "MyApp",
"apiEndpoint": "https://api.example.com/v1",
"embedded": false,
"isMock": true,
"showDebugSeverities": false
}
13 changes: 0 additions & 13 deletions apps/doop/babel.config.js

This file was deleted.

198 changes: 0 additions & 198 deletions apps/doop/esbuild.config.js

This file was deleted.

Loading
Loading