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

Un-ossify the build system #36

Draft
wants to merge 110 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
d0fb3dd
Move components into playground
tstirrat15 Jan 10, 2025
a7233d8
Remove unused type
tstirrat15 Jan 10, 2025
43c1d7f
Remove unnecessary .d.ts file
tstirrat15 Jan 10, 2025
f7b651f
Remove remaining files from playground-ui
tstirrat15 Jan 10, 2025
a22b4b7
Remove unnecessary react usages
tstirrat15 Jan 10, 2025
768243a
Remove reference to workspace package
tstirrat15 Jan 10, 2025
5a6b5ca
Remove package.json from workspace
tstirrat15 Jan 10, 2025
1e80dd6
Update yarn.lock
tstirrat15 Jan 10, 2025
2ed9327
Fix a bunch of references and a few lint issues
tstirrat15 Jan 10, 2025
922b119
Move things out of spicedb-common dir
tstirrat15 Jan 10, 2025
9a6f2d1
Remove spicedb-common bits
tstirrat15 Jan 10, 2025
3de0ff8
Move wasm-config where code can see it
tstirrat15 Jan 10, 2025
84b0e64
Fix use-deep-compare reference
tstirrat15 Jan 10, 2025
c36ff77
Add a todo to the genfile
tstirrat15 Jan 10, 2025
23d4398
Fix all of the references
tstirrat15 Jan 10, 2025
cf93156
Get rid of workspace package.json
tstirrat15 Jan 10, 2025
7d93352
Add scripts from root package to playground package
tstirrat15 Jan 10, 2025
696402a
Move some playground things into the root
tstirrat15 Jan 10, 2025
cfcffdc
Remove unintentionally-committed vite config
tstirrat15 Jan 10, 2025
8178d79
Move script into root scripts
tstirrat15 Jan 10, 2025
fbfb7b6
Move source files to root
tstirrat15 Jan 10, 2025
81d9f88
Move public and contrib to root
tstirrat15 Jan 10, 2025
f49c665
Finish reorganization
tstirrat15 Jan 10, 2025
605ce2f
Update to reflect flattened structure
tstirrat15 Jan 10, 2025
f298863
Handle mjs correctly
tstirrat15 Jan 10, 2025
5c889f6
Get rid of unnecessary module resolutions:
tstirrat15 Jan 10, 2025
c8dbe00
Remove changes I made to package.json
tstirrat15 Jan 10, 2025
5fb0109
Remove craco config
tstirrat15 Jan 10, 2025
f042762
Get rid of craco and react-scripts'
tstirrat15 Jan 10, 2025
6764286
Put index.html file in the root
tstirrat15 Jan 10, 2025
3a35231
Upgrade ts, add vite and vitest
tstirrat15 Jan 10, 2025
b2723b4
Add some vite configuration
tstirrat15 Jan 10, 2025
54caa5d
Add missing plugins
tstirrat15 Jan 10, 2025
bbae2ee
Get linting working
tstirrat15 Jan 10, 2025
91aaef1
Disable lint rules that errored on generated files
tstirrat15 Jan 10, 2025
f68c0a1
Fix a bunch of types
tstirrat15 Jan 10, 2025
83cf1c4
Make some mods to tsconfig
tstirrat15 Jan 10, 2025
54ddf27
We never used this
tstirrat15 Jan 10, 2025
1e1dc14
Fix fontsource and remove service worker
tstirrat15 Jan 10, 2025
df9d933
Swap for new fontsource package
tstirrat15 Jan 10, 2025
555e347
Update react types
tstirrat15 Jan 10, 2025
3ea9ba5
Upgrade styled-compoennts to fix errors
tstirrat15 Jan 10, 2025
a8fb449
Get rid of setupTests
tstirrat15 Jan 10, 2025
72d8d30
Empty tests are useless
tstirrat15 Jan 10, 2025
0ac22b1
Remove now-unused file
tstirrat15 Jan 13, 2025
5dab8d2
Remove config file in favor of build-time vars
tstirrat15 Jan 13, 2025
19e6956
Add typescript types for environment variables
tstirrat15 Jan 13, 2025
9345420
Remove config file, fix name of entrypoint
tstirrat15 Jan 13, 2025
0c0748f
Add types for svgr
tstirrat15 Jan 13, 2025
eae1f45
Fix imports, types, remove unused
tstirrat15 Jan 13, 2025
f40dfab
Fix import, add TODO
tstirrat15 Jan 13, 2025
d4a4469
Simplify configuration service
tstirrat15 Jan 13, 2025
65ef89a
Simplify/fix types
tstirrat15 Jan 13, 2025
a257dad
Fix types
tstirrat15 Jan 13, 2025
b123401
Fix test imports
tstirrat15 Jan 13, 2025
83e7fec
Fix types and imports
tstirrat15 Jan 13, 2025
8f8b487
Fix some types and imports
tstirrat15 Jan 13, 2025
b3942fa
Fix svg imports
tstirrat15 Jan 13, 2025
09897ce
Remove props that the component doesn't support, fix types and imports
tstirrat15 Jan 13, 2025
50946c8
Fix tests
tstirrat15 Jan 13, 2025
d158114
Rename buf.gen.yaml'
tstirrat15 Jan 13, 2025
9e331c3
Update buf.gen.yaml
tstirrat15 Jan 13, 2025
ebda000
Fix versions
tstirrat15 Jan 13, 2025
feb5a66
Regenerate protobuf files to try and fix build issue
tstirrat15 Jan 13, 2025
1e37c88
Temp commit todo file
tstirrat15 Jan 13, 2025
3a950ac
Vendor the entire client
tstirrat15 Jan 13, 2025
4139993
Remove temporarily
tstirrat15 Jan 13, 2025
31c7435
Work towards generating everything in the same directory
tstirrat15 Jan 13, 2025
3f84528
Vendor the SpiceDB proto
tstirrat15 Jan 14, 2025
6c9164b
Add proto gen for internal protos to repo
tstirrat15 Jan 14, 2025
7aaaba2
Add configuration for vendored proto
tstirrat15 Jan 14, 2025
255093f
Bump eslint deps
tstirrat15 Jan 14, 2025
2a6c791
Remove vendored proto
tstirrat15 Jan 14, 2025
17c040e
Deleting to regenerate again
tstirrat15 Jan 14, 2025
267b050
Reference repo instead of vendored proto, add optimize code size flag
tstirrat15 Jan 14, 2025
a819f81
Add generated code
tstirrat15 Jan 14, 2025
4c6fec0
Remove now-unused grpc-web
tstirrat15 Jan 14, 2025
f29c50a
Remove unused filde
tstirrat15 Jan 14, 2025
07fc5ca
Update copy-build script'
tstirrat15 Jan 14, 2025
03bee8d
Ignore dist file instead of build
tstirrat15 Jan 14, 2025
35c63f5
Get rid of unused functions from contrib file
tstirrat15 Jan 14, 2025
e4b8788
Update imports
tstirrat15 Jan 14, 2025
2ff00bc
Refactor sharing code to use protobuf-ts syntax
tstirrat15 Jan 14, 2025
61e35fd
Update imports
tstirrat15 Jan 14, 2025
f87a667
Get rid of postbuild script
tstirrat15 Jan 14, 2025
c8d43d3
Fix build script
tstirrat15 Jan 14, 2025
5b47c03
Get rid of config files in vercel config
tstirrat15 Jan 14, 2025
40fc6df
Remove references to process.env
tstirrat15 Jan 14, 2025
0434020
Use createRoot instead of render)
tstirrat15 Jan 14, 2025
d3f9af2
Reference webassembly directly instead of global
tstirrat15 Jan 14, 2025
307b604
Formatting
tstirrat15 Jan 14, 2025
09179f4
add more todos
tstirrat15 Jan 14, 2025
d733e60
Fix an error on render
tstirrat15 Jan 16, 2025
00ddc22
Add theme color to fix runtime error
tstirrat15 Jan 16, 2025
f1c4a69
Fix issue with light theme colors being undefined
tstirrat15 Jan 16, 2025
cac3938
Move wasm into public so it doesn't need to be copied
tstirrat15 Jan 16, 2025
195df0f
Update scripts to reflect new wasm location
tstirrat15 Jan 16, 2025
efe889d
Put wasm in static dir
tstirrat15 Jan 16, 2025
2af936a
Put into static folder
tstirrat15 Jan 16, 2025
160ac78
Flatten dir
tstirrat15 Jan 16, 2025
93ddd1b
Update script location again
tstirrat15 Jan 16, 2025
f021eb0
Remove references to removed files
tstirrat15 Jan 16, 2025
4ced366
Add a dockerignore file for easier building
tstirrat15 Jan 16, 2025
8181f8b
Simplify dockerfile and get build working
tstirrat15 Jan 16, 2025
a45c399
Fix local instance
tstirrat15 Jan 16, 2025
ba66ccd
Make build directory build again
tstirrat15 Jan 16, 2025
81fd01d
Put build folder back in build
tstirrat15 Jan 16, 2025
5ece1d4
Add a comment
tstirrat15 Jan 16, 2025
339b7e7
Finish pointing build script back at build
tstirrat15 Jan 16, 2025
2e586cb
Fix merge conflicts
tstirrat15 Jan 16, 2025
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
yarn-debug.log
yarn-error.log
spicedb
zed
build
.vercel
39 changes: 10 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
ARG BASE_IMAGE=node:18-alpine3.18
ARG BASE_IMAGE=node:22-alpine

