From bd8793cea68fa8ad342b0fd68f7a7d93370c4077 Mon Sep 17 00:00:00 2001 From: Tauan Binato <11513929+tauanbinato@users.noreply.github.com> Date: Thu, 3 Sep 2026 17:15:51 -0400 Subject: [PATCH] fix: npm registry quality (readme, license files, metadata) --- .github/workflows/ci.yml | 1 + .github/workflows/release.yml | 9 +++ npm/hardgate-darwin-arm64/README.md | 16 +++++ npm/hardgate-darwin-arm64/package.json | 18 +++-- npm/hardgate-darwin-x64/README.md | 16 +++++ npm/hardgate-darwin-x64/package.json | 18 +++-- npm/hardgate-linux-arm64-musl/README.md | 16 +++++ npm/hardgate-linux-arm64-musl/package.json | 18 +++-- npm/hardgate-linux-arm64/README.md | 16 +++++ npm/hardgate-linux-arm64/package.json | 18 +++-- npm/hardgate-linux-x64-musl/README.md | 16 +++++ npm/hardgate-linux-x64-musl/package.json | 18 +++-- npm/hardgate-linux-x64/README.md | 16 +++++ npm/hardgate-linux-x64/package.json | 18 +++-- npm/hardgate-win32-x64/README.md | 16 +++++ npm/hardgate-win32-x64/package.json | 18 +++-- npm/hardgate/README.md | 31 ++++++++- npm/hardgate/package.json | 16 +++-- scripts/check-npm-quality.mjs | 76 ++++++++++++++++++++++ scripts/sync-npm-version.mjs | 33 ++++++++++ 20 files changed, 371 insertions(+), 33 deletions(-) create mode 100644 npm/hardgate-darwin-arm64/README.md create mode 100644 npm/hardgate-darwin-x64/README.md create mode 100644 npm/hardgate-linux-arm64-musl/README.md create mode 100644 npm/hardgate-linux-arm64/README.md create mode 100644 npm/hardgate-linux-x64-musl/README.md create mode 100644 npm/hardgate-linux-x64/README.md create mode 100644 npm/hardgate-win32-x64/README.md create mode 100644 scripts/check-npm-quality.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11af125..3a819c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,5 +32,6 @@ jobs: node-version: 20 - run: cargo build --locked - run: node scripts/sync-npm-version.mjs --check + - run: node scripts/check-npm-quality.mjs - run: node npm/hardgate/bin/hardgate.js --version - run: node tests/npm-wrapper.test.mjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af21cf0..ef8136e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -197,6 +197,7 @@ jobs: node scripts/sync-npm-version.mjs for pkg in hardgate-linux-x64 hardgate-linux-x64-musl hardgate-linux-arm64 hardgate-linux-arm64-musl hardgate-darwin-x64 hardgate-darwin-arm64 hardgate-win32-x64; do mkdir -p "npm/$pkg/bin" + rm -f "npm/$pkg/bin/.gitkeep" tar xzf "/tmp/hg-dist/$pkg.tar.gz" -C /tmp/hg-dist if [ "$pkg" = "hardgate-win32-x64" ]; then cp "/tmp/hg-dist/$pkg/hardgate.exe" "npm/$pkg/bin/hardgate.exe" @@ -204,8 +205,16 @@ jobs: cp "/tmp/hg-dist/$pkg/hardgate" "npm/$pkg/bin/hardgate" chmod +x "npm/$pkg/bin/hardgate" fi + # Registry quality: every tarball ships README + both licenses. + # Platform READMEs are committed stubs; licenses are copied here + # so the repo keeps a single copy at the root. + cp README.md LICENSE-MIT LICENSE-APACHE "npm/$pkg/" ls -lh "npm/$pkg/bin/" + (cd "npm/$pkg" && npm pack --dry-run 2>&1 | tail -12) done + # Main wrapper ships its own npm README; licenses come from root. + cp LICENSE-MIT LICENSE-APACHE npm/hardgate/ + (cd npm/hardgate && npm pack --dry-run 2>&1 | tail -12) node tests/npm-wrapper.test.mjs # NOTE: the "./" prefix is load-bearing: a bare `npm/` arg is # parsed as a GitHub `owner/repo` shorthand (git ls-remote failure), diff --git a/npm/hardgate-darwin-arm64/README.md b/npm/hardgate-darwin-arm64/README.md new file mode 100644 index 0000000..d054803 --- /dev/null +++ b/npm/hardgate-darwin-arm64/README.md @@ -0,0 +1,16 @@ +# hardgate-darwin-arm64 + +hardgate prebuilt binary: macOS arm64 (Apple Silicon). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-darwin-arm64/package.json b/npm/hardgate-darwin-arm64/package.json index a439ecd..c40beee 100644 --- a/npm/hardgate-darwin-arm64/package.json +++ b/npm/hardgate-darwin-arm64/package.json @@ -2,11 +2,11 @@ "name": "hardgate-darwin-arm64", "version": "0.3.3", "description": "hardgate prebuilt binary: macOS arm64 (Apple Silicon)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "darwin" @@ -15,6 +15,16 @@ "arm64" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-darwin-x64/README.md b/npm/hardgate-darwin-x64/README.md new file mode 100644 index 0000000..e26105e --- /dev/null +++ b/npm/hardgate-darwin-x64/README.md @@ -0,0 +1,16 @@ +# hardgate-darwin-x64 + +hardgate prebuilt binary: macOS x64 (Intel). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-darwin-x64/package.json b/npm/hardgate-darwin-x64/package.json index 5785661..406956c 100644 --- a/npm/hardgate-darwin-x64/package.json +++ b/npm/hardgate-darwin-x64/package.json @@ -2,11 +2,11 @@ "name": "hardgate-darwin-x64", "version": "0.3.3", "description": "hardgate prebuilt binary: macOS x64 (Intel)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "darwin" @@ -15,6 +15,16 @@ "x64" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-linux-arm64-musl/README.md b/npm/hardgate-linux-arm64-musl/README.md new file mode 100644 index 0000000..6353718 --- /dev/null +++ b/npm/hardgate-linux-arm64-musl/README.md @@ -0,0 +1,16 @@ +# hardgate-linux-arm64-musl + +hardgate prebuilt binary: linux arm64 (musl, static — Alpine/Docker). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-linux-arm64-musl/package.json b/npm/hardgate-linux-arm64-musl/package.json index b579595..116d55c 100644 --- a/npm/hardgate-linux-arm64-musl/package.json +++ b/npm/hardgate-linux-arm64-musl/package.json @@ -2,11 +2,11 @@ "name": "hardgate-linux-arm64-musl", "version": "0.3.3", "description": "hardgate prebuilt binary: linux arm64 (musl, static — Alpine/Docker)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "linux" @@ -18,6 +18,16 @@ "musl" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-linux-arm64/README.md b/npm/hardgate-linux-arm64/README.md new file mode 100644 index 0000000..f4f8f58 --- /dev/null +++ b/npm/hardgate-linux-arm64/README.md @@ -0,0 +1,16 @@ +# hardgate-linux-arm64 + +hardgate prebuilt binary: linux arm64 (glibc). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-linux-arm64/package.json b/npm/hardgate-linux-arm64/package.json index 8caadb9..1c20c69 100644 --- a/npm/hardgate-linux-arm64/package.json +++ b/npm/hardgate-linux-arm64/package.json @@ -2,11 +2,11 @@ "name": "hardgate-linux-arm64", "version": "0.3.3", "description": "hardgate prebuilt binary: linux arm64 (glibc)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "linux" @@ -18,6 +18,16 @@ "glibc" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-linux-x64-musl/README.md b/npm/hardgate-linux-x64-musl/README.md new file mode 100644 index 0000000..32525a9 --- /dev/null +++ b/npm/hardgate-linux-x64-musl/README.md @@ -0,0 +1,16 @@ +# hardgate-linux-x64-musl + +hardgate prebuilt binary: linux x64 (musl, static — Alpine/Docker). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-linux-x64-musl/package.json b/npm/hardgate-linux-x64-musl/package.json index 559c3c4..ae24de2 100644 --- a/npm/hardgate-linux-x64-musl/package.json +++ b/npm/hardgate-linux-x64-musl/package.json @@ -2,11 +2,11 @@ "name": "hardgate-linux-x64-musl", "version": "0.3.3", "description": "hardgate prebuilt binary: linux x64 (musl, static — Alpine/Docker)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "linux" @@ -18,6 +18,16 @@ "musl" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-linux-x64/README.md b/npm/hardgate-linux-x64/README.md new file mode 100644 index 0000000..2a95a00 --- /dev/null +++ b/npm/hardgate-linux-x64/README.md @@ -0,0 +1,16 @@ +# hardgate-linux-x64 + +hardgate prebuilt binary: linux x64 (glibc). + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-linux-x64/package.json b/npm/hardgate-linux-x64/package.json index dced843..7f828a9 100644 --- a/npm/hardgate-linux-x64/package.json +++ b/npm/hardgate-linux-x64/package.json @@ -2,11 +2,11 @@ "name": "hardgate-linux-x64", "version": "0.3.3", "description": "hardgate prebuilt binary: linux x64 (glibc)", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "linux" @@ -18,6 +18,16 @@ "glibc" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate-win32-x64/README.md b/npm/hardgate-win32-x64/README.md new file mode 100644 index 0000000..bf6f6ad --- /dev/null +++ b/npm/hardgate-win32-x64/README.md @@ -0,0 +1,16 @@ +# hardgate-win32-x64 + +hardgate prebuilt binary: windows x64. + +This is a platform-specific package. Install the main wrapper instead: + +```sh +npm i -D hardgate +npx hardgate check +``` + +Binaries are delivered via `optionalDependencies`, no postinstall downloads. + +Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +License: MIT OR Apache-2.0. diff --git a/npm/hardgate-win32-x64/package.json b/npm/hardgate-win32-x64/package.json index 19ab14e..4ae55fc 100644 --- a/npm/hardgate-win32-x64/package.json +++ b/npm/hardgate-win32-x64/package.json @@ -2,11 +2,11 @@ "name": "hardgate-win32-x64", "version": "0.3.3", "description": "hardgate prebuilt binary: windows x64", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "os": [ "win32" @@ -15,6 +15,16 @@ "x64" ], "files": [ - "bin/" - ] + "bin/", + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" + ], + "author": "Tauan BF ", + "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/npm/hardgate/README.md b/npm/hardgate/README.md index 5e24fac..398dc6a 100644 --- a/npm/hardgate/README.md +++ b/npm/hardgate/README.md @@ -1,5 +1,8 @@ # hardgate (npm) +[![License](https://img.shields.io/crates/l/hardgate.svg)](https://github.com/Tech-Byte-Frontier/hardgate#license) +[![GitHub Release](https://img.shields.io/github/v/release/Tech-Byte-Frontier/hardgate)](https://github.com/Tech-Byte-Frontier/hardgate/releases) + Deterministic quality gates, hard budgets, and anti-gaming verification harness for the AI agent era. Prebuilt Rust binary, no toolchain required. ```sh @@ -7,11 +10,37 @@ npm i -D hardgate npx hardgate check ``` -Install as a devDependency, then run via `npx`, `pnpm exec`, `yarn exec`, `bunx`, or a `package.json` script. Platform binaries are delivered via `optionalDependencies` (`hardgate-linux-*`, `hardgate-darwin-*`, `hardgate-win32-*`), so installs stay offline-friendly with no postinstall downloads. +Install as a devDependency, then run via `npx`, `pnpm exec`, `yarn dlx`, `bunx`, or a `package.json` script. Platform binaries are delivered via `optionalDependencies` (`hardgate-linux-*`, `hardgate-darwin-*`, `hardgate-win32-*`), so installs stay offline-friendly with no postinstall downloads. ```sh pnpm add -D hardgate pnpm exec hardgate check --diff + +# yarn / bun +yarn add -D hardgate +yarn dlx hardgate check +bun add -d hardgate +bunx hardgate check +``` + +## Common commands + +```sh +npx hardgate check # full gate (<200ms) +npx hardgate check --diff # git-modified files only (sub-10ms, pre-commit) +npx hardgate check --all --dead-code +npx hardgate scan src/index.ts # 1ms AST metric inspection +npx hardgate init --preset strict-agent ``` +Set `HARDGATE_BINARY` to override the resolved binary. + +## Docs + Full docs: https://github.com/Tech-Byte-Frontier/hardgate + +* Configuration (`hardgate.toml`), CLI reference, MCP / agent integration, and architecture live in [`docs/`](https://github.com/Tech-Byte-Frontier/hardgate/tree/main/docs). + +## License + +Dual-licensed under either MIT or Apache-2.0, at your option. See `LICENSE-MIT` and `LICENSE-APACHE`. diff --git a/npm/hardgate/package.json b/npm/hardgate/package.json index 3a1a3fc..d057095 100644 --- a/npm/hardgate/package.json +++ b/npm/hardgate/package.json @@ -2,11 +2,11 @@ "name": "hardgate", "version": "0.3.3", "description": "Deterministic quality gates, hard budgets, and anti-gaming verification harness for the AI agent era", - "license": "MIT OR Apache-2.0", + "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/Tech-Byte-Frontier/hardgate", "repository": { "type": "git", - "url": "https://github.com/Tech-Byte-Frontier/hardgate.git" + "url": "git+https://github.com/Tech-Byte-Frontier/hardgate.git" }, "bugs": "https://github.com/Tech-Byte-Frontier/hardgate/issues", "keywords": [ @@ -25,7 +25,9 @@ }, "files": [ "bin/", - "README.md" + "README.md", + "LICENSE-MIT", + "LICENSE-APACHE" ], "optionalDependencies": { "hardgate-linux-x64": "0.3.3", @@ -38,5 +40,11 @@ }, "scripts": { "test": "node ../../tests/npm-wrapper.test.mjs" - } + }, + "author": "Tauan BF ", + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "commonjs" } diff --git a/scripts/check-npm-quality.mjs b/scripts/check-npm-quality.mjs new file mode 100644 index 0000000..2a7e04c --- /dev/null +++ b/scripts/check-npm-quality.mjs @@ -0,0 +1,76 @@ +#!/usr/bin/env node +// Quality gate for npm/* packages (registry standards). +// Usage: node scripts/check-npm-quality.mjs +// Checks: metadata (license/author/publishConfig/type/repo/bugs), +// files[] includes README + both licenses, platform READMEs exist, +// versions + optionalDependencies in sync with Cargo.toml. +"use strict"; +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = path.join(path.dirname(fileURLToPath(import.meta.url)), ".."); +const cargoToml = fs.readFileSync(path.join(root, "Cargo.toml"), "utf8"); +const version = cargoToml.match(/^version\s*=\s*"([^"]+)"/m)?.[1]; +if (!version) { + console.error("check-npm-quality: could not parse version from Cargo.toml"); + process.exit(1); +} + +const platformPkgs = [ + "hardgate-linux-x64", + "hardgate-linux-x64-musl", + "hardgate-linux-arm64", + "hardgate-linux-arm64-musl", + "hardgate-darwin-x64", + "hardgate-darwin-arm64", + "hardgate-win32-x64", +]; + +let failures = 0; +const fail = (msg) => { + failures += 1; + console.error(`FAIL: ${msg}`); +}; + +const readJson = (rel) => + JSON.parse(fs.readFileSync(path.join(root, rel), "utf8")); + +// --- main wrapper --- +const main = readJson("npm/hardgate/package.json"); +if (main.version !== version) fail(`npm/hardgate version ${main.version} != Cargo ${version}`); +for (const p of platformPkgs) { + if (main.optionalDependencies?.[p] !== version) + fail(`npm/hardgate optionalDependencies[${p}] != ${version}`); +} +for (const f of ["bin/", "README.md", "LICENSE-MIT", "LICENSE-APACHE"]) { + if (!main.files?.includes(f)) fail(`npm/hardgate files[] missing ${f}`); +} +if (main.license !== "(MIT OR Apache-2.0)") fail(`npm/hardgate license = ${main.license}`); +if (!main.author) fail("npm/hardgate missing author"); +if (main.publishConfig?.access !== "public") fail("npm/hardgate missing publishConfig.access=public"); +if (!main.repository?.url?.startsWith("git+https://")) fail("npm/hardgate repository.url should be git+https://"); +if (!fs.existsSync(path.join(root, "npm/hardgate/README.md"))) fail("npm/hardgate/README.md missing"); +if (!fs.existsSync(path.join(root, "npm/hardgate/bin/hardgate.js"))) fail("npm/hardgate/bin/hardgate.js missing"); + +// --- platform packages --- +for (const p of platformPkgs) { + const j = readJson(`npm/${p}/package.json`); + if (j.version !== version) fail(`npm/${p} version ${j.version} != Cargo ${version}`); + if (j.license !== "(MIT OR Apache-2.0)") fail(`npm/${p} license = ${j.license}`); + if (!j.author) fail(`npm/${p} missing author`); + if (j.publishConfig?.access !== "public") fail(`npm/${p} missing publishConfig.access=public`); + if (!j.repository?.url?.startsWith("git+https://")) fail(`npm/${p} repository.url should be git+https://`); + if (!j.bugs) fail(`npm/${p} missing bugs`); + for (const f of ["bin/", "README.md", "LICENSE-MIT", "LICENSE-APACHE"]) { + if (!j.files?.includes(f)) fail(`npm/${p} files[] missing ${f}`); + } + if (!fs.existsSync(path.join(root, `npm/${p}/README.md`))) fail(`npm/${p}/README.md missing`); + if (!j.os?.length || !j.cpu?.length) fail(`npm/${p} missing os/cpu`); +} + +if (failures) { + console.error(`check-npm-quality: ${failures} failure(s)`); + process.exit(1); +} +console.log(`check-npm-quality: ok (${platformPkgs.length} platform pkgs + wrapper @ ${version})`); diff --git a/scripts/sync-npm-version.mjs b/scripts/sync-npm-version.mjs index 4b152d2..5cd4493 100644 --- a/scripts/sync-npm-version.mjs +++ b/scripts/sync-npm-version.mjs @@ -26,6 +26,35 @@ const platformPkgs = [ "hardgate-win32-x64", ]; +// Canonical npm metadata. Single source of truth for versions is Cargo.toml; +// the fields below keep `npm/*` aligned with npm registry quality standards +// (readme + license files present, SPDX dual-license, public provenance). +// `files` entries may not exist in git (LICENSE/README are copied into +// `npm//` by the release workflow before `npm publish`); npm ignores +// missing `files` entries on pack, so listing them here is safe locally. +const META = { + license: "(MIT OR Apache-2.0)", + author: "Tauan BF ", + homepage: "https://github.com/Tech-Byte-Frontier/hardgate", + repository: { + type: "git", + url: "git+https://github.com/Tech-Byte-Frontier/hardgate.git", + }, + bugs: "https://github.com/Tech-Byte-Frontier/hardgate/issues", + publishConfig: { access: "public", provenance: true }, + type: "commonjs", +}; + +function applyCommon(j) { + j.license = META.license; + j.author = META.author; + j.homepage = META.homepage; + j.repository = { ...META.repository }; + j.bugs = META.bugs; + j.publishConfig = { ...META.publishConfig }; + j.type = META.type; +} + let dirty = false; function syncJson(file, mutate) { const before = fs.readFileSync(file, "utf8"); @@ -41,12 +70,16 @@ function syncJson(file, mutate) { syncJson(path.join(root, "npm/hardgate/package.json"), (j) => { j.version = version; + applyCommon(j); + j.files = ["bin/", "README.md", "LICENSE-MIT", "LICENSE-APACHE"]; j.optionalDependencies ??= {}; for (const p of platformPkgs) j.optionalDependencies[p] = version; }); for (const p of platformPkgs) { syncJson(path.join(root, `npm/${p}/package.json`), (j) => { j.version = version; + applyCommon(j); + j.files = ["bin/", "README.md", "LICENSE-MIT", "LICENSE-APACHE"]; }); }