0.10.5 • Published 25 days ago

ryor v0.10.5

Weekly downloads
463
License
MIT
Repository
github
Last release
25 days ago

(R)oll (Y)our (O)wn Task (R)unner for Node.js Projects

license

No system dependencies

Including ryor as a project development dependency is all that's needed to get started.

No plugins

Unlike task runners or pluggable build tools that require often clunky coordination between unevenly maintained 3rd-party plugins (Gulp, Grunt, Webpack, etc.), ryor offers a convenient means of using tools that already do one thing and do it well as CLIs or Node APIs.

Less clutter

Instead of cluttering of a project's root directory and/or package.json file with configuration files/details, runnables can be neatly self-contained.

Concurrency

Similar to shell, npm or NPS scripts, sequences can be composed that run runnables either serially or concurrently.

Get started:

First, install ryor as a project development dependency: npm install -D ryor

Next, create a subdirectory in your project's root directory for your task runner and runnable ES modules ("tasks" is a good option). A runnable module must export a run value, which can be a string, an array or a function (sync or async). Runnable modules should also export a description value describing what the runnable does ("No description provided" is output in the CLI usage information for the runnable otherwise).

Note: "type": "module" in the project's package.json file is required and version 16 or greater of Node.js is recommended.

Create runnables:

A string run value can be used to call a CLI:

tasks/minify.js

export const description = 'Minifies JavaScript'

export const run = 'minifier --option1 --option2 path/to/file'

A configuration file can be included alongside a runnable ES module by simply creating a directory with an index.js file:

tasks/minify/index.js

export const description = 'Minifies JavaScript'

export const run = 'minifier --config tasks/minify/config.js'

An array run value can be used to call other runnables, CLIs or functions in sequence:

tasks/build.js

export const description = 'Creates production build'

export const run = ['transpile', 'minify', () => (...do something), 'echo "Done."',]

An array run value that begins with the flag -c or --concurrent will run anything following it concurrently:

tasks/develop.js

export const description = 'Runs development watchers and server'

export const run = ['-c', 'transpile --watch', 'lint --watch', 'serve', () => (...start some process for development)]

A run function can be passed arguments which are defined in the args export:

tasks/test.js

export const description = 'Runs tester and optionally collects coverage information'

export const args = {
  coverage: {
    alias: 'c',
    description: 'Collect coverage data',
    type: 'boolean'
  }
}

export async function run({ coverage }) {
  const tester = await import('tester')
  const result = await tester.test(coverage)

  console.log(`Tests complete${coverage ? ' and coverage data collected' : ''}`)
}

A run function can return strings, arrays or functions to run:

tasks/build.js

export const description = 'Creates production build'

export const args = {
  quiet: {
    alias: 'q',
    description: 'No output unless errors are encountered',
    type: 'boolean'
  }
}

export function run({ quiet }) {
  const startTime = Date.now()
  const sequence = [`transpile${quiet ? ' -d' : ''}`, `minify${quiet ? ' -d' : ''}`]

  if (!quiet) sequence.push(`echo "Build took ${Date.now() - startTime}ms."`)

  return sequence
}

Create a runner:

Add an index.js file in your runnables directory that specifies your runnables like this:

tasks/index.js

import ryor from 'ryor'

ryor(['build', 'develop', 'test'])

or, if runnables are separated into subdirectories, like this:

import ryor from 'ryor'

ryor([
  ['main', ['build', 'develop', 'test']],
  ['tools', ['eslint', 'jest', 'tsc']],
  ['utilities', ['log']]
])

Usage information:

To output usage information for all runnables, simply run node [directory name].

Example: node tasks

To output usage information for a specific runnable, run node [directory name] <runnable> -h/--help

Example: node tasks develop -h or node tasks develop --help

Note: When defining arguments for a runnable module, note that help and its h alias are both reserved for all modules.

Usage:

To run a single runnable, use node [directory name] <runnable> [...args]

Example: node tasks build -q

To run more than one runnable in a sequence, use +.

Example: node tasks test + build + publish

0.10.5

25 days ago

0.10.4

2 months ago

0.10.2

4 months ago

0.10.1

4 months ago

0.9.26

5 months ago

0.10.0

5 months ago

0.9.25

5 months ago

0.9.23

6 months ago

0.9.24

6 months ago

0.9.20

6 months ago

0.9.21

6 months ago

0.9.22

6 months ago

0.9.18

7 months ago

0.9.19

6 months ago

0.9.17

8 months ago

0.9.15

11 months ago

0.9.16

10 months ago

0.9.14

1 year ago

0.9.12

1 year ago

0.9.13

1 year ago

0.9.9

2 years ago

0.9.10

2 years ago

0.9.11

2 years ago

0.9.8

2 years ago

0.9.7

2 years ago

0.9.6

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.5

2 years ago

0.9.0

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.7

3 years ago

0.7.5

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.22

4 years ago

0.2.21

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.77

7 years ago

0.0.76

7 years ago

0.0.75

7 years ago

0.0.74

7 years ago

0.0.73

7 years ago

0.0.72

7 years ago

0.0.71

7 years ago

0.0.70

7 years ago

0.0.69

7 years ago

0.0.68

7 years ago

0.0.67

7 years ago

0.0.66

7 years ago

0.0.65

7 years ago

0.0.64

7 years ago

0.0.63

7 years ago

0.0.62

7 years ago

0.0.61

7 years ago

0.0.60

7 years ago

0.0.59

7 years ago

0.0.58

7 years ago

0.0.57

7 years ago

0.0.56

7 years ago

0.0.55

7 years ago

0.0.54

7 years ago

0.0.53

7 years ago

0.0.52

7 years ago

0.0.51

7 years ago

0.0.50

7 years ago

0.0.49

7 years ago

0.0.48

7 years ago

0.0.47

7 years ago

0.0.46

7 years ago

0.0.45

7 years ago

0.0.44

7 years ago

0.0.43

7 years ago

0.0.42

7 years ago

0.0.41

7 years ago

0.0.40

7 years ago

0.0.39

7 years ago

0.0.38

7 years ago

0.0.37

7 years ago

0.0.36

7 years ago

0.0.35

7 years ago

0.0.34

7 years ago

0.0.33

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.30

7 years ago

0.0.29

7 years ago

0.0.28

7 years ago

0.0.27

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.12

7 years ago

0.0.13

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.3

7 years ago

0.0.5

7 years ago

0.0.6

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago