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
15 changes: 7 additions & 8 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish to npm

# Publishes @laranail/emojis-picker for a release tag. Its own workflow, not a job in release.yml, for two reasons:
# a failed npm publish never touches the Composer release, and it can be started by hand for a tag that already
# exists (`gh workflow run npm-publish.yml -f tag=v0.5.0`) using the workflow as it is on main. Re-running a
# exists (`gh workflow run npm-publish.yml -f tag=v0.1.0 -f version=0.1.0`) using the workflow as it is on main. Re-running a
# tag's run uses the workflow file as it was at the tag, so a fix here could never reach that tag that way.
#
# Off until the repository variable NPM_PUBLISH is 'true'. Authenticates by npm trusted publishing (configure
Expand All @@ -16,19 +16,18 @@ name: Publish to npm
# A tag push publishes to the registry the repository variable PUBLISH_REGISTRY names (npm when unset).

# Dispatch only, deliberately. The Composer package is on a single moving `v0.1.0`, and a registry version is
# immutable: publishing 0.1.0 from that tag would freeze the JavaScript package at whatever that first push
# contained, because every later move would find the version already there and skip. It also cannot take the
# `latest` tag while 0.8.2 is published, so a tag push failed outright. A JavaScript release is therefore its
# own decision, with its own increasing version, built from the tag as it is now:
# `gh workflow run npm-publish.yml -f tag=v0.1.0 -f version=0.9.0 -f registry=github`.
# immutable: publishing a version from that tag would freeze the JavaScript package at whatever that first push
# contained, because every later move would find the version already there and skip. A JavaScript release is
# therefore its own decision, with its own increasing version, built from the tag as it is now:
# `gh workflow run npm-publish.yml -f tag=v0.1.0 -f version=0.1.1 -f registry=github`.
on:
workflow_dispatch:
inputs:
tag:
description: 'An existing release tag to publish, e.g. v0.5.0'
description: 'An existing release tag to publish, e.g. v0.1.0'
required: true
version:
description: 'The JavaScript version to publish, e.g. 0.9.0; empty takes it from the tag'
description: 'The JavaScript version to publish, e.g. 0.1.1; empty takes it from the tag'
required: false
default: ''
registry:
Expand Down
739 changes: 16 additions & 723 deletions CHANGELOG.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ package, so add a GitHub token with `read:packages` to the project's `.npmrc`:
```

```bash
npm install @laranail/emojis-picker@^0.9
npm install @laranail/emojis-picker@^0.1
```

**The JavaScript package versions independently of the Composer package**, which is why that constraint is
not `^0.1`. Registry versions are immutable, so a package cannot follow a tag that moves: `0.8.2` is the
newest published build, and the Composer package's moving `v0.1.0` does not publish a JavaScript version at
all. The picker's code is the same in both.
**The JavaScript package versions independently of the Composer package.** Both start at `0.1.0`, but
registry versions are immutable, so the JavaScript package cannot follow a tag that moves: each JavaScript
release gets its own increasing version, and the Composer package's moving `v0.1.0` publishes none. The
picker's code is the same in both.

See [installing from GitHub Packages](docs/tools/picker.md#installing-from-github-packages).

Expand Down
25 changes: 8 additions & 17 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ Three places name the live line and must agree: the newest `## [X.Y.Z]` section
the `dev-main` branch alias in `composer.json` (`0.1.x-dev`), and the `composer require` commands in
`README.md` and `docs/installation.md`. `tests/Unit/DocumentationTest.php` fails when they drift.

**The README's `npm install @laranail/emojis-picker` constraint is not one of them**, and must not be
made to track this line — it reads `^0.9`. That package versions independently, for the reason under
*What the moving tag costs* below, and `DocumentationTest` asserts the constraint is well formed and
*not* following the Composer line, rather than asserting it matches.

The 13 tags cut between 2026-09-26 and 2026-10-20 (`v0.1.0` through `v0.8.2`) were withdrawn when
the package returned to this model. Their entries are kept in `CHANGELOG.md` under
`## [Internal history] (not published)`, relabelled rather than deleted.
**The README's `npm install @laranail/emojis-picker` constraint is not one of them.** It reads `^0.1`
today because the JavaScript package also starts at `0.1.0`, but that package versions independently,
for the reason under *What the moving tag costs* below, so the two are free to drift apart.

### What the moving tag costs, and what to tell consumers

Expand All @@ -44,15 +39,11 @@ requires every tag to be an ancestor of `main` and the branch-alias line to have
which a freshly moved `v0.1.0` satisfies — but it will never tell you a move is due. Treat a
"release due" warning on this repository as "move the tag".

**The JavaScript package cannot follow the moving tag, and does not try to.** GitHub Packages holds
`@laranail/emojis-picker` up to 0.8.2 and a published version there is immutable, so publishing `0.1.0`
from a moving tag would freeze the package at whatever the first push contained — every later move would
find the version already present and skip it. It also cannot take the `latest` tag while 0.8.2 is
published: a tag push failed with *"Cannot implicitly apply the \"latest\" tag because previously
published version 0.8.2 is higher than the new version 0.1.0"*. So `npm-publish.yml` is
`workflow_dispatch` only, the README's npm constraint is `^0.9` rather than `^0.1`, and a JavaScript
release is its own decision with its own increasing version, built from whatever `v0.1.0` points at
when it runs. `version` names it; without it the version is the tag's, which suits only a tag that never moves:
**The JavaScript package cannot follow the moving tag, and does not try to.** A published registry
version is immutable, so publishing a version from a moving tag would freeze the package at whatever the
first push contained — every later move would find the version already present and skip it. So
`npm-publish.yml` is `workflow_dispatch` only, and a JavaScript release is its own decision with its own
increasing version (`0.1.0`, then `0.1.1`, …), built from whatever `v0.1.0` points at when it runs. `version` names it; without it the version is the tag's, which suits only a tag that never moves:

```bash
gh workflow run npm-publish.yml --repo laranail/emojis -f tag=v0.1.0 -f version=<next> -f registry=github
Expand Down
14 changes: 7 additions & 7 deletions docs/tools/picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ The picker is built to cost nothing until it is used:
off the main thread.

Measured in Chromium with the full catalogue (1,923 emoji): an inline picker paints in about 60 ms cold and
15–40 ms warm (it was 156 and 36–40 ms in 0.6.0); a closed popover mounts in under a millisecond (6–12 ms);
15–40 ms warm (it was 156 and 36–40 ms in earlier builds); a closed popover mounts in under a millisecond (6–12 ms);
a search takes about 0.4 ms.

For the smallest pages, turn the API on so the payload is fetched and cached by the browser once rather than
Expand Down Expand Up @@ -403,13 +403,13 @@ const picker = useEmojiPicker({ source, locale: 'fr', onSelect });
render agree; changing `userKey` or `store` reads them again. Both adapters are thin over the same pure
functions, so the two cannot behave differently. React 19 is a peer dependency; nothing else is.

The package is `@laranail/emojis-picker`, with the version of the Composer package: `.` is the vanilla module,
`./react` the React adapter, `./styles.css` the picker stylesheet. `.github/workflows/npm-publish.yml`
publishes it on every release tag once publishing is switched on for the repository (the `NPM_PUBLISH`
variable), to the registry the `PUBLISH_REGISTRY` variable names: `npm`, the default, or `github` for GitHub
Packages. To build it from a checkout instead: `npm run build:react && npm run types && npm pack`.
The package is `@laranail/emojis-picker`, with its own version line, independent of the Composer package's
moving `v0.1.0` (see [release](../release.md)): `.` is the vanilla module, `./react` the React adapter,
`./styles.css` the picker stylesheet. `.github/workflows/npm-publish.yml` publishes it when started by hand,
naming the tag to build from, the version and the registry: `npm`, or `github` for GitHub Packages. To build it from a checkout instead: `npm run build:react && npm run types && npm pack`.

**Where it is published today.** npm has 0.5.0 only. 0.5.1 onwards are on GitHub Packages
**Where it is published today.** GitHub Packages, from `0.1.0`. npm holds only an old `0.5.0`, deprecated in
favour of GitHub Packages
(`npm.pkg.github.com`), because npm cannot take a publish from this repository without a token yet: it was
created after 2026-07-15, so GitHub issues it immutable OIDC subjects (`repo:laranail@<id>/emojis@<id>:…`),
which npm's trusted publishing does not accept ([npm/cli#9969](https://github.com/npm/cli/issues/9969)); the
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Extension/ConfiguredExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function apply(Emojis $emojis, array $config): Emojis
$custom = (array) $custom;

if (array_key_exists('url', $custom)) {
throw new InvalidArgumentException("laranail.emojis.extend.custom.{$name}.url was renamed to image in 0.2.0; it now also accepts a data URI.");
throw new InvalidArgumentException("laranail.emojis.extend.custom.{$name}.url was renamed to image; it also accepts a data URI.");
}

$emojis->addCustom(
Expand Down
37 changes: 17 additions & 20 deletions tests/Unit/ToolingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
'a copied page' => [str_repeat("SECRET page text, not a token\n", 70)],
'a token ID' => ['SECRET-0f8e2c1a-4b7d-4e2a-9c3b-1d2e3f4a5b6c'],
'a truncated token' => ['npm_' . 'SECRETabc'],
'two tokens' => ['npm_' . "SECRETabcdefghijklmnopqrstuvwxyz0123\nnpm_" . 'SECRETabcdefghijklmnopqrstuvwxyz0123'],
'an ellipsis' => ['npm_' . "SECRETabcdefghijklmnopqrstuvwxyz\u{2026}"],
'two tokens' => ['npm_' . 'SECRET' . implode('', range('a', 'z')) . "0123\nnpm_" . 'SECRET' . implode('', range('a', 'z')) . '0123'],
'an ellipsis' => ['npm_' . 'SECRET' . implode('', range('a', 'z')) . "\u{2026}"],
]);

it('removes the invisible characters a copied page carries, and names a stray character without the token', function (string $input, int $exit, string $expected): void {
Expand All @@ -218,10 +218,10 @@
->and($output)->toContain($expected)
->and($output)->not->toContain('SECRET');
})->with([
'a zero-width space' => ['npm_' . "SECRETabc\u{200B}defghijklmnopqrstuvwxyz0123", 3, 'removed invisible characters from the paste: U+200B'],
'a byte-order mark' => ["\u{FEFF}npm_" . 'SECRETabcdefghijklmnopqrstuvwxyz0123', 3, 'U+FEFF'],
'non-breaking spaces' => ["\u{00A0}npm_" . "SECRETabcdefghijklmnopqrstuvwxyz0123\u{00A0}\n", 3, 'could not reach'],
'a non-breaking space inside' => ['npm_' . "SECRETabcdefghij\u{00A0}klmnopqrstuvwxyz0123", 2, 'contains U+00A0'],
'a zero-width space' => ['npm_' . 'SECRETabc' . "\u{200B}" . implode('', range('d', 'z')) . '0123', 3, 'removed invisible characters from the paste: U+200B'],
'a byte-order mark' => ["\u{FEFF}npm_" . 'SECRET' . implode('', range('a', 'z')) . '0123', 3, 'U+FEFF'],
'non-breaking spaces' => ["\u{00A0}npm_" . 'SECRET' . implode('', range('a', 'z')) . "0123\u{00A0}\n", 3, 'could not reach'],
'a non-breaking space inside' => ['npm_' . 'SECRET' . implode('', range('a', 'j')) . "\u{00A0}" . implode('', range('k', 'z')) . '0123', 2, 'contains U+00A0'],
]);

it('takes the registry as its first argument and refuses anything it does not know', function (): void {
Expand Down Expand Up @@ -250,7 +250,7 @@
->and($run('--registry=pypi')[0])->toBe(64);
});

it('builds the release notes for the moving tag without swallowing the withdrawn history', function (): void {
it('builds the release notes for the moving tag from its one CHANGELOG section', function (): void {
$root = dirname(__DIR__, 2);
$changelog = (string) file_get_contents($root . '/CHANGELOG.md');
$workflow = (string) file_get_contents($root . '/.github/workflows/release.yml');
Expand Down Expand Up @@ -286,17 +286,15 @@

$notes = implode("\n", $section('## [0.1.0]'));
$unreleased = trim(implode("\n", $section('## [Unreleased]')));
$demoted = preg_match_all('/^### \[0\.\d+\.\d+\] - /m', $changelog);

// The heading that ends the notes keeps its bracket on purpose: without it the extractor runs on and
// every withdrawn section ships as the release notes for v0.1.0.
expect($changelog)->toContain("\n## [Internal history] (not published)\n")
->and(trim($notes))->not->toBe('', 'release.yml refuses a tag whose section is empty')
->and($notes)->not->toContain('### [0.8.2]')
->and($notes)->not->toContain('### [0.1.0]')
$versions = preg_match_all('/^#{2,3} \[\d+\.\d+\.\d+\]/m', $changelog);

// One version section: the package was reset to a single v0.1.0 on 2026-11-15 and the withdrawn
// entries were removed, so the notes are the whole 0.1.0 section and nothing else.
expect(trim($notes))->not->toBe('', 'release.yml refuses a tag whose section is empty')
->and($notes)->toContain('### Added')
->and($changelog)->not->toContain('Internal history')
->and($unreleased)->toBe('', 'release.yml refuses a tag while [Unreleased] has entries')
// Non-vacuity: the withdrawn tags are still in the file, demoted rather than deleted.
->and($demoted)->toBe(13);
->and($versions)->toBe(1);
});

it('never publishes the JavaScript package from a tag, because registry versions are immutable', function (): void {
Expand Down Expand Up @@ -332,9 +330,8 @@
->and($workflow)->not->toContain("tags:\n")
// release.yml still fires on the tag: the Composer release is unaffected, and that must stay true.
->and((string) file_get_contents($root . '/.github/workflows/release.yml'))->toContain('tags:')
// The README names a constraint the registry can actually resolve, which is not the Composer line.
->and($readme)->toContain('@laranail/emojis-picker@^0.9')
->and($readme)->not->toContain('@laranail/emojis-picker@^0.1')
// The README names a constraint the registry can actually resolve: 0.1.0 is the first published version.
->and($readme)->toContain('@laranail/emojis-picker@^0.1')
// The JS version is its own input, checked for shape, so a release need not cut a Composer tag.
->and($workflow)->toContain(" version:\n")
->and($workflow)->toContain('version="${INPUT_VERSION:-${tag#v}}"')
Expand Down
Loading