@hyperfrontend/features/nx/generatorsgenerators
Nx generators for hyperfrontend features — init declares the SDK dependency in the consumer workspace, feature scaffolds a feature by delegating to the SDK's headless hf init.
import { featureGenerator, initGenerator } from '@hyperfrontend/features/nx/generators'
const installCallback = await initGenerator(tree, {})
Generators
| Generator | Purpose |
|---|---|
init | Ensures @hyperfrontend/features is declared in the root package.json; run automatically by nx add. |
feature | Scaffolds the glue module, feature.config.json, and entry wiring for a feature, declaring the SDK dependency when missing. |
Both generators stage every write into the Nx tree, so nx g ... --dry-run
previews the full change set without touching the disk. When the consumer
workspace has @nx/devkit installed, staged files are formatted with it and
installs run through its installPackagesTask; otherwise built-in equivalents
take over. Each generator returns a callback Nx runs after flushing, which
installs dependencies only when the root manifest actually changed.
Usage
nx g @hyperfrontend/features:init
nx g @hyperfrontend/features:feature \
--name=clock --contract=./clock.contract.json --entry=./src/main.ts --directory=apps/clock
API Reference
ƒ Functions
Scaffold a hyperfrontend feature by delegating to the SDK's
First ensures
hf init. First ensures
@hyperfrontend/features is declared in the workspace root package.json (an existing declaration is left untouched), then forwards options to runInit in headless mode with the SDK's tree seams backed by the Nx tree — every scaffolding write stages into Nx's virtual tree, so nx g ... --dry-run previews the full change set without touching the disk. When the consumer workspace has @nx/devkit installed, staged files are formatted with it before Nx flushes them. The returned callback — run by Nx only after flushing real changes — installs dependencies only when the manifest was changed by this run.Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The Nx virtual file-system tree every write is staged into. |
§options | FeatureGeneratorSchema | Generator options forwarded to the SDK runner. |
Returns
Promise<GeneratorCallback>The post-flush callback that installs when the manifest changed.
Example
Scaffold a feature in a project directory
nx generate \@hyperfrontend/features:feature \
--name=clock --contract=./clock.contract.json --entry=./src/main.ts --directory=apps/clockEnsure the SDK package is declared in the consumer workspace's root
A declaration in any dependency section satisfies the check and is left in its section untouched, so repeat runs are no-ops. When the package is undeclared it is added to
All writes go through the tree, so
package.json; the nx add flow runs this generator after installing the package. A declaration in any dependency section satisfies the check and is left in its section untouched, so repeat runs are no-ops. When the package is undeclared it is added to
dependencies — the SDK is a runtime dependency — pinned to a caret range on the running plugin's own version. Passing keepExistingVersions: false instead re-pins an existing declaration in its own section. When the consumer workspace has @nx/devkit installed, staged files are formatted with it before Nx flushes them. All writes go through the tree, so
--dry-run previews the manifest change without touching the disk. The returned callback — which Nx runs only after flushing real changes — installs dependencies only when the manifest actually changed (via the consumer's installPackagesTask when resolvable, else the built-in installer) and then verifies rollup's native platform binding, printing the exact fix when it is missing.Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The Nx virtual file-system tree for the consumer workspace. |
§options | InitGeneratorSchema | Generator options; see InitGeneratorSchema. |
Returns
Promise<GeneratorCallback>The post-flush callback that installs and runs the binding advisory.
Example
Initialize a workspace after installing the package
nx g @hyperfrontend/features:init◈ Interfaces
Options for the
feature generator; mirrors schema.json.Properties
Options for the
init generator; mirrors schema.json.Properties
§
keepExistingVersions?:booleanKeep an existing declaration's range untouched instead of pinning it to the running plugin's version. Defaults to
true.