@hyperfrontend/versioning/workspace/modelsmodels
Workspace data models: projects, workspace config, and project-level query helpers.
Project is the per-package shape (name, version, path, dependencies, declared changelog) carried throughout the workspace operations; createProject is the factory. Workspace, WorkspaceConfig, and WorkspaceType describe the workspace as a whole. The project-level predicates (isPublishable, isPrivate, hasChangelog, hasInternalDependencies, hasInternalDependents) and accessors (getDependencyCount) cover the common questions consumers ask of a Project without reaching into its raw fields.
API Reference
ƒ Functions
Parameters
Returns
ProjectExample
Add an internal dependent to a project
import { discoverProject, addDependent } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/utils')
if (project) {
const updated = addDependent(project, '@myorg/new-app')
console.log('Dependents now:', updated.internalDependents)
}Parameters
| Name | Type | Description |
|---|---|---|
§options | CreateProjectOptions | Project properties |
Returns
ProjectExample
Create a new Project object
import { createProject, readPackageJson } from '@hyperfrontend/versioning'
const packageJson = readPackageJson('./libs/my-lib/package.json')
const project = createProject({
name: '@myorg/my-lib',
version: '1.0.0',
path: './libs/my-lib',
packageJsonPath: './libs/my-lib/package.json',
packageJson,
changelogPath: './libs/my-lib/CHANGELOG.md',
})createWorkspace(options: { config: WorkspaceConfig; dependencyGraph: ReadonlyMap<string, unknown>; projects: ReadonlyMap<string, Project>; reverseDependencyGraph: ReadonlyMap<string, unknown>; root: string; type: WorkspaceType }): Workspace
Parameters
| Name | Type | Description |
|---|---|---|
§options | { config: WorkspaceConfig; dependencyGraph: ReadonlyMap<string, unknown>; projects: ReadonlyMap<string, Project>; reverseDependencyGraph: ReadonlyMap<string, unknown>; root: string; type: WorkspaceType } | Workspace properties |
Returns
WorkspaceExample
Create a new workspace object
import { createWorkspace, createWorkspaceConfig, createProject } from '@hyperfrontend/versioning'
const projects = new Map([['@myorg/utils', createProject({ ... })]])
const workspace = createWorkspace({
root: '/path/to/workspace',
type: 'nx',
projects,
config: createWorkspaceConfig(),
dependencyGraph: new Map(),
reverseDependencyGraph: new Map(),
})Parameters
| Name | Type | Description |
|---|---|---|
§options? | Partial<WorkspaceConfig> | Partial configuration options |
Returns
WorkspaceConfigExample
Create a workspace configuration with defaults
import { createWorkspaceConfig } from '@hyperfrontend/versioning'
const config = createWorkspaceConfig({
patterns: ['packages/*', 'libs/*'],
exclude: ['node_modules', 'dist'],
})Parameters
Returns
booleanExample
Check if one project depends on another
import { discoverWorkspace, dependsOn } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
if (dependsOn(workspace, '@myorg/app', '@myorg/utils')) {
console.log('@myorg/app directly depends on @myorg/utils')
}Parameters
Returns
unknownExample
Get projects that the given project depends on
import { discoverWorkspace, getDependencies } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
const deps = getDependencies(workspace, '@myorg/app')
console.log(`@myorg/app depends on:`, deps)Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | Project instance to analyze |
Returns
numberExample
Get the dependency count for a project
import { discoverProject, getDependencyCount } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/my-lib')
if (project) {
console.log(`${project.name} depends on ${getDependencyCount(project)} internal packages`)
}Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | Project instance to analyze |
Returns
numberExample
Get the dependent count for a project
import { discoverProject, getDependentCount } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/utils')
if (project) {
console.log(`${project.name} is used by ${getDependentCount(project)} packages`)
}Parameters
Returns
unknownExample
Get projects that depend on a given project
import { discoverWorkspace, getDependents } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
const dependents = getDependents(workspace, '@myorg/utils')
console.log(`Packages depending on @myorg/utils:`, dependents)Parameters
Returns
ProjectExample
Get a project by name from the workspace
import { discoverWorkspace, getProject } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
const project = getProject(workspace, '@myorg/utils')
if (project) {
console.log(`Version: ${project.version}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§workspace | Workspace | Workspace to count projects in |
Returns
numberExample
Get the count of projects in the workspace
import { discoverWorkspace, getProjectCount } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
console.log(`Workspace contains ${getProjectCount(workspace)} projects`)Parameters
| Name | Type | Description |
|---|---|---|
§workspace | Workspace | Workspace to retrieve project names from |
Returns
unknownExample
Get all project names in the workspace
import { discoverWorkspace, getProjectNames } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
const names = getProjectNames(workspace)
console.log(`Found ${names.length} projects:`, names)Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | The project to check |
Returns
booleanExample
Check if a project has a changelog
import { discoverProject, hasChangelog } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/my-lib')
if (project && !hasChangelog(project)) {
console.log('Warning: No changelog found for', project.name)
}Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | The project to check |
Returns
booleanExample
Check if a project has internal dependencies
import { discoverProject, hasInternalDependencies } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/my-lib')
if (project && hasInternalDependencies(project)) {
console.log(`${project.name} depends on:`, project.internalDependencies)
}Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | The project to check |
Returns
booleanExample
Check if a project has internal dependents
import { discoverProject, hasInternalDependents } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/utils')
if (project && hasInternalDependents(project)) {
console.log(`${project.name} is used by:`, project.internalDependents)
}Parameters
Returns
booleanExample
Check if a project exists in the workspace
import { discoverWorkspace, hasProject } from '@hyperfrontend/versioning'
const workspace = discoverWorkspace()
if (hasProject(workspace, '@myorg/utils')) {
console.log('Package exists in workspace')
}Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | The project to check |
Returns
booleanExample
Check if a project is private
import { discoverProject, isPrivate } from '@hyperfrontend/versioning'
const project = discoverProject('./apps/internal-app')
if (project && isPrivate(project)) {
console.log('Skipping private package')
}Parameters
| Name | Type | Description |
|---|---|---|
§project | Project | The project to check |
Returns
booleanExample
Check if a project is publishable
import { discoverProject, isPublishable } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/my-lib')
if (project && isPublishable(project)) {
console.log(`${project.name} can be published to npm`)
}Parameters
Returns
ProjectExample
Create a project copy with updated dependents
import { discoverProject, withDependents } from '@hyperfrontend/versioning'
const project = discoverProject('./libs/utils')
if (project) {
const updated = withDependents(project, ['@myorg/app', '@myorg/web'])
console.log('Updated dependents:', updated.internalDependents)
}◈ Interfaces
Properties
Properties
◆ Types
type WorkspaceType = "nx" | "turbo" | "lerna" | "pnpm" | "npm" | "yarn" | "rush" | "unknown"