sublime_node_tools 0.0.4

Node.js bindings for Sublime Workspace CLI Tools via napi-rs
Documentation
//! Changeset command implementations for Node.js bindings.
//!
//! # What
//!
//! This module implements the changeset NAPI functions that manage the changeset
//! workflow. Changesets track intended changes before they are applied as version
//! bumps, enabling better release management and changelog generation.
//!
//! # How
//!
//! The module provides the following functions:
//!
//! - `changesetAdd`: Creates a new changeset for the current branch
//! - `changesetUpdate`: Updates an existing changeset with new packages or commits
//! - `changesetList`: Lists all pending changesets in the workspace
//! - `changesetShow`: Shows details of a specific changeset
//! - `changesetRemove`: Removes a changeset
//! - `changesetHistory`: Queries archived changeset history
//! - `changesetCheck`: Checks if the current branch has a changeset
//!
//! Each function:
//! 1. Validates the input parameters
//! 2. Calls the appropriate `execute_*` function from `sublime_cli_tools`
//! 3. Captures the JSON output
//! 4. Returns a `JsonResponse<T>` with the result
//!
//! # Why
//!
//! Changesets are the core of the version management workflow. They allow
//! developers to document their changes as they work, and then batch those
//! changes into coordinated version bumps and releases.
//!
//! # Examples
//!
//! ```typescript
//! import {
//!   changesetAdd,
//!   changesetUpdate,
//!   changesetList,
//!   changesetShow,
//!   changesetRemove,
//!   changesetHistory,
//!   changesetCheck
//! } from '@websublime/workspace-tools';
//!
//! // Add a new changeset
//! const addResult = await changesetAdd({
//!   root: '.',
//!   packages: ['@scope/core', '@scope/utils'],
//!   bumpType: 'minor',
//!   message: 'Add new feature'
//! });
//!
//! // Update an existing changeset
//! const updateResult = await changesetUpdate({
//!   root: '.',
//!   branch: 'feature/xyz',
//!   addCommits: true
//! });
//!
//! // List all pending changesets
//! const listResult = await changesetList({ root: '.' });
//! if (listResult.success) {
//!   for (const cs of listResult.data.changesets) {
//!     console.log(`${cs.branch}: ${cs.packages.join(', ')} (${cs.bump})`);
//!   }
//! }
//!
//! // Show a specific changeset
//! const showResult = await changesetShow({
//!   root: '.',
//!   branch: 'feature/xyz'
//! });
//!
//! // Check if current branch has a changeset
//! const checkResult = await changesetCheck({ root: '.' });
//! if (checkResult.success && !checkResult.data.hasChangeset) {
//!   console.log('No changeset found for current branch');
//! }
//!
//! // Query changeset history
//! const historyResult = await changesetHistory({
//!   root: '.',
//!   package: '@scope/core',
//!   limit: 10
//! });
//! ```

// TODO: will be implemented on story 4.2-4.8 - Changeset Commands
//
// Implementation outline for changesetAdd:
//
// #[napi]
// pub async fn changeset_add(params: ChangesetAddParams) -> JsonResponse<ChangesetAddData> {
//     // 1. Validate parameters
//     if let Err(e) = validate_root(&params.root) {
//         return JsonResponse::from_error_info(e);
//     }
//     if let Err(e) = validate_packages_not_empty(&params.packages) {
//         return JsonResponse::from_error_info(e);
//     }
//     if let Err(e) = validate_bump_type(&params.bump_type) {
//         return JsonResponse::from_error_info(e);
//     }
//     if let Err(e) = validate_message_not_empty(&params.message, "message") {
//         return JsonResponse::from_error_info(e);
//     }
//
//     // 2. Create ChangesetCreateArgs from params
//     // 3. Create Output with JSON format for capturing
//     // 4. Call execute_add from CLI (commands/changeset/add.rs)
//     // 5. Parse JSON response
//     // 6. Return JsonResponse::success(data) or JsonResponse::error(msg)
// }
//
// Implementation outline for changesetUpdate:
//
// #[napi]
// pub async fn changeset_update(params: ChangesetUpdateParams) -> JsonResponse<ChangesetUpdateData> {
//     // Similar pattern: validate, create args, execute, parse, return
// }
//
// Implementation outline for changesetList:
//
// #[napi]
// pub async fn changeset_list(params: ChangesetListParams) -> JsonResponse<ChangesetListData> {
//     // Similar pattern: validate root, execute_list, parse, return
// }
//
// Implementation outline for changesetShow:
//
// #[napi]
// pub async fn changeset_show(params: ChangesetShowParams) -> JsonResponse<ChangesetShowData> {
//     // Similar pattern: validate root and branch, execute_show, parse, return
// }
//
// Implementation outline for changesetRemove:
//
// #[napi]
// pub async fn changeset_remove(params: ChangesetRemoveParams) -> JsonResponse<ChangesetRemoveData> {
//     // Similar pattern: validate root and branch, execute_remove, parse, return
// }
//
// Implementation outline for changesetHistory:
//
// #[napi]
// pub async fn changeset_history(params: ChangesetHistoryParams) -> JsonResponse<ChangesetHistoryData> {
//     // Similar pattern: validate root, execute_history with filters, parse, return
// }
//
// Implementation outline for changesetCheck:
//
// #[napi]
// pub async fn changeset_check(params: ChangesetCheckParams) -> JsonResponse<ChangesetCheckData> {
//     // Similar pattern: validate root, execute_check, parse, return
// }