-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate-plugin.sh
More file actions
executable file
·172 lines (141 loc) · 4.63 KB
/
migrate-plugin.sh
File metadata and controls
executable file
·172 lines (141 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
# Plugin Migration Script
# Usage: ./migrate-plugin.sh <service-name> <display-name> <category> <description>
set -e
SERVICE_NAME="$1"
DISPLAY_NAME="$2"
CATEGORY="$3"
DESCRIPTION="$4"
# Extract repo name from service name (remove nexus- prefix and format)
REPO_SUFFIX=$(echo "$SERVICE_NAME" | sed 's/nexus-//' | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)$i=toupper(substr($i,1,1)) substr($i,2)}1' | sed 's/ //g')
REPO_NAME="Adverant-Nexus-Plugin-${REPO_SUFFIX}"
if [ -z "$SERVICE_NAME" ] || [ -z "$DISPLAY_NAME" ] || [ -z "$CATEGORY" ]; then
echo "Usage: ./migrate-plugin.sh <service-name> <display-name> <category> [description]"
echo "Example: ./migrate-plugin.sh nexus-crm 'Nexus CRM' 'business' 'AI-powered CRM'"
exit 1
fi
SERVICE_DIR="/Users/don/Adverant/Adverant-Nexus/services/${SERVICE_NAME}"
TEMPLATE_DIR="/Users/don/Adverant/plugin-template"
TARGET_DIR="/Users/don/Adverant/plugins/${REPO_NAME}"
echo "=========================================="
echo "Migrating: $DISPLAY_NAME"
echo "Service: $SERVICE_NAME"
echo "Repository: $REPO_NAME"
echo "Category: $CATEGORY"
echo "=========================================="
# Check if service exists
if [ ! -d "$SERVICE_DIR" ]; then
echo "ERROR: Service directory not found: $SERVICE_DIR"
exit 1
fi
# Clone the repo if it doesn't exist
if [ ! -d "$TARGET_DIR" ]; then
echo "Cloning repository..."
mkdir -p /Users/don/Adverant/plugins
cd /Users/don/Adverant/plugins
gh repo clone "adverant/${REPO_NAME}" 2>/dev/null || {
echo "Repository not found or clone failed"
exit 1
}
fi
cd "$TARGET_DIR"
# Create directory structure
echo "Creating directory structure..."
mkdir -p .github/{ISSUE_TEMPLATE,workflows}
mkdir -p docs/{getting-started,api-reference,architecture/diagrams,use-cases/{enterprise,startup,examples},changelog}
mkdir -p assets/{screenshots,diagrams}
mkdir -p k8s
mkdir -p src/{types,services,routes,middleware,utils}
mkdir -p database/migrations 2>/dev/null || true
# Copy source code if exists
echo "Copying source code..."
if [ -d "$SERVICE_DIR/src" ]; then
cp -r "$SERVICE_DIR/src/"* src/ 2>/dev/null || true
fi
if [ -d "$SERVICE_DIR/database" ]; then
cp -r "$SERVICE_DIR/database/"* database/ 2>/dev/null || true
fi
if [ -d "$SERVICE_DIR/k8s" ]; then
cp -r "$SERVICE_DIR/k8s/"* k8s/ 2>/dev/null || true
fi
# Copy config files
[ -f "$SERVICE_DIR/package.json" ] && cp "$SERVICE_DIR/package.json" .
[ -f "$SERVICE_DIR/tsconfig.json" ] && cp "$SERVICE_DIR/tsconfig.json" .
[ -f "$SERVICE_DIR/Dockerfile" ] && cp "$SERVICE_DIR/Dockerfile" .
[ -f "$SERVICE_DIR/nexus.manifest.json" ] && cp "$SERVICE_DIR/nexus.manifest.json" .
# Copy template files
echo "Copying template files..."
cp "$TEMPLATE_DIR/LICENSE" .
cp "$TEMPLATE_DIR/CODE_OF_CONDUCT.md" .
cp "$TEMPLATE_DIR/SECURITY.md" .
cp -r "$TEMPLATE_DIR/.github/"* .github/
cp -r "$TEMPLATE_DIR/docs/getting-started/"* docs/getting-started/ 2>/dev/null || true
cp -r "$TEMPLATE_DIR/docs/api-reference/"* docs/api-reference/ 2>/dev/null || true
# Create .env.example
PLUGIN_NAME_UPPER=$(echo "$SERVICE_NAME" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
cat > .env.example << EOF
# ${DISPLAY_NAME} Configuration
# Required
NEXUS_API_URL=https://api.adverant.ai
PORT=9200
# Database
DATABASE_URL=postgresql://nexus:nexus@localhost:5432/nexus
# Optional
LOG_LEVEL=info
${PLUGIN_NAME_UPPER}_TIMEOUT_MS=30000
${PLUGIN_NAME_UPPER}_MAX_CONCURRENT=5
EOF
# Create .gitignore
cat > .gitignore << 'EOF'
# Dependencies
node_modules/
.pnpm-store/
# Build
dist/
build/
*.tsbuildinfo
# Environment
.env
.env.local
.env.*.local
# IDE
.idea/
.vscode/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Logs
*.log
logs/
# Test
coverage/
.nyc_output/
# Temp
tmp/
temp/
EOF
# Replace placeholders in template files
echo "Customizing files..."
find . -type f \( -name "*.md" -o -name "*.yml" \) ! -path "./.git/*" -exec sed -i '' \
-e "s/{{PLUGIN_NAME}}/${SERVICE_NAME}/g" \
-e "s/{{PLUGIN_DISPLAY_NAME}}/${DISPLAY_NAME}/g" \
-e "s/{{PLUGIN_NAME_UPPER}}/${PLUGIN_NAME_UPPER}/g" \
-e "s/{{REPO_NAME}}/${REPO_NAME}/g" \
-e "s/{{PLUGIN_CATEGORY}}/${CATEGORY}/g" \
{} \; 2>/dev/null || true
# Update package.json repository URL if exists
if [ -f "package.json" ]; then
sed -i '' "s|\"url\": \".*github.com/adverant/.*\"|\"url\": \"https://github.com/adverant/${REPO_NAME}\"|g" package.json 2>/dev/null || true
fi
echo "=========================================="
echo "Migration complete for: $DISPLAY_NAME"
echo "Target: $TARGET_DIR"
echo ""
echo "Next steps:"
echo "1. Create/update README.md"
echo "2. Create nexus.manifest.json if missing"
echo "3. Add & commit files"
echo "4. Push to GitHub"
echo "=========================================="