# @gasket/plugin-command

> Plugin to enable other plugins to inject new gasket commands

Latest version **7.6.7** (published 2026-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gasket/plugin-command
pnpm add @gasket/plugin-command
yarn add @gasket/plugin-command
bun add @gasket/plugin-command
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.6.7 |
| Published | 2026-08-28 |
| First published | 2019-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 3 |
| Unpacked size | 38.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 145 |
| Author | GoDaddy Operating Company, LLC |
| Maintainers | kinetifex, 3rdeden, kawikabader, mmason2, jpina1-godaddy, bbetts, ecarlson-godaddy, rxmarbles |
| Keywords | command, gasket, plugin |

## Links

- npm: https://www.npmjs.com/package/@gasket/plugin-command
- Repository: https://github.com/godaddy/gasket
- Homepage: https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-command
- Issues: https://github.com/godaddy/gasket/issues
- npm.io page: https://npm.io/package/@gasket/plugin-command

## Dependencies (3)

- [commander](https://npm.io/package/commander.md) ^12.1.0
- [@gasket/core](https://npm.io/package/@gasket/core.md) ^7.7.6
- [@gasket/utils](https://npm.io/package/@gasket/utils.md) ^7.6.7

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 7.6.7 (latest) — 2026-08-28
- 0.0.0-react19-20260205182644 (react19) — 2026-02-05
- 0.0.0-canary-20260205165418 (canary) — 2026-02-05
- 8.0.0-next.1 (next) — 2026-01-28
- 6.47.5 (lts) — 2024-09-26
- 6.46.2-esm.15 (esm) — 2024-02-27
- 7.6.6 — 2026-05-13
- 7.6.5 — 2026-02-23
- 7.6.4 — 2026-02-16
- 7.6.3 — 2026-01-07
- 7.6.2 — 2025-12-19
- 7.6.1 — 2025-11-20
- 7.6.0 — 2025-11-12
- 0.0.0-canary-20251110223653 — 2025-11-10
- 0.0.0-canary-20251028184342 — 2025-10-28
- … 188 more at https://npm.io/package/@gasket/plugin-command/versions

## README

# @gasket/plugin-command

This plugin enables other plugins to define and inject custom commands into the
Gasket CLI. It executes the `commands` lifecycle during the `configure` hook,
allowing you to extend the functionality of the Gasket CLI with custom commands.
The plugin utilizes [Commander.js] for command management.

## Installation

```bash
npm i @gasket/plugin-command
```

Update your Gasket configuration to include the plugin:

```diff
import { makeGasket } from '@gasket/core';
+ import pluginCommand from '@gasket/plugin-command';

export default makeGasket({
  plugins: [
    // other plugins
+    pluginCommand
  ]
});
```

---

## Lifecycles

### commands

The `commands` lifecycle is executed during the `configure` hook if the `gasket`
CLI command is present in the `argv`. You can define commands that include
arguments, options, and custom parsing logic. The hook can return either a
single command definition object or an array of command definitions.

#### Examples Basic Command

Define a command with a description and an action:

```js
export default {
  name: 'example-plugin',
  hooks: {
    commands(gasket) {
      return {
        id: 'example-cmd',
        description: 'Example command',
        action: async () => {
          console.log('Hello from example command!');
        }
      };
    }
  }
};
```

Execute the command:

```bash
node ./gasket.js example-cmd
# Output: Hello from example command!
```

---

#### Example Command with Arguments

Add arguments to your command using the `args` array:

```js
export default {
  name: 'example-plugin',
  hooks: {
    commands(gasket) {
      return {
        id: 'example-cmd',
        description: 'Example command with arguments',
        args: [
          {
            name: 'message',
            description: 'Message to display',
            required: true
          }
        ],
        action: async (message) => {
          console.log('Message:', message);
        }
      };
    }
  }
};
```

Run with arguments:

```bash
node ./gasket.js example-cmd "Hello, World!"
# Output: Message: Hello, World!
```

#### Example Command with Options

```js
export default {
  name: 'example-plugin',
  hooks: {
    commands(gasket) {
      return {
        id: 'example-cmd',
        description: 'Example command with options',
        options: [
          {
            name: 'message',
            description: 'Message to display',
            required: true,
            short: 'm',
            type: 'string'
          }
        ],
        action: async ({ message }) => {
          console.log('Message:', message);
        }
      };
    }
  }
};
```

Run with options:

```bash
node ./gasket.js example-cmd --message "Hello, World!"
# Output: Message: Hello, World!
```

#### Example Command with Parsing

Use a custom `parse` function to transform option values:

```js
export default {
  name: 'example-plugin',
  hooks: {
    commands(gasket) {
      return {
        id: 'example-cmd',
        description: 'Example command with parsing',
        options: [
          {
            name: 'list',
            description: 'Comma-separated list of items',
            required: true,
            type: 'string',
            parse: (value) => value.split(',')
          }
        ],
        action: async ({ list }) => {
          console.log('Parsed List:', list);
        }
      };
    }
  }
};
```

Run with parsing:

```bash
node ./gasket.js example-cmd --list "apple,banana,orange"
# Output: Parsed List: [ 'apple', 'banana', 'orange' ]
```

#### Example with JSDoc Types

For type safety, use the `CommandsHook` type:

```js
export default {
  name: 'example-plugin',
  hooks: {
    /** @type {import('@gasket/plugin-command').CommandsHook} */
    commands(gasket) {
      return {
        id: 'example-cmd',
        description: 'Example command',
        args: [
          {
            name: 'message',
            description: 'Message to display',
            required: true
          }
        ],
        action: async (message) => {
          console.log('Message:', message);
        }
      };
    }
  }
};
```

### build

The `build` lifecycle allows plugins to hook into the application's build
process. This lifecycle is triggered by the `build` command in the Gasket CLI.

#### Example

Define a plugin that hooks into the `build` lifecycle:

```js
export default {
  name: 'example-plugin',
  hooks: {
    async build(gasket) {
      console.log('Running custom build logic...');
    }
  }
};
```

Run the `build` command:

```bash
node ./gasket.js build
# Output:
# Running custom build logic...
```

### Command-based Configuration

The commands property in the `gasket.js` file allows you to define configurations that are specific to individual commands. This means that when a particular command is executed, the corresponding configuration values will be applied, ensuring that each command can have its own tailored settings. This helps in managing command-specific behaviors and settings efficiently within your Gasket application.

#### Example

Define a command-based configuration in the `gasket.js` file:

```js
// gasket.js
import { makeGasket } from '@gasket/core';

export default makeGasket({
  message: 'Default message',
  commands: {
    'example-cmd': {
      message: 'Hello, World!' // when the `example-cmd` command is executed, this message will be displayed
    }
  }
});
```

<!-- Links -->
[Commander.js]: https://github.com/tj/commander.js?tab=readme-ov-file#commanderjs

---
_Source: https://npm.io/package/@gasket/plugin-command · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
