Skip to content
/ smol-cli Public template

A typescript cli template powered by typescript, prettier, zx, esbuild, and pkg

License

Notifications You must be signed in to change notification settings

jacob-shuman/smol-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smol-cli

license badge

A typescript cli template powered by typescript, prettier, zx, esbuild, and pkg

Before using this template

Replace the following templated variables globally:

YOUR_NAME (author's name)
YOUR_EMAIL (author's email)
GITHUB_USERNAME (github username)
smol-cli (package name)
smol--cli (package name)

Why?

I needed a lightweight approach that had all the tools I preferred using that resulted in smol binaries that worked across all major platforms.

  • Is this the best way to develop a CLI in javascript? Doubtful.
  • Is it usable? By my standards sure.
  • Is the output small? No... its smol 😉.

How does this work?

Getting started

Install the dreaded 💀 node_modules 💀 with your package manager of choice:

npm i

Developing

  1. Run the watch script to create a minified CommonJS bundle at dist/out.cjs (using esbuild) and update it when changes are made to any files in ./src/**/*.

  2. There is no testing framework (yet) so to test it run node ./dist/out.cjs.

  3. zx utils can be used to run shell commands, get options and arguments, and access common utils (path, fs, fetch, cd, echo, etc).

  4. src/utils.ts includes a couple functions for normalizing shorthand argument names and showing a formatted help message.

Compiling binaries

pkg is used to create binaries for all major platforms. The package script will create binaries for windows, macos, and linux from the ./dist/out.cjs bundle.

Scripts

Script Description
compile Bundles the source files from the src directory into a single CommonJS module, minifying the output.
watch Runs the compile script in watch mode, recompiling automatically on source file changes.
package Packages the compiled CommonJS module into standalone executables for Windows, macOS, and Linux.

About

A typescript cli template powered by typescript, prettier, zx, esbuild, and pkg

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project