@hyperfrontend/features/nx/generators/feature

feature

Nx feature generator. Scaffolds a hyperfrontend feature by delegating to the SDK's headless hf init (config resolution, contract loading, entry wiring), staging every write into the Nx tree so --dry-run previews without touching the disk. It first ensures @hyperfrontend/features is declared in the root package.json and returns a callback that installs — via the workspace's @nx/devkit when present, a built-in installer otherwise — only when that declaration was added. Registered via the package's generators.json.

Usage

nx generate @hyperfrontend/features:feature \
  --name=clock --contract=./clock.contract.json --entry=./src/main.ts --directory=apps/clock
OptionRequiredDescription
nameyesFeature name.
contractyesPath to the contract file, relative to the target directory.
entryyesEntry file the generated glue import is wired into.
directorynoDirectory to scaffold into, relative to the workspace root.
versionnoFeature version string.
urlnoURL the generated shell loads the feature from.

API Reference

ƒ Functions

§function

featureGenerator(tree: Tree, options: FeatureGeneratorSchema): Promise<GeneratorCallback>

Scaffold a hyperfrontend feature by delegating to the SDK's 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

NameTypeDescription
§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/clock
§function

featureGenerator(tree: Tree, options: FeatureGeneratorSchema): Promise<GeneratorCallback>

Scaffold a hyperfrontend feature by delegating to the SDK's 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

NameTypeDescription
§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/clock

Interfaces

§interface

FeatureGeneratorSchema

Options for the feature generator; mirrors schema.json.

Properties

§contract:string
Path to the feature contract file, relative to the target directory.
§directory?:string
Directory to scaffold into, relative to the workspace root. Defaults to the root.
§entry:string
Entry file the generated glue import is wired into.
§name:string
Feature name.
§url?:string
URL the generated shell loads the feature from.
§version?:string
Feature version string.