Skip to content

Commit

Permalink
build: Configure deployment previews with Vega Editor (#9294)
Browse files Browse the repository at this point in the history
## Motivation

- A cloudflare-based take on
#9276
- As discussed w/ @domoritz, Previewing the editor site is probably more
useful than the docs site, so we're going after that first

## Changes

- Use explicit packageManager version so Cloudflare doesn't autoupgrade
to yarn 3 (breaks lockfile)
- Add a build script (originally this was a 1-liner in package.json but
it was getting hard to read) that
  - Builds vega-lite
- Clones vega/editor and links the local vega-lite in place of the full
build
- Install `vega/editor` without running the `prepare` script. (The CI
device doesn't have rsync installed).
  - Makes empty index.json for vega / vega-lite examples.
- Build editor with vite with `/` as the base URL (previously it was
erroring due to thinking it was under the `/editor` subdomain).
Technically this is an abstraction leak but fixing it would involve
modifying the vega/editor repo too and I'd like to contain this change
to 1 repo if possible.

## Testing

- See Cloudflare comment below, confirm site loads

## Notes

- For now only `cameron.yick/*` branches have the previews since the
build script is WIP. It's using my personal Cloudflare account for
testing. I'll open it up to all (non dependabot/*) PRs this change is
confirmed.
- I've filed an request to
https://blog.cloudflare.com/cloudflare-new-oss-sponsorships-program to
see if we can get deployment previews sponsored (they also sponsor D3,
yarn). If not, I'll plan to discuss on Slack whether to keep Cloudflare
or switch the config to a different account.
- Free plan limits: 500 builds/ month:
https://developers.cloudflare.com/pages/platform/limits/ .
  • Loading branch information
hydrosquall authored Apr 6, 2024
1 parent b33dfee commit 64d6daf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"clean": "yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete",
"clean:build": "del-cli 'build/*' !build/vega-lite-schema.json",
"data": "rsync -r node_modules/vega-datasets/data/* site/data",
"build-editor-preview": "scripts/build-editor-preview.sh",
"schema": "mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",
"renameschema": "scripts/rename-schema.sh",
"presite": "yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",
Expand Down Expand Up @@ -138,5 +139,6 @@
},
"engines": {
"node": ">=18"
}
},
"packageManager": "[email protected]"
}
36 changes: 36 additions & 0 deletions scripts/build-editor-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eo pipefail

# Build the docs site and replace the main build with the local copy of vega-lite
echo "Attempting install"
# apt install rsync

yarn build
yarn link
git clone https://github.com/vega/editor.git

#
cd editor
yarn --frozen-lockfile --ignore-scripts
yarn link vega-lite

# TODO: load in real files if we can get rsync installed in the runner someday?
# Put index.json files in public/spec/vega-lite and public/spec/vega
echo "Creating stub index.json for each vega library"

mkdir -p public/spec/vega-lite
mkdir -p public/spec/vega
touch public/spec/vega-lite/index.json
touch public/spec/vega/index.json

cat <<EOF > public/spec/vega-lite/index.json
{}
EOF

cat <<EOF > public/spec/vega/index.json
{}
EOF

# TBD if some vendor files are needed
yarn run vite build --base /

0 comments on commit 64d6daf

Please sign in to comment.