Complete rewrite of deployment script to use unified .saac.json
configuration file and integrate email verification for user registration.
Major Changes:
==============
1. **New Configuration System**
- Replaced .deployment-uuid + deployment-info.txt with .saac.json
- Single JSON file for all SAAC-related state
- Secure file permissions (600)
- Structured format with version tracking
2. **.saac.json Structure**
```json
{
"version": "1.0",
"user": {
"email": "user@example.com",
"user_id": "uuid",
"api_key": "cw_...",
"verified": true,
"registered_at": "timestamp"
},
"deployment": {
"application_uuid": "uuid",
"domain": "https://...",
"deployed_at": "timestamp"
}
}
```
3. **Email Verification Flow** (NEW)
- Registration prompts for email
- Calls POST /api/v1/users/register
- Saves initial config with verified: false
- Prompts for verification code from MailHog
- Calls POST /api/v1/users/verify
- Updates config with verified: true
- Only then allows deployment
4. **Auto-Detection Enhanced**
```
No .saac.json → Registration + Verification
Exists, not verified → Verification only
Exists, verified, no app → Setup mode
Exists, verified, has app → Update mode
```
5. **Helper Functions** (NEW)
- load_config() - Loads all state from .saac.json using jq
- save_config() - Saves state with secure permissions
6. **Removed Dependencies**
- SAAC_API_KEY environment variable (now in .saac.json)
- .deployment-uuid file (now in .saac.json)
- deployment-info.txt file (now in .saac.json)
7. **New Dependency**
- jq (JSON processor) - Required and checked at startup
8. **Updated .gitignore**
- Added: .saac.json
- Removed: .deployment-uuid, deployment-info.txt
Script Modes:
=============
./deploy-to-apps.sh # Auto-detect
./deploy-to-apps.sh --setup # Force new deployment
./deploy-to-apps.sh --update # Force update existing
./deploy-to-apps.sh --status # Check deployment status
Registration Flow:
==================
1. Script detects no .saac.json
2. Prompts: "Enter your email:"
3. Calls POST /users/register
4. Receives user_id and api_key
5. Saves to .saac.json with verified: false
6. Shows: "Check MailHog at https://mailhog.goryan.io"
7. Prompts: "Enter verification code from email:"
8. Calls POST /users/verify with code
9. Updates .saac.json with verified: true
10. Proceeds to application setup
Update Flow:
============
1. Script loads config from .saac.json
2. Extracts api_key automatically
3. Calls PATCH /applications/:uuid/env
4. Calls POST /applications/:uuid/deploy
5. Updates last_updated in .saac.json
Documentation Created:
======================
1. DEPLOYMENT_UPDATE_SUMMARY.md
- Technical documentation
- .saac.json schema
- Helper function details
- Flow diagrams
- Security considerations
2. QUICK_START.md
- User-friendly guide
- First-time deployment walkthrough
- Common scenarios
- Troubleshooting tips
3. MIGRATION_GUIDE.md
- Existing user migration instructions
- Two migration options
- Verification checklist
- Rollback instructions
- FAQ section
Benefits:
=========
✅ Single source of truth for all SAAC state
✅ No manual API key management
✅ Email verification integrated
✅ Secure file permissions
✅ Extensible JSON format
✅ Self-documenting structure
✅ Easier maintenance
Breaking Changes:
=================
- Must install jq
- Must migrate from old .deployment-uuid format
- SAAC_API_KEY env var no longer used
- Email verification required for new users
Migration Path:
===============
Option 1 (Recommended): Start fresh
- Delete old files
- Run new script
- Follow registration prompts
Option 2 (Advanced): Manual migration
- Create .saac.json with existing data
- Preserve deployment UUID
- Test functionality
Validation:
===========
✓ Bash syntax validated (bash -n)
✓ .saac.json in .gitignore
✓ Helper functions implemented
✓ Registration flow integrated
✓ Verification flow integrated
✓ All modes working
✓ File permissions set correctly
Script size: 471 → 657 lines
Complexity: Reduced (single config file)
Security: Improved (600 permissions, no env vars)
🤖 Generated with Claude Code
https://claude.com/claude-code
Co-Authored-By: Claude <noreply@anthropic.com>
19 lines
206 B
Plaintext
19 lines
206 B
Plaintext
node_modules/
|
|
.env
|
|
.env.local
|
|
npm-debug.log*
|
|
yarn-debug.log*
|
|
yarn-error.log*
|
|
.DS_Store
|
|
*.log
|
|
.vscode/
|
|
.idea/
|
|
deploy_key
|
|
cc/
|
|
|
|
# Deployment keys and scripts
|
|
deploy_key*
|
|
deploy.sh
|
|
deploy-to-apps.sh
|
|
.saac.json
|