@jonloucks/variants-ts
v1.1.1
Published
Node.js Typescript Configuration Library, normalize how configuration is loaded from various sources is retrieved.
Maintainers
Readme
@jonloucks/variants-ts
Variants
TypeScript configuration library that normalizes how values are loaded from multiple sources.
Documentation
- Documentation
- License
- Contributing
- Code of conduct
- Coding standards
- Security policy
- Pull request template
- TypeDoc API
- Test coverage report
Installation
npm install @jonloucks/variants-tsUsage
import {
BOOTSTRAPPED,
VERSION,
createInstaller,
type Installer,
type InstallerConfig
} from '@jonloucks/variants-ts';import {
createEnvironment,
createProcessSource,
createRecordSource,
createVariant,
CONTRACTS
} from "@jonloucks/variants-ts/auxiliary/Convenience";const portVariant = createVariant<string>({
name: "server.port",
keys: ["PORT"],
fallback: "3000"
});const processSource = createProcessSource();
const recordSource = createRecordSource({ PORT: "8080" });const env = createEnvironment({
sources: [processSource, recordSource]
});
const port = env.getVariance(portVariant);Development
npm installnpm run buildnpm testnpm run test:watchnpm run test:coveragenpm run lintnpm run lint:fixnpm run docs- All tests must have suffix of -test.ts or -spec.ts
- Tests that validate supported APIs go in src/test
- Tests that validate internal implementation details go in src/impl
variants-ts
├── .github/
│ └── workflows/
│ ├── main-pull-request-matrix.yml
│ ├── main-pull-request-smoke.yml
│ ├── main-pull-request.yml
│ ├── main-push-smoke.yml
│ ├── main-push.yml
│ ├── main-release-smoke.yml
│ └── main-release.yml
├── CODE_OF_CONDUCT.md
├── CODING_STANDARDS.md
├── CONTRIBUTING.md
├── .editorconfig
├── eslint.config.mjs
├── LICENSE
├── package-lock.json
├── package.json
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── SECURITY.md
├── DOCUMENTATION.md
├── notes/
├── src/
│ ├── api/
│ ├── auxiliary/
│ ├── data/
│ ├── impl/
│ ├── test/
│ ├── index.ts
│ └── version.ts
├── tsconfig.json
└── typedoc.jsonGitHub Workflows
The CI workflow runs on every push and pull request to main branch. It:
- Tests against Node.js versions 16.x, 18.x, 20.x, 22.x, and 24.x
- Runs linting
- Builds the project
- Runs tests with coverage
- Uploads coverage to Codecov (optional)
The publish workflow creates an official release package.
- Publish is gated by
main-release-smokeand runs only when the smoke matrix completes successfully. - Publishing authentication is done using (OIDC trusted publishing)
To set up your own publishing:
- Publishing this project as is intentionally disabled
- You are welcome to fork this repository and publish where you want.
- Run
npm pkg delete privateto remove theprivateflag from the package. - Change the
namefield inpackage.jsonto your desired package name.
License
MIT
