summaryrefslogtreecommitdiff
path: root/build/main.php
blob: 0446be3893f562988ab2e4d842978e9141132734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

declare(strict_types=1);

use Symfony\Component\VarExporter\VarExporter;

require_once __DIR__.'/vendor/autoload.php';

$path = __DIR__.'/../data/products.php';
$products = Strip::product(require $path);

$contents = sprintf('<?php return %s;'.PHP_EOL, VarExporter::export($products));
if (file_put_contents($path, $contents, LOCK_EX) === false) {
    throw new \RuntimeException(sprintf('Failed to write file "%s".', $path));
}

foreach ($products as $product) {
    foreach ($product['versions'] as $version) {
        printf('==> Processing %s %s'.PHP_EOL, $product['code'], $version);

        $apiDocsPath = sprintf('%s/%s/%s/api-docs.php', __DIR__.'/../data', $product['code'], $version);
        $apiDocs = Strip::apiDocs(require $apiDocsPath);

        $contents = sprintf('<?php return %s;'.PHP_EOL, VarExporter::export($apiDocs));
        if (file_put_contents($apiDocsPath, $contents, LOCK_EX) === false) {
            throw new \RuntimeException(sprintf('Failed to write file "%s".', $apiDocsPath));
        }
    }
}

printf('==> Done!'.PHP_EOL);