Skip to content
Merged
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
28 changes: 28 additions & 0 deletions packages/provider-core/src/server/maintenanceResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,34 @@ it.layer(
},
);

it.effect.skipIf(!symlinksSupported || windowsHost)(
"updates an npm-owned launcher in a native install location with npm",
() =>
Effect.gen(function* () {
const tempDir = yield* makeTempDir("t3-native-npm");
const prefix = NodePath.join(tempDir, ".local");
const packageBin = NodePath.join("node_modules", "@example", "native-package-tool", "bin");
writeExecutable(NodePath.join(prefix, "lib", packageBin, "native-package-tool.exe"));
const launcher = NodePath.join(prefix, "bin", "native-package-tool");
Comment thread
juliusmarminge marked this conversation as resolved.
Resolved
NodeFS.mkdirSync(NodePath.dirname(launcher), { recursive: true });
NodeFS.symlinkSync(
NodePath.join("..", "lib", packageBin, "native-package-tool.exe"),
launcher,
);

const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
nativePackageToolUpdate,
{ binaryPath: launcher, env: { PATH: "" } },
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));

expect(capabilities.update).toMatchObject({
executable: "npm",
args: expect.arrayContaining(["--prefix", prefix]),
lockKey: `npm-global:${normalizeCommandPath(prefix)}`,
});
}),
);

it.effect.skipIf(!symlinksSupported)(
"prefers npm ownership over the Node keg the package lives under",
() =>
Expand Down
3 changes: 2 additions & 1 deletion packages/provider-core/src/server/maintenanceResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,11 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
: {}),
})
: manual;
// A native-looking launcher can still delegate to a mise-owned install.
// A native-looking launcher can still delegate to an npm- or mise-owned install.
if (
nativeUpdate?.isCommandPath &&
commandPaths.some(nativeUpdate.isCommandPath) &&
!npmGlobalPrefixFromCommandPath(context.realCommandPath, packageName) &&
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
!commandPaths.some(isMiseCommandPath) &&
!(yield* isMiseWrapperScript(context))
) {
Expand Down
Loading