The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 17:15 UTC
fix(provider-core): Vite+ provider updates respect npm's release-age policy (#32340)
Julius Marminge committed
Nov 13, 2026 at 00:20 UTC
290182dc83cc7e645c2c9961f07886c223ff08b7
2 files changed
+129
-10
packages/provider-core/src/server/maintenanceResolver.test.ts
+68
@@ -429,6 +429,74 @@ it.layer(
429
{ skip: !symlinksSupported || windowsHost },
430
);
431
432
+ it.effect.skipIf(windowsHost)(
433
+ "does not offer a Vite+ update npm's release-age policy will not install",
434
+ () =>
435
+ Effect.gen(function* () {
436
+ const tempDir = yield* makeTempDir("t3-release-age");
437
+ const npmBinDir = NodePath.join(tempDir, "npm-bin");
438
+ const npmPath = NodePath.join(npmBinDir, "npm");
439
+ writeExecutable(npmPath);
440
+ const vitePlusNodePath = NodePath.join(tempDir, "vite-plus-node/bin/node");
441
+ const binaryPath = NodePath.join(tempDir, ".vite-plus/bin/package-tool");
442
+ writeExecutable(binaryPath);
443
+ const advise = (env: NodeJS.ProcessEnv, vitePlusPacks: string, nodeSource = "lts") =>
444
+ resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
445
+ binaryPath,
446
+ env: { PATH: npmBinDir, ...env },
447
+ }).pipe(
448
+ Effect.provideService(
449
+ ChildProcessSpawner.ChildProcessSpawner,
450
+ // `vp i -g` runs the npm beside Vite+'s Node; `npm view` ignores min-release-age.
451
+ stdoutSpawner((command, args) => {
452
+ if (command === "vp") {
453
+ return JSON.stringify({
454
+ node: { source: nodeSource, bin_path: vitePlusNodePath, installed: true },
455
+ });
456
+ }
457
+ if (command === npmPath) {
458
+ return args[0] === "view" ? '"1.2.0"' : "example-package-tool-1.2.0.tgz\n";
459
+ }
460
+ return command === NodePath.join(NodePath.dirname(vitePlusNodePath), "npm") &&
461
+ args[0] === "pack"
462
+ ? `example-package-tool-${vitePlusPacks}.tgz\n`
463
+ : "";
464
+ }),
465
+ ),
466
+ Effect.flatMap((capabilities) =>
467
+ enrichProviderSnapshotWithVersionAdvisory(
468
+ { ...installedPackageToolProvider, version: "1.1.0" },
469
+ capabilities,
470
+ ),
471
+ ),
472
+ Effect.map((snapshot) => snapshot.versionAdvisory),
473
+ );
474
+
475
+ expect(yield* advise({ npm_config_min_release_age: "7" }, "1.1.0")).toMatchObject({
476
+ status: "current",
477
+ currentVersion: "1.1.0",
478
+ latestVersion: "1.1.0",
479
+ });
480
+ expect((yield* advise({}, "1.2.0"))?.latestVersion).toBe("1.2.0");
481
+ // Install never uses the system Node `vp env off` reports, so this falls back to `npm view`.
482
+ expect(
483
+ (yield* advise(
484
+ { npm_config_min_release_age: "7", VP_HOME: "system-first" },
485
+ "1.1.0",
486
+ "system PATH",
487
+ ))?.latestVersion,
488
+ ).toBe("1.2.0");
489
+ }).pipe(
490
+ Effect.provide(ProviderLatestVersions.layer),
491
+ Effect.provideService(
492
+ HttpClient.HttpClient,
493
+ HttpClient.make(() =>
494
+ Effect.die("a configured npm lookup must not fall back to public npm"),
495
+ ),
496
+ ),
497
+ ),
498
+ );
499
+
500
it.effect.skipIf(!symlinksSupported || windowsHost)(
501
"keeps configured npm registries' latest versions apart for one install",
502
() =>
packages/provider-core/src/server/maintenanceResolver.ts
+61
-10
@@ -482,6 +482,49 @@ const resolvePnpmGlobalLatestVersion = Effect.fn("resolvePnpmGlobalLatestVersion
482
return nonEmptyString(listedEntries?.[0]?.dependencies?.[packageName]?.version);
483
});
484
485
+// npm names the tarball `${name}-${version}.tgz`, dropping a scope's `@` and its `/`.
486
+function parseNpmPackVersion(stdout: string, packageName: string): string | null {
487
+ const prefix = `${packageName.replace(/^@/, "").replace("/", "-")}-`;
488
+ const filename = stdout.trim();
489
+ if (!filename.startsWith(prefix) || !filename.endsWith(".tgz")) return null;
490
+ const version = filename.slice(prefix.length, -".tgz".length);
491
+ return version && !/\s/.test(version) ? version : null;
492
+}
493
+
494
+const decodeVitePlusCurrentEnv = Schema.decodeUnknownOption(
495
+ Schema.fromJsonString(
496
+ Schema.Struct({
497
+ node: Schema.Struct({
498
+ source: Schema.String,
499
+ bin_path: Schema.String,
500
+ installed: Schema.Boolean,
501
+ }),
502
+ }),
503
+ ),
504
+);
505
+
506
+// `vp i -g` installs through the npm beside Vite+'s managed Node, even under `vp env off`, and
507
+// `vp env current` names that Node unless it reports a system one, which install does not use.
508
+// Pack honours npm's min-release-age and `before`, which `npm view` ignores, and resolves
509
+// `@latest` the way install does. `--json=false` keeps its output to the tarball name.
510
+const resolveVitePlusInstallableLatestVersion = Effect.fn(
511
+ "resolveVitePlusInstallableLatestVersion",
512
+)(function* (packageName: string, env: NodeJS.ProcessEnv, platform: NodeJS.Platform) {
513
+ const path = yield* Path.Path;
514
+ const current = yield* runProbe("vp", ["env", "current", "--json"], env);
515
+ const node = current ? Option.getOrUndefined(decodeVitePlusCurrentEnv(current))?.node : undefined;
516
+ if (!node?.installed || node.source === "system PATH" || !path.isAbsolute(node.bin_path)) {
517
+ return null;
518
+ }
519
+ const npmPath = path.join(path.dirname(node.bin_path), platform === "win32" ? "npm.cmd" : "npm");
520
+ const packed = yield* runProbe(
521
+ npmPath,
522
+ ["pack", "--dry-run", "--json=false", "--global", `${packageName}@latest`],
523
+ env,
524
+ );
525
+ return packed ? parseNpmPackVersion(packed, packageName) : null;
526
+});
527
+
528
// `bun outdated` has no JSON output; its `Latest` column is what `@latest` installs
529
// under minimumReleaseAge (marked `*`). `Update` is only the global package.json range.
530
function parseBunOutdatedLatestVersion(output: string, packageName: string): string | null {
@@ -613,14 +656,6 @@ export const resolveMiseProviderMaintenance = Effect.fn("resolveMiseProviderMain
656
}
657
const args = ["upgrade", miseTool];
658
const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
616
- // Mise reads its settings from this environment, so each one gets its own cached answer.
617
- const envHash = NodeCrypto.createHash("sha256");
618
- for (const [name, value] of Object.entries(context.env).toSorted(([a], [b]) =>
619
- a < b ? -1 : 1,
620
- )) {
621
- envHash.update(`${name}\0${value ?? ""}\0`);
622
- }
623
- const envKey = envHash.digest("hex");
659
const capabilities = makeProviderMaintenanceCapabilities({
660
...owner,
661
updateExecutable: misePath,
@@ -643,7 +678,9 @@ export const resolveMiseProviderMaintenance = Effect.fn("resolveMiseProviderMain
678
});
679
return {
680
...capabilities,
646
- latestVersionCacheKey: ["mise", misePath, miseTool, envKey].join("\0"),
681
+ latestVersionCacheKey: ["mise", misePath, miseTool, environmentCacheKey(context.env)].join(
682
+ "\0",
683
+ ),
684
};
685
},
686
);
@@ -797,14 +834,28 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
834
? manual
835
: native;
836
if (commandPaths.some(isVitePlusGlobalCommandPath)) {
800
- return makeProviderMaintenanceCapabilities({
837
+ const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
838
+ const capabilities = makeProviderMaintenanceCapabilities({
839
provider: definition.provider,
840
packageName,
841
updateExecutable: "vp",
842
updateArgs: ["i", "-g", packageName],
843
updateLockKey: "vite-plus-global",
844
env: context.env,
845
+ lookupLatestVersion: resolveVitePlusInstallableLatestVersion(
846
+ packageName,
847
+ context.env,
848
+ context.platform,
849
+ ).pipe(Effect.provideContext(services)),
850
});
851
+ return {
852
+ ...capabilities,
853
+ latestVersionCacheKey: [
854
+ "vite-plus-global",
855
+ packageName,
856
+ environmentCacheKey(context.env),
857
+ ].join("\0"),
858
+ };
859
}
860
if (commandPaths.some(isBunGlobalCommandPath)) {
861
const services = yield* Effect.context<ProviderMaintenanceResolverServices>();