FROM --platform=$BUILDPLATFORM $BASE_IMAGE AS playground-builder
WORKDIR /app
COPY ./package.json .
COPY ./yarn.lock .
COPY ./playground-ui ./playground-ui
COPY ./spicedb-common ./spicedb-common
COPY ./playground/package.json ./playground/package.json
# Bring in everything not ignored by the dockerignore
COPY . .
ENV YARN_CACHE_FOLDER=/tmp/yarn_cache
RUN yarn install --frozen-lockfile --production --non-interactive --network-timeout 1000000
RUN yarn install --frozen-lockfile --non-interactive --network-timeout 1000000

COPY ./playground ./playground

WORKDIR /app/playground

ARG APPLICATION_ROOT=/
ARG NODE_OPTIONS=--openssl-legacy-provider
ENV PUBLIC_URL ${APPLICATION_ROOT}
RUN yarn build

FROM $BASE_IMAGE AS playground-verifier
RUN npm install -g jshint
COPY ./playground/contrib/generate-config-env.sh .
COPY ./playground/contrib/test-config-env.sh .
RUN ./test-config-env.sh
RUN echo 'Config Verified' > verified

FROM nginx:1.25.2
LABEL maintainer="AuthZed <support@authzed.com>"
Expand All @@ -34,18 +19,14 @@ ENV PORT=3000
ENTRYPOINT ["./docker-entrypoint-wrapper.sh"]
CMD []

