Files
pipdock/scripts/bundle-cli.mjs
T
poli0981andClaude Opus 5.5 12bf723daa ci: failures reach someone, audits run on what is merged, releases are attested
- notify-ci-failure.yml lists its workflows by name. `workflows: ['*']` is not a wildcard to
  workflow_run: it matched nothing, so `main` was red from 2026-09-23 with no one told.
- cargo audit runs a prebuilt cargo-audit (taiki-e/install-action, pinned by commit) with
  `--deny warnings`, replacing rustsec/audit-check@v2 - Node 20, a check-run write token, and on a
  pull request a failure only for "critical", which is how September's advisories passed every PR.
  .cargo/audit.toml's contract (a new informational advisory fails CI) is now what runs.
- security-scan.yml: both audits daily against `main`, so an advisory against something already
  merged is reported the day it is published, not at the next PR.
- cargo deny (licences, sources, bans) with deny.toml: the licence allowlist makes "every bundled
  licence is GPL-3.0-compatible" a test. The workspace declares `publish = false`, which it never
  had - and without which cargo-deny judged the app crates as published ones.
- CodeQL analyses rust and actions as well as javascript-typescript. The comment saying CodeQL had
  no Rust support stopped being true in 2025.
- ci-node.yml: Pages and id-token write move from the workflow to the one job that needs them
  (Sonar S8233); the audit installs with --ignore-scripts (S6505); a new `tauri lockstep` job
  fails when a Tauri crate and its npm package drift apart on Cargo.lock and package-lock.json.
- release.yml: build (read-only token, no persisted credentials) and publish (attest + draft) are
  separate jobs; the tag must match all five version fields; SHA256SUMS.txt is LF, which
  `sha256sum -c` elsewhere needs; actions/attest-build-provenance attests the .exe and .msi;
  softprops/action-gh-release is pinned by commit; `workflow_dispatch` with `dry_run` builds any
  ref without attesting or drafting.
- ci-integration.yml also runs for the CLI, exec, audit, release metadata, errors, store, index,
  Cargo.lock and rust-toolchain.toml - every one of which its end-to-end steps run through.
- dependabot.yml: cooldowns, a group per ecosystem for Tauri packages and for actions and pip,
  TypeScript held below 6.1 (typescript-eslint's peer range), and the rust-toolchain ecosystem.
  A multi-ecosystem group would put both Tauri halves in one PR, but what it does to dependencies
  outside its patterns is undocumented; the lockstep job covers the gap instead.
- Sonar: NOSONAR with reasons on the dev scripts' argv and PATH lookups; bundle-cli.mjs no longer
  claims to run from beforeBuildCommand. The dev CSP moves out of index.html into a Vite plugin
  that reads devCsp from tauri.conf.json, so a release build carries one policy, the strict one
  (S7039); checked in the dev server, where React Refresh's preamble still runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 00:55:27 +07:00

51 lines
2.6 KiB
JavaScript

/**
* Build `pipdock.exe` and stage it as a Tauri sidecar, so the installer ships the CLI.
*
* **Why this exists.** The first bundle built for Phase 4 contained exactly one binary,
* `pipdock-app.exe`. PRD P0-12 is "CLI core parity", CLI-SPEC documents the whole surface, and the
* README's Quick start tells the user to run `pipdock env list` — none of which was on the machine
* after a real install. Found by listing the installer, not by reading the config.
*
* Tauri's `externalBin` wants the host target triple in the filename and strips it when bundling,
* so the installed name is plain `pipdock.exe`, next to the GUI. **`PATH` is deliberately not
* touched** (owner decision, 2026-08-13): PipDock does not modify the user's environment, which is
* the same restraint SECURITY §5 applies to not shipping a self-updater. The README says where the
* binary lands and how to put it on `PATH` if you want it there.
*
* Run by `npm run bundle` (package.json), which the release workflow calls too, so a local bundle
* and CI produce the same installer — a bundle that differs by who built it is how "works on my
* machine" gets into a release. (This said `beforeBuildCommand`; it has never been wired there.)
*
* `rustc` and `cargo` are found on PATH, which SonarCloud flags (S4036). That is the toolchain the
* developer or the runner installed and this script is a build step run by them, with their PATH —
* there is no less-trusted caller whose PATH it could be handed.
*/
import { execFileSync } from 'node:child_process'
import { copyFileSync, mkdirSync } from 'node:fs'
import { join } from 'node:path'
/** The host triple, asked of rustc rather than assumed — cross-compiling would break a guess. */
function hostTriple() {
const out = execFileSync('rustc', ['-vV'], { encoding: 'utf8' }) // NOSONAR: see the header
const line = out.split('\n').find((l) => l.startsWith('host:'))
if (line === undefined) throw new Error('rustc -vV printed no host line')
return line.slice('host:'.length).trim()
}
const triple = hostTriple()
const target = join('src-tauri', 'binaries')
mkdirSync(target, { recursive: true })
// `--locked` for the reason the release workflow passes it: a bundle is not the place to discover
// that a dependency resolved differently than the lockfile says.
// NOSONAR: see the header — the developer's own cargo.
execFileSync('cargo', ['build', '--release', '--locked', '-p', 'pipdock-cli'], {
stdio: 'inherit',
})
const from = join('target', 'release', 'pipdock.exe')
const to = join(target, `pipdock-${triple}.exe`)
copyFileSync(from, to)
console.log(`staged ${from} -> ${to}`)