Installer
Install compiled registry components into a consumer codebase.
Connectors
- HTTP:
HttpRegistryConnector(baseUrl), fetch resource via HTTP. - File System:
LocalRegistryConnector(dir), reads resource from file system.
Installer
It accepts a config object, it is recommended to implement your own config system, then pass the config to installer.
import { ComponentInstaller } from "fuma-cli/registry/installer";
import { HttpRegistryConnector } from "fuma-cli/registry/connector";
const installer = new ComponentInstaller(
new HttpRegistryConnector("https://registry.example.com"),
{
// options
},
);
const { deps } = await installer.install("button");
// or with sub registry:
const { deps } = await installer.install("button", "my-sub-registry");
const dm = await deps();
if (dm.hasRequired()) await dm.installRequired(); // runs detected package managerinstall() returns an object for futher actions, such as install require dependencies.
framework
Fuma CLI generates code based on consumer's framework (e.g. next or tanstack-start).
Instead of detecting automatically, you can specify it:
import { ComponentInstaller } from "fuma-cli/registry/installer";
const installer = new ComponentInstaller(connector, {
// 'none' = framework-agnostic
framework: "none",
});io
Customise the IO interface, useful for integrating with your own TUI.
import { ComponentInstaller } from "fuma-cli/registry/installer";
const installer = new ComponentInstaller(connector, {
io: {
onWarn(message) {
console.warn(message);
},
confirmFileOverride() {
return true;
},
onFileDownloaded() {},
},
});