Skip to content

Commit d71416e

Browse files
committed
chore: wip
1 parent 9c08f53 commit d71416e

File tree

6 files changed

+319
-20
lines changed

6 files changed

+319
-20
lines changed

.github/workflows/precompile-php.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
- name: Get PHP versions from ts-pkgx
4343
id: get-versions
4444
run: |
45-
# Get dynamic PHP versions using published ts-pkgx package
46-
PHP_VERSIONS=$(bunx ts-pkgx get-php-versions)
45+
# Get dynamic PHP versions using our custom script
46+
PHP_VERSIONS=$(bun scripts/get-php-versions.ts | grep "JSON output for GitHub Actions:" -A 1 | tail -1)
4747
echo "php_versions=$PHP_VERSIONS" >> $GITHUB_OUTPUT
4848
echo "🔍 Dynamic PHP versions: $PHP_VERSIONS"
4949
@@ -876,14 +876,27 @@ jobs:
876876
877877
# Release job to create GitHub releases with binaries
878878
create-release:
879-
needs: build-matrix
879+
needs: [build-matrix, get-php-versions]
880880
runs-on: ubuntu-latest
881881
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
882882

883883
steps:
884884
- name: Checkout repository
885885
uses: actions/checkout@v4
886886

887+
- name: Setup Bun
888+
uses: oven-sh/setup-bun@v2
889+
with:
890+
bun-version: latest
891+
892+
- name: Get PHP versions
893+
id: get-versions
894+
run: |
895+
# Get dynamic PHP versions using our custom script
896+
PHP_VERSIONS=$(bun scripts/get-php-versions.ts | grep "JSON output for GitHub Actions:" -A 1 | tail -1)
897+
echo "php_versions=$PHP_VERSIONS" >> $GITHUB_OUTPUT
898+
echo "🔍 Dynamic PHP versions: $PHP_VERSIONS"
899+
887900
- name: Download all artifacts
888901
uses: actions/download-artifact@v4
889902
with:
@@ -937,16 +950,16 @@ jobs:
937950
body: |
938951
🚀 **PHP Precompiled Binaries**
939952
940-
This release contains precompiled PHP binaries optimized for modern PHP usage:
953+
This release contains precompiled PHP binaries optimized for modern PHP usage:
941954
942955
- **Platforms**: Linux (x86_64), macOS (ARM64 & Intel)
943-
- **PHP Versions**: 8.4.11, 8.3.14, 8.2.26, 8.1.30
944-
- **Laravel-Optimized Configurations**:
945-
- `laravel-mysql`: Laravel with MySQL/MariaDB (most common)
946-
- `laravel-postgres`: Laravel with PostgreSQL (enterprise)
947-
- `laravel-sqlite`: Laravel with SQLite (development/testing)
948-
- `api-only`: API-only applications (minimal footprint)
949-
- `enterprise`: Full-featured Laravel with all extensions
956+
- **PHP Versions**: ${{ fromJSON(steps.get-versions.outputs.php_versions).join(', ') }}
957+
- **Configuration Options**:
958+
- `laravel-mysql`: Laravel applications using MySQL or MariaDB
959+
- `laravel-postgres`: Laravel applications using PostgreSQL
960+
- `laravel-sqlite`: Laravel applications using SQLite
961+
- `api-only`: Minimal footprint for API-only applications
962+
- `enterprise`: Full-featured configuration for enterprise applications
950963
- `wordpress`: WordPress optimized build
951964
- `full-stack`: Complete PHP build with major extensions and database drivers
952965

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ Modern development requires managing dependencies at multiple levels - from syst
8484

