Skip to content

Commit ef7e645

Browse files
Vitexusclaude
andcommitted
fix: write composer.json name into autoload.php at build time, no runtime file I/O
Replace runtime json_decode(file_get_contents()) fallback with a build-time sed injection: debian/rules replaces the 'unknown' placeholder with the PKG_SOURCE value (jq .name from composer.json), keeping full compatibility with composer package naming conventions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 75a858c commit ef7e645

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

debian/autoload.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
foreach (\Composer\InstalledVersions::getAllRawData() as $d) {
3030
$versions = array_merge($versions, $d['versions'] ?? []);
3131
}
32-
$_cj = @json_decode(@file_get_contents(__DIR__ . '/composer.json'), true);
33-
$name = defined('APP_NAME') ? APP_NAME : ($_cj['name'] ?? basename(__DIR__));
32+
$name = defined('APP_NAME') ? APP_NAME : 'unknown';
3433
$version = defined('APP_VERSION') ? APP_VERSION : '0.0.0';
3534
$versions[$name] = ['pretty_version' => $version, 'version' => $version,
3635
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,

debian/rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ override_dh_install:
2222
dh_install
2323
sed -i "1a defined('APP_NAME') || define('APP_NAME', '$(PKG_SOURCE)');" \
2424
debian/php-vitexsoftware-ease-bootstrap5-widgets/usr/share/php/EaseTWB5Widgets/autoload.php
25+
sed -i "s|: 'unknown'|: '$(PKG_SOURCE)'|" \\
26+
debian/php-vitexsoftware-ease-bootstrap5-widgets/usr/share/php/EaseTWB5Widgets/autoload.php
2527
sed -i "2a defined('APP_VERSION') || define('APP_VERSION', '$(PKG_VERSION)');" \
2628
debian/php-vitexsoftware-ease-bootstrap5-widgets/usr/share/php/EaseTWB5Widgets/autoload.php
2729
sed -e "/includeCss/c\ \$$this->includeCss(\'\/javascript\/bootstrap5\/css\/bootstrap5-toggle.min.css\');" -i debian/php-vitexsoftware-ease-bootstrap5-widgets/usr/share/php/EaseTWB5Widgets/Toggle.php

0 commit comments

Comments
 (0)