mirror of
https://github.com/opdavies/build-configs.git
synced 2025-03-13 05:26:56 +00:00
feat: add support for Astro projects
This commit is contained in:
parent
022315edd3
commit
cd4355bbc1
|
@ -7,6 +7,7 @@ namespace App\Action;
|
||||||
use App\DataTransferObject\Config;
|
use App\DataTransferObject\Config;
|
||||||
use App\DataTransferObject\TemplateFile;
|
use App\DataTransferObject\TemplateFile;
|
||||||
use App\Enum\Language;
|
use App\Enum\Language;
|
||||||
|
use App\Enum\ProjectType;
|
||||||
use App\Enum\WebServer;
|
use App\Enum\WebServer;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
@ -21,12 +22,32 @@ final class CreateListOfFilesToGenerate
|
||||||
*/
|
*/
|
||||||
[$configurationData, $configurationDataDto] = $configurationDataAndDto;
|
[$configurationData, $configurationDataDto] = $configurationDataAndDto;
|
||||||
|
|
||||||
$isDocker = static::isDocker($configurationData);
|
|
||||||
$isFlake = static::isFlake($configurationData);
|
|
||||||
|
|
||||||
/** @var Collection<int, TemplateFile> */
|
/** @var Collection<int, TemplateFile> */
|
||||||
$filesToGenerate = collect();
|
$filesToGenerate = collect();
|
||||||
|
|
||||||
|
switch (strtolower($configurationDataDto->type)) {
|
||||||
|
case (strtolower(ProjectType::Astro->name)):
|
||||||
|
$filesToGenerate = collect([
|
||||||
|
['astro/.envrc', '.envrc'],
|
||||||
|
['astro/flake.nix', 'flake.nix'],
|
||||||
|
['astro/tsconfig.json', 'tsconfig.json'],
|
||||||
|
])->map(function (array $file) {
|
||||||
|
return new TemplateFile(
|
||||||
|
data: $file[0],
|
||||||
|
name: $file[1],
|
||||||
|
path: null,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filesToGenerate->isNotEmpty()) {
|
||||||
|
return $next([$configurationData, $configurationDataDto, $filesToGenerate]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$isDocker = static::isDocker($configurationData);
|
||||||
|
$isFlake = static::isFlake($configurationData);
|
||||||
|
|
||||||
if ($isDocker) {
|
if ($isDocker) {
|
||||||
$filesToGenerate->push(new TemplateFile(data: 'common/.dockerignore', name: '.dockerignore'));
|
$filesToGenerate->push(new TemplateFile(data: 'common/.dockerignore', name: '.dockerignore'));
|
||||||
$filesToGenerate->push(new TemplateFile(data: 'common/.hadolint.yaml', name: '.hadolint.yaml'));
|
$filesToGenerate->push(new TemplateFile(data: 'common/.hadolint.yaml', name: '.hadolint.yaml'));
|
||||||
|
|
|
@ -54,7 +54,7 @@ final class Config
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
public string $name;
|
public string $name;
|
||||||
|
|
||||||
#[Assert\Choice(choices: ['drupal', 'fractal', 'laravel', 'php-library', 'vuejs'])]
|
#[Assert\Choice(choices: ['astro', 'drupal', 'fractal', 'laravel', 'php-library', 'vuejs'])]
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
public string $type;
|
public string $type;
|
||||||
|
|
||||||
|
|
10
src/Enum/ProjectType.php
Normal file
10
src/Enum/ProjectType.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Enum;
|
||||||
|
|
||||||
|
enum ProjectType
|
||||||
|
{
|
||||||
|
case Astro;
|
||||||
|
}
|
3
templates/astro/.envrc.twig
Normal file
3
templates/astro/.envrc.twig
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# {{ managedText|raw }}
|
||||||
|
|
||||||
|
use flake
|
25
templates/astro/flake.nix.twig
Normal file
25
templates/astro/flake.nix.twig
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# {{ managedText|raw }}
|
||||||
|
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
devshell.url = "github:numtide/devshell";
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = inputs@{ flake-parts, ... }:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
imports = [ inputs.devshell.flakeModule ];
|
||||||
|
|
||||||
|
systems = [ "x86_64-linux" ];
|
||||||
|
|
||||||
|
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||||
|
devshells.default = {
|
||||||
|
packages = with pkgs; [
|
||||||
|
{% for package in flake.devshell.packages %}
|
||||||
|
"{{ package }}"
|
||||||
|
{% endfor %}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
12
templates/astro/tsconfig.json.twig
Normal file
12
templates/astro/tsconfig.json.twig
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// {{ managedText }}
|
||||||
|
|
||||||
|
{
|
||||||
|
"extends": "astro/tsconfigs/strict",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["src/*"]
|
||||||
|
},
|
||||||
|
"strictNullChecks": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue