Node.js Collector
Analyze Node.js projects to collect package metadata, dependencies, test coverage, and CI/CD command tracking. Enforce Node.js-specific engineering standards.
nodejs to your lunar-config.yml:uses: github://earthly/lunar-lib/collectors/nodejs@v1.0.0
What This Integration Collects
This integration includes 4 collectors that gather metadata from your systems.
project
Analyzes Node.js project structure by detecting package.json, lockfiles, TypeScript configuration, ESLint, Prettier, monorepo setup, and engines.node. Writes project metadata to .lang.nodejs with build system info.
dependencies
Extracts direct and dev dependencies from package.json. Captures package names and version ranges for dependency tracking and policy enforcement.
cicd
Records every npm, yarn, or pnpm command executed in CI pipelines along with the Node.js version. Writes command strings and version info to .lang.nodejs.cicd for audit trails and build reproducibility analysis.
test-coverage
Extracts coverage percentage from existing test coverage output after tests complete. Parses coverage-summary.json to calculate total coverage and writes results to .lang.nodejs.tests.coverage and .testing.coverage.
How Collectors Fit into Lunar
Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.
Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.
Learn How Lunar Works →Example Collected Data
This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:
{
"lang": {
"nodejs": {
"version": "20.11.0",
"build_systems": ["npm"],
"package_json_exists": true,
"package_lock_exists": true,
"yarn_lock_exists": false,
"pnpm_lock_exists": false,
"tsconfig_exists": true,
"eslint_configured": true,
"prettier_configured": false,
"engines_node": ">=18",
"monorepo": { "type": "workspaces" },
"source": { "tool": "node", "integration": "code" },
"cicd": {
"cmds": [{ "cmd": "npm test", "version": "20.11.0" }],
"source": { "tool": "node", "integration": "ci" }
},
"tests": {
"coverage": {
"percentage": 85.5,
"source": { "tool": "jest", "integration": "ci" }
}
},
"dependencies": {
"direct": [
{ "path": "express", "version": "^4.18.2" }
],
"dev": [
{ "path": "jest", "version": "^29.7.0" }
],
"source": { "tool": "npm", "integration": "code" }
}
}
}
}
Documentation
View on GitHubNode.js Collector
Collects Node.js project information, CI/CD commands, test coverage, and dependencies.
Overview
This collector gathers metadata about Node.js projects including package manager detection, dependency graphs, TypeScript and linter configuration, monorepo setup, and test coverage metrics. It runs on both code changes (for static analysis) and CI hooks (to capture runtime metrics like test coverage and command tracking).
Note: The CI-hook collectors (test-coverage, cicd) don't run tests—they observe and collect data from npm/yarn/pnpm commands that your CI pipeline already runs.
Collected Data
This collector writes to the following Component JSON paths:
| Path | Type | Description |
|---|---|---|
.lang.nodejs |
object | Node.js project metadata (version, build systems) |
.lang.nodejs.dependencies |
object | Direct and dev dependencies from package.json |
.lang.nodejs.cicd |
object | CI/CD command tracking with Node.js version |
.lang.nodejs.tests.coverage |
object | Test coverage percentage and source |
.testing.coverage |
object | Normalized cross-language coverage (dual-write) |
Collectors
This plugin provides the following collectors (use include to select a subset):
| Collector | Hook Type | Description |
|---|---|---|
project |
code | Collects project structure (package.json, lockfiles, TypeScript, ESLint, monorepo) |
dependencies |
code | Collects dependencies from package.json |
cicd |
ci-before-command | Tracks npm/yarn/pnpm commands run in CI with Node.js version |
test-coverage |
ci-after-command | Extracts coverage from existing test output |
Installation
Add to your lunar-config.yml:
collectors:
- uses: github://earthly/lunar-lib/collectors/nodejs@v1.0.0
on: [nodejs] # Or use domain: ["domain:your-domain"]
# include: [project, dependencies] # Only include specific subcollectors
Open Source
This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore guardrails that use data from Node.js Collector.
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.