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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions config/icon-sets-flag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions resources/assets/svg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"version": "0.1.1",
"upstream_version": "7.6.0",
"type": "single",
"kind": "icon",
"license": "MIT"
},
"metadata": {
Expand Down
12 changes: 0 additions & 12 deletions resources/lang/en/icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
];
58 changes: 58 additions & 0 deletions tests/Feature/RetiredCopiesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* Pins what was removed from this pack as unread copies, and what it keeps.
*
* Removed 2026-10-30 (the wire-in plan's pack rows): the `commands` and `info`
* translation groups, written for an update command and an about block no
* pack ships (core's about section reads the registry instead), and the
* `set.name` / `set.prefix` config copies. Each was read by nothing, which is
* why none of them could fail.
*/
function flag_translations(): array
{
return require dirname(__DIR__, 2) . '/resources/lang/en/icons.php';
}

it(description: 'ships no translations for an update command or an about block', closure: function () {
expect(flag_translations())->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']);
});
113 changes: 113 additions & 0 deletions tests/Feature/SvgKindTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

declare(strict_types=1);

use Simtabi\Laranail\Ichava\Services\IconRegistry;

/**
* Pins the SVG kind this pack declares in `config.json`, `icon` or `illustration`.
*
* Core resolves a category's kind as its own `kind`, then `package.kind`, then
* `icon`, and ignores a value that names no kind. So a typo here does not fail
* anywhere at runtime: it files the SVGs as icons and nothing reports it. These
* cases are what make it fail.
*
* The category is the first folder under `files/`, which is the folder core
* files an icon under, so the folders on disk are resolved as well as the
* categories `config.json` declares.
*/
function flag_kind_config(): array
{
return json_decode(
(string) file_get_contents(dirname(__DIR__, 2) . '/resources/assets/svg/config.json'),
true,
flags: JSON_THROW_ON_ERROR,
);
}

/** @return list<string> */
function flag_kinds(): array
{
return ['icon', 'illustration'];
}

/** @return array<string, string> 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);
}
});
Loading