#!/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 ""