COPY ./playground/contrib/generate-config-env.sh .
COPY ./playground/contrib/test-nginx-conf.sh .
COPY ./playground/contrib/test-config-env.sh .
COPY ./playground/contrib/nginx.conf.tmpl .
COPY ./playground/contrib/docker-entrypoint-wrapper.sh .
COPY ./contrib/generate-config-env.sh .
COPY ./contrib/test-nginx-conf.sh .
COPY ./contrib/test-config-env.sh .
COPY ./contrib/nginx.conf.tmpl .
COPY ./contrib/docker-entrypoint-wrapper.sh .
RUN bash ./test-nginx-conf.sh

COPY --from=playground-verifier verified .
COPY --from=playground-builder /app/playground/build/ /usr/share/nginx/html/
COPY wasm/main.wasm /usr/share/nginx/html/static/main.wasm
COPY wasm/zed.wasm /usr/share/nginx/html/static/zed.wasm
COPY --from=playground-builder /app/build/ /usr/share/nginx/html/

RUN mkdir /usr/share/nginx/html/static/schemas
COPY examples/schemas/ /usr/share/nginx/html/static/schemas
RUN ls /usr/share/nginx/html/static/schemas > /usr/share/nginx/html/static/schemas/_all
6 changes: 6 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [x] Fix tests
- [ ] Fix environment variable setting in dockerfile
- [ ] Fix environment variable setting in vercel
- [x] Fix build
- [x] Fix buf.gen.yaml
- [x] Get local instance working without errors
15 changes: 15 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
version: 'v2'
plugins:
- remote: buf.build/community/timostamm-protobuf-ts:v2.9.1
out: 'src/spicedb-common/protodefs'
opt:
- "long_type_string"
- "generate_dependencies"
- "optimize_code_size"
inputs:
- module: "buf.build/authzed/api:v1.38.0"
paths:
- "authzed/api/v0"
- git_repo: "https://github.com/authzed/spicedb"
subdir: "proto/internal"
9 changes: 9 additions & 0 deletions contrib/generate-config-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

