Giter Club home page Giter Club logo

better-scripts's Introduction


➤_ Better Scripts


A better way to organize your npm scripts


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 annoyc
iamyoki annoyc

License

MIT

better-scripts's People

Contributors

iamyoki avatar annoyc 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.