diff --git a/Cargo.toml b/Cargo.toml index 5379d87..ca75434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Miguel Ramos "] edition = "2021" name = "websublime_workspace-tools" -version = "0.7.2" +version = "0.7.3" exclude = ["tests/*", "examples/*", "node_modules/*", "target/*"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,7 +13,7 @@ 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.4", features = ["napi", "napi-derive"] } +workspace-node-tools = { version = "1.0.6", features = ["napi", "napi-derive"] } [build-dependencies] napi-build = "2" diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index dddfda9..4a852a0 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -1,6 +1,9 @@ import test from 'ava'; -import { getDefinedPackageManager, PackageManager } from '../index'; +import { + getDefinedPackageManager, + PackageManager +} from '../index'; test('get defined package manager', (t) => { t.is(getDefinedPackageManager(), PackageManager.Pnpm); diff --git a/index.d.ts b/index.d.ts index 2f50e4c..ac46250 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ /* auto-generated by NAPI-RS */ /* eslint-disable */ -export const enum Bump { +export enum Bump { Major = 'Major', Minor = 'Minor', Patch = 'Patch', @@ -42,52 +42,361 @@ export interface ConventionalPackageOptions { title?: string } +/** + * Detect the package manager + * + * # Examples + * + * ``` + * const { detectPackageManager } = require('workspace-node-tools'); + * const packageManager = detectPackageManager(process.cwd()); + * ``` + * + * @param root - The root path to start searching from + */ export declare function detectPackageManager(root: string): PackageManager | null +/** + * Get all files changed since a branch + * + * # Examples + * + * ``` + * const { getAllFilesChangedSinceBranch } = require('workspace-node-tools'); + * const files = getAllFilesChangedSinceBranch([PackageInfo{}], "main", process.cwd()); + * ``` + * + * @param package_info - The list of package info + * @param branch - The branch to compare against + * @param cwd - The root path to start searching from + */ export declare function getAllFilesChangedSinceBranch(packageInfo: Array, branch: string, cwd?: string | undefined | null): Array +/** + * Get bumps + * + * # Examples + * + * ``` + * const { getBumps } = require('workspace-node-tools'); + * const bumps = getBumps(BumpOptions{}); + * ``` + * + * @param options - The bump options + */ export declare function getBumps(options: BumpOptions): Array +/** + * Get changed packages + * + * # Examples + * + * ``` + * const { getChangedPackages } = require('workspace-node-tools'); + * const changedPackages = getChangedPackages("main", process.cwd()); + * ``` + * + * @param sha - The commit sha to compare against (normally main branch) + * @param cwd - The root path to start searching from + */ export declare function getChangedPackages(sha?: string | undefined | null, cwd?: string | undefined | null): Array +/** + * Get commits since a commit id + * + * # Examples + * + * ``` + * const { getCommitsSince } = require('workspace-node-tools'); + * const commits = getCommitsSince(process.cwd(), "main", "packages/package-a"); + * ``` + * + * @param cwd - The root path to start searching from + * @param since - The commit id (accepts branch, tag) + * @param relative - The relative path to search from + */ export declare function getCommitsSince(cwd?: string | undefined | null, since?: string | undefined | null, relative?: string | undefined | null): Array +/** + * Get the conventional for a package + * + * # Examples + * + * ``` + * const { getConventionalForPackage } = require('workspace-node-tools'); + * const conventional = getConventionalForPackage(PackageInfo{}, false, process.cwd(), ConventionalPackageOptions{}); + * ``` + * + * @param package_info - The package info + * @param no_fetch_all - Do not fetch all commits + * @param cwd - The root path to start searching from + * @param conventional_options - The conventional options + */ export declare function getConventionalForPackage(packageInfo: PackageInfo, noFetchAll?: boolean | undefined | null, cwd?: string | undefined | null, conventionalOptions?: ConventionalPackageOptions | undefined | null): ConventionalPackage +/** + * Get the defined package manager + * + * # Examples + * + * ``` + * const { getDefinedPackageManager } = require('workspace-node-tools'); + * const packageManager = getDefinedPackageManager(process.cwd()); + * ``` + * + * @param root - The root path to start searching from + */ export declare function getDefinedPackageManager(root?: string | undefined | null): PackageManager | null +/** + * Get the diverged commit + * + * # Examples + * + * ``` + * const { getDivergedCommit } = require('workspace-node-tools'); + * const diverged = getDivergedCommit("main", process.cwd()); + * ``` + * + * @param refer - The branch to compare against + * @param cwd - The root path to start searching from + */ export declare function getDivergedCommit(refer: string, cwd?: string | undefined | null): string | null +/** + * Get the last known publish tag info for all packages + * + * # Examples + * + * ``` + * const { getLastKnownPublishTagInfoForAllPackages } = require('workspace-node-tools'); + * const tagInfo = getLastKnownPublishTagInfoForAllPackages([PackageInfo{}], process.cwd()); + * ``` + * + * @param package_info - The list of package info + * @param cwd - The root path to start searching from + */ export declare function getLastKnownPublishTagInfoForAllPackages(packageInfo: Array, cwd?: string | undefined | null): Array +/** + * Get the last known publish tag info for a package + * + * # Examples + * + * ``` + * const { getLastKnownPublishTagInfoForPackage } = require('workspace-node-tools'); + * const tagInfo = getLastKnownPublishTagInfoForPackage(PackageInfo{}, process.cwd()); + * ``` + * + * @param package_info - The package info + * @param cwd - The root path to start searching from + */ export declare function getLastKnownPublishTagInfoForPackage(packageInfo: PackageInfo, cwd?: string | undefined | null): PublishTagInfo | null +/** + * Get packages available in the monorepo + * + * # Examples + * + * ``` + * const { getPackages } = require('workspace-node-tools'); + * const packages = getPackages(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function getPackages(cwd?: string | undefined | null): Array +/** + * Get the project root path + * + * # Examples + * + * ``` + * const { getProjectRootPath } = require('workspace-node-tools'); + * const project_root = getProjectRootPath(process.cwd()); + * ``` + * + * @param root - The root path to start searching from + */ export declare function getProjectRootPath(root?: string | undefined | null): string | null +/** + * Get remote or local tags + * + * # Examples + * + * ``` + * const { getRemoteOrLocalTags } = require('workspace-node-tools'); + * const tags = getRemoteOrLocalTags(process.cwd(), true); + * ``` + * + * @param cwd - The root path to start searching from + * @param local - Fetch local tags + */ export declare function getRemoteOrLocalTags(cwd?: string | undefined | null, local?: boolean | undefined | null): Array +/** + * Get all files changed since a commit id + * + * # Examples + * + * ``` + * const { gitAllFilesChangedSinceSha } = require('workspace-node-tools'); + * const files = gitAllFilesChangedSinceSha("sha", process.cwd()); + * ``` + * + * @param sha - The commit id (accepts branch, tag) + * @param cwd - The root path to start searching from + */ export declare function gitAllFilesChangedSinceSha(sha: string, cwd?: string | undefined | null): Array +/** + * Commit changes to git + * + * # Examples + * + * ``` + * const { gitCommit } = require('workspace-node-tools'); + * gitCommit("feat: add new feature", "body", "footer", process.cwd()); + * ``` + * + * @param message - The commit message + * @param body - The commit body + * @param footer - The commit footer + * @param cwd - The root path to start searching from + */ export declare function gitCommit(message: string, body?: string | undefined | null, footer?: string | undefined | null, cwd?: string | undefined | null): boolean +/** + * Get the branch name from a commit id + * + * # Examples + * + * ``` + * const { gitCommitBranchName } = require('workspace-node-tools'); + * const branch = gitCommitBranchName("sha", process.cwd()); + * ``` + * + * @param sha - The commit id + * @param cwd - The root path to start searching from + */ export declare function gitCommitBranchName(sha: string, cwd?: string | undefined | null): string | null +/** + * Get the current branch + * + * # Examples + * + * ``` + * const { gitCurrentBranch } = require('workspace-node-tools'); + * const branch = gitCurrentBranch(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function gitCurrentBranch(cwd?: string | undefined | null): string | null +/** + * Get the current commit id + * + * # Examples + * + * ``` + * const { gitCurrentSha } = require('workspace-node-tools'); + * const sha = gitCurrentSha(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function gitCurrentSha(cwd?: string | undefined | null): string +/** + * Fetch all git changes + * + * # Examples + * + * ``` + * const { gitFetchAll } = require('workspace-node-tools'); + * gitFetchAll(process.cwd(), true); + * ``` + * + * @param cwd - The root path to start searching from + * @param fetch_tags - Fetch tags from remote + */ export declare function gitFetchAll(cwd?: string | undefined | null, fetchTags?: boolean | undefined | null): boolean +/** + * Get the first commit id + * + * # Examples + * + * ``` + * const { gitFirstSha } = require('workspace-node-tools'); + * const sha = gitFirstSha(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function gitFirstSha(cwd?: string | undefined | null, branch?: string | undefined | null): string | null +/** + * Get the previous commit id + * + * # Examples + * + * ``` + * const { gitPreviousSha } = require('workspace-node-tools'); + * const sha = gitPreviousSha(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function gitPreviousSha(cwd?: string | undefined | null): string | null +/** + * Push changes to git + * + * # Examples + * + * ``` + * const { gitPush } = require('workspace-node-tools'); + * gitPush(process.cwd(), true); + * ``` + * + * @param cwd - The root path to start searching from + * @param follow_tags - Follow tags + */ export declare function gitPush(cwd?: string | undefined | null, followTags?: boolean | undefined | null): boolean +/** + * Tag a git commit + * + * # Examples + * + * ``` + * const { gitTag } = require('workspace-node-tools'); + * gitTag("v1.0.0", "message", process.cwd()); + * ``` + * + * @param tag - The tag to apply + * @param message - The tag message + * @param cwd - The root path to start searching from + */ export declare function gitTag(tag: string, message?: string | undefined | null, cwd?: string | undefined | null): boolean +/** + * Check if the workdir is unclean + * + * # Examples + * + * ``` + * const { isWorkdirUnclean } = require('workspace-node-tools'); + * const unclean = isWorkdirUnclean(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ export declare function isWorkdirUnclean(cwd?: string | undefined | null): boolean export interface PackageInfo { @@ -104,7 +413,7 @@ export interface PackageInfo { changedFiles: Array } -export const enum PackageManager { +export enum PackageManager { Npm = 'Npm', Yarn = 'Yarn', Pnpm = 'Pnpm', diff --git a/package.json b/package.json index e18e753..8205a9a 100644 --- a/package.json +++ b/package.json @@ -110,5 +110,8 @@ "singleQuote": true, "arrowParens": "always" }, - "packageManager": "pnpm@9.4.0" + "packageManager": "pnpm@9.4.0", + "dependencies": { + "@types/node": "^20.14.11" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 723c97a..c4bd7cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,10 @@ settings: importers: .: + dependencies: + '@types/node': + specifier: ^20.14.11 + version: 20.14.11 devDependencies: '@emnapi/core': specifier: ^1.1.1 @@ -598,6 +602,9 @@ packages: '@tybys/wasm-util@0.9.0': resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==} + '@types/node@20.14.11': + resolution: {integrity: sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==} + '@vercel/nft@0.26.4': resolution: {integrity: sha512-j4jCOOXke2t8cHZCIxu1dzKLHLcFmYzC3yqAK6MfZznOL1QIJKd0xcFsXK3zcqzU7ScsE2zWkiMMNHGMHgp+FA==} engines: {node: '>=16'} @@ -1643,6 +1650,9 @@ packages: engines: {node: '>=14.17'} hasBin: true + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + unicorn-magic@0.1.0: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} @@ -2174,6 +2184,10 @@ snapshots: dependencies: tslib: 2.6.2 + '@types/node@20.14.11': + dependencies: + undici-types: 5.26.5 + '@vercel/nft@0.26.4': dependencies: '@mapbox/node-pre-gyp': 1.0.11 @@ -3174,6 +3188,8 @@ snapshots: typescript@5.4.5: {} + undici-types@5.26.5: {} + unicorn-magic@0.1.0: {} universal-user-agent@6.0.1: {} diff --git a/src/lib.rs b/src/lib.rs index 748bf58..ccbe4c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,16 @@ use workspace_node_tools::paths::get_project_root_path; #[macro_use] extern crate napi_derive; +/// Get the project root path +/// +/// # Examples +/// +/// ``` +/// const { getProjectRootPath } = require('workspace-node-tools'); +/// const project_root = getProjectRootPath(process.cwd()); +/// ``` +/// +/// @param root - The root path to start searching from #[napi(js_name = "getProjectRootPath")] pub fn js_project_root_path(root: Option) -> Option { match root { @@ -30,31 +40,96 @@ pub fn js_project_root_path(root: Option) -> Option { } } +/// Get the defined package manager +/// +/// # Examples +/// +/// ``` +/// const { getDefinedPackageManager } = require('workspace-node-tools'); +/// const packageManager = getDefinedPackageManager(process.cwd()); +/// ``` +/// +/// @param root - The root path to start searching from #[napi(js_name = "getDefinedPackageManager")] pub fn js_define_package_manager(root: Option) -> Option { get_monorepo_package_manager(root) } +/// Detect the package manager +/// +/// # Examples +/// +/// ``` +/// const { detectPackageManager } = require('workspace-node-tools'); +/// const packageManager = detectPackageManager(process.cwd()); +/// ``` +/// +/// @param root - The root path to start searching from #[napi(js_name = "detectPackageManager")] pub fn js_detect_package_manager(root: String) -> Option { detect_package_manager(&Path::new(&root)) } +/// Get packages available in the monorepo +/// +/// # Examples +/// +/// ``` +/// const { getPackages } = require('workspace-node-tools'); +/// const packages = getPackages(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "getPackages")] pub fn js_get_packages(cwd: Option) -> Vec { get_packages(cwd) } +/// Get changed packages +/// +/// # Examples +/// +/// ``` +/// const { getChangedPackages } = require('workspace-node-tools'); +/// const changedPackages = getChangedPackages("main", process.cwd()); +/// ``` +/// +/// @param sha - The commit sha to compare against (normally main branch) +/// @param cwd - The root path to start searching from #[napi(js_name = "getChangedPackages")] pub fn js_get_changed_packages(sha: Option, cwd: Option) -> Vec { get_changed_packages(sha, cwd) } +/// Fetch all git changes +/// +/// # Examples +/// +/// ``` +/// const { gitFetchAll } = require('workspace-node-tools'); +/// gitFetchAll(process.cwd(), true); +/// ``` +/// +/// @param cwd - The root path to start searching from +/// @param fetch_tags - Fetch tags from remote #[napi(js_name = "gitFetchAll")] pub fn js_git_fetch_all(cwd: Option, fetch_tags: Option) -> bool { git_fetch_all(cwd, fetch_tags).is_ok() } +/// Commit changes to git +/// +/// # Examples +/// +/// ``` +/// const { gitCommit } = require('workspace-node-tools'); +/// gitCommit("feat: add new feature", "body", "footer", process.cwd()); +/// ``` +/// +/// @param message - The commit message +/// @param body - The commit body +/// @param footer - The commit footer +/// @param cwd - The root path to start searching from #[napi(js_name = "gitCommit")] pub fn js_git_commit( message: String, @@ -65,56 +140,174 @@ pub fn js_git_commit( git_commit(message, body, footer, cwd).is_ok() } +/// Tag a git commit +/// +/// # Examples +/// +/// ``` +/// const { gitTag } = require('workspace-node-tools'); +/// gitTag("v1.0.0", "message", process.cwd()); +/// ``` +/// +/// @param tag - The tag to apply +/// @param message - The tag message +/// @param cwd - The root path to start searching from #[napi(js_name = "gitTag")] pub fn js_git_tag(tag: String, message: Option, cwd: Option) -> bool { git_tag(tag, message, cwd).is_ok() } +/// Push changes to git +/// +/// # Examples +/// +/// ``` +/// const { gitPush } = require('workspace-node-tools'); +/// gitPush(process.cwd(), true); +/// ``` +/// +/// @param cwd - The root path to start searching from +/// @param follow_tags - Follow tags #[napi(js_name = "gitPush")] pub fn js_git_push(cwd: Option, follow_tags: Option) -> bool { git_push(cwd, follow_tags).is_ok() } +/// Get the current branch +/// +/// # Examples +/// +/// ``` +/// const { gitCurrentBranch } = require('workspace-node-tools'); +/// const branch = gitCurrentBranch(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "gitCurrentBranch")] pub fn js_git_current_branch(cwd: Option) -> Option { git_current_branch(cwd) } +/// Get the current commit id +/// +/// # Examples +/// +/// ``` +/// const { gitCurrentSha } = require('workspace-node-tools'); +/// const sha = gitCurrentSha(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "gitCurrentSha")] pub fn js_git_current_sha(cwd: Option) -> String { git_current_sha(cwd) } +/// Get the previous commit id +/// +/// # Examples +/// +/// ``` +/// const { gitPreviousSha } = require('workspace-node-tools'); +/// const sha = gitPreviousSha(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "gitPreviousSha")] pub fn js_git_previous_sha(cwd: Option) -> Option { Some(git_previous_sha(cwd)) } +/// Get the first commit id +/// +/// # Examples +/// +/// ``` +/// const { gitFirstSha } = require('workspace-node-tools'); +/// const sha = gitFirstSha(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "gitFirstSha")] pub fn js_git_first_sha(cwd: Option, branch: Option) -> Option { Some(git_first_sha(cwd, branch)) } +/// Check if the workdir is unclean +/// +/// # Examples +/// +/// ``` +/// const { isWorkdirUnclean } = require('workspace-node-tools'); +/// const unclean = isWorkdirUnclean(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from #[napi(js_name = "isWorkdirUnclean")] pub fn js_git_workdir_unclean(cwd: Option) -> bool { git_workdir_unclean(cwd) } +/// Get the branch name from a commit id +/// +/// # Examples +/// +/// ``` +/// const { gitCommitBranchName } = require('workspace-node-tools'); +/// const branch = gitCommitBranchName("sha", process.cwd()); +/// ``` +/// +/// @param sha - The commit id +/// @param cwd - The root path to start searching from #[napi(js_name = "gitCommitBranchName")] pub fn js_git_branch_from_commit(sha: String, cwd: Option) -> Option { git_branch_from_commit(sha, cwd) } +/// Get all files changed since a commit id +/// +/// # Examples +/// +/// ``` +/// const { gitAllFilesChangedSinceSha } = require('workspace-node-tools'); +/// const files = gitAllFilesChangedSinceSha("sha", process.cwd()); +/// ``` +/// +/// @param sha - The commit id (accepts branch, tag) +/// @param cwd - The root path to start searching from #[napi(js_name = "gitAllFilesChangedSinceSha")] pub fn js_git_all_files_changed_since_sha(sha: String, cwd: Option) -> Vec { git_all_files_changed_since_sha(sha, cwd) } +/// Get the diverged commit +/// +/// # Examples +/// +/// ``` +/// const { getDivergedCommit } = require('workspace-node-tools'); +/// const diverged = getDivergedCommit("main", process.cwd()); +/// ``` +/// +/// @param refer - The branch to compare against +/// @param cwd - The root path to start searching from #[napi(js_name = "getDivergedCommit")] pub fn js_get_diverged_commit(refer: String, cwd: Option) -> Option { get_diverged_commit(refer, cwd) } +/// Get commits since a commit id +/// +/// # Examples +/// +/// ``` +/// const { getCommitsSince } = require('workspace-node-tools'); +/// const commits = getCommitsSince(process.cwd(), "main", "packages/package-a"); +/// ``` +/// +/// @param cwd - The root path to start searching from +/// @param since - The commit id (accepts branch, tag) +/// @param relative - The relative path to search from #[napi(js_name = "getCommitsSince")] pub fn js_get_commits_since( cwd: Option, @@ -124,6 +317,18 @@ pub fn js_get_commits_since( get_commits_since(cwd, since, relative) } +/// Get all files changed since a branch +/// +/// # Examples +/// +/// ``` +/// const { getAllFilesChangedSinceBranch } = require('workspace-node-tools'); +/// const files = getAllFilesChangedSinceBranch([PackageInfo{}], "main", process.cwd()); +/// ``` +/// +/// @param package_info - The list of package info +/// @param branch - The branch to compare against +/// @param cwd - The root path to start searching from #[napi(js_name = "getAllFilesChangedSinceBranch")] pub fn js_get_all_files_changed_since_branch( package_info: Vec, @@ -133,6 +338,17 @@ pub fn js_get_all_files_changed_since_branch( get_all_files_changed_since_branch(&package_info, &branch, cwd) } +/// Get the last known publish tag info for a package +/// +/// # Examples +/// +/// ``` +/// const { getLastKnownPublishTagInfoForPackage } = require('workspace-node-tools'); +/// const tagInfo = getLastKnownPublishTagInfoForPackage(PackageInfo{}, process.cwd()); +/// ``` +/// +/// @param package_info - The package info +/// @param cwd - The root path to start searching from #[napi(js_name = "getLastKnownPublishTagInfoForPackage")] pub fn js_get_last_known_publish_tag_info_for_package( package_info: PackageInfo, @@ -141,6 +357,17 @@ pub fn js_get_last_known_publish_tag_info_for_package( get_last_known_publish_tag_info_for_package(&package_info, cwd) } +/// Get the last known publish tag info for all packages +/// +/// # Examples +/// +/// ``` +/// const { getLastKnownPublishTagInfoForAllPackages } = require('workspace-node-tools'); +/// const tagInfo = getLastKnownPublishTagInfoForAllPackages([PackageInfo{}], process.cwd()); +/// ``` +/// +/// @param package_info - The list of package info +/// @param cwd - The root path to start searching from #[napi(js_name = "getLastKnownPublishTagInfoForAllPackages")] pub fn js_get_last_known_publish_tag_info_for_all_packages( package_info: Vec, @@ -149,11 +376,35 @@ pub fn js_get_last_known_publish_tag_info_for_all_packages( get_last_known_publish_tag_info_for_all_packages(&package_info, cwd) } +/// Get remote or local tags +/// +/// # Examples +/// +/// ``` +/// const { getRemoteOrLocalTags } = require('workspace-node-tools'); +/// const tags = getRemoteOrLocalTags(process.cwd(), true); +/// ``` +/// +/// @param cwd - The root path to start searching from +/// @param local - Fetch local tags #[napi(js_name = "getRemoteOrLocalTags")] pub fn js_get_remote_or_local_tags(cwd: Option, local: Option) -> Vec { get_remote_or_local_tags(cwd, local) } +/// Get the conventional for a package +/// +/// # Examples +/// +/// ``` +/// const { getConventionalForPackage } = require('workspace-node-tools'); +/// const conventional = getConventionalForPackage(PackageInfo{}, false, process.cwd(), ConventionalPackageOptions{}); +/// ``` +/// +/// @param package_info - The package info +/// @param no_fetch_all - Do not fetch all commits +/// @param cwd - The root path to start searching from +/// @param conventional_options - The conventional options #[napi(js_name = "getConventionalForPackage")] pub fn js_get_conventional_for_package( package_info: PackageInfo, @@ -164,6 +415,16 @@ pub fn js_get_conventional_for_package( get_conventional_for_package(&package_info, no_fetch_all, cwd, &conventional_options) } +/// Get bumps +/// +/// # Examples +/// +/// ``` +/// const { getBumps } = require('workspace-node-tools'); +/// const bumps = getBumps(BumpOptions{}); +/// ``` +/// +/// @param options - The bump options #[napi(js_name = "getBumps")] pub fn js_get_bumps(options: BumpOptions) -> Vec { get_bumps(options)