Skip to content

Greg-CS/package-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

package-creator

CLI to bootstrap a minimal Node.js TypeScript package with sensible defaults and some animated terminal feedback.

It is published as @greg-466/package-creator and exposes the package-creator binary.

What it does

When you run package-creator in an existing or new folder, it will:

  • Ensure package.json exists

    • If none is found, it runs npm init interactively to create one.
  • Create core project files (if missing)

    • tsconfig.json with:
      • target: ES2022
      • module: ESNext
      • moduleResolution: Bundler
      • types: ["node"]
      • strict: true
      • esModuleInterop: true
    • index.ts with a simple starter export:
      export const hello = () => console.log("Hello World");
    • README.md generated from your package.json metadata (name, description, author, license, bin).
    • .gitignore containing:
      node_modules
      
    • .npmignore (empty by default).
  • Configure package.json (idempotently)

    • Ensures type is set to "module" (if not already defined).
    • Ensures main is set to "index.ts" (if not already defined).
    • Ensures bin contains a CLI entry pointing at index.ts:
      • If bin is missing or a string, it becomes an object like:
        {
          "bin": {
            "<cli-name>": "index.ts"
          }
        }
      • <cli-name> is inferred from the existing bin field, or else from the package name.
    • Adds/keeps standard npm scripts when they are missing:
      • clean: rm -rf dist
      • build: tsc
      • prepare: npm run build
      • prettier: prettier --write .
      • lint: eslint .
      • test: echo "Error: no test specified" && exit 1
      • publish: defaults to node --loader ts-node/esm utils/utils.ts if not set.
  • Set up version bump automation

    • Creates scripts/update-version.mjs if missing.
    • Ensures a prepublishOnly hook runs:
      node scripts/update-version.mjs
      (prepended to any existing prepublishOnly script).
    • Guarantees there is a publish script (defaults to npm publish if none).
  • Create a utils helper folder

    • Ensures utils/ exists.
    • Creates an empty utils/utils.ts if it does not already exist.
  • Show animated feedback

    • Displays a neon ASCII banner when starting.
    • Shows a rainbow/glitch animation when creating or reusing folders/files.
    • Uses a spinner animation while the main setup runs, then prints:
      NODEJS PACKAGE STARTER KIT CREATED
      

Prerequisites

  • Node.js 18+ (for native ESM and node: imports).
  • npm (comes with Node).
  • An interactive terminal (the script uses animations and inherits stdin/stdout).

Installation

Install locally in a project:

npm install --save-dev @greg-466/package-creator

Or run it ad‑hoc with npx (no global install needed):

npx @greg-466/package-creator

You can also install it globally:

npm install -g @greg-466/package-creator

# now the binary is available as:
package-creator

Usage

From inside the folder where you want to (or already) have a Node.js package:

npx package-creator

This will:

  • Run npm init if no package.json is present.
  • Create missing files (tsconfig.json, index.ts, README.md, .gitignore, .npmignore).
  • Update your package.json scripts/bin/version automation in a non-destructive way.

CLI flags

  • --force
    Overwrite files even if they already exist. Without this flag, existing files are left alone and you’ll see messages like:

    Skipping README.md: file already exists (use --force to overwrite).
    
  • --skip-readme
    Do not create or overwrite README.md. Useful if you already maintain a custom README.

You can combine them, for example:

npx package-creator --force --skip-readme

How the generated README works

If README.md doesn’t exist and you haven’t passed --skip-readme, the tool:

  • Reads your package.json.
  • Derives:
    • Name
    • Version
    • Description
    • Author (string or { name } form)
    • License
    • CLI command name (based on bin or fallback to package name)
  • Writes a basic README template with:
    • About section (author, version, description, license).
    • Install instructions (npm install <name> / npx <cli>).
    • Placeholder configuration notes.

You can edit the generated README afterwards as you see fit.

Development

To work on package-creator itself in this repo:

npm install
npm run build

The CLI entry point is src/index.ts (built to dist/index.js), and the package is published under @greg-466/package-creator.

About

script file to start npm packages

Resources

Stars

Watchers

Forks

Packages

No packages published