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.
When you run package-creator in an existing or new folder, it will:
-
Ensure
package.jsonexists- If none is found, it runs
npm initinteractively to create one.
- If none is found, it runs
-
Create core project files (if missing)
tsconfig.jsonwith:target:ES2022module:ESNextmoduleResolution:Bundlertypes:["node"]strict:trueesModuleInterop:true
index.tswith a simple starter export:export const hello = () => console.log("Hello World");
README.mdgenerated from yourpackage.jsonmetadata (name, description, author, license, bin)..gitignorecontaining:node_modules.npmignore(empty by default).
-
Configure
package.json(idempotently)- Ensures
typeis set to"module"(if not already defined). - Ensures
mainis set to"index.ts"(if not already defined). - Ensures
bincontains a CLI entry pointing atindex.ts:- If
binis missing or a string, it becomes an object like:{ "bin": { "<cli-name>": "index.ts" } } <cli-name>is inferred from the existingbinfield, or else from the package name.
- If
- Adds/keeps standard npm scripts when they are missing:
clean:rm -rf distbuild:tscprepare:npm run buildprettier:prettier --write .lint:eslint .test:echo "Error: no test specified" && exit 1publish: defaults tonode --loader ts-node/esm utils/utils.tsif not set.
- Ensures
-
Set up version bump automation
- Creates
scripts/update-version.mjsif missing. - Ensures a
prepublishOnlyhook runs:(prepended to any existingnode scripts/update-version.mjs
prepublishOnlyscript). - Guarantees there is a
publishscript (defaults tonpm publishif none).
- Creates
-
Create a
utilshelper folder- Ensures
utils/exists. - Creates an empty
utils/utils.tsif it does not already exist.
- Ensures
-
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
- Node.js 18+ (for native ESM and
node:imports). - npm (comes with Node).
- An interactive terminal (the script uses animations and inherits stdin/stdout).
Install locally in a project:
npm install --save-dev @greg-466/package-creatorOr run it ad‑hoc with npx (no global install needed):
npx @greg-466/package-creatorYou can also install it globally:
npm install -g @greg-466/package-creator
# now the binary is available as:
package-creatorFrom inside the folder where you want to (or already) have a Node.js package:
npx package-creatorThis will:
- Run
npm initif nopackage.jsonis present. - Create missing files (
tsconfig.json,index.ts,README.md,.gitignore,.npmignore). - Update your
package.jsonscripts/bin/version automation in a non-destructive way.
-
--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 overwriteREADME.md. Useful if you already maintain a custom README.
You can combine them, for example:
npx package-creator --force --skip-readmeIf 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
binor 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.
To work on package-creator itself in this repo:
npm install
npm run buildThe CLI entry point is src/index.ts (built to dist/index.js), and the package is published under @greg-466/package-creator.