Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-impalas-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hunkdiff": patch
---

Support pacman/AUR installs via `HUNK_INSTALL_SOURCE=pacman`.
11 changes: 11 additions & 0 deletions src/core/install/installSource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ describe("install source detection", () => {
).toBe("curl");
});

test("accepts pacman as declared install source", () => {
expect(
detectInstallSource({
env: { HUNK_INSTALL_SOURCE: "pacman" },
executablePath: join("/", "usr", "lib", "hunkdiff", "hunk"),
version: "1.2.3",
homeDir: HOME_DIR,
}),
).toBe("pacman");
});

test("keeps npm for a .hunk segment that is not followed by bin", () => {
expect(
detectInstallSource({
Expand Down
12 changes: 10 additions & 2 deletions src/core/install/installSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ const INSTALL_DIR_ENV = "HUNK_INSTALL_DIR";
/** Path segments Homebrew always puts above its binaries, on macOS and Linux alike. */
const HOMEBREW_PATH_SEGMENTS = ["cellar", "homebrew", "linuxbrew"];

export type InstallSource = "npm" | "homebrew" | "nix" | "mise" | "curl" | "dev";
export type InstallSource = "npm" | "homebrew" | "nix" | "mise" | "pacman" | "curl" | "dev";

/** Package-manager clients that can install the global `hunkdiff` npm package. */
export type NpmClient = "npm" | "bun" | "pnpm";

const INSTALL_SOURCES: readonly InstallSource[] = ["npm", "homebrew", "nix", "mise", "curl", "dev"];
const INSTALL_SOURCES: readonly InstallSource[] = [
"npm",
"homebrew",
"nix",
"mise",
"pacman",
"curl",
"dev",
];

export interface InstallSourceFacts {
env?: NodeJS.ProcessEnv;
Expand Down
2 changes: 1 addition & 1 deletion src/core/install/latestRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ export async function fetchChannelVersions(
return fetchNpmChannelVersions(deps);
}

// Nix, mise, and source builds install from somewhere Hunk cannot query or act on.
// Nix, mise, pacman and source builds install from somewhere Hunk cannot query or act on.
return {};
}
8 changes: 8 additions & 0 deletions src/core/install/selfUpdate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ describe("hunk update", () => {
expect(result.stdout).toContain("Run `mise up hunk` to update it.");
});

test("points pacman installs at pacman or an AUR helper", async () => {
const result = await runUpdate({ installSource: "pacman" });

expect(result.exitCode).toBe(1);
expect(result.commands).toEqual([]);
expect(result.stdout).toContain("Update it through pacman or your AUR helper.");
});

test("points source builds at install:bin", async () => {
const result = await runUpdate({ installSource: "dev", installedVersion: "0.0.0-unknown" });

Expand Down
4 changes: 4 additions & 0 deletions src/core/install/selfUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ function unmanagedInstallGuidance(installSource: InstallSource) {
return ["Hunk was installed with mise.", "Run `mise up hunk` to update it."];
}

if (installSource === "pacman") {
return ["Hunk was installed with pacman.", "Update it through pacman or your AUR helper."];
}

return [
"Hunk is running from a local source build.",
"Run `bun run install:bin` in your Hunk checkout to update it.",
Expand Down
15 changes: 15 additions & 0 deletions src/core/process/updateNotice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,21 @@ describe("startup update notice", () => {
});
});

test("suppresses update notices for pacman-managed installs", async () => {
await withTempStatePath(async (statePath) => {
await expect(
resolveStartupUpdateNotice({
env: { HUNK_INSTALL_SOURCE: "pacman" },
fetchImpl: async () => {
throw new Error("should not fetch for pacman installs");
},
resolveInstalledVersion: () => "0.7.0",
statePath,
}),
).resolves.toBeNull();
});
});

test("detects unmarked mise installs from their mise install path", async () => {
await withTempStatePath(async (statePath) => {
await expect(
Expand Down
4 changes: 3 additions & 1 deletion src/core/process/updateNotice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export type { InstallSource, UpdateChannel };
* starts. A notice there would ask the user to fix something mise just fixed. A local source build
* is replaced by rebuilding the checkout it came from, which is the developer's own workflow and
* not something a published version number should interrupt.
*
* AUR packages installed via pacman should be updated manually or via an AUR helper.
*/
const SILENT_INSTALL_SOURCES: readonly InstallSource[] = ["mise", "dev"];
const SILENT_INSTALL_SOURCES: readonly InstallSource[] = ["mise", "pacman", "dev"];

export interface UpdateNoticeDeps {
env?: NodeJS.ProcessEnv;
Expand Down