mcfe-cli
v1.2.8
Published
CLI tool for interacting with MCE API
Downloads
25
Readme
MCFE CLI
The MCFE CLI (mcfe) is a command-line tool for managing MCFE projects, modules, versions, and file uploads via a REST API. It interacts with a backend service to perform operations like creating projects, listing modules, activating versions, and uploading files.
Table of Contents
Installation
Prerequisites
- Node.js: Version 14 or higher.
- npm: Included with Node.js.
Steps
- Clone the repository:
git clone <repository-url> cd mcfe-cli - Install dependencies:
npm install - Link the CLI globally (optional, for global access):
npm link
Usage
Run the CLI with:
npx mcfe-cli [command] [options]Global Options
--base-url <url>: Backend service URL (default:http://localhost:3000).--insecure: Skip SSL certificate verification (useful for development).--help: Display help for commands.--version: Show the CLI version (1.0.0).
Example:
npx mcfe-cli --insecure --base-url https://mcfe.node.local project listUpload Version:
npx mcfe-cli --insecure --base-url https://mcfe.node.local version push 7 "D:\Dinocollabs\mcfe-provider\layout-react-js\dist" --link-commit <url>Commands
Project Commands
Manage projects in the MCFE system.
Create a project:
npx mcfe-cli project create <name>Example:
npx mcfe-cli project create my-projectOutput:
{ "id": 1, "name": "my-project", "createdAt": "2025-05-16T09:17:00Z" }List projects:
npx mcfe-cli project list [--filter <json>]Example:
npx mcfe-cli project list --filter '{"status":"active"}'Output:
[ { "id": 1, "name": "my-project", "status": "active" } ]Get a project:
npx mcfe-cli project get <id>Example:
npx mcfe-cli project get 1Output:
{ "id": 1, "name": "my-project" }
Module Commands
Manage modules within projects.
Create a module:
npx mcfe-cli module create <projectId> <name>Example:
npx mcfe-cli module create 1 my-moduleOutput:
{ "id": 101, "projectId": 1, "name": "my-module" }List modules:
npx mcfe-cli module list <projectId>Example:
npx mcfe-cli module list 1Output:
[ { "id": 101, "name": "my-module" } ]
Version Commands
Manage versions of modules.
Create a version:
npx mcfe-cli version create <moduleId> <name>Example:
npx mcfe-cli version create 101 v1.0Output:
{ "id": 201, "moduleId": 101, "name": "v1.0" }Activate a version:
npx mcfe-cli version activate <versionId>Example:
npx mcfe-cli version activate 201Output:
{ "id": 201, "moduleId": 101, "name": "v1.0", "active": true }List versions:
npx mcfe-cli version list <moduleId>Example:
npx mcfe-cli version list 101Output:
[ { "id": 201, "name": "v1.0" } ]
File Commands
Upload files to the server.
- Upload a file:
Example:npx mcfe-cli file upload <filePath>
Output:npx mcfe-cli file upload ./test-file.zip
Notes:{ "id": "123", "filename": "test-file.zip", "url": "http://localhost:3000/uploads/test-file.zip", "uploadedAt": "2025-05-16T09:18:00Z" }- File size limit: 100MB.
- The file must exist at the specified path.
Configuration
Environment Variables
MCFE_BASE_URL: Override the default--base-url.MCFE_INSECURE: Set totrueto skip SSL verification (equivalent to--insecure).
Example:
export MCFE_BASE_URL=https://mcfe.node.local
mcfe project listDevelopment
Project Structure
index.ts: Main CLI entry point, defines commands usingcommander.api-client.ts:MceApiClientclass for API interactions.package.json: Defines dependencies and scripts.
Dependencies
commander: CLI framework.axios: HTTP client for API requests.form-data: Formultipart/form-datafile uploads.
Building
The project uses TypeScript. Compile it with:
npm run buildTesting
Add tests using a framework like jest. Example test setup:
npm install --save-dev jest ts-jest @types/jestRun tests:
npm testExtending the CLI
To add new commands:
- Update
index.tswith newcommandercommands. - Extend
MceApiClientwith corresponding API methods. - Align with the OpenAPI spec (
openapi.json).
Contributing
- Fork the repository.
- Create a feature branch (
git checkout -b feature/new-feature). - Commit changes (
git commit -m "Add new feature"). - Push to the branch (
git push origin feature/new-feature). - Open a pull request.
License
MIT License. See LICENSE for details.
Generated on May 16, 2025
