1
1
Fork
You've already forked librejs-cmd
0
Command line interface for librejs (maintained fork of librejs-cli)
  • JavaScript 75.2%
  • TypeScript 22.5%
  • HTML 2.3%
Alex Jenkins 53d2f56f08
All checks were successful
ci/woodpecker/push/test-bun Pipeline was successful
ci/woodpecker/push/test-deno Pipeline was successful
ci/woodpecker/push/test-node Pipeline was successful
ci/woodpecker/push/test-selenium Pipeline was successful
Merge pull request 'Clean up source files' ( #2 ) from nikolas/librejs-cmd:more-file-cleanup into main
Reviewed-on: #2 
2026年06月06日 23:23:45 +02:00
.woodpecker Remove obsolete browser extension testing and CI configurations. 2026年06月03日 15:30:23 -04:00
bin Clean up source files 2026年06月06日 06:46:17 -04:00
lib add JSDoc to all exported symbols, bump to 0.0.18 2026年06月01日 04:25:12 -04:00
src Clean up source files 2026年06月06日 06:46:17 -04:00
tests Clean up source files 2026年06月06日 06:46:17 -04:00
workers Clean up source files 2026年06月06日 06:46:17 -04:00
.gitignore bump to 0.0.14, remove code coverage 2026年05月26日 23:04:56 -04:00
.jscsrc first commit 2026年05月24日 12:06:07 -04:00
.jshintrc first commit 2026年05月24日 12:06:07 -04:00
AUTHORS.md Credits cleanup 2026年06月05日 22:02:02 -04:00
CODE_OF_CONDUCT.md update CoC 2026年05月24日 19:28:15 -04:00
eslint.config.js inital boost of CI 2026年06月03日 13:46:19 -04:00
jsr.json docs: full JSDoc coverage, bump to 0.0.19 2026年06月01日 04:29:49 -04:00
LICENSE.md release v0.0.10: LGPL-3.0 workers, license update, spdx-lgpl3 fixtures 2026年05月26日 11:13:58 -04:00
mod.ts Clean up source files 2026年06月06日 06:46:17 -04:00
package.json Credits cleanup 2026年06月05日 22:02:02 -04:00
README.md update CI badge to new repo ID after transfer to librejs org 2026年06月03日 13:57:48 -04:00
SECURITY.md update security doc 2026年05月24日 19:10:04 -04:00
vitest.workers.config.mjs bump to 0.0.14, remove code coverage 2026年05月26日 23:04:56 -04:00
WHATS-NEW.md Clean up source files 2026年06月06日 06:46:17 -04:00
wrangler.jsonc release v0.0.11: contributors attribution, LGPL-3.0 metadata, AUTHORS.md 2026年05月26日 12:13:00 -04:00

LibreJS-CMD

CI npm JSR

gnu JavaScript TypeScript

A maintained fork of librejs-cli, the command line tool for checking GNU LibreJS compliance of JavaScript, TypeScript, and HTML files.

Now supports: JavaScript checking for ES6 and beyond, Bun and Deno as runtimes, TypeScript support, and a HTTP Workers API for serverside compliance checking.

This brings the tool up to date more with the web extension of LibreJS, and makes it more of a library that can be used in various runtimes, while still providing a command-line interface for easy use in scripts and CI pipelines.

About

Licensed under the GNU Lesser General Public License version 3 or later (LGPL v3 or later), this tool analyzes JavaScript (now TypeScript too) and HTML files to determine if they comply with the GNU LibreJS guidelines for free software. It checks for issues such as minification, obfuscation, and the presence of non-free code.

This project was forked in May 2026, to keep the tool up to date with the latest JavaScript features and to add support for multiple runtimes. The original project has not been updated since November 2018, and this fork aims to maintain and enhance the tool for modern development of free JavaScript & TypeScript.

For a full description of the changes in this fork, see the WHATS-NEW document.

Installation

Pick either a global install for command-line use, or run directly without installing.

You have the choice of three runtimes: Node.js, Bun, or Deno. The same analysis is available in all runtimes, but you're expected to choose the right commands below for your runtime of choice. All are free software, and flawlessly work on most major platforms.

Node.js

npm install -g librejs-cmd
pnpm add -g librejs-cmd

Bun

bun add -g librejs-cmd

Deno

deno install --global --allow-all --unstable-detect-cjs -n librejs-cmd-deno jsr:@rockenman1234/librejs-cmd

Supported file types

Extension Type
.js JavaScript
.mjs ES module JavaScript
.cjs CommonJS JavaScript
.ts TypeScript
.mts ES module TypeScript
.cts CommonJS TypeScript
.jsx JavaScript (JSX)
.tsx TypeScript (JSX)
.html / .htm HTML (web labels check)

Usage

Analyze one or more JS, TS, or HTML files. The tool exits with code 0 if all files pass, or 2 if any are non-free or fail analysis.

Node.js - runs the analysis using the Node.js runtime

librejs-cmd file.js
librejs-cmd file.mjs
librejs-cmd file.ts
librejs-cmd file.mts
librejs-cmd file.jsx
librejs-cmd file.tsx
librejs-cmd file.html
librejs-cmd *.js *.mjs *.cjs *.ts *.mts *.cts *.jsx *.tsx

Bun - runs the same analysis using the Bun runtime

librejs-cmd-bun file.js
librejs-cmd-bun *.ts

Deno - runs the same analysis using the Deno runtime

librejs-cmd-deno file.js
librejs-cmd-deno *.ts

Example output

A file with a valid SPDX license identifier:

$ librejs-cmd script.js
script.js
Trivial 	f
Has @licstart/@licend license 	f
Has magnet license 	f
Has SPDX-License-Identifier 	t
---------------------------------
Passed

A file with no license and non-trivial code (exits with code 2):

$ librejs-cmd unlicensed.ts
unlicensed.ts
Trivial 	f
Has @licstart/@licend license 	f
Has magnet license 	f
Has SPDX-License-Identifier 	f
---------------------------------
Failed (no license found, and nontrivial)

Running without installing

Node.js

npx librejs-cmd file.js
pnpm dlx librejs-cmd file.js

Bun

bunx librejs-cmd file.js

Deno

deno run --allow-all --unstable-detect-cjs npm:librejs-cmd file.js

Cloudflare Workers HTTP API

The package includes a Cloudflare Worker that exposes the LibreJS analysis as an HTTP API, letting you check compliance from any HTTP client without installing the tool.

Deploy

npm run workers:deploy # deploy to Cloudflare
npm run workers:dev # run locally on http://localhost:8787

Endpoints

Method Path Description
GET / API info and usage
GET /health Health check
POST /analyze Analyze content for LibreJS compliance

Analyzing content

Send a POST /analyze request with a JSON body containing filename and content:

curl -X POST http://localhost:8787/analyze \
 -H 'Content-Type: application/json' \
 -d '{"filename": "app.js", "content": "// SPDX-License-Identifier: MIT\nfunction greet(n) { return n; }"}'

Response:

{
 "filename": "app.js",
 "passed": true,
 "type": "js",
 "checks": {
 "trivial": false,
 "hasLicstart": false,
 "hasMagnet": false,
 "hasSpdx": true
 },
 "rendered": "Trivial \tf\n..."
}

The filename field is used only to detect whether to analyze as JS/TS or HTML — the file does not need to exist anywhere. All extensions from the table above are supported.

Using as a library

Install via JSR:

deno add jsr:@rockenman1234/librejs-cmd

Then import and use in your project:

import { run } from "jsr:@rockenman1234/librejs-cmd";
const passed = run(["app.js", "index.html"]);
console.log(passed ? "All files pass" : "Some files failed");

API

run(files: string[]): boolean — Analyze multiple files for GNU LibreJS compliance.

analyzeFile(file: string): boolean | Error — Analyze a single file for GNU LibreJS compliance.

analyzeContent(content: string, filename: string): AnalyzeResult — Analyze raw source text without filesystem access. Safe to use in browser extensions, Cloudflare Workers, and other sandboxed runtimes.

createClient(options): LibreJSClient — Create a type-safe HTTP client that delegates analysis to a remote librejs-cmd API. Uses @zap-studio/fetch for schema-validated requests — every response is parsed through a Zod schema before it reaches your code, so a malformed or unexpected server response throws a typed error rather than silently corrupting state. Retries on transient failures via @zap-studio/retry exponential backoff.

import { createClient } from "jsr:@rockenman1234/librejs-cmd/lib";
const client = createClient({ baseURL: "https://librejs-api.example.com" });
const result = await client.analyze({ filename: "app.js", content: source });
if (!result.passed) console.warn("License check failed:", result.rendered);

Running from source

Clone the repo and install dependencies:

git clone https://codeberg.org/rockenman1234/librejs-cmd
cd librejs-cmd
npm install # or: pnpm install

Then run directly without a global install:

Node.js

node bin/librejs-cmd file.js
node bin/librejs-cmd *.js

Bun

bun bin/librejs-cmd-bun file.js
bun bin/librejs-cmd-bun *.js

Deno

deno run --allow-all --unstable-detect-cjs bin/librejs-cmd-deno file.js
deno run --allow-all --unstable-detect-cjs bin/librejs-cmd-deno *.js

Install from source globally

Node.js

npm install -g .
pnpm add -g .

Bun

bun link

Deno

deno install --global --allow-all --unstable-detect-cjs -n librejs-cmd-deno ./bin/librejs-cmd-deno

Uninstalling

Node.js

npm uninstall -g librejs-cmd
pnpm remove -g librejs-cmd

Bun (registry install)

bun remove -g librejs-cmd

Bun (source install via bun link - run from the repo directory)

bun unlink

Deno

deno uninstall --global librejs-cmd-deno

Development

Run tests:

npm test # Node.js unit + workers + integration + ts-compiled (or: pnpm test)
npm run test:bun # Bun unit tests (or: pnpm run test:bun)
npm run test:deno # Deno unit tests (or: pnpm run test:deno)
npm run test:workers # Cloudflare Worker tests (Vitest)
npm run test:integration # Runtime consistency — Node/Bun/Deno against all fixtures
npm run test:ts-compiled # TypeScript compiled-output tests

The full suite (npm test) runs 36 unit tests, 42 worker tests, 110 integration assertions, and 9 TypeScript compiled-output tests.

License

librejs-cmd is licensed under the GNU Lesser General Public License version 3 or later (LGPL v3 or later). See LICENSE for details, or the official website.

This is free software, we respect your freedom to use, modify, study, and distribute it - as described in the terms of the license. We only ask that you give us credit and share any improvements you make under the same license.