Repository navigation
Description
Problem
An organisation that wants the same header settings in every repository has to copy the whole options file into each one, and the copies drift. CLDMV's standard will be published as @cldmv/configs (repository CLDMV/configs) and should be the single source.
Proposal
A config file (--config <path> / configFile) may contain extends: a string or an array of strings, each one of:
- an https URL, fetched on every run. There is no local cache: a cached copy can go stale, and the point is that every repo uses the current shared config. A failed fetch or a non-2xx response fails the run with a clear error.
- an npm package path, e.g.
@cldmv/configs/fix-headers.json, resolved from the config file's own location the way Node resolves packages (createRequire). Packageexportsmust be honoured. - a relative or absolute file path, resolved from the config file's folder.
Merge rules: extended configs are applied in order, then the file's own settings on top, so the repository's file overrides what it extends. Plain objects merge key by key, while arrays and scalars replace. extends chains (a shared config extending another) work, a cycle is an error, and relative extends inside a fetched URL resolve against that URL. The CLI and the programmatic configFile option behave the same. Direct options passed on the CLI or in the API call still win over everything from files.
Tests
- A URL served by a local test HTTP server: success, 404, invalid JSON, and a chained relative reference.
- An npm package in a temp
node_modules, with and without anexportsmap. - Relative and absolute paths, and array order.
- Override precedence: file over extends, and CLI/API over file.
- A cycle error, and no caching: a second run sees the server's changed content.
Activity
release: v2.0.0 - re-cut the release notes as v2.0.0