mext-cli
v1.0.0
Published
MEXT CLI for managing blocks and repositories
Maintainers
Readme
MEXT CLI
Command-line interface for managing MEXT blocks and repositories.
Installation
From Source (Development)
# Navigate to the CLI directory
cd cli
# Install dependencies
npm install
# Build the CLI
npm run build
# Link for global usage (optional)
npm linkGlobal Installation (Future)
npm install -g mext-cliPrerequisites
- Node.js 16+ installed
- Git installed and configured
- MEXT server running (default: http://localhost:3001)
- GitHub access for repository operations
Commands
mext-cli login
Authenticate with MEXT (currently a placeholder).
mext-cli loginmext-cli create <name>
Create a new block and clone its repository locally.
# Basic usage
mext-cli create "My Block"
# With options
mext-cli create "My Block" --description "My custom block description" --type customOptions:
-d, --description <description>: Block description-t, --type <type>: Block type (default: custom)
What it does:
- Creates a new block on the MEXT server
- Automatically creates a GitHub repository (if configured)
- Clones the repository to your local machine
- Provides next steps for development
mext-cli fork <blockId>
Fork an existing block and pull its content locally.
mext-cli fork 507f1f77bcf86cd799439011What it does:
- Creates a fork of the specified block on the MEXT server
- Creates a new GitHub repository for the fork
- Clones the forked repository to your local machine
mext-cli delete <blockId>
Delete a block from the MEXT server.
mext-cli delete 507f1f77bcf86cd799439011What it does:
- Shows block information for confirmation
- Prompts for confirmation
- Deletes the block from the server
- Note: GitHub repository needs to be deleted manually if desired
mext-cli sync
Manually sync the block registry and update named exports (automatically done after publish).
mext-cli syncWhat it does:
- Fetches the latest registry from the MEXT server
- Updates the mext-block package's named exports
- Shows available components and their metadata
- Regenerates TypeScript definitions for new components
When to use:
- After someone else publishes a block and you want to use it as a named component
- On a different computer than where the block was published
- To manually refresh the registry if components seem outdated
Note: This command is automatically executed after a successful mext-cli publish on the same machine, so you typically don't need to run it manually unless you're on a different computer or want to get components published by others.
mext-cli publish
Publish the current block after pushing changes to GitHub.
# In your block repository directory
mext-cli publishWhat it does:
- Checks if you're in a valid block repository
- Shows repository status and detects the block ID
- Checks for uncommitted changes
- Prompts you to push changes to GitHub
- Triggers the build and bundle process on the server
- Provides feedback on the build status
- Automatically syncs the registry to make your block available as a named component
Workflow
Creating a New Block
# 1. Create and clone the block
mext-cli create "My Amazing Block"
# 2. Navigate to the repository
cd block-<block-id>
# 3. Make your changes
# Edit files, add features, etc.
# 4. Commit your changes
git add .
git commit -m "Add amazing features"
# 5. Push to GitHub
git push origin main
# 6. Publish the block (automatically syncs registry)
mext-cli publishForking an Existing Block
# 1. Fork and clone the block
mext-cli fork 507f1f77bcf86cd799439011
# 2. Navigate to the repository
cd block-<new-block-id>
# 3. Make your modifications
# Customize the forked block
# 4. Follow steps 4-6 from "Creating a New Block"
# Note: publish automatically syncs the registryMulti-Developer Team Workflow
Developer A (Publishing a new block):
mext-cli create "Team Component"
cd block-<id>
# Make changes...
git add . && git commit -m "Add team component"
git push origin main
mext-cli publish # Automatically syncs registry locallyDeveloper B (Using the new block on different computer):
# First, sync to get the latest components
mext-cli sync
# Then use in your React app
import { TeamComponent } from 'mextblock';
<TeamComponent props={{ data: "value" }} />Configuration
The CLI uses the following default settings:
- Server URL: http://localhost:3001
- Timeout: 30 seconds for API requests
Troubleshooting
"Network Error: Could not reach MEXT server"
Make sure the MEXT server is running on the expected port (default: 3001).
"GitHub repository creation failed"
Check that the server has proper GitHub configuration:
GITHUB_TOKENenvironment variableGITHUB_USERNAMEenvironment variable
"Could not determine block ID from repository"
This happens when running mext-cli publish in a directory that's not a valid block repository. Make sure you're in a directory created by mext-cli create or mext-cli fork.
Permission Issues
If you get permission errors, you may need to:
- Set up GitHub SSH keys properly
- Ensure your GitHub token has the necessary permissions
- Check repository access rights
Development
Building
npm run buildDevelopment Mode
npm run devProject Structure
cli/
├── src/
│ ├── commands/ # Individual CLI commands
│ │ ├── login.ts
│ │ ├── create.ts
│ │ ├── fork.ts
│ │ ├── delete.ts
│ │ └── publish.ts
│ ├── utils/
│ │ ├── api.ts # API client for MEXT server
│ │ └── git.ts # Git operations utility
│ └── index.ts # Main CLI entry point
├── dist/ # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT
