|
1 | 1 | // @effect-diagnostics nodeBuiltinImport:off |
2 | | -import { expect, it } from "@effect/vitest"; |
| 2 | +import { expect, it, vi } from "@effect/vitest"; |
3 | 3 | import * as NodeChildProcess from "node:child_process"; |
4 | 4 | import * as NodeFS from "node:fs"; |
5 | 5 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
@@ -624,6 +624,50 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => { |
624 | 624 | }), |
625 | 625 | ); |
626 | 626 |
|
| 627 | + it.effect.skipIf(windowsHost || !symlinksSupported)( |
| 628 | + "uses the cleaned host for omitted probe environments and preserves supplied partial maps", |
| 629 | + () => |
| 630 | + Effect.gen(function* () { |
| 631 | + const tempDir = yield* makeTempDir("t3-maintenance-environment"); |
| 632 | + const link = linkIntoPackage(tempDir, "package-tool", [ |
| 633 | + "pnpm", |
| 634 | + "global", |
| 635 | + "5", |
| 636 | + "node_modules", |
| 637 | + "@example", |
| 638 | + "package-tool", |
| 639 | + ]); |
| 640 | + const binDir = NodePath.dirname(link); |
| 641 | + const pnpmPath = NodePath.join(binDir, "pnpm"); |
| 642 | + writeExecutable(pnpmPath); |
| 643 | + NodeFS.writeFileSync( |
| 644 | + pnpmPath, |
| 645 | + '#!/bin/sh\n[ "$HOME" = "$T3_MAINTENANCE_HOME" ] && [ -n "$HOME" ] && [ -z "${APPDIR+x}${ELECTRON_RUN_AS_NODE+x}" ] || exit 1\nprintf "11.1.3\\n"\n', |
| 646 | + ); |
| 647 | + yield* Effect.addFinalizer(() => Effect.sync(() => vi.unstubAllEnvs())); |
| 648 | + vi.stubEnv("HOME", tempDir); |
| 649 | + vi.stubEnv("T3_MAINTENANCE_HOME", tempDir); |
| 650 | + vi.stubEnv("APPDIR", NodePath.join(tempDir, "appimage")); |
| 651 | + vi.stubEnv("ELECTRON_RUN_AS_NODE", "1"); |
| 652 | + vi.stubEnv("PATH", `${tempDir}/appimage/bin:${binDir}`); |
| 653 | + |
| 654 | + const inherited = yield* resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, { |
| 655 | + binaryPath: "package-tool", |
| 656 | + }); |
| 657 | + expect(inherited.update?.command).toBe( |
| 658 | + "pnpm add -g --allow-build=@example/package-tool @example/package-tool@latest", |
| 659 | + ); |
| 660 | + |
| 661 | + const env = { PATH: binDir }; |
| 662 | + const explicit = yield* resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, { |
| 663 | + binaryPath: "package-tool", |
| 664 | + env, |
| 665 | + }); |
| 666 | + expect(explicit.update?.command).toBe("pnpm add -g @example/package-tool@latest"); |
| 667 | + expect(env).toEqual({ PATH: binDir }); |
| 668 | + }).pipe(Effect.scoped), |
| 669 | + ); |
| 670 | + |
627 | 671 | it.effect.skipIf(windowsHost)( |
628 | 672 | "switches to bun updates when the resolved binary lives in bun's global bin", |
629 | 673 | () => |
|
0 commit comments