@morphql/cli

中文文档
0.1.47发布于 2026/11/02MITES Module构建来源已验证

CLI tool for morphql - transform structural data from the command line.

原始使用文档
文档目录9 节
  1. Key Features
  2. Installation
  3. Basic Usage
  4. Single File (Default)
  5. Batch Processing
  6. Watch Mode
  7. Options Summary
  8. Learn More
  9. License

MorphQL

npm version License: MIT

@morphql/cli

The command-line interface for MorphQL. Transform structural data (JSON, XML, CSV, etc.) directly from your terminal using declarative queries.

Key Features

  • 🏎️ Fast Execution: Compiles queries to optimized native JavaScript functions.
  • 📂 Batch Processing: Transform entire directories of files in one command.
  • 👁️ Watch Mode: Real-time directory monitoring and automatic transformation.
  • 📊 Structured Logging: Human-readable text or machine-parsable json output.
  • 🧩 Lightweight: Minimal dependencies, leveraging Node.js native modules where possible.

Installation

npm install -g @morphql/cli

Basic Usage

Single File (Default)

# Inline transformation
echo '{"name":"Alice"}' | morphql -q "from json to xml"

# File-to-file
morphql --from data.json --to output.xml -q "from json to xml"

Batch Processing

morphql batch \
  -q "from xml to json transform set status = 'processed'" \
  --in ./inbox \
  --out ./outbox \
  --pattern "*.xml"

Watch Mode

morphql watch \
  -q "from csv to json" \
  --in ./incoming \
  --out ./processed \
  --delete

Options Summary

FeatureExampleDescription
Patterm--pattern "*.json"Filter which files to process.
Archive--done-dir ./doneMove files here after success.
Error--error-dir ./errMove files here on failure.
Cleanup--deleteRemove source files after successful processing.
Logging--log-format jsonOutput JSONL for automated monitoring.
PID File--pid-file morph.pidWrite process PID for service management.

Learn More

License

MIT

版本与发布记录

@morphql/cli 共发布 44 个版本,首次发布于 2026/01/25;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.47latest2026/11/021 天前
0.1.462026/07/283 个月前
0.1.452026/05/275 个月前
0.1.442026/05/275 个月前
0.1.432026/05/215 个月前
0.1.422026/05/195 个月前

关于 @morphql/cli 的常见问题

@morphql/cli 是什么?

用于从命令行转换结构数据的CLI工具。

如何安装 @morphql/cli?

在项目目录运行 npm install @morphql/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 morphql,可以用 npx morphql 直接运行。

@morphql/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/morphql__cli 是否存在。

@morphql/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@morphql/cli 可以商用吗?

@morphql/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@morphql/cli 还在维护吗?

最新版本 0.1.47 发布于 2026/11/02(1 天前);至今共发布 44 个版本,其中过去 12 个月发布了 44 个;首次发布于 2026/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。