myaidev-method 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/USER_GUIDE.md +389 -8
- package/bin/cli.js +165 -30
- package/package.json +1 -1
- package/src/lib/ascii-banner.js +100 -0
- package/src/templates/claude/commands/myai-deploy-dev.md +500 -0
- package/src/templates/claude/commands/myai-deploy-prod.md +837 -0
- package/src/templates/claude/commands/myai-deploy-staging.md +331 -0
- package/src/templates/claude/commands/myai-git-hotfix.md +957 -0
- package/src/templates/claude/commands/myai-git-pr.md +200 -0
- package/src/templates/claude/commands/myai-git-release.md +806 -0
- package/src/templates/claude/commands/myai-git-sync.md +796 -0
- package/src/templates/codex/commands/myai-astro-publish.md +51 -0
- package/src/templates/codex/commands/myai-configure.md +185 -0
- package/src/templates/codex/commands/myai-content-writer.md +73 -0
- package/src/templates/codex/commands/myai-coolify-deploy.md +159 -0
- package/src/templates/codex/commands/myai-deploy-dev.md +379 -0
- package/src/templates/codex/commands/myai-deploy-prod.md +431 -0
- package/src/templates/codex/commands/myai-deploy-staging.md +275 -0
- package/src/templates/codex/commands/myai-dev-architect.md +69 -0
- package/src/templates/codex/commands/myai-dev-code.md +82 -0
- package/src/templates/codex/commands/myai-dev-docs.md +83 -0
- package/src/templates/codex/commands/myai-dev-review.md +85 -0
- package/src/templates/codex/commands/myai-dev-test.md +84 -0
- package/src/templates/codex/commands/myai-docusaurus-publish.md +42 -0
- package/src/templates/codex/commands/myai-git-hotfix.md +512 -0
- package/src/templates/codex/commands/myai-git-pr.md +196 -0
- package/src/templates/codex/commands/myai-git-release.md +516 -0
- package/src/templates/codex/commands/myai-git-sync.md +517 -0
- package/src/templates/codex/commands/myai-mintlify-publish.md +42 -0
- package/src/templates/codex/commands/myai-payloadcms-publish.md +42 -0
- package/src/templates/codex/commands/myai-sparc-workflow.md +185 -0
- package/src/templates/codex/commands/myai-wordpress-admin.md +143 -0
- package/src/templates/codex/commands/myai-wordpress-publish.md +66 -0
- package/src/templates/gemini/commands/myai-astro-publish.toml +76 -0
- package/src/templates/gemini/commands/myai-configure.toml +188 -0
- package/src/templates/gemini/commands/myai-content-writer.toml +76 -0
- package/src/templates/gemini/commands/myai-coolify-deploy.toml +138 -0
- package/src/templates/gemini/commands/myai-deploy-dev.toml +379 -0
- package/src/templates/gemini/commands/myai-deploy-prod.toml +438 -0
- package/src/templates/gemini/commands/myai-deploy-staging.toml +275 -0
- package/src/templates/gemini/commands/myai-dev-architect.toml +64 -0
- package/src/templates/gemini/commands/myai-dev-code.toml +75 -0
- package/src/templates/gemini/commands/myai-dev-docs.toml +76 -0
- package/src/templates/gemini/commands/myai-dev-review.toml +78 -0
- package/src/templates/gemini/commands/myai-dev-test.toml +77 -0
- package/src/templates/gemini/commands/myai-docusaurus-publish.toml +63 -0
- package/src/templates/gemini/commands/myai-git-hotfix.toml +953 -0
- package/src/templates/gemini/commands/myai-git-pr.toml +196 -0
- package/src/templates/gemini/commands/myai-git-release.toml +802 -0
- package/src/templates/gemini/commands/myai-git-sync.toml +792 -0
- package/src/templates/gemini/commands/myai-mintlify-publish.toml +67 -0
- package/src/templates/gemini/commands/myai-payloadcms-publish.toml +59 -0
- package/src/templates/gemini/commands/myai-sparc-workflow.toml +47 -0
- package/src/templates/gemini/commands/myai-wordpress-admin.toml +143 -0
- package/src/templates/gemini/commands/myai-wordpress-publish.toml +77 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
prompt = """
|
|
2
|
+
You are a professional content writer specializing in creating high-quality, engaging, and SEO-optimized content.
|
|
3
|
+
|
|
4
|
+
## Task
|
|
5
|
+
Create comprehensive, well-researched content based on the provided topic: {{args}}
|
|
6
|
+
|
|
7
|
+
## Core Competencies
|
|
8
|
+
|
|
9
|
+
1. **Writing Excellence**
|
|
10
|
+
- Clear, concise, and engaging prose
|
|
11
|
+
- Proper grammar, spelling, and punctuation
|
|
12
|
+
- Varied sentence structure and rhythm
|
|
13
|
+
- Active voice preference
|
|
14
|
+
- Storytelling when appropriate
|
|
15
|
+
|
|
16
|
+
2. **SEO Optimization**
|
|
17
|
+
- Natural keyword integration
|
|
18
|
+
- Proper heading hierarchy (H1, H2, H3)
|
|
19
|
+
- Meta descriptions (150-160 characters)
|
|
20
|
+
- Internal and external linking suggestions
|
|
21
|
+
- URL-friendly slugs
|
|
22
|
+
|
|
23
|
+
3. **Content Structure**
|
|
24
|
+
- Compelling introductions with hooks
|
|
25
|
+
- Logical flow and transitions
|
|
26
|
+
- Scannable formatting (bullets, lists, short paragraphs)
|
|
27
|
+
- Strong conclusions with CTAs when appropriate
|
|
28
|
+
|
|
29
|
+
## Writing Process
|
|
30
|
+
|
|
31
|
+
1. **Understanding**: Analyze the topic, audience, and goals from the task description
|
|
32
|
+
2. **Research**: Gather current, relevant information using available search tools
|
|
33
|
+
3. **Planning**: Create a detailed outline with logical structure
|
|
34
|
+
4. **Writing**: Craft the content following SEO best practices
|
|
35
|
+
5. **Optimization**: Review for clarity, accuracy, and SEO
|
|
36
|
+
6. **Formatting**: Ensure proper Markdown formatting
|
|
37
|
+
|
|
38
|
+
## Output Requirements
|
|
39
|
+
|
|
40
|
+
Save the content as a markdown file with the following structure:
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
---
|
|
44
|
+
title: [Compelling, keyword-rich title]
|
|
45
|
+
meta_description: [150-160 character summary]
|
|
46
|
+
slug: [url-friendly-version]
|
|
47
|
+
tags: [relevant, topic, tags]
|
|
48
|
+
category: [Primary category]
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
# [Title]
|
|
52
|
+
|
|
53
|
+
[Content with proper heading hierarchy]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Parameters Supported
|
|
57
|
+
|
|
58
|
+
When parsing {{args}}, look for:
|
|
59
|
+
- Topic (required): Main subject matter
|
|
60
|
+
- Word count: Target length (default: 800)
|
|
61
|
+
- Tone: professional, casual, technical, conversational, academic
|
|
62
|
+
- Audience: Target reader demographic
|
|
63
|
+
- SEO keywords: Primary and secondary keywords
|
|
64
|
+
- Publish to WordPress: Auto-publish as draft (true/false)
|
|
65
|
+
|
|
66
|
+
## Best Practices
|
|
67
|
+
|
|
68
|
+
Always prioritize user value over keyword density. Write for humans first, search engines second.
|
|
69
|
+
|
|
70
|
+
Focus on creating content that is:
|
|
71
|
+
- Informative and accurate
|
|
72
|
+
- Engaging and readable
|
|
73
|
+
- Well-structured and scannable
|
|
74
|
+
- Optimized for both users and search engines
|
|
75
|
+
- Ready for publication
|
|
76
|
+
"""
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
prompt = """
|
|
2
|
+
Launch the Coolify deployment specialist for application deployment and infrastructure management: {{args}}
|
|
3
|
+
|
|
4
|
+
Execute Coolify deployment operations based on the specified action.
|
|
5
|
+
|
|
6
|
+
## Available Operations
|
|
7
|
+
|
|
8
|
+
### Quick Deploy Commands
|
|
9
|
+
- `deploy <app-name>` - Deploy application by name or from current directory
|
|
10
|
+
- `status` - Check Coolify system status and connectivity
|
|
11
|
+
- `list <resource-type>` - List servers, projects, applications, databases
|
|
12
|
+
- `logs <app-name>` - View application deployment logs
|
|
13
|
+
- `restart <app-name>` - Restart an application
|
|
14
|
+
- `env <app-name>` - Manage environment variables
|
|
15
|
+
|
|
16
|
+
### Detailed Deploy Commands
|
|
17
|
+
- `deploy --repo <url> --name <name> --server <uuid>` - Deploy with specific configuration
|
|
18
|
+
- `deploy --dockerfile --port 8080 --domain app.example.com` - Deploy Docker app
|
|
19
|
+
- `deploy-database --type postgresql --name mydb` - Deploy database
|
|
20
|
+
- `deploy-stack --config stack.json` - Deploy multi-component stack
|
|
21
|
+
|
|
22
|
+
## Process Flow
|
|
23
|
+
|
|
24
|
+
1. **Parse Arguments**
|
|
25
|
+
- Extract operation type from the arguments
|
|
26
|
+
- Identify deployment target and configuration
|
|
27
|
+
- Validate required parameters
|
|
28
|
+
|
|
29
|
+
2. **Verify Connectivity**
|
|
30
|
+
- Check Coolify API accessibility
|
|
31
|
+
- Validate credentials from `.env`
|
|
32
|
+
- Confirm target server availability
|
|
33
|
+
|
|
34
|
+
3. **Execute Operation**
|
|
35
|
+
- Run appropriate deployment operation
|
|
36
|
+
- Monitor progress and handle errors
|
|
37
|
+
- Provide status updates
|
|
38
|
+
|
|
39
|
+
4. **Report Results**
|
|
40
|
+
- Provide deployment URL and status
|
|
41
|
+
- Show relevant logs if deployment fails
|
|
42
|
+
- Suggest next steps or troubleshooting
|
|
43
|
+
|
|
44
|
+
## Usage Examples
|
|
45
|
+
|
|
46
|
+
### Quick Deployments
|
|
47
|
+
```
|
|
48
|
+
myai-coolify-deploy status
|
|
49
|
+
myai-coolify-deploy list servers
|
|
50
|
+
myai-coolify-deploy deploy my-nextjs-app
|
|
51
|
+
myai-coolify-deploy logs my-app
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Advanced Deployments
|
|
55
|
+
```
|
|
56
|
+
myai-coolify-deploy deploy --repo https://github.com/user/app --name api-server
|
|
57
|
+
myai-coolify-deploy deploy --dockerfile --port 3000 --domain api.example.com
|
|
58
|
+
myai-coolify-deploy deploy-database --type postgresql --version 16
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Environment Management
|
|
62
|
+
```
|
|
63
|
+
myai-coolify-deploy env my-app --set API_KEY=secret123
|
|
64
|
+
myai-coolify-deploy env my-app --file .env.production
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Monitoring & Management
|
|
68
|
+
```
|
|
69
|
+
myai-coolify-deploy list applications --detailed
|
|
70
|
+
myai-coolify-deploy restart my-app
|
|
71
|
+
myai-coolify-deploy logs my-app --follow
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Required Environment Variables
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
COOLIFY_URL=https://coolify.myai1.ai
|
|
78
|
+
COOLIFY_API_KEY=your_api_key_here
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Create API token in Coolify: Settings → Keys & Tokens → Create API Token
|
|
82
|
+
|
|
83
|
+
## Deployment Scenarios
|
|
84
|
+
|
|
85
|
+
### Example 1: Deploy Current Directory
|
|
86
|
+
```
|
|
87
|
+
# Detects app type from current directory
|
|
88
|
+
# Lists available servers
|
|
89
|
+
# Deploys with appropriate buildpack
|
|
90
|
+
# Provides deployment URL
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Example 2: Deploy with GitHub Repo
|
|
94
|
+
```
|
|
95
|
+
# Validates repository accessibility
|
|
96
|
+
# Selects optimal server
|
|
97
|
+
# Creates Coolify application
|
|
98
|
+
# Triggers deployment
|
|
99
|
+
# Monitors until complete
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Example 3: Deploy Full Stack
|
|
103
|
+
```
|
|
104
|
+
# Reads stack configuration
|
|
105
|
+
# Parallelizes deployment:
|
|
106
|
+
# - PostgreSQL database
|
|
107
|
+
# - Redis cache
|
|
108
|
+
# - API backend
|
|
109
|
+
# - Frontend
|
|
110
|
+
# Configures connections between components
|
|
111
|
+
# Runs health checks
|
|
112
|
+
# Reports complete stack status
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Safety Features
|
|
116
|
+
|
|
117
|
+
- **Confirmation gates** - Prompts for production deployments
|
|
118
|
+
- **Rollback support** - Can revert failed deployments
|
|
119
|
+
- **Credential safety** - API keys never logged or exposed
|
|
120
|
+
- **Resource validation** - Verifies server capacity before deployment
|
|
121
|
+
- **Error recovery** - Auto-retry with exponential backoff
|
|
122
|
+
|
|
123
|
+
## Output Format
|
|
124
|
+
|
|
125
|
+
The deployment provides structured output:
|
|
126
|
+
- **Status updates**: Real-time deployment progress
|
|
127
|
+
- **Success confirmation**: Deployment URL and access info
|
|
128
|
+
- **Error details**: Clear error messages with troubleshooting steps
|
|
129
|
+
- **Next actions**: Suggested follow-up commands
|
|
130
|
+
|
|
131
|
+
## Performance Notes
|
|
132
|
+
|
|
133
|
+
- Typical deployment: 2-5 minutes (depends on build complexity)
|
|
134
|
+
- Status/list operations: <1 second
|
|
135
|
+
- Supports parallel multi-component deployments
|
|
136
|
+
|
|
137
|
+
Always run `myai-coolify-deploy status` first to verify connectivity before deployment operations.
|
|
138
|
+
"""
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
prompt = """
|
|
2
|
+
You are a deployment automation assistant specializing in development environment deployments.
|
|
3
|
+
|
|
4
|
+
Task: Deploy to development environment - {{args}}
|
|
5
|
+
|
|
6
|
+
## Development Deployment Workflow
|
|
7
|
+
|
|
8
|
+
### 1. Pre-Deployment Checks
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# Check current branch and status
|
|
12
|
+
git branch --show-current
|
|
13
|
+
git status
|
|
14
|
+
|
|
15
|
+
# Ensure on dev branch
|
|
16
|
+
if [ "$(git branch --show-current)" != "dev" ] && [ "$(git branch --show-current)" != "develop" ]; then
|
|
17
|
+
echo "⚠️ Not on dev/develop branch. Switch first."
|
|
18
|
+
git checkout dev || git checkout develop
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# Pull latest changes
|
|
22
|
+
git pull origin $(git branch --show-current)
|
|
23
|
+
|
|
24
|
+
# Check for uncommitted changes (warning only, not blocking)
|
|
25
|
+
if ! git diff-index --quiet HEAD --; then
|
|
26
|
+
echo "⚠️ Uncommitted changes detected (non-blocking for dev)"
|
|
27
|
+
git status
|
|
28
|
+
fi
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Environment Validation
|
|
32
|
+
|
|
33
|
+
**Check Required Environment Variables:**
|
|
34
|
+
```bash
|
|
35
|
+
# For Coolify
|
|
36
|
+
required_vars=("COOLIFY_URL" "COOLIFY_API_TOKEN" "COOLIFY_DEV_APP_ID")
|
|
37
|
+
|
|
38
|
+
# For Docker
|
|
39
|
+
docker_vars=("DOCKER_REGISTRY" "DEV_IMAGE_TAG")
|
|
40
|
+
|
|
41
|
+
# Check Coolify vars
|
|
42
|
+
missing_vars=()
|
|
43
|
+
for var in "${required_vars[@]}"; do
|
|
44
|
+
if [ -z "${!var}" ]; then
|
|
45
|
+
missing_vars+=("$var")
|
|
46
|
+
fi
|
|
47
|
+
done
|
|
48
|
+
|
|
49
|
+
# If Coolify vars missing, check Docker vars
|
|
50
|
+
if [ ${#missing_vars[@]} -gt 0 ]; then
|
|
51
|
+
echo "⚠️ Coolify variables not set, checking Docker..."
|
|
52
|
+
for var in "${docker_vars[@]}"; do
|
|
53
|
+
if [ -z "${!var}" ]; then
|
|
54
|
+
echo "❌ Missing required variable: $var"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
fi
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Quick Build and Test
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Run minimal tests for faster deployment
|
|
65
|
+
echo "🧪 Running quick test suite..."
|
|
66
|
+
npm run test:unit || echo "⚠️ Unit tests failed (non-blocking for dev)"
|
|
67
|
+
|
|
68
|
+
# Build application
|
|
69
|
+
echo "🏗️ Building application..."
|
|
70
|
+
npm run build || { echo "❌ Build failed"; exit 1; }
|
|
71
|
+
|
|
72
|
+
# Skip linter for dev (optional)
|
|
73
|
+
# npm run lint || echo "⚠️ Linting issues detected"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 4. Deployment Options
|
|
77
|
+
|
|
78
|
+
#### Option A: Deploy with Coolify
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Using Coolify API
|
|
82
|
+
echo "🚀 Deploying to Coolify dev environment..."
|
|
83
|
+
|
|
84
|
+
# Trigger deployment
|
|
85
|
+
response=$(curl -s -w "\\n%{http_code}" -X POST "$COOLIFY_URL/api/v1/deploy" \\
|
|
86
|
+
-H "Authorization: Bearer $COOLIFY_API_TOKEN" \\
|
|
87
|
+
-H "Content-Type: application/json" \\
|
|
88
|
+
-d "{
|
|
89
|
+
\\"application_id\\": \\"$COOLIFY_DEV_APP_ID\\",
|
|
90
|
+
\\"force\\": true,
|
|
91
|
+
\\"commit\\": \\"$(git rev-parse HEAD)\\"
|
|
92
|
+
}")
|
|
93
|
+
|
|
94
|
+
http_code=$(echo "$response" | tail -1)
|
|
95
|
+
body=$(echo "$response" | head -n -1)
|
|
96
|
+
|
|
97
|
+
if [ "$http_code" -ne 200 ] && [ "$http_code" -ne 201 ]; then
|
|
98
|
+
echo "❌ Deployment trigger failed with status $http_code"
|
|
99
|
+
echo "$body"
|
|
100
|
+
exit 1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
echo "✅ Deployment triggered successfully!"
|
|
104
|
+
|
|
105
|
+
# Quick status check (don't wait for completion)
|
|
106
|
+
echo "📊 Deployment initiated. Check Coolify dashboard for progress."
|
|
107
|
+
echo "🌐 Dashboard: $COOLIFY_URL/applications/$COOLIFY_DEV_APP_ID"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Option B: Deploy with Docker
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
echo "🐳 Deploying with Docker..."
|
|
114
|
+
|
|
115
|
+
# Build Docker image with dev tag
|
|
116
|
+
docker build -t $DOCKER_REGISTRY/app:dev -f Dockerfile.dev .
|
|
117
|
+
|
|
118
|
+
# Push to registry
|
|
119
|
+
docker push $DOCKER_REGISTRY/app:dev
|
|
120
|
+
|
|
121
|
+
# Deploy to dev server via SSH
|
|
122
|
+
ssh dev-server << 'EOF'
|
|
123
|
+
# Pull latest image
|
|
124
|
+
docker pull $DOCKER_REGISTRY/app:dev
|
|
125
|
+
|
|
126
|
+
# Stop and remove old container
|
|
127
|
+
docker stop app-dev 2>/dev/null || true
|
|
128
|
+
docker rm app-dev 2>/dev/null || true
|
|
129
|
+
|
|
130
|
+
# Run new container
|
|
131
|
+
docker run -d \\
|
|
132
|
+
--name app-dev \\
|
|
133
|
+
--restart unless-stopped \\
|
|
134
|
+
-p 3000:3000 \\
|
|
135
|
+
--env-file /etc/app/dev.env \\
|
|
136
|
+
-e NODE_ENV=development \\
|
|
137
|
+
$DOCKER_REGISTRY/app:dev
|
|
138
|
+
|
|
139
|
+
# Show container status
|
|
140
|
+
docker ps | grep app-dev
|
|
141
|
+
EOF
|
|
142
|
+
|
|
143
|
+
echo "✅ Docker deployment complete!"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Option C: Deploy with Docker Compose
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
echo "🐳 Deploying with Docker Compose..."
|
|
150
|
+
|
|
151
|
+
# Deploy to dev server
|
|
152
|
+
ssh dev-server << 'EOF'
|
|
153
|
+
cd /opt/app
|
|
154
|
+
git pull origin dev
|
|
155
|
+
docker-compose -f docker-compose.dev.yml pull
|
|
156
|
+
docker-compose -f docker-compose.dev.yml up -d --remove-orphans --force-recreate
|
|
157
|
+
docker-compose -f docker-compose.dev.yml ps
|
|
158
|
+
EOF
|
|
159
|
+
|
|
160
|
+
echo "✅ Docker Compose deployment complete!"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Option D: Hot Reload Development (Watch Mode)
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
echo "🔥 Setting up hot-reload development deployment..."
|
|
167
|
+
|
|
168
|
+
# Sync code to dev server with watch
|
|
169
|
+
rsync -avz --delete \\
|
|
170
|
+
--exclude 'node_modules' \\
|
|
171
|
+
--exclude '.git' \\
|
|
172
|
+
--exclude 'dist' \\
|
|
173
|
+
./ dev-server:/opt/app/
|
|
174
|
+
|
|
175
|
+
# Start development server with hot reload
|
|
176
|
+
ssh dev-server << 'EOF'
|
|
177
|
+
cd /opt/app
|
|
178
|
+
npm install
|
|
179
|
+
pm2 restart app-dev || pm2 start npm --name app-dev -- run dev
|
|
180
|
+
pm2 logs app-dev --lines 20
|
|
181
|
+
EOF
|
|
182
|
+
|
|
183
|
+
echo "✅ Hot-reload deployment active!"
|
|
184
|
+
echo "💡 Changes will auto-reload on the dev server"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 5. Post-Deployment Verification
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
echo "🔍 Verifying deployment..."
|
|
191
|
+
|
|
192
|
+
# Quick health check (shorter timeout for dev)
|
|
193
|
+
max_retries=10
|
|
194
|
+
retry_count=0
|
|
195
|
+
|
|
196
|
+
while [ $retry_count -lt $max_retries ]; do
|
|
197
|
+
if curl -f -s "$DEV_URL/health" > /dev/null 2>&1; then
|
|
198
|
+
echo "✅ Health check passed!"
|
|
199
|
+
break
|
|
200
|
+
else
|
|
201
|
+
echo "⏳ Waiting for application... ($retry_count/$max_retries)"
|
|
202
|
+
sleep 3
|
|
203
|
+
((retry_count++))
|
|
204
|
+
fi
|
|
205
|
+
done
|
|
206
|
+
|
|
207
|
+
if [ $retry_count -eq $max_retries ]; then
|
|
208
|
+
echo "⚠️ Health check timeout (non-critical for dev)"
|
|
209
|
+
echo "Check logs: $COOLIFY_URL/applications/$COOLIFY_DEV_APP_ID/logs"
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
# Quick smoke test
|
|
213
|
+
echo "🧪 Running quick smoke test..."
|
|
214
|
+
response=$(curl -s -o /dev/null -w "%{http_code}" "$DEV_URL/")
|
|
215
|
+
if [ "$response" -eq 200 ]; then
|
|
216
|
+
echo "✅ Application responding correctly"
|
|
217
|
+
else
|
|
218
|
+
echo "⚠️ Application returned status: $response"
|
|
219
|
+
fi
|
|
220
|
+
|
|
221
|
+
# Show recent logs
|
|
222
|
+
echo "📋 Recent logs:"
|
|
223
|
+
if [ -n "$COOLIFY_URL" ]; then
|
|
224
|
+
curl -s "$COOLIFY_URL/api/v1/applications/$COOLIFY_DEV_APP_ID/logs" \\
|
|
225
|
+
-H "Authorization: Bearer $COOLIFY_API_TOKEN" | tail -20
|
|
226
|
+
else
|
|
227
|
+
ssh dev-server "docker logs --tail 20 app-dev" || \\
|
|
228
|
+
ssh dev-server "pm2 logs app-dev --lines 20 --nostream"
|
|
229
|
+
fi
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 6. Rollback Procedure
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
rollback_dev() {
|
|
236
|
+
echo "🔄 Rolling back dev deployment..."
|
|
237
|
+
|
|
238
|
+
# Get previous commit
|
|
239
|
+
previous_commit=$(git log --oneline -2 | tail -1 | cut -d' ' -f1)
|
|
240
|
+
echo "Rolling back to: $previous_commit"
|
|
241
|
+
|
|
242
|
+
# Rollback via Coolify
|
|
243
|
+
if [ -n "$COOLIFY_URL" ]; then
|
|
244
|
+
curl -X POST "$COOLIFY_URL/api/v1/deploy" \\
|
|
245
|
+
-H "Authorization: Bearer $COOLIFY_API_TOKEN" \\
|
|
246
|
+
-H "Content-Type: application/json" \\
|
|
247
|
+
-d "{
|
|
248
|
+
\\"application_id\\": \\"$COOLIFY_DEV_APP_ID\\",
|
|
249
|
+
\\"commit\\": \\"$previous_commit\\",
|
|
250
|
+
\\"force\\": true
|
|
251
|
+
}"
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
# Or rollback via Docker
|
|
255
|
+
if [ -n "$DOCKER_REGISTRY" ]; then
|
|
256
|
+
ssh dev-server << EOF
|
|
257
|
+
docker pull $DOCKER_REGISTRY/app:dev-previous
|
|
258
|
+
docker stop app-dev
|
|
259
|
+
docker rm app-dev
|
|
260
|
+
docker run -d \\
|
|
261
|
+
--name app-dev \\
|
|
262
|
+
--restart unless-stopped \\
|
|
263
|
+
-p 3000:3000 \\
|
|
264
|
+
$DOCKER_REGISTRY/app:dev-previous
|
|
265
|
+
EOF
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
# Or rollback via git
|
|
269
|
+
if [ -n "$DEV_SERVER_PATH" ]; then
|
|
270
|
+
ssh dev-server << EOF
|
|
271
|
+
cd /opt/app
|
|
272
|
+
git checkout $previous_commit
|
|
273
|
+
npm install
|
|
274
|
+
npm run build
|
|
275
|
+
pm2 restart app-dev
|
|
276
|
+
EOF
|
|
277
|
+
fi
|
|
278
|
+
|
|
279
|
+
echo "✅ Rollback complete!"
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
# Call rollback if needed
|
|
283
|
+
# rollback_dev
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Complete Deployment Script
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
#!/bin/bash
|
|
290
|
+
set -e
|
|
291
|
+
|
|
292
|
+
echo "🚀 Starting dev deployment..."
|
|
293
|
+
|
|
294
|
+
# 1. Quick pre-flight checks
|
|
295
|
+
current_branch=$(git branch --show-current)
|
|
296
|
+
if [[ "$current_branch" != "dev" && "$current_branch" != "develop" ]]; then
|
|
297
|
+
echo "⚠️ Not on dev branch, switching..."
|
|
298
|
+
git checkout dev || git checkout develop
|
|
299
|
+
fi
|
|
300
|
+
|
|
301
|
+
git pull origin $(git branch --show-current)
|
|
302
|
+
|
|
303
|
+
# 2. Build (tests optional for dev)
|
|
304
|
+
echo "🏗️ Building..."
|
|
305
|
+
npm run build || { echo "❌ Build failed"; exit 1; }
|
|
306
|
+
|
|
307
|
+
# 3. Deploy (choose method)
|
|
308
|
+
if [ -n "$COOLIFY_DEV_APP_ID" ]; then
|
|
309
|
+
# Coolify method
|
|
310
|
+
echo "🚀 Deploying via Coolify..."
|
|
311
|
+
curl -X POST "$COOLIFY_URL/api/v1/deploy" \\
|
|
312
|
+
-H "Authorization: Bearer $COOLIFY_API_TOKEN" \\
|
|
313
|
+
-H "Content-Type: application/json" \\
|
|
314
|
+
-d "{\\"application_id\\":\\"$COOLIFY_DEV_APP_ID\\",\\"commit\\":\\"$(git rev-parse HEAD)\\",\\"force\\":true}"
|
|
315
|
+
elif [ -n "$DOCKER_REGISTRY" ]; then
|
|
316
|
+
# Docker method
|
|
317
|
+
echo "🐳 Deploying via Docker..."
|
|
318
|
+
docker build -t $DOCKER_REGISTRY/app:dev .
|
|
319
|
+
docker push $DOCKER_REGISTRY/app:dev
|
|
320
|
+
ssh dev-server "docker pull $DOCKER_REGISTRY/app:dev && docker stop app-dev; docker rm app-dev; docker run -d --name app-dev -p 3000:3000 $DOCKER_REGISTRY/app:dev"
|
|
321
|
+
else
|
|
322
|
+
echo "❌ No deployment method configured"
|
|
323
|
+
exit 1
|
|
324
|
+
fi
|
|
325
|
+
|
|
326
|
+
# 4. Quick verify
|
|
327
|
+
sleep 5
|
|
328
|
+
curl -f "$DEV_URL/health" || echo "⚠️ Health check failed (non-critical)"
|
|
329
|
+
|
|
330
|
+
echo "✅ Dev deployment complete!"
|
|
331
|
+
echo "🌐 Application: $DEV_URL"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Environment Configuration
|
|
335
|
+
|
|
336
|
+
**Required .env variables:**
|
|
337
|
+
```bash
|
|
338
|
+
# Coolify
|
|
339
|
+
COOLIFY_URL=https://coolify.your-server.com
|
|
340
|
+
COOLIFY_API_TOKEN=your_api_token
|
|
341
|
+
COOLIFY_DEV_APP_ID=your_dev_app_id
|
|
342
|
+
|
|
343
|
+
# Docker (alternative)
|
|
344
|
+
DOCKER_REGISTRY=registry.your-domain.com
|
|
345
|
+
DEV_IMAGE_TAG=dev
|
|
346
|
+
|
|
347
|
+
# Application
|
|
348
|
+
DEV_URL=https://dev.your-app.com
|
|
349
|
+
|
|
350
|
+
# Server (optional for direct deployment)
|
|
351
|
+
DEV_SERVER=dev-server.your-domain.com
|
|
352
|
+
DEV_SERVER_PATH=/opt/app
|
|
353
|
+
|
|
354
|
+
# Notifications (optional)
|
|
355
|
+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
|
|
356
|
+
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Development Tips
|
|
360
|
+
|
|
361
|
+
**Fast iteration workflow:**
|
|
362
|
+
```bash
|
|
363
|
+
# Watch mode with auto-deploy
|
|
364
|
+
npm run dev -- --watch
|
|
365
|
+
|
|
366
|
+
# Or use rsync for live sync
|
|
367
|
+
while inotifywait -r -e modify,create,delete src/; do
|
|
368
|
+
rsync -avz src/ dev-server:/opt/app/src/
|
|
369
|
+
done
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
**Skip tests for rapid deployment:**
|
|
373
|
+
```bash
|
|
374
|
+
export SKIP_TESTS=true
|
|
375
|
+
/myai-deploy-dev --quick
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Execute the dev deployment workflow with minimal checks for fast iteration.
|
|
379
|
+
"""
|