Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Toolkit/kits/shadcn/Alert/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
"dependencies": [
{
"type": "php",
"package": "twig/extra-bundle"
"name": "twig/extra-bundle"
},
{
"type": "php",
"package": "twig/html-extra:^3.12.0"
"name": "twig/html-extra",
"version": "^3.12.0"
},
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/AspectRatio/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "twig/extra-bundle"
"name": "twig/extra-bundle"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Avatar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
7 changes: 4 additions & 3 deletions src/Toolkit/kits/shadcn/Badge/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
"dependencies": [
{
"type": "php",
"package": "twig/extra-bundle"
"name": "twig/extra-bundle"
},
{
"type": "php",
"package": "twig/html-extra:^3.12.0"
"name": "twig/html-extra",
"version": "^3.12.0"
},
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Breadcrumb/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
7 changes: 4 additions & 3 deletions src/Toolkit/kits/shadcn/Button/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
"dependencies": [
{
"type": "php",
"package": "twig/extra-bundle"
"name": "twig/extra-bundle"
},
{
"type": "php",
"package": "twig/html-extra:^3.12.0"
"name": "twig/html-extra",
"version": "^3.12.0"
},
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Card/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Checkbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Input/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Label/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Pagination/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Progress/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Select/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
7 changes: 4 additions & 3 deletions src/Toolkit/kits/shadcn/Separator/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
"dependencies": [
{
"type": "php",
"package": "twig/extra-bundle"
"name": "twig/extra-bundle"
},
{
"type": "php",
"package": "twig/html-extra:^3.12.0"
"name": "twig/html-extra",
"version": "^3.12.0"
},
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Skeleton/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Switch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Table/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/Textarea/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": [
{
"type": "php",
"package": "tales-from-a-dev/twig-tailwind-extra"
"name": "tales-from-a-dev/twig-tailwind-extra"
}
]
}
42 changes: 40 additions & 2 deletions src/Toolkit/schema-kit-recipe-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,53 @@
{
"description": "A dependency on a PHP package",
"type": "object",
"required": ["type", "package"],
"required": ["type", "name"],
"properties": {
"type": {
"type": "string",
"enum": ["php"]
},
"name": {
"type": "string",
"description": "Package name and optional version constraint (e.g., 'vendor/package')"
},
"version": {
"type": "string",
"description": "Optional version constraint (e.g., '^1.0')"
}
}
},
{
"description": "A dependency on an NPM package",
"type": "object",
"required": ["type", "name"],
"properties": {
"type": {
"type": "string",
"enum": ["npm"]
},
"name": {
"type": "string",
"description": "Package name and optional version constraint (e.g., 'vendor/package')"
},
"version": {
"type": "string",
"description": "Optional version constraint (e.g., '^1.0')"
}
}
},
{
"description": "A dependency on an Importmap package",
"type": "object",
"required": ["type", "package"],
"properties": {
"type": {
"type": "string",
"enum": ["importmap"]
},
"package": {
"type": "string",
"description": "Package name and optional version constraint (e.g., 'vendor/package:^1.0')"
"description": "Importmap package name (e.g., 'lodash', 'bootstrap/dist/css/bootstrap.min.css')"
}
}
},
Expand Down
15 changes: 15 additions & 0 deletions src/Toolkit/src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,19 @@ public static function phpPackageName(string $name): void
throw new \InvalidArgumentException(\sprintf('Invalid PHP package name "%s".', $name));
}
}

/**
* Assert that the NPM package name is valid (ex: "react", "@hotwired/stimulus", etc.).
*
* @param non-empty-string $name
*
* @throws \InvalidArgumentException if the NPM package name is invalid
*/
public static function npmPackageName(string $name): void
{
// Taken from https://github.com/dword-design/package-name-regex/blob/master/src/index.ts
if (1 !== preg_match('/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/', $name)) {
throw new \InvalidArgumentException(\sprintf('Invalid NPM package name "%s".', $name));
}
}
}
4 changes: 2 additions & 2 deletions src/Toolkit/src/Command/DebugKitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'Dependencies',
])
->addRow([
implode("\n", iterator_to_array($recipe->getFiles())),
implode("\n", $recipe->manifest->dependencies),
implode("\n", iterator_to_array($recipe->getFiles())) ?: 'N/A',
implode("\n", $recipe->manifest->dependencies) ?: 'N/A',
])
->setColumnWidth(1, 80)
->setColumnMaxWidth(1, 80)
Expand Down
33 changes: 31 additions & 2 deletions src/Toolkit/src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,40 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$this->io->success('The recipe has been installed.');
$this->io->writeln('The following file(s) have been added to your project:');

$this->io->section('Installed files');
$this->io->listing(array_map(fn (File $file) => Path::join($destinationPath, $file->sourceRelativePathName), $installationReport->newFiles));

if ([] !== $installationReport->suggestedPhpPackages || [] !== $installationReport->suggestedNpmPackages || [] !== $installationReport->suggestedImportmapPackages) {
$this->io->section('Next steps');
}

$stepIndex = 0;
if ([] !== $installationReport->suggestedPhpPackages) {
$this->io->writeln(\sprintf('Run <info>composer require %s</> to install the required PHP dependencies.', implode(' ', $installationReport->suggestedPhpPackages)));
$this->io->writeln(++$stepIndex.'. Install suggested PHP package(s) with the command:');
$this->io->newLine();
$this->io->writeln(\sprintf(' $ <info>composer require %s</>', implode(' ', $installationReport->suggestedPhpPackages)));
$this->io->newLine();
}

if ([] !== $installationReport->suggestedNpmPackages && [] !== $installationReport->suggestedImportmapPackages) {
$this->io->writeln(++$stepIndex.'. Install suggested front-end packages with one of the following commands:');
$this->io->newLine();
$this->io->writeln(' # with npm/pnpm/yarn');
$this->io->writeln(\sprintf(' $ <info>npm install --save %s</>', implode(' ', $installationReport->suggestedNpmPackages)));
$this->io->newLine();
$this->io->writeln(' # or with Importmap');
$this->io->writeln(\sprintf(' $ <info>php bin/console importmap:install %s</>', implode(' ', $installationReport->suggestedImportmapPackages)));
$this->io->newLine();
} elseif ([] !== $installationReport->suggestedNpmPackages) {
$this->io->writeln(++$stepIndex.'. Install suggested front-end package(s) with the command:');
$this->io->newLine();
$this->io->writeln(\sprintf(' $ <info>npm install --save %s</>', implode(' ', $installationReport->suggestedNpmPackages)));
$this->io->newLine();
} elseif ([] !== $installationReport->suggestedImportmapPackages) {
$this->io->writeln(++$stepIndex.'. Install suggested front-end package(s) with the command:');
$this->io->newLine();
$this->io->writeln(\sprintf(' $ <info>php bin/console importmap:install %s</>', implode(' ', $installationReport->suggestedImportmapPackages)));
$this->io->newLine();
}

Expand Down
49 changes: 49 additions & 0 deletions src/Toolkit/src/Dependency/ImportmapPackageDependency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\UX\Toolkit\Dependency;

/**
* Represents a dependency on an Importmap package.
*
* @internal
*
* @author Hugo Alliaume <hugo@alliau.me>
*/
final class ImportmapPackageDependency implements DependencyInterface
{
/**
* @param non-empty-string $package
*/
public function __construct(
public readonly string $package,
) {
}

public function isEquivalentTo(DependencyInterface $dependency): bool
{
if (!$dependency instanceof self) {
return false;
}

return $this->package === $dependency->package;
}

public function toDebug(): string
{
return \sprintf('Importmap package "%s"', $this->package);
}

public function __toString(): string
{
return $this->package;
}
}
Loading
Loading