| Crates.io | sublime_node_tools |
| lib.rs | sublime_node_tools |
| version | 0.0.4 |
| created_at | 2025-12-03 12:43:56.916188+00 |
| updated_at | 2025-12-03 18:34:26.532618+00 |
| description | Node.js bindings for Sublime Workspace CLI Tools via napi-rs |
| homepage | |
| repository | https://github.com/websublime/workspace-tools |
| max_upload_size | |
| id | 1963951 |
| size | 381,265 |
Node.js bindings for Sublime Workspace CLI Tools via napi-rs.
This crate provides Node.js bindings via napi-rs for the workspace-tools CLI, exposing 23 execute functions as native JavaScript/TypeScript functions. It enables Node.js and TypeScript applications to use workspace-tools functionality programmatically without spawning CLI processes.
JsonResponse<T> with success/error handlingThis crate is used internally by the @websublime/workspace-tools npm package.
You don't need to install it directly.
npm install @websublime/workspace-tools
# or
pnpm add @websublime/workspace-tools
import { status, changesetAdd, bumpPreview } from '@websublime/workspace-tools';
// Get workspace status
const result = await status({ root: '.' });
if (result.success) {
console.log(result.data.packages);
} else {
console.error(`Error [${result.error.code}]: ${result.error.message}`);
}
// Add a changeset
const changesetResult = await changesetAdd({
root: '.',
packages: ['@scope/pkg1'],
bumpType: 'minor',
message: 'Add new feature'
});
// Preview version bumps
const previewResult = await bumpPreview({ root: '.', showDiff: true });
status(params): Get workspace statusinit(params): Initialize workspace configurationchangesetAdd(params): Create a new changesetchangesetUpdate(params): Update an existing changesetchangesetList(params): List pending changesetschangesetShow(params): Show changeset detailschangesetRemove(params): Remove a changesetchangesetHistory(params): Query changeset historychangesetCheck(params): Check if branch has a changesetbumpPreview(params): Preview version bumpsbumpApply(params): Apply version bumpsbumpSnapshot(params): Generate snapshot versionsconfigShow(params): Show configurationconfigValidate(params): Validate configurationupgradeCheck(params): Check for available upgradesupgradeApply(params): Apply upgradesbackupCreate(params): Create backupbackupRestore(params): Restore from backupbackupList(params): List backupsaudit(params): Run workspace auditchanges(params): Analyze changesclone(params): Clone repositoryexecute(params): Execute command across packagesAll functions return a JsonResponse<T> with the following structure:
interface JsonResponse<T> {
success: boolean;
data?: T; // Present when success is true
error?: string; // Present when success is false
}
Error codes follow Node.js conventions:
| Code | Description |
|---|---|
ECONFIG |
Configuration error |
EVALIDATION |
Validation error |
EEXEC |
Execution error |
EGIT |
Git error |
EPKG |
Package error |
ENOENT |
File/path not found |
EIO |
I/O error |
ENETWORK |
Network error |
EUSER |
User error |
ETIMEOUT |
Timeout error |
# Build the native module
pnpm build-binding
# Build for release
pnpm build-binding:release
# Run Rust tests
cargo test -p sublime_node_tools
# Run Node.js integration tests
pnpm test
┌─────────────────────────────────────────────────────────────────────┐
│ JavaScript/TypeScript │
│ │
│ const result = await status({ root: "/path/to/project" }); │
└────────────────────────────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ NAPI Layer (crates/node/) │
│ │
│ 1. Parameter validation │
│ 2. Conversion JS → Rust structs │
│ 3. Call execute_* functions from CLI │
│ 4. Return JsonResponse<T> │
└────────────────────────────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ CLI Layer (crates/cli/) │
│ │
│ execute_status(), execute_init(), execute_changeset_add(), ... │
└─────────────────────────────────────────────────────────────────────┘
MIT