Add ID generator, and automate releases from the changelog - #1
Merged
Merged
Conversation
ID generator - Prefixed identifiers in the Stripe shape (sk_live_4eC39HqL...): prefix, separator, random length, alphabet and batch size are all configurable. - Doubles as a password generator via a symbol alphabet plus an option to drop confusable glyphs (0/O, 1/l/I), which matters for anything a human retypes and is pointless for a machine token -- hence optional rather than default. - Live entropy readout with a qualitative verdict. Deliberately no "time to crack" figure: it depends entirely on assumed hardware and on whether the value is hashed, so quoting one would be false precision presented as a guarantee. - Entropy counts the random portion only. The prefix is public by design and contributes none. - Rejection sampling, never `value % n`, which biases toward the start of the alphabet whenever the size does not divide 2^32. A distribution test would fail if that regressed. - Settings persist; generated values live in component state and are never written to disk under any code path. - The unbiased randomness primitives move to src/lib/random.ts now that the list shuffler and this tool both need them. Release automation - CI gates every pull request on typecheck, lint, tests, build, and an entry bundle budget, so a heavy dependency escaping a lazy chunk fails the build rather than reaching production. - Merging to main does not deploy. It derives the next version from the [Unreleased] section of CHANGELOG.md, rewrites the changelog, commits that back to main and pushes a tag. The tag is what deploys, so merging and releasing stay separate decisions and an empty [Unreleased] ships nothing. - The bump logic is a tested pure module rather than inline shell, because a mistake there silently ships the wrong version and a green run would not reveal it. `### Removed` maps to patch, not major, so a tidy-up cannot silently become a 1.0; major requires an explicit `### Breaking`. - A tag pushed with the default GITHUB_TOKEN does not trigger other workflows, by design. With a PAT in RELEASE_TOKEN the tag triggers Deploy natively; without one the workflow starts Deploy explicitly, so this works either way.
GitHub is forcing actions that target Node 20 onto Node 24 and warning about it, so move to the current majors rather than wait for them to break. Also clears the two warnings the run surfaced in the new release scripts: a Set lookup instead of repeated array scans, and a test helper hoisted out of its describe block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two things that belong together, because the second is what ships the first.
1. ID generator
Prefixed identifiers in the Stripe shape — a readable prefix, a separator, then a run of random characters. Configurable prefix, separator, random length, alphabet and batch size, with presets for Stripe secret/test keys, object ids, API tokens, hex session ids, passwords and human-readable codes.
It doubles as a password generator: a symbol alphabet plus an option to drop confusable glyphs (
0/O,1/l/I). That closes the separate password-generator item too — it is the same machine underneath, and shipping two would have implied one was the non-secure option.Decisions worth reviewing:
% n. Modulo biases toward the start of the alphabet whenever the size does not divide 2^32. There is a distribution test that fails if that regresses.2. Release automation
Merging this does not deploy. Instead:
## [Unreleased]inCHANGELOG.mdand derives the bump —### Breaking→ major,### Added→ minor, anything else → patch.package.json, commits back tomain, and pushesvx.y.z.An empty
[Unreleased]releases nothing, so merging and releasing stay separate decisions.The bump logic is a tested pure module (
scripts/changelog.ts, 22 tests) rather than inline shell, because a mistake there silently ships the wrong version and a green workflow run would not reveal it. Preview any merge with:Merging this will release v0.2.0
The dry run confirms it:
[Unreleased]contains### Added→ minor →0.1.0→0.2.0.Needed before the deploy can succeed
CLOUDFLARE_API_TOKENis not set yet. Create it at Cloudflare → My Profile → API Tokens → Custom with Account → Workers Scripts: Edit and Zone → Workers Routes: Edit onfadeltd.devonly, then rungh secret set CLOUDFLARE_API_TOKEN --repo fadeltd/devtoolsand paste at the prompt. Without it the deploy step fails; everything before it still passes.RELEASE_TOKEN(optional). A tag pushed with the defaultGITHUB_TOKENdeliberately does not trigger other workflows. Without a PAT the Release workflow starts Deploy explicitly, which works. If you want the tag itself to trigger it, add a fine-grained PAT with Contents: Read and write asRELEASE_TOKEN.Note
GitHub push protection blocked the first push of this branch: I had used Stripe's documentation example key as a doc comment, and it matches their live-key pattern. I replaced the example with prose rather than allowlisting it — a scanner cannot tell a doc example from a real leak, and should not have to.
Verification