mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
b0c31a4042
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
74 lines
1.8 KiB
JavaScript
Executable File
74 lines
1.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
"use strict";
|
|
|
|
const path = require("path");
|
|
const { spawnSync } = require("child_process");
|
|
const {
|
|
getPlatformKey,
|
|
PLATFORM_MAP,
|
|
describeHost,
|
|
supportedPlatforms,
|
|
} = require("./platform-map");
|
|
|
|
const key = getPlatformKey();
|
|
if (!key) {
|
|
console.error(
|
|
`cpd: no prebuilt binary for this platform: ${describeHost()}`
|
|
);
|
|
console.error(
|
|
`cpd: supported platforms: ${supportedPlatforms().join(", ")}`
|
|
);
|
|
console.error(
|
|
"cpd: build from source instead with `cargo install jscpd` " +
|
|
"(https://github.com/kucherenko/jscpd/tree/master/rust)"
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const entry = PLATFORM_MAP[key];
|
|
const binaryName = process.platform === "win32" ? "jscpd.exe" : "jscpd";
|
|
|
|
let binaryPath;
|
|
try {
|
|
const pkgJson = require.resolve(`${entry.packageName}/package.json`, {
|
|
paths: [path.resolve(__dirname, ".."), __dirname],
|
|
});
|
|
binaryPath = path.join(path.dirname(pkgJson), "bin", binaryName);
|
|
} catch {
|
|
const localBuild = path.join(
|
|
__dirname,
|
|
"target",
|
|
"release",
|
|
binaryName
|
|
);
|
|
const fs = require("fs");
|
|
if (fs.existsSync(localBuild)) {
|
|
binaryPath = localBuild;
|
|
} else {
|
|
console.error(
|
|
`cpd: Platform package "${entry.packageName}" not installed.` +
|
|
` Install it with: npm install ${entry.packageName}`
|
|
);
|
|
console.error(
|
|
"Alternatively, build from source: cargo build --release -p jscpd"
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
stdio: "inherit",
|
|
});
|
|
|
|
if (result.error) {
|
|
if (result.error.code === "ENOENT") {
|
|
console.error(`cpd: binary not found: ${binaryPath}`);
|
|
process.exit(1);
|
|
}
|
|
throw result.error;
|
|
}
|
|
if (result.signal) {
|
|
process.kill(process.pid, result.signal);
|
|
}
|
|
process.exit(result.status ?? 0);
|