Nova Identity
Read your project's identity from one place — the nearest nova.config.json — instead of hand-copying the title, tagline, URLs, and copyright line into every config that needs them.
Summary
The NovaIdentity battery walks up from a working directory to the nearest nova.config.json, reads the identity it declares, and exposes it as typed projections plus the pure transforms used to derive them.
It gives configs, recipes, and generators a single definition of who the project is, so a change in nova.config.json flows everywhere without a manual sweep.
Why Use This Battery?
- One source of truth: edit
nova.config.jsonand every consumer that reads through the battery updates on the next build. - No drift: the copyright line, repository URL, and organization name are derived the same way everywhere.
- Fail loud, not wrong: a missing file, invalid JSON, or a wrongly-typed field throws a clear, path-specific error instead of shipping a bad value.
Capabilities
- Resolves the config by walking up the directory tree, so a nested workspace finds the project root without a hard-coded path.
- Treats every identity field as optional: an absent value comes back as
undefined(or an empty array) for the caller to coalesce with a fallback. - Projects identity into the exact shape a Docusaurus config consumes through
forDocs(), applying the copyright, repository, GitHub, and trailing-slash transforms. - Exposes those transforms as static methods, so a README or license generator composes the same copyright line the site footer shows.
Usage
Projections
forDocs() returns a flat object ready to spread into a Docusaurus config. Each field is optional, so pair it with a fallback using the ?? operator:
title,tagline, andprojectNamecome straight fromproject.nameandproject.description.urlis the homepage with any trailing slash removed.organizationNameis the GitHub owner, andgithubis the owner's profile URL.copyrightis the composed line, present only when bothproject.startingYearandproject.legalNameexist.editUrlandrepositoryare the normalized repository URL;npm,bugs,documentation,privacyPolicy, andtermsOfUsecome fromurls;fundingis the list of funding URLs.
Static Transforms
Every transform is pure and available without constructing an instance:
composeCopyright(startingYear, legalName)builds the full copyright line.copyrightYearRange(startingYear)returns a single year, or astart-currentrange, computing the current year at call time.normalizeRepoUrl(repositoryUrl)strips a leadinggit+and a trailing.git.githubUserUrl(owner)builds the canonical GitHub profile URL.stripTrailingSlash(url)removes a single trailing slash.
Troubleshooting
no "nova.config.json" found— The walk-up reached the filesystem root without finding a config. Run from inside a nova project, or pass a starting directory to the constructor.could not read or parse— The config exists but is unreadable or is not valid JSON. Check file permissions and JSON syntax.field "..." must be a string/must be a number— A field is present but has the wrong type. Fix the value innova.config.json; absent fields are allowed and simply come back asundefined.