Перейти к содержанию
Skillpedia
Код в целом8.1k · #12593

webiny-cli-extensions

Что он делает

Этот скилл помогает вашему ИИ создавать новые команды для командной утилиты Webiny. Он нужен разработчикам, которые хотят запускать свои скрипты через CLI проекта.

Когда использовать

  • ✓Когда вам нужна собственная команда для миграции данных или экспорта контента.
  • ✓Когда внутри Webiny CLI нужен генератор кода или помощник развертывания.
  • ✓Когда вам нужна команда проверки состояния, которая выводит понятный результат в терминал.

Ссылка на скилл

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/cli-extensions/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/cli-extensions/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Добавь команду Webiny CLI, которая экспортирует все записи блога в файл JSON.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Скилл объясняет класс команды с именем, описанием, типизированными параметрами и обработчиком. Обработчик выводит сообщения через вспомогательный модуль терминала, а команда регистрируется в файле конфигурации.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

CLI Extensions

TL;DR

Add custom commands to the Webiny CLI using the CliCommandFactory pattern. Define a class implementing CliCommandFactory.Interface<TParams>, specify command name, description, params, and handler, then export with CliCommandFactory.createImplementation(). Register in webiny.config.tsx via <Cli.Command>.

The CliCommandFactory Pattern

// extensions/MyCustomCommand.ts
import { Ui } from "webiny/cli";
import { CliCommandFactory } from "webiny/cli/command";

export interface IMyCustomCommandParams {
  name: string;
}

class MyCustomCommandImpl implements CliCommandFactory.Interface<IMyCustomCommandParams> {
  constructor(private ui: Ui.Interface) {}

  execute(): CliCommandFactory.CommandDefinition<IMyCustomCommandParams> {
    return {
      name: "my-custom-command",
      description: "This is my custom command",
      examples: ["$0 my-custom-command test1", "$0 my-custom-command test2"],
      params: [
        {
          name: "name",
          description: "Your name",
          type: "string"
        }
      ],
      handler: async params => {
        this.ui.info("Starting my custom command...");
        this.ui.emptyLine();
        this.ui.success(`Hello, ${params.name}! This is my custom command.`);
      }
    };
  }
}

export default CliCommandFactory.createImplementation({
  implementation: MyCustomCommandImpl,
  dependencies: [Ui]
});

Register in webiny.config.tsx (YOU MUST include the .ts file extension in the src prop — omitting it will cause a build failure):

<Cli.Command src={"/extensions/MyCustomCommand.ts"} />

Run it:

yarn webiny my-custom-command "World"

Command Definition Properties

Property Type Description
name string The command name used on the CLI (e.g., "my-custom-command")
description string Help text shown when listing commands
examples string[] Usage examples ($0 is replaced with the CLI binary name)
params ParamDefinition[] Positional parameters and options
handler (params: TParams) => Promise<void> The function that executes the command

Parameter Definition

Each param in the params array:

Property Type Description
name string Parameter name (matches the key in your TParams interface)
description string Help text for this parameter
type "string" | "number" | "boolean" Parameter value type

The Ui Service

Inject Ui for formatted terminal output:

import { Ui } from "webiny/cli";
Method Description
this.ui.info("message") Print an info message (blue)
this.ui.success("message") Print a success message (green)
this.ui.warning("message") Print a warning message (yellow)
this.ui.error("message") Print an error message (red)
this.ui.emptyLine() Print a blank line for spacing

Use Cases

  • Data migrations -- Scripts to migrate or seed CMS data
  • Code generators -- Generate boilerplate extension files
  • Deployment scripts -- Custom deployment workflows
  • Data exports -- Export CMS content to files
  • Health checks -- Verify infrastructure or API status

Quick Reference

Import:          import { CliCommandFactory } from "webiny/cli/command";
Ui import:       import { Ui } from "webiny/cli";
Interface:       CliCommandFactory.Interface<TParams>
Definition:      CliCommandFactory.CommandDefinition<TParams>
Export:          CliCommandFactory.createImplementation({ implementation, dependencies })
Registe
Частые вопросы

Как регистрируется команда?

Через настройку команд в файле конфигурации webiny.

Как задаются параметры?

Каждый параметр имеет имя, описание и тип.

Как команда выводит результат?

Через вспомогательный модуль терминала, который выводит информацию, сообщения об успехе и пустые строки.

Подробности

Оригинальное описание автора

Adding custom commands to the Webiny CLI using CliCommandFactory. Use this skill when the developer wants to create a custom CLI command, add a data migration script, build a code generator, create deployment scripts, export CMS content, or add health check commands. Covers CliCommandFactory.Interface, command definition, typed parameters, the Ui service for terminal output, and registration via <Cli.Command>.

repo: webiny/webiny-js

Популярность

Звёзды на GitHub
8.1k
Место в рейтинге
#12593
Лицензия
—
Обновлён
02.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы