{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Pre Debug Check & Start All",
            "dependsOn": [
                "validate local prerequisites",
                "prepare local environment",
                "Start All"
            ],
            "dependsOrder": "sequence"
        },
        {
            // Check if all required prerequisites are installed and will install them if not.
            // See https://aka.ms/teamsfx-check-prerequisites-task to know the details and how to customize the args.
            "label": "validate local prerequisites",
            "type": "teamsfx",
            "command": "debug-check-prerequisites",
            "presentation": {
                "reveal": "never"
            },
            "args": {
                "prerequisites": [
                    //"nodejs", // Validate if Node.js is installed.
                    "m365Account", // Sign-in prompt for Microsoft 365 account, then validate if the account enables the sideloading permission.
                    "portOccupancy" // Validate available ports to ensure those debug ones are not occupied.
                ],
                "portOccupancy": [
                    53000, // tab service port
                    7071, // backend service port
                    9229 // backend inspector port for Node.js debugger
                ]
            }
        },
        {
            "label": "prepare local environment",
            "dependsOn": [
                "Provision",
                "Deploy"
            ],
            "dependsOrder": "sequence"
        },
        {
            // Create the debug resources.
            // See https://aka.ms/teamsfx-tasks/provision to know the details and how to customize the args.
            "label": "Provision",
            "type": "teamsfx",
            "command": "provision",
            "args": {
                "env": "local"
            }
        },
        {
            // Build project.
            // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args.
            "label": "Deploy",
            "type": "teamsfx",
            "command": "deploy",
            "args": {
                "env": "local"
            }
        },
        {
            "label": "Start All",
            "dependsOn": [
                "Start Frontend",
                "Start Backend"
            ]
        },
        {
            "label": "Start Frontend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-frontend-watch",
            "options": {
                "cwd": "${workspaceFolder}/tabs"
            }
        },
        {
            "label": "Start Backend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-backend-watch",
            "options": {
                "cwd": "${workspaceFolder}/api",
                "env": {
                    "PATH": "${workspaceFolder}/devTools/func${command:fx-extension.get-path-delimiter}${env:PATH}"
                }
            },
            "presentation": {
                "reveal": "silent"
            }
        }
    ]
}