Files
kucherenko__jscpd/rust/platform-map.js
apk b0c31a4042 chore: apply audit fixes across repo, crates, npm wrapper and pipelines
Rust / crates.io
- report the invoked binary name in --version/--help (jscpd vs cpd)
- add repository, documentation, keywords, categories to all crates
- exclude tests/ from the jscpd crate package; add cargo-binstall metadata
- expand the crates.io README and render it on docs.rs

npm
- add funding field to jscpd, cpd and jscpd@4 packages
- add jscpd-linux-arm64-musl platform package and clearer unsupported-platform error
- enable provenance for the v4 changeset publish

Pipelines
- rust.yml: windows-latest in the matrix, drop dead schedule guard
- release.yml: cosign-sign release assets, floating v5 tag, LICENSE in tarballs,
  invoke the new docker.yml (GHCR multi-arch image) after each release
- audit.yml: nightly cargo audit, cargo deny and pnpm audit
- Dockerfile: multi-stage image from release binaries (distroless), mcp target for Glama

Docs / community
- README: shields badges, single primary install per OS, GitHub Action snippet,
  link to jscpd.dev, v5.1 features, 15 reporters, 224 formats, 8 platforms
- docs: @v5 action tag, Docker usage, baseline section, current crate versions
- YAML issue forms with engine selector, config.yml, CODEOWNERS
- remove stale .github/CONTRIBUTING.md stub, custom.md, TODO.md; untrack rust/jscpd-report.json
- examples: mark as v4 API, add a Rust cpd-finder example
2026-09-02 09:57:06 +02:00

120 lines
2.6 KiB
JavaScript

"use strict";
const { platform, arch } = process;
const PLATFORM_MAP = {
"linux-x64-gnu": {
packageName: "jscpd-linux-x64-gnu",
os: "linux",
cpu: "x64",
libc: "glibc",
rustTarget: "x86_64-unknown-linux-gnu",
runner: "ubuntu-latest",
},
"linux-arm64-gnu": {
packageName: "jscpd-linux-arm64-gnu",
os: "linux",
cpu: "arm64",
libc: "glibc",
rustTarget: "aarch64-unknown-linux-gnu",
runner: "ubuntu-latest",
},
"linux-x64-musl": {
packageName: "jscpd-linux-x64-musl",
os: "linux",
cpu: "x64",
libc: "musl",
rustTarget: "x86_64-unknown-linux-musl",
runner: "ubuntu-latest",
},
"linux-arm64-musl": {
packageName: "jscpd-linux-arm64-musl",
os: "linux",
cpu: "arm64",
libc: "musl",
rustTarget: "aarch64-unknown-linux-musl",
runner: "ubuntu-22.04-arm",
},
"darwin-arm64": {
packageName: "jscpd-darwin-arm64",
os: "darwin",
cpu: "arm64",
rustTarget: "aarch64-apple-darwin",
runner: "macos-latest",
},
"darwin-x64": {
packageName: "jscpd-darwin-x64",
os: "darwin",
cpu: "x64",
rustTarget: "x86_64-apple-darwin",
runner: "macos-13",
},
"windows-x64-msvc": {
packageName: "jscpd-windows-x64-msvc",
os: "win32",
cpu: "x64",
rustTarget: "x86_64-pc-windows-msvc",
runner: "windows-latest",
},
"windows-arm64-msvc": {
packageName: "jscpd-windows-arm64-msvc",
os: "win32",
cpu: "arm64",
rustTarget: "aarch64-pc-windows-msvc",
runner: "windows-11-arm",
},
};
function detectLinuxLibc() {
if (platform !== "linux") {
return undefined;
}
const report =
process.report && typeof process.report.getReport === "function"
? process.report.getReport()
: undefined;
if (report && report.header && report.header.glibcVersionRuntime) {
return "glibc";
}
return "musl";
}
function getPlatformKey() {
const libc = detectLinuxLibc();
for (const [key, target] of Object.entries(PLATFORM_MAP)) {
if (target.os !== platform || target.cpu !== arch) {
continue;
}
if (target.os === "linux" && target.libc !== libc) {
continue;
}
return key;
}
return undefined;
}
/**
* Human-readable description of the host, e.g. "linux/arm64 (musl)", for
* error messages.
*/
function describeHost() {
const libc = detectLinuxLibc();
return `${platform}/${arch}${libc ? ` (${libc})` : ""}`;
}
/** Supported platform keys, e.g. ["linux-x64-gnu", ...]. */
function supportedPlatforms() {
return Object.keys(PLATFORM_MAP);
}
module.exports = {
PLATFORM_MAP,
getPlatformKey,
detectLinuxLibc,
describeHost,
supportedPlatforms,
};