diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf75779..a733534 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,8 +59,10 @@ jobs: - name: Install frontend dependencies run: npm ci - # No separate frontend step: `tauri build` runs `beforeBuildCommand`, which is - # `npm run build`. Having both meant vite ran twice per release for no benefit. + # No separate frontend or CLI step: `tauri build` runs `beforeBuildCommand`, which is + # `npm run build && npm run bundle:cli`. Keeping them there rather than here is what makes a + # locally built installer identical to a released one — a bundle that differs by who built + # it is how "works on my machine" reaches a release. - name: Build and bundle # `--locked` is **cargo's** flag, not `tauri build`'s: everything after `--` is passed # to the runner. Written the other way round it fails with "unexpected argument diff --git a/.gitignore b/.gitignore index a2d412c..8cc2fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,6 @@ tauri-signing-private.key* # Spike tooling venvs (SP-1 needs several uv versions side by side) /spikes/.venv*/ + +# Staged by scripts/bundle-cli.mjs so the installer ships the CLI; rebuilt every bundle. +src-tauri/binaries/ diff --git a/README.md b/README.md index a038e48..ae22889 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,14 @@ PipDock does not update itself — grab a new build from the same page when you **GUI:** launch PipDock → accept the first-run legal gate → pick an environment (auto-discovered or *Browse…*) → the *Updates* tab shows what's outdated → *Select all* → *Update* → review the preview → *Confirm*. Four clicks. -**CLI:** +**CLI:** the installer puts `pipdock.exe` next to the GUI — `%LOCALAPPDATA%\Programs\PipDock\` +for a per-user install, `C:\Program Files\PipDock\` for a machine-wide one. **PipDock does not +edit your `PATH`**; add that folder yourself if you want to type `pipdock` from anywhere: + +```powershell +$dir = "$env:LOCALAPPDATA\Programs\PipDock" +[Environment]::SetEnvironmentVariable('Path', "$([Environment]::GetEnvironmentVariable('Path','User'));$dir", 'User') +``` ```text pipdock env list diff --git a/package.json b/package.json index c628193..e51a246 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "scripts": { "dev": "vite", "build": "vite build", + "bundle:cli": "node scripts/bundle-cli.mjs", "preview": "vite preview", "lint": "eslint .", "typecheck": "tsc --noEmit", diff --git a/scripts/bundle-cli.mjs b/scripts/bundle-cli.mjs new file mode 100644 index 0000000..9aa3811 --- /dev/null +++ b/scripts/bundle-cli.mjs @@ -0,0 +1,45 @@ +/** + * 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 from `beforeBuildCommand` rather than only from the release workflow, so a local + * `tauri build` and CI produce the same installer — a bundle that differs by who built it is how + * "works on my machine" gets into a release. + */ + +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' }) + 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. +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}`) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 89f1199..c4d886d 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -5,7 +5,7 @@ "identifier": "com.skullmute.pipdock", "build": { "beforeDevCommand": "npm run dev", - "beforeBuildCommand": "npm run build", + "beforeBuildCommand": "npm run build && npm run bundle:cli", "devUrl": "http://localhost:1420", "frontendDist": "../dist" }, @@ -28,6 +28,7 @@ "bundle": { "active": true, "targets": ["nsis", "msi"], + "externalBin": ["binaries/pipdock"], "icon": ["icons/icon.ico"], "copyright": "Copyright (C) 2026 Kokone (poli0981). Licensed under GPL-3.0-only.", "category": "DeveloperTool",