diff --git a/CHANGELOG.md b/CHANGELOG.md index 140b07f..f1b7c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +#### 0.2.33 (2024-08-26) + +##### Bug Fixes + +* register ([6ce87507](https://github.com/zaaack/foy/commit/6ce87507c2465b8aa85d76067a7b59d5a91e7983)) + #### 0.2.32 (2024-08-26) ##### Chores diff --git a/docs/api/assets/highlight.css b/docs/api/assets/highlight.css index 4f9e310..b7c8a1f 100644 --- a/docs/api/assets/highlight.css +++ b/docs/api/assets/highlight.css @@ -11,42 +11,30 @@ --dark-hl-4: #6A9955; --light-hl-5: #0070C1; --dark-hl-5: #4FC1FF; - --light-hl-6: #A31515; - --dark-hl-6: #D4D4D4; - --light-hl-7: #A31515; - --dark-hl-7: #DCDCAA; - --light-hl-8: #001080; - --dark-hl-8: #CE9178; - --light-hl-9: #A31515; - --dark-hl-9: #569CD6; - --light-hl-10: #A31515; - --dark-hl-10: #9CDCFE; - --light-hl-11: #CD3131; - --dark-hl-11: #D4D4D4; - --light-hl-12: #AF00DB; - --dark-hl-12: #C586C0; - --light-hl-13: #001080; - --dark-hl-13: #9CDCFE; - --light-hl-14: #000000FF; - --dark-hl-14: #D4D4D4; - --light-hl-15: #267F99; - --dark-hl-15: #4EC9B0; - --light-hl-16: #098658; - --dark-hl-16: #B5CEA8; + --light-hl-6: #001080; + --dark-hl-6: #9CDCFE; + --light-hl-7: #AF00DB; + --dark-hl-7: #C586C0; + --light-hl-8: #000000FF; + --dark-hl-8: #D4D4D4; + --light-hl-9: #267F99; + --dark-hl-9: #4EC9B0; + --light-hl-10: #098658; + --dark-hl-10: #B5CEA8; + --light-hl-11: #000000; + --dark-hl-11: #9CDCFE; + --light-hl-12: #000000; + --dark-hl-12: #DCDCAA; + --light-hl-13: #795E26; + --dark-hl-13: #C586C0; + --light-hl-14: #000000; + --dark-hl-14: #C586C0; + --light-hl-15: #001080; + --dark-hl-15: #569CD6; + --light-hl-16: #001080; + --dark-hl-16: #C586C0; --light-hl-17: #000000; - --dark-hl-17: #9CDCFE; - --light-hl-18: #000000; - --dark-hl-18: #DCDCAA; - --light-hl-19: #795E26; - --dark-hl-19: #C586C0; - --light-hl-20: #000000; - --dark-hl-20: #C586C0; - --light-hl-21: #001080; - --dark-hl-21: #569CD6; - --light-hl-22: #001080; - --dark-hl-22: #C586C0; - --light-hl-23: #000000; - --dark-hl-23: #C8C8C8; + --dark-hl-17: #C8C8C8; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -70,12 +58,6 @@ --hl-15: var(--light-hl-15); --hl-16: var(--light-hl-16); --hl-17: var(--light-hl-17); - --hl-18: var(--light-hl-18); - --hl-19: var(--light-hl-19); - --hl-20: var(--light-hl-20); - --hl-21: var(--light-hl-21); - --hl-22: var(--light-hl-22); - --hl-23: var(--light-hl-23); --code-background: var(--light-code-background); } } @@ -98,12 +80,6 @@ --hl-15: var(--dark-hl-15); --hl-16: var(--dark-hl-16); --hl-17: var(--dark-hl-17); - --hl-18: var(--dark-hl-18); - --hl-19: var(--dark-hl-19); - --hl-20: var(--dark-hl-20); - --hl-21: var(--dark-hl-21); - --hl-22: var(--dark-hl-22); - --hl-23: var(--dark-hl-23); --code-background: var(--dark-code-background); } } @@ -126,12 +102,6 @@ --hl-15: var(--light-hl-15); --hl-16: var(--light-hl-16); --hl-17: var(--light-hl-17); - --hl-18: var(--light-hl-18); - --hl-19: var(--light-hl-19); - --hl-20: var(--light-hl-20); - --hl-21: var(--light-hl-21); - --hl-22: var(--light-hl-22); - --hl-23: var(--light-hl-23); --code-background: var(--light-code-background); } @@ -154,12 +124,6 @@ --hl-15: var(--dark-hl-15); --hl-16: var(--dark-hl-16); --hl-17: var(--dark-hl-17); - --hl-18: var(--dark-hl-18); - --hl-19: var(--dark-hl-19); - --hl-20: var(--dark-hl-20); - --hl-21: var(--dark-hl-21); - --hl-22: var(--dark-hl-22); - --hl-23: var(--dark-hl-23); --code-background: var(--dark-code-background); } @@ -181,10 +145,4 @@ .hl-15 { color: var(--hl-15); } .hl-16 { color: var(--hl-16); } .hl-17 { color: var(--hl-17); } -.hl-18 { color: var(--hl-18); } -.hl-19 { color: var(--hl-19); } -.hl-20 { color: var(--hl-20); } -.hl-21 { color: var(--hl-21); } -.hl-22 { color: var(--hl-22); } -.hl-23 { color: var(--hl-23); } pre, code { background: var(--code-background); } diff --git a/docs/api/classes/Logger.html b/docs/api/classes/Logger.html index ec71436..c829b85 100644 --- a/docs/api/classes/Logger.html +++ b/docs/api/classes/Logger.html @@ -1,8 +1,8 @@ -Logger | foy

Class Logger

Constructors

constructor +Logger | foy

Class Logger

Constructors

Properties

Accessors

Constructors

Properties

debug: ((...args: any[]) => void) = ...
error: ((...args: any[]) => void) = ...
info: ((...args: any[]) => void) = ...
log: ((...args: any[]) => void) = ...
warn: ((...args: any[]) => void) = ...

Accessors

+

Constructors

Properties

debug: ((...args: any[]) => void) = ...
error: ((...args: any[]) => void) = ...
info: ((...args: any[]) => void) = ...
log: ((...args: any[]) => void) = ...
warn: ((...args: any[]) => void) = ...

Accessors

diff --git a/docs/api/classes/ShellContext.html b/docs/api/classes/ShellContext.html index 98a3e87..04d2990 100644 --- a/docs/api/classes/ShellContext.html +++ b/docs/api/classes/ShellContext.html @@ -1,4 +1,4 @@ -ShellContext | foy

Class ShellContext

Constructors

constructor +ShellContext | foy

Class ShellContext

Constructors

Properties

_logger logCommand sleep @@ -12,21 +12,21 @@ pushd resetEnv spawn -

Constructors

Properties

_logger: Logger = logger
logCommand: boolean = false
sleep: ((ms: number) => Promise<void>) = sleep

Accessors

  • get cwd(): string
  • get current word directory

    -

    Returns string

Methods

  • set/get/delete env +

Constructors

Properties

_logger: Logger = logger
logCommand: boolean = false
sleep: ((ms: number) => Promise<void>) = sleep

Accessors

  • get cwd(): string
  • get current word directory

    +

    Returns string

Methods

  • set/get/delete env set: ctx.env('key', 'val') get: ctx.env('key') delete: ctx.env('key', void 0)

    -

    Parameters

    • key: string

    Returns undefined | string

  • Parameters

    • key: string
    • val: undefined | string

    Returns this

  • exec (multi-line) cmd in *unix platforms, +

    Parameters

    • key: string

    Returns undefined | string

  • Parameters

    • key: string
    • val: undefined | string

    Returns this

  • restart processes when file changes

    -

    Parameters

    • dir: string
    • run: string | string[] | ((p: {
          current: null | ChildProcess;
      }) => void)
    • options: WatchDirOptions & {
          ignore?: ((event: string, file: string) => boolean);
      } = {}

    Returns void

    ctx.monitor('./src', 'tsc')
    ctx.monitor('./src', 'webpack')
    ctx.monitor('./src', 'foy watch')
    ctx.monitor('./src', ['rm -rf dist', 'foy watch'])
    ctx.monitor('./src', async p => {
    await fs.rmrf('dist')
    p.current = ctx.exec('webpack serve')
    }) +

    Parameters

    • cmd: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • restart processes when file changes

    +

    Parameters

    • dir: string
    • run: string | string[] | ((p: {
          current: null | ChildProcess;
      }) => void)
    • options: WatchDirOptions & {
          ignore?: ((event: string, file: string) => boolean);
      } = {}

    Returns void

    ctx.monitor('./src', 'tsc')
    ctx.monitor('./src', 'webpack')
    ctx.monitor('./src', 'foy watch')
    ctx.monitor('./src', ['rm -rf dist', 'foy watch'])
    ctx.monitor('./src', async p => {
    await fs.rmrf('dist')
    p.current = ctx.exec('webpack serve')
    })
    -
+
diff --git a/docs/api/functions/after.html b/docs/api/functions/after.html index cd9d8e9..c9e70a0 100644 --- a/docs/api/functions/after.html +++ b/docs/api/functions/after.html @@ -1 +1 @@ -after | foy

Function after

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

+after | foy

Function after

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

diff --git a/docs/api/functions/before.html b/docs/api/functions/before.html index 8f8c015..28c1614 100644 --- a/docs/api/functions/before.html +++ b/docs/api/functions/before.html @@ -1 +1 @@ -before | foy

Function before

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

+before | foy

Function before

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

diff --git a/docs/api/functions/defaults.html b/docs/api/functions/defaults.html index 61e0534..8f3ae0f 100644 --- a/docs/api/functions/defaults.html +++ b/docs/api/functions/defaults.html @@ -1 +1 @@ -defaults | foy

Function defaults

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • val4: undefined | T
    • defaultVal: T

    Returns T

+defaults | foy

Function defaults

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • val4: undefined | T
    • defaultVal: T

    Returns T

diff --git a/docs/api/functions/dep.html b/docs/api/functions/dep.html index 8df1c94..a9b467c 100644 --- a/docs/api/functions/dep.html +++ b/docs/api/functions/dep.html @@ -1 +1 @@ -dep | foy

Function dep

+dep | foy

Function dep

diff --git a/docs/api/functions/desc.html b/docs/api/functions/desc.html index b6f651f..a86b4cc 100644 --- a/docs/api/functions/desc.html +++ b/docs/api/functions/desc.html @@ -1,2 +1,2 @@ desc | foy

Function desc

  • Define task description

    -

    Parameters

    • desc: string

    Returns void

+

Parameters

Returns void

diff --git a/docs/api/functions/exec.html b/docs/api/functions/exec.html index 60898b2..72430b8 100644 --- a/docs/api/functions/exec.html +++ b/docs/api/functions/exec.html @@ -1 +1 @@ -exec | foy

Function exec

+exec | foy

Function exec

diff --git a/docs/api/functions/execa-1.html b/docs/api/functions/execa-1.html index a087db9..eface6d 100644 --- a/docs/api/functions/execa-1.html +++ b/docs/api/functions/execa-1.html @@ -3,7 +3,7 @@

Parameters

Returns ExecaChildProcess<string>

A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

-
import execa = require('execa');

(async () => {
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout);
//=> 'unicorns'

// Cancelling a spawned process
const subprocess = execa('node');
setTimeout(() => { spawned.cancel() }, 1000);
try {
await subprocess;
} catch (error) {
console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
}
})();

// Pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout); +
import execa = require('execa');

(async () => {
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout);
//=> 'unicorns'

// Cancelling a spawned process
const subprocess = execa('node');
setTimeout(() => { spawned.cancel() }, 1000);
try {
await subprocess;
} catch (error) {
console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
}
})();

// Pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • diff --git a/docs/api/functions/namespace.html b/docs/api/functions/namespace.html index 665c4b0..1eb29f2 100644 --- a/docs/api/functions/namespace.html +++ b/docs/api/functions/namespace.html @@ -1,6 +1,6 @@ namespace | foy

    Function namespace

    • Create namespace prefix for inner tasks

      Parameters

      • ns: string

        namespace

        -
      • fn: ((ns: string) => void)
          • (ns): void
          • Parameters

            • ns: string

            Returns void

      Returns void

      namespace('client', ns => {
      task('run', async ctx => {
      logger.log(ns) // 'client'
      await ctx.exec('<run cmd>')
      })
      })
      namespace('server', ns => {
      task('run', async ctx => {
      logger.log(ns) // 'server'
      await ctx.exec('<run cmd>')
      })
      })

      ==========
      $ yarn foy client:run
      $ yarn foy server:run +
    • fn: ((ns: string) => void)
        • (ns): void
        • Parameters

          • ns: string

          Returns void

    Returns void

    namespace('client', ns => {
    task('run', async ctx => {
    logger.log(ns) // 'client'
    await ctx.exec('<run cmd>')
    })
    })
    namespace('server', ns => {
    task('run', async ctx => {
    logger.log(ns) // 'server'
    await ctx.exec('<run cmd>')
    })
    })

    ==========
    $ yarn foy client:run
    $ yarn foy server:run
    -
    +
    diff --git a/docs/api/functions/onerror.html b/docs/api/functions/onerror.html index d1aa951..8542339 100644 --- a/docs/api/functions/onerror.html +++ b/docs/api/functions/onerror.html @@ -1 +1 @@ -onerror | foy

    Function onerror

    • Parameters

      • fn: ((err: Error, t: Task<any>) => void | Promise<void>)
          • (err, t): void | Promise<void>
          • Parameters

            • err: Error
            • t: Task<any>

            Returns void | Promise<void>

      Returns void

    +onerror | foy

    Function onerror

    • Parameters

      • fn: ((err: Error, t: Task<any>) => void | Promise<void>)
          • (err, t): void | Promise<void>
          • Parameters

            • err: Error
            • t: Task<any>

            Returns void | Promise<void>

      Returns void

    diff --git a/docs/api/functions/option.html b/docs/api/functions/option.html index adacdb4..b535480 100644 --- a/docs/api/functions/option.html +++ b/docs/api/functions/option.html @@ -1,2 +1,2 @@ option | foy

    Function option

    • Define a task cli option

      -

      Parameters

      • rawName: string
      • description: string
      • Optionalconfig: OptionConfig

      Returns void

    +

    Parameters

    • rawName: string
    • description: string
    • Optionalconfig: OptionConfig

    Returns void

    diff --git a/docs/api/functions/setGlobalOptions.html b/docs/api/functions/setGlobalOptions.html index 1fe1e95..644d399 100644 --- a/docs/api/functions/setGlobalOptions.html +++ b/docs/api/functions/setGlobalOptions.html @@ -1,2 +1,2 @@ setGlobalOptions | foy

    Function setGlobalOptions

    • Set global options for all tasks.

      -

      Parameters

      Returns void

    +

    Parameters

    Returns void

    diff --git a/docs/api/functions/setOption.html b/docs/api/functions/setOption.html index 9538a0b..59db92d 100644 --- a/docs/api/functions/setOption.html +++ b/docs/api/functions/setOption.html @@ -1,2 +1,2 @@ setOption | foy

    Function setOption

    • Set options for next task.

      -

      Parameters

      • options: Partial<{
            desc: undefined | string;
            loading: undefined | boolean;
            optionDefs: OptionDef[];
            strict: undefined | boolean;
        }>

      Returns void

    +

    Parameters

    • options: Partial<{
          desc: undefined | string;
          loading: undefined | boolean;
          optionDefs: OptionDef[];
          strict: undefined | boolean;
      }>

    Returns void

    diff --git a/docs/api/functions/shell.html b/docs/api/functions/shell.html index efec225..8989072 100644 --- a/docs/api/functions/shell.html +++ b/docs/api/functions/shell.html @@ -1 +1 @@ -shell | foy

    Function shell

    • Parameters

      Returns Promise<any>

    +shell | foy

    Function shell

    • Parameters

      Returns Promise<any>

    diff --git a/docs/api/functions/sleep.html b/docs/api/functions/sleep.html index 67a0145..b383880 100644 --- a/docs/api/functions/sleep.html +++ b/docs/api/functions/sleep.html @@ -1 +1 @@ -sleep | foy

    Function sleep

    • Parameters

      • ms: number

      Returns Promise<void>

    +sleep | foy

    Function sleep

    • Parameters

      • ms: number

      Returns Promise<void>

    diff --git a/docs/api/functions/spawn.html b/docs/api/functions/spawn.html index 73b7ec8..141b445 100644 --- a/docs/api/functions/spawn.html +++ b/docs/api/functions/spawn.html @@ -3,10 +3,10 @@

    Parameters

    • file: string

      The program/script to execute.

    • Optionalarguments: readonly string[]

      Arguments to pass to file on execution.

    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

    A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

    -
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa('echo', ['unicorns']);
    console.log(stdout);
    //=> 'unicorns'

    // Cancelling a spawned process
    const subprocess = execa('node');
    setTimeout(() => { spawned.cancel() }, 1000);
    try {
    await subprocess;
    } catch (error) {
    console.log(subprocess.killed); // true
    console.log(error.isCanceled); // true
    }
    })();

    // Pipe the child process stdout to the current stdout
    execa('echo', ['unicorns']).stdout.pipe(process.stdout); +
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa('echo', ['unicorns']);
    console.log(stdout);
    //=> 'unicorns'

    // Cancelling a spawned process
    const subprocess = execa('node');
    setTimeout(() => { spawned.cancel() }, 1000);
    try {
    await subprocess;
    } catch (error) {
    console.log(subprocess.killed); // true
    console.log(error.isCanceled); // true
    }
    })();

    // Pipe the child process stdout to the current stdout
    execa('echo', ['unicorns']).stdout.pipe(process.stdout);
    -
  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Methods

  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Methods

    command commandSync node sync @@ -15,7 +15,7 @@

    The shell option must be used if the command uses shell-specific features, as opposed to being a simple file followed by its arguments.

    Parameters

    • command: string

      The program/script to execute and its arguments.

    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

    A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

    -
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa.command('echo unicorns');
    console.log(stdout);
    //=> 'unicorns'
    })(); +
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa.command('echo unicorns');
    console.log(stdout);
    //=> 'unicorns'
    })();
  • Parameters

    • command: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

    • Same as execa.command() but synchronous.

      diff --git a/docs/api/functions/strict.html b/docs/api/functions/strict.html index fb499e1..9650d7e 100644 --- a/docs/api/functions/strict.html +++ b/docs/api/functions/strict.html @@ -1,2 +1,2 @@ strict | foy

      Function strict

      • Define task cli options are strict, which means it will throw an error if you passed undefined options.

        -

        Returns void

      +

      Returns void

    diff --git a/docs/api/functions/task-1.html b/docs/api/functions/task-1.html index 449ac61..4114c8f 100644 --- a/docs/api/functions/task-1.html +++ b/docs/api/functions/task-1.html @@ -1,2 +1,2 @@ task | foy

    Function task

    Define a task

    -
    +
    diff --git a/docs/api/functions/throttle.html b/docs/api/functions/throttle.html index eae1c83..028746b 100644 --- a/docs/api/functions/throttle.html +++ b/docs/api/functions/throttle.html @@ -1 +1 @@ -throttle | foy

    Function throttle

    • Type Parameters

      • T extends ((...args: any[]) => void)

      Parameters

      • cb: T
      • ms: number
      • getArgsKey: ((args: any[]) => string) = ...
          • (args): string
          • Parameters

            • args: any[]

            Returns string

      Returns T

    +throttle | foy

    Function throttle

    • Type Parameters

      • T extends ((...args: any[]) => void)

      Parameters

      • cb: T
      • ms: number
      • getArgsKey: ((args: any[]) => string) = ...
          • (args): string
          • Parameters

            • args: any[]

            Returns string

      Returns T

    diff --git a/docs/api/index.html b/docs/api/index.html index 6059e08..6002dab 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -55,7 +55,7 @@

    which will create a simple Foyfile.js in the current folder:

    -
    // Foyfile.js
    const { task } = require('foy')

    task('build', async ctx => {
    await ctx.exec('tsc')
    }) +
    // Foyfile.js
    const { task } = require('foy')

    task('build', async ctx => {
    await ctx.exec('tsc')
    })

    You can also generate a Foyfile.ts via

    @@ -67,67 +67,67 @@

    You can also add some options and a description to your tasks:

    -
    import { task, desc, option, strict } from 'foy'

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task('build', async ctx => {
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    }) +
    import { task, desc, option, strict } from 'foy'

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task('build', async ctx => {
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    })

    And, if using TypeScript, add types to your options through the task generic:

    -
    import { task, desc, option, strict } from 'foy'

    type BuildOptions = {
    watch: boolean
    }

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task<BuildOptions>('build', async ctx => { // ctx.options now has type BuildOptions instead of unknown
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    }) +
    import { task, desc, option, strict } from 'foy'

    type BuildOptions = {
    watch: boolean
    }

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task<BuildOptions>('build', async ctx => { // ctx.options now has type BuildOptions instead of unknown
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    })
    foy build -w
     

    Warning! If you want to set flags like strict for all tasks, please use setGlobalOptions:

    -
    import { setGlobalOptions } from 'foy'

    setGlobalOptions({ strict: true }) // all tasks' options will be strict.

    option('-aa') // strict via default
    task('dev', async ctx => {

    })
    option('-bb') // strict via default
    task('build', async ctx => {

    })
    +
    import { setGlobalOptions } from 'foy'

    setGlobalOptions({ strict: true }) // all tasks' options will be strict.

    option('-aa') // strict via default
    task('dev', async ctx => {

    })
    option('-bb') // strict via default
    task('build', async ctx => {

    })
    -
    import { fs, task } from 'foy'

    task('some task', async ctx => {
    await fs.rmrf('/some/dir/or/file') // Remove directory or file
    await fs.copy('/src', '/dist') // Copy folder or file
    let json = await fs.readJson('./xx.json')
    await ctx
    .env('NODE_ENV', 'production')
    .cd('./src')
    .exec('some command') // Execute an command
    let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`.
    }) +
    import { fs, task } from 'foy'

    task('some task', async ctx => {
    await fs.rmrf('/some/dir/or/file') // Remove directory or file
    await fs.copy('/src', '/dist') // Copy folder or file
    let json = await fs.readJson('./xx.json')
    await ctx
    .env('NODE_ENV', 'production')
    .cd('./src')
    .exec('some command') // Execute an command
    let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`.
    })
    -
    import { task, logger } from 'foy'
    import * as axios from 'axios'

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    logger.info(res.data)
    }) +
    import { task, logger } from 'foy'
    import * as axios from 'axios'

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    logger.info(res.data)
    })
    -

    import { task } from 'foy'
    import * as axios from 'axios'

    task('test', async ctx => {
    await ctx.exec('mocha')
    })

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    console.log(res.data)
    await ctx.exec('build my awesome project')
    })
    task(
    'publish:patch',
    ['test', 'build'], // Run test and build before publish
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    ) +

    import { task } from 'foy'
    import * as axios from 'axios'

    task('test', async ctx => {
    await ctx.exec('mocha')
    })

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    console.log(res.data)
    await ctx.exec('build my awesome project')
    })
    task(
    'publish:patch',
    ['test', 'build'], // Run test and build before publish
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    Dependencies run serially by default but you can specify when a task should be run concurrently.

    Example: Passing running options to dependencies:

    -
    task(
    'publish:patch',
    [{
    name: 'test',
    async: true, // run test parallelly
    force: true, // force rerun test whether it has been executed before or not.
    }, {
    name: 'build',
    async: true,
    force: true,
    },],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /* Sugar version */
    task(
    'publish:patch',
    [ 'test'.async().force(),
    'build'.async().force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /*
    Priority for async tasks

    Default is 0, higher values will be run earlier; so, in this next example, `build` will be run before `test`.
    (Note: If you have multiple async dependencies with same priority, they will be executed in parallel.)
    */
    task(
    'publish:patch',
    [ 'test'.async(0).force(),
    'build'.async(1).force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    ) +
    task(
    'publish:patch',
    [{
    name: 'test',
    async: true, // run test parallelly
    force: true, // force rerun test whether it has been executed before or not.
    }, {
    name: 'build',
    async: true,
    force: true,
    },],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /* Sugar version */
    task(
    'publish:patch',
    [ 'test'.async().force(),
    'build'.async().force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /*
    Priority for async tasks

    Default is 0, higher values will be run earlier; so, in this next example, `build` will be run before `test`.
    (Note: If you have multiple async dependencies with same priority, they will be executed in parallel.)
    */
    task(
    'publish:patch',
    [ 'test'.async(0).force(),
    'build'.async(1).force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    You can also pass options to dependencies:

    -
    task('task1', async ctx => {
    console.log(ctx.options) // "{ forceRebuild: true, lazyOptions: 1 }"
    console.log(ctx.global.options) // options from command line "{ a: 1 }"
    })


    task('task2', [{
    name: 'task1',
    options: {
    forceRebuild: true,
    },
    // Some options that rely on ctx or asynchronization,
    // it will be merged to options.
    resolveOptions: async ctx => {
    return { lazyOptions: 1 }
    }
    }])

    // foy task2 -a 1 +
    task('task1', async ctx => {
    console.log(ctx.options) // "{ forceRebuild: true, lazyOptions: 1 }"
    console.log(ctx.global.options) // options from command line "{ a: 1 }"
    })


    task('task2', [{
    name: 'task1',
    options: {
    forceRebuild: true,
    },
    // Some options that rely on ctx or asynchronization,
    // it will be merged to options.
    resolveOptions: async ctx => {
    return { lazyOptions: 1 }
    }
    }])

    // foy task2 -a 1

    To avoid name collisions, Foy provides namespaces to group tasks via the namespace function:

    -
    import { task, namespace } from 'foy'

    namespace('client', ns => {
    before(() => {
    logger.info('before')
    })
    after(() => {
    logger.info('after')
    })
    onerror(() => {
    logger.info('onerror')
    })
    task('start', async ctx => { /* ... */ }) // client:start
    task('build', async ctx => { /* ... */ }) // client:build
    task('watch', async ctx => { /* ... */ }) // client:watch
    namespace('proj1', ns => { // nested namespace
    onerror(() => {
    logger.info('onerror', ns)
    })
    task('start', async ctx => { /* ... */ }) // client:proj1:start

    })
    })

    namespace('server', ns => {
    task('build', async ctx => { /* ... */ }) // server:build
    task('start', async ctx => { /* ... */ }) // server:start
    task('watch', async ctx => { /* ... */ }) // server:watch
    })

    task('start', ['client:start'.async(), 'server:start'.async()]) // start

    // foy start
    // foy client:build +
    import { task, namespace } from 'foy'

    namespace('client', ns => {
    before(() => {
    logger.info('before')
    })
    after(() => {
    logger.info('after')
    })
    onerror(() => {
    logger.info('onerror')
    })
    task('start', async ctx => { /* ... */ }) // client:start
    task('build', async ctx => { /* ... */ }) // client:build
    task('watch', async ctx => { /* ... */ }) // client:watch
    namespace('proj1', ns => { // nested namespace
    onerror(() => {
    logger.info('onerror', ns)
    })
    task('start', async ctx => { /* ... */ }) // client:proj1:start

    })
    })

    namespace('server', ns => {
    task('build', async ctx => { /* ... */ }) // server:build
    task('start', async ctx => { /* ... */ }) // server:start
    task('watch', async ctx => { /* ... */ }) // server:watch
    })

    task('start', ['client:start'.async(), 'server:start'.async()]) // start

    // foy start
    // foy client:build

    Foy wraps the NodeJS's fs (file system) module with a promise-based API, so you can easily use async/await patterns, if you prefer. Foy also implements some useful utility functions for build scripts not present in NodeJS's built-in modules.

    -
    import { fs } from 'foy'


    task('build', async ctx => {
    let f = await fs.readFileSync('./assets/someFile')

    // copy file or directory
    await fs.copy('./fromPath', './toPath')

    // watch a directory
    await fs.watchDir('./src', (event, filename) => {
    logger.info(event, filename)
    })

    // make directory with parent directories
    await fs.mkdirp('./some/directory/with/parents/not/exists')

    // write file will auto create missing parent directories
    await fs.outputFile('./some/file/with/parents/not/exists', 'file data')

    // write json file will auto create missing parent directories
    await fs.outputJson('./some/file/with/parents/not/exists', {text: 'json data'})
    let file = await fs.readJson('./some/jsonFile')

    // iterate directory tree
    await fs.iter('./src', async (path, stat) => {
    if (stat.isDirectory()) {
    logger.info('directory:', path)
    // skip scan node_modules
    if (path.endsWith('node_modules')) {
    return true
    }
    } else if (stat.isFile()) {
    logger.warn('file:', path)
    }
    })
    }) +
    import { fs } from 'foy'


    task('build', async ctx => {
    let f = await fs.readFileSync('./assets/someFile')

    // copy file or directory
    await fs.copy('./fromPath', './toPath')

    // watch a directory
    await fs.watchDir('./src', (event, filename) => {
    logger.info(event, filename)
    })

    // make directory with parent directories
    await fs.mkdirp('./some/directory/with/parents/not/exists')

    // write file will auto create missing parent directories
    await fs.outputFile('./some/file/with/parents/not/exists', 'file data')

    // write json file will auto create missing parent directories
    await fs.outputJson('./some/file/with/parents/not/exists', {text: 'json data'})
    let file = await fs.readJson('./some/jsonFile')

    // iterate directory tree
    await fs.iter('./src', async (path, stat) => {
    if (stat.isDirectory()) {
    logger.info('directory:', path)
    // skip scan node_modules
    if (path.endsWith('node_modules')) {
    return true
    }
    } else if (stat.isFile()) {
    logger.warn('file:', path)
    }
    })
    })

    Foy includes a light-weight built-in logger

    -
    import { logger } from 'foy'

    task('build', async ctx => {

    logger.debug('debug', { aa: 1})
    logger.info('info')
    logger.warn('warn')
    logger.error('error')

    })
    +
    import { logger } from 'foy'

    task('build', async ctx => {

    logger.debug('debug', { aa: 1})
    logger.info('info')
    logger.warn('warn')
    logger.error('error')

    })

    A simple wrapper for sindresorhus's lovely module execa

    -
    import { logger } from 'foy'

    task('build', async ctx => {
    await ctx.exec('tsc')

    // run multiple commands synchronously
    await ctx.exec([
    'tsc --outDir ./lib',
    'tsc --module es6 --outDir ./es',
    ])

    // run multiple commands concurrently
    await Promise.all([
    ctx.exec('eslint'),
    ctx.exec('tsc'),
    ctx.exec('typedoc'),
    ])
    // restart process when file changes
    ctx.monitor('./src', 'node ./dist')
    ctx.monitor('./src', ['rm -rf dist', 'tsc', 'node dist'])
    ctx.monitor('./src', async () => {
    await ctx.run('build:server')
    await ctx.exec('node ./dist') // auth detect long-running process when using ctx.exec
    })
    ctx.monitor('./src', async (p) => {
    // manually point out the process need to be killed when restart
    p.current = require('child_process').exec('node dist')
    })
    })

    +
    import { logger } from 'foy'

    task('build', async ctx => {
    await ctx.exec('tsc')

    // run multiple commands synchronously
    await ctx.exec([
    'tsc --outDir ./lib',
    'tsc --module es6 --outDir ./es',
    ])

    // run multiple commands concurrently
    await Promise.all([
    ctx.exec('eslint'),
    ctx.exec('tsc'),
    ctx.exec('typedoc'),
    ])
    // restart process when file changes
    ctx.monitor('./src', 'node ./dist')
    ctx.monitor('./src', ['rm -rf dist', 'tsc', 'node dist'])
    ctx.monitor('./src', async () => {
    await ctx.run('build:server')
    await ctx.exec('node ./dist') // auth detect long-running process when using ctx.exec
    })
    ctx.monitor('./src', async (p) => {
    // manually point out the process need to be killed when restart
    p.current = require('child_process').exec('node dist')
    })
    })

    If you use Foy in CI servers, you won't want the loading spinners as most CI servers will log stdout and stderr in discreet frames not meant for continuous streaming animations. Luckily, Foy has already considered this! You can simply disable the loading animation like this:

    -
    import { task, setGlobalOptions } from 'foy'

    setGlobalOptions({ loading: false }) // disable loading animations

    task('test', async cyx => { /* ... */ })
    /*
    $ foy test
    DependencyGraph for task [test]:
    ─ test

    Task: test
    ...
    */ +
    import { task, setGlobalOptions } from 'foy'

    setGlobalOptions({ loading: false }) // disable loading animations

    task('test', async cyx => { /* ... */ })
    /*
    $ foy test
    DependencyGraph for task [test]:
    ─ test

    Task: test
    ...
    */

    You can add lifecycle hooks via the before, after, and onerror functions.

    -
    import { before, after, onerror } from 'foy'
    before(() => { // do something before all tasks tree start
    // ...
    })
    after(() => { // do something after all tasks tree finished
    // ...
    })
    onerror((err) => { // do something when error happens
    // ...
    }) +
    import { before, after, onerror } from 'foy'
    before(() => { // do something before all tasks tree start
    // ...
    })
    after(() => { // do something after all tasks tree finished
    // ...
    })
    onerror((err) => { // do something when error happens
    // ...
    })
    -

    task('task1', async ctx => { /* ... */ })
    task('task2', async ctx => {
    // do things before task1

    // run task1 manually, so we can
    // do things before or after it
    await ctx.run('task1')

    // do things after task1
    })
    +

    task('task1', async ctx => { /* ... */ })
    task('task2', async ctx => {
    // do things before task1

    // run task1 manually, so we can
    // do things before or after it
    await ctx.run('task1')

    // do things after task1
    })
    -

    task('build', async ctx => { /* build your project */ })


    let p = null
    task('watch', async ctx => {
    ctx.monitor('./src', async ()=> {
    ctx.exec('node ./src/server.ts')
    })
    }) +

    task('build', async ctx => { /* build your project */ })


    let p = null
    task('watch', async ctx => {
    ctx.monitor('./src', async ()=> {
    ctx.exec('node ./src/server.ts')
    })
    })

    # Write Foyfile in ts, enabled by default
    foy -r ts-node/register -c ./some/Foyfile.ts build

    # Write Foyfile in coffee
    foy -r coffeescript/register -c ./some/Foyfile.coffee build
    diff --git a/docs/api/interfaces/GlobalOptions.html b/docs/api/interfaces/GlobalOptions.html index a13eb24..2802497 100644 --- a/docs/api/interfaces/GlobalOptions.html +++ b/docs/api/interfaces/GlobalOptions.html @@ -1,4 +1,4 @@ -GlobalOptions | foy

    Interface GlobalOptions

    interface GlobalOptions {
        indent?: number;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        options?: any;
        rawArgs?: string[];
        showTaskDuration?: boolean;
        strict?: boolean;
    }

    Properties

    indent? +GlobalOptions | foy

    Interface GlobalOptions

    interface GlobalOptions {
        indent?: number;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        options?: any;
        rawArgs?: string[];
        showTaskDuration?: boolean;
        strict?: boolean;
    }

    Properties

    indent?: number
    loading?: boolean
    true
    +

    Properties

    indent?: number
    loading?: boolean
    true
     
    -
    logCommand?: boolean
    logger?: ILoggerProps
    options?: any
    rawArgs?: string[]
    showTaskDuration?: boolean
    true
    +
    logCommand?: boolean
    logger?: ILoggerProps
    options?: any
    rawArgs?: string[]
    showTaskDuration?: boolean
    true
     
    -
    strict?: boolean

    Whether task options only allow defined options, default false

    +
    strict?: boolean

    Whether task options only allow defined options, default false

    false
     
    -
    +
    diff --git a/docs/api/interfaces/ILogInfo.html b/docs/api/interfaces/ILogInfo.html index e5b1394..25f0614 100644 --- a/docs/api/interfaces/ILogInfo.html +++ b/docs/api/interfaces/ILogInfo.html @@ -1,8 +1,8 @@ -ILogInfo | foy

    Interface ILogInfo

    interface ILogInfo {
        args: any[];
        filterLevelNum: number;
        formatedTime: string;
        level:
            | "error"
            | "debug"
            | "info"
            | "warn";
        levelNum: number;
        message: string;
        time: Date;
    }

    Properties

    args +ILogInfo | foy

    Interface ILogInfo

    interface ILogInfo {
        args: any[];
        filterLevelNum: number;
        formatedTime: string;
        level:
            | "error"
            | "debug"
            | "info"
            | "warn";
        levelNum: number;
        message: string;
        time: Date;
    }

    Properties

    args: any[]
    filterLevelNum: number
    formatedTime: string
    level:
        | "error"
        | "debug"
        | "info"
        | "warn"
    levelNum: number
    message: string
    time: Date
    +

    Properties

    args: any[]
    filterLevelNum: number
    formatedTime: string
    level:
        | "error"
        | "debug"
        | "info"
        | "warn"
    levelNum: number
    message: string
    time: Date
    diff --git a/docs/api/interfaces/ILoggerProps.html b/docs/api/interfaces/ILoggerProps.html index a099566..e89cc99 100644 --- a/docs/api/interfaces/ILoggerProps.html +++ b/docs/api/interfaces/ILoggerProps.html @@ -1,7 +1,7 @@ -ILoggerProps | foy

    Interface ILoggerProps

    interface ILoggerProps {
        hideConsole?: boolean;
        level?: string;
        levelColor?: {
            debug: ((v: string) => string);
            error: ((v: string) => string);
            info: ((v: string) => string);
            warn: ((v: string) => string);
        };
        logTime?: boolean | (() => string);
        format?(level: string, time: string, color: ((v: string) => string), args: any[]): string;
        onLog?(info: ILogInfo): void;
    }

    Properties

    hideConsole? +ILoggerProps | foy

    Interface ILoggerProps

    interface ILoggerProps {
        hideConsole?: boolean;
        level?: string;
        levelColor?: {
            debug: ((v: string) => string);
            error: ((v: string) => string);
            info: ((v: string) => string);
            warn: ((v: string) => string);
        };
        logTime?: boolean | (() => string);
        format?(level: string, time: string, color: ((v: string) => string), args: any[]): string;
        onLog?(info: ILogInfo): void;
    }

    Properties

    hideConsole?: boolean
    level?: string
    levelColor?: {
        debug: ((v: string) => string);
        error: ((v: string) => string);
        info: ((v: string) => string);
        warn: ((v: string) => string);
    }
    logTime?: boolean | (() => string)

    Methods

    • Parameters

      • level: string
      • time: string
      • color: ((v: string) => string)
          • (v): string
          • Parameters

            • v: string

            Returns string

      • args: any[]

      Returns string

    +

    Properties

    hideConsole?: boolean
    level?: string
    levelColor?: {
        debug: ((v: string) => string);
        error: ((v: string) => string);
        info: ((v: string) => string);
        warn: ((v: string) => string);
    }
    logTime?: boolean | (() => string)

    Methods

    • Parameters

      • level: string
      • time: string
      • color: ((v: string) => string)
          • (v): string
          • Parameters

            • v: string

            Returns string

      • args: any[]

      Returns string

    diff --git a/docs/api/interfaces/Task.html b/docs/api/interfaces/Task.html index d5453dc..b309b12 100644 --- a/docs/api/interfaces/Task.html +++ b/docs/api/interfaces/Task.html @@ -1,4 +1,4 @@ -Task | foy

    Interface Task<O>

    interface Task<O> {
        async?: number | boolean;
        dependencies?: TaskDep<any>[];
        desc?: string;
        fn?: ((ctx: TaskContext<O>) => void | Promise<void>);
        force?: boolean;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        name: string;
        namespaces: string[];
        options: O;
        rawArgs: string[];
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        strict?: boolean;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Properties

    async? +Task | foy

    Interface Task<O>

    interface Task<O> {
        async?: number | boolean;
        dependencies?: TaskDep<any>[];
        desc?: string;
        fn?: ((ctx: TaskContext<O>) => void | Promise<void>);
        force?: boolean;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        name: string;
        namespaces: string[];
        options: O;
        rawArgs: string[];
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        strict?: boolean;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Properties

    async? dependencies? desc? fn? @@ -16,19 +16,19 @@ If order doesn't matter and you want better performance via parallel, you can mark it as asynchronized. Asynchronized will run immediately whether there are synchronized tasks before them or not. You can pass a number as the priority of asynchronized tasks, bigger is formmer.

    -
    dependencies?: TaskDep<any>[]
    desc?: string
    fn?: ((ctx: TaskContext<O>) => void | Promise<void>)
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    -
    loading?: boolean

    whether show loading

    -
    globalOptions.loading
    +
    dependencies?: TaskDep<any>[]
    desc?: string
    fn?: ((ctx: TaskContext<O>) => void | Promise<void>)
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    +
    loading?: boolean

    whether show loading

    +
    globalOptions.loading
     
    -
    logCommand?: boolean

    whether log executed command

    -
    globalOptions.logCommand
    +
    logCommand?: boolean

    whether log executed command

    +
    globalOptions.logCommand
     
    -
    logger?: ILoggerProps
    name: string
    namespaces: string[]
    options: O

    Parsed options

    -
    rawArgs: string[]

    Raw arg strings

    -
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    strict?: boolean

    Whether task options only allow defined options, default false

    +
    logger?: ILoggerProps
    name: string
    namespaces: string[]
    options: O

    Parsed options

    +
    rawArgs: string[]

    Raw arg strings

    +
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    strict?: boolean

    Whether task options only allow defined options, default false

    false
     
    -
    +
    diff --git a/docs/api/interfaces/TaskDep.html b/docs/api/interfaces/TaskDep.html index 8dc8e3a..adb4703 100644 --- a/docs/api/interfaces/TaskDep.html +++ b/docs/api/interfaces/TaskDep.html @@ -1,4 +1,4 @@ -TaskDep | foy

    Interface TaskDep<O>

    interface TaskDep<O> {
        async?: number | boolean;
        force?: boolean;
        name: string;
        options?: O;
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        [k: string]: any;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Indexable

    • [k: string]: any

    Properties

    async? +TaskDep | foy

    Interface TaskDep<O>

    interface TaskDep<O> {
        async?: number | boolean;
        force?: boolean;
        name: string;
        options?: O;
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        [k: string]: any;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Indexable

    • [k: string]: any

    Properties

    async? force? name options? @@ -7,6 +7,6 @@ If order doesn't matter and you want better performance via parallel, you can mark it as asynchronized. Asynchronized will run immediately whether there are synchronized tasks before them or not. You can pass a number as the priority of asynchronized tasks, bigger is formmer.

    -
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    -
    name: string
    options?: O

    Parsed options

    -
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    +
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    +
    name: string
    options?: O

    Parsed options

    +
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    diff --git a/docs/api/interfaces/WriteOptions.html b/docs/api/interfaces/WriteOptions.html index 0924a9d..971e60f 100644 --- a/docs/api/interfaces/WriteOptions.html +++ b/docs/api/interfaces/WriteOptions.html @@ -1,4 +1,4 @@ -WriteOptions | foy

    Interface WriteOptions

    interface WriteOptions {
        encoding?: BufferEncoding;
        flag?: string;
        mode?: string | number;
    }

    Properties

    encoding? +WriteOptions | foy

    Interface WriteOptions

    interface WriteOptions {
        encoding?: BufferEncoding;
        flag?: string;
        mode?: string | number;
    }

    Properties

    Properties

    encoding?: BufferEncoding
    flag?: string
    mode?: string | number
    +

    Properties

    encoding?: BufferEncoding
    flag?: string
    mode?: string | number
    diff --git a/docs/api/interfaces/execa.CommonOptions.html b/docs/api/interfaces/execa.CommonOptions.html index c83f286..496625a 100644 --- a/docs/api/interfaces/execa.CommonOptions.html +++ b/docs/api/interfaces/execa.CommonOptions.html @@ -42,7 +42,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -54,14 +54,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -74,11 +74,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -129,7 +129,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.KillOptions.html b/docs/api/interfaces/execa.KillOptions.html index 26a7ea1..909ff32 100644 --- a/docs/api/interfaces/execa.KillOptions.html +++ b/docs/api/interfaces/execa.KillOptions.html @@ -1,7 +1,7 @@ KillOptions | foy

    Interface KillOptions

    interface KillOptions {
        forceKillAfterTimeout?: number | false;
    }

    Properties

    forceKillAfterTimeout?: number | false

    Milliseconds to wait for the child process to terminate before sending SIGKILL.

    Can be disabled with false.

    -
    5000
    +
    5000
     
    diff --git a/docs/api/interfaces/execa.NodeOptions.html b/docs/api/interfaces/execa.NodeOptions.html index 2e6bb1e..3066cd5 100644 --- a/docs/api/interfaces/execa.NodeOptions.html +++ b/docs/api/interfaces/execa.NodeOptions.html @@ -45,7 +45,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -57,14 +57,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -78,19 +78,19 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    nodeOptions?: string[]

    List of CLI options passed to the Node.js executable.

    -
    process.execArgv
    +
    process.execArgv
     
    nodePath?: string

    The Node.js executable to use.

    -
    process.execPath
    +
    process.execPath
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -141,7 +141,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.Options.html b/docs/api/interfaces/execa.Options.html index 65b1b56..308816a 100644 --- a/docs/api/interfaces/execa.Options.html +++ b/docs/api/interfaces/execa.Options.html @@ -43,7 +43,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -55,14 +55,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -76,11 +76,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -131,7 +131,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.SyncOptions.html b/docs/api/interfaces/execa.SyncOptions.html index a327e0d..8acd2a9 100644 --- a/docs/api/interfaces/execa.SyncOptions.html +++ b/docs/api/interfaces/execa.SyncOptions.html @@ -43,7 +43,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -55,14 +55,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -76,11 +76,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -131,7 +131,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/types/Dependency.html b/docs/api/types/Dependency.html index 1061b71..0266eff 100644 --- a/docs/api/types/Dependency.html +++ b/docs/api/types/Dependency.html @@ -1 +1 @@ -Dependency | foy

    Type Alias Dependency

    Dependency: TaskDep | string | DepBuilder
    +Dependency | foy

    Type Alias Dependency

    Dependency: TaskDep | string | DepBuilder
    diff --git a/docs/api/types/LogLevels.html b/docs/api/types/LogLevels.html index eea8274..094bbba 100644 --- a/docs/api/types/LogLevels.html +++ b/docs/api/types/LogLevels.html @@ -1 +1 @@ -LogLevels | foy

    Type Alias LogLevels

    LogLevels: keyof typeof LogLevels
    +LogLevels | foy

    Type Alias LogLevels

    LogLevels: keyof typeof LogLevels
    diff --git a/docs/api/types/TaskFn.html b/docs/api/types/TaskFn.html index b0dd1a7..06d145f 100644 --- a/docs/api/types/TaskFn.html +++ b/docs/api/types/TaskFn.html @@ -1 +1 @@ -TaskFn | foy

    Type Alias TaskFn<O, T>

    TaskFn<O, T>: ((ctx: TaskContext<O>) => T | Promise<T>)

    Type Parameters

    • O
    • T = any
    +TaskFn | foy

    Type Alias TaskFn<O, T>

    TaskFn<O, T>: ((ctx: TaskContext<O>) => T | Promise<T>)

    Type Parameters

    • O
    • T = any
    diff --git a/docs/api/types/WatchDirHandler.html b/docs/api/types/WatchDirHandler.html index 1c64c29..efefadb 100644 --- a/docs/api/types/WatchDirHandler.html +++ b/docs/api/types/WatchDirHandler.html @@ -1 +1 @@ -WatchDirHandler | foy

    Type Alias WatchDirHandler

    WatchDirHandler: ((event: string, filename: string) => void)
    +WatchDirHandler | foy

    Type Alias WatchDirHandler

    WatchDirHandler: ((event: string, filename: string) => void)
    diff --git a/docs/api/types/WatchDirOptions.html b/docs/api/types/WatchDirOptions.html index 0a284cc..ab10eb4 100644 --- a/docs/api/types/WatchDirOptions.html +++ b/docs/api/types/WatchDirOptions.html @@ -1,3 +1,3 @@ WatchDirOptions | foy

    Type Alias WatchDirOptions

    WatchDirOptions: {
        iterOnLinux?: boolean;
        persistent?: boolean;
        threshold?: number;
    }

    Type declaration

    • OptionaliterOnLinux?: boolean

      using iter on linux, default false

    • Optionalpersistent?: boolean
    • Optionalthreshold?: number

      ms, default 300

      -
    +
    diff --git a/docs/api/variables/Is.html b/docs/api/variables/Is.html index ed3df2d..cc79fd8 100644 --- a/docs/api/variables/Is.html +++ b/docs/api/variables/Is.html @@ -1 +1 @@ -Is | foy

    Variable IsConst

    Is: {
        bool(v: any): v is boolean;
        defined<T>(v: undefined | null | T): v is T;
        fn(v: any): v is Function;
        num(v: any): v is number;
        obj(v: any): v is object;
        str(v: any): v is string;
    } = ...
    +Is | foy

    Variable IsConst

    Is: {
        bool(v: any): v is boolean;
        defined<T>(v: undefined | null | T): v is T;
        fn(v: any): v is Function;
        num(v: any): v is number;
        obj(v: any): v is object;
        str(v: any): v is string;
    } = ...
    diff --git a/docs/api/variables/LogLevels-1.html b/docs/api/variables/LogLevels-1.html index c27a16b..7ddc261 100644 --- a/docs/api/variables/LogLevels-1.html +++ b/docs/api/variables/LogLevels-1.html @@ -1 +1 @@ -LogLevels | foy

    Variable LogLevelsConst

    LogLevels: {
        debug: number;
        error: number;
        info: number;
        warn: number;
    } = ...
    +LogLevels | foy

    Variable LogLevelsConst

    LogLevels: {
        debug: number;
        error: number;
        info: number;
        warn: number;
    } = ...
    diff --git a/docs/api/variables/fs.html b/docs/api/variables/fs.html index f80026b..bbe6a25 100644 --- a/docs/api/variables/fs.html +++ b/docs/api/variables/fs.html @@ -1,9 +1,9 @@ fs | foy

    Variable fsConst

    fs: __module & __module & {
        copy: ((src: string, dist: string, opts?: {
            overwrite?: boolean;
            skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
        }) => Promise<void>);
        copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>);
        watchDir: {
            (dir: string, cb: WatchDirHandler): void;
            (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
        };
        exists(path: PathLike): Promise<boolean>;
        isDirectory(path: PathLike): Promise<boolean>;
        isFile(path: PathLike): Promise<boolean>;
        isSymbolicLink(path: PathLike): Promise<boolean>;
        iter(dir: string, skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)): Promise<void>;
        lexists(path: PathLike): Promise<boolean>;
        mkdirp(dir: string): Promise<void>;
        mkdirpSync(dir: string): void;
        outputFile(path: string, data: any, options?: WriteOptions): Promise<void>;
        outputFileSync(path: string, data: any, options?: WriteOptions): void;
        outputJson(path: string, data: object, options?: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions): Promise<void>;
        outputJsonSync(path: string, data: any, options?: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions): void;
        readJson<T>(path: string, options?: null | {
            encoding?: null;
            flag?: string;
        }): Promise<T>;
        readJsonSync<T>(path: string, options?: null | {
            encoding?: null;
            flag?: string;
        }): T;
        rmrf(path: string): Promise<void>;
    } = ...

    Type declaration

    • copy: ((src: string, dist: string, opts?: {
          overwrite?: boolean;
          skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
      }) => Promise<void>)
        • (src, dist, opts?): Promise<void>
        • Parameters

          • src: string
          • dist: string
          • Optionalopts: {
                overwrite?: boolean;
                skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
            }
            • Optionaloverwrite?: boolean

              overwrite if exists, default is true

            • Optionalskip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>)

              return true will skip

              -
                • (file, stat): boolean | void | Promise<boolean | void>
                • Parameters

                  • file: string
                  • stat: Stats

                  Returns boolean | void | Promise<boolean | void>

          Returns Promise<void>

    • copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>)
    • watchDir: {
          (dir: string, cb: WatchDirHandler): void;
          (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
      }
    • exists:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isDirectory:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isFile:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isSymbolicLink:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • iter:function
      • Parameters

        • dir: string
        • skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)

          return true will skip

          -
            • (path, stat): boolean | void | Promise<boolean | void>
            • Parameters

              • path: string
              • stat: Stats

              Returns boolean | void | Promise<boolean | void>

        Returns Promise<void>

    • lexists:function
      • exists via lstat, if a symbolic link's target file doesn't exists, fs.exists will return false, but fs.lexists will return true.

        -

        Parameters

        • path: PathLike

        Returns Promise<boolean>

    • mkdirp:function
      • Make directory with parents, like mkdir -p

        -

        Parameters

        • dir: string

        Returns Promise<void>

    • mkdirpSync:function
      • Make directory with parents, like mkdir -p

        -

        Parameters

        • dir: string

        Returns void

    • outputFile:function
      • Parameters

        Returns Promise<void>

    • outputFileSync:function
      • Parameters

        Returns void

    • outputJson:function
      • Parameters

        • path: string
        • data: object
        • Optionaloptions: {
              replacer?: ((key: string, value: any) => any);
              space?: number;
          } & WriteOptions

        Returns Promise<void>

    • outputJsonSync:function
      • Parameters

        • path: string
        • data: any
        • Optionaloptions: {
              replacer?: ((key: string, value: any) => any);
              space?: number;
          } & WriteOptions

        Returns void

    • readJson:function
      • Type Parameters

        • T = any

        Parameters

        • path: string
        • Optionaloptions: null | {
              encoding?: null;
              flag?: string;
          }

        Returns Promise<T>

    • readJsonSync:function
      • Type Parameters

        • T = any

        Parameters

        • path: string
        • Optionaloptions: null | {
              encoding?: null;
              flag?: string;
          }

        Returns T

    • rmrf:function
      • Remove file or directory recursively, like rm -rf

        +
          • (file, stat): boolean | void | Promise<boolean | void>
          • Parameters

            • file: string
            • stat: Stats

            Returns boolean | void | Promise<boolean | void>

    Returns Promise<void>

  • copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>)
  • watchDir: {
        (dir: string, cb: WatchDirHandler): void;
        (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
    }
  • exists:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isDirectory:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isFile:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isSymbolicLink:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • iter:function
    • Parameters

      • dir: string
      • skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)

        return true will skip

        +
          • (path, stat): boolean | void | Promise<boolean | void>
          • Parameters

            • path: string
            • stat: Stats

            Returns boolean | void | Promise<boolean | void>

      Returns Promise<void>

  • lexists:function
    • exists via lstat, if a symbolic link's target file doesn't exists, fs.exists will return false, but fs.lexists will return true.

      +

      Parameters

      • path: PathLike

      Returns Promise<boolean>

  • mkdirp:function
    • Make directory with parents, like mkdir -p

      +

      Parameters

      • dir: string

      Returns Promise<void>

  • mkdirpSync:function
    • Make directory with parents, like mkdir -p

      +

      Parameters

      • dir: string

      Returns void

  • outputFile:function
    • Parameters

      Returns Promise<void>

  • outputFileSync:function
    • Parameters

      Returns void

  • outputJson:function
    • Parameters

      • path: string
      • data: object
      • Optionaloptions: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions

      Returns Promise<void>

  • outputJsonSync:function
    • Parameters

      • path: string
      • data: any
      • Optionaloptions: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions

      Returns void

  • readJson:function
    • Type Parameters

      • T = any

      Parameters

      • path: string
      • Optionaloptions: null | {
            encoding?: null;
            flag?: string;
        }

      Returns Promise<T>

  • readJsonSync:function
    • Type Parameters

      • T = any

      Parameters

      • path: string
      • Optionaloptions: null | {
            encoding?: null;
            flag?: string;
        }

      Returns T

  • rmrf:function
    • Remove file or directory recursively, like rm -rf

      Parameters

      • path: string

        The path to remove

        -

      Returns Promise<void>

  • +

    Returns Promise<void>

    diff --git a/docs/api/variables/logger-1.html b/docs/api/variables/logger-1.html index a6a4bbd..4bc929e 100644 --- a/docs/api/variables/logger-1.html +++ b/docs/api/variables/logger-1.html @@ -1 +1 @@ -logger | foy

    Variable loggerConst

    logger: Logger = ...
    +logger | foy

    Variable loggerConst

    logger: Logger = ...
    diff --git a/src/default-cli.ts b/src/default-cli.ts index 8bf017c..51e855d 100644 --- a/src/default-cli.ts +++ b/src/default-cli.ts @@ -8,7 +8,7 @@ import { getGlobalTaskManager } from './task-manager' import requireStr from 'require-from-string' export function initDefaultCli() { - const defaultCli = cac("foy") + const defaultCli = cac() // generate default argv because cac cannot handle `foy command` + `foy options` function generateArgv() { let defaultArgv: string[] = []