➤_ A better way to organize your npm scripts

Overview

➤_ Better Scripts


A better way to organize your npm scripts

See better-scripts.vercel.app →


example

Installation

Install with yarn

yarn add better-scripts -D

Or install with npm

npm install better-scripts --save-dev

Or install with pnpm

pnpm add better-scripts -D

Or use npx for one-time use

npx better-scripts

Usage

Basic setup

Simply run npx better-scripts will read your existing scripts, let's give it a try at first

npx better-scripts

example-at-first

Now, let's move all scripts into better-scripts and add only one "scripts": "better-scripts" in scripts

{
  "scripts": {
    "scripts": "better-scripts"
  },
  "better-scripts": {
    "dev": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test"
  }
}

Then run yarn scripts will read your scripts from better-scripts

yarn scripts

Add script description

Second value as description in array form

{
  "better-scripts": {
    "dev": ["react-scripts start", "Start a development server"]
  }
}

example-at-first

Script as object

You can add more properties in object form

{
  "better-scripts": {
    "dev": {
      "alias": "🧑🏻‍💻 Dev",
      "command": "react-scripts start",
      "desc": "Start a development server"
    }
  }
}

example-at-first

Separate configuration file

You can write your "better-scriprts" out of package.json

Create a scripts.json file in the root directory

{
  "dev": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test"
}

Supported file formats

  • a better-scripts property in package.json ( ⭐️ Recommended)
  • scripts.json ( ⭐️ ⭐️ Recommended)
  • better-scripts.json
  • .better-scriptsrc
  • .better-scriptsrc.json
  • .better-scriptsrc.yaml
  • .better-scriptsrc.yml
  • .better-scriptsrc.js
  • .better-scriptsrc.cjs
  • better-scriptsrc.config.js
  • better-scriptsrc.config.cjs

Specified configuration file

yarn scripts --config custom-config.json

Command line

yarn scripts --help

➤_ A better way to organize your npm scripts

Commands:
  better-scripts              Run your script  [default]
  better-scripts run <name>   Run script non-interactive, usually in CI mode
  better-scripts list [name]  Show all scripts

Options:
  -v, --version  Show version number  [boolean]
  -c, --config   Specified config filepath  [string]
      --track    Show tracked error stack message
  -h, --help     Show help  [boolean]

Examples:
  npx better-scripts                   - Run your script interactive
  npx better-scripts run dev           - Run "dev" script non-interactive
  npx better-scripts run build.deploy  - Run "build" and "deploy" child script in chain order
  npx better-scripts list              - Show all scripts

Default

Interactive with one simple command

yarn scripts

Run

Non-interactive with specific command

yarn scripts run <name>

<name> is your script name that defined in config

Chain operation

yarn scripts run <name.name...>

Skip chaining paths

yarn scripts run <name.name...> --skip

-s, --skip

List

Show all your scripts

yarn scripts list

Compact mode

yarn scripts list --compact

Show specific script name's scripts

yarn scripts list <name>
yarn scripts list <name.name...>

Advanced

The API is not stable yet

Contributors

iamyoki Garker annoyc
iamyoki Garker annoyc

License

MIT

You might also like...

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project Those days of manually updating portfolio website after every new project made are gone ⚡ Yesss . . . you read that right. 😉 portfo

Aug 3, 2021

A tool to document your package.json scripts

A tool to document your package.json scripts

why A tool to document your package.json scripts Why why? As your project grows you add more scripts to package.json. When a new member joins the proj

Sep 22, 2022

A collection of scripts to build offline documentation for your favourite frameworks/libraries. Simply search, copy/paste the commands and enjoy.

Offline-docs A collection of scripts to build offline documentation for your favourite frameworks/libraries. Simply search, copy/paste the commands an

Dec 24, 2022

Minimal versions of popular analytics libraries. Reduce the impact of third-party scripts on your application.

minimal-analytics This project aims to provide minimal implementations of popular analytics libraries. It's aimed at users who want to reduce the impa

Dec 25, 2022

A tool to document your package.json scripts

A tool to document your package.json scripts

why A tool to document your package.json scripts Why why? As your project grows you add more scripts to package.json. When a new member joins the proj

Sep 22, 2022

A Cypress plugin that generates test scripts from your interactions, a replacement Cypress Studio for Cypress v10 🖱 ⌨

A Cypress plugin that generates test scripts from your interactions, a replacement Cypress Studio for Cypress v10 🖱 ⌨

DeploySentinel Cypress Recorder Plugin Create Cypress tests scripts within the Cypress test browser by simply interacting with your application, simil

Dec 15, 2022

"To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete

To Do List "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as compl

Aug 9, 2022

"To-do list" is a tool that helps to organize your day

Todo_List Description "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark th

Nov 12, 2022

"To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete.

Todo_List Description "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark th

Apr 19, 2022
Comments
  • Not picking up scripts in scripts.json

    Not picking up scripts in scripts.json

    According to the docs npx better-scripts --config scripts.json should pick up scripts in a scripts.json file at the root level.

    It doesn't...

    /root package.json: "npx better-scripts --config scripts.json" scripts.json "..all scripts"

    It work when I move back the scripts directly in package JSON under a "better-scripts" property

    scripts.json

    {
        "better-scripts": {
            "test": ["mocha -r ts-node/register test/**/**.spec.ts --exit", "Run unit tests"],
            ...
        }
    }
    
    opened by adadgio 1
Owner
Yoki
🥳 I'm an open source front-end developer 👋🏻.
Yoki
To Do List Application Organize your tasks with simple add and delete functionality. Organize your items with ease.

TODO-LIST To Do List Application Organize your tasks with simple add and delete functionality. Organize your items with ease. Additional description a

Steve 12 Jul 22, 2022
"To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete. It is created with HTML , CSS , JS and webpack and NPM.

My Todo List "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as com

Dyary Raoof Bayz Agha 5 Mar 29, 2022
This project is written in JavaScript with minimal npm scripts and commands

This is an Educational repository, for learning how to install and implement the Webpack, Webpack-CLI and the Webpack-dev-server for a project. This project is written in Javascript with minimal npm scripts and commands. It is a minimal implementation of a To Do list application.

John Omachi 7 Sep 23, 2022
🔗 A better npm link

npx link A safer version of npm link. Why is npm link unsafe? Read the blog post. Features ?? Link dependencies without removing previous links ?? Onl

hiroki osame 85 Dec 24, 2022
Veloorum. An easy way to organize a community or work team

Veloorum ❗️ ❗️ Приложение находится на раннем этапе разработки ❗️ ❗️ ❗️ ❗️ Обновления будут выходить по мере возможности ❗️ ❗️ Исходный код сервера Ve

Vladislav Wagner 2 Jan 30, 2022
Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist ?? ?? ?? ?? ?? The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Mikael Vesavuori 11 Dec 13, 2022
🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing ?? About

Mauro de Souza 476 Jan 1, 2023
Demonstration of how you build full-stack, typed, NPM packages, the right way

NPM Packages - The Right way This repository aims to demonstrate how to build NPM packages the right way. my-package should import the shared code, bu

VulcanJS 61 Nov 27, 2022
A simple project to keep track of your activities. It allows basic CRUD operations to organize your to do list.

todo-list A simple project to keep track of todo list. Built With HTML CSS Javascript Webpack Live Demo You can checkout the live version here Getting

Abdelmejid Oumer Ali 9 Jul 20, 2022