# grahampugh/erase-install architecture

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

- Interactive diagram: https://gitdiagram.com/grahampugh/erase-install
- Repository: https://github.com/grahampugh/erase-install

## Overview

##### Project type and purpose
- This is a command-line tool and packaging pipeline (a shell-script-based macOS “self-destruct” installer) rather than a web app or microservice.
- Its purpose is to orchestrate macOS installer downloads (via mist-cli or softwareupdate), run Apple’s startosinstall with erase/upgrade flags, and optionally present dialogs (via swiftDialog). It also provides a .pkg build in pkg/erase-install for mass deployment.

##### File structure
- Top-level scripts:
- erase-install.sh (main entrypoint)
- erase-install-launcher.sh / erase-install-install-scripts (helpers and examples)
- set-credentials.sh (credentials helper)
- Packaging directory: pkg/erase-install/
- build-info.plist (metadata)
- scripts/postinstall (invokes the main script)
- Configuration/build: Makefile, .prettierrc.yaml, .gitignore
- CI/templates: .github (funding, issue templates)

##### README for additional insights
- Workflow:
a. Download installer app from Apple (mist-cli or softwareupdate)
b. Invoke startosinstall with --eraseinstall or --reinstall flags
c. Optionally present user dialogs via swiftDialog
d. Support integration with Jamf Pro or other MDMs
- External dependencies and minimum OS versions are key architectural constraints.

##### Main components
a. CLI layer (shell scripts)
- erase-install.sh as orchestrator
- set-credentials.sh as submodule
b. Build/Packaging pipeline
- pkg/erase-install and postinstall script
- Makefile-driven build steps
c. External tools/services
- mist-cli (download agent)
- softwareupdate (native download)
- swiftDialog (UI)
- startosinstall (OS installer binary)
- Apple Software Update servers
- Optional MDM integration (Jamf Pro)
d. Outputs
- macOS Installer.app
- Completed macOS install/erase

##### Relationships and interactions
- erase-install.sh → invokes either mist-cli or softwareupdate → downloads Installer.app
- erase-install.sh → (if enabled) calls swiftDialog → displays progress/UI → collects user input
- erase-install.sh → calls startosinstall with chosen flags → triggers OS reinstallation
- Packaging pipeline: Makefile → builds .pkg in pkg/erase-install → copies scripts and metadata → outputs installer package for MDM
- Management tool (Jamf Pro) → deploys the .pkg to clients → postinstall script triggers the above steps on target machines

##### Architectural patterns and design principles
- Modular scripting: separate concerns via helper scripts (set-credentials, launcher)
- Adapter pattern: wrapping native binaries (startosinstall, softwareupdate) behind a unified CLI interface
- CI/CD pipeline for packaging: using Makefile and pkg folder rather than manual packaging
- Externalization of UI: swiftDialog used only when available, fallback to CLI where needed

