diff --git a/Cargo.toml b/Cargo.toml index 1fa0149..2e3a8cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Miguel Ramos "] edition = "2021" name = "websublime_workspace-tools" -version = "0.7.4" +version = "0.7.5" exclude = ["tests/*", "examples/*", "node_modules/*", "target/*"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,7 +17,7 @@ napi = { version = "2.16.8", default-features = false, features = [ "serde-json", "tokio_rt", ] } -workspace-node-tools = { version = "1.0.8", features = ["napi", "napi-derive"] } +workspace-node-tools = { version = "1.0.9", features = ["napi", "napi-derive"] } [build-dependencies] napi-build = "2" diff --git a/README.md b/README.md index 82af458..4579a9b 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ This package offer a set of functions to retrieve information about the monorepo | `change_exist(branch_name: string, cwd?: string): boolean` | Check if change already exist. | | `get_change(branch_name: string, cwd?: string): Array` | Get the list of changes for the branch. | | `get_changes(cwd?: string): Changes` | Get all changes. | +| `changes_file_exist(cwd?: string): boolean` | Check if `.changes.json` file exist | ## Develop requirements diff --git a/index.d.ts b/index.d.ts index d4c3084..d81b838 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,7 +15,7 @@ */ export declare function addChange(change: Change, cwd?: string | undefined | null): boolean -export enum Bump { +export const enum Bump { Major = 'Major', Minor = 'Minor', Patch = 'Patch', @@ -71,6 +71,20 @@ export interface ChangesFileData { changes: ChangesData } +/** + * Changes file exist + * + * # Examples + * + * ``` + * const { changesFileExist } = require('workspace-node-tools'); + * const exist = changesFileExist(process.cwd()); + * ``` + * + * @param cwd - The root path to start searching from + */ +export declare function changesFileExist(cwd?: string | undefined | null): boolean + export interface ChangesOptions { message?: string } @@ -546,7 +560,7 @@ export interface PackageInfo { changedFiles: Array } -export enum PackageManager { +export const enum PackageManager { Npm = 'Npm', Yarn = 'Yarn', Pnpm = 'Pnpm', diff --git a/index.js b/index.js index 8f0a6e6..8e942dd 100644 --- a/index.js +++ b/index.js @@ -364,6 +364,7 @@ if (!nativeBinding) { module.exports.addChange = nativeBinding.addChange module.exports.Bump = nativeBinding.Bump module.exports.changeExist = nativeBinding.changeExist +module.exports.changesFileExist = nativeBinding.changesFileExist module.exports.detectPackageManager = nativeBinding.detectPackageManager module.exports.getAllFilesChangedSinceBranch = nativeBinding.getAllFilesChangedSinceBranch module.exports.getBumps = nativeBinding.getBumps diff --git a/src/lib.rs b/src/lib.rs index 2c9a2ee..15172df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,8 @@ 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, get_changes, init_changes, remove_change, Change, Changes, - ChangesFileData, ChangesOptions, + add_change, change_exist, changes_file_exist, get_change, get_changes, init_changes, + remove_change, Change, Changes, ChangesFileData, ChangesOptions, }; use workspace_node_tools::conventional::{ get_conventional_for_package, ConventionalPackage, ConventionalPackageOptions, @@ -530,3 +530,18 @@ pub fn js_get_change(branch_name: String, cwd: Option) -> Vec { pub fn js_get_changes(cwd: Option) -> Changes { get_changes(cwd) } + +/// Changes file exist +/// +/// # Examples +/// +/// ``` +/// const { changesFileExist } = require('workspace-node-tools'); +/// const exist = changesFileExist(process.cwd()); +/// ``` +/// +/// @param cwd - The root path to start searching from +#[napi(js_name = "changesFileExist")] +pub fn js_changes_file_exist(cwd: Option) -> bool { + changes_file_exist(cwd) +}