diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4b234..44a367b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to `ichava/icon-sets-flag` follow [Keep a Changelog](https:/ ## [Unreleased] +### Added + +- **The pack declares its SVG kind.** `config.json` sets `package.kind` to `icon`, the kind ichava/core resolves for every category that names none of its own (core reads it from ichava/core#148; an older core ignores the key). `tests/Feature/SvgKindTest.php` fails on a kind core would not recognise, on a category that resolves none, and, against a core that has `IconRegistry::kindFor()`, on any category core resolves differently. `RetiredCopiesTest` also pins a non-empty description for every label core loads. + ### Changed - **Every workflow runs on every pull request.** The `paths-ignore: '**.md'` and `paths:` filters are removed from the `pull_request` triggers, so every check reports on every pull request and can be a required status check on `main`. A path-filtered required check never reports on the pull requests it skips, and blocks them for good. @@ -12,6 +16,11 @@ All notable changes to `ichava/icon-sets-flag` follow [Keep a Changelog](https:/ - **The package author is Simtabi LLC, not a person.** `composer.json` named a personal maintainer and mailbox as author; it now names `Simtabi LLC` with the role address `ichava@simtabi.com` (no personal contact is published, decided 2026-10-28). `NoPersonalContactTest` reads `composer.json`, `README.md`, `LICENSE`, `docs/` and `src/`, fails on a personal name or address, and fails when it reads fewer files than it did when written. - **`sync-upstream.yml`'s header describes what the workflow runs.** It said the image bundles Python and that a release ships to Packagist. The image is icon-sets-sync's Go binary with git, gh and Node, built from the toolkit's `main`, and a release is the GitHub release that release-please and `release.yml` make; nothing is published to Packagist. Comments only: the workflow runs the same steps. +### Removed + +- **The `commands` and `info` translation groups.** They were written for an update command and an about block this pack does not ship (core's about section reads the registry), and nothing loaded them. `tests/Feature/RetiredCopiesTest.php` keeps them out. +- **`set.name` and `set.prefix` from the config file.** Both copied what core already reads from `config.json` through `IconsConstants`, and nothing read them. The file keeps its one real setting, `default_variant`. + ## [0.1.1] - 2026-10-26 ### Added diff --git a/config/icon-sets-flag.php b/config/icon-sets-flag.php index cc43a10..67250c4 100644 --- a/config/icon-sets-flag.php +++ b/config/icon-sets-flag.php @@ -2,14 +2,7 @@ declare(strict_types=1); -use Simtabi\Laranail\Ichava\IconSetsFlag\Constants\IconsConstants; - return [ - 'set' => [ - 'name' => IconsConstants::getPackageName(), - 'prefix' => IconsConstants::getPrefix(), - ], - /* |-------------------------------------------------------------------------- | Default Aspect Ratio diff --git a/docs/configuration.md b/docs/configuration.md index a49adbf..6d200b5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -16,8 +16,11 @@ Publishing is optional; the defaults are merged either way. ## What is here -Only what is specific to this pack -- the set name and prefix it registers under, and its own -addressing defaults. Read the published file for the current list rather than a copy of it here. +One key, `default_variant`: the aspect ratio an unqualified flag resolves to (`4x3` or `1x1`, `ICHAVA_FLAG_DEFAULT_VARIANT`). + +The set name and prefix are not here. Core reads both from `resources/assets/svg/config.json` +through `IconsConstants`, which is canonical for the pack's name, prefix, kind, variants and +categories; the copies this file used to carry were read by nothing and are gone. ## What is not here diff --git a/resources/assets/svg/config.json b/resources/assets/svg/config.json index 84e1bc6..37c26c7 100644 --- a/resources/assets/svg/config.json +++ b/resources/assets/svg/config.json @@ -14,6 +14,7 @@ "version": "0.1.1", "upstream_version": "7.6.0", "type": "single", + "kind": "icon", "license": "MIT" }, "metadata": { diff --git a/resources/lang/en/icons.php b/resources/lang/en/icons.php index 8ebde35..bbad01b 100644 --- a/resources/lang/en/icons.php +++ b/resources/lang/en/icons.php @@ -28,16 +28,4 @@ '4x3' => 'The canonical aspect ratio for most national flags', '1x1' => 'Square crop, for round badges, picker grids and favicons', ], - - 'commands' => [ - 'update' => 'Update the flag icons from lipis/flag-icons', - 'fetching' => 'Fetching the latest flag icons...', - 'complete' => 'Flag icons updated successfully!', - ], - - 'info' => [ - 'version' => 'Version :version', - 'total_icons' => ':count icons available', - 'variant_info' => ':variant: :count flags', - ], ]; diff --git a/tests/Feature/RetiredCopiesTest.php b/tests/Feature/RetiredCopiesTest.php new file mode 100644 index 0000000..c395f5a --- /dev/null +++ b/tests/Feature/RetiredCopiesTest.php @@ -0,0 +1,58 @@ +not->toHaveKey('commands') + ->and(flag_translations())->not->toHaveKey('info'); +}); + +it(description: 'keeps a description for every label core loads', closure: function () { + // Core loads `variants`, `categories` and `sets` as labels. Each label + // group carries a description per key, for the browser's tooltips. + $groups = ['variants' => 'variant_descriptions', 'categories' => 'category_descriptions', 'sets' => 'set_descriptions']; + $inspected = 0; + + foreach ($groups as $labels => $descriptions) { + if (! array_key_exists($labels, flag_translations())) { + continue; + } + + $inspected++; + $expected = array_keys(flag_translations()[$labels]); + $actual = array_keys(flag_translations()[$descriptions] ?? []); + sort($expected); + sort($actual); + + expect($actual)->toBe($expected); + + foreach (flag_translations()[$descriptions] as $key => $text) { + expect(is_string($text) && trim($text) !== '')->toBeTrue("{$descriptions}.{$key} is empty"); + } + } + + expect($inspected)->toBeGreaterThan(0, 'no label group was inspected'); +}); + +it(description: 'keeps only its own default in config, with no copy of the set name or prefix', closure: function () { + // `set.name` and `set.prefix` copied what core already takes from + // config.json through IconsConstants, and nothing read them. + $config = config('ichava.icon-sets-flag'); + + expect($config)->toBeArray() + ->and(array_keys($config))->toBe(['default_variant']); +}); diff --git a/tests/Feature/SvgKindTest.php b/tests/Feature/SvgKindTest.php new file mode 100644 index 0000000..363daa2 --- /dev/null +++ b/tests/Feature/SvgKindTest.php @@ -0,0 +1,113 @@ + */ +function flag_kinds(): array +{ + return ['icon', 'illustration']; +} + +/** @return array category slug => the kind it resolves to */ +function flag_resolved_kinds(): array +{ + $config = flag_kind_config(); + $packageKind = $config['package']['kind'] ?? 'icon'; + $categories = $config['metadata']['data']['categories'] ?? []; + + $slugs = array_keys($categories); + + foreach (glob(dirname(__DIR__, 2) . '/resources/assets/svg/files/*', GLOB_ONLYDIR) ?: [] as $directory) { + $slugs[] = basename($directory); + } + + $kinds = []; + + foreach (array_unique($slugs) as $slug) { + $kinds[$slug] = $categories[$slug]['kind'] ?? $packageKind; + } + + ksort($kinds); + + return $kinds; +} + +it(description: 'declares a pack-wide kind core recognises', closure: function () { + $package = flag_kind_config()['package']; + + expect(array_key_exists('kind', $package))->toBeTrue('config.json package.kind is missing'); + expect(in_array($package['kind'], flag_kinds(), true)) + ->toBeTrue("config.json package.kind is '{$package['kind']}', which names no kind"); +}); + +it(description: 'declares only kinds core recognises on its categories', closure: function () { + $declared = []; + + foreach (flag_kind_config()['metadata']['data']['categories'] ?? [] as $slug => $category) { + if (array_key_exists('kind', $category)) { + $declared[$slug] = $category['kind']; + } + } + + // Empty is fine: a category that names no kind inherits the pack's. + expect(array_diff($declared, flag_kinds()))->toBe([]); +}); + +it(description: 'resolves a kind for every category', closure: function () { + $kinds = flag_resolved_kinds(); + + // A glob or a key that matches nothing would make the loop below vacuous. + expect($kinds)->not->toBeEmpty('no categories were inspected'); + + foreach ($kinds as $slug => $kind) { + expect(in_array($kind, flag_kinds(), true)) + ->toBeTrue("category {$slug} resolves to '{$kind}', which names no kind"); + } +}); + +it(description: 'files exactly the expected categories as illustrations', closure: function () { + $illustrations = array_keys(array_filter( + flag_resolved_kinds(), + static fn (string $kind): bool => $kind === 'illustration', + )); + + expect($illustrations)->toBe([]); +}); + +it(description: 'resolves the same kinds through core', closure: function () { + if (! method_exists(IconRegistry::class, 'kindFor')) { + $this->markTestSkipped( + 'the ichava/core resolved here predates SVG kinds (IconRegistry::kindFor, ichava/core#148); ' + . 'the config.json cases above still run', + ); + } + + $registry = $this->app->make(IconRegistry::class); + + foreach (flag_resolved_kinds() as $slug => $kind) { + expect($registry->kindFor('ichava/icon-sets-flag', $slug)->value)->toBe($kind); + } +});