Add npx claude-translator init - #3
Merged
Merged
Conversation
Installing was four manual steps: clone, copy scripts, npm i parse5, copy
config. Now it is one command, and the four steps still work for anyone who
prefers them.
bin/claude-translator.mjs copies the pipeline into scripts/i18n/ (or --dir),
writes i18n.config.json, declares parse5, and appends the derived i18n/ paths
to .gitignore — deliberately NOT i18n/tm/{lang}.json, because the memory is
the asset and ignoring it is how people pay twice.
Two rules it does not break: it never overwrites without --force, and it
prints every path it touched. A scaffolder that quietly clobbers a config
someone has edited is worse than no scaffolder, so both are covered by tests
rather than by intent.
The scripts are copied rather than run from node_modules on purpose. They
resolve parse5 and every relative path from the project they live in, they
are short enough to read, and this is AGPL software whose point is that you
can change them.
Packaging
- "files" allowlist so the tarball carries bin, scripts, references, SKILL.md
and the example config, and nothing else — 27 files
- parse5 moved to devDependencies. Nothing in the published package needs it
at runtime, so npx no longer downloads it; a clone plus npm install is
unaffected
Verified through the real package path rather than by running the source:
npm pack, install the tarball into a clean project, run init, then drive
extract -> translate -> build-locales -> verify to ALL GATES PASSED using a
local stand-in provider. CI now does the same on every PR, so a broken
published package fails the build instead of a user's first command.
12 CLI contract tests cover the refusal to install outside a Node project
(and that it leaves nothing behind), idempotency, --force, --dir, appending
to an existing .gitignore rather than replacing it, and that package.json
"files" actually ships what init copies.
Not yet published to npm — no credentials on this machine. Until it is,
`npx claude-translator init` will not resolve; the README documents running
the scaffolder from a clone as the alternative.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Why
Installing was four manual steps: clone, copy scripts,
npm i parse5, copy config. Now it is one command — and the four steps still work for anyone who prefers them.What
initdoesCopies the pipeline into
scripts/i18n/(or--dir), writesi18n.config.json, declaresparse5, and appends the derivedi18n/paths to.gitignore— deliberately noti18n/tm/{lang}.json, because the translation memory is the asset and ignoring it is how people end up paying twice.Two rules it does not break: it never overwrites without
--force, and it prints every path it touched. Both are covered by tests rather than by intent — a scaffolder that quietly clobbers a config someone has edited is worse than no scaffolder.The scripts are copied rather than run from
node_moduleson purpose: they resolveparse5and every relative path from the project they live in, they are short enough to read, and this is AGPL software whose point is that you can change them.Packaging
"files"allowlist — the tarball carriesbin,scripts,references,SKILL.mdand the example config. 27 files, nothing stray.parse5moved todevDependencies. Nothing in the published package needs it at runtime (the CLI only copies files), sonpxno longer downloads it. A clone plusnpm installis unaffected.Verification
Tested through the real package path, not by running the source:
npm pack→ install the tarball into a clean project →init→ driveextract → translate → build-locales → verifytoALL GATES PASSEDwith a local stand-in provider.CI now does the same on every PR, so a broken published package fails the build instead of a user's first command.
12 CLI contract tests cover:
initoverwrites nothing and says so--forcebeing the only way to replace an edited file--dir(including that the printed next-steps reference the chosen directory).gitignorerather than replacing itpackage.json"files"actually shipping whatinitcopiesThere are no npm credentials on the machine this was built on, so
npx claude-translator initwill not resolve until someone runsnpm login && npm publish. The README documents running the scaffolder from a clone as the alternative in the meantime.