Git Product home page Git Product logo

smol-cli's Introduction

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.

smol-cli's People

Contributors

jacob-shuman avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.