##### Elements
- erase-install.sh (orchestrator)
- set-credentials.sh
- pkg/erase-install (packaging component)
- External tools: mist-cli, softwareupdate, swiftDialog, startosinstall
- Apple Software Update servers
- MDM/Jamf Pro server
- Script calls
- Downloads (to local machine)
- Data flow (installer artifact)
- Deployment (MDM → client)
- External binaries in another
- Servers/external services in a third
- Build/pipeline components in a fourth

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        erase["erase-install.sh"]:::shell
        creds["set-credentials.sh"]:::shell
        launcher["erase-install-launcher.sh"]:::shell
        exTrigger["erase-install-launch-script-example-with-trigger.sh"]:::shell
        exScript["erase-install-launch-script-example.sh"]:::shell
    end

    %% Packaging Pipeline
    subgraph "Packaging Pipeline"
        makefile["Makefile"]:::pipeline
        pkgdir["pkg/erase-install/"]:::pipeline
        buildinfo["build-info.plist"]:::pipeline
        pkggitignore[".gitignore"]:::pipeline
        postinstall["scripts/postinstall"]:::pipeline
        pkgOutput["Installer Package (.pkg)"]:::pipeline
    end

    %% Documentation & Config
    subgraph "Project Config & Docs"
        pretti[".prettierrc.yaml"]:::pipeline
        gitignoreRoot[".gitignore"]:::pipeline
        readme["README.md"]:::pipeline
        changelog["CHANGELOG.md"]:::pipeline
        issueBug[".github/ISSUE_TEMPLATE/bug_report.md"]:::pipeline
        issueFeature[".github/ISSUE_TEMPLATE/feature_request.md"]:::pipeline
        funding[".github/FUNDING.yml"]:::pipeline
        icons["icons/"]:::pipeline
        img["img/"]:::pipeline
    end

    %% External Services & Tools
    subgraph "External Services"
        mist["mist-cli"]:::binary
        softwareupdate["softwareupdate"]:::binary
        appleServers["Apple Software Update Servers"]:::service
        swiftDialog["swiftDialog"]:::binary
        startosinstall["startosinstall"]:::binary
        jamf["Jamf Pro (MDM Server)"]:::service
    end

    %% Runtime Orchestration
    erase -->|"uses"| creds
    erase -->|"uses"| launcher
    launcher --> exTrigger
    launcher --> exScript
    erase -->|"choose download method"| mist
    erase -->|"choose download method"| softwareupdate
    mist -->|"download installer"| appleServers
    softwareupdate -->|"download installer"| appleServers
    appleServers -->|"provides Installer.app"| installerApp["macOS Installer.app"]:::service
    erase -->|"optional UI"| swiftDialog
    swiftDialog -->|"display progress & input"| erase
    erase -->|"invoke"| startosinstall
    installerApp -->|"passed to"| startosinstall
    startosinstall -->|"triggers reinstall/erase"| completed["Completed macOS Install/Erase"]:::service

    %% Packaging Pipeline Flow
    makefile -->|"builds"| pkgdir
    pkgdir --> buildinfo
    pkgdir --> pkggitignore
    pkgdir --> postinstall
    pkgdir -->|"outputs"| pkgOutput
    jamf -->|"deploys pkg"| pkgOutput
    pkgOutput -->|"runs postinstall"| erase

    classDef shell fill:#e0f7fa,stroke:#006064,color:#004d40;
    classDef binary fill:#e8f5e9,stroke:#1b5e20,color:#2e7d32;
    classDef service fill:#fff3e0,stroke:#e65100,color:#bf360c;
    classDef pipeline fill:#e1bee7,stroke:#4a148c,color:#6a1b9a;

    %% Click Events
    click erase "https://github.com/grahampugh/erase-install/blob/main/erase-install.sh"
    click creds "https://github.com/grahampugh/erase-install/blob/main/set-credentials.sh"
    click launcher "https://github.com/grahampugh/erase-install/blob/main/erase-install-launcher.sh"
    click exTrigger "https://github.com/grahampugh/erase-install/blob/main/erase-install-launch-script-example-with-trigger.sh"
    click exScript "https://github.com/grahampugh/erase-install/blob/main/erase-install-launch-script-example.sh"
    click makefile "https://github.com/grahampugh/erase-install/tree/main/Makefile"
    click pkgdir "https://github.com/grahampugh/erase-install/tree/main/pkg/erase-install/"
    click buildinfo "https://github.com/grahampugh/erase-install/blob/main/pkg/erase-install/build-info.plist"
    click pkggitignore "https://github.com/grahampugh/erase-install/blob/main/pkg/erase-install/.gitignore"
    click postinstall "https://github.com/grahampugh/erase-install/tree/main/pkg/erase-install/scripts/postinstall"
    click pretti "https://github.com/grahampugh/erase-install/blob/main/.prettierrc.yaml"
    click gitignoreRoot "https://github.com/grahampugh/erase-install/blob/main/.gitignore"
    click issueBug "https://github.com/grahampugh/erase-install/blob/main/.github/ISSUE_TEMPLATE/bug_report.md"
    click issueFeature "https://github.com/grahampugh/erase-install/blob/main/.github/ISSUE_TEMPLATE/feature_request.md"
    click funding "https://github.com/grahampugh/erase-install/blob/main/.github/FUNDING.yml"
    click readme "https://github.com/grahampugh/erase-install/blob/main/README.md"
    click changelog "https://github.com/grahampugh/erase-install/blob/main/CHANGELOG.md"
    click icons "https://github.com/grahampugh/erase-install/tree/main/icons/"
    click img "https://github.com/grahampugh/erase-install/tree/main/img/"
```
