commit14
This commit is contained in:
@@ -6,11 +6,12 @@ use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Tempo\Purchasing\Delivery\Installation;
|
||||
use Tempo\Purchasing\Delivery\SqlPrivileges;
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$action = $argv[1] ?? '';
|
||||
$host = realpath($argv[2] ?? '');
|
||||
if (! in_array($action, ['plan', 'migrate'], true) || ! $host) {
|
||||
if (! in_array($action, ['plan', 'migrate', 'privileges-plan'], true) || ! $host) {
|
||||
fwrite(STDERR, "Usage: plan <host> | migrate <host> <target-sha> <backup-file> <backup-sha> <operator> <manifest-sha>\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ try {
|
||||
throw new RuntimeException('Manifesto de preparação operacional obrigatório.');
|
||||
}
|
||||
foreach ($manifest['support_files'] as $file => $hash) {
|
||||
if (($file !== 'bootstrap.php' && ! preg_match('~^(app|packages|integrations|scripts)/[A-Za-z0-9_./-]+$~D', $file)) || str_contains($file, '..') || is_link($root.'/'.$file) || ! hash_equals($hash, hash_file('sha256', $root.'/'.$file))) {
|
||||
if (($file !== 'bootstrap.php' && ! preg_match('~^((app|packages|integrations|scripts)/[A-Za-z0-9_./-]+|resources/js/(app|PurchasingHome)\.jsx|public/build/manifest\.json)$~D', $file)) || str_contains($file, '..') || is_link($root.'/'.$file) || ! hash_equals($hash, hash_file('sha256', $root.'/'.$file))) {
|
||||
throw new RuntimeException('Integridade da entrega divergente.');
|
||||
}
|
||||
}
|
||||
@@ -36,7 +37,9 @@ try {
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
require $root.'/integrations/sgf/operational/bootstrap.php';
|
||||
$db = DB::connection();
|
||||
if ($action === 'plan') {
|
||||
if ($action === 'privileges-plan') {
|
||||
echo json_encode(SqlPrivileges::plan($argv[3] ?? ''), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)."\n";
|
||||
} elseif ($action === 'plan') {
|
||||
echo json_encode(['target_sha256' => Installation::target($db), 'manifest_sha256' => hash('sha256', $manifestText), 'schema_prepared' => $db->getSchemaBuilder()->hasTable('sgc_installations'), 'activated' => false], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)."\n";
|
||||
} else {
|
||||
$backup = $argv[4] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user