1.0.2 • Published 10 months ago

@websublime/workspace-tools v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@websublime/workspace-tools

https://github.com/websublime/workspace-node-binding-tools/actions

Tools to use on github actions for bumping version, changelogs on a monorepo.

Install this package

pnpm add @websublime/workspace-tools

Usage

This package offer a set of functions to retrieve information about the monorepo and the packages that contain. It support all package managers including Bun (WIP).

API

FunctionDescription
getProjectRootPath(root?: string): string or undefinedGet the root path of the project.
getDefinedPackageManager(root?: string): string or undefinedGet the package manager defined in the project.
detectPackageManager(root: string): PackageManager or undefinedDetect the package manager defined in the project.
getPackages(cwd?: string): Array<PackageInfo>Get the list of packages in the monorepo.
getPackageInfo(package_name: string, cwd?: string): PackageInfoGet PackageInfo for a package.
getChangedPackages(sha?: string, cwd: string): Array<PackageInfo>Get the list of packages that have changed since the given sha ('main').
git_add(file: string, cwd?: string): booleanStage a file.
git_add_all(cwd?: string): booleanStage all files.
git_config(name: string, email: string, cwd?: string): booleanGit config user name and email.
gitFetchAll(cwd?: string, fetch_tags?: boolean): booleanExecute a fetch command to get the latest changes from the remote repository. You can also retrieve tags
gitCommit(message: string, body?: string, footer?: string cwd?: string): booleanCommit the changes.
gitTag(tag: string, message?: string, cwd?: string): booleanTag the repository with the given tag.
gitPush(cwd?: string, follow_tags?: boolean): booleanPush the changes to the remote repository, including optional tags.
gitCurrentBranch(cwd?: string): string or undefinedGet the current branch name.
gitCurrentSha(cwd?: string): stringGet's the current commit id.
gitPreviousSha(cwd?: string): string or undefinedGet's the previous commit id.
gitFirstSha(cwd?: string, branch?: string): string or undefinedGet's the first commit id in a branch. Compare is done between branch..Head, and it should be used as main..HEAD
isWorkdirUnclean(cwd?: string): booleanCheck if the workdir is unclean (uncommited changes).
gitCommitBranchName(sha: string, cwd?: string): string or undefinedGet the branch name for the commit id.
gitAllFilesChangedSinceSha(sha: string, cwd?: string): Array<String>Get all files changed sinc branch, commit id etc.
getDivergedCommit(sha: string, cwd?: string): string or undefinedGet the diverged commit from the given sha (main).
getCommitsSince(cwd?: string, since?: string, relative?: string): Array<Commit>Get the commits since the given sha (main) for a particular package.
getAllFilesChangedSinceBranch(package_info: Array<PackageInfo>, branch: string, cwd?: string): Array<String>Get all the files changed for a branch (main).
getLastKnownPublishTagInfoForPackage(package_info: PackageInfo, cwd?: string): Array<PublishTagInfo>Get the last known publish tag info for a particular package.
getLastKnownPublishTagInfoForAllPackages(package_info: Array<PackageInfo>, cwd?: string): Array<PublishTagInfo>Get the last known publish tag info for all packages.
getRemoteOrLocalTags(cwd?: string, local?: boolean): Array<RemoteTags>Get all the tags in the remote or local repository.
getConventionalForPackage(package_info: PackageInfo, no_fetch_all?: boolean cwd?: string, conventional_options?: ConventionalPackageOptions): ConventionalPackageGet the conventional commits for a particular package, changelog output and package info.
getBumps(options: BumpOptions): Array<BumpPackage>Output bumps version for packages and it's dependencies
initChanges(cwd?: string, change_options?: ChangesOptions): ChangesFileDataCreat changes file or retrieve is data if already exist
addChange(change: Change, cwd?: string): booleanAdds a new change to the change file
removeChange(branch_name: String, cwd?: string): booleanRemoves the change from the changes files.
changeExist(branch_name: string, packages_name: Array<string>, cwd?: string): booleanCheck if change already exist.
getChange(branch_name: string, cwd?: string): Array<Change>Get the list of changes for the branch.
getChanges(cwd?: string): ChangesGet all changes.
getPackageChange(package_name: string, branch: string, cwd?: string): ChangesGet a change by package name.
changesFileExist(cwd?: string): booleanCheck if .changes.json file exist

Develop requirements

  • Install the latest Rust
  • Install Node.js@16+ which fully supported Node-API
  • Run corepack enable

Test in local

  • pnpm
  • pnpm build
  • pnpm test

And you will see:

$ ava --verbose

  ✔ get defined package manager
  ─

  2 tests passed
✨  Done in 1.12s.

Release package

Ensure you have set your NPM_TOKEN in the GitHub project setting.

In Settings -> Secrets, add NPM_TOKEN into it.

When you want to release the package:

npm run build
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]

git push

GitHub actions will do the rest job for you.

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.7.13

11 months ago

0.7.12

11 months ago

0.7.14

10 months ago

0.7.11

12 months ago

0.7.10

12 months ago

0.7.9

12 months ago

0.7.8

12 months ago

0.7.7

12 months ago

0.7.6

1 year ago

0.7.5

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago