Skip to content

Instantly share code, notes, and snippets.

@GromNaN GromNaN/build.sh
Last active Jul 11, 2019

Embed
What would you like to do?
Split Composer Satis repositories into smaller packages
#!/bin/sh
# For each sub-package, run the Satis build command.
php bin/satis build repositories-mirrors.json ./web/mirrors
php bin/satis build repositories-pear.json ./web/pear
php bin/satis build repositoriesp-rojects.json ./web/projects
# Merge all the package files.
php web/packages.php > web/packages.json
<?php
// File located in web/packages.php
require __DIR__.'/../vendor/autoload.php';
$dirs = array(
'mirrors',
'pear',
'projects',
);
$packages = array(
'packages' => array(),
'includes' => array(),
);
foreach ($dirs as $dir) {
$file = __DIR__.'/'.$dir.'/packages.json';
if (!file_exists($file)) {
fwrite(STDERR, "File $file does not exist.\n");
$packages['includes'][$dir.'/packages.json'] = new stdClass;
continue;
}
$data = json_decode(file_get_contents($file), true);
foreach ($data['includes'] as $key => $value) {
$packages['includes'][$dir.'/'.$key] = $value;
}
}
header('Content-Type: text/plain');
echo Composer\Json\JsonFormatter::format(json_encode($packages), false, true);
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.