@haldami/habits-cli
v0.1.0
Published
Tiny CLI to stamp habit completions into a CSV file and print a monthly calendar.
Readme
habits-cli
Two tiny commands for tracking a habit in a plain CSV file. Written in TypeScript (strict), compiled to plain JavaScript, no runtime dependencies, Node >= 18.
habits-stamp <csv_file>appends the current local time asyyyy-mm-ddThh:mm.habits-print [<year> <month>] <csv_file>prints a Markdown calendar of the month; days with a stamp are marked with*.
$ habits-stamp habit.csv
$ habits-print 2026 6 habit.csv
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| --- | --- | --- | --- | --- | --- | --- |
| 01 | 02 | 03 | 04 | 05 | 06 | 07 |
...
| 22 | 23 | 24 | *25 | 26 | 27 | 28 |
| 29 | 30 | | | | | |Develop
pnpm install
pnpm typecheck # tsc, strict + noUncheckedIndexedAccess
pnpm test # vitest
pnpm build # tsc -> dist/
node dist/cli/print.js 2026 6 habits/habit.csv
pnpm link --global # exposes habits-stamp and habits-print for local testingLayout:
src/habits.ts logic (pure functions + file helpers)
src/habits.test.ts tests
src/cli/stamp.ts habits-stamp entry point
src/cli/print.ts habits-print entry point
dist/ build output, git-ignored, the only thing that gets publishedtsconfig.json is for typechecking (including tests, no emit); tsconfig.build.json emits dist/ without the tests.
Publish as an npm package
Publishing a TypeScript package is the same as publishing a JavaScript one, except that you publish the compiled dist/, not src/. This is already wired up: package.json has bin pointing into dist/, files: ["dist"], and a prepublishOnly script that runs typecheck, tests and build, so a stale or missing dist/ can't be published. The bin sources start with #!/usr/bin/env node, which tsc preserves; npm makes the bin files executable on install.
- Pick the name.
habits-cliis already taken on npm, so the package is scoped:@haldami/habits-cli. Use your own npm username/org as the scope and check it is free:npm view @<scope>/habits-clishould return 404. - Log in:
npm login(check withnpm whoami). Enable 2FA on the account. - Check the tarball:
pnpm typecheck && pnpm test && pnpm build pnpm pack --dry-run # should list only dist/, package.json, README.md - Try it locally from the tarball, the way users will get it:
Delete thepnpm pack npx --package ./haldami-habits-cli-0.1.0.tgz habits-print habits/habit.csv.tgzafterwards. - Publish. Scoped packages are private by default, so pass
--access public:pnpm publish --access publicprepublishOnlyrebuilds first. Publishing is effectively permanent: a version can't be reused, and unpublishing is restricted. - Use it:
npm i -g @haldami/habits-cli # or without installing (the package has two bins, so name the one to run): npx -p @haldami/habits-cli habits-print habit.csv
Releasing later
pnpm version patch # or minor / major: bumps package.json, commits, tags
pnpm publish
git push --follow-tagsBefore the first release consider adding repository, author and a LICENSE file (package.json already says MIT, but no license text is in the repo yet).
