Skip to content

Commit 01a8089

Browse files
authored
Merge pull request #22: Load not archived binaries
2 parents 8d7b017 + 71eb96b commit 01a8089

File tree

22 files changed

+876
-229
lines changed

22 files changed

+876
-229
lines changed

README.md

Lines changed: 227 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414

1515
<br />
1616

17+
DLoad simplifies downloading and managing binary artifacts for your projects. Perfect for development environments that require specific tools like RoadRunner, Temporal, or custom binaries.
18+
19+
## Why DLoad?
20+
21+
DLoad solves a common problem in PHP projects: how to distribute and install necessary binary tools and assets alongside your PHP code.
22+
With DLoad, you can:
23+
24+
- Automatically download required tools during project initialization
25+
- Ensure all team members use the same versions of tools
26+
- Simplify onboarding by automating environment setup
27+
- Manage cross-platform compatibility without manual configuration
28+
- Keep binaries and assets separate from your version control
29+
1730
## Installation
1831

1932
```bash
@@ -25,71 +38,258 @@ composer require internal/dload -W
2538
[![License](https://img.shields.io/packagist/l/internal/dload.svg?style=flat-square)](LICENSE.md)
2639
[![Total DLoads](https://img.shields.io/packagist/dt/internal/dload.svg?style=flat-square)](https://packagist.org/packages/internal/dload/stats)
2740

28-
## Usage
41+
## Command Line Usage
42+
43+
DLoad offers two main commands:
2944

30-
### Get predefined software list
45+
### List Available Software
3146

3247
```bash
33-
./vendor/bin/dload list
48+
# View all available software packages
49+
./vendor/bin/dload software
3450
```
3551

36-
### Download single software
52+
This displays a list of all registered software packages with their IDs, names, repository information, and descriptions.
53+
54+
DLoad comes with a pre-configured list of popular tools and software packages ready for download.
55+
You can contribute to this list by submitting issues or pull requests to the DLoad repository.
56+
57+
### Download Software
3758

3859
```bash
39-
./vendor/bin/dload get dolt
60+
# Basic usage
61+
./vendor/bin/dload get rr
62+
63+
# Download multiple packages
64+
./vendor/bin/dload get rr dolt temporal
65+
66+
# Download with specific stability
67+
./vendor/bin/dload get rr --stability=beta
68+
69+
# Use configuration from file (without specifying software)
70+
./vendor/bin/dload get
71+
72+
# Force download even if binary exists
73+
./vendor/bin/dload get rr --force
4074
```
4175

42-
### Configure preset for the project
76+
#### Download Command Options
77+
78+
| Option | Description | Default |
79+
|--------|-------------|---------|
80+
| `--path` | Directory to store binaries | Current directory |
81+
| `--arch` | Target architecture (amd64, arm64) | System architecture |
82+
| `--os` | Target OS (linux, darwin, windows) | Current OS |
83+
| `--stability` | Release stability (stable, beta) | stable |
84+
| `--config` | Path to configuration file | ./dload.xml |
85+
| `--force`, `-f` | Force download even if binary exists | false |
86+
87+
## Project Configuration
88+
89+
### Setting Up Your Project
90+
91+
The `dload.xml` file in your project root is essential for automation. It defines the tools and assets required by your project, allowing for automatic initialization of development environments.
4392

44-
Create `dload.xml` file in the root of the project with the following content:
93+
When a new developer joins your project, they can simply run `dload get` to download all necessary binaries and assets without manual configuration.
94+
95+
Create `dload.xml` in your project root:
4596

4697
```xml
4798
<?xml version="1.0"?>
48-
<dload>
99+
<dload
100+
temp-dir="./runtime"
101+
>
49102
<actions>
50103
<download software="rr" version="^2.12.0" />
51-
<download software="temporal"/>
104+
<download software="dolt" />
105+
<download software="temporal" />
106+
<download software="frontend" extract-path="frontend"/>
52107
</actions>
53108
</dload>
54109
```
55110

56-
There are two software packages to download: `temporal` and `rr` with version `^2.12.0`.
57-
Optionally, you may specify the version of the software package using Composer versioning syntax.
58-
To download all the configured software, run `dload get` without arguments:
111+
Then run:
59112

60113
```bash
61114
./vendor/bin/dload get
62115
```
63116

64-
### Custom software registry
117+
### Configuration Options
118+
119+
The `dload.xml` file supports several options:
120+
121+
- **temp-dir**: Directory for temporary files during download (default: system temp dir)
122+
- **actions**: List of download actions to perform
123+
124+
#### Download Action Options
125+
126+
Each `<download>` action supports:
127+
128+
- **software**: Name or alias of the software to download (required)
129+
- **version**: Target version using Composer versioning syntax (e.g., `^2.12.0`, `~1.0`, `1.2.3`)
130+
- **extract-path**: Directory where files will be extracted (useful for non-binary assets)
131+
132+
### Handling Different File Types
133+
134+
DLoad handles both binary executables and regular files:
135+
136+
```xml
137+
<software name="my-app">
138+
<!-- Binary executable that depends on OS/architecture -->
139+
<binary name="app-cli" pattern="/^app-cli-.*/" />
140+
141+
<!-- Regular file that works on any system -->
142+
<file pattern="/^config.yml$/" />
143+
</software>
144+
```
145+
146+
## Custom Software Registry
147+
148+
### Defining Custom Software
149+
150+
Create your own software definitions:
65151

66152
```xml
67153
<?xml version="1.0"?>
68154
<dload>
69-
<registry>
70-
<software name="RoadRunner"
71-
alias="rr"
72-
binary="rr"
73-
description="High performant Application server"
74-
>
155+
<registry overwrite="false">
156+
<!-- Binary software example -->
157+
<software name="RoadRunner" alias="rr"
158+
homepage="https://roadrunner.dev"
159+
description="High performant Application server">
160+
<repository type="github" uri="roadrunner-server/roadrunner" asset-pattern="/^roadrunner-.*/" />
161+
<binary name="rr" pattern="/^roadrunner-.*/" />
162+
</software>
163+
164+
<!-- Non-binary files example -->
165+
<software name="frontend" description="Frontend assets">
75166
<repository type="github"
76-
uri="roadrunner-server/roadrunner"
77-
asset-pattern="/^roadrunner-.*/"
78-
/>
79-
<file pattern="/^(roadrunner|rr)(?:\.exe)?$/"
80-
rename="rr"
167+
uri="my-org/frontend"
168+
asset-pattern="/^artifacts.*/"
81169
/>
170+
<file pattern="/^.*\.js$/" />
171+
<file pattern="/^.*\.css$/" />
172+
</software>
173+
174+
<!-- Software with mixed file types -->
175+
<software name="my-tool" description="Complete tool suite">
176+
<repository type="github" uri="my-org/tool" />
177+
<!-- Binary executables -->
178+
<binary name="tool-cli" pattern="/^tool-cli.*/" />
179+
<binary name="tool-worker" pattern="/^worker.*/" />
180+
<!-- Configuration files -->
181+
<file pattern="/^config\.yml$/" extract-path="config" />
182+
<file pattern="/^templates\/.*/" extract-path="templates" />
82183
</software>
83184
</registry>
84185
</dload>
85186
```
86187

87-
DLoad will check the option `software.binary` to prevent downloading if the file already exists.
188+
### Software Configuration Options
189+
190+
Each `<software>` entry supports:
191+
192+
- **name**: Display name (required)
193+
- **alias**: Short name for command line usage
194+
- **description**: Brief description
195+
- **homepage**: Website URL
196+
197+
#### Repository Options
198+
199+
The `<repository>` element configures where to download from:
200+
201+
- **type**: Currently supports "github"
202+
- **uri**: Repository path (e.g., "username/repo")
203+
- **asset-pattern**: Regex pattern to match release assets
88204

89-
### GitHub Token
205+
#### Binary Options
90206

91-
To increase the rate limit for GitHub API, you can specify the token in the environment variable `GITHUB_TOKEN`:
207+
The `<binary>` element defines executable files:
208+
209+
- **name**: Binary name that will be referenced
210+
- **pattern**: Regex pattern to match the binary in release assets
211+
212+
Binary files are OS and architecture specific. DLoad will automatically download the correct version for your system.
213+
214+
#### File Options
215+
216+
The `<file>` element defines non-binary files:
217+
218+
- **pattern**: Regex pattern to match files
219+
- **extract-path**: Optional subdirectory where files will be extracted
220+
221+
File assets don't have OS/architecture restrictions and work on any system.
222+
223+
## GitHub API Rate Limits
224+
225+
To avoid GitHub API rate limits, use a personal access token:
92226

93227
```bash
94228
GITHUB_TOKEN=your_token_here ./vendor/bin/dload get
95229
```
230+
231+
You can add this to your CI/CD pipeline environment variables for automated downloads.
232+
233+
## Use Cases
234+
235+
### Local Development Environment Setup
236+
237+
Automatically download required tools when setting up a development environment:
238+
239+
```bash
240+
# Initialize project with all required tools
241+
composer install
242+
./vendor/bin/dload get
243+
```
244+
245+
### CI/CD Pipeline Integration
246+
247+
In your GitHub Actions workflow:
248+
249+
```yaml
250+
steps:
251+
- uses: actions/checkout@v2
252+
253+
- name: Setup PHP
254+
uses: shivammathur/setup-php@v2
255+
with:
256+
php-version: '8.1'
257+
258+
- name: Install dependencies
259+
run: composer install
260+
261+
- name: Download binary tools
262+
run: |
263+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} ./vendor/bin/dload get
264+
```
265+
266+
### Cross-Platform Development Team
267+
268+
Configure once, use everywhere:
269+
270+
```xml
271+
<dload>
272+
<actions>
273+
<download software="rr" version="^2.12.0" />
274+
<download software="temporal" />
275+
</actions>
276+
</dload>
277+
```
278+
279+
Each team member runs `./vendor/bin/dload get` and gets the correct binaries for their system (Windows, macOS, or Linux).
280+
281+
### Distributed Frontend Assets
282+
283+
Keep your frontend assets separate from your PHP repository:
284+
285+
```xml
286+
<software name="frontend-bundle">
287+
<repository type="github" uri="your-org/frontend-build" asset-pattern="/^dist.*/" />
288+
<file pattern="/^.*$/" extract-path="public/assets" />
289+
</software>
290+
```
291+
292+
## Contributing
293+
294+
Contributions are welcome!
295+
Feel free to submit a Pull Request to add new software to the predefined list or improve the functionality of DLoad.

dload.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66
<actions>
77
<download software="rr" version="^2.12.0" />
88
<download software="dolt" />
9-
<download software="temporal" />
9+
<download software="temporal" version-path="composer.json@require.temporal/sdk" />
10+
<download software="frontend" extract-path="frontend"/>
1011
</actions>
1112
<registry overwrite="false">
12-
<software name="RoadRunner" alias="rr" binary="rr"
13+
<software name="RoadRunner" alias="rr"
1314
homepage="https://roadrunner.dev"
1415
description="High performant Application server">
1516
<repository type="github" uri="roadrunner-server/roadrunner" asset-pattern="/^roadrunner-.*/"/>
17+
<binary name="rr" pattern="/^roadrunner-.*/" />
18+
</software>
19+
<software name="frontend" description="Buggregator Frontend files">
20+
<repository type="github"
21+
uri="buggregator/frontend"
22+
asset-pattern="/^artifacts.*/"
23+
/>
24+
<file pattern="/^.*$/"/>
1625
</software>
1726
</registry>
1827
</dload>

0 commit comments

Comments
 (0)