# hey24sheep/azure-flutter-tasks architecture

> Architecture diagram of the GitHub repository hey24sheep/azure-flutter-tasks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hey24sheep/azure-flutter-tasks
- Repository: https://github.com/hey24sheep/azure-flutter-tasks

## Overview

##### Project Type and Purpose
- This is an **Azure DevOps extension** (VSS/Marketplace) that provides a set of pipeline “tasks” to install, build, test, analyze, and run arbitrary Flutter commands on a build agent.
- It bundles several Node.js/TypeScript task implementations, a sample Flutter project for testing, CI definitions for itself, and metadata (vss-extension.json) to publish to the Marketplace.

##### Top-Level Components
a. **Developer & CI Environment**
- Source Code Repository (GitHub)
- Azure Pipelines (CI): uses `azure-pipelines.yml` to compile TypeScript, run unit tests in `tasks/*/tests`, bundle the extension, and publish to Marketplace.
b. **Azure DevOps Marketplace**
- Hosts the packaged `.vsix` extension defined by `vss-extension.json`.
c. **Pipeline Agent**
- Hosted or self-hosted machine that runs your Flutter build pipeline.
- Installs and executes the tasks delivered by the extension.
d. **Flutter Tasks** (each in `tasks/{install,build,test,analyze,command,env}`)
- Node.js/TypeScript code that leverages the Azure DevOps Task SDK.
- Exposes inputs/outputs, performs CLI invocations (`flutter`, `dart`), sets environment variables, parses logs, and publishes reports.
e. **Flutter SDK & Dart SDK**
- Installed via the **Install** task (or provided by the agent).
- Made available to subsequent tasks via environment variables (`FlutterToolPath`, `DartToolPath`, `FlutterPubCachePath`).
f. **Sample Flutter Project** (`sample_project`)
- A reference project used by CI tests to validate tasks (e.g., running `tasks/test` against `sample_project`).

##### Relationships & Data Flows
1. **Developer → GitHub**
- Commits code, pushes to repo.
2. **GitHub → Azure Pipelines CI**
- Web-hook triggers CI defined in `azure-pipelines.yml`.
3. **CI Agent**
- Runs `tsc-build-with-npm.sh` / `publish-build-with-npm.sh` to compile TS to JS.
- Executes unit tests under `tasks/*/tests` using Node.
- Packages the extension via `vss-extension.json` and publishes to Marketplace (using `tfx` CLI).
4. **Azure DevOps Marketplace**
- Stores extension package.
5. **User Pipeline Definition**
- A consumer adds the “Flutter” tasks into their build pipeline via the Marketplace.
6. **Pipeline Agent** (customer)
- Downloads the extension tasks.
- Runs **Install** task to fetch or reuse Flutter SDK.
- Sets env-vars (`FlutterToolPath`, etc.) via **Env** task.
- Runs **Build**, **Test**, **Analyze**, or **Command** tasks in sequence, each:
- Receiving inputs (projectDirectory, target, extraArgs, etc.)
- Invoking `$(FlutterToolPath)/flutter ...` or `$(DartToolPath)/dart ...`
- Parsing output, publishing test reports, coverage, or build artifacts.

##### Architectural Patterns & Design Principles
- **Modular Tasks**: Each feature (install, build, test, analyze, command, env) is a separate module under `tasks/`, allowing independent versioning and testing.
- **CI-driven Packaging**: TypeScript sources are compiled and unit-tested in CI, ensuring integrity before publishing.
- **Env Injection**: Use of a dedicated **Env** task to set reusable env-vars for later tasks, reducing duplication.
- **Sample Project Validation**: A “canary” Flutter project tests the tasks end-to-end.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development & CI Layer
    subgraph "Development & CI" 
        direction TB
        GH("GitHub Repo"):::devCI
        CI("Azure Pipelines CI"):::devCI
        YML["azure-pipelines.yml"]:::devCI
        Scripts["CI Build Scripts"]:::devCI
        Sample["Sample Flutter Project"]:::devCI
    end

    %% Distribution & Marketplace Layer
    subgraph "Distribution & Marketplace"
        direction TB
        MPStore("Visual Studio Marketplace Store"):::dist
        Manifest["vss-extension.json"]:::dist
    end

    %% Runtime on Agent Layer
    subgraph "Pipeline Agent (Runtime)"
        direction TB
        Agent("Pipeline Agent"):::runtime
        SDK("Flutter SDK & Dart SDK"):::runtime
        subgraph "Flutter Tasks Modules"
            direction TB
            Install("Install Task Module"):::runtime
            Env("Env Task Module"):::runtime
            Build("Build Task Module"):::runtime
            Test("Test Task Module"):::runtime
            Analyze("Analyze Task Module"):::runtime
            Command("Command Task Module"):::runtime
        end
    end

    %% Connections
    Developer("Developer"):::devCI -->|"Push code"| GH
    GH -->|"Webhook trigger"| CI
    CI -->|"uses azure-pipelines.yml"| YML
    CI -->|"compile&test"| Scripts
    CI -->|"e2e validate against sample_project"| Sample
    CI -->|"package & publish .vsix"| Manifest
    Manifest -->|"host extension v{major.minor.patch}"| MPStore
    MPStore -->|"download tasks"| Agent
    Agent -->|"install or reuse"| SDK
    Agent -->|"runs"| Install
    Install -->|"sets env vars"| Env
    Env -->|"provides paths"| Build
    Env -->|"provides paths"| Test
    Env -->|"provides paths"| Analyze
    Env -->|"provides paths"| Command
    Build -->|"flutter build"| Agent
    Test -->|"flutter test"| Agent
    Analyze -->|"flutter analyze"| Agent
    Command -->|"flutter run/custom"| Agent

    %% Click Events
    click YML "https://github.com/hey24sheep/azure-flutter-tasks/blob/master/azure-pipelines.yml"
    click Scripts "https://github.com/hey24sheep/azure-flutter-tasks/blob/master/tsc-build-with-npm.sh"
    click Scripts "https://github.com/hey24sheep/azure-flutter-tasks/blob/master/publish-build-with-npm.sh"
    click Scripts "https://github.com/hey24sheep/azure-flutter-tasks/blob/master/publish-build.sh"
    click Manifest "https://github.com/hey24sheep/azure-flutter-tasks/blob/master/vss-extension.json"
    click Install "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/install"
    click Env "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/env"
    click Build "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/build"
    click Test "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/test"
    click Analyze "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/analyze"
    click Command "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/tasks/command"
    click Sample "https://github.com/hey24sheep/azure-flutter-tasks/tree/master/sample_project"

    %% Styles
    classDef devCI fill:#D6E9FF,stroke:#000,stroke-width:1px
    classDef dist fill:#D6FFD6,stroke:#000,stroke-width:1px
    classDef runtime fill:#FFE6B3,stroke:#000,stroke-width:1px
```
