0.0.10 • Published 2 years ago

devcmd v0.0.10

Weekly downloads
501
License
MIT
Repository
github
Last release
2 years ago

devcmd

Development Commands in Node.js and TypeScript

NPM version

What is DevCmd?

  • Automation: Improve your development life, speed up recurring tasks, and reduce errors by automating your development tasks like building, running tests, or bumping versions.
  • Library: DevCmd gives you the tools to make automation simpler, such as easily running external programs (in series or in parallel) or composing smaller commands into more powerful ones.
  • Launcher: With the included devcmd launcher, you can easily start your commands with yarn devcmd or npx devcmd. Additionally, you can globally install devcmd-cli to use the launcher directly and from anywhere.
  • TypeScript & JavaScript: Benefit from the power of the npm ecosystem. Use the safety and abstraction of TypeScript where it helps you. Drop to plain JavaScript when you want to.

Getting Started

  • Install the devcmd package in your workspace:

    $ yarn add -D devcmd
    # - or -
    $ npm install -D devcmd
  • If you want to write commands in TypeScript, you also need typescript and ts-node. If you don't already have these installed, do so now:

    $ yarn add -D typescript ts-node
    # - or -
    $ npm install -D typescript ts-node
  • Create a directory named "dev_cmds" in your workspace (this name is required).

  • Create your commands in this "dev_cmds" directory.

    • The file name (without the extension) is the command name.

    • Each command is run as a standalone script, so top-level statements are permissible. When you want to use Promises (async/await), you need to take care of top-level Promise rejections as well.

    • For example, to create a "build" command, add a file "dev_cmds/build.ts" with the following content (or "dev_cmds/build.js" and drop the type definitions):

      // TypeScript
      import { execPiped, execPipedParallel } from "devcmd";
      
      (async () => {
        console.log("My first Dev Command!");
      
        await execPiped({
          command: "node",
          args: ["-v"],
        });
      
        await execPipedParallel({
          nodeVersion: { command: "npm", args: ["build", "--prod"] },
          npmVersion: { command: "npm", args: ["test"] },
        });
      })().catch((e) => {
        console.error(e);
        process.exit(1);
      });
  • You can now run your commands with the locally installed devcmd CLI. We recommend using yarn or npx to invoke it:

    $ yarn devcmd <script name> [<args of you scripts>...]
    # - or -
    $ npx devcmd <script name> [<args of you scripts>...]
    • For example, to run the "build" command from above:

      $ yarn devcmd build
      # - or -
      $ npx devcmd build
  • If you don't want to type yarn/npx every time, you can install the global launcher tool devcmd-cli. See the package README or the DevCmd project README for more info.

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago