Skip to content

Commit

Permalink
feat: changes implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ramos committed Jul 19, 2024
1 parent 0d44677 commit becd234
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Miguel Ramos <miguel.ramos@websublime.dev>"]
edition = "2021"
name = "websublime_workspace-tools"
version = "0.7.3"
version = "0.7.4"
exclude = ["tests/*", "examples/*", "node_modules/*", "target/*"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -12,8 +12,12 @@ crate-type = ["cdylib"]

[dependencies]
napi-derive = "2.16.9"
napi = { version = "2.16.8", default-features = false, features = ["napi9", "serde-json", "tokio_rt"] }
workspace-node-tools = { version = "1.0.6", features = ["napi", "napi-derive"] }
napi = { version = "2.16.8", default-features = false, features = [
"napi9",
"serde-json",
"tokio_rt",
] }
workspace-node-tools = { version = "1.0.7", features = ["napi", "napi-derive"] }

[build-dependencies]
napi-build = "2"
Expand Down
90 changes: 90 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
use std::path::{Path, PathBuf};

use workspace_node_tools::bumps::{get_bumps, BumpOptions, BumpPackage};
use workspace_node_tools::changes::{
add_change, change_exist, get_change, init_changes, remove_change, Change, ChangesFileData,
ChangesOptions,
};
use workspace_node_tools::conventional::{
get_conventional_for_package, ConventionalPackage, ConventionalPackageOptions,
};
Expand Down Expand Up @@ -429,3 +433,89 @@ pub fn js_get_conventional_for_package(
pub fn js_get_bumps(options: BumpOptions) -> Vec<BumpPackage> {
get_bumps(options)
}

/// Init changes
///
/// # Examples
///
/// ```
/// const { initChanges } = require('workspace-node-tools');
/// const changes = initChanges(process.cwd(), ChangesOptions{});
/// ```
///
/// @param cwd - The root path to start searching from
#[napi(js_name = "initChanges")]
pub fn js_init_changes(
cwd: Option<String>,
change_options: Option<ChangesOptions>,
) -> ChangesFileData {
init_changes(cwd, &change_options)
}

/// Add change
///
/// # Examples
///
/// ```
/// const { addChange } = require('workspace-node-tools');
/// addChange(Change{}, process.cwd());
/// ```
///
/// @param change - The change to add
/// @param cwd - The root path to start searching from
#[napi(js_name = "addChange")]
pub fn js_add_change(change: Change, cwd: Option<String>) -> bool {
add_change(&change, cwd)
}

/// Remove change
///
/// # Examples
///
/// ```
/// const { removeChange } = require('workspace-node-tools');
/// removeChange("branch-name", process.cwd());
/// ```
///
/// @param branch_name - The branch name to remove
/// @param cwd - The root path to start searching from
#[napi(js_name = "removeChange")]
pub fn js_remove_change(branch_name: String, cwd: Option<String>) -> bool {
remove_change(branch_name, cwd)
}

/// Change exist
///
/// # Examples
///
/// ```
/// const { changeExist } = require('workspace-node-tools');
/// const exist = changeExist("branch-name", process.cwd());
/// ```
///
/// @param branch_name - The branch name to check
/// @param cwd - The root path to start searching from
#[napi(js_name = "changeExist")]
pub fn js_change_exist(branch_name: String, cwd: Option<String>) -> bool {
change_exist(branch_name, cwd)
}

/// Get change
///
/// # Examples
///
/// ```
/// const { getChange } = require('workspace-node-tools');
/// const changes = getChange("branch-name", process.cwd());
/// ```
///
/// @param branch_name - The branch name to get
/// @param cwd - The root path to start searching from
#[napi(js_name = "getChange")]
pub fn js_get_change(branch_name: String, cwd: Option<String>) -> Vec<Change> {
get_change(branch_name, cwd)
}

/*pub fn js_get_changes(cwd: Option<String>) -> ChangesData {
get_changes(cwd)
}*/

0 comments on commit becd234

Please sign in to comment.