diff --git a/Cargo.toml b/Cargo.toml index f79cfff..3ed52ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Miguel Ramos "] edition = "2021" name = "websublime_workspace-tools" -version = "0.1.0" +version = "0.2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -12,7 +12,7 @@ crate-type = ["cdylib"] [dependencies] napi-derive = "2.16.8" napi = { version = "2.16.7", default-features = false, features = ["napi9", "serde-json", "tokio_rt"] } -workspace-node-tools = "0.5.0" +workspace-node-tools = "0.6.0" [build-dependencies] napi-build = "2" diff --git a/src/lib.rs b/src/lib.rs index 2ceb69a..d437bd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![deny(clippy::all)] -use workspace_node_tools::git::commands::Git; +use workspace_node_tools::git::commands::{Commit, Git, PublishTagInfo, RemoteTags}; +use workspace_node_tools::git::conventional::{ConventionalPackage, ConventionalPackageOptions}; use workspace_node_tools::monorepo::packages::{Monorepo, PackageInfo}; #[macro_use] @@ -30,3 +31,101 @@ pub fn git_fetch_all(cwd: Option) -> bool { pub fn git_fetch_all_tags(cwd: Option) -> bool { Git::fetch_all_tags(cwd).is_ok() } + +#[napi(js_name = "setCommit")] +pub fn commit( + message: String, + body: Option, + footer: Option, + cwd: Option, +) -> bool { + Git::git_commit(message, body, footer, cwd).is_ok() +} + +#[napi(js_name = "setTag")] +pub fn tag(tag: String, message: Option, cwd: Option) -> bool { + Git::git_tag(tag, message, cwd).is_ok() +} + +#[napi(js_name = "gitPush")] +pub fn push(cwd: Option) -> bool { + Git::git_push(cwd).is_ok() +} + +#[napi(js_name = "getCurrentSha")] +pub fn current_sha(cwd: Option) -> String { + Git::git_current_sha(cwd) +} + +#[napi(js_name = "isWorkdirUnclean")] +pub fn workdir_unclean(cwd: Option) -> bool { + Git::git_workdir_unclean(cwd) +} + +#[napi(js_name = "getDivergedCommit")] +pub fn diverged_commit(refer: String, cwd: Option) -> Option { + Git::get_diverged_commit(refer, cwd) +} + +#[napi(js_name = "getCommitsSince")] +pub fn commits_since( + cwd: Option, + since: Option, + relative: Option, +) -> Vec { + Git::get_commits_since(cwd, since, relative) +} + +#[napi(js_name = "getAllFilesChangedSinceSha")] +pub fn all_files_changed_since_sha(sha: String, cwd: Option) -> Vec { + Git::git_all_files_changed_since_sha(sha, cwd) +} + +#[napi(js_name = "getAllFilesChangedSinceTagInfos")] +pub fn all_files_changed_since_tag_infos( + package_info: Vec, + tag_info: Vec, + cwd: Option, +) -> Vec { + Git::get_all_files_changed_since_tag_infos(package_info, tag_info, cwd) +} + +#[napi(js_name = "getAllFilesChangedSinceBranch")] +pub fn all_files_changed_since_branch( + package_info: Vec, + branch: String, + cwd: Option, +) -> Vec { + Git::get_all_files_changed_since_branch(package_info, branch, cwd) +} + +#[napi(js_name = "getRemoteOrLocalTags")] +pub fn remote_tags(cwd: Option, local: Option) -> Vec { + Git::get_remote_or_local_tags(cwd, local) +} + +#[napi(js_name = "getLastKnownPublishTagInfoForPackage")] +pub fn last_known_publish_tag_info_for_package( + package_info: PackageInfo, + cwd: Option, +) -> Option { + Git::get_last_known_publish_tag_info_for_package(package_info, cwd) +} + +#[napi(js_name = "getLastKnownPublishTagInfoForAllPackages")] +pub fn last_known_publish_tag_info_for_all_packages( + package_info: Vec, + cwd: Option, +) -> Vec> { + Git::get_last_known_publish_tag_info_for_all_packages(package_info, cwd) +} + +#[napi(js_name = "getConventionalForPackage")] +pub fn conventional_for_package( + package_info: PackageInfo, + no_fetch_all: Option, + cwd: Option, + conventional_options: Option, +) -> ConventionalPackage { + Git::get_conventional_for_package(package_info, no_fetch_all, cwd, conventional_options) +}