Izhaki / pliz

A minimalistic task router for Node.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Workflow Status

Pliz is a cli tool that invokes JS functions (typically development, build, or deploy tasks).

Pliz can be supercharged with Google's zx for ultimate shell power.

Example

When calling:

$ pliz bump minor

A function like this may be invoked:

// plizers.js
import { $ } from 'zx';

export async function bump([versionType]) {
  await $`npm version ${versionType}`;
  await $`git push`;
  await $`git push --tags`;
}

Rationale

With pliz

  • All tasks are written in javascript and can be easily invoked from command line1.
  • Single source of truth, in a single file/folder.
  • Reduction of cognitive load.

1 Existing shell scripts do not need migration as their invocation is still possible (via javascript).

Without pliz

Modern Javascript projects involve a multitude of development tasks. Typically these live in:

  • package.json script commands:
    • shell syntax
    • no comments
    • sometimes require extra dependencies (eg, cross-env)
    • parametrisation and branching can be tricky
  • shell scripts:
    • another syntax to learn and maintain
    • shells may differ across machines
  • scripts folder
    • onboarding and discoverability may be sub-optimal
  • our heads:
    • What's the command to kill a process? Do everyone remember -9? What about Windows?
    • What's the command to enter a docker image interactive shell again?

Quick Start

1. Install Globally

$ npm i -g pliz

2. Create plizers

Create the following plizers.js file (or plizers/index.js) in your project root:

const say = ([text]) => {
  console.log(`${text}!`);
};

module.exports = {
  say,
};
đź’ˇ Using ES6
yarn add --dev @babel/core @babel/register @babel/preset-env

pliz.config.js:

require('@babel/register')({
  presets: [
    [
      '@babel/preset-env',
      {
        targets: { node: 'current' },
      },
    ],
  ],
});

plizers.js:

export const say = ([text]) => {
  console.log(`${text}!`);
};

3. Use

In your shell:

$ pliz say Hello

About

A minimalistic task router for Node.

License:MIT License


Languages

Language:JavaScript 68.9%Language:Gherkin 30.3%Language:Shell 0.7%