@hyperfrontend/workspace/executors/version-batch

version-batch

Versions every library a change between two refs makes due a release, in dependency order, and records the bumps in one commit. It stands down on the base branch itself, so a pre-push hook can run it on every branch.

{
  "version:all": {
    "executor": "@hyperfrontend/workspace:version-batch",
    "options": { "base": "origin/main" }
  }
}
OptionWhat it does
--baseThe ref the change is measured from; defaults to origin/main. The batch fails when git cannot compare it with --head
--headThe ref it is measured to; defaults to the head of the checkout
--dryRunPrints the libraries and bumps and writes nothing
--releaseAsForces this bump on the libraries named with --libraries, for a change in the artifact rather than the code
--librariesThe projects to version instead of the affected set; only with --releaseAs
--maxCommitFallbackHow many commits the flow reads at most; defaults to what the project's version target declares
--scopeFilteringWhich commit scopes count for a project; defaults to the project's version target's
--verbosePrints each library's decision

The commit subject names every bumped library. A failed run restores the working tree to what it was.

API Reference§

ƒ Functions

§function

baseBranches(base: string, remotes: unknown): string[]

The branch names a base revision may be read as: the revision as written, without a refs/heads/ or refs/remotes/ prefix, and the branch behind a remote-tracking name such as origin/main for each remote the repository knows.
Parameters
NameTypeDescription
§base
stringThe base revision, as the batch was given it
§remotes
unknownThe names of the repository's remotes
Returns
string[]
The branch names, each once
Example

The branch behind a remote-tracking base

baseBranches('origin/main', ['origin']) // ['origin/main', 'main']
§function

versionBatchExecutor(options: VersionBatchExecutorOptions, context: ExecutorContext): Promise<ExecutorResult>

Versions every library a change makes due a release and records the bumps in one commit.
This executor:
  1. Detects affected libraries programmatically
  2. Runs versioning for each affected library
  3. Creates a single batch commit
It stands down on the base branch itself: the releases of that branch are made from the branches merged into it.
Parameters
NameTypeDescription
§options
VersionBatchExecutorOptionsExecutor options from schema
§context
ExecutorContextThe workspace, the project and the target the task runs on
Returns
Promise<ExecutorResult>
Executor result with success status
Examples

A root project's `version-batch` target

{
  "name": "workspace",
  "root": ".",
  "targets": {
    "version-batch": {
      "executor": "@hyperfrontend/workspace:version-batch",
      "options": { "base": "origin/main" }
    }
  }
}
```
`npx hf run workspace:version-batch` versions every library the change since `origin/main` makes due a release and commits the bumps as `chore: update versions for lib-core, lib-utils`; on `main` itself it stands down.

Forcing a bump the commits would not have made

npx hf run workspace:version-batch --releaseAs=patch --libraries=lib-core,lib-utils

◈ Interfaces

§interface

VersionBatchExecutorOptions

Options of the version-batch executor.
The executor detects affected libraries, versions each one, and creates a single batch commit.
Properties
§base?:stringBase git ref for affected detection.
§head?:stringHead git ref for affected detection.
§dryRun?:booleanPreview changes without making them.
§verbose?:booleanEnable verbose logging.
§scopeFiltering?:ScopeFilteringConfigCommit scope filtering applied when attributing commits to a project.
Defaults to whatever the version target declares, so the batch that writes versions attributes commits exactly as the single-project run and version-check do.
§maxCommitFallback?:numberUpper bound on the commit window the flow analyzes for bumps and changelogs.
§releaseAs?:"major" | "minor" | "patch"Force this bump on the libraries named by libraries, calculated from each one's published version, for a release whose change is in the package artifact rather than its code.
§libraries?:string[]Project names to version instead of the affected set. Required with releaseAs, and only meaningful with it.
§followUps?:unknownCalled after each bump and before the batch commit, each answering the files the commit must also carry. No configuration sets this; an executor that wraps this one passes it.
§interface

VersionBatchResult

Result of version-batch executor.
Properties
§success:booleanWhether the batch versioning operation succeeded
§bumpedLibraries:string[]Libraries that were actually bumped
§commitHash?:stringCommit hash if a batch commit was created
§error?:stringError message if operation failed