8585
[Read more about why we created Launchpad](https://github.com/stacksjs/launchpad/tree/main/docs/why.md)
8686

87+
## Development
88+
89+
### Scripts
90+
91+
Launchpad includes several utility scripts for development and maintenance:
92+
93+
#### Dynamic PHP Version Management
94+
```bash
95+
# Get latest PHP versions from ts-pkgx registry
96+
bun scripts/get-php-versions.ts
97+
98+
# This script:
99+
# - Fetches latest PHP versions dynamically
100+
# - Generates improved configuration descriptions
101+
# - Outputs JSON for GitHub Actions
102+
# - Creates markdown tables for documentation
103+
```
104+
87105
## Installation
88106

89107
Get started with Launchpad through your preferred package manager:

docs/.vitepress/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const sidebar = [
8080
{ text: 'Cross-platform Compatibility', link: '/advanced/cross-platform' },
8181
{ text: 'Performance Optimization', link: '/advanced/performance' },
8282
{ text: 'Cache Optimization', link: '/advanced/cache-optimization' },
83+
{ text: 'PHP Configuration', link: '/advanced/php-configuration' },
84+
{ text: 'Scripts', link: '/scripts' },
8385
],
8486
},
8587
{

docs/advanced/php-configuration.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ export LAUNCHPAD_PHP_VERSION=8.4.11 # PHP version
7878

7979
## Available Configurations
8080

81-
| Configuration | When Used | Includes |
82-
|---------------|-----------|----------|
83-
| `laravel-mysql` | Laravel + MySQL (default) | Core + MySQL drivers + web extensions |
84-
| `laravel-postgres` | Laravel + PostgreSQL | Core + PostgreSQL drivers + web extensions |
85-
| `laravel-sqlite` | Laravel + SQLite (dev) | Core + SQLite drivers + web extensions |
86-
| `api-only` | API-only applications | Minimal: CLI, FPM, basic web extensions |
87-
| `enterprise` | Enterprise features | All major extensions + all database drivers |
88-
| `wordpress` | WordPress applications | WordPress-specific extensions |
89-
| `full-stack` | **Complete flexibility** | **All extensions + all databases** |
81+
| Configuration | Description | Use Case | Database Support |
82+
|---------------|-------------|----------|------------------|
83+
| `laravel-mysql` | Laravel with MySQL/MariaDB | Laravel applications using MySQL or MariaDB | MySQL, MariaDB |
84+
| `laravel-postgres` | Laravel with PostgreSQL | Laravel applications using PostgreSQL | PostgreSQL |
85+
| `laravel-sqlite` | Laravel with SQLite | Laravel applications using SQLite (development) | SQLite |
86+
| `api-only` | API-only applications | Minimal footprint for API-only applications | MySQL |
87+
| `enterprise` | Enterprise applications | Full-featured configuration for enterprise applications | MySQL, PostgreSQL, SQLite |
88+
| `wordpress` | WordPress applications | WordPress optimized build | MySQL |
89+
| `full-stack` | Complete PHP build | Complete PHP build with major extensions and database drivers | MySQL, PostgreSQL, SQLite |
9090

9191
## Smart Auto-Detection
9292

docs/scripts.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Launchpad Scripts
2+
3+
This document describes the utility scripts available in the Launchpad project for development and maintenance tasks.
4+
5+
## Dynamic PHP Version Management
6+
7+
### `scripts/get-php-versions.ts`
8+
9+
A TypeScript script that dynamically fetches the latest PHP versions from the ts-pkgx registry and generates improved configuration descriptions.
10+
11+
#### Usage
12+
13+
```bash
14+
# Run the script to get latest PHP versions and configuration info
15+
bun scripts/get-php-versions.ts
16+
```
17+
18+
#### Features
19+
20+
- **Dynamic Version Fetching**: Retrieves the latest PHP versions from ts-pkgx registry
21+
- **Version Filtering**: Automatically filters to stable versions and sorts by version number
22+
- **Configuration Descriptions**: Generates improved descriptions for all PHP configurations
23+
- **Multiple Output Formats**:
24+
- Human-readable output for development
25+
- JSON output for GitHub Actions
26+
- Markdown tables for documentation
27+
28+
#### Output
29+
30+
The script provides three types of output:
31+
32+
1. **Human-readable summary**:
33+
```
34+
🔍 Dynamic PHP versions: 8.4.11, 8.3.24, 8.2.29, 8.1.32
35+
36+
📋 Configuration Descriptions:
37+
• laravel-mysql: Laravel with MySQL/MariaDB
38+
Use case: Laravel applications using MySQL or MariaDB
39+
Databases: MySQL, MariaDB
40+
```
41+
42+
2. **JSON for GitHub Actions**:
43+
```json
44+
["8.4.11","8.3.24","8.2.29","8.1.32"]
45+
```
46+
47+
3. **Markdown table for documentation**:
48+
```markdown
49+
| Configuration | Description | Use Case | Database Support |
50+
|---------------|-------------|----------|------------------|
51+
| `laravel-mysql` | Laravel with MySQL/MariaDB | Laravel applications using MySQL or MariaDB | MySQL, MariaDB |
52+
```
53+
54+
#### Configuration Descriptions
55+
56+
The script provides improved descriptions for all PHP configurations:
57+
58+
| Configuration | Description | Use Case | Database Support |
59+
|---------------|-------------|----------|------------------|
60+
| `laravel-mysql` | Laravel with MySQL/MariaDB | Laravel applications using MySQL or MariaDB | MySQL, MariaDB |
61+
| `laravel-postgres` | Laravel with PostgreSQL | Laravel applications using PostgreSQL | PostgreSQL |
62+
| `laravel-sqlite` | Laravel with SQLite | Laravel applications using SQLite (development) | SQLite |
63+
| `api-only` | API-only applications | Minimal footprint for API-only applications | MySQL |
64+
| `enterprise` | Enterprise applications | Full-featured configuration for enterprise applications | MySQL, PostgreSQL, SQLite |
65+
| `wordpress` | WordPress applications | WordPress optimized build | MySQL |
66+
| `full-stack` | Complete PHP build | Complete PHP build with major extensions and database drivers | MySQL, PostgreSQL, SQLite |
67+
68+
#### Integration with GitHub Actions
69+
70+
The script is integrated into the GitHub workflow for PHP binary compilation:
71+
72+
```yaml
73+
- name: Get PHP versions from ts-pkgx
74+
id: get-versions
75+
run: |
76+
# Get dynamic PHP versions using our custom script
77+
PHP_VERSIONS=$(bun scripts/get-php-versions.ts | grep "JSON output for GitHub Actions:" -A 1 | tail -1)
78+
echo "php_versions=$PHP_VERSIONS" >> $GITHUB_OUTPUT
79+
echo "🔍 Dynamic PHP versions: $PHP_VERSIONS"
80+
```
81+
82+
#### Error Handling
83+
84+
The script includes robust error handling:
85+
86+
- **Fallback Versions**: If ts-pkgx is unavailable, falls back to hardcoded versions
87+
- **Version Validation**: Filters out invalid version strings
88+
- **Sorting**: Automatically sorts versions by major.minor.patch
89+
- **Limit**: Keeps only the 4 most recent stable versions
90+
91+
#### Dependencies
92+
93+
- **Bun**: Required for execution
94+
- **ts-pkgx**: Used to fetch PHP versions from the registry
95+
- **child_process**: Used to execute external commands
96+
97+
## Contributing
98+
99+
When adding new scripts:
100+
101+
1. **Documentation**: Update this file with script description and usage
102+
2. **Error Handling**: Include proper error handling and fallbacks
103+
3. **Testing**: Test the script locally before committing
104+
4. **Integration**: Update relevant workflows or documentation if needed

scripts/get-php-versions.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#!/usr/bin/env bun
2+
3+
/**
4+
* Dynamic PHP Version Generator for Launchpad
5+
*
6+
* This script fetches the latest PHP versions from the ts-pkgx registry
7+
* and formats them for use in GitHub workflows and documentation.
8+
*/
9+
10+
interface PHPVersion {
11+
version: string;
12+
status: 'stable' | 'security' | 'eol';
13+
releaseDate?: string;
14+
}
15+
16+
interface ConfigDescription {
17+
name: string;
18+
description: string;
19+
useCase: string;
20+
databaseSupport: string[];
21+
extensions: string[];
22+
}
23+
24+
async function getPHPVersions(): Promise<string[]> {
25+
try {
26+
// Use ts-pkgx to get PHP versions
27+
const { execSync } = await import('child_process');
28+
const output = execSync('bunx ts-pkgx get-php-versions', { encoding: 'utf8' });
29+
30+
// Parse the output - assuming it returns a JSON array or comma-separated string
31+
let versions: string[];
32+
try {
33+
versions = JSON.parse(output);
34+
} catch {
35+
// If not JSON, split by comma
36+
versions = output.trim().split(',').map(v => v.trim());
37+
}
38+
39+
// Filter to only stable versions and sort by version
40+
const stableVersions = versions
41+
.filter(v => v.match(/^\d+\.\d+\.\d+$/))
42+
.sort((a, b) => {
43+
const [aMajor, aMinor, aPatch] = a.split('.').map(Number);
44+
const [bMajor, bMinor, bPatch] = b.split('.').map(Number);
45+
46+
if (aMajor !== bMajor) return bMajor - aMajor;
47+
if (aMinor !== bMinor) return bMinor - aMinor;
48+
return bPatch - aPatch;
49+
})
50+
.slice(0, 4); // Keep only the 4 most recent versions
51+
52+
return stableVersions;
53+
} catch (error) {
54+
console.error('Failed to fetch PHP versions from ts-pkgx:', error);
55+
56+
// Fallback to hardcoded versions
57+
return ['8.4.11', '8.3.14', '8.2.26', '8.1.30'];
58+
}
59+
}
60+
61+
function getConfigDescriptions(): ConfigDescription[] {
62+
return [
63+
{
64+
name: 'laravel-mysql',
65+
description: 'Laravel with MySQL/MariaDB',
66+
useCase: 'Laravel applications using MySQL or MariaDB',
67+
databaseSupport: ['MySQL', 'MariaDB'],
68+
extensions: ['PDO MySQL', 'MySQLi', 'GD', 'cURL', 'OpenSSL', 'ZIP', 'XML', 'Zlib']
69+
},
70+
{
71+
name: 'laravel-postgres',
72+
description: 'Laravel with PostgreSQL',
73+
useCase: 'Laravel applications using PostgreSQL',
74+
databaseSupport: ['PostgreSQL'],
75+
extensions: ['PDO PostgreSQL', 'PostgreSQL', 'GD', 'cURL', 'OpenSSL', 'ZIP', 'XML', 'Zlib']
76+
},
77+
{
78+
name: 'laravel-sqlite',
79+
description: 'Laravel with SQLite',
80+
useCase: 'Laravel applications using SQLite (development)',
81+
databaseSupport: ['SQLite'],
82+
extensions: ['PDO SQLite', 'SQLite3', 'GD', 'cURL', 'OpenSSL', 'ZIP', 'XML', 'Zlib']
83+
},
84+
{
85+
name: 'api-only',
86+
description: 'API-only applications',
87+
useCase: 'Minimal footprint for API-only applications',
88+
databaseSupport: ['MySQL'],
89+
extensions: ['PDO MySQL', 'MySQLi', 'cURL', 'OpenSSL', 'ZIP', 'XML', 'Zlib']
90+
},
91+
{
92+
name: 'enterprise',
93+
description: 'Enterprise applications',
94+
useCase: 'Full-featured configuration for enterprise applications',
95+
databaseSupport: ['MySQL', 'PostgreSQL', 'SQLite'],
96+
extensions: ['All PDO drivers', 'All database drivers', 'GD', 'SOAP', 'Sockets', 'LDAP', 'XSL', 'Sodium', 'GMP', 'Gettext']
97+
},
98+
{
99+
name: 'wordpress',
100+
description: 'WordPress applications',
101+
useCase: 'WordPress optimized build',
102+
databaseSupport: ['MySQL'],
103+
extensions: ['PDO MySQL', 'MySQLi', 'GD', 'cURL', 'OpenSSL', 'ZIP', 'XML', 'Zlib']
104+
},
105+
{
106+
name: 'full-stack',
107+
description: 'Complete PHP build',
108+
useCase: 'Complete PHP build with major extensions and database drivers',
109+
databaseSupport: ['MySQL', 'PostgreSQL', 'SQLite'],
110+
extensions: ['All major extensions', 'All database drivers', 'Calendar', 'FTP', 'SOAP', 'Sockets', 'LDAP', 'XSL', 'Sodium', 'GMP', 'Gettext', 'Fileinfo', 'JSON', 'PHAR', 'Filter', 'Hash', 'Session', 'Tokenizer', 'CTYPE', 'DOM', 'SimpleXML', 'XML', 'XMLReader', 'XMLWriter', 'SHMOP']
111+
}
112+
];
113+
}
114+
115+
function generateWorkflowOutput(versions: string[], configs: ConfigDescription[]): void {
116+
console.log('🔍 Dynamic PHP versions:', versions.join(', '));
117+
console.log('');
118+
console.log('📋 Configuration Descriptions:');
119+
configs.forEach(config => {
120+
console.log(` • ${config.name}: ${config.description}`);
121+
console.log(` Use case: ${config.useCase}`);
122+
console.log(` Databases: ${config.databaseSupport.join(', ')}`);
123+
console.log('');
124+
});
125+
}
126+
127+
function generateMarkdownTable(configs: ConfigDescription[]): string {
128+
let table = '| Configuration | Description | Use Case | Database Support |\n';
129+
table += '|---------------|-------------|----------|------------------|\n';
130+
131+
configs.forEach(config => {
132+
const description = config.description.replace(/\|/g, '\\|');
133+
const useCase = config.useCase.replace(/\|/g, '\\|');
134+
const databases = config.databaseSupport.join(', ').replace(/\|/g, '\\|');
135+
table += `| \`${config.name}\` | ${description} | ${useCase} | ${databases} |\n`;
136+
});
137+
138+
return table;
139+
}
140+
141+
async function main(): Promise<void> {
142+
const versions = await getPHPVersions();
143+
const configs = getConfigDescriptions();
144+
145+
// Generate workflow output
146+
generateWorkflowOutput(versions, configs);
147+
148+
// Output versions as JSON for GitHub Actions
149+
console.log('JSON output for GitHub Actions:');
150+
console.log(JSON.stringify(versions));
151+
152+
// Generate markdown table
153+
console.log('\nMarkdown table for documentation:');
154+
console.log(generateMarkdownTable(configs));
155+
}
156+
157+
// Run the script
158+
if (import.meta.main) {
159+
main().catch(console.error);
160+
}
161+
162+
export { getPHPVersions, getConfigDescriptions, generateMarkdownTable };

0 commit comments

Comments
 (0)