hyva-exec-shell-cmd

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Execute Shell Commands in Magento Environment

在Magento环境中执行Shell命令

This utility skill detects the Magento development environment and provides the appropriate command wrapper for executing shell commands.
本实用技能可检测Magento开发环境,并为执行Shell命令提供相应的命令包装器。

Usage

使用方法

Other skills should reference this skill when they need to execute commands in the Magento environment. The detected wrapper ensures commands run in the correct context (container or local).
当其他技能需要在Magento环境中执行命令时,应引用本技能。检测到的包装器可确保命令在正确的上下文(容器或本地)中运行。

Step 1: Detect Environment

步骤1:检测环境

Important: Execute this script from the Magento project root directory, or provide the path as an argument.
Run this detection once at the start of any skill that needs to execute shell commands:
bash
<skill_path>/scripts/detect_env.sh [magento_root_path]
Where
<skill_path>
is the directory containing this SKILL.md file (e.g.,
.claude/skills/hyva-exec-shell-cmd
).
The optional
magento_root_path
argument specifies the Magento installation directory. If omitted, the script uses the current working directory.
Output:
warden
,
docker-magento
,
ddev
, or
local
重要提示: 请从Magento项目根目录执行此脚本,或提供路径作为参数。
在任何需要执行Shell命令的技能启动时,运行一次此检测:
bash
<skill_path>/scripts/detect_env.sh [magento_root_path]
其中
<skill_path>
是包含本SKILL.md文件的目录(例如:
.claude/skills/hyva-exec-shell-cmd
)。
可选的
magento_root_path
参数用于指定Magento安装目录。如果省略,脚本将使用当前工作目录。
输出:
warden
docker-magento
ddev
local

Step 2: Apply Command Wrapper

步骤2:应用命令包装器

Based on detected environment, wrap commands as follows:
EnvironmentCommand WrapperDescription
Warden
warden env exec -T php-fpm bash -c "<command>"
Docker environment managed by Warden
docker-magento
bin/clinotty bash -c "<command>"
Mark Shust's docker-magento setup
DDEV
ddev exec <command>
DDEV containerized environment
LocalRun
<command>
directly
Native environment without containers
根据检测到的环境,按以下方式包装命令:
环境命令包装器说明
Warden
warden env exec -T php-fpm bash -c "<command>"
由Warden管理的Docker环境
docker-magento
bin/clinotty bash -c "<command>"
Mark Shust的docker-magento环境配置
DDEV
ddev exec <command>
DDEV容器化环境
Local直接运行
<command>
无容器的原生环境

Examples

示例

Single command

单个命令

bash
undefined
bash
undefined

Warden

Warden

warden env exec -T php-fpm bash -c "bin/magento cache:clean"
warden env exec -T php-fpm bash -c "bin/magento cache:clean"

docker-magento

docker-magento

bin/clinotty bash -c "bin/magento cache:clean"
bin/clinotty bash -c "bin/magento cache:clean"

DDEV

DDEV

ddev exec bin/magento cache:clean
ddev exec bin/magento cache:clean

Local

Local

bin/magento cache:clean
undefined
bin/magento cache:clean
undefined

Command with directory change

包含目录切换的命令

bash
undefined
bash
undefined

Warden

Warden

warden env exec -T php-fpm bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
warden env exec -T php-fpm bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

docker-magento

docker-magento

bin/clinotty bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
bin/clinotty bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

DDEV

DDEV

ddev exec bash -c "vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
ddev exec bash -c "vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

Local

Local

cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build
undefined
cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build
undefined

Commands That Do NOT Require Wrapping

无需包装的命令

Some commands run on the host system and should NOT be wrapped:
  • composer
    commands (runs on host, not in container)
  • git
    commands
  • File operations on the host filesystem (
    ls
    ,
    find
    ,
    cp
    for files accessible from host)
  • warden
    CLI commands
  • ddev
    CLI commands
部分命令在主机系统上运行,不应进行包装:
  • composer
    命令(在主机而非容器中运行)
  • git
    命令
  • 主机文件系统上的文件操作(如
    ls
    find
    cp
    ,针对主机可访问的文件)
  • warden
    CLI命令
  • ddev
    CLI命令

Integration Pattern

集成模式

Skills that need to execute commands should:
  1. Reference this skill: "Use the
    hyva-exec-shell-cmd
    skill to determine the command wrapper"
  2. Detect environment once using Step 1
  3. Store the wrapper pattern for use throughout the skill
  4. Apply the wrapper to all container commands per Step 2
<!-- Copyright © Hyvä Themes https://hyva.io. All rights reserved. Licensed under OSL 3.0 -->
需要执行命令的技能应遵循以下步骤:
  1. 引用本技能:“使用
    hyva-exec-shell-cmd
    技能确定命令包装器”
  2. 使用步骤1检测一次环境
  3. 存储包装器模式,以便在整个技能中使用
  4. 根据步骤2对所有容器命令应用包装器
<!-- Copyright © Hyvä Themes https://hyva.io. All rights reserved. Licensed under OSL 3.0 -->