Demo plugin showing how to create a Salesforce CLI plugin that integrates with the sfdx-hardis VS Code extension via the Plugin API.
This repository demonstrates how to build a community plugin for sfdx-hardis that:
- Uses
uxLogto send messages to both the terminal and VS Code extension UI - Uses
uxLogTableto display tabular data in both the terminal and VS Code extension UI - Uses
promptsto display interactive prompts in VS Code (with terminal fallback) - Uses
WebSocketClientto send progress indicators and report file notifications to VS Code - Uses
NotifProviderto post notifications to Slack, MS Teams, Email, or custom API channels
The WebSocket connection is automatically activated because this plugin lists sfdx-hardis in its dependencies.
Install both sfdx-hardis and this demo plugin:
sf plugins install sfdx-hardis
sf plugins install sf-plugin-hardis-demoRun the demo command showing full Plugin API integration.
# Interactive mode (prompts for action and items)
sf cloudity demo
# CI-friendly: pass --action to skip the action prompt
sf cloudity demo --action someOption
# Pass --items to skip the multi-select items prompt
sf cloudity demo --action someOption --items item1 --items item2
# Multiple items, another action
sf cloudity demo --action anotherOption --items item1 --items item3 --items item5Flags:
| Flag | Short | Description |
|---|---|---|
--action |
-a |
Action to perform: someOption or anotherOption (skips the interactive prompt) |
--items |
-i |
Items to process — repeatable (skips the interactive multi-select prompt) |
import { uxLog, uxLogTable, prompts, WebSocketClient, NotifProvider } from 'sfdx-hardis/plugin-api';
import type { PromptsQuestion, NotifMessage } from 'sfdx-hardis/plugin-api';
import c from 'chalk';
// Log to terminal + VS Code extension UI
uxLog('action', this, c.cyan('Starting...'));
uxLog('success', this, c.green('Done!'));
// Display tabular data in terminal + VS Code extension UI
uxLogTable(this, [{ name: 'Item1', status: 'OK' }], ['name', 'status']);
// Interactive prompt (VS Code UI or terminal fallback)
const response = await prompts({
type: 'select',
name: 'action',
message: 'What would you like to do?',
choices: [
{ title: 'Some option', value: 'someOption' },
{ title: 'Another option', value: 'anotherOption' },
],
});
// Progress tracking in VS Code
WebSocketClient.sendProgressStartMessage('Processing', items.length);
WebSocketClient.sendProgressStepMessage(i + 1, items.length);
WebSocketClient.sendProgressEndMessage(items.length);
// Send a report file or URL to the VS Code extension sidebar
WebSocketClient.sendReportFileMessage('/tmp/report.json', 'My Report', 'report');
WebSocketClient.sendReportFileMessage('https://example.com', 'Documentation', 'docUrl');
// Notifications to Slack, Teams, Email, etc.
await NotifProvider.postNotifications({
text: 'My plugin completed!',
type: 'DEPLOYMENT',
severity: 'success',
logElements: [],
data: {},
metrics: {},
});# Install dependencies
yarn install
# Build
yarn build
# Run tests
yarn test
# Run the command locally
./bin/dev.js cloudity demo --action someOption --items item1 --items item2