Skip to content

Commit

Permalink
default stub for BOX Manifest v4
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Oct 3, 2024
1 parent 8ef6bd3 commit fdc8851
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ sbom.xml
sbom.cdx.json
sbom.cdx.xml
custom.bin
stub.php

###### PHPLint ######
.phplint-cache
Expand Down
36 changes: 36 additions & 0 deletions stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

// default stub template @generated by BOX Manifest 4.x-dev@05f7f1a

$withManifest = array_search('--manifest', $argv);
$withoutAnsi = array_search('--no-ansi', $argv);

if ($withManifest !== false) {
$manifestDir = '.box.manifests/';
$resources = (($argc - 1 > $withManifest) && !str_starts_with($argv[$withManifest + 1], '-')) ? [$argv[$withManifest + 1]] : ['console-table.txt', 'plain.txt', 'sbom.json'];

foreach ($resources as $resource) {
$res = str_replace($manifestDir, '', $resource);
$filename = "phar://" . __FILE__ . "/$manifestDir$res";
if (file_exists($filename)) {
$manifest = file_get_contents($filename);
if ($withoutAnsi !== false) {
$manifest = preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $manifest);
}
echo $manifest, PHP_EOL;
exit(0);
} elseif (count($resources) === 1) {
echo sprintf('Manifest "%s" is not available in this PHP Archive.', $resource), PHP_EOL;
exit(2);
}
}
echo 'No manifest found in this PHP Archive', PHP_EOL;
exit(1);
}



// No PHAR config

__HALT_COMPILER(); ?>

0 comments on commit fdc8851

Please sign in to comment.