generate_nginx() {
conf_template=$1
nginx_conf=$2
envsubst '$PLAYGROUND_DEVELOPER_API_DOWNLOAD_ENDPOINT,$HEADER_CONTENT_SECURITY_POLICY' < "$conf_template" > "$nginx_conf"
echo "${nginx_conf}:"
cat "$nginx_conf"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ http {
add_header Cache-Control no-cache;
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always;
}
location /config.json {
add_header Cache-Control no-cache;
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always;
}
location /config-env.js {
add_header Cache-Control no-cache;
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always;
}
location ~ ^/s/([^/]+)/download$ {
rewrite ^/s/([^/]+)/download$ ${PLAYGROUND_DEVELOPER_API_DOWNLOAD_ENDPOINT}/$1;
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
10 changes: 5 additions & 5 deletions playground/public/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet" type="text/css" />

<script src="%PUBLIC_URL%/wasm_exec.js"></script>
<script src="/wasm_exec.js"></script>

<meta charset="utf-8" />
<meta name="robots" content="noindex,nofollow" />
<link rel="icon" href="%PUBLIC_URL%/favicon.svg" />
<link rel="icon" href="/favicon.svg" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<script src="%PUBLIC_URL%/config-env.js"></script>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<title>SpiceDB Playground</title>
</head>

<body>
<noscript>JavaScript is required to run this single-page app. Sorry :/</noscript>
<div id="root"></div>
<div id="portal"></div>
<script type="module" src="/src/index.tsx"></script>
</body>

</html>
114 changes: 104 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,111 @@
{
"name": "code",
"private": "true",
"name": "playground",
"version": "0.1.0",
"type": "module",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.3",
"@apollo/link-context": "^2.0.0-beta.3",
"@fontsource/roboto": "^5.1.1",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@glideapps/glide-data-grid": "^4.0.2",
"@glideapps/glide-data-grid-cells": "^4.0.2",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
"@monaco-editor/react": "^4.3.1",
"@protobuf-ts/grpcweb-transport": "^2.9.4",
"@protobuf-ts/plugin": "^2.6.0",
"ansi-to-html": "^0.7.2",
"color-hash": "^2.0.2",
"d3-scale-chromatic": "^2.0.0",
"dequal": "^2.0.2",
"file-saver": "^2.0.5",
"file-select-dialog": "^1.5.4",
"google-protobuf": "^3.21.2",
"graphql": "16.6.0",
"install": "^0.13.0",
"line-column": "^1.0.2",
"lodash.throttle": "^4.1.1",
"markdown-it": "^13.0.1",
"marked": "^4.0.10",
"monaco-editor-core": "^0.39.0",
"parsimmon": "^1.18.1",
"react": "^18.3.1",
"react-cookie": "^4.1.1",
"react-dom": "^18.3.1",
"react-joyride": "^2.5.3",
"react-reflex": "^4.0.9",
"react-responsive-carousel": "^3.2.23",
"react-router-dom": "^5.3.4",
"sjcl": "^1.0.8",
"string-to-color": "^2.2.2",
"string.prototype.replaceall": "^1.0.6",
"styled-components": "^6.1.14",
"typeface-roboto-mono": "^1.1.13",
"use-deep-compare": "^1.1.0",
"use-deep-compare-effect": "^1.8.1",
"use-keyboard-shortcuts": "^2.2.2",
"visjs-network": "^4.24.11",
"yaml": "^2.0.1"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/color-hash": "^1.0.2",
"@types/d3-scale-chromatic": "^3.0.0",
"@types/file-saver": "^2.0.5",
"@types/jest": "^29.5.0",
"@types/line-column": "^1.0.0",
"@types/markdown-it": "^12.2.3",
"@types/node": "^20.3.3",
"@types/parsimmon": "^1.10.6",
"@types/react": "^18.3.1",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-dom": "^18.3.1",
"@types/react-router-dom": "^5.3.0",
"@types/sjcl": "^1.0.30",
"@types/styled-components": "^5.1.26",
"@types/use-deep-compare-effect": "^1.5.1",
"@types/uuid": "^9.0.1",
"@vitejs/plugin-react": "^4.3.4",
"cypress": "^12.9.0",
"cypress-wait-until": "^1.7.2",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.18",
"globals": "^15.14.0",
"postcss-safe-parser": "7.0.0",
"typescript": "~5.7.3",
"typescript-eslint": "^8.20.0",
"vite": "^6.0.7",
"vite-plugin-svgr": "^4.3.0",
"vitest": "^2.1.8"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "yarn workspace playground build && ./scripts/copy-build.sh",
"dev": "HTTPS=true vite",
"build": "tsc -b && vite build && ./scripts/copy-build.sh",
"test": "vitest",
"lint": "eslint .",
"lint-fix": "eslint --fix .",
"cy:run": "cypress run --browser chrome",
"cy:open": "cypress open",
"update:spicedb": "./scripts/update-spicedb.sh",
"update:zed": "./scripts/update-zed.sh"
},
"workspaces": [
"spicedb-common",
"playground-ui",
"playground"
],
"dependencies": {}
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
13 changes: 0 additions & 13 deletions playground-ui/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions playground-ui/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions playground-ui/src/types.d.ts

This file was deleted.

6 changes: 0 additions & 6 deletions playground-ui/src/types.ts

This file was deleted.

26 changes: 0 additions & 26 deletions playground-ui/tsconfig.json

This file was deleted.

Loading