Skip to content
Closed
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
32 changes: 21 additions & 11 deletions apps/desktop/src/fixPath.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import * as ChildProcess from "node:child_process";

export function fixPath(): void {
if (process.platform !== "darwin") return;
if (process.platform === "win32") return;

try {
const shell = process.env.SHELL ?? "/bin/zsh";
const result = ChildProcess.execFileSync(shell, ["-ilc", "echo -n $PATH"], {
encoding: "utf8",
timeout: 5000,
});
if (result) {
process.env.PATH = result;
const shell = process.env.SHELL ?? (process.platform === "darwin" ? "/bin/zsh" : "/bin/sh");
const commandArgSets = [
["-ilc", "echo -n $PATH"],
["-lc", "echo -n $PATH"],
] as const;

for (const args of commandArgSets) {
try {
const result = ChildProcess.execFileSync(shell, args, {
encoding: "utf8",
timeout: 5000,
});
if (result) {
process.env.PATH = result;
return;
}
} catch {
// Try the next shell invocation mode.
}
} catch {
// Keep inherited PATH if shell lookup fails.
}

// Keep inherited PATH if shell lookup fails.
}
32 changes: 21 additions & 11 deletions apps/server/src/os-jank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ import { Effect, Path } from "effect";
import { execFileSync } from "node:child_process";

export function fixPath(): void {
if (process.platform !== "darwin") return;
if (process.platform === "win32") return;

try {
const shell = process.env.SHELL ?? "/bin/zsh";
const result = execFileSync(shell, ["-ilc", "echo -n $PATH"], {
encoding: "utf8",
timeout: 5000,
});
if (result) {
process.env.PATH = result;
const shell = process.env.SHELL ?? (process.platform === "darwin" ? "/bin/zsh" : "/bin/sh");
const commandArgSets = [
["-ilc", "echo -n $PATH"],
["-lc", "echo -n $PATH"],
] as const;

for (const args of commandArgSets) {
try {
const result = execFileSync(shell, args, {
encoding: "utf8",
timeout: 5000,
});
if (result) {
process.env.PATH = result;
return;
}
} catch {
// Try the next shell invocation mode.
}
} catch {
// Silently ignore — keep default PATH
}

// Silently ignore and keep default PATH.
}

export const expandHomePath = Effect.fn(function* (input: string) {
Expand Down
27 changes: 26 additions & 1 deletion scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@ function resolveGitCommitHash(repoRoot: string): string {
return hash.toLowerCase();
}

function resolveGitTaggedVersion(repoRoot: string): string | undefined {
const result = spawnSync("git", ["tag", "--points-at", "HEAD"], {
cwd: repoRoot,
encoding: "utf8",
});
if (result.status !== 0) {
return undefined;
}

const tags = result.stdout
.split("\n")
.map((value) => value.trim())
.filter((value) => value.length > 0);

for (const tag of tags) {
const match = tag.match(/^v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/);
if (match?.[1]) {
return match[1];
}
}

return undefined;
}

function resolvePythonForNodeGyp(): string | undefined {
const configured = process.env.npm_config_python ?? process.env.PYTHON;
if (configured && existsSync(configured)) {
Expand Down Expand Up @@ -558,7 +582,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
}),
});

const appVersion = options.version ?? serverPackageJson.version;
const tagVersion = resolveGitTaggedVersion(repoRoot);
const appVersion = options.version ?? tagVersion ?? serverPackageJson.version;
const commitHash = resolveGitCommitHash(repoRoot);
const mkdir = options.keepStage ? fs.makeTempDirectory : fs.makeTempDirectoryScoped;
const stageRoot = yield* mkdir({
Expand Down