How webinstall/webi-installers works
This project is essentially a collection of install scripts and utilities used by the webi installer system—essentially a tooling ecosystem that enables developers to install packages without requiring package managers or elevated privileges. The repository is structured as a mix of common logic modules, installer templates, and many individual package directories that each encapsulate the installation logic for a specific tool.
Project's Core Purpose and Type
• This is not a “traditional” full-stack web application but rather a tooling repository for a package installation framework.
• Its purpose is to fetch, format, and install software packages (from different sources) by using common scripts and wrappers that interface with external APIs (like GitHub releases) to dynamically generate installation scripts.
Major Architectural Components
a. Client/Entry Point:
– The user initiates the process by running a curl command (e.g., “curl https://webi.sh/webi | sh”), so the entry point is the bootstrap script that is downloaded.
b. Bootstrap and Template Engine:
– The _webi directory contains core scripts:
• bootstrap.sh – serves as the initial entry point that exchanges system information (OS, CPU, supported archive formats) for a suitable installer.
• template.sh – holds shared functions for version checking, downloading, extraction, PATH updating, and linking.
c. Common APIs and Utility Libraries:
– The _common folder holds scripts that wrap various release API calls (e.g., github.js, gitea.js). These scripts are responsible for transforming data (from releases available in HTML, CSV, JSON, etc.) into a uniform JSON format.
d. Package-specific Installers:
– Each subdirectory (e.g., aliasman, arc, caddy, deno, etc.) contains its own install.sh, install.ps1, and releases.js. These are essentially overrides or additional hooks on top of the common template functions.
e. CI/CD and Development Utilities:
– Directories like .github, package.json, and various _scripts/ support automated testing, linting, and continuous integration.
f. Examples and Documentation:
– The _example, _npm, _vim-example directories and various README files provide usage examples and instructions for both package authors and maintainers.
Relationships and Data Flow
• User Execution Flow:
– The user executes the curl command, which downloads and runs the bootstrap script from the _webi folder.
– The bootstrap script uses system/OS information to select the appropriate installer (for a specific package) by interacting with release APIs through functions defined in the _common folder.
• Template Utilization:
– The template.sh script provides a standard process (pre-check, download, extraction, installation, linking, and PATH updating) that can be overridden by package-specific install scripts.
• Package Overrides:
– Individual package directories include their own ‘install.sh’ and ‘install.ps1’ to override or provide custom behaviors, but they still call into the shared functions in the _webi and _common folders.
• External Data Sources:
– The releases.js files in each package directory fetch version information from external release endpoints (e.g., GitHub APIs). This data is formatted and then passed to the bootstrap/template system for installation operations.
Important Architectural Patterns and Design Principles
• Modularity and Reusability:
– Common code is placed in _common and _webi so that each package installer only needs to provide minimal overrides.
• Template Method Pattern:
– The shared installer functions in _webi/template.sh serve as “hooks” that can be customized by package-specific install scripts.
• Separation of Concerns:
– Core functionalities (bootstrapping, preparation, common release handling) are separated from individual package logic.
• Cross-Platform Considerations:
– Both POSIX shell (install.sh) and PowerShell (install.ps1) scripts are used across package directories.
Relevant Technologies, Frameworks, and Libraries
• JavaScript/Node.js is used to power some parts of the release fetching and transformation logic (e.g., releases.js, _webi/test.js).
• Shell scripting (Bash) and PowerShell provide the installer logic.
• GitHub Actions (workflow definitions in .github/workflows) support CI/CD testing.
• Various configuration files (.gitignore, linting configs, etc.) support code quality and repository management.
• Avoid over-simplification; include as many components as possible so that stakeholders see the full architectural landscape.