Add initial command, get values from build.yaml

This commit is contained in:
Oliver Davies 2023-01-19 18:11:24 +00:00
parent cc9a65ba96
commit c476543f5c
4 changed files with 124 additions and 3 deletions

View file

@ -1,8 +1,14 @@
<?php
use OliverDaviesLtd\BuildConfiguration\Console\Command\BuildConfigurationCommand;
use Symfony\Component\Console\Application;
require __DIR__ . '/vendor/autoload.php';
$app = new Application();
$app->addCommands([
new BuildConfigurationCommand(),
]);
$app->run();

View file

@ -1,9 +1,16 @@
{
"require": {
"twig/twig": "^3.5",
"symfony/console": "^6.2"
"symfony/console": "^6.2",
"symfony/yaml": "^6.2"
},
"require-dev": {
"humbug/box": "^4.2"
"humbug/box": "^4.2",
"symfony/var-dumper": "^6.2"
},
"autoload": {
"psr-4": {
"OliverDaviesLtd\\BuildConfiguration\\": "src/"
}
}
}

76
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "33bee317bc6e480792bb6770639a652b",
"content-hash": "10bdf6712c1d4ee4e01f212c41080a07",
"packages": [
{
"name": "psr/container",
@ -723,6 +723,80 @@
],
"time": "2022-12-14T16:11:27+00:00"
},
{
"name": "symfony/yaml",
"version": "v6.2.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3",
"reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony/console": "<5.4"
},
"require-dev": {
"symfony/console": "^5.4|^6.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"bin": [
"Resources/bin/yaml-lint"
],
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v6.2.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-12-14T16:11:27+00:00"
},
{
"name": "twig/twig",
"version": "v3.5.0",

View file

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace OliverDaviesLtd\BuildConfiguration\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Yaml;
#[AsCommand(
description: 'Build configuration files',
name: 'build-configuration'
)]
final class BuildConfigurationCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output)
{
// Find a build.yaml file.
$buildYaml = Yaml::parseFile(getcwd().'/build.yaml');
$io = new SymfonyStyle($input, $output);
$io->info("Building configuration for {$buildYaml['name']}.");
// Parse its contents.
// Generate the appropriate configuration files.
//
return Command::SUCCESS;
}
}