diff --git a/.github/workflows/deploy-sandbox.yml b/.github/workflows/deploy-sandbox.yml new file mode 100644 index 0000000..1dbd173 --- /dev/null +++ b/.github/workflows/deploy-sandbox.yml @@ -0,0 +1,51 @@ +name: Deploy sandbox to GitHub Pages + +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: npm + + - uses: actions/configure-pages@v5 + + - run: npm ci + + - run: npm run sandbox:typecheck + + - run: npm run sandbox:build + + - uses: actions/upload-pages-artifact@v4 + with: + path: sandbox/dist + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/sandbox/README.md b/sandbox/README.md new file mode 100644 index 0000000..36b8938 --- /dev/null +++ b/sandbox/README.md @@ -0,0 +1,26 @@ +# Demo WebApp project + +A live deployment of this demo can be found here: https://bitboxswiss.github.io/bitbox-api-ts/. + +This folder contains a React project showcasing the TypeScript API. It uses the bitbox-api library +in `../src` through the Vite alias in [./vite.config.ts](./vite.config.ts). + +The main entry point of the sandbox is at [./src/App.tsx](./src/App.tsx). + +The full package API is described by the TypeScript definitions file `../dist/index.d.ts` after +running `npm run build`. + +Install the deps from the repository root using: + + npm ci + +Run the sandbox from the repository root using: + + npm run sandbox:dev + +Hot-reloading is supported - you can change the library source or sandbox files without restarting +the server. + +To build the sandbox from the repository root: + + npm run sandbox:build diff --git a/sandbox/vite.config.ts b/sandbox/vite.config.ts index a03e422..b1be131 100644 --- a/sandbox/vite.config.ts +++ b/sandbox/vite.config.ts @@ -7,8 +7,9 @@ import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -export default defineConfig({ +export default defineConfig(({ command }) => ({ root: __dirname, + base: command === 'build' ? '/bitbox-api-ts/' : '/', plugins: [react()], resolve: { alias: { @@ -21,4 +22,4 @@ export default defineConfig({ outDir: path.resolve(__dirname, 'dist'), emptyOutDir: true, }, -}); +}));