Skip to content

stacknide/npm-package-template

Repository files navigation

npm-package-template

Monorepo for @stacknide/create-package — a CLI that scaffolds a production-ready TypeScript npm package — and the template it generates from.

npm create @stacknide/package my-package
# or
npx @stacknide/create-package my-package

Layout

Path What it is
template/ The tokenized payload copied into new projects (single source of truth).
cli/ The @stacknide/create-package scaffolder that bundles template/.

The CLI never edits template/ directly at publish time — a build step (cli/scripts/sync-template.mjs) copies template/ into cli/template/ so it ships inside the published tarball.

What the template gives a new package

  • tsup — ESM + CJS + .d.ts bundling.
  • Biome — lint + format.
  • Changesets — versioning & changelogs.
  • Lefthook — pre-commit / pre-push git hooks.
  • Yarn 4 workspaces — a package/ (published) + test/ (runtime tests) split.
  • GitHub Actions — PR checks + Release workflow with OIDC trusted publishing.

Template tokens

Files under template/ use {{token}} placeholders that the CLI substitutes:

Token Example
{{packageName}} @stacknide/my-lib
{{packageSlug}} my-lib
{{packageDescription}} A tiny, well-typed utility.
{{author}} Jane Doe <https://github.com/jane>
{{githubOrg}} stacknide
{{githubRepo}} stacknide/my-lib
{{year}} 2026
{{licenseHolder}} Stacknide

.gitignore / .npmignore are stored un-dotted (gitignore, npmignore) inside template/ because npm strips dotfiles from published tarballs; the CLI restores their names when scaffolding.

Development

yarn install
yarn dev        # run the CLI from source (tsx)
yarn build      # bundle the CLI (syncs template/ first)
yarn test       # build + scaffold smoke test

Releasing the CLI

yarn bump       # add a changeset

Merging to main runs the Release workflow, which opens a Version Packages PR; merging that publishes @stacknide/create-package to npm via OIDC (configure the trusted publisher on npmjs.com first).

About

A CLI tool that scaffolds a production-ready TypeScript npm package

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors