Skip to content

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Sep 9, 2025

Q A
Bug fix? no
New feature? yes
Docs? no
Issues Fix #...
License MIT

I needed to reference a npm dependency while writing on new recipes for the Shadcn kit:

Capture d’écran 2025-09-09 à 22 00 36

This pull request standardizes the way dependencies are defined across multiple manifest.json files for shadcn UI kits and updates the schema to support more flexible dependency definitions. It also introduces validation for NPM package names in the codebase.

Manifest and Schema Standardization:

  • Updated all shadcn kit manifest.json files to use a name and optional version field for PHP dependencies instead of a single package field. This change improves consistency and clarity in dependency definitions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
  • Enhanced the schema-kit-recipe-v1.json schema to:
    • Require name instead of package for PHP dependencies.
    • Add support for NPM and Importmap dependencies, each with their own required fields and validation.

Validation Improvements:

  • Added a new Assert::npmPackageName method to validate NPM package names, ensuring only valid names are accepted when defining NPM dependencies.

@Kocal Kocal self-assigned this Sep 9, 2025
@carsonbot carsonbot added Feature New Feature Toolkit Status: Needs Review Needs to be reviewed labels Sep 9, 2025
@Kocal Kocal requested a review from Copilot September 9, 2025 07:51
Copilot

This comment was marked as outdated.

@Kocal Kocal force-pushed the toolkit-importmap-and-npm-dependencies branch 4 times, most recently from 33b6f00 to 9d8d870 Compare September 9, 2025 16:15
@Kocal Kocal force-pushed the toolkit-importmap-and-npm-dependencies branch from 9d8d870 to f783a4f Compare September 9, 2025 20:00
@Kocal Kocal requested a review from Copilot September 9, 2025 20:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for NPM and importmap package dependencies in the Symfony UX Toolkit. The main purpose is to standardize dependency definitions across manifest files and enable frontend package management alongside existing PHP package dependencies.

  • Standardizes dependency format from a package field containing name and version to separate name and version fields for PHP dependencies
  • Adds new dependency types for NPM and importmap packages with appropriate validation
  • Updates installation and documentation generation to handle all three dependency types

Reviewed Changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Multiple shadcn manifest.json files Updated PHP dependency format to use separate name and version fields
schema-kit-recipe-v1.json Added schema definitions for NPM and importmap dependency types
src/Toolkit/src/Dependency/ Added new dependency classes for NPM and importmap packages
src/Toolkit/src/Assert.php Added NPM package name validation
src/Toolkit/src/Recipe/RecipeManifest.php Updated parsing logic to handle all dependency types
Pool/PoolResolver classes Extended to manage NPM and importmap dependencies
Command classes Enhanced output to display all dependency types
Test files Added comprehensive test coverage for new functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -59,7 +59,7 @@ public function getContent(): string
$this->component->manifest->description,
current($examples),
$this->toolkitService->renderInstallationSteps($this->kitId, $this->component),
dump(preg_replace('/^```twig.*\n/', '```twig'.\PHP_EOL, current($examples))),
preg_replace('/^```twig.*\n/', '```twig'.\PHP_EOL, current($examples)),
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the dump() call is correct, but this code will fail if $examples is empty since current() will return false. Consider adding a null coalesce operator or checking if $examples is not empty before calling current().

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but we assume we will always have one example

Comment on lines +66 to 67
if (isset($this->phpPackageDependencies[$dependency->name]) && !$dependency->isHigherThan($this->phpPackageDependencies[$dependency->name])) {
return;
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic has been inverted but this creates a bug. Previously, packages were updated when the new version was higher. Now they're only updated when the new version is NOT higher, which means lower versions will overwrite higher versions. The condition should be $dependency->isHigherThan($this->phpPackageDependencies[$dependency->name]) without the negation.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's correct

return new self(
type: $type,
name: $data['name'] ?? throw new \InvalidArgumentException('Property "name" is required.'),
description: $data['description'] ?? throw new \InvalidArgumentException('Property "description" is required.'),
copyFiles: $data['copy-files'] ?? throw new \InvalidArgumentException('Property "copy-files" is required.'),
copyFiles: $data['copy-files'] ?? [],
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making copy-files optional by defaulting to an empty array is a breaking change. The previous behavior required this field, and tests indicate this was intentional. Consider reverting this change to maintain backward compatibility, or update the schema and documentation if this change is intentional.

Copilot uses AI. Check for mistakes.

@Kocal Kocal merged commit 24becab into symfony:2.x Sep 9, 2025
27 of 29 checks passed
@Kocal Kocal deleted the toolkit-importmap-and-npm-dependencies branch September 9, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed Toolkit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants