162 lines
3.9 KiB
Bash
162 lines
3.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Make script executable and set proper permissions
|
|
chmod +x /workspaces/*/devcontainer/post-create.sh
|
|
|
|
echo "🚀 Setting up Seclore n8n Development Environment..."
|
|
|
|
# Update npm to latest version
|
|
echo "📦 Updating npm..."
|
|
npm install -g npm@latest
|
|
|
|
# Install n8n globally
|
|
echo "🔧 Installing n8n..."
|
|
npm install -g n8n
|
|
|
|
# Install common development tools
|
|
echo "🛠️ Installing development tools..."
|
|
npm install -g typescript ts-node nodemon
|
|
|
|
# Install project dependencies
|
|
echo "📋 Installing project dependencies..."
|
|
npm install
|
|
|
|
# Create .n8n directory if it doesn't exist
|
|
mkdir -p ~/.n8n
|
|
|
|
# Set up n8n environment variables
|
|
echo "⚙️ Setting up n8n configuration..."
|
|
cat > ~/.n8n/.env << EOF
|
|
# n8n Configuration
|
|
N8N_BASIC_AUTH_ACTIVE=false
|
|
N8N_HOST=0.0.0.0
|
|
N8N_PORT=5678
|
|
N8N_PROTOCOL=http
|
|
|
|
# Development settings
|
|
NODE_ENV=development
|
|
N8N_LOG_LEVEL=debug
|
|
|
|
# Custom nodes path
|
|
N8N_CUSTOM_EXTENSIONS=/workspaces/Seclore\ n8n
|
|
EOF
|
|
|
|
# Create a startup script for n8n
|
|
echo "📝 Creating n8n startup script..."
|
|
cat > ~/start-n8n.sh << 'EOF'
|
|
#!/bin/bash
|
|
echo "🎯 Starting n8n with custom Seclore nodes..."
|
|
echo "📍 Custom nodes path: /workspaces/Seclore n8n"
|
|
echo "🌐 n8n will be available at: http://localhost:5678"
|
|
echo ""
|
|
|
|
# Build the custom nodes first
|
|
cd "/workspaces/Seclore n8n"
|
|
npm run build
|
|
|
|
# Start n8n with custom nodes
|
|
N8N_CUSTOM_EXTENSIONS="/workspaces/Seclore n8n" n8n start
|
|
EOF
|
|
|
|
chmod +x ~/start-n8n.sh
|
|
|
|
# Create development scripts
|
|
echo "📋 Creating development scripts..."
|
|
cat > ~/dev-scripts.sh << 'EOF'
|
|
#!/bin/bash
|
|
|
|
# Function to build and test the custom node
|
|
build_and_test() {
|
|
echo "🔨 Building Seclore n8n nodes..."
|
|
cd "/workspaces/Seclore n8n"
|
|
npm run build
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Build successful!"
|
|
echo "🧪 Running linter..."
|
|
npm run lint
|
|
else
|
|
echo "❌ Build failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Function to start n8n in development mode
|
|
start_dev() {
|
|
echo "🚀 Starting n8n in development mode..."
|
|
build_and_test && ~/start-n8n.sh
|
|
}
|
|
|
|
# Function to watch for changes and rebuild
|
|
watch_build() {
|
|
echo "👀 Watching for changes..."
|
|
cd "/workspaces/Seclore n8n"
|
|
npm run build:watch
|
|
}
|
|
|
|
# Export functions
|
|
export -f build_and_test
|
|
export -f start_dev
|
|
export -f watch_build
|
|
|
|
echo "📚 Available commands:"
|
|
echo " build_and_test - Build and lint the project"
|
|
echo " start_dev - Build and start n8n with custom nodes"
|
|
echo " watch_build - Watch for changes and rebuild automatically"
|
|
echo " ~/start-n8n.sh - Start n8n directly (after manual build)"
|
|
EOF
|
|
|
|
chmod +x ~/dev-scripts.sh
|
|
|
|
# Add to bashrc for easy access
|
|
echo "source ~/dev-scripts.sh" >> ~/.bashrc
|
|
|
|
# Create a welcome message
|
|
echo "📄 Creating welcome message..."
|
|
cat > ~/welcome.txt << 'EOF'
|
|
🎉 Seclore n8n Development Environment Ready!
|
|
|
|
📁 Project Structure:
|
|
/workspaces/Seclore n8n/
|
|
├── nodes/SecloreProtect/ # Custom n8n node
|
|
├── credentials/ # Credential types
|
|
└── Services/ # API services
|
|
|
|
🚀 Quick Start:
|
|
1. Run: start_dev # Build and start n8n
|
|
2. Open: http://localhost:5678 # Access n8n interface
|
|
3. Use: build_and_test # Build and test changes
|
|
|
|
🔧 Development Commands:
|
|
- start_dev : Build project and start n8n
|
|
- build_and_test : Build project and run linter
|
|
- watch_build : Auto-rebuild on file changes
|
|
- ~/start-n8n.sh : Start n8n (manual build required)
|
|
|
|
📦 Installed Tools:
|
|
- Node.js 20.x
|
|
- npm (latest)
|
|
- n8n (latest)
|
|
- TypeScript
|
|
- ts-node
|
|
- nodemon
|
|
|
|
🔌 VS Code Extensions:
|
|
- TypeScript & JavaScript support
|
|
- ESLint & Prettier
|
|
- Node.js IntelliSense
|
|
- Git tools
|
|
- REST client for API testing
|
|
|
|
Happy coding! 🎯
|
|
EOF
|
|
|
|
# Display welcome message
|
|
echo ""
|
|
echo "✅ Setup complete!"
|
|
echo ""
|
|
cat ~/welcome.txt
|
|
echo ""
|
|
echo "💡 Tip: Run 'cat ~/welcome.txt' anytime to see this guide again."
|
|
echo ""
|