@zonekit/config-publisher
v0.2.0
Published
Config validation, building, diffing, and publishing for Zonekit external config repos
Maintainers
Readme
@zonekit/config-publisher
Library-level config build and release workflow for Zonekit.
Use @zonekit/config-publisher when you want to script the config lifecycle in code instead of shelling out to the CLI. It loads authored config from disk, validates it, builds artifacts, computes diffs, publishes outputs, negotiates schema versions, and promotes versions through a lock file.
If you mostly want terminal commands in CI or local workflows, use @zonekit/cli. This package is the lower-level library behind that flow.
Installation
pnpm add -D @zonekit/config-publisherQuick start
import {
buildConfig,
loadConfig,
publishConfig,
validateConfig,
} from "@zonekit/config-publisher";
const config = await loadConfig("./zonekit.config.yaml");
const validation = await validateConfig({ configPath: "./zonekit.config.yaml" });
if (!validation.valid) {
console.error(validation.errors);
process.exit(1);
}
const result = await buildConfig({ configPath: "./zonekit.config.yaml", outDir: "./dist" });
console.log("Built config hash:", result.hash);
const published = await publishConfig({
buildDir: "./dist",
outputDir: "./publish",
});
console.log("Published version:", published.versionFile.current);
void config;Recommended workflow
loadConfig()to parse authored YAML or JSON and expand flow globs.validateConfig()andvalidateContracts()before merge or publish.buildConfig()to create the exact artifact set you intend to ship.diffConfig()to compare versions and estimate consumer impact.publishConfig()to stage or upload artifacts.promoteConfig()to move a chosen version into the lock file.
Key exports
Loading and validation
loadConfig(configPath)parses a Zonekit config from YAML or JSON and resolvesflows.pattern.validateConfig(options)validates an authored config file against schema and semantic rules.validateContracts(options)checks the current config surface against*.contract.jsonfiles.
Building and diffing
buildConfig(options)builds versioned artifacts from the authored config.diffConfig(options)compares two config versions and returns structural changes plus optional app impact.
Publishing and promotion
publishConfig(options)copies build artifacts to an output directory and optionally uploads them through a CDN adapter.promoteConfig(options)updates a lock file to point at a chosen version hash after schema compatibility checks.negotiateSchemaVersion(options)negotiates a compatible schema version across consumers.
Errors
SchemaVersionMismatchErroris thrown when promotion would move the lock file to an incompatible schema version.
Common types
BuildConfigOptions/BuildResult-- Build input and outputDiffConfigOptions/DiffResult/StructuralChange/AppImpact-- Diff typesPublishConfigOptions/PublishResult-- Publish typesPromoteConfigOptions/PromoteResult-- Promote typesCdnUploadAdapter/UploadArtifact/UploadResult-- CDN adapter interfaceNegotiateSchemaVersionOptions/NegotiationResult-- Schema negotiation types
Notes
buildConfig()writes a hash directory plus top-levelconfig.json,config.d.ts, andversion.json.publishConfig()expects the output ofbuildConfig()as itsbuildDir.promoteConfig()readsmeta.jsonfrom the published artifacts directory, not from the raw source config.loadConfig()expandsflows.patternrelative to the config file location.
License
MIT
Read more:
