Hamburger Cross Icon
Node.js Collector - Lunar Collector

Node.js Collector

Collector Stable LanguagesBuild

Analyze Node.js projects to collect package metadata, dependencies, test coverage, and CI/CD command tracking. Enforce Node.js-specific engineering standards.

Add 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.

Collector code

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.

nodejs package.json project structure npm yarn pnpm
Book a demo
Collector code

dependencies

Extracts direct and dev dependencies from package.json. Captures package names and version ranges for dependency tracking and policy enforcement.

nodejs dependencies npm packages package.json supply chain
Book a demo
Collector ci-before-command

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.

nodejs ci npm ci yarn ci pnpm ci ci commands
Book a demo
Collector ci-after-command

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.

code coverage jest coverage vitest coverage test metrics
Book a demo

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
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "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 GitHub

Node.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.

View Repository

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.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Turn any process doc into guardrails
Book a Demo