Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nodevu is composed of a set of modules, each supporting Node.js 24 and later:
Installing needs npm 11.17 or newer, which ships with Node.js 24 and later. `.npmrc` skips packages published in the last 3 days and blocks git and URL dependencies. npm only runs the dependency install scripts that `allowScripts` in `package.json` approves, and `npm approve-scripts <pkg>` adds one pinned to its installed version.

- `npm test` and `npm run coverage` run every module's tests. The tests share the release data snapshot and its helpers through `fixtures/`, a private workspace that isn't published. `npm run test:update -w fixtures` refreshes the snapshot.
- `npm run lint` checks the whole repo with oxlint (warnings fail it too) and oxfmt, and checks with [docov](https://github.com/cutenode/docov) that everything the modules export has JSDoc. `docov.jsonc` sets what it scans. `npm run lint:harden` tests `tools/harden/` and runs [@lavamoat/harden](https://github.com/LavaMoat/LavaMoat/tree/main/packages/harden) to check that `.npmrc` and `package.json` keep every hardening setting, except the ones `tools/harden/decisions.json` turns off. `tools/oxlint/nodevu/` holds the repo's own oxlint rule, which stops code from reaching into another package's folder by relative path, and `npm run lint:rules` tests it. `npm run lint:pack` packs every module and checks the tarball with [publint](https://publint.dev) and [Are the Types Wrong?](https://arethetypeswrong.github.io). `npm run lint:workspaces` checks that every config naming the modules (tsconfig, CI, release, Dependabot, the docs sidebar) matches `workspaces` in `package.json`. `npm run lint:docs` runs the JavaScript examples in `docs/pages/` with [readme-assert](https://readme-assert.laat.dev) against the `@nodevu/fixtures` snapshots, and checks each `//=> value` comment. `npm run knip` runs [knip](https://knip.dev) to find unused files, exports and dependencies. `knip.jsonc` lists what it skips and why. `npm run lint` runs all of them.
- `npm run lint` checks the whole repo with oxlint (warnings fail it too) and oxfmt, and checks with [docov](https://github.com/cutenode/docov) that everything the modules export has JSDoc with a description, and that the JSDoc is well formed: a description on each tag, a `@param` for each parameter, and no unknown tags. `docov.jsonc` sets what it scans and which checks run, and `tsdoc.json` lists the JSDoc tags it knows past TSDoc's own. `npm run lint:harden` tests `tools/harden/` and runs [@lavamoat/harden](https://github.com/LavaMoat/LavaMoat/tree/main/packages/harden) to check that `.npmrc` and `package.json` keep every hardening setting, except the ones `tools/harden/decisions.json` turns off. `tools/oxlint/nodevu/` holds the repo's own oxlint rule, which stops code from reaching into another package's folder by relative path, and `npm run lint:rules` tests it. `npm run lint:pack` packs every module and checks the tarball with [publint](https://publint.dev) and [Are the Types Wrong?](https://arethetypeswrong.github.io). `npm run lint:workspaces` checks that every config naming the modules (tsconfig, CI, release, Dependabot, the docs sidebar) matches `workspaces` in `package.json`. `npm run lint:docs` runs the JavaScript examples in `docs/pages/` with [readme-assert](https://readme-assert.laat.dev) against the `@nodevu/fixtures` snapshots, and checks each `//=> value` comment. `npm run knip` runs [knip](https://knip.dev) to find unused files, exports and dependencies. `knip.jsonc` lists what it skips and why. `npm run lint` runs all of them.
- CI also checks spelling with [typos](https://github.com/crate-ci/typos) (`_typos.toml` lists words it shouldn't flag), relative links and anchors with [lychee](https://lychee.cli.rs), the workflows with [actionlint](https://github.com/rhysd/actionlint) and [zizmor](https://docs.zizmor.sh), and that a PR adds no runtime dependency with a known advisory or a licence outside the list in `ci.yml`. A weekly run tests every module on Linux, macOS and Windows, tries 50 times as many fast-check cases, and checks external links, and [OpenSSF Scorecard](https://scorecard.dev) rates the repo's supply-chain setup.
- `npm run types` type-checks the JSDoc, the tests and the scripts, and writes each module's TypeScript declarations to its `types/` folder. Commit them: CI fails when they're out of date.
- `npm run docs:dev` builds the docs from `docs/pages/` with [doc-kit](https://doc-kit.nodejs.org/) and serves them locally. `npm run docs` only builds them, into `out/`.
Expand Down
5 changes: 3 additions & 2 deletions core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ const scheduleFetcher = require('./util/prod/schedule');
* one object keyed by release line. Rejects when `now` isn't a date, or when
* the index has a version semver can't read.
*
* @param {Options} [options]
* @returns {Promise<Data>}
* @param {Options} [options] Where to fetch the data from, and the date to
* work out each release line's phase on.
* @returns {Promise<Data>} Every release line, keyed by name.
*/
async function core(options) {
// parse our user's options and set up our fetch/DateTime implementations
Expand Down
5 changes: 3 additions & 2 deletions core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ export type Data = Record<string, ReleaseLine>;
* one object keyed by release line. Rejects when `now` isn't a date, or when
* the index has a version semver can't read.
*
* @param {Options} [options]
* @returns {Promise<Data>}
* @param {Options} [options] Where to fetch the data from, and the date to
* work out each release line's phase on.
* @returns {Promise<Data>} Every release line, keyed by name.
*/
declare function core(options?: Options): Promise<Data>;
6 changes: 4 additions & 2 deletions core/types/util/prod/optionsParser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export type ParsedOptions = {
* @property {{ index: string, schedule: string }} urls
*/
/**
* @param {import('../../index').Options} [options]
* @returns {ParsedOptions}
* Fills in a default for each option the caller left out.
*
* @param {import('../../index').Options} [options] The caller's options.
* @returns {ParsedOptions} The options, each one set.
*/
declare function parseOptions(options?: import('../../index').Options): ParsedOptions;
5 changes: 4 additions & 1 deletion core/types/util/prod/schedule.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export type Schedule = Record<string, {
codename?: string;
}>;
/**
* Fetches the Node.js release schedule.
*
* @param {{ fetch: import('../../index').Fetch, urls: { schedule: string } }} options
* @returns {Promise<Schedule>}
* The `fetch` implementation to use, and the full URL of the schedule.
* @returns {Promise<Schedule>} The schedule, keyed by release line.
*/
declare function schedule(options: {
fetch: import('../../index').Fetch;
Expand Down
6 changes: 4 additions & 2 deletions core/util/prod/optionsParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const { DateTime } = require('luxon');
// this is particularly useful for tests so we can reduce variables
// and ensure that our test suite is able to be consistent.
/**
* @param {import('../../index').Options} [options]
* @returns {ParsedOptions}
* Fills in a default for each option the caller left out.
*
* @param {import('../../index').Options} [options] The caller's options.
* @returns {ParsedOptions} The options, each one set.
*/
function parseOptions(options) {
// set up our defaults
Expand Down
5 changes: 4 additions & 1 deletion core/util/prod/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
*/

/**
* Fetches the Node.js release schedule.
*
* @param {{ fetch: import('../../index').Fetch, urls: { schedule: string } }} options
* @returns {Promise<Schedule>}
* The `fetch` implementation to use, and the full URL of the schedule.
* @returns {Promise<Schedule>} The schedule, keyed by release line.
*/
async function schedule(options) {
// parse our options and set up fetch if a custom fetch is passed
Expand Down
6 changes: 5 additions & 1 deletion doc-kit.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const description =

// doc-kit deep-merges this with its defaults, so `global` can leave out what
// they fill in. its own types only describe the merged result
/** @satisfies {Omit<Partial<Configuration>, 'global'> & { global?: Partial<GlobalConfiguration> }} */
/**
* How doc-kit builds the docs site from docs/pages.
*
* @satisfies {Omit<Partial<Configuration>, 'global'> & { global?: Partial<GlobalConfiguration> }}
*/
export default {
target: ['html', 'orama-db', 'json', 'llms-txt', 'sitemap'],

Expand Down
24 changes: 23 additions & 1 deletion docov.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/cutenode/docov/v0.1.1/docov.schema.json",
"$schema": "https://raw.githubusercontent.com/cutenode/docov/v0.2.1/docov.schema.json",
"exclude": [
"**/test/**",
// generated from the JSDoc by `npm run types`, and TypeScript 7 leaves
Expand All @@ -9,4 +9,26 @@
"tools/oxlint/anti-slop/**",
],
"threshold": 100,
"requireDescription": true,
// defines the JSDoc tags nodevu uses, so tsdoc-tags only flags unknown ones
"tsdocConfig": "tsdoc.json",
"rules": {
"doc-markdown": "error",
"empty-tag-description": "error",
"informative-docs": "error",
"param-names": "error",
"require-param": "error",
"require-returns": "error",
"require-template": "error",
"require-yields": "error",
"summary-sentence": "error",
"tsdoc-code": "error",
"tsdoc-inline-tags": "error",
"tsdoc-tags": "error",
"valid-link": "error",
// tsdoc-escapes, tsdoc-html, tsdoc-links and tsdoc-params stay off: they
// hold blocks to TSDoc's grammar, which has no place for the JSDoc
// {type}s `npm run types` builds the types from. require-throws stays off
// while it counts a throw in an async function, which rejects instead
},
}
2 changes: 1 addition & 1 deletion fetchindex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Fetches the Node.js release index.
*
* @param {object} options
* @param {object} options The `fetch` implementation and the URL to use.
* @param {Fetch} options.fetch The `fetch` implementation to use.
* @param {{ index: string }} options.urls The full URL of the index.
* @returns {Promise<IndexRelease[]>} Every release, newest first.
Expand Down
2 changes: 1 addition & 1 deletion fetchindex/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type IndexRelease = {
/**
* Fetches the Node.js release index.
*
* @param {object} options
* @param {object} options The `fetch` implementation and the URL to use.
* @param {Fetch} options.fetch The `fetch` implementation to use.
* @param {{ index: string }} options.urls The full URL of the index.
* @returns {Promise<IndexRelease[]>} Every release, newest first.
Expand Down
5 changes: 2 additions & 3 deletions fixtures/beforeEachTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ const staticIndex = require('./data/index.json');
const staticSchedule = require('./data/schedule.json');

/**
* Mocks the network for a test: the default and `https://bnb.im` index.json
* and schedule.json URLs serve the snapshots, and any other request
* fails.
* Mocks the network for a test. The default and `https://bnb.im` index.json
* and schedule.json URLs serve the snapshots, and any other request fails.
*/
function beforeEachTemplate() {
// this fixes a bug in Node.js - it should be fixed _eventually_ and can be removed: https://github.com/nodejs/undici/issues/1248
Expand Down
17 changes: 10 additions & 7 deletions fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ const index = require('./data/index.json');
const schedule = require('./data/schedule.json');

/**
* Returns options for @nodevu/core (and the packages built on it) that serve
* `data` (the index.json and schedule.json snapshots by default) instead of
* fetching them, only including releases that were out by `now`, like the
* real index.json. Any other URL throws, so tests never touch the network.
* Returns options for `@nodevu/core`, and the packages built on it, that serve
* `data` instead of fetching it. Its index.json only has the releases that
* were out by `now`, like the real one. Any other URL throws, so tests never
* touch the network.
*
* `now` defaults to 2025-09-01, picked so that current, active LTS,
* maintenance LTS and end of life each have a release line, and each of those
* lines already has a security release, so no range or security field is
* empty.
*
* @param {string} [now]
* @param {{ index: { date: string }[], schedule: unknown }} [data]
* @returns {{ now: string, fetch: typeof fetch }}
* @param {string} [now] The date to serve the data as of, such as
* `'2025-09-01'`.
* @param {{ index: { date: string }[], schedule: unknown }} [data] The
* index.json and schedule.json to serve. Defaults to the snapshots.
* @returns {{ now: string, fetch: typeof fetch }} The `now` and `fetch`
* options.
*/
function at(now = '2025-09-01', data = { index, schedule }) {
return {
Expand Down
5 changes: 2 additions & 3 deletions fixtures/types/beforeEachTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export = beforeEachTemplate;
/**
* Mocks the network for a test: the default and `https://bnb.im` index.json
* and schedule.json URLs serve the snapshots, and any other request
* fails.
* Mocks the network for a test. The default and `https://bnb.im` index.json
* and schedule.json URLs serve the snapshots, and any other request fails.
*/
declare function beforeEachTemplate(): void;
17 changes: 10 additions & 7 deletions fixtures/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ declare const _exports: {
};
export = _exports;
/**
* Returns options for @nodevu/core (and the packages built on it) that serve
* `data` (the index.json and schedule.json snapshots by default) instead of
* fetching them, only including releases that were out by `now`, like the
* real index.json. Any other URL throws, so tests never touch the network.
* Returns options for `@nodevu/core`, and the packages built on it, that serve
* `data` instead of fetching it. Its index.json only has the releases that
* were out by `now`, like the real one. Any other URL throws, so tests never
* touch the network.
*
* `now` defaults to 2025-09-01, picked so that current, active LTS,
* maintenance LTS and end of life each have a release line, and each of those
* lines already has a security release, so no range or security field is
* empty.
*
* @param {string} [now]
* @param {{ index: { date: string }[], schedule: unknown }} [data]
* @returns {{ now: string, fetch: typeof fetch }}
* @param {string} [now] The date to serve the data as of, such as
* `'2025-09-01'`.
* @param {{ index: { date: string }[], schedule: unknown }} [data] The
* index.json and schedule.json to serve. Defaults to the snapshots.
* @returns {{ now: string, fetch: typeof fetch }} The `now` and `fetch`
* options.
*/
declare function at(now?: string, data?: {
index: {
Expand Down
4 changes: 2 additions & 2 deletions fixtures/util/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const { resolve } = require('node:path');
/**
* Writes `data` to `path` as tab-indented JSON.
*
* @param {string} path
* @param {unknown} data
* @param {string} path The file to write, relative to the working directory.
* @param {unknown} data The value to write, which `JSON.stringify` takes.
*/
async function write(path, data) {
const outputJSON = JSON.stringify(data, null, '\t');
Expand Down
6 changes: 4 additions & 2 deletions newest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ async function newest(name, type, options) {
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no LTS release.
*/
async function lts(name, options) {
return await newest(name, 'lts', options);
Expand All @@ -40,7 +41,8 @@ async function lts(name, options) {
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no security release.
*/
async function security(name, options) {
return await newest(name, 'security', options);
Expand Down
6 changes: 4 additions & 2 deletions newest/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ declare function newest(name: string, type: 'lts' | 'security', options?: import
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no LTS release.
*/
declare function lts(name: string, options?: import('@nodevu/core').Options): Promise<string | undefined>;
/**
* Finds the newest security release of a release line.
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no security release.
*/
declare function security(name: string, options?: import('@nodevu/core').Options): Promise<string | undefined>;
6 changes: 4 additions & 2 deletions oldest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ async function oldest(name, type, options) {
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no LTS release.
*/
async function lts(name, options) {
return await oldest(name, 'lts', options);
Expand All @@ -40,7 +41,8 @@ async function lts(name, options) {
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no security release.
*/
async function security(name, options) {
return await oldest(name, 'security', options);
Expand Down
6 changes: 4 additions & 2 deletions oldest/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ declare function oldest(name: string, type: 'lts' | 'security', options?: import
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no LTS release.
*/
declare function lts(name: string, options?: import('@nodevu/core').Options): Promise<string | undefined>;
/**
* Finds the oldest security release of a release line.
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no security release.
*/
declare function security(name: string, options?: import('@nodevu/core').Options): Promise<string | undefined>;
3 changes: 2 additions & 1 deletion opt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const { DateTime } = require('luxon');
* left out.
*
* @param {{ fetch?: Fetch, now?: string | DateTime, urls?: { index?: string, schedule?: string } }} [inputOptions]
* @returns {Options}
* The caller's options.
* @returns {Options} The options, each one set.
*/
function opt(inputOptions) {
// set up our defaults
Expand Down
3 changes: 2 additions & 1 deletion opt/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type Options = {
* left out.
*
* @param {{ fetch?: Fetch, now?: string | DateTime, urls?: { index?: string, schedule?: string } }} [inputOptions]
* @returns {Options}
* The caller's options.
* @returns {Options} The options, each one set.
*/
declare function opt(inputOptions?: {
fetch?: Fetch;
Expand Down
Loading
Loading