Contributing
git clone https://github.com/Richard-Sen27/copy-ink.git
cd copy-ink
npm install
npm run typecheck # tsc --noEmit
npm test # vitest run
npm run build # tsc -p tsconfig.build.json
npm run test:watch # vitest
npm run test:app # build a real Next app against the package
The first three run automatically before publish (prepublishOnly).
What the tests cover
- The YAML round-trip, including comment preservation
- The scope resolution chain
- The Markdown allowlist, including XSS bypass attempts
- The publish pipeline and the changeset
- The CLI
- The publish validator, including the traversal attempts it exists to refuse
- An import-graph assertion that the editor never enters the visitor bundle
That last one guards the whole premise of the library, so please keep it
passing. It lives in test/packaging/imports.test.ts.
The smoke build
npm run test:app builds test/fixtures/site — a small but complete App Router
project — against the freshly built package, then checks the prerendered HTML.
It exists because a whole class of failure is invisible to unit tests: whether
copy-ink/middleware loads on the Edge runtime, whether a route handler
resolves its entry point, whether the editor really stays out of a visitor's
bundle once Next has done the bundling. Each of those breaks the host's build
rather than copy-ink's, so this builds a host.
Layout
| Directory | Contents |
|---|---|
src/components/ | <Copy> and friends |
src/server/ | Runtime, route handler, sessions, server API |
src/editor/ | The lazily-loaded editor |
src/backend/ | ContentBackend implementations |
src/auth/ | AuthProvider implementations |
src/content/ | Content store and collections |
src/core/ | YAML, paths, images, naming, errors |
src/manifest/ | The JSX scanner and codegen |
src/cli/ | The six commands |
Tests mirror src/ under test/.
Conventions
- Commits follow Angular
style:
type(scope): subject. Bodies only when the change genuinely needs one. - British spelling in prose and identifiers (
localisation,colour,authorise), matching the existing code. - Comments explain why, not what. The codebase is deliberately light on restating its own code.
- No new runtime dependencies without a good reason. The package ships two.
Documentation
This site lives in docs/
in the same repository, as its own npm project:
cd docs
npm install
npm start
npm run build fails on a broken internal link, which is the check worth
running before pushing. Pushing to main deploys it to GitHub Pages
automatically.
Reporting a bug
Include the output of copy-ink doctor and your versions of copy-ink, Next
and Node:
github.com/Richard-Sen27/copy-ink/issues.
Licence
MIT © Richard Senger.