fix typescript errors
This commit is contained in:
parent
55f10aeb2b
commit
d2fd1c0fac
|
|
@ -0,0 +1,103 @@
|
|||
# Deployment Summary
|
||||
|
||||
## Current Setup
|
||||
|
||||
### ✅ Frontend: Cloudflare Pages
|
||||
- **Deployment**: Automatic on push to `main` branch
|
||||
- **Build**: `npm run build`
|
||||
- **Output**: `dist/`
|
||||
- **Configuration**: Set in Cloudflare Pages dashboard
|
||||
- **Environment Variables**: Set in Cloudflare Pages dashboard (VITE_* variables)
|
||||
|
||||
### ✅ Worker: GitHub Actions
|
||||
- **Production**: Deploys on push to `main` branch → uses `wrangler.toml`
|
||||
- **Dev**: Deploys on push to `automerge/**` branches → uses `wrangler.dev.toml`
|
||||
- **Manual**: Can trigger via GitHub Actions UI with environment selection
|
||||
|
||||
### ❌ Vercel: Can be disabled
|
||||
- Frontend is now on Cloudflare Pages
|
||||
- Worker was never on Vercel
|
||||
- You can safely disconnect/delete the Vercel project
|
||||
|
||||
## Why GitHub Actions for Workers?
|
||||
|
||||
**GitHub Actions is better than Cloudflare's automatic worker deployments because:**
|
||||
|
||||
1. ✅ **More Control**: You can add tests, checks, conditional logic
|
||||
2. ✅ **Better Branching**: Different configs for dev vs prod
|
||||
3. ✅ **Manual Triggers**: Deploy specific environments on demand
|
||||
4. ✅ **No Conflicts**: Single source of truth (no competing deployments)
|
||||
5. ✅ **Version Tracking**: All deployments tracked in GitHub
|
||||
6. ✅ **Flexibility**: Can add deployment gates, notifications, etc.
|
||||
|
||||
**Cloudflare's automatic worker deployments:**
|
||||
- ❌ Less control over the process
|
||||
- ❌ Can conflict with GitHub Actions
|
||||
- ❌ Harder to debug when issues occur
|
||||
- ❌ Limited branching/environment support
|
||||
|
||||
## Environment Switching
|
||||
|
||||
### For Local Development
|
||||
|
||||
You can switch between dev and prod workers locally using:
|
||||
|
||||
```bash
|
||||
# Switch to production worker
|
||||
./switch-worker-env.sh production
|
||||
|
||||
# Switch to dev worker
|
||||
./switch-worker-env.sh dev
|
||||
|
||||
# Switch to local worker (requires local worker running)
|
||||
./switch-worker-env.sh local
|
||||
```
|
||||
|
||||
This updates `.env.local` with `VITE_WORKER_ENV=production` or `VITE_WORKER_ENV=dev`.
|
||||
|
||||
**Default**: Now set to `production` (changed from `dev`)
|
||||
|
||||
### For Cloudflare Pages
|
||||
|
||||
Set environment variables in Cloudflare Pages dashboard:
|
||||
- **Production**: `VITE_WORKER_ENV=production`
|
||||
- **Preview**: `VITE_WORKER_ENV=dev` (for testing)
|
||||
|
||||
## Deployment Workflow
|
||||
|
||||
### Frontend (Cloudflare Pages)
|
||||
1. Push to `main` → Auto-deploys to production
|
||||
2. Create PR → Auto-deploys to preview environment
|
||||
3. Environment variables set in Cloudflare dashboard
|
||||
|
||||
### Worker (GitHub Actions)
|
||||
1. **Production**: Push to `main` → Auto-deploys to production worker
|
||||
2. **Dev**: Push to `automerge/**` branch → Auto-deploys to dev worker
|
||||
3. **Manual**: Go to Actions → "Deploy Worker" → Run workflow → Choose environment
|
||||
|
||||
## Testing Both Environments
|
||||
|
||||
### Local Testing
|
||||
```bash
|
||||
# Test with production worker
|
||||
./switch-worker-env.sh production
|
||||
npm run dev
|
||||
|
||||
# Test with dev worker
|
||||
./switch-worker-env.sh dev
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Remote Testing
|
||||
- **Production**: Visit your production Cloudflare Pages URL
|
||||
- **Dev**: Visit your dev worker URL directly or use preview deployment
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. ✅ **Disable Vercel**: Go to Vercel dashboard → Disconnect repository
|
||||
2. ✅ **Verify Cloudflare Pages**: Ensure it's deploying correctly
|
||||
3. ✅ **Test Worker Deployments**: Push to main and verify production worker updates
|
||||
4. ✅ **Test Dev Worker**: Push to `automerge/test` branch and verify dev worker updates
|
||||
|
||||
|
||||
|
||||
|
|
@ -119,27 +119,29 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
|
|||
try {
|
||||
// Create a deep copy to ensure Automerge properly handles nested objects
|
||||
// This is critical for preserving nested structures like props, richText, etc.
|
||||
// Cast record to any to access properties that may not exist on all TLRecord types
|
||||
const recordAny = record as any
|
||||
let recordToSave: any
|
||||
try {
|
||||
recordToSave = JSON.parse(JSON.stringify(record))
|
||||
// Verify essential properties are preserved
|
||||
if (!recordToSave.typeName && record.typeName) {
|
||||
recordToSave.typeName = record.typeName
|
||||
if (!recordToSave.typeName && recordAny.typeName) {
|
||||
recordToSave.typeName = recordAny.typeName
|
||||
}
|
||||
if (!recordToSave.id && record.id) {
|
||||
recordToSave.id = record.id
|
||||
if (!recordToSave.id && recordAny.id) {
|
||||
recordToSave.id = recordAny.id
|
||||
}
|
||||
if (!recordToSave.type && record.type) {
|
||||
recordToSave.type = record.type
|
||||
if (!recordToSave.type && recordAny.type) {
|
||||
recordToSave.type = recordAny.type
|
||||
}
|
||||
if (!recordToSave.props && record.props) {
|
||||
recordToSave.props = record.props
|
||||
if (!recordToSave.props && recordAny.props) {
|
||||
recordToSave.props = recordAny.props
|
||||
}
|
||||
// Copy all enumerable properties that might have been lost
|
||||
for (const prop in record) {
|
||||
for (const prop in recordAny) {
|
||||
if (!(prop in recordToSave)) {
|
||||
try {
|
||||
recordToSave[prop] = record[prop]
|
||||
recordToSave[prop] = recordAny[prop]
|
||||
} catch (e) {
|
||||
// Skip properties that can't be accessed
|
||||
}
|
||||
|
|
@ -149,9 +151,9 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
|
|||
// If JSON serialization fails, manually copy properties
|
||||
console.warn(`⚠️ JSON serialization failed for record ${key}, using manual copy`)
|
||||
recordToSave = {}
|
||||
for (const prop in record) {
|
||||
for (const prop in recordAny) {
|
||||
try {
|
||||
recordToSave[prop] = record[prop]
|
||||
recordToSave[prop] = recordAny[prop]
|
||||
} catch (e) {
|
||||
// Skip properties that can't be accessed
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue