DevOps Pipeline Generator
Run ID: 69cd15123e7fb09ff16a7c962026-04-01Infrastructure
PantheraHive BOS
BOS Dashboard

As part of the PantheraHive "DevOps Pipeline Generator" workflow, this deliverable provides comprehensive and detailed CI/CD pipeline configurations for three leading platforms: GitHub Actions, GitLab CI, and Jenkins. These configurations are designed to include essential stages such as linting, testing, building, and deployment, offering a robust foundation for your software delivery process.


DevOps Pipeline Configurations: A Comprehensive Overview

This document presents actionable CI/CD pipeline configurations tailored for common development scenarios. Each configuration is structured to be easily adaptable to your specific project needs, technology stack, and deployment targets.

Core CI/CD Principles Applied

The generated pipelines adhere to the following best practices:

General Assumptions & Placeholders


1. GitHub Actions Configuration

GitHub Actions provides a flexible and powerful way to automate workflows directly within your GitHub repository.

File Location: .github/workflows/main.yml

text • 258 chars
---

## 3. Jenkins Declarative Pipeline Configuration

Jenkins offers extensive customization and is suitable for complex enterprise environments. This example uses a Declarative Pipeline.

**File Location**: `Jenkinsfile` (at the root of your repository)

Sandboxed live preview

Step 1 of 3: Infrastructure Needs Analysis for DevOps Pipeline Generation

Introduction

Welcome to the initial phase of your DevOps Pipeline Generation journey. This crucial first step, "Analyze Infrastructure Needs," lays the foundational groundwork for designing a robust, efficient, and tailored CI/CD pipeline. The objective is to comprehensively assess your current and target technical landscape, identifying all critical components and requirements that will influence the choice of CI/CD tool (GitHub Actions, GitLab CI, or Jenkins), pipeline structure, and deployment strategy.

Without a deep understanding of your infrastructure, application architecture, and operational practices, generating an effective pipeline is challenging. This analysis will guide us in making informed decisions, ensuring the generated pipeline is not only functional but also optimized for your specific environment.

Executive Summary

This analysis identifies key areas essential for defining your CI/CD pipeline. These areas encompass Source Code Management (SCM), application technology stack, deployment targets, security, testing, and operational considerations. The goal is to gather detailed insights into your existing ecosystem to recommend the most suitable CI/CD platform and design a pipeline that integrates seamlessly.

Key Findings (General): Modern CI/CD pipelines prioritize automation, security-by-design (shift-left), containerization, and cloud-native integrations. The choice of CI/CD tool often correlates with the chosen SCM and cloud provider.

Initial Recommendation: A detailed inventory of your current infrastructure, application details, and operational preferences is critical for proceeding. The "Next Steps" section outlines the specific information required.

Detailed Infrastructure Analysis Areas

To generate a truly effective CI/CD pipeline, we need to understand the following critical infrastructure components and requirements:

1. Source Code Management (SCM) System

  • Impact: Directly dictates the primary integration point for your CI/CD tool.
  • Considerations:

* Platform: GitHub, GitLab, Bitbucket, Azure DevOps, or other.

* Repository Structure: Monorepo vs. polyrepo.

* Branching Strategy: GitFlow, GitHub Flow, GitLab Flow, Trunk-Based Development.

* Permissions & Access Control: How is access managed for repositories and users?

  • Why it matters: GitHub Actions is native to GitHub, GitLab CI is native to GitLab. Jenkins offers broad integration but requires specific plugin configuration. Your SCM choice is often the primary driver for the CI/CD platform.

2. Application Technology Stack

  • Impact: Determines build tools, testing frameworks, and artifact types.
  • Considerations:

* Programming Languages: Python, Java, Node.js, Go, .NET, Ruby, PHP, C++, etc.

* Frameworks: React, Angular, Spring Boot, Django, Flask, Express, ASP.NET Core, etc.

* Build Tools: Maven, Gradle, npm, yarn, pip, Go Modules, Docker Compose, Kubernetes manifests, Terraform, Ansible.

* Database Technologies: SQL (PostgreSQL, MySQL, SQL Server), NoSQL (MongoDB, Cassandra, DynamoDB).

  • Why it matters: Each stack requires specific build commands, dependencies, and testing environments that must be configured within the pipeline.

3. Deployment Environments & Targets

  • Impact: Defines deployment strategies, necessary credentials, and specific deployment commands.
  • Considerations:

* Cloud Provider(s): AWS, Azure, GCP, On-premise, Hybrid.

* Target Infrastructure:

* Virtual Machines (VMs): EC2, Azure VMs, GCP Compute Engine, vSphere.

* Container Orchestration: Kubernetes (EKS, AKS, GKE, OpenShift), Docker Swarm.

* Serverless: AWS Lambda, Azure Functions, GCP Cloud Functions/Run.

* Platform as a Service (PaaS): AWS Elastic Beanstalk, Azure App Service, Heroku, GCP App Engine.

* Environment Stages: Dev, Test, Staging, Production.

* Geographic Regions: Multi-region deployments.

  • Why it matters: The pipeline must include specific steps to authenticate with the target environment and execute deployment commands (e.g., kubectl apply, aws deploy, az webapp deploy).

4. Containerization Strategy

  • Impact: Influences build steps (Docker build), image registry integration, and deployment to container orchestration platforms.
  • Considerations:

* Container Runtime: Docker, containerd.

* Container Registry: Docker Hub, AWS ECR, Azure ACR, GCP GCR, GitLab Container Registry, Quay.io, Artifactory.

* Image Tagging Strategy: Semantic versioning, Git SHA, build number.

  • Why it matters: If using containers, the pipeline must include steps to build Docker images, tag them, push them to a registry, and then update the deployment manifests to pull the new image.

5. Security & Compliance Requirements

  • Impact: Determines necessary pipeline stages for vulnerability scanning, secret management, and compliance checks.
  • Considerations:

* Secrets Management: AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, HashiCorp Vault, Kubernetes Secrets, external CI/CD secrets.

* Vulnerability Scanning: SAST (Static Application Security Testing), DAST (Dynamic Application Security Testing), SCA (Software Composition Analysis), container image scanning (e.g., Trivy, Clair).

* Compliance Standards: HIPAA, GDPR, SOC2, PCI DSS.

* Access Control & Least Privilege: How are pipeline agents authenticated?

  • Why it matters: Integrating security scans early ("shift left") reduces risks. Secure handling of credentials is paramount for pipeline integrity.

6. Testing Strategy

  • Impact: Defines the types of tests to be executed within the pipeline and their execution environment.
  • Considerations:

* Test Types: Unit tests, integration tests, end-to-end (E2E) tests, performance tests, security tests, UI tests.

* Test Frameworks: Jest, JUnit, Pytest, Selenium, Cypress, Playwright, JMeter.

* Test Reporting: Junit XML, HTML reports.

  • Why it matters: Automated testing is a cornerstone of CI/CD. The pipeline must be configured to run tests, collect results, and potentially gate deployments based on test outcomes.

7. Linting & Static Analysis

  • Impact: Ensures code quality, style consistency, and early detection of potential issues.
  • Considerations:

* Tools: ESLint, Prettier, SonarQube, Black, Flake8, RuboCop, Checkstyle, GoLint.

* Configuration: Custom rule sets, integration with IDEs.

  • Why it matters: Integrating linting and static analysis as early stages in the pipeline helps maintain code quality and prevent common errors.

8. Artifact Management

  • Impact: Determines where built artifacts (e.g., JARs, WARs, compiled binaries, npm packages) are stored and retrieved.
  • Considerations:

* Artifact Repository: AWS S3, Azure Blob Storage, GCP Cloud Storage, JFrog Artifactory, Sonatype Nexus, GitLab Generic Packages.

* Versioning Strategy: How are artifacts versioned and managed?

  • Why it matters: Artifact repositories ensure that consistent, versioned builds are available for deployment and rollback, decoupling the build from the deployment process.

9. Existing CI/CD Practices & Tooling

  • Impact: Informs migration strategies, potential integrations, and team familiarity.
  • Considerations:

* Current CI/CD Tool: If any, what is it? What are its strengths/weaknesses?

* Automation Level: How much is currently automated?

* Team Expertise: Familiarity with specific CI/CD tools, scripting languages, and cloud platforms.

  • Why it matters: Understanding existing practices helps in designing a migration path (if applicable) and leveraging existing knowledge.

Key Data Insights & Trends

  1. Shift-Left Security: Integrating security scans (SAST, DAST, SCA, secret scanning) early in the pipeline is a dominant trend. This reduces the cost and effort of fixing vulnerabilities later in the development cycle.
  2. Containerization & Kubernetes Adoption: The rise of Docker and Kubernetes has made container image building, scanning, and deployment to orchestration platforms standard CI/CD stages. This provides portability and scalability.
  3. Cloud-Native CI/CD: There's a strong trend towards using CI/CD solutions that are tightly integrated with cloud providers (e.g., GitHub Actions with Azure/AWS/GCP integrations, GitLab CI with Auto DevOps). This simplifies setup and leverages cloud services.
  4. Infrastructure as Code (IaC): Managing infrastructure through code (Terraform, CloudFormation, ARM Templates, Pulumi) is now a best practice. CI/CD pipelines are increasingly used to validate and apply IaC changes.
  5. GitOps Principles: Using Git as the single source of truth for declarative infrastructure and applications is gaining traction. This often involves automated reconciliation loops for deployments.
  6. Observability & Feedback Loops: Pipelines are evolving to include better monitoring of their own health and success metrics, with integrations for Slack/Teams notifications, status dashboards, and comprehensive logging.

Initial Recommendations

Based on general best practices and the common needs of modern software development, we recommend the following foundational approaches:

  1. Prioritize Automation: Aim for maximum automation across all stages, from code commit to production deployment, to minimize manual errors and accelerate delivery.
  2. Embrace "Shift-Left" Security: Integrate security testing (SAST, SCA, container scanning) as early stages in your pipeline to proactively identify and mitigate risks.
  3. Adopt Infrastructure as Code (IaC): If not already in use, consider adopting IaC for managing your deployment environments. This ensures consistency, repeatability, and version control for your infrastructure.
  4. Standardize Containerization: Leverage Docker for application packaging and a robust container registry for artifact management. This simplifies deployments to Kubernetes or other container platforms.
  5. Comprehensive Testing: Implement a layered testing strategy (unit, integration, E2E) within the pipeline, with clear pass/fail criteria to ensure code quality and prevent regressions.
  6. Secure Secret Management: Utilize dedicated secret management solutions (e.g., cloud-native secret stores, HashiCorp Vault) rather than embedding credentials directly in pipeline configurations.

Next Steps: Action Required from Customer

To proceed with generating a highly effective and tailored CI/CD pipeline, we require specific details regarding your infrastructure and application. Please provide the following information:

  1. Primary Source Code Management (SCM) System:

* Which platform do you use (e.g., GitHub.com, GitHub Enterprise, GitLab.com, self-hosted GitLab, Bitbucket Cloud, Azure DevOps Repos)?

  1. Application Details (for the pipeline to be generated):

* Primary Programming Language(s) & Framework(s): (e.g., Python/Django, Node.js/React, Java/Spring Boot, Go, .NET Core)

* Build Tool(s): (e.g., npm, yarn, Maven, Gradle, pip, make, Docker build)

* Is the application containerized (Docker)? (Yes/No)

* If Yes, which Container Registry do you use (e.g., Docker Hub, AWS ECR, Azure ACR, GitLab Registry)?

  1. Deployment Target(s):

* Cloud Provider(s): (e.g., AWS, Azure, GCP, On-premise, Hybrid)

* Specific Deployment Environment(s): (e.g., AWS EKS, AWS EC2, Azure App Service, Azure AKS, GCP Cloud Run, GCP GKE, On-premise VMs, Serverless Functions)

* How do you typically deploy? (e.g., kubectl apply, aws cli, az cli, custom scripts, Ansible, Terraform)

  1. Preferred CI/CD Tool (if any):

* Do you have a preference among GitHub Actions, GitLab CI, or Jenkins? If so, why?

  1. Key Security & Compliance Needs:

* Are there specific security scans you require (e.g., SAST, SCA, DAST, Secret Scanning)?

* Are there any specific compliance standards (e.g., HIPAA, GDPR) that need to be addressed?

  1. Testing Strategy:

* Which types of tests are critical for your application (e.g., Unit, Integration, E2E)?

* Do you use specific testing frameworks (e.g., Jest, JUnit, Pytest, Selenium, Cypress)?

  1. Secrets Management:

* How do you currently manage sensitive

groovy

// Jenkinsfile for a Declarative Pipeline

pipeline {

agent {

docker {

image 'node:20-alpine' // Use a Node.js image for linting/testing

args '-u 1000:1000' // Ensure permissions are correct if running as non-root

}

}

environment {

// Define environment variables accessible across stages

DOCKER_IMAGE_NAME = "your-app-name"

DOCKER_REGISTRY = "your-docker-registry.com/your-org" // e.g., myregistry.com/myorg or public Docker Hub

AWS_REGION = "us-east-1"

}

stages {

stage('Lint Code') {

steps {

script {

echo "Running linting checks..."

sh 'npm ci' // Or yarn install

sh 'npm run lint' // Or yarn lint

echo "Linting complete."

}

}

}

stage('Run Tests') {

steps {

script {

echo "Running unit and integration tests..."

sh 'npm test' // Or yarn test

// Optionally publish test results

// junit '**/test-results.xml'

echo "Tests complete."

}

}

}

stage('Build Docker Image') {

agent {

docker {

image 'docker:latest' // Use a Docker image with Docker CLI

args '-u 1000:1000'

}

}

steps {

script {

echo "Building Docker image..."

// Use withCredentials to inject Docker Hub / ECR credentials securely

withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {

sh "docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY"

sh "docker

gemini Output

DevOps Pipeline Generator: Comprehensive CI/CD Configurations

We are pleased to deliver comprehensive CI/CD pipeline configurations tailored for your project. These configurations provide a robust foundation for automating your software delivery process, integrating best practices for quality assurance, efficient building, and staged deployments.

This deliverable includes detailed, professional-grade pipeline definitions for the three most popular CI/CD platforms: GitHub Actions, GitLab CI, and Jenkins. Each configuration incorporates essential stages: Linting, Testing, Building (Dockerized), and Deployment to multiple environments.


1. Key Features of the Generated Pipelines

The provided pipeline configurations are designed with the following core principles and features:

  • Automated Quality Gates: Integration of linting and unit/integration testing ensures code quality and functional correctness early in the development cycle.
  • Containerized Builds: Leverage Docker for consistent and reproducible build environments, packaging your application into an immutable image.
  • Staged Deployments: Support for deploying to multiple environments (e.g., Development, Staging, Production) with clear separation and optional manual approvals for critical stages.
  • Environment Agnostic: While examples use generic deployment commands, the structure allows easy integration with major cloud providers (AWS, Azure, GCP) or on-premise infrastructure.
  • Security Best Practices: Designed to integrate with platform-specific secret management for sensitive credentials.
  • Modularity and Extensibility: Structured to be easily adaptable to various technology stacks and extensible with additional steps or integrations.

2. Detailed Pipeline Configurations

Below are the detailed CI/CD pipeline configurations for each platform. Each example assumes a generic web application that is built into a Docker image and deployed.

2.1. GitHub Actions Configuration

Filename: .github/workflows/main.yml

This workflow triggers on pushes to the main branch and pull requests, executing linting, testing, and building. Deployment jobs are conditional.


name: CI/CD Pipeline

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

env:
  PROJECT_NAME: my-web-app
  DOCKER_REGISTRY: ghcr.io/${{ github.repository_owner }}
  # Example: For a Node.js app
  NODE_VERSION: '18' 

jobs:
  # Job for linting, testing, and building the Docker image
  lint_test_build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # --- Linting Stage (Example: Node.js/ESLint) ---
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'
      - name: Install dependencies
        run: npm ci
      - name: Run Lint
        run: npm run lint

      # --- Testing Stage (Example: Node.js/Jest) ---
      - name: Run Tests
        run: npm test

      # --- Build Stage (Docker Image) ---
      - name: Log in to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ${{ env.DOCKER_REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:${{ github.sha }},${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max

  # Job for deploying to Development environment
  deploy_dev:
    needs: lint_test_build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: development # GitHub Environment for secrets/protection rules
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Deploy to Development
        run: |
          echo "Deploying ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:${{ github.sha }} to Development..."
          # Replace with your actual deployment commands (e.g., kubectl, AWS CLI, Azure CLI)
          # Example: Update a Kubernetes deployment
          # kubectl --kubeconfig <(echo "${{ secrets.KUBECONFIG_DEV }}" | base64 -d) \
          #   set image deployment/${{ env.PROJECT_NAME }}-dev \
          #   ${{ env.PROJECT_NAME }}=${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:${{ github.sha }} \
          #   -n dev-namespace
          echo "Deployment to Development complete."

  # Job for deploying to Production environment (requires manual approval)
  deploy_prod:
    needs: deploy_dev
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production # GitHub Environment for secrets/protection rules
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Deploy to Production
        run: |
          echo "Deploying ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:${{ github.sha }} to Production..."
          # Replace with your actual deployment commands
          # Example: Update a Kubernetes deployment
          # kubectl --kubeconfig <(echo "${{ secrets.KUBECONFIG_PROD }}" | base64 -d) \
          #   set image deployment/${{ env.PROJECT_NAME }}-prod \
          #   ${{ env.PROJECT_NAME }}=${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:${{ github.sha }} \
          #   -n prod-namespace
          echo "Deployment to Production complete."

Customization Notes for GitHub Actions:

  • env: Update PROJECT_NAME, DOCKER_REGISTRY, and NODE_VERSION (or other language-specific versions).
  • Linting/Testing: Modify npm run lint and npm test for your specific language/framework (e.g., pytest, mvn test, go test).
  • Deployment: Replace placeholder echo commands with actual deployment scripts or CLI commands (e.g., aws ecs update-service, az webapp deploy, kubectl apply).
  • Secrets: Utilize GitHub Secrets (e.g., secrets.KUBECONFIG_DEV, secrets.AWS_ACCESS_KEY_ID, secrets.AWS_SECRET_ACCESS_KEY) for sensitive information. Define these in your repository settings under "Secrets and variables" -> "Actions".
  • Environments: Leverage GitHub Environments for fine-grained access control, required reviewers, and environment-specific secrets.

2.2. GitLab CI Configuration

Filename: .gitlab-ci.yml

This pipeline defines stages for linting, testing, building, and deploying. It uses GitLab's built-in Docker registry and environment features.


stages:
  - lint
  - test
  - build
  - deploy-dev
  - deploy-prod

variables:
  # Customize these variables for your project
  PROJECT_NAME: my-web-app
  DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE/$PROJECT_NAME
  # Example: For a Node.js app
  NODE_VERSION: '18'

default:
  # Use a base image for common operations or specific runners
  image: alpine/git:latest # Or a more feature-rich image like 'node:${NODE_VERSION}-alpine' for all stages

# --- Linting Stage (Example: Node.js/ESLint) ---
lint:
  stage: lint
  image: node:${NODE_VERSION}-alpine # Use a specific image for this job
  script:
    - npm ci
    - npm run lint
  artifacts:
    expire_in: 1 day
    paths:
      - node_modules/ # Cache node_modules if needed for subsequent jobs

# --- Testing Stage (Example: Node.js/Jest) ---
test:
  stage: test
  image: node:${NODE_VERSION}-alpine
  script:
    - npm ci # Re-install dependencies if not cached or shared
    - npm test
  artifacts:
    reports:
      junit: junit.xml # Optional: for test report visualization in GitLab

# --- Build Stage (Docker Image) ---
build_docker_image:
  stage: build
  image: docker:latest # Docker-in-Docker (dind) service required for building images
  services:
    - docker:dind
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $DOCKER_IMAGE_NAME:$CI_COMMIT_SHA -t $DOCKER_IMAGE_NAME:latest .
    - docker push $DOCKER_IMAGE_NAME:$CI_COMMIT_SHA
    - docker push $DOCKER_IMAGE_NAME:latest
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

# --- Deployment to Development Environment ---
deploy_to_dev:
  stage: deploy-dev
  image: alpine/git:latest # Or an image with your deployment tools (kubectl, aws-cli, etc.)
  environment:
    name: development
    url: https://dev.example.com
  script:
    - echo "Deploying $DOCKER_IMAGE_NAME:$CI_COMMIT_SHA to Development..."
    # Replace with your actual deployment commands
    # Example: Update a Kubernetes deployment
    # kubectl config use-context "$KUBE_CONTEXT_DEV"
    # kubectl set image deployment/$PROJECT_NAME-dev $PROJECT_NAME=$DOCKER_IMAGE_NAME:$CI_COMMIT_SHA -n dev-namespace
    echo "Deployment to Development complete."
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

# --- Deployment to Production Environment (Manual Approval) ---
deploy_to_prod:
  stage: deploy-prod
  image: alpine/git:latest # Or an image with your deployment tools
  environment:
    name: production
    url: https://prod.example.com
  script:
    - echo "Deploying $DOCKER_IMAGE_NAME:$CI_COMMIT_SHA to Production..."
    # Replace with your actual deployment commands
    # kubectl config use-context "$KUBE_CONTEXT_PROD"
    # kubectl set image deployment/$PROJECT_NAME-prod $PROJECT_NAME=$DOCKER_IMAGE_NAME:$CI_COMMIT_SHA -n prod-namespace
    echo "Deployment to Production complete."
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual # Requires a manual trigger in the GitLab UI

Customization Notes for GitLab CI:

  • variables: Adjust PROJECT_NAME, DOCKER_IMAGE_NAME, and NODE_VERSION. CI_REGISTRY_IMAGE is a predefined GitLab variable for your project's container registry.
  • image: Specify the Docker image required for each job. Use docker:dind (Docker-in-Docker) for the build_docker_image job.
  • Linting/Testing: Modify npm ci, npm run lint, and npm test as per your tech stack.
  • Deployment: Replace placeholder echo commands with your specific deployment logic. GitLab CI/CD Variables (e.g., KUBE_CONTEXT_DEV, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) should be used for secrets, configured in Settings > CI/CD > Variables.
  • rules: Control when jobs run. when: manual is used for manual approval for production deployments.
  • environment: Define environments for better organization, history, and integration with GitLab's deployment boards.

2.3. Jenkins Pipeline Configuration

**

devops_pipeline_generator.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' import './index.css' ReactDOM.createRoot(document.getElementById('root')!).render( ) "); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react' import './App.css' function App(){ return(

"+slugTitle(pn)+"

Built with PantheraHive BOS

) } export default App "); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e} .app{min-height:100vh;display:flex;flex-direction:column} .app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px} h1{font-size:2.5rem;font-weight:700} "); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` ## Open in IDE Open the project folder in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview" }, "dependencies": { "vue": "^3.5.13", "vue-router": "^4.4.5", "pinia": "^2.3.0", "axios": "^1.7.9" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", "typescript": "~5.7.3", "vite": "^6.0.5", "vue-tsc": "^2.2.0" } } '); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': resolve(__dirname,'src') } } }) "); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]} '); zip.file(folder+"tsconfig.app.json",'{ "compilerOptions":{ "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"], "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true, "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue", "strict":true,"paths":{"@/*":["./src/*"]} }, "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"] } '); zip.file(folder+"env.d.ts","/// "); zip.file(folder+"index.html"," "+slugTitle(pn)+"
"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue' import { createPinia } from 'pinia' import App from './App.vue' import './assets/main.css' const app = createApp(App) app.use(createPinia()) app.mount('#app') "); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue"," "); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547} "); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` Open in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test" }, "dependencies": { "@angular/animations": "^19.0.0", "@angular/common": "^19.0.0", "@angular/compiler": "^19.0.0", "@angular/core": "^19.0.0", "@angular/forms": "^19.0.0", "@angular/platform-browser": "^19.0.0", "@angular/platform-browser-dynamic": "^19.0.0", "@angular/router": "^19.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.0.0", "@angular/cli": "^19.0.0", "@angular/compiler-cli": "^19.0.0", "typescript": "~5.6.0" } } '); zip.file(folder+"angular.json",'{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "'+pn+'": { "projectType": "application", "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/'+pn+'", "index": "src/index.html", "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.css"], "scripts": [] } }, "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"} } } } } '); zip.file(folder+"tsconfig.json",'{ "compileOnSave": false, "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]}, "references":[{"path":"./tsconfig.app.json"}] } '); zip.file(folder+"tsconfig.app.json",'{ "extends":"./tsconfig.json", "compilerOptions":{"outDir":"./dist/out-tsc","types":[]}, "files":["src/main.ts"], "include":["src/**/*.d.ts"] } '); zip.file(folder+"src/index.html"," "+slugTitle(pn)+" "); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, appConfig) .catch(err => console.error(err)); "); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; } "); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = '"+pn+"'; } "); zip.file(folder+"src/app/app.component.html","

"+slugTitle(pn)+"

Built with PantheraHive BOS

"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1} "); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes) ] }; "); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router'; export const routes: Routes = []; "); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install ng serve # or: npm start ``` ## Build ```bash ng build ``` Open in VS Code with Angular Language Service extension. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local .angular/ "); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join(" "):"# add dependencies here "; zip.file(folder+"main.py",src||"# "+title+" # Generated by PantheraHive BOS print(title+" loaded") "); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Run ```bash python main.py ``` "); zip.file(folder+".gitignore",".venv/ __pycache__/ *.pyc .env .DS_Store "); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+" "; zip.file(folder+"package.json",pkgJson); var fallback="const express=require("express"); const app=express(); app.use(express.json()); app.get("/",(req,res)=>{ res.json({message:""+title+" API"}); }); const PORT=process.env.PORT||3000; app.listen(PORT,()=>console.log("Server on port "+PORT)); "; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000 "); zip.file(folder+".gitignore","node_modules/ .env .DS_Store "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash npm install ``` ## Run ```bash npm run dev ``` "); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:" "+title+" "+code+" "; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */ *{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e} "); zip.file(folder+"script.js","/* "+title+" — scripts */ "); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Open Double-click `index.html` in your browser. Or serve locally: ```bash npx serve . # or python3 -m http.server 3000 ``` "); zip.file(folder+".gitignore",".DS_Store node_modules/ .env "); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/**(.+?)**/g,"$1"); hc=hc.replace(/ {2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. Files: - "+app+".md (Markdown) - "+app+".html (styled HTML) "); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); }function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}