diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4192319..e01fbbeba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to `ichava/icon-sets-extras` follow [Keep a Changelog](https ### Changed +- **This pack requires `ichava/core` and nothing else.** `composer.json` `require` is now `php` and `ichava/core`; `illuminate/support` and `laranail/package-tools` were dropped from it and still arrive through core. The provider extends core's `IconPackServiceProvider` and declares its constants class and component class, so `src/` imports no `laranail/*` namespace; it registers the same name, path, Blade component and icon directory as before. The composer `type` is `ichava-icon-set`, which core's pack discovery reads. The README and `docs/installation.md` no longer restate the `laranail/*` repositories: they link to core's installation guide, the one place that lists them, and no longer say the pack is on Packagist, which no Ichava package is yet. `tests/Unit/CoreOnlyDependencyTest.php` fails if any of it comes back. - **The hand-supplied licences of `ant-design`, `eva` and `pepicons` are marked with a `source.md`** beside each `LICENSE`, recording the upstream file, ref and SHA-256. Their npm packages ship no licence file, so without the marker a real sync would delete those directories. The upstream sync runs icon-sets-sync `cbebf08` (icon-sets-sync#89), up from `06b17d7`, the first commit whose licence sink accepts the lowercase marker. `SetLicenceTest` fails if a marker or a text goes missing. - **Licence files carry upstream's names, so the first sync of each set rewrites nothing** (icon-sets-sync#88). Game Icons' text is `licenses/game-icons/license.txt`, Zendesk Garden's and Siemens iX's are `LICENSE.md`, and SVG Logos' is `LICENSE.txt`, as their upstreams ship them; they had been renamed to `LICENSE`, which a sync would have written back under the upstream name. The bytes, and so the recorded SHA-256s, are unchanged. - **Radix Icons records `0.0.17` at `upstream.sets.radix-icons.current_version`**, the `website@0.0.17` archive tag the recipe fetches and stamps, instead of `1.3.2`, the version of `packages/radix-icons` inside that tag (still named in `ref`). With `1.3.2` recorded, the sync would have compared the wrong number with upstream's tags and rewritten the field on its first run. diff --git a/README.md b/README.md index e1f088ba7..b63b53de7 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,7 @@ Requires [`ichava/core`](https://github.com/ichava/core) `^0.1` on PHP `^8.4.1 | ## Install -`ichava/core` and this pack come from Packagist. The `laranail/*` packages core depends on are not on Packagist yet, so the **application's** `composer.json` names them: - -```json -{ - "repositories": [ - { "type": "vcs", "url": "https://github.com/laranail/package-tools" }, - { "type": "vcs", "url": "https://github.com/laranail/console" }, - { "type": "vcs", "url": "https://github.com/laranail/enumerator" }, - { "type": "vcs", "url": "https://github.com/laranail/db-tools" } - ] -} -``` +This pack requires [`ichava/core`](https://github.com/ichava/core) and nothing else. Nothing in the Ichava family is on Packagist yet, so the **application's** `composer.json` first names the repositories: core's [installation guide](https://github.com/ichava/core/blob/main/docs/installation.md#1-point-composer-at-the-repositories) holds the one block that lists them, core's dependencies included, and this pack's line in it is `https://github.com/ichava/icon-sets-extras`. Then require the pack: diff --git a/composer.json b/composer.json index 5906d9ed4..b065b8079 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ichava/icon-sets-extras", "description": "43,561 SVGs from 20 open-licence icon, logo and emoji sets (MIT, Apache-2.0, CC0, CC BY), one directory per set, for Laravel 13 on the Ichava icon ecosystem.", - "type": "library", + "type": "ichava-icon-set", "keywords": [ "laravel", "blade", @@ -23,9 +23,7 @@ ], "require": { "php": "^8.4.1 || ^8.5", - "illuminate/support": "^13.0", - "ichava/core": "^0.1", - "laranail/package-tools": "^0.1.0" + "ichava/core": "^0.1" }, "repositories": [ { diff --git a/docs/architecture.md b/docs/architecture.md index 1eb7c1941..40fe13187 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -23,11 +23,14 @@ that do not exist yet, and logging there raises `Log [ichava] not defined`. Core discovers installed packs at runtime. It has no list of them, so a pack is added by installing it and removed by removing it. -## It requires `laranail/package-tools` directly - -The provider writes `Package` into its own `configurePackage()` signature, so it depends on that -class whatever the dependency graph delivers transitively through core. **Require what you import** -is the rule; a transitive dependency is not a contract. +## It requires `ichava/core` only + +`composer.json` requires `php` and `ichava/core`, and nothing under `src/` names a class from any +other `Simtabi\Laranail` namespace. The provider extends core's `IconPackServiceProvider` and declares +its constants class and its component class; core writes the `laranail/package-tools` signature, so +the `laranail/*` packages reach this pack only through core. The composer `type` is +`ichava-icon-set`, which is how core's pack discovery finds it. `tests/Unit/CoreOnlyDependencyTest.php` +fails if any of that changes. ## Why one bundle diff --git a/docs/installation.md b/docs/installation.md index 436129a47..41b0b273f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -9,10 +9,11 @@ Core is the engine; this pack is only icons and the provider that registers them ## The repositories block -The `ichava/*` packages are on Packagist, but the `laranail/*` packages core depends on are not yet, so Composer has to be told where to find them. -Composer reads `repositories` only from the root package, which is why the block belongs in the -**application's** `composer.json` and has to name the whole transitive closure rather than just this -pack. Core's [installation guide](https://github.com/ichava/core/blob/main/docs/installation.md) gives the full block. +This pack requires `ichava/core` and nothing else; the `laranail/*` packages are core's dependencies, +not this pack's. Nothing in the Ichava family is on Packagist yet, and Composer reads `repositories` +only from the root package, so the **application's** `composer.json` names core, core's dependencies +and this pack. Core's [installation guide](https://github.com/ichava/core/blob/main/docs/installation.md#1-point-composer-at-the-repositories) holds that block and is the one place that lists +it; this pack's line is `https://github.com/ichava/icon-sets-extras`. ## Require it diff --git a/src/Providers/IconsServiceProvider.php b/src/Providers/IconsServiceProvider.php index 483c08594..69bee552d 100644 --- a/src/Providers/IconsServiceProvider.php +++ b/src/Providers/IconsServiceProvider.php @@ -4,37 +4,22 @@ namespace Simtabi\Laranail\Ichava\IconSetsExtras\Providers; -use Simtabi\Laranail\Package\Tools\Package; -use Simtabi\Laranail\Ichava\Services\IconRegistry; -use Simtabi\Laranail\Ichava\Support\ServiceProvider; -use Simtabi\Laranail\Package\Tools\Exceptions\InvalidPath; -use Simtabi\Laranail\Package\Tools\Exceptions\InvalidPackage; +use Simtabi\Laranail\Ichava\Support\IconPackServiceProvider; use Simtabi\Laranail\Ichava\IconSetsExtras\Constants\IconsConstants; use Simtabi\Laranail\Ichava\IconSetsExtras\View\Components\IconComponent; /** * Registers the Ichava Extras sets with the Ichava registry on boot. */ -class IconsServiceProvider extends ServiceProvider +class IconsServiceProvider extends IconPackServiceProvider { - /** - * @throws InvalidPath - * @throws InvalidPackage - */ - public function configurePackage(Package $package): void + protected function constantsClass(): string { - $package - ->setName(IconsConstants::getVendorPackage()) - ->setPathFrom(source: $this, levelsUp: 2); + return IconsConstants::class; } - public function bootingPackage(): void + protected function componentClass(): string { - $this->loadBladeComponent(componentClass: IconComponent::class, packageName: 'icon-sets-extras'); - - $this->app->make(IconRegistry::class)->fromDirectory( - $this->package->basePath('resources/assets/svg'), - self::class, - ); + return IconComponent::class; } } diff --git a/tests/Unit/CoreOnlyDependencyTest.php b/tests/Unit/CoreOnlyDependencyTest.php new file mode 100644 index 000000000..21a6d3673 --- /dev/null +++ b/tests/Unit/CoreOnlyDependencyTest.php @@ -0,0 +1,77 @@ + */ +function coreOnlyComposerJson(): array +{ + $composer = json_decode((string) file_get_contents(dirname(__DIR__, 2) . '/composer.json'), true, flags: JSON_THROW_ON_ERROR); + + return is_array($composer) ? $composer : []; +} + +it('requires php and ichava/core, and nothing else', function (): void { + $require = array_keys(coreOnlyComposerJson()['require'] ?? []); + sort($require); + + expect($require)->toBe(['ichava/core', 'php']); +}); + +it('declares the composer type core discovers packs by', function (): void { + expect(coreOnlyComposerJson()['type'] ?? null)->toBe('ichava-icon-set'); +}); + +it('imports no laranail namespace but ichava/core from src/', function (): void { + $inspected = 0; + $offenders = []; + + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(dirname(__DIR__, 2) . '/src', FilesystemIterator::SKIP_DOTS), + ); + + foreach ($files as $file) { + if (! $file instanceof SplFileInfo || ! $file->isFile() || $file->getExtension() !== 'php') { + continue; + } + + $inspected++; + $source = (string) file_get_contents($file->getPathname()); + + // Every spelling: a `use` line, a fully qualified name, or a string with + // escaped backslashes. + preg_match_all('/Simtabi\\\\+Laranail\\\\+(\w+)(?:\\\\+(\w+))?/', $source, $matches, PREG_SET_ORDER); + + foreach ($matches as $match) { + if ($match[1] !== 'Ichava' || ($match[2] ?? '') === 'IconBrowser') { + $offenders[] = $file->getFilename() . ': ' . $match[0]; + } + } + } + + // Every pack has a provider, a constants class, an enum and a component. A + // walk that stops finding them must fail, not pass over an empty tree. + expect($inspected)->toBeGreaterThanOrEqual(4) + ->and($offenders)->toBe([]); +});