@fluid-app/fluid-cli-portal 0.1.25 → 0.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-app/fluid-cli-portal",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Fluid CLI plugin for building portal applications",
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,68 @@
1
+ name: Deploy Portal
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ workflow_dispatch:
7
+
8
+ env:
9
+ GCP_PROJECT: fluid-417204
10
+ GCS_BUCKET: gs://portals-cdn/{{projectName}}/assets
11
+ CDN_URL_MAP: custom-domains-c42c
12
+ CDN_INVALIDATION_PATH: /{{projectName}}/assets/*
13
+ # CDN frontend hostname — update this to match your load balancer's domain.
14
+ # Using the raw GCS URL bypasses Cloud CDN; the CDN-fronted URL ensures
15
+ # chunk imports are served (and invalidated) through the cache.
16
+ CDN_HOSTNAME: https://cdn.example.com
17
+
18
+ jobs:
19
+ build-and-upload:
20
+ name: Build and upload to GCS
21
+ runs-on: ubuntu-latest
22
+ concurrency:
23
+ group: portal-deploy-$\{{ github.ref }}
24
+ cancel-in-progress: false
25
+
26
+ steps:
27
+ - name: Checkout repo
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Setup pnpm
31
+ uses: pnpm/action-setup@v4
32
+
33
+ - name: Setup Node
34
+ uses: actions/setup-node@v4
35
+ with:
36
+ node-version: 24.x
37
+ cache: pnpm
38
+
39
+ - name: Install deps
40
+ run: pnpm install --frozen-lockfile
41
+
42
+ - name: Build portal
43
+ run: pnpm build
44
+ env:
45
+ VITE_ASSET_BASE: $\{{ env.CDN_HOSTNAME }}/{{projectName}}/assets/
46
+
47
+ - name: Authenticate to Google Cloud
48
+ uses: google-github-actions/auth@v2
49
+ with:
50
+ project_id: $\{{ env.GCP_PROJECT }}
51
+ credentials_json: $\{{ secrets.GCP_SA_JSON }}
52
+
53
+ - name: Setup Cloud SDK
54
+ uses: google-github-actions/setup-gcloud@v2
55
+ with:
56
+ project_id: $\{{ env.GCP_PROJECT }}
57
+
58
+ - name: Upload assets to GCS
59
+ run: |
60
+ gcloud storage rsync ./dist $\{{ env.GCS_BUCKET }} \
61
+ --recursive \
62
+ --delete-unmatched-destination-objects
63
+
64
+ - name: Invalidate CDN cache
65
+ run: |
66
+ gcloud compute url-maps invalidate-cdn-cache $\{{ env.CDN_URL_MAP }} \
67
+ --path="$\{{ env.CDN_INVALIDATION_PATH }}" \
68
+ --global
@@ -59,6 +59,34 @@ src/
59
59
  └── Dashboard.tsx # Dashboard with multiple widgets
60
60
  ```
61
61
 
62
+ ## Deployment
63
+
64
+ This project includes a GitHub Actions workflow (`.github/workflows/deploy.yml`) that deploys your portal to Google Cloud Storage + Cloud CDN.
65
+
66
+ ### How it works
67
+
68
+ 1. **Trigger** — pushes to `main` (or manual dispatch)
69
+ 2. **Build** — runs `pnpm build`, producing stable filenames (`portal.js`, `portal.css`)
70
+ 3. **Upload** — syncs `dist/` to `gs://portals-cdn/{{projectName}}/assets/` via `gcloud storage rsync`
71
+ 4. **Invalidate** — clears the CDN cache for your tenant's asset prefix
72
+
73
+ ### Setup
74
+
75
+ 1. Create a GCP service account with Storage Object Admin and Compute Load Balancer Admin roles
76
+ 2. Add the service account JSON key as a GitHub Actions secret named `GCP_SA_JSON`
77
+ 3. Set `CDN_HOSTNAME` in `.github/workflows/deploy.yml` to your Cloud CDN load balancer's frontend domain
78
+ 4. Update `GCP_PROJECT` and `CDN_URL_MAP` if your project differs from the defaults
79
+
80
+ ### Environment variables
81
+
82
+ | Variable | Where | Purpose |
83
+ |----------|-------|---------|
84
+ | `GCP_SA_JSON` | GitHub secret | GCP service account credentials |
85
+ | `GCP_PROJECT` | Workflow env | Google Cloud project ID |
86
+ | `CDN_URL_MAP` | Workflow env | Cloud CDN URL map name for cache invalidation |
87
+ | `CDN_HOSTNAME` | Workflow env | CDN frontend domain (load balancer hostname) |
88
+ | `VITE_ASSET_BASE` | Build env | Derived from `CDN_HOSTNAME` (set automatically) |
89
+
62
90
  ## Customization
63
91
 
64
92
  ### Modify Navigation
@@ -8,6 +8,7 @@ import {
8
8
  } from "@fluid-app/portal-sdk/vite";
9
9
 
10
10
  export default defineConfig({
11
+ base: process.env.VITE_ASSET_BASE ?? "/",
11
12
  plugins: [
12
13
  react(),
13
14
  tailwindcss(),
@@ -23,6 +24,14 @@ export default defineConfig({
23
24
  preview: fileURLToPath(new URL("preview.html", import.meta.url)),
24
25
  },
25
26
  output: {
27
+ entryFileNames: (chunk) =>
28
+ chunk.name === "preview" ? "preview.js" : "portal.js",
29
+ assetFileNames: (asset) =>
30
+ asset.names?.some((n) => n.endsWith(".css"))
31
+ ? "portal.[ext]"
32
+ : "assets/[name].[ext]",
33
+ chunkFileNames: (chunk) =>
34
+ `${chunk.name.replace(/-[A-Za-z0-9_-]{8}$/, "")}.js`,
26
35
  manualChunks(id) {
27
36
  if (
28
37
  id.includes("node_modules/react-dom") ||