Skip to content

Commit

Permalink
feat(cloudflare): dedicated package for building and deploying to clo…
Browse files Browse the repository at this point in the history
…udflare (#45)
  • Loading branch information
CorentinTh authored Aug 26, 2024
1 parent 649369c commit 88b68c6
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 10 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci-app-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ jobs:
- name: Run unit test
run: pnpm test

- name: Build the app
run: pnpm build
- name: Build the app for Node.js
run: pnpm build:node

- name: Build the app for Cloudflare
run: pnpm build:cloudflare
30 changes: 30 additions & 0 deletions .github/workflows/ci-deploy-cloudflare.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI - Deploy Cloudflare

on:
pull_request:
push:
branches:
- main

jobs:
ci-deploy-cloudflare:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/deploy-cloudflare

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
corepack: true
cache: 'pnpm'

- name: Install dependencies
run: pnpm i
working-directory: ./

- name: Build the app
run: pnpm build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
dist
dist-app
dist-node
dist-cloudflare

# Node dependencies
node_modules
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ This ensures that the note remains securely encrypted during transmission and st

This project is organized as a monorepo using `pnpm` workspaces. The structure is as follows:

- **packages/app-client**: Frontend application built with SolidJS.
- **packages/app-server**: Backend application using HonoJS.
- **[packages/app-client](./packages/app-client/)**: Frontend application built with SolidJS.
- **[packages/app-server](./packages/app-server/)**: Backend application using HonoJS.
- **[packages/deploy-cloudflare](./packages/deploy-cloudflare/)**: Cloudflare Pages build scripts and configuration.

## Contributing

Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@enclosed/root",
"version": "0.0.0",
"description": "Send private and secure note",
"packageManager": "pnpm@9.8.0",
"license": "Apache-2.0",
"description": "Send private and secure note",
"author": "Corentin Thomasset <corentinth@proton.me> (https://corentin.tech)",
"repository": {
"type": "git",
Expand All @@ -18,8 +18,5 @@
"password",
"manager",
"expiration"
],
"scripts": {
"build:app": "pnpm -p --filter @enclosed/app-* run build && mkdir -p packages/app-server/dist-app && cp -r packages/app-*/dist/* packages/app-server/dist-app"
}
]
}
2 changes: 1 addition & 1 deletion packages/app-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "$npm_execpath run build:cloudflare",
"dev:node": "tsx -r dotenv/config --watch src/index.node.ts",
"dev:cloudflare": "wrangler dev --test-scheduled --port=8787 src/index.cloudflare.ts",
"build:cloudflare": "esbuild --bundle src/index.cloudflare.ts --format=esm --outfile=dist/_worker.js --minify",
"build:cloudflare": "esbuild --bundle src/index.cloudflare.ts --format=esm --outfile=dist-cloudflare/_worker.js --minify",
"build:node": "esbuild --bundle src/index.node.ts --platform=node --format=cjs --outfile=dist-node/index.cjs --minify",
"preview": "wrangler pages dev",
"deploy": "$npm_execpath run build && wrangler pages deploy",
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions packages/deploy-cloudflare/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Build the app server and client
pnpm --filter @enclosed/app-server build:cloudflare
pnpm --filter @enclosed/app-client build

# Reset the dist folder
rm -rf dist
mkdir dist

# Copy the app server and client to the dist folder
cp -r ../app-server/dist-cloudflare/* dist/
cp -r ../app-client/dist/* dist/

# Copy routes.json to the dist folder
cp _routes.json dist/
15 changes: 15 additions & 0 deletions packages/deploy-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@enclosed/deploy-cloudflare",
"version": "0.0.0",
"description": "Deploy scripts for Cloudflare Pages",
"packageManager": "pnpm@9.8.0",
"license": "Apache-2.0",
"author": "Corentin Thomasset <corentinth@proton.me> (https://corentin.tech)",
"repository": {
"type": "git",
"url": "https://github.com/CorentinTh/enclosed"
},
"scripts": {
"build": "./build.sh"
}
}
1 change: 1 addition & 0 deletions packages/deploy-cloudflare/wrangler.toml
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 88b68c6

Please sign in to comment.