Skip to content

Commit

Permalink
Merge pull request #2094 from cardstack/cs-7779-add-a-pre-start-scrip…
Browse files Browse the repository at this point in the history
…t-for-host-to-verify-if-the-boxel-ui

Host's pnpm start now builds boxel-ui before host if boxel-ui dist dir is out of date
  • Loading branch information
lukemelia authored Jan 28, 2025
2 parents 86a2a24 + 57ee458 commit 9c9bf9f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ jobs:
INPUT_ENVIRONMENT: ${{ inputs.environment }}
run: |
if [ "$INPUT_ENVIRONMENT" = "production" ]; then
echo "OWN_REALM_URL=https://app.boxel.ai/experiments/" >> $GITHUB_ENV
echo "RESOLVED_BASE_REALM_URL=https://app.boxel.ai/base/" >> $GITHUB_ENV
echo "MATRIX_URL=https://matrix.boxel.ai" >> $GITHUB_ENV
echo "MATRIX_SERVER_NAME=boxel.ai" >> $GITHUB_ENV
echo "EXPERIMENTAL_AI_ENABLED=true" >> $GITHUB_ENV
elif [ "$INPUT_ENVIRONMENT" = "staging" ]; then
echo "OWN_REALM_URL=https://realms-staging.stack.cards/experiments/" >> $GITHUB_ENV
echo "RESOLVED_BASE_REALM_URL=https://realms-staging.stack.cards/base/" >> $GITHUB_ENV
echo "MATRIX_URL=https://matrix-staging.stack.cards" >> $GITHUB_ENV
echo "MATRIX_SERVER_NAME=stack.cards" >> $GITHUB_ENV
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pr-boxel-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
- name: Deploy boxel-host preview
uses: ./.github/actions/deploy-ember-preview
env:
OWN_REALM_URL: https://realms-staging.stack.cards/experiments/
RESOLVED_BASE_REALM_URL: https://realms-staging.stack.cards/base/
MATRIX_URL: https://matrix-staging.stack.cards
MATRIX_SERVER_NAME: stack.cards
Expand Down Expand Up @@ -87,7 +86,6 @@ jobs:
- name: Deploy boxel-host preview
uses: ./.github/actions/deploy-ember-preview
env:
OWN_REALM_URL: https://app.boxel.ai/experiments/
RESOLVED_BASE_REALM_URL: https://app.boxel.ai/base/
MATRIX_URL: https://matrix.boxel.ai
MATRIX_SERVER_NAME: boxel.ai
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ In order to run the ember-cli hosted app:

1. `pnpm build` in the boxel-ui/addon workspace to build the boxel-ui addon.
2. `pnpm build` in the boxel-motion/addon workspace to build the boxel-motion addon.
3. `pnpm start` in the host/ workspace to serve the ember app. Note that this script includes the environment variable `OWN_REALM_URL=http://localhost:4201/experiments/` which configures the host to point to the experiments realm's cards realm by default.
3. `pnpm start` in the host/ workspace to serve the ember app.
4. `pnpm start:all` in the realm-server/ to serve the base and experiments realms -- this will also allow you to switch between the app and the tests without having to restart servers). This expects the Ember application to be running at `http://localhost:4200`, if you’re running it elsewhere you can specify it with `HOST_URL=http://localhost:5200 pnpm start:all`.

The app is available at http://localhost:4200. It will serve the experiments realm (configurable with OWN_REALM_URL, as mentioned above). You can open the base and experiments cards workspace directly by entering http://localhost:4201/base or http://localhost:4201/experiments in the browser.

If you want to use operator mode, you need to register an account on Matrix. To make it easier, you can execute `pnpm register-test-user` in `packages/matrix/`. Now you can sign in with the test user using the credentials `username: user`, `password: password`.
The app is available at http://localhost:4200. You will be prompted to register an account. To make it easier, you can execute `pnpm register-test-user` in `packages/matrix/`. Now you can sign in with the test user using the credentials `username: user`, `password: password`.

When you are done running the app you can stop the synapse server by running the following from the `packages/matrix` workspace:

Expand Down
25 changes: 25 additions & 0 deletions packages/boxel-ui/addon/bin/conditional-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /bin/sh

CURRENT_DIR="$(pwd)"
SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"

SRC_DIR="${SCRIPTS_DIR}/../src"
DIST_DIR="${SCRIPTS_DIR}/../dist"

if [ ! -d "$DIST_DIR" ]; then
echo "boxel-ui/addon dist dir does not exist. Building in ${SRC_DIR}/.."
cd "${SRC_DIR}/.."
pnpm run build
exit 0
fi

mod_time_src=$(find "$SRC_DIR" -type f -exec stat -f %m {} + | sort -nr | head -n1)
mod_time_dist=$(find "$DIST_DIR" -type f -exec stat -f %m {} + | sort -nr | head -n1)

if [ "$mod_time_src" -gt "$mod_time_dist" ]; then
echo "boxel-ui/addon dist dir is out of date. Building in ${SRC_DIR}/.."
cd "${SRC_DIR}/.."
pnpm run build
else
echo "✔️ boxel-ui/addon dist dir is up to date"
fi
3 changes: 2 additions & 1 deletion packages/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:glint": "glint",
"start": "NODE_OPTIONS='--max-old-space-size=8192' FASTBOOT_DISABLED=true OWN_REALM_URL=http://localhost:4201/experiments/ ember serve",
"ensure-boxel-ui": "../boxel-ui/addon/bin/conditional-build.sh",
"start": "pnpm ensure-boxel-ui && NODE_OPTIONS='--max-old-space-size=8192' FASTBOOT_DISABLED=true ember serve",
"start:build": "NODE_OPTIONS='--max-old-space-size=8192' FASTBOOT_DISABLED=true ember build --watch",
"test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\"",
"test-with-percy": "percy exec --parallel -- pnpm test:wait-for-servers",
Expand Down

0 comments on commit 9c9bf9f

Please sign in to comment.