{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Install Dependencies conda test",
      "type": "shell",
      "command": "source activate node && export NODE_ENV=test && npm install",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "Run Server conda test",
      "type": "shell",
      "command": "source activate node && export NODE_ENV=test && node server.js",
      "dependsOn": [
        "Install Dependencies"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "Run Server conda test",
      "type": "shell",
      "command": "source activate node && export NODE_ENV=test && node server.js",
      "dependsOn": [
        "Install Dependencies"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "killInspector",
      "type": "shell",
      "command": "FOR /F \"tokens=5\" %p IN ('netstat -ano ^| find \"9229\" ^| find \"LISTENING\"') DO taskkill /PID %p",
      "problemMatcher": [],
      "windows": {
        "command": "FOR /F \"tokens=5\" %p IN ('netstat -ano ^| find \"9229\" ^| find \"LISTENING\"') DO taskkill /F /PID %p",
        "options": {
          "shell": {
            "executable": "cmd.exe",
            "args": [
              "/d",
              "/c"
            ]
          }
        }
      },
      "linux": {
        "command": "lsof -t -i:9229 | xargs -r kill -9"
      },
    },
    {
      "label": "Remove node_modules",
      "type": "shell",
      "command": "Remove-Item -Recurse -Force node_modules",
      "problemMatcher": [],
      "windows": {
        "command": "Remove-Item -Recurse -Force node_modules",
        "options": {
          "shell": {
            "executable": "powershell.exe",
            "args": [
              "-Command"
            ]
          }
        }
      },
      "linux": {
        "command": "rm -rf node_modules"
      }
    },
    {
      "label": "Build Docker Image",
      "type": "shell",
      "command": "docker build -t next-cart-app:dev .",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": []
    },
    {
      "label": "Docker Compose Up",
      "type": "shell",
      "command": "docker-compose up --build",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": []
    },
    {
      "label": "Deploy to Remote Server",
      "type": "shell",
      "command": "rsync",
      "args": [
        "-avz",
        ".next/",
        "public/",
        "package.json",
        "package-lock.json",
        "server.js",
        "${env:REMOTE_USER}@${env:REMOTE_SERVER}:${env:REMOTE_DESTINATION}"
      ],
      "presentation": {
        "reveal": "always",
        "panel": "new"
      },
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "options": {
        "env": {
          "REMOTE_USER": "azureuser", // Replace with your remote username
          "REMOTE_SERVER": "172.160.240.73", // Replace with your remote server IP or hostname
          "REMOTE_DESTINATION": "/mnt/docker_volumes/pw/app/" // Replace with your destination path on the remote server
        }
      }
    }
  ]
}