diff options
| author | Zhineng Li <[email protected]> | 2026-02-14 10:08:30 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-02-14 10:08:30 +0800 |
| commit | eccd5cd5a067f5659982685afdeea209b1888efb (patch) | |
| tree | 1626c903b854317be1708ce3ccd3b4f4e6e0fc97 /build/main.php | |
| download | acs-metadata-main.tar.gz acs-metadata-main.zip | |
first commitHEADv1.0.0+20260212main
Diffstat (limited to 'build/main.php')
| -rw-r--r-- | build/main.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/build/main.php b/build/main.php new file mode 100644 index 0000000..0446be3 --- /dev/null +++ b/build/main.php @@ -0,0 +1,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); |
