Skip to content

feremabraz/script-executable-publishable

Repository files navigation

script-executable-publishable

Template that you can use to create an executable script, ready to be published in NPM. It does not use any bundler.

If you are wondering whether or not you need a bundler for your purposes, you can read this answer on stackoverflow and maybe this blog article.

script-executable-publishable

How to use

The procedure is straightforward:

  1. Use this project as a template.
  2. Replace all occurrences of 'script-executable-publishable' in package.json with your project name. Update the description, author, and license fields as needed.
  3. Authentication & Registry:
    • If you intend to publish to the public npm registry (npmjs.com), simply run:
      pnpm login
      You do not need a .npmrc file or a GitHub token for public npm.
    • If you intend to publish to GitHub Packages (npm.pkg.github.com), you need a .npmrc file with an auth token. You can use the provided .npmrc.example:
      cp .npmrc.example .npmrc
      # Then edit .npmrc and add your GitHub Personal Access Token (with write:packages scope)
  4. Install dependencies:
    pnpm install
    If you don’t have pnpm, follow this guide.
  5. Lint and format your code (recommended):
    pnpm lint
    pnpm format

    This project uses Biome for linting and formatting.

  6. (Recommended) Test your script locally before publishing. You can use pnpm link --global or these npm tips.
  7. When you're ready to publish to npm, run:
    pnpm publish --access public

Public vs Private Packages

  • For public packages on npmjs.com, use:
    pnpm publish --access public
  • For private packages on npmjs.com, use a scoped package name (e.g., @yourname/package) and publish with:
    pnpm publish --access restricted
  • For private packages on GitHub Packages, packages are private by default. Just publish as usual after configuring .npmrc.

About

Template to publish an executable script to NPM without a bundler.

Topics

Resources

License

Stars

Watchers

Forks