From 982c15fcfb1e747742f0e45a5fbf14b1028ccdac Mon Sep 17 00:00:00 2001 From: Tarek Touati <19335073+Tarektouati@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:52:35 +0200 Subject: [PATCH 1/4] modify cli options and API in README --- README.md | 575 ++++++++++++++++++++++--------------- package.json | 2 + pnpm-lock.yaml | 133 +++++++++ src/command.ts | 64 ++--- src/completion-listener.ts | 8 +- src/concurrently.ts | 12 +- src/defaults.ts | 44 +-- src/get-spawn-opts.ts | 8 +- src/index.ts | 14 +- src/logger.ts | 8 +- 10 files changed, 520 insertions(+), 348 deletions(-) diff --git a/README.md b/README.md index 1f92edd9..0b1ed82f 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,13 @@ Like `npm run watch-js & npm run watch-less` but better. - [Why](#why) - [Installation](#installation) - [Usage](#usage) + - [CLI options](#cli-options) + - [General options](#general) + - [Styling](#styling) + - [Input handling](#input-handling) + - [Killing other processes](#killing-other-processes) + - [Restarting](#restarting) - [API](#api) - - [`concurrently(commands[, options])`](#concurrentlycommands-options) - - [`Command`](#command) - - [`CloseEvent`](#closeevent) - [FAQ](#faq) ## Why @@ -138,282 +141,386 @@ concurrently "npm:lint:*(!fix)" Good frontend one-liner example [here](https://github.com/kimmobrunfeldt/dont-copy-paste-this-frontend-template/blob/5cd2bde719654941bdfc0a42c6f1b8e69ae79980/package.json#L9). -Help: +### CLI options : -``` +```bash concurrently [options] +``` -General - -m, --max-processes How many processes should run at once. - Exact number or a percent of CPUs available (for example "50%"). - New processes only spawn after all restart tries - of a process. [string] - -n, --names List of custom names to be used in prefix - template. - Example names: "main,browser,server" [string] - --name-separator The character to split on. Example usage: - -n "styles|scripts|server" --name-separator "|" - [default: ","] - -s, --success Which command(s) must exit with code 0 in order - for concurrently exit with code 0 too. Options - are: - - "first" for the first command to exit; - - "last" for the last command to exit; - - "all" for all commands; - - "command-{name}"/"command-{index}" for the - commands with that name or index; - - "!command-{name}"/"!command-{index}" for all - commands but the ones with that name or index. - [default: "all"] - -r, --raw Output only raw output of processes, disables - prettifying and concurrently coloring. [boolean] - --no-color Disables colors from logging [boolean] - --hide Comma-separated list of processes to hide the - output. - The processes can be identified by their name or - index. [string] [default: ""] - -g, --group Order the output as if the commands were run - sequentially. [boolean] - --timings Show timing information for all processes. - [boolean] [default: false] - -P, --passthrough-arguments Passthrough additional arguments to commands - (accessible via placeholders) instead of treating - them as commands. [boolean] [default: false] - -Prefix styling - -p, --prefix Prefix used in logging for each process. - Possible values: index, pid, time, command, name, - none, or a template. Example template: "{time}-{pid}" - [string] [default: index or name (when --names is set)] - -c, --prefix-colors Comma-separated list of chalk colors to use on - prefixes. If there are more commands than colors, the - last color will be repeated. - - Available modifiers: reset, bold, dim, italic, - underline, inverse, hidden, strikethrough - - Available colors: black, red, green, yellow, blue, - magenta, cyan, white, gray, - any hex values for colors (e.g. #23de43) or auto for - an automatically picked color - - Available background colors: bgBlack, bgRed, - bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite - See https://www.npmjs.com/package/chalk for more - information. [string] [default: "reset"] - -l, --prefix-length Limit how many characters of the command is displayed - in prefix. The option can be used to shorten the - prefix when it is set to "command" - [number] [default: 10] - -t, --timestamp-format Specify the timestamp in moment/date-fns format. - [string] [default: "yyyy-MM-dd HH:mm:ss.SSS"] +### General -Input handling - -i, --handle-input Whether input should be forwarded to the child - processes. See examples for more information. - [boolean] - --default-input-target Identifier for child process to which input on - stdin should be sent if not specified at start of - input. - Can be either the index or the name of the - process. [default: 0] +| options | description | +| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h, --help` | Show help | +| `-v, -V, --version` | Show version number | +| `-m, --max-processes` | How many processes should run at once. Exact number or a percent of CPUs available (for example "50%"). New processes only spawn after all restart tries of a process. | +| `-n, --names` | List of custom names to be used in prefix template. | +| `--name-separator` | The character to split on. | +| ` -s, --success` |

Which command(s) must exit with code 0 in order for concurrently exit with code 0 too.
Options are:
 - "first" for the first command to exit;
 - "last" for the last command to exit;
 - "all" for all commands;
 - "command-{name}"/"command-{index}" for the commands with that name or index;
 - "!command-{name}"/"!command-{index}" for all commands but the ones with that name or index.

| +| `-r, --raw` | Output only raw output of processes, disables prettifying and concurrently coloring. | +| `--no-color` | Disables colors from logging | +| `--hide` | Comma-separated list of processes to hide the output. The processes can be identified by their name or index. | +| `-g, --group` | Order the output as if the commands were run sequentially. | +| `--timings` | Show timing information for all processes. | +| `-P, --passthrough-arguments` | Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. | -Killing other processes - -k, --kill-others Kill other processes if one exits or dies.[boolean] - --kill-others-on-fail Kill other processes if one exits with non zero - status code. [boolean] - --kill-signal Signal to send to other processes if one exits or dies. - (SIGTERM/SIGKILL, defaults to SIGTERM) [string] +### Styling -Restarting - --restart-tries How many times a process that died should restart. - Negative numbers will make the process restart forever. - [number] [default: 0] - --restart-after Delay time to respawn the process, in milliseconds. - [number] [default: 0] +| options | description | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-p, --prefix` | Prefix used in logging for each process
Possible values: index, pid, time, command, name, none, or a template.
Example template: `"{time}-{pid}"` | +| `-c, --prefix-colors` | Comma-separated list of chalk colors to use on prefixes. If there are more commands than colors, the last color will be repeated.
 - Available modifiers: reset, bold, dim, italic,underline, inverse, hidden, strikethrough
 - Available colors: black, red, green, yellow, blue,magenta, cyan, white, gray,any hex values for colors (e.g. #23de43) or auto for an automatically picked color
 - Available background colors: `bgBlack`, `bgRed`,`bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
See https://www.npmjs.com/package/chalk for more information. | +| `-l, --prefix-length` | Limit how many characters of the command is displayed in prefix. The option can be used to shorten the prefix when it is set to "command" | +| `-t, --timestamp-format` | Specify the timestamp in moment/date-fns format. | -Options: - -h, --help Show help [boolean] - -v, -V, --version Show version number [boolean] +### Input handling +| options | description | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-i, --handle-input` | Whether input should be forwarded to the child processes. See examples for more information. | +| `--default-input-target` | Identifier for child process to which input on stdin should be sent if not specified at start of input.
Can be either the index or the name of the process. | -Examples: +### Killing other processes - - Output nothing more than stdout+stderr of child processes +| options | description | +| ----------------------- | ---------------------------------------------------------------------------------------------- | +| ` -k, --kill-others` | Kill other processes if one exits or dies. | +| `--kill-others-on-fail` | Kill other processes if one exits with non zero status code. | +| `--kill-signal` | Signal to send to other processes if one exits or dies. (SIGTERM/SIGKILL, defaults to SIGTERM) | - $ concurrently --raw "npm run watch-less" "npm run watch-js" +### Restarting - - Normal output but without colors e.g. when logging to file +| options | description | +| ----------------- | -------------------------------------------------------------------------------------------------------------- | +| `--restart-tries` | How many times a process that died should restart.
Negative numbers will make the process restart forever. | +| `--restart-after` | Delay time to respawn the process, in milliseconds. | - $ concurrently --no-color "grunt watch" "http-server" > log +### Examples: - - Custom prefix +- Output nothing more than stdout+stderr of child processes - $ concurrently --prefix "{time}-{pid}" "npm run watch" "http-server" +```bash + $ concurrently --raw "npm run watch-less" "npm run watch-js" +``` - - Custom names and colored prefixes +- Normal output but without colors e.g. when logging to file - $ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold" - "http-server" "npm run watch" +```bash + $ concurrently --no-color "grunt watch" "http-server" > log +``` - - Auto varying colored prefixes +- Custom prefix - $ concurrently -c "auto" "npm run watch" "http-server" +```bash + $ concurrently --prefix "{time}-{pid}" "npm run watch" "http-server" +``` - - Mixing auto and manual colored prefixes +- Custom names and colored prefixes - $ concurrently -c "red,auto" "npm run watch" "http-server" "echo hello" +```bash + $ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold" + "http-server" "npm run watch" +``` - - Configuring via environment variables with CONCURRENTLY_ prefix +- Auto varying colored prefixes - $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo - hello" "echo world" +```bash + $ concurrently -c "auto" "npm run watch" "http-server" +``` - - Send input to default +- Mixing auto and manual colored prefixes - $ concurrently --handle-input "nodemon" "npm run watch-js" - rs # Sends rs command to nodemon process +```bash + $ concurrently -c "red,auto" "npm run watch" "http-server" "echo hello" +``` - - Send input to specific child identified by index +- Configuring via environment variables with CONCURRENTLY\_ prefix - $ concurrently --handle-input "npm run watch-js" nodemon - 1:rs +```bash + $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo + hello" "echo world" +``` - - Send input to specific child identified by name +- Send input to default - $ concurrently --handle-input -n js,srv "npm run watch-js" nodemon - srv:rs +```bash + $ concurrently --handle-input "nodemon" "npm run watch-js" + rs # Sends rs command to nodemon process +``` - - Shortened NPM run commands +- Send input to specific child identified by index - $ concurrently npm:watch-node npm:watch-js npm:watch-css +```bash + $ concurrently --handle-input "npm run watch-js" nodemon + 1:rs +``` - - Shortened NPM run command with wildcard (make sure to wrap it in quotes!) +- Send input to specific child identified by name - $ concurrently "npm:watch-*" +```bash + $ concurrently --handle-input -n js,srv "npm run watch-js" nodemon + srv:rs +``` - - Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" - is ran +- Shortened NPM run commands - $ concurrently "npm:*(!fix)" +```bash + $ concurrently npm:watch-node npm:watch-js npm:watch-css +``` - - Passthrough some additional arguments via '{}' placeholder +- Shortened NPM run command with wildcard (make sure to wrap it in quotes!) - $ concurrently -P "echo {1}" -- foo +```bash + $ concurrently "npm:watch-\*" +``` - - Passthrough all additional arguments via '{@}' placeholder +- Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" + is ran - $ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit +```bash + $ concurrently "npm:*(!fix)" +``` - - Passthrough all additional arguments combined via '{*}' placeholder +- Passthrough some additional arguments via '{}' placeholder + +```bash + $ concurrently -P "echo {1}" -- foo +``` - $ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit +- Passthrough all additional arguments via '{@}' placeholder -For more details, visit https://github.com/open-cli-tools/concurrently +```bash + $ concurrently -P "npm:dev-\* -- {@}" -- --watch --noEmit +``` + +- Passthrough all additional arguments combined via '{\*}' placeholder + +```bash + $ concurrently -P "npm:dev-_ -- {_}" -- --watch --noEmit ``` +For more details, visit https://github.com/open-cli-tools/concurrently + ## API **concurrently** can be used programmatically by using the API documented below: -### `concurrently(commands[, options])` - -- `commands`: an array of either strings (containing the commands to run) or objects - with the shape `{ command, name, prefixColor, env, cwd }`. - -- `options` (optional): an object containing any of the below: - - `cwd`: the working directory to be used by all commands. Can be overriden per command. - Default: `process.cwd()`. - - `defaultInputTarget`: the default input target when reading from `inputStream`. - Default: `0`. - - `handleInput`: when `true`, reads input from `process.stdin`. - - `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams) - to read the input from. Should only be used in the rare instance you would like to stream anything other than `process.stdin`. Overrides `handleInput`. - - `pauseInputStreamOnFinish`: by default, pauses the input stream (`process.stdin` when `handleInput` is enabled, or `inputStream` if provided) when all of the processes have finished. If you need to read from the input stream after `concurrently` has finished, set this to `false`. ([#252](https://github.com/kimmobrunfeldt/concurrently/issues/252)). - - `killOthers`: an array of exitting conditions that will cause a process to kill others. - Can contain any of `success` or `failure`. - - `maxProcesses`: how many processes should run at once. - - `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams) - to write logs to. Default: `process.stdout`. - - `prefix`: the prefix type to use when logging processes output. - Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`). - Default: the name of the process, or its index if no name is set. - - `prefixColors`: a list of colors or a string as supported by [chalk](https://www.npmjs.com/package/chalk) and additional style `auto` for an automatically picked color. - If concurrently would run more commands than there are colors, the last color is repeated, unless if the last color value is `auto` which means following colors are automatically picked to vary. - Prefix colors specified per-command take precedence over this list. - - `prefixLength`: how many characters to show when prefixing with `command`. Default: `10` - - `raw`: whether raw mode should be used, meaning strictly process output will - be logged, without any prefixes, coloring or extra stuff. Can be overriden per command. - - `successCondition`: the condition to consider the run was successful. - If `first`, only the first process to exit will make up the success of the run; if `last`, the last process that exits will determine whether the run succeeds. - Anything else means all processes should exit successfully. - - `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`. - - `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`. - - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format) - to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ` - - `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen. - -> **Returns:** an object in the shape `{ result, commands }`. -> -> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option), -> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated. -> - `commands`: an array of all spawned [`Command`s](#Command). - -Example: - -```js -const concurrently = require('concurrently'); -const { result } = concurrently( - [ - 'npm:watch-*', - { command: 'nodemon', name: 'server' }, - { command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } }, - { - command: 'watch', - name: 'watch', - cwd: path.resolve(__dirname, 'scripts/watchers'), - }, - ], - { - prefix: 'name', - killOthers: ['failure', 'success'], - restartTries: 3, - cwd: path.resolve(__dirname, 'scripts'), - }, -); -result.then(success, failure); -``` + + +### `CommandIdentifier` (type) + +Identifier for a command; if string, it's the command's name, if number, it's the index. + +### `CommandInfo` (interface) + +**Members:** + +- name (`string`) - Command's name. +- command (`string`) - Which command line the command has. +- env (`Record`) - Which environment variables should the spawned process have. +- cwd (`string`) - The current working directory of the process when spawned. +- prefixColor (`string`) - Color to use on prefix of the command. +- raw (`boolean`) - Output command in raw format. + +### `CloseEvent` (interface) + +**Members:** + +- command (`CommandInfo`) +- index (`number`) - The command's index among all commands ran. +- killed (`boolean`) - Whether the command exited because it was killed. +- exitCode (`string | number`) - The exit code or signal for the command. +- timings (`{ startDate: Date; endDate: Date; durationSeconds: number; }`) + +### `TimerEvent` (interface) + +**Members:** + +- startDate (`Date`) +- endDate (`Date`) + +### `ChildProcess` (type) + +Subtype of NodeJS's child_process including only what's actually needed for a command to work. + +### `KillProcess` (type) + +Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. + +### `SpawnCommand` (type) + +Interface for a function that spawns a command and returns its child process instance. + +### `Command` (class) + +### `CommandParser` (interface) + +A command parser encapsulates a specific logic for mapping `CommandInfo` objects +into another `CommandInfo`. + +A prime example is turning an abstract `npm:foo` into `npm run foo`, but it could also turn +the prefix color of a command brighter, or maybe even prefixing each command with `time(1)`. + +**Members:** + +- /\*\* + +* Parses `commandInfo` and returns one or more `CommandInfo`s. +* +* Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to +* run given the original input. +* An example of this is when the command contains a wildcard and it must be expanded into all +* viable options so that the consumer can decide which ones to run. + \*/ + parse (`(commandInfo: CommandInfo) => CommandInfo | CommandInfo[]`) - Parses `commandInfo` and returns one or more `CommandInfo`s. + +Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to +run given the original input. +An example of this is when the command contains a wildcard and it must be expanded into all +viable options so that the consumer can decide which ones to run. + +### `ExpandArguments` (class) + +Replace placeholders with additional arguments. + +### `ExpandNpmShortcut` (class) + +Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run ` and so on. -### `Command` - -An object that contains all information about a spawned command, and ways to interact with it.
-It has the following properties: - -- `index`: the index of the command among all commands spawned. -- `command`: the command line of the command. -- `name`: the name of the command; defaults to an empty string. -- `cwd`: the current working directory of the command. -- `env`: an object with all the environment variables that the command will be spawned with. -- `killed`: whether the command has been killed. -- `exited`: whether the command exited yet. -- `pid`: the command's process ID. -- `stdin`: a Writable stream to the command's `stdin`. -- `stdout`: an RxJS observable to the command's `stdout`. -- `stderr`: an RxJS observable to the command's `stderr`. -- `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn). -- `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping). -- `close`: an RxJS observable to the command's close events. - See [`CloseEvent`](#CloseEvent) for more information. -- `start()`: starts the command, setting up all -- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc). - -### `CloseEvent` - -An object with information about a command's closing event.
-It contains the following properties: - -- `command`: a stripped down version of [`Command`](#command), including only `name`, `command`, `env` and `cwd` properties. -- `index`: the index of the command among all commands spawned. -- `killed`: whether the command exited because it was killed. -- `exitCode`: the exit code of the command's process, or the signal which it was killed with. -- `timings`: an object in the shape `{ startDate, endDate, durationSeconds }`. +### `ExpandNpmWildcard` (class) + +Finds wildcards in npm/yarn/pnpm/bun run commands and replaces them with all matching scripts in the +`package.json` file of the current directory. + +### `StripQuotes` (class) + +Strips quotes around commands so that they can run on the current shell. + +### `SuccessCondition` (type) + +Defines which command(s) in a list must exit successfully (with an exit code of `0`): + +- `first`: only the first specified command; +- `last`: only the last specified command; +- `all`: all commands. +- `command-{name|index}`: only the commands with the specified names or index. +- `!command-{name|index}`: all commands but the ones with the specified names or index. + +### `CompletionListener` (class) + +Provides logic to determine whether lists of commands ran successfully. + +### `FlowController` (interface) + +Interface for a class that controls and/or watches the behavior of commands. + +This may include logging their output, creating interactions between them, or changing when they +actually finish. + +**Members:** + +- handle (`(commands: Command[]) => { commands: Command[]; onFinish?: () => void; }`) + +### `getSpawnOpts` (function) + +### `defaultInputTarget` (variable) + +### `handleInput` (variable) + +Whether process.stdin should be forwarded to child processes. + +### `maxProcesses` (variable) + +How many processes to run at once. + +### `hide` (variable) + +Indices and names of commands whose output are not to be logged. + +### `nameSeparator` (variable) + +The character to split on. + +### `prefix` (variable) + +Which prefix style to use when logging processes output. + +### `prefixColors` (variable) + +Default prefix color. + +### `prefixLength` (variable) + +How many bytes we'll show on the command prefix. + +### `raw` (variable) + +### `restartTries` (variable) + +Number of attempts of restarting a process, if it exits with non-0 code. + +### `restartDelay` (variable) + +How many milliseconds concurrently should wait before restarting a process. + +### `success` (variable) + +Condition of success for concurrently itself. + +### `timestampFormat` (variable) + +Date format used when logging date/time. + +### `cwd` (variable: string | undefined) + +Current working dir passed as option to spawn command. +Defaults to process.cwd() + +### `timings` (variable) + +Whether to show timing information for processes in console output. + +### `passthroughArguments` (variable) + +Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. + +### `killSignal` (variable: string | undefined) + +Signal to send to other processes if one exits or dies. + +Defaults to OS specific signal. (SIGTERM on Linux/MacOS) + +### `Logger` (class) + +### `OutputWriter` (class) + +Class responsible for actually writing output onto a writable stream. + +### `PrefixColorSelector` (class) + +### `ConcurrentlyCommandInput` (type) + +A command that is to be passed into `concurrently()`. +If value is a string, then that's the command's command line. +Fine grained options can be defined by using the object format. + +### `ConcurrentlyResult` (type) + +### `ConcurrentlyOptions` (type) + +### `concurrently` (function) + +Core concurrently functionality -- spawns the given commands concurrently and +returns the commands themselves + the result according to the specified success condition. + +**Parameters:** + +- baseCommands (`ConcurrentlyCommandInput[]`) +- baseOptions (`Partial`) + +**returns:** ConcurrentlyResult + + ## FAQ @@ -432,3 +539,11 @@ It contains the following properties: - Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn), [pnpm](https://pnpm.js.org/), or [Bun](https://bun.sh/)? Yes! In all examples above, you may replace "`npm`" with "`yarn`", "`pnpm`", or "`bun`". + +``` + +``` + +``` + +``` diff --git a/package.json b/package.json index 27b35d61..a7293dd3 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "scripts": { "build": "tsc --build", "postbuild": "chmod +x dist/bin/concurrently.js", + "generate:doc:api": "ts-readme --header-depth 3 src/concurrently.ts ", "clean": "tsc --build --clean", "format": "prettier --check '**/*.{json,y?(a)ml,md}'", "format:fix": "pnpm run format --write", @@ -88,6 +89,7 @@ "prettier": "^3.0.3", "safe-publish-latest": "^2.0.0", "string-argv": "^0.3.2", + "ts-readme": "^1.1.3", "typescript": "~5.2.2" }, "files": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af151ac5..bdccfa74 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,6 +115,9 @@ devDependencies: string-argv: specifier: ^0.3.2 version: 0.3.2 + ts-readme: + specifier: ^1.1.3 + version: 1.1.3(typescript@5.2.2) typescript: specifier: ~5.2.2 version: 5.2.2 @@ -1238,6 +1241,14 @@ packages: '@babel/types': 7.20.7 dev: true + /@types/command-line-args@5.2.1: + resolution: {integrity: sha512-U2OcmS2tj36Yceu+mRuPyUV0ILfau/h5onStcSCzqTENsq0sBiAp2TmaXu1k8fY4McLcPKSYl9FRzn2hx5bI+w==} + dev: true + + /@types/command-line-usage@5.0.2: + resolution: {integrity: sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg==} + dev: true + /@types/graceful-fs@4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: @@ -1595,6 +1606,16 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true + /array-back@3.1.0: + resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} + engines: {node: '>=6'} + dev: true + + /array-back@4.0.2: + resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} + engines: {node: '>=8'} + dev: true + /array-buffer-byte-length@1.0.0: resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} dependencies: @@ -1923,6 +1944,39 @@ packages: delayed-stream: 1.0.0 dev: true + /command-line-application@0.9.6: + resolution: {integrity: sha512-7wc7YX7s/hqZWKp4r37IBlW/Bhh92HWeQW2VV++Mt9x35AKFntz9f7A94Zz+AsImHZmRGHd8iNW5m0jUd4GQpg==} + dependencies: + '@types/command-line-args': 5.2.1 + '@types/command-line-usage': 5.0.2 + chalk: 2.4.2 + command-line-args: 5.2.1 + command-line-usage: 6.1.3 + meant: 1.0.3 + remove-markdown: 0.3.0 + tslib: 1.10.0 + dev: true + + /command-line-args@5.2.1: + resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + find-replace: 3.0.0 + lodash.camelcase: 4.3.0 + typical: 4.0.0 + dev: true + + /command-line-usage@6.1.3: + resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + chalk: 2.4.2 + table-layout: 1.0.2 + typical: 5.2.0 + dev: true + /commander@11.0.0: resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} engines: {node: '>=16'} @@ -2046,6 +2100,11 @@ packages: optional: true dev: true + /deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + dev: true + /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true @@ -2664,6 +2723,13 @@ packages: to-regex-range: 5.0.1 dev: true + /find-replace@3.0.0: + resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + dev: true + /find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -3810,6 +3876,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: true + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -3860,6 +3930,10 @@ packages: tmpl: 1.0.5 dev: true + /meant@1.0.3: + resolution: {integrity: sha512-88ZRGcNxAq4EH38cQ4D85PM57pikCwS8Z99EWHODxN7KBY+UuPiqzRTtZzS8KTXO/ywSWbdjjJST2Hly/EQxLw==} + dev: true + /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true @@ -4154,6 +4228,12 @@ packages: fast-diff: 1.2.0 dev: true + /prettier@1.19.1: + resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==} + engines: {node: '>=4'} + hasBin: true + dev: true + /prettier@3.0.3: resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} engines: {node: '>=14'} @@ -4203,6 +4283,11 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: true + /reduce-flatten@2.0.0: + resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} + engines: {node: '>=6'} + dev: true + /regenerator-runtime@0.13.11: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} dev: false @@ -4225,6 +4310,10 @@ packages: functions-have-names: 1.2.3 dev: true + /remove-markdown@0.3.0: + resolution: {integrity: sha512-5392eIuy1mhjM74739VunOlsOYKjsH82rQcTBlJ1bkICVC3dQ3ksQzTHh4jGHQFnM+1xzLzcFOMH+BofqXhroQ==} + dev: true + /require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -4548,6 +4637,16 @@ packages: tslib: 2.6.2 dev: true + /table-layout@1.0.2: + resolution: {integrity: sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + deep-extend: 0.6.0 + typical: 5.2.0 + wordwrapjs: 4.0.1 + dev: true + /test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -4596,6 +4695,18 @@ packages: typescript: 5.2.2 dev: true + /ts-readme@1.1.3(typescript@5.2.2): + resolution: {integrity: sha512-GvI+Vu3m/LGBlgrWwzSmvslnz8msJLNrZ7hQ3Ko2B6PMxeXidqsn6fi20IWgepFjOzhKGw/WlG8NmM7jl3DWeg==} + hasBin: true + peerDependencies: + typescript: '>= 3.x' + dependencies: + command-line-application: 0.9.6 + fast-glob: 3.3.1 + prettier: 1.19.1 + typescript: 5.2.2 + dev: true + /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} dependencies: @@ -4605,6 +4716,10 @@ packages: strip-bom: 3.0.0 dev: true + /tslib@1.10.0: + resolution: {integrity: sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==} + dev: true + /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true @@ -4697,6 +4812,16 @@ packages: hasBin: true dev: true + /typical@4.0.0: + resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} + engines: {node: '>=8'} + dev: true + + /typical@5.2.0: + resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} + engines: {node: '>=8'} + dev: true + /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} dependencies: @@ -4772,6 +4897,14 @@ packages: isexe: 2.0.0 dev: true + /wordwrapjs@4.0.1: + resolution: {integrity: sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==} + engines: {node: '>=8.0.0'} + dependencies: + reduce-flatten: 2.0.0 + typical: 5.2.0 + dev: true + /wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} diff --git a/src/command.ts b/src/command.ts index c5593e0c..f50bacf7 100644 --- a/src/command.ts +++ b/src/command.ts @@ -2,59 +2,39 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process'; import * as Rx from 'rxjs'; import { EventEmitter, Writable } from 'stream'; -/** - * Identifier for a command; if string, it's the command's name, if number, it's the index. - */ +/** Identifier for a command; if string, it's the command's name, if number, it's the index.*/ export type CommandIdentifier = string | number; export interface CommandInfo { - /** - * Command's name. - */ + /** Command's name. */ name: string; - /** - * Which command line the command has. - */ + /** Which command line the command has. */ command: string; - /** - * Which environment variables should the spawned process have. - */ + /** Which environment variables should the spawned process have.*/ env?: Record; - /** - * The current working directory of the process when spawned. - */ + /** The current working directory of the process when spawned.*/ cwd?: string; - /** - * Color to use on prefix of the command. - */ + /** Color to use on prefix of the command.*/ prefixColor?: string; - /** - * Output command in raw format. - */ + /** Output command in raw format.*/ raw?: boolean; } export interface CloseEvent { command: CommandInfo; - /** - * The command's index among all commands ran. - */ + /** The command's index among all commands ran.*/ index: number; - /** - * Whether the command exited because it was killed. - */ + /** Whether the command exited because it was killed.*/ killed: boolean; - /** - * The exit code or signal for the command. - */ + /** The exit code or signal for the command.*/ exitCode: string | number; timings: { startDate: Date; @@ -68,20 +48,14 @@ export interface TimerEvent { endDate?: Date; } -/** - * Subtype of NodeJS's child_process including only what's actually needed for a command to work. - */ +/** Subtype of NodeJS's child_process including only what's actually needed for a command to work. */ export type ChildProcess = EventEmitter & Pick; -/** - * Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. - */ +/** Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. */ export type KillProcess = (pid: number, signal?: string) => void; -/** - * Interface for a function that spawns a command and returns its child process instance. - */ +/** Interface for a function that spawns a command and returns its child process instance. */ export type SpawnCommand = (command: string, options: SpawnOptions) => ChildProcess; export class Command implements CommandInfo { @@ -139,9 +113,7 @@ export class Command implements CommandInfo { this.spawnOpts = spawnOpts; } - /** - * Starts this command, piping output, error and close events onto the corresponding observables. - */ + /** Starts this command, piping output, error and close events onto the corresponding observables. */ start() { const child = this.spawn(this.command, this.spawnOpts); this.process = child; @@ -190,9 +162,7 @@ export class Command implements CommandInfo { this.stdin = child.stdin || undefined; } - /** - * Kills this command, optionally specifying a signal to send to it. - */ + /** Kills this command, optionally specifying a signal to send to it. */ kill(code?: string) { if (Command.canKill(this)) { this.killed = true; @@ -210,9 +180,7 @@ export class Command implements CommandInfo { } } -/** - * Pipes all events emitted by `stream` into `subject`. - */ +/** Pipes all events emitted by `stream` into `subject`.s */ function pipeTo(stream: Rx.Observable, subject: Rx.Subject) { stream.subscribe((event) => subject.next(event)); } diff --git a/src/completion-listener.ts b/src/completion-listener.ts index 6889a676..07855031 100644 --- a/src/completion-listener.ts +++ b/src/completion-listener.ts @@ -19,9 +19,7 @@ export type SuccessCondition = | `command-${string | number}` | `!command-${string | number}`; -/** - * Provides logic to determine whether lists of commands ran successfully. - */ +/** Provides logic to determine whether lists of commands ran successfully. */ export class CompletionListener { private readonly successCondition: SuccessCondition; private readonly scheduler?: Rx.SchedulerLike; @@ -38,9 +36,7 @@ export class CompletionListener { */ successCondition?: SuccessCondition; - /** - * For testing only. - */ + /** For testing only.*/ scheduler?: Rx.SchedulerLike; }) { this.successCondition = successCondition; diff --git a/src/concurrently.ts b/src/concurrently.ts index 2c5b9ec8..1a0e7ecc 100644 --- a/src/concurrently.ts +++ b/src/concurrently.ts @@ -34,9 +34,7 @@ const defaults: ConcurrentlyOptions = { export type ConcurrentlyCommandInput = string | ({ command: string } & Partial); export type ConcurrentlyResult = { - /** - * All commands created and ran by concurrently. - */ + /** All commands created and ran by concurrently.*/ commands: Command[]; /** @@ -51,14 +49,10 @@ export type ConcurrentlyResult = { export type ConcurrentlyOptions = { logger?: Logger; - /** - * Which stream should the commands output be written to. - */ + /** Which stream should the commands output be written to. */ outputStream?: Writable; - /** - * Whether the output should be ordered as if the commands were run sequentially. - */ + /** Whether the output should be ordered as if the commands were run sequentially.*/ group?: boolean; /** diff --git a/src/defaults.ts b/src/defaults.ts index ddefbf4f..2a32edb6 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -6,29 +6,19 @@ import { SuccessCondition } from './completion-listener'; export const defaultInputTarget = 0; -/** - * Whether process.stdin should be forwarded to child processes. - */ +/** Whether process.stdin should be forwarded to child processes. */ export const handleInput = false; -/** - * How many processes to run at once. - */ +/** How many processes to run at once. */ export const maxProcesses = 0; -/** - * Indices and names of commands whose output are not to be logged. - */ +/** Indices and names of commands whose output are not to be logged. */ export const hide = ''; -/** - * The character to split on. - */ +/** The character to split on.*/ export const nameSeparator = ','; -/** - * Which prefix style to use when logging processes output. - */ +/** Which prefix style to use when logging processes output.*/ export const prefix = ''; /** @@ -37,26 +27,18 @@ export const prefix = ''; */ export const prefixColors = 'reset'; -/** - * How many bytes we'll show on the command prefix. - */ +/** How many bytes we'll show on the command prefix.*/ export const prefixLength = 10; export const raw = false; -/** - * Number of attempts of restarting a process, if it exits with non-0 code. - */ +/** Number of attempts of restarting a process, if it exits with non-0 code. */ export const restartTries = 0; -/** - * How many milliseconds concurrently should wait before restarting a process. - */ +/** How many milliseconds concurrently should wait before restarting a process. */ export const restartDelay = 0; -/** - * Condition of success for concurrently itself. - */ +/** Condition of success for concurrently itself. */ export const success = 'all' as SuccessCondition; /** @@ -71,14 +53,10 @@ export const timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS'; */ export const cwd: string | undefined = undefined; -/** - * Whether to show timing information for processes in console output. - */ +/** Whether to show timing information for processes in console output. */ export const timings = false; -/** - * Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. - */ +/** Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. */ export const passthroughArguments = false; /** diff --git a/src/get-spawn-opts.ts b/src/get-spawn-opts.ts index a65d6faa..d50fa58f 100644 --- a/src/get-spawn-opts.ts +++ b/src/get-spawn-opts.ts @@ -16,9 +16,7 @@ export const getSpawnOpts = ({ */ colorSupport?: Pick | false; - /** - * The NodeJS process. - */ + /** The NodeJS process. */ process?: Pick; /** @@ -33,9 +31,7 @@ export const getSpawnOpts = ({ */ raw?: boolean; - /** - * Map of custom environment variables to include in the spawn options. - */ + /** Map of custom environment variables to include in the spawn options. */ env?: Record; }): SpawnOptions => ({ cwd: cwd || process.cwd(), diff --git a/src/index.ts b/src/index.ts index 3dce77b6..27307ac4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,11 +18,9 @@ import { LogTimings } from './flow-control/log-timings'; import { RestartProcess } from './flow-control/restart-process'; import { Logger } from './logger'; +/** Logger options */ export type ConcurrentlyOptions = BaseConcurrentlyOptions & { - // Logger options - /** - * Which command(s) should have their output hidden. - */ + /** Which command(s) should have their output hidden. */ hide?: CommandIdentifier | CommandIdentifier[]; /** @@ -31,14 +29,10 @@ export type ConcurrentlyOptions = BaseConcurrentlyOptions & { */ prefix?: string; - /** - * How many characters should a prefix have at most, used when the prefix format is `command`. - */ + /** How many characters should a prefix have at most, used when the prefix format is `command`. */ prefixLength?: number; - /** - * Whether output should be formatted to include prefixes and whether "event" logs will be logged. - */ + /** Whether output should be formatted to include prefixes and whether "event" logs will be logged. */ raw?: boolean; /** diff --git a/src/logger.ts b/src/logger.ts index bc3f7d6d..100c30e1 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -32,9 +32,7 @@ export class Logger { raw = false, timestampFormat, }: { - /** - * Which command(s) should have their output hidden. - */ + /** Which command(s) should have their output hidden. */ hide?: CommandIdentifier | CommandIdentifier[]; /** @@ -49,9 +47,7 @@ export class Logger { */ prefixFormat?: string; - /** - * How many characters should a prefix have at most, used when the prefix format is `command`. - */ + /** How many characters should a prefix have at most, used when the prefix format is `command`. */ prefixLength?: number; /** From 7843e66f53bd914f9c3b87f731c4cb2a24e22c75 Mon Sep 17 00:00:00 2001 From: Tarek Touati <19335073+Tarektouati@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:00:24 +0200 Subject: [PATCH 2/4] replace ts-readme by typedoc --- README.md | 233 +---------------------------- {docs => assets}/demo.gif | Bin {docs => assets}/frontend-demo.gif | Bin {docs => assets}/kill-demo.gif | Bin {docs => assets}/raw-demo.gif | Bin package.json | 5 +- pnpm-lock.yaml | 225 ++++++++++++---------------- typedoc.json | 8 + 8 files changed, 110 insertions(+), 361 deletions(-) rename {docs => assets}/demo.gif (100%) rename {docs => assets}/frontend-demo.gif (100%) rename {docs => assets}/kill-demo.gif (100%) rename {docs => assets}/raw-demo.gif (100%) create mode 100644 typedoc.json diff --git a/README.md b/README.md index 0b1ed82f..00aebf16 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Run multiple commands concurrently. Like `npm run watch-js & npm run watch-less` but better. -![Demo](docs/demo.gif) +![Demo](assets/demo.gif) **Table of Contents** @@ -23,7 +23,7 @@ Like `npm run watch-js & npm run watch-less` but better. - [Input handling](#input-handling) - [Killing other processes](#killing-other-processes) - [Restarting](#restarting) - - [API](#api) + - [API](docs/modules.md) - [FAQ](#faq) ## Why @@ -301,227 +301,6 @@ concurrently [options] For more details, visit https://github.com/open-cli-tools/concurrently -## API - -**concurrently** can be used programmatically by using the API documented below: - - - -### `CommandIdentifier` (type) - -Identifier for a command; if string, it's the command's name, if number, it's the index. - -### `CommandInfo` (interface) - -**Members:** - -- name (`string`) - Command's name. -- command (`string`) - Which command line the command has. -- env (`Record`) - Which environment variables should the spawned process have. -- cwd (`string`) - The current working directory of the process when spawned. -- prefixColor (`string`) - Color to use on prefix of the command. -- raw (`boolean`) - Output command in raw format. - -### `CloseEvent` (interface) - -**Members:** - -- command (`CommandInfo`) -- index (`number`) - The command's index among all commands ran. -- killed (`boolean`) - Whether the command exited because it was killed. -- exitCode (`string | number`) - The exit code or signal for the command. -- timings (`{ startDate: Date; endDate: Date; durationSeconds: number; }`) - -### `TimerEvent` (interface) - -**Members:** - -- startDate (`Date`) -- endDate (`Date`) - -### `ChildProcess` (type) - -Subtype of NodeJS's child_process including only what's actually needed for a command to work. - -### `KillProcess` (type) - -Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. - -### `SpawnCommand` (type) - -Interface for a function that spawns a command and returns its child process instance. - -### `Command` (class) - -### `CommandParser` (interface) - -A command parser encapsulates a specific logic for mapping `CommandInfo` objects -into another `CommandInfo`. - -A prime example is turning an abstract `npm:foo` into `npm run foo`, but it could also turn -the prefix color of a command brighter, or maybe even prefixing each command with `time(1)`. - -**Members:** - -- /\*\* - -* Parses `commandInfo` and returns one or more `CommandInfo`s. -* -* Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to -* run given the original input. -* An example of this is when the command contains a wildcard and it must be expanded into all -* viable options so that the consumer can decide which ones to run. - \*/ - parse (`(commandInfo: CommandInfo) => CommandInfo | CommandInfo[]`) - Parses `commandInfo` and returns one or more `CommandInfo`s. - -Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to -run given the original input. -An example of this is when the command contains a wildcard and it must be expanded into all -viable options so that the consumer can decide which ones to run. - -### `ExpandArguments` (class) - -Replace placeholders with additional arguments. - -### `ExpandNpmShortcut` (class) - -Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run ` and so on. - -### `ExpandNpmWildcard` (class) - -Finds wildcards in npm/yarn/pnpm/bun run commands and replaces them with all matching scripts in the -`package.json` file of the current directory. - -### `StripQuotes` (class) - -Strips quotes around commands so that they can run on the current shell. - -### `SuccessCondition` (type) - -Defines which command(s) in a list must exit successfully (with an exit code of `0`): - -- `first`: only the first specified command; -- `last`: only the last specified command; -- `all`: all commands. -- `command-{name|index}`: only the commands with the specified names or index. -- `!command-{name|index}`: all commands but the ones with the specified names or index. - -### `CompletionListener` (class) - -Provides logic to determine whether lists of commands ran successfully. - -### `FlowController` (interface) - -Interface for a class that controls and/or watches the behavior of commands. - -This may include logging their output, creating interactions between them, or changing when they -actually finish. - -**Members:** - -- handle (`(commands: Command[]) => { commands: Command[]; onFinish?: () => void; }`) - -### `getSpawnOpts` (function) - -### `defaultInputTarget` (variable) - -### `handleInput` (variable) - -Whether process.stdin should be forwarded to child processes. - -### `maxProcesses` (variable) - -How many processes to run at once. - -### `hide` (variable) - -Indices and names of commands whose output are not to be logged. - -### `nameSeparator` (variable) - -The character to split on. - -### `prefix` (variable) - -Which prefix style to use when logging processes output. - -### `prefixColors` (variable) - -Default prefix color. - -### `prefixLength` (variable) - -How many bytes we'll show on the command prefix. - -### `raw` (variable) - -### `restartTries` (variable) - -Number of attempts of restarting a process, if it exits with non-0 code. - -### `restartDelay` (variable) - -How many milliseconds concurrently should wait before restarting a process. - -### `success` (variable) - -Condition of success for concurrently itself. - -### `timestampFormat` (variable) - -Date format used when logging date/time. - -### `cwd` (variable: string | undefined) - -Current working dir passed as option to spawn command. -Defaults to process.cwd() - -### `timings` (variable) - -Whether to show timing information for processes in console output. - -### `passthroughArguments` (variable) - -Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. - -### `killSignal` (variable: string | undefined) - -Signal to send to other processes if one exits or dies. - -Defaults to OS specific signal. (SIGTERM on Linux/MacOS) - -### `Logger` (class) - -### `OutputWriter` (class) - -Class responsible for actually writing output onto a writable stream. - -### `PrefixColorSelector` (class) - -### `ConcurrentlyCommandInput` (type) - -A command that is to be passed into `concurrently()`. -If value is a string, then that's the command's command line. -Fine grained options can be defined by using the object format. - -### `ConcurrentlyResult` (type) - -### `ConcurrentlyOptions` (type) - -### `concurrently` (function) - -Core concurrently functionality -- spawns the given commands concurrently and -returns the commands themselves + the result according to the specified success condition. - -**Parameters:** - -- baseCommands (`ConcurrentlyCommandInput[]`) -- baseOptions (`Partial`) - -**returns:** ConcurrentlyResult - - - ## FAQ - Process exited with code _null_? @@ -539,11 +318,3 @@ returns the commands themselves + the result according to the specified success - Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn), [pnpm](https://pnpm.js.org/), or [Bun](https://bun.sh/)? Yes! In all examples above, you may replace "`npm`" with "`yarn`", "`pnpm`", or "`bun`". - -``` - -``` - -``` - -``` diff --git a/docs/demo.gif b/assets/demo.gif similarity index 100% rename from docs/demo.gif rename to assets/demo.gif diff --git a/docs/frontend-demo.gif b/assets/frontend-demo.gif similarity index 100% rename from docs/frontend-demo.gif rename to assets/frontend-demo.gif diff --git a/docs/kill-demo.gif b/assets/kill-demo.gif similarity index 100% rename from docs/kill-demo.gif rename to assets/kill-demo.gif diff --git a/docs/raw-demo.gif b/assets/raw-demo.gif similarity index 100% rename from docs/raw-demo.gif rename to assets/raw-demo.gif diff --git a/package.json b/package.json index a7293dd3..f83d5151 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "scripts": { "build": "tsc --build", "postbuild": "chmod +x dist/bin/concurrently.js", - "generate:doc:api": "ts-readme --header-depth 3 src/concurrently.ts ", + "generate:doc:api": "typedoc", "clean": "tsc --build --clean", "format": "prettier --check '**/*.{json,y?(a)ml,md}'", "format:fix": "pnpm run format --write", @@ -89,7 +89,8 @@ "prettier": "^3.0.3", "safe-publish-latest": "^2.0.0", "string-argv": "^0.3.2", - "ts-readme": "^1.1.3", + "typedoc": "^0.25.2", + "typedoc-plugin-markdown": "^3.16.0", "typescript": "~5.2.2" }, "files": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bdccfa74..d8eeffd7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: false @@ -115,9 +115,12 @@ devDependencies: string-argv: specifier: ^0.3.2 version: 0.3.2 - ts-readme: - specifier: ^1.1.3 - version: 1.1.3(typescript@5.2.2) + typedoc: + specifier: ^0.25.2 + version: 0.25.2(typescript@5.2.2) + typedoc-plugin-markdown: + specifier: ^3.16.0 + version: 3.16.0(typedoc@0.25.2) typescript: specifier: ~5.2.2 version: 5.2.2 @@ -1241,14 +1244,6 @@ packages: '@babel/types': 7.20.7 dev: true - /@types/command-line-args@5.2.1: - resolution: {integrity: sha512-U2OcmS2tj36Yceu+mRuPyUV0ILfau/h5onStcSCzqTENsq0sBiAp2TmaXu1k8fY4McLcPKSYl9FRzn2hx5bI+w==} - dev: true - - /@types/command-line-usage@5.0.2: - resolution: {integrity: sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg==} - dev: true - /@types/graceful-fs@4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: @@ -1565,6 +1560,10 @@ packages: engines: {node: '>=12'} dev: true + /ansi-sequence-parser@1.1.1: + resolution: {integrity: sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==} + dev: true + /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -1606,16 +1605,6 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true - /array-back@3.1.0: - resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} - engines: {node: '>=6'} - dev: true - - /array-back@4.0.2: - resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} - engines: {node: '>=8'} - dev: true - /array-buffer-byte-length@1.0.0: resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} dependencies: @@ -1786,6 +1775,12 @@ packages: concat-map: 0.0.1 dev: true + /brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: true + /braces@3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} @@ -1944,39 +1939,6 @@ packages: delayed-stream: 1.0.0 dev: true - /command-line-application@0.9.6: - resolution: {integrity: sha512-7wc7YX7s/hqZWKp4r37IBlW/Bhh92HWeQW2VV++Mt9x35AKFntz9f7A94Zz+AsImHZmRGHd8iNW5m0jUd4GQpg==} - dependencies: - '@types/command-line-args': 5.2.1 - '@types/command-line-usage': 5.0.2 - chalk: 2.4.2 - command-line-args: 5.2.1 - command-line-usage: 6.1.3 - meant: 1.0.3 - remove-markdown: 0.3.0 - tslib: 1.10.0 - dev: true - - /command-line-args@5.2.1: - resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - find-replace: 3.0.0 - lodash.camelcase: 4.3.0 - typical: 4.0.0 - dev: true - - /command-line-usage@6.1.3: - resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} - engines: {node: '>=8.0.0'} - dependencies: - array-back: 4.0.2 - chalk: 2.4.2 - table-layout: 1.0.2 - typical: 5.2.0 - dev: true - /commander@11.0.0: resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} engines: {node: '>=16'} @@ -2100,11 +2062,6 @@ packages: optional: true dev: true - /deep-extend@0.6.0: - resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} - engines: {node: '>=4.0.0'} - dev: true - /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true @@ -2723,13 +2680,6 @@ packages: to-regex-range: 5.0.1 dev: true - /find-replace@3.0.0: - resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - dev: true - /find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} @@ -2917,6 +2867,19 @@ packages: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true + /handlebars@4.7.8: + resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} + engines: {node: '>=0.4.7'} + hasBin: true + dependencies: + minimist: 1.2.7 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.17.4 + dev: true + /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} dev: true @@ -3876,10 +3839,6 @@ packages: p-locate: 5.0.0 dev: true - /lodash.camelcase@4.3.0: - resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - dev: true - /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -3917,6 +3876,10 @@ packages: yallist: 4.0.0 dev: true + /lunr@2.3.9: + resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} + dev: true + /make-dir@3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} @@ -3930,8 +3893,10 @@ packages: tmpl: 1.0.5 dev: true - /meant@1.0.3: - resolution: {integrity: sha512-88ZRGcNxAq4EH38cQ4D85PM57pikCwS8Z99EWHODxN7KBY+UuPiqzRTtZzS8KTXO/ywSWbdjjJST2Hly/EQxLw==} + /marked@4.3.0: + resolution: {integrity: sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==} + engines: {node: '>= 12'} + hasBin: true dev: true /merge-stream@2.0.0: @@ -3979,6 +3944,13 @@ packages: brace-expansion: 1.1.11 dev: true + /minimatch@9.0.3: + resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimist@1.2.7: resolution: {integrity: sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==} dev: true @@ -3995,6 +3967,10 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true + /neo-async@2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + dev: true + /node-int64@0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} dev: true @@ -4228,12 +4204,6 @@ packages: fast-diff: 1.2.0 dev: true - /prettier@1.19.1: - resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==} - engines: {node: '>=4'} - hasBin: true - dev: true - /prettier@3.0.3: resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} engines: {node: '>=14'} @@ -4283,11 +4253,6 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: true - /reduce-flatten@2.0.0: - resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} - engines: {node: '>=6'} - dev: true - /regenerator-runtime@0.13.11: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} dev: false @@ -4310,10 +4275,6 @@ packages: functions-have-names: 1.2.3 dev: true - /remove-markdown@0.3.0: - resolution: {integrity: sha512-5392eIuy1mhjM74739VunOlsOYKjsH82rQcTBlJ1bkICVC3dQ3ksQzTHh4jGHQFnM+1xzLzcFOMH+BofqXhroQ==} - dev: true - /require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -4456,6 +4417,15 @@ packages: resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==} dev: false + /shiki@0.14.5: + resolution: {integrity: sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==} + dependencies: + ansi-sequence-parser: 1.1.1 + jsonc-parser: 3.2.0 + vscode-oniguruma: 1.7.0 + vscode-textmate: 8.0.0 + dev: true + /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -4637,16 +4607,6 @@ packages: tslib: 2.6.2 dev: true - /table-layout@1.0.2: - resolution: {integrity: sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==} - engines: {node: '>=8.0.0'} - dependencies: - array-back: 4.0.2 - deep-extend: 0.6.0 - typical: 5.2.0 - wordwrapjs: 4.0.1 - dev: true - /test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -4695,18 +4655,6 @@ packages: typescript: 5.2.2 dev: true - /ts-readme@1.1.3(typescript@5.2.2): - resolution: {integrity: sha512-GvI+Vu3m/LGBlgrWwzSmvslnz8msJLNrZ7hQ3Ko2B6PMxeXidqsn6fi20IWgepFjOzhKGw/WlG8NmM7jl3DWeg==} - hasBin: true - peerDependencies: - typescript: '>= 3.x' - dependencies: - command-line-application: 0.9.6 - fast-glob: 3.3.1 - prettier: 1.19.1 - typescript: 5.2.2 - dev: true - /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} dependencies: @@ -4716,10 +4664,6 @@ packages: strip-bom: 3.0.0 dev: true - /tslib@1.10.0: - resolution: {integrity: sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==} - dev: true - /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true @@ -4806,21 +4750,42 @@ packages: is-typed-array: 1.1.12 dev: true + /typedoc-plugin-markdown@3.16.0(typedoc@0.25.2): + resolution: {integrity: sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw==} + peerDependencies: + typedoc: '>=0.24.0' + dependencies: + handlebars: 4.7.8 + typedoc: 0.25.2(typescript@5.2.2) + dev: true + + /typedoc@0.25.2(typescript@5.2.2): + resolution: {integrity: sha512-286F7BeATBiWe/qC4PCOCKlSTwfnsLbC/4cZ68oGBbvAqb9vV33quEOXx7q176OXotD+JdEerdQ1OZGJ818lnA==} + engines: {node: '>= 16'} + hasBin: true + peerDependencies: + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x + dependencies: + lunr: 2.3.9 + marked: 4.3.0 + minimatch: 9.0.3 + shiki: 0.14.5 + typescript: 5.2.2 + dev: true + /typescript@5.2.2: resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} engines: {node: '>=14.17'} hasBin: true dev: true - /typical@4.0.0: - resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} - engines: {node: '>=8'} - dev: true - - /typical@5.2.0: - resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} - engines: {node: '>=8'} + /uglify-js@3.17.4: + resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==} + engines: {node: '>=0.8.0'} + hasBin: true + requiresBuild: true dev: true + optional: true /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} @@ -4862,6 +4827,14 @@ packages: convert-source-map: 1.9.0 dev: true + /vscode-oniguruma@1.7.0: + resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} + dev: true + + /vscode-textmate@8.0.0: + resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} + dev: true + /walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} dependencies: @@ -4897,12 +4870,8 @@ packages: isexe: 2.0.0 dev: true - /wordwrapjs@4.0.1: - resolution: {integrity: sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==} - engines: {node: '>=8.0.0'} - dependencies: - reduce-flatten: 2.0.0 - typical: 5.2.0 + /wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} dev: true /wrap-ansi@7.0.0: diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 00000000..e0db2770 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "name": "Concurrently API documentation", + "entryPoints": ["./src"], + "hideBreadcrumbs": true, + "disableSources": true, + "plugin": "typedoc-plugin-markdown" +} From c594afa0cea434bd574db834bd3b82771c16a70a Mon Sep 17 00:00:00 2001 From: Tarek Touati <19335073+Tarektouati@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:07:49 +0200 Subject: [PATCH 3/4] create a script to generate documentation --- docs/.nojekyll | 1 + docs/classes/Command.md | 264 +++++++++++++++++++++++++++++ docs/classes/InputHandler.md | 95 +++++++++++ docs/classes/KillOnSignal.md | 65 +++++++ docs/classes/KillOthers.md | 80 +++++++++ docs/classes/LogError.md | 64 +++++++ docs/classes/LogExit.md | 64 +++++++ docs/classes/LogOutput.md | 64 +++++++ docs/classes/LogTimings.md | 102 +++++++++++ docs/classes/Logger.md | 273 ++++++++++++++++++++++++++++++ docs/classes/RestartProcess.md | 88 ++++++++++ docs/interfaces/CloseEvent.md | 55 ++++++ docs/interfaces/FlowController.md | 44 +++++ docs/interfaces/TimerEvent.md | 20 +++ docs/modules.md | 114 +++++++++++++ package.json | 2 +- scripts/generate-documentation.sh | 6 + 17 files changed, 1400 insertions(+), 1 deletion(-) create mode 100644 docs/.nojekyll create mode 100644 docs/classes/Command.md create mode 100644 docs/classes/InputHandler.md create mode 100644 docs/classes/KillOnSignal.md create mode 100644 docs/classes/KillOthers.md create mode 100644 docs/classes/LogError.md create mode 100644 docs/classes/LogExit.md create mode 100644 docs/classes/LogOutput.md create mode 100644 docs/classes/LogTimings.md create mode 100644 docs/classes/Logger.md create mode 100644 docs/classes/RestartProcess.md create mode 100644 docs/interfaces/CloseEvent.md create mode 100644 docs/interfaces/FlowController.md create mode 100644 docs/interfaces/TimerEvent.md create mode 100644 docs/modules.md create mode 100755 scripts/generate-documentation.sh diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 00000000..e2ac6616 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/docs/classes/Command.md b/docs/classes/Command.md new file mode 100644 index 00000000..656bc493 --- /dev/null +++ b/docs/classes/Command.md @@ -0,0 +1,264 @@ +# Class: Command + +## Implements + +- `CommandInfo` + +## Table of contents + +### Constructors + +- [constructor](Command.md#constructor) + +### Properties + +- [close](Command.md#close) +- [command](Command.md#command) +- [cwd](Command.md#cwd) +- [env](Command.md#env) +- [error](Command.md#error) +- [exited](Command.md#exited) +- [index](Command.md#index) +- [killProcess](Command.md#killprocess) +- [killed](Command.md#killed) +- [name](Command.md#name) +- [pid](Command.md#pid) +- [prefixColor](Command.md#prefixcolor) +- [process](Command.md#process) +- [spawn](Command.md#spawn) +- [spawnOpts](Command.md#spawnopts) +- [stderr](Command.md#stderr) +- [stdin](Command.md#stdin) +- [stdout](Command.md#stdout) +- [timer](Command.md#timer) + +### Accessors + +- [killable](Command.md#killable) + +### Methods + +- [kill](Command.md#kill) +- [start](Command.md#start) +- [canKill](Command.md#cankill) + +## Constructors + +### constructor + +• **new Command**(`«destructured»`, `spawnOpts`, `spawn`, `killProcess`) + +#### Parameters + +| Name | Type | +| :--------------- | :------------------------------------ | +| `«destructured»` | `CommandInfo` & { `index`: `number` } | +| `spawnOpts` | `SpawnOptions` | +| `spawn` | `SpawnCommand` | +| `killProcess` | `KillProcess` | + +## Properties + +### close + +• `Readonly` **close**: `Subject`<[`CloseEvent`](../interfaces/CloseEvent.md)\> + +--- + +### command + +• `Readonly` **command**: `string` + +**`Inherit Doc`** + +#### Implementation of + +CommandInfo.command + +--- + +### cwd + +• `Optional` `Readonly` **cwd**: `string` + +**`Inherit Doc`** + +#### Implementation of + +CommandInfo.cwd + +--- + +### env + +• `Readonly` **env**: `Record`<`string`, `unknown`\> + +**`Inherit Doc`** + +#### Implementation of + +CommandInfo.env + +--- + +### error + +• `Readonly` **error**: `Subject`<`unknown`\> + +--- + +### exited + +• **exited**: `boolean` = `false` + +--- + +### index + +• `Readonly` **index**: `number` + +--- + +### killProcess + +• `Private` `Readonly` **killProcess**: `KillProcess` + +--- + +### killed + +• **killed**: `boolean` = `false` + +--- + +### name + +• `Readonly` **name**: `string` + +**`Inherit Doc`** + +#### Implementation of + +CommandInfo.name + +--- + +### pid + +• `Optional` **pid**: `number` + +--- + +### prefixColor + +• `Optional` `Readonly` **prefixColor**: `string` + +**`Inherit Doc`** + +#### Implementation of + +CommandInfo.prefixColor + +--- + +### process + +• `Optional` **process**: `ChildProcess` + +--- + +### spawn + +• `Private` `Readonly` **spawn**: `SpawnCommand` + +--- + +### spawnOpts + +• `Private` `Readonly` **spawnOpts**: `SpawnOptions` + +--- + +### stderr + +• `Readonly` **stderr**: `Subject`<`Buffer`\> + +--- + +### stdin + +• `Optional` **stdin**: `Writable` + +--- + +### stdout + +• `Readonly` **stdout**: `Subject`<`Buffer`\> + +--- + +### timer + +• `Readonly` **timer**: `Subject`<[`TimerEvent`](../interfaces/TimerEvent.md)\> + +## Accessors + +### killable + +• `get` **killable**(): `boolean` + +#### Returns + +`boolean` + +**`Deprecated`** + +## Methods + +### kill + +▸ **kill**(`code?`): `void` + +Kills this command, optionally specifying a signal to send to it. + +#### Parameters + +| Name | Type | +| :------ | :------- | +| `code?` | `string` | + +#### Returns + +`void` + +--- + +### start + +▸ **start**(): `void` + +Starts this command, piping output, error and close events onto the corresponding observables. + +#### Returns + +`void` + +--- + +### canKill + +▸ `Static` **canKill**(`command`): command is Command & Object + +Detects whether a command can be killed. + +Also works as a type guard on the input `command`. + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `command` | [`Command`](Command.md) | + +#### Returns + +command is Command & Object diff --git a/docs/classes/InputHandler.md b/docs/classes/InputHandler.md new file mode 100644 index 00000000..a80655ee --- /dev/null +++ b/docs/classes/InputHandler.md @@ -0,0 +1,95 @@ +# Class: InputHandler + +Sends input from concurrently through to commands. + +Input can start with a command identifier, in which case it will be sent to that specific command. +For instance, `0:bla` will send `bla` to command at index `0`, and `server:stop` will send `stop` +to command with name `server`. + +If the input doesn't start with a command identifier, it is then always sent to the default target. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](InputHandler.md#constructor) + +### Properties + +- [defaultInputTarget](InputHandler.md#defaultinputtarget) +- [inputStream](InputHandler.md#inputstream) +- [logger](InputHandler.md#logger) +- [pauseInputStreamOnFinish](InputHandler.md#pauseinputstreamonfinish) + +### Methods + +- [handle](InputHandler.md#handle) + +## Constructors + +### constructor + +• **new InputHandler**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :---------------------------- | :----------------------------------------------------- | +| `«destructured»` | `Object` | +| › `defaultInputTarget?` | [`CommandIdentifier`](../modules.md#commandidentifier) | +| › `inputStream?` | `Readable` | +| › `logger` | [`Logger`](Logger.md) | +| › `pauseInputStreamOnFinish?` | `boolean` | + +## Properties + +### defaultInputTarget + +• `Private` `Readonly` **defaultInputTarget**: [`CommandIdentifier`](../modules.md#commandidentifier) + +--- + +### inputStream + +• `Private` `Optional` `Readonly` **inputStream**: `Readable` + +--- + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +--- + +### pauseInputStreamOnFinish + +• `Private` `Readonly` **pauseInputStreamOnFinish**: `boolean` + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :---------- | :-------------------------- | +| `commands` | [`Command`](Command.md)[] | +| `onFinish?` | () => `undefined` \| `void` | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/KillOnSignal.md b/docs/classes/KillOnSignal.md new file mode 100644 index 00000000..e724e84f --- /dev/null +++ b/docs/classes/KillOnSignal.md @@ -0,0 +1,65 @@ +# Class: KillOnSignal + +Watches the main concurrently process for signals and sends the same signal down to each spawned +command. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](KillOnSignal.md#constructor) + +### Properties + +- [process](KillOnSignal.md#process) + +### Methods + +- [handle](KillOnSignal.md#handle) + +## Constructors + +### constructor + +• **new KillOnSignal**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :------------- | +| `«destructured»` | `Object` | +| › `process` | `EventEmitter` | + +## Properties + +### process + +• `Private` `Readonly` **process**: `EventEmitter` + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/KillOthers.md b/docs/classes/KillOthers.md new file mode 100644 index 00000000..4de3d23a --- /dev/null +++ b/docs/classes/KillOthers.md @@ -0,0 +1,80 @@ +# Class: KillOthers + +Sends a SIGTERM signal to all commands when one of the commands exits with a matching condition. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](KillOthers.md#constructor) + +### Properties + +- [conditions](KillOthers.md#conditions) +- [killSignal](KillOthers.md#killsignal) +- [logger](KillOthers.md#logger) + +### Methods + +- [handle](KillOthers.md#handle) + +## Constructors + +### constructor + +• **new KillOthers**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :--------------------------------------------------- | +| `«destructured»` | `Object` | +| › `conditions` | `ProcessCloseCondition` \| `ProcessCloseCondition`[] | +| › `killSignal` | `undefined` \| `string` | +| › `logger` | [`Logger`](Logger.md) | + +## Properties + +### conditions + +• `Private` `Readonly` **conditions**: `ProcessCloseCondition`[] + +--- + +### killSignal + +• `Private` `Readonly` **killSignal**: `undefined` \| `string` + +--- + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/LogError.md b/docs/classes/LogError.md new file mode 100644 index 00000000..32621989 --- /dev/null +++ b/docs/classes/LogError.md @@ -0,0 +1,64 @@ +# Class: LogError + +Logs when commands failed executing, e.g. due to the executable not existing in the system. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](LogError.md#constructor) + +### Properties + +- [logger](LogError.md#logger) + +### Methods + +- [handle](LogError.md#handle) + +## Constructors + +### constructor + +• **new LogError**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :-------------------- | +| `«destructured»` | `Object` | +| › `logger` | [`Logger`](Logger.md) | + +## Properties + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/LogExit.md b/docs/classes/LogExit.md new file mode 100644 index 00000000..1a604f59 --- /dev/null +++ b/docs/classes/LogExit.md @@ -0,0 +1,64 @@ +# Class: LogExit + +Logs the exit code/signal of commands. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](LogExit.md#constructor) + +### Properties + +- [logger](LogExit.md#logger) + +### Methods + +- [handle](LogExit.md#handle) + +## Constructors + +### constructor + +• **new LogExit**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :-------------------- | +| `«destructured»` | `Object` | +| › `logger` | [`Logger`](Logger.md) | + +## Properties + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/LogOutput.md b/docs/classes/LogOutput.md new file mode 100644 index 00000000..ae4e8cae --- /dev/null +++ b/docs/classes/LogOutput.md @@ -0,0 +1,64 @@ +# Class: LogOutput + +Logs the stdout and stderr output of commands. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](LogOutput.md#constructor) + +### Properties + +- [logger](LogOutput.md#logger) + +### Methods + +- [handle](LogOutput.md#handle) + +## Constructors + +### constructor + +• **new LogOutput**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :-------------------- | +| `«destructured»` | `Object` | +| › `logger` | [`Logger`](Logger.md) | + +## Properties + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/classes/LogTimings.md b/docs/classes/LogTimings.md new file mode 100644 index 00000000..01bcb66d --- /dev/null +++ b/docs/classes/LogTimings.md @@ -0,0 +1,102 @@ +# Class: LogTimings + +Logs timing information about commands as they start/stop and then a summary when all commands finish. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](LogTimings.md#constructor) + +### Properties + +- [logger](LogTimings.md#logger) +- [timestampFormat](LogTimings.md#timestampformat) + +### Methods + +- [handle](LogTimings.md#handle) +- [printExitInfoTimingTable](LogTimings.md#printexitinfotimingtable) +- [mapCloseEventToTimingInfo](LogTimings.md#mapcloseeventtotiminginfo) + +## Constructors + +### constructor + +• **new LogTimings**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :------------------- | :-------------------- | +| `«destructured»` | `Object` | +| › `logger?` | [`Logger`](Logger.md) | +| › `timestampFormat?` | `string` | + +## Properties + +### logger + +• `Private` `Optional` `Readonly` **logger**: [`Logger`](Logger.md) + +--- + +### timestampFormat + +• `Private` `Readonly` **timestampFormat**: `string` + +## Methods + +### handle + +▸ **handle**(`commands`): { `commands`: [`Command`](Command.md)[] ; `onFinish?`: `undefined` } \| { `commands`: [`Command`](Command.md)[] ; `onFinish`: () => `void` } + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +{ `commands`: [`Command`](Command.md)[] ; `onFinish?`: `undefined` } \| { `commands`: [`Command`](Command.md)[] ; `onFinish`: () => `void` } + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) + +--- + +### printExitInfoTimingTable + +▸ `Private` **printExitInfoTimingTable**(`exitInfos`): [`CloseEvent`](../interfaces/CloseEvent.md)[] + +#### Parameters + +| Name | Type | +| :---------- | :-------------------------------------------- | +| `exitInfos` | [`CloseEvent`](../interfaces/CloseEvent.md)[] | + +#### Returns + +[`CloseEvent`](../interfaces/CloseEvent.md)[] + +--- + +### mapCloseEventToTimingInfo + +▸ `Static` **mapCloseEventToTimingInfo**(`«destructured»`): `TimingInfo` + +#### Parameters + +| Name | Type | +| :--------------- | :------------------------------------------ | +| `«destructured»` | [`CloseEvent`](../interfaces/CloseEvent.md) | + +#### Returns + +`TimingInfo` diff --git a/docs/classes/Logger.md b/docs/classes/Logger.md new file mode 100644 index 00000000..45713431 --- /dev/null +++ b/docs/classes/Logger.md @@ -0,0 +1,273 @@ +# Class: Logger + +## Table of contents + +### Constructors + +- [constructor](Logger.md#constructor) + +### Properties + +- [hide](Logger.md#hide) +- [lastChar](Logger.md#lastchar) +- [output](Logger.md#output) +- [prefixFormat](Logger.md#prefixformat) +- [prefixLength](Logger.md#prefixlength) +- [raw](Logger.md#raw) +- [timestampFormat](Logger.md#timestampformat) + +### Methods + +- [colorText](Logger.md#colortext) +- [emit](Logger.md#emit) +- [getPrefix](Logger.md#getprefix) +- [getPrefixesFor](Logger.md#getprefixesfor) +- [log](Logger.md#log) +- [logCommandEvent](Logger.md#logcommandevent) +- [logCommandText](Logger.md#logcommandtext) +- [logGlobalEvent](Logger.md#logglobalevent) +- [logTable](Logger.md#logtable) +- [shortenText](Logger.md#shortentext) + +## Constructors + +### constructor + +• **new Logger**(`«destructured»`) + +#### Parameters + +| Name | Type | Description | +| :------------------- | :----------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | +| `«destructured»` | `Object` | - | +| › `hide?` | [`CommandIdentifier`](../modules.md#commandidentifier) \| [`CommandIdentifier`](../modules.md#commandidentifier)[] | Which command(s) should have their output hidden. | +| › `prefixFormat?` | `string` | The prefix format to use when logging a command's output. Defaults to the command's index. | +| › `prefixLength?` | `number` | How many characters should a prefix have at most, used when the prefix format is `command`. | +| › `raw?` | `boolean` | Whether output should be formatted to include prefixes and whether "event" logs will be logged. | +| › `timestampFormat?` | `string` | Date format used when logging date/time. **`See`** https://date-fns.org/v2.0.1/docs/format | + +## Properties + +### hide + +• `Private` `Readonly` **hide**: [`CommandIdentifier`](../modules.md#commandidentifier)[] + +--- + +### lastChar + +• `Private` `Optional` **lastChar**: `string` + +Last character emitted. +If `undefined`, then nothing has been logged yet. + +--- + +### output + +• `Readonly` **output**: `Subject`<{ `command`: `undefined` \| [`Command`](Command.md) ; `text`: `string` }\> + +Observable that emits when there's been output logged. +If `command` is is `undefined`, then the log is for a global event. + +--- + +### prefixFormat + +• `Private` `Optional` `Readonly` **prefixFormat**: `string` + +--- + +### prefixLength + +• `Private` `Readonly` **prefixLength**: `number` + +--- + +### raw + +• `Private` `Readonly` **raw**: `boolean` + +--- + +### timestampFormat + +• `Private` `Readonly` **timestampFormat**: `string` + +## Methods + +### colorText + +▸ **colorText**(`command`, `text`): `string` + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `command` | [`Command`](Command.md) | +| `text` | `string` | + +#### Returns + +`string` + +--- + +### emit + +▸ **emit**(`command`, `text`): `void` + +#### Parameters + +| Name | Type | +| :-------- | :------------------------------------- | +| `command` | `undefined` \| [`Command`](Command.md) | +| `text` | `string` | + +#### Returns + +`void` + +--- + +### getPrefix + +▸ **getPrefix**(`command`): `string` + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `command` | [`Command`](Command.md) | + +#### Returns + +`string` + +--- + +### getPrefixesFor + +▸ `Private` **getPrefixesFor**(`command`): `Record`<`string`, `string`\> + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `command` | [`Command`](Command.md) | + +#### Returns + +`Record`<`string`, `string`\> + +--- + +### log + +▸ **log**(`prefix`, `text`, `command?`): `void` + +#### Parameters + +| Name | Type | +| :--------- | :---------------------- | +| `prefix` | `string` | +| `text` | `string` | +| `command?` | [`Command`](Command.md) | + +#### Returns + +`void` + +--- + +### logCommandEvent + +▸ **logCommandEvent**(`text`, `command`): `void` + +Logs an event for a command (e.g. start, stop). + +If raw mode is on, then nothing is logged. + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `text` | `string` | +| `command` | [`Command`](Command.md) | + +#### Returns + +`void` + +--- + +### logCommandText + +▸ **logCommandText**(`text`, `command`): `void` + +#### Parameters + +| Name | Type | +| :-------- | :---------------------- | +| `text` | `string` | +| `command` | [`Command`](Command.md) | + +#### Returns + +`void` + +--- + +### logGlobalEvent + +▸ **logGlobalEvent**(`text`): `void` + +Logs a global event (e.g. sending signals to processes). + +If raw mode is on, then nothing is logged. + +#### Parameters + +| Name | Type | +| :----- | :------- | +| `text` | `string` | + +#### Returns + +`void` + +--- + +### logTable + +▸ **logTable**(`tableContents`): `void` + +Logs a table from an input object array, like `console.table`. + +Each row is a single input item, and they are presented in the input order. + +#### Parameters + +| Name | Type | +| :-------------- | :------------------------------- | +| `tableContents` | `Record`<`string`, `unknown`\>[] | + +#### Returns + +`void` + +--- + +### shortenText + +▸ `Private` **shortenText**(`text`): `string` + +#### Parameters + +| Name | Type | +| :----- | :------- | +| `text` | `string` | + +#### Returns + +`string` diff --git a/docs/classes/RestartProcess.md b/docs/classes/RestartProcess.md new file mode 100644 index 00000000..af929091 --- /dev/null +++ b/docs/classes/RestartProcess.md @@ -0,0 +1,88 @@ +# Class: RestartProcess + +Restarts commands that fail up to a defined number of times. + +## Implements + +- [`FlowController`](../interfaces/FlowController.md) + +## Table of contents + +### Constructors + +- [constructor](RestartProcess.md#constructor) + +### Properties + +- [delay](RestartProcess.md#delay) +- [logger](RestartProcess.md#logger) +- [scheduler](RestartProcess.md#scheduler) +- [tries](RestartProcess.md#tries) + +### Methods + +- [handle](RestartProcess.md#handle) + +## Constructors + +### constructor + +• **new RestartProcess**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :--------------- | :-------------------- | +| `«destructured»` | `Object` | +| › `delay?` | `number` | +| › `logger` | [`Logger`](Logger.md) | +| › `scheduler?` | `SchedulerLike` | +| › `tries?` | `number` | + +## Properties + +### delay + +• `Readonly` **delay**: `number` + +--- + +### logger + +• `Private` `Readonly` **logger**: [`Logger`](Logger.md) + +--- + +### scheduler + +• `Private` `Optional` `Readonly` **scheduler**: `SchedulerLike` + +--- + +### tries + +• `Readonly` **tries**: `number` + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------ | +| `commands` | [`Command`](Command.md)[] | + +#### Implementation of + +[FlowController](../interfaces/FlowController.md).[handle](../interfaces/FlowController.md#handle) diff --git a/docs/interfaces/CloseEvent.md b/docs/interfaces/CloseEvent.md new file mode 100644 index 00000000..b812a2a4 --- /dev/null +++ b/docs/interfaces/CloseEvent.md @@ -0,0 +1,55 @@ +# Interface: CloseEvent + +## Table of contents + +### Properties + +- [command](CloseEvent.md#command) +- [exitCode](CloseEvent.md#exitcode) +- [index](CloseEvent.md#index) +- [killed](CloseEvent.md#killed) +- [timings](CloseEvent.md#timings) + +## Properties + +### command + +• **command**: `CommandInfo` + +--- + +### exitCode + +• **exitCode**: `string` \| `number` + +The exit code or signal for the command. + +--- + +### index + +• **index**: `number` + +The command's index among all commands ran. + +--- + +### killed + +• **killed**: `boolean` + +Whether the command exited because it was killed. + +--- + +### timings + +• **timings**: `Object` + +#### Type declaration + +| Name | Type | +| :---------------- | :------- | +| `durationSeconds` | `number` | +| `endDate` | `Date` | +| `startDate` | `Date` | diff --git a/docs/interfaces/FlowController.md b/docs/interfaces/FlowController.md new file mode 100644 index 00000000..ad9e225b --- /dev/null +++ b/docs/interfaces/FlowController.md @@ -0,0 +1,44 @@ +# Interface: FlowController + +Interface for a class that controls and/or watches the behavior of commands. + +This may include logging their output, creating interactions between them, or changing when they +actually finish. + +## Implemented by + +- [`InputHandler`](../classes/InputHandler.md) +- [`KillOnSignal`](../classes/KillOnSignal.md) +- [`KillOthers`](../classes/KillOthers.md) +- [`LogError`](../classes/LogError.md) +- [`LogExit`](../classes/LogExit.md) +- [`LogOutput`](../classes/LogOutput.md) +- [`LogTimings`](../classes/LogTimings.md) +- [`RestartProcess`](../classes/RestartProcess.md) + +## Table of contents + +### Methods + +- [handle](FlowController.md#handle) + +## Methods + +### handle + +▸ **handle**(`commands`): `Object` + +#### Parameters + +| Name | Type | +| :--------- | :----------------------------------- | +| `commands` | [`Command`](../classes/Command.md)[] | + +#### Returns + +`Object` + +| Name | Type | +| :---------- | :----------------------------------- | +| `commands` | [`Command`](../classes/Command.md)[] | +| `onFinish?` | () => `void` | diff --git a/docs/interfaces/TimerEvent.md b/docs/interfaces/TimerEvent.md new file mode 100644 index 00000000..4d29aa42 --- /dev/null +++ b/docs/interfaces/TimerEvent.md @@ -0,0 +1,20 @@ +# Interface: TimerEvent + +## Table of contents + +### Properties + +- [endDate](TimerEvent.md#enddate) +- [startDate](TimerEvent.md#startdate) + +## Properties + +### endDate + +• `Optional` **endDate**: `Date` + +--- + +### startDate + +• **startDate**: `Date` diff --git a/docs/modules.md b/docs/modules.md new file mode 100644 index 00000000..f4227e85 --- /dev/null +++ b/docs/modules.md @@ -0,0 +1,114 @@ +# Concurrently API documentation + +## Table of contents + +### Classes + +- [Command](classes/Command.md) +- [InputHandler](classes/InputHandler.md) +- [KillOnSignal](classes/KillOnSignal.md) +- [KillOthers](classes/KillOthers.md) +- [LogError](classes/LogError.md) +- [LogExit](classes/LogExit.md) +- [LogOutput](classes/LogOutput.md) +- [LogTimings](classes/LogTimings.md) +- [Logger](classes/Logger.md) +- [RestartProcess](classes/RestartProcess.md) + +### Interfaces + +- [CloseEvent](interfaces/CloseEvent.md) +- [FlowController](interfaces/FlowController.md) +- [TimerEvent](interfaces/TimerEvent.md) + +### Type Aliases + +- [CommandIdentifier](modules.md#commandidentifier) +- [ConcurrentlyCommandInput](modules.md#concurrentlycommandinput) +- [ConcurrentlyOptions](modules.md#concurrentlyoptions) +- [ConcurrentlyResult](modules.md#concurrentlyresult) + +### Functions + +- [concurrently](modules.md#concurrently) +- [default](modules.md#default) + +## Type Aliases + +### CommandIdentifier + +Ƭ **CommandIdentifier**: `string` \| `number` + +Identifier for a command; if string, it's the command's name, if number, it's the index. + +--- + +### ConcurrentlyCommandInput + +Ƭ **ConcurrentlyCommandInput**: `string` \| { `command`: `string` } & `Partial`<`CommandInfo`\> + +A command that is to be passed into `concurrently()`. +If value is a string, then that's the command's command line. +Fine grained options can be defined by using the object format. + +--- + +### ConcurrentlyOptions + +Ƭ **ConcurrentlyOptions**: `BaseConcurrentlyOptions` & { `additionalArguments?`: `string`[] ; `defaultInputTarget?`: [`CommandIdentifier`](modules.md#commandidentifier) ; `handleInput?`: `boolean` ; `hide?`: [`CommandIdentifier`](modules.md#commandidentifier) \| [`CommandIdentifier`](modules.md#commandidentifier)[] ; `inputStream?`: `Readable` ; `killOthers?`: `ProcessCloseCondition` \| `ProcessCloseCondition`[] ; `pauseInputStreamOnFinish?`: `boolean` ; `prefix?`: `string` ; `prefixLength?`: `number` ; `raw?`: `boolean` ; `restartDelay?`: `number` ; `restartTries?`: `number` ; `timestampFormat?`: `string` ; `timings?`: `boolean` } + +Logger options + +--- + +### ConcurrentlyResult + +Ƭ **ConcurrentlyResult**: `Object` + +#### Type declaration + +| Name | Type | Description | +| :--------- | :----------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `commands` | [`Command`](classes/Command.md)[] | All commands created and ran by concurrently. | +| `result` | `Promise`<[`CloseEvent`](interfaces/CloseEvent.md)[]\> | A promise that resolves when concurrently ran successfully according to the specified success condition, or reject otherwise. Both the resolved and rejected value is the list of all command's close events. | + +## Functions + +### concurrently + +▸ **concurrently**(`baseCommands`, `baseOptions?`): [`ConcurrentlyResult`](modules.md#concurrentlyresult) + +Core concurrently functionality -- spawns the given commands concurrently and +returns the commands themselves + the result according to the specified success condition. + +#### Parameters + +| Name | Type | +| :------------- | :------------------------------------------------------------------ | +| `baseCommands` | [`ConcurrentlyCommandInput`](modules.md#concurrentlycommandinput)[] | +| `baseOptions?` | `Partial`<`ConcurrentlyOptions`\> | + +#### Returns + +[`ConcurrentlyResult`](modules.md#concurrentlyresult) + +**`See`** + +CompletionListener + +--- + +### default + +▸ **default**(`commands`, `options?`): [`ConcurrentlyResult`](modules.md#concurrentlyresult) + +#### Parameters + +| Name | Type | +| :--------- | :------------------------------------------------------------------ | +| `commands` | [`ConcurrentlyCommandInput`](modules.md#concurrentlycommandinput)[] | +| `options` | `Partial`<[`ConcurrentlyOptions`](modules.md#concurrentlyoptions)\> | + +#### Returns + +[`ConcurrentlyResult`](modules.md#concurrentlyresult) diff --git a/package.json b/package.json index f83d5151..49359b94 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "scripts": { "build": "tsc --build", "postbuild": "chmod +x dist/bin/concurrently.js", - "generate:doc:api": "typedoc", + "generate:doc:api": "./scripts/generate-documentation.sh", "clean": "tsc --build --clean", "format": "prettier --check '**/*.{json,y?(a)ml,md}'", "format:fix": "pnpm run format --write", diff --git a/scripts/generate-documentation.sh b/scripts/generate-documentation.sh new file mode 100755 index 00000000..d744612b --- /dev/null +++ b/scripts/generate-documentation.sh @@ -0,0 +1,6 @@ +#!/bin/bash +#Generate documentation for the project based on Typescript types +pnpm exec typedoc + +# Typedoc generates a README.md file in the docs folder, which is not needed +rm -rf docs/README.md From af9993ff999f4e5d1ffc3be363d759cdfa741ecc Mon Sep 17 00:00:00 2001 From: Tarek Touati <19335073+Tarektouati@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:52:09 +0200 Subject: [PATCH 4/4] revert modified comments in codebase --- src/command.ts | 64 ++++++++++++++++++++++++++++---------- src/completion-listener.ts | 8 +++-- src/concurrently.ts | 12 +++++-- src/defaults.ts | 44 +++++++++++++++++++------- src/get-spawn-opts.ts | 8 +++-- src/index.ts | 14 ++++++--- src/logger.ts | 8 +++-- 7 files changed, 118 insertions(+), 40 deletions(-) diff --git a/src/command.ts b/src/command.ts index f50bacf7..c5593e0c 100644 --- a/src/command.ts +++ b/src/command.ts @@ -2,39 +2,59 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process'; import * as Rx from 'rxjs'; import { EventEmitter, Writable } from 'stream'; -/** Identifier for a command; if string, it's the command's name, if number, it's the index.*/ +/** + * Identifier for a command; if string, it's the command's name, if number, it's the index. + */ export type CommandIdentifier = string | number; export interface CommandInfo { - /** Command's name. */ + /** + * Command's name. + */ name: string; - /** Which command line the command has. */ + /** + * Which command line the command has. + */ command: string; - /** Which environment variables should the spawned process have.*/ + /** + * Which environment variables should the spawned process have. + */ env?: Record; - /** The current working directory of the process when spawned.*/ + /** + * The current working directory of the process when spawned. + */ cwd?: string; - /** Color to use on prefix of the command.*/ + /** + * Color to use on prefix of the command. + */ prefixColor?: string; - /** Output command in raw format.*/ + /** + * Output command in raw format. + */ raw?: boolean; } export interface CloseEvent { command: CommandInfo; - /** The command's index among all commands ran.*/ + /** + * The command's index among all commands ran. + */ index: number; - /** Whether the command exited because it was killed.*/ + /** + * Whether the command exited because it was killed. + */ killed: boolean; - /** The exit code or signal for the command.*/ + /** + * The exit code or signal for the command. + */ exitCode: string | number; timings: { startDate: Date; @@ -48,14 +68,20 @@ export interface TimerEvent { endDate?: Date; } -/** Subtype of NodeJS's child_process including only what's actually needed for a command to work. */ +/** + * Subtype of NodeJS's child_process including only what's actually needed for a command to work. + */ export type ChildProcess = EventEmitter & Pick; -/** Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. */ +/** + * Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. + */ export type KillProcess = (pid: number, signal?: string) => void; -/** Interface for a function that spawns a command and returns its child process instance. */ +/** + * Interface for a function that spawns a command and returns its child process instance. + */ export type SpawnCommand = (command: string, options: SpawnOptions) => ChildProcess; export class Command implements CommandInfo { @@ -113,7 +139,9 @@ export class Command implements CommandInfo { this.spawnOpts = spawnOpts; } - /** Starts this command, piping output, error and close events onto the corresponding observables. */ + /** + * Starts this command, piping output, error and close events onto the corresponding observables. + */ start() { const child = this.spawn(this.command, this.spawnOpts); this.process = child; @@ -162,7 +190,9 @@ export class Command implements CommandInfo { this.stdin = child.stdin || undefined; } - /** Kills this command, optionally specifying a signal to send to it. */ + /** + * Kills this command, optionally specifying a signal to send to it. + */ kill(code?: string) { if (Command.canKill(this)) { this.killed = true; @@ -180,7 +210,9 @@ export class Command implements CommandInfo { } } -/** Pipes all events emitted by `stream` into `subject`.s */ +/** + * Pipes all events emitted by `stream` into `subject`. + */ function pipeTo(stream: Rx.Observable, subject: Rx.Subject) { stream.subscribe((event) => subject.next(event)); } diff --git a/src/completion-listener.ts b/src/completion-listener.ts index 07855031..6889a676 100644 --- a/src/completion-listener.ts +++ b/src/completion-listener.ts @@ -19,7 +19,9 @@ export type SuccessCondition = | `command-${string | number}` | `!command-${string | number}`; -/** Provides logic to determine whether lists of commands ran successfully. */ +/** + * Provides logic to determine whether lists of commands ran successfully. + */ export class CompletionListener { private readonly successCondition: SuccessCondition; private readonly scheduler?: Rx.SchedulerLike; @@ -36,7 +38,9 @@ export class CompletionListener { */ successCondition?: SuccessCondition; - /** For testing only.*/ + /** + * For testing only. + */ scheduler?: Rx.SchedulerLike; }) { this.successCondition = successCondition; diff --git a/src/concurrently.ts b/src/concurrently.ts index 1a0e7ecc..2c5b9ec8 100644 --- a/src/concurrently.ts +++ b/src/concurrently.ts @@ -34,7 +34,9 @@ const defaults: ConcurrentlyOptions = { export type ConcurrentlyCommandInput = string | ({ command: string } & Partial); export type ConcurrentlyResult = { - /** All commands created and ran by concurrently.*/ + /** + * All commands created and ran by concurrently. + */ commands: Command[]; /** @@ -49,10 +51,14 @@ export type ConcurrentlyResult = { export type ConcurrentlyOptions = { logger?: Logger; - /** Which stream should the commands output be written to. */ + /** + * Which stream should the commands output be written to. + */ outputStream?: Writable; - /** Whether the output should be ordered as if the commands were run sequentially.*/ + /** + * Whether the output should be ordered as if the commands were run sequentially. + */ group?: boolean; /** diff --git a/src/defaults.ts b/src/defaults.ts index 2a32edb6..ddefbf4f 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -6,19 +6,29 @@ import { SuccessCondition } from './completion-listener'; export const defaultInputTarget = 0; -/** Whether process.stdin should be forwarded to child processes. */ +/** + * Whether process.stdin should be forwarded to child processes. + */ export const handleInput = false; -/** How many processes to run at once. */ +/** + * How many processes to run at once. + */ export const maxProcesses = 0; -/** Indices and names of commands whose output are not to be logged. */ +/** + * Indices and names of commands whose output are not to be logged. + */ export const hide = ''; -/** The character to split on.*/ +/** + * The character to split on. + */ export const nameSeparator = ','; -/** Which prefix style to use when logging processes output.*/ +/** + * Which prefix style to use when logging processes output. + */ export const prefix = ''; /** @@ -27,18 +37,26 @@ export const prefix = ''; */ export const prefixColors = 'reset'; -/** How many bytes we'll show on the command prefix.*/ +/** + * How many bytes we'll show on the command prefix. + */ export const prefixLength = 10; export const raw = false; -/** Number of attempts of restarting a process, if it exits with non-0 code. */ +/** + * Number of attempts of restarting a process, if it exits with non-0 code. + */ export const restartTries = 0; -/** How many milliseconds concurrently should wait before restarting a process. */ +/** + * How many milliseconds concurrently should wait before restarting a process. + */ export const restartDelay = 0; -/** Condition of success for concurrently itself. */ +/** + * Condition of success for concurrently itself. + */ export const success = 'all' as SuccessCondition; /** @@ -53,10 +71,14 @@ export const timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS'; */ export const cwd: string | undefined = undefined; -/** Whether to show timing information for processes in console output. */ +/** + * Whether to show timing information for processes in console output. + */ export const timings = false; -/** Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. */ +/** + * Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. + */ export const passthroughArguments = false; /** diff --git a/src/get-spawn-opts.ts b/src/get-spawn-opts.ts index d50fa58f..a65d6faa 100644 --- a/src/get-spawn-opts.ts +++ b/src/get-spawn-opts.ts @@ -16,7 +16,9 @@ export const getSpawnOpts = ({ */ colorSupport?: Pick | false; - /** The NodeJS process. */ + /** + * The NodeJS process. + */ process?: Pick; /** @@ -31,7 +33,9 @@ export const getSpawnOpts = ({ */ raw?: boolean; - /** Map of custom environment variables to include in the spawn options. */ + /** + * Map of custom environment variables to include in the spawn options. + */ env?: Record; }): SpawnOptions => ({ cwd: cwd || process.cwd(), diff --git a/src/index.ts b/src/index.ts index 27307ac4..3dce77b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,9 +18,11 @@ import { LogTimings } from './flow-control/log-timings'; import { RestartProcess } from './flow-control/restart-process'; import { Logger } from './logger'; -/** Logger options */ export type ConcurrentlyOptions = BaseConcurrentlyOptions & { - /** Which command(s) should have their output hidden. */ + // Logger options + /** + * Which command(s) should have their output hidden. + */ hide?: CommandIdentifier | CommandIdentifier[]; /** @@ -29,10 +31,14 @@ export type ConcurrentlyOptions = BaseConcurrentlyOptions & { */ prefix?: string; - /** How many characters should a prefix have at most, used when the prefix format is `command`. */ + /** + * How many characters should a prefix have at most, used when the prefix format is `command`. + */ prefixLength?: number; - /** Whether output should be formatted to include prefixes and whether "event" logs will be logged. */ + /** + * Whether output should be formatted to include prefixes and whether "event" logs will be logged. + */ raw?: boolean; /** diff --git a/src/logger.ts b/src/logger.ts index 100c30e1..bc3f7d6d 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -32,7 +32,9 @@ export class Logger { raw = false, timestampFormat, }: { - /** Which command(s) should have their output hidden. */ + /** + * Which command(s) should have their output hidden. + */ hide?: CommandIdentifier | CommandIdentifier[]; /** @@ -47,7 +49,9 @@ export class Logger { */ prefixFormat?: string; - /** How many characters should a prefix have at most, used when the prefix format is `command`. */ + /** + * How many characters should a prefix have at most, used when the prefix format is `command`. + */ prefixLength?: number; /**