@@ -26,8 +26,12 @@ import {
2626 resolveProviderMaintenanceCapabilitiesEffect ,
2727 type ProviderMaintenanceCapabilities ,
2828} from "./providerMaintenance.ts" ;
29+ import { symlinksSupported } from "@t3tools/shared/testing/symlinks" ;
2930
3031const driver = ( value : string ) => ProviderDriverKind . make ( value ) ;
32+ // These write `#!/bin/sh` stubs and evaluate them with darwin/linux path
33+ // semantics; a Windows temp path cannot be split on `:`.
34+ const windowsHost = HostProcessPlatform . defaultValue ( ) === "win32" ;
3135const makeTempDir = ( name : string ) =>
3236 Crypto . Crypto . pipe (
3337 Effect . flatMap ( ( crypto ) => crypto . randomUUIDv4 ) ,
@@ -237,39 +241,44 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
237241 ) ,
238242 ) ;
239243
240- it . effect ( "pins npm updates to the global prefix that owns the package" , ( ) =>
241- Effect . gen ( function * ( ) {
242- const tempDir = yield * makeTempDir ( "t3-npm-capabilities" ) ;
243- const link = linkIntoPackage ( tempDir , "package-tool" , [
244- "lib" ,
245- "node_modules" ,
246- "@example" ,
247- "package-tool" ,
248- ] ) ;
244+ it . effect . skipIf ( ! symlinksSupported ) (
245+ "pins npm updates to the global prefix that owns the package" ,
246+ ( ) =>
247+ Effect . gen ( function * ( ) {
248+ const tempDir = yield * makeTempDir ( "t3-npm-capabilities" ) ;
249+ const link = linkIntoPackage ( tempDir , "package-tool" , [
250+ "lib" ,
251+ "node_modules" ,
252+ "@example" ,
253+ "package-tool" ,
254+ ] ) ;
249255
250- const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect ( packageToolUpdate , {
251- binaryPath : link ,
252- env : { PATH : "" } ,
253- } ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
256+ const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
257+ packageToolUpdate ,
258+ {
259+ binaryPath : link ,
260+ env : { PATH : "" } ,
261+ } ,
262+ ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
254263
255- expect ( capabilities ) . toEqual ( {
256- provider : driver ( "packageTool" ) ,
257- packageName : "@example/package-tool" ,
258- update : {
259- command : `npm install -g --prefix ${ tempDir } --allow-scripts=@example/package-tool @example/package-tool@latest` ,
260- executable : "npm" ,
261- args : [
262- "install" ,
263- "-g" ,
264- "--prefix" ,
265- tempDir ,
266- "--allow-scripts=@example/package-tool" ,
267- "@example/package-tool@latest" ,
268- ] ,
269- lockKey : `npm-global:${ normalizeCommandPath ( tempDir ) } ` ,
270- } ,
271- } ) ;
272- } ) ,
264+ expect ( capabilities ) . toEqual ( {
265+ provider : driver ( "packageTool" ) ,
266+ packageName : "@example/package-tool" ,
267+ update : {
268+ command : `npm install -g --prefix ${ tempDir } --allow-scripts=@example/package-tool @example/package-tool@latest` ,
269+ executable : "npm" ,
270+ args : [
271+ "install" ,
272+ "-g" ,
273+ "--prefix" ,
274+ tempDir ,
275+ "--allow-scripts=@example/package-tool" ,
276+ "@example/package-tool@latest" ,
277+ ] ,
278+ lockKey : `npm-global:${ normalizeCommandPath ( tempDir ) } ` ,
279+ } ,
280+ } ) ;
281+ } ) ,
273282 ) ;
274283
275284 it ( "derives the npm prefix only from the global lib/node_modules layout" , ( ) => {
@@ -342,54 +351,64 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
342351 } ) ,
343352 ) ;
344353
345- it . effect ( "switches to pnpm updates when the real path lives in pnpm's global store" , ( ) =>
346- Effect . gen ( function * ( ) {
347- const tempDir = yield * makeTempDir ( "t3-pnpm-capabilities" ) ;
348- const link = linkIntoPackage ( tempDir , "package-tool" , [
349- ".local" ,
350- "share" ,
351- "pnpm" ,
352- "global" ,
353- "5" ,
354- "node_modules" ,
355- "@example" ,
356- "package-tool" ,
357- ] ) ;
354+ it . effect . skipIf ( ! symlinksSupported ) (
355+ "switches to pnpm updates when the real path lives in pnpm's global store" ,
356+ ( ) =>
357+ Effect . gen ( function * ( ) {
358+ const tempDir = yield * makeTempDir ( "t3-pnpm-capabilities" ) ;
359+ const link = linkIntoPackage ( tempDir , "package-tool" , [
360+ ".local" ,
361+ "share" ,
362+ "pnpm" ,
363+ "global" ,
364+ "5" ,
365+ "node_modules" ,
366+ "@example" ,
367+ "package-tool" ,
368+ ] ) ;
358369
359- const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect ( packageToolUpdate , {
360- binaryPath : link ,
361- env : { PATH : "" } ,
362- } ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
370+ const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
371+ packageToolUpdate ,
372+ {
373+ binaryPath : link ,
374+ env : { PATH : "" } ,
375+ } ,
376+ ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
363377
364- expect ( capabilities . update ) . toMatchObject ( {
365- command : "pnpm add -g @example/package-tool@latest" ,
366- lockKey : "pnpm-global" ,
367- } ) ;
368- } ) ,
378+ expect ( capabilities . update ) . toMatchObject ( {
379+ command : "pnpm add -g @example/package-tool@latest" ,
380+ lockKey : "pnpm-global" ,
381+ } ) ;
382+ } ) ,
369383 ) ;
370384
371- it . effect ( "switches to bun updates when the resolved binary lives in bun's global bin" , ( ) =>
372- Effect . gen ( function * ( ) {
373- const tempDir = yield * makeTempDir ( "t3-bun-capabilities" ) ;
374- const bunBinDir = NodePath . join ( tempDir , ".bun" , "bin" ) ;
375- writeExecutable ( NodePath . join ( bunBinDir , "package-tool" ) ) ;
385+ it . effect . skipIf ( windowsHost ) (
386+ "switches to bun updates when the resolved binary lives in bun's global bin" ,
387+ ( ) =>
388+ Effect . gen ( function * ( ) {
389+ const tempDir = yield * makeTempDir ( "t3-bun-capabilities" ) ;
390+ const bunBinDir = NodePath . join ( tempDir , ".bun" , "bin" ) ;
391+ writeExecutable ( NodePath . join ( bunBinDir , "package-tool" ) ) ;
376392
377- const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect ( packageToolUpdate , {
378- binaryPath : "package-tool" ,
379- env : { PATH : bunBinDir } ,
380- } ) . pipe (
381- Effect . provideService ( HostProcessPlatform , "darwin" ) ,
382- Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ,
383- ) ;
393+ const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
394+ packageToolUpdate ,
395+ {
396+ binaryPath : "package-tool" ,
397+ env : { PATH : bunBinDir } ,
398+ } ,
399+ ) . pipe (
400+ Effect . provideService ( HostProcessPlatform , "darwin" ) ,
401+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ,
402+ ) ;
384403
385- expect ( capabilities . update ) . toMatchObject ( {
386- command : "bun i -g @example/package-tool@latest" ,
387- lockKey : "bun-global" ,
388- } ) ;
389- } ) ,
404+ expect ( capabilities . update ) . toMatchObject ( {
405+ command : "bun i -g @example/package-tool@latest" ,
406+ lockKey : "bun-global" ,
407+ } ) ;
408+ } ) ,
390409 ) ;
391410
392- it . effect ( "switches to native updates and runs the resolved executable" , ( ) =>
411+ it . effect . skipIf ( windowsHost ) ( "switches to native updates and runs the resolved executable" , ( ) =>
393412 Effect . gen ( function * ( ) {
394413 const tempDir = yield * makeTempDir ( "t3-native-capabilities" ) ;
395414 const nativeBinDir = NodePath . join ( tempDir , ".local" , "bin" ) ;
@@ -438,21 +457,23 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
438457 } ) ;
439458 } ) ;
440459
441- it . effect ( "stays manual-only for an explicit binary path that does not exist" , ( ) =>
442- Effect . gen ( function * ( ) {
443- const tempDir = yield * makeTempDir ( "t3-missing-native-capabilities" ) ;
444- const missingPath = NodePath . join ( tempDir , ".local" , "bin" , "native-package-tool" ) ;
460+ it . effect . skipIf ( windowsHost ) (
461+ "stays manual-only for an explicit binary path that does not exist" ,
462+ ( ) =>
463+ Effect . gen ( function * ( ) {
464+ const tempDir = yield * makeTempDir ( "t3-missing-native-capabilities" ) ;
465+ const missingPath = NodePath . join ( tempDir , ".local" , "bin" , "native-package-tool" ) ;
445466
446- const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
447- nativePackageToolUpdate ,
448- { binaryPath : missingPath , env : { PATH : "" } } ,
449- ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
467+ const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
468+ nativePackageToolUpdate ,
469+ { binaryPath : missingPath , env : { PATH : "" } } ,
470+ ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) ) ;
450471
451- expect ( capabilities . update ) . toBeNull ( ) ;
452- } ) ,
472+ expect ( capabilities . update ) . toBeNull ( ) ;
473+ } ) ,
453474 ) ;
454475
455- it . effect (
476+ it . effect . skipIf ( ! symlinksSupported ) (
456477 "upgrades the Homebrew cask that owns the binary and compares against its version" ,
457478 ( ) =>
458479 Effect . gen ( function * ( ) {
@@ -510,35 +531,40 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
510531 } ) ,
511532 ) ;
512533
513- it . effect ( "stays manual-only when the keg is not under the resolved brew's prefix" , ( ) =>
514- Effect . gen ( function * ( ) {
515- const tempDir = yield * makeTempDir ( "t3-homebrew-foreign-prefix" ) ;
516- const brewBinDir = NodePath . join ( tempDir , "brew-bin" ) ;
517- writeExecutable ( NodePath . join ( brewBinDir , "brew" ) ) ;
518- const kegBinary = NodePath . join (
519- tempDir ,
520- "elsewhere" ,
521- "Cellar" ,
522- "package-tool" ,
523- "1.0.0" ,
524- "bin" ,
525- "package-tool" ,
526- ) ;
527- writeExecutable ( kegBinary ) ;
534+ it . effect . skipIf ( windowsHost ) (
535+ "stays manual-only when the keg is not under the resolved brew's prefix" ,
536+ ( ) =>
537+ Effect . gen ( function * ( ) {
538+ const tempDir = yield * makeTempDir ( "t3-homebrew-foreign-prefix" ) ;
539+ const brewBinDir = NodePath . join ( tempDir , "brew-bin" ) ;
540+ writeExecutable ( NodePath . join ( brewBinDir , "brew" ) ) ;
541+ const kegBinary = NodePath . join (
542+ tempDir ,
543+ "elsewhere" ,
544+ "Cellar" ,
545+ "package-tool" ,
546+ "1.0.0" ,
547+ "bin" ,
548+ "package-tool" ,
549+ ) ;
550+ writeExecutable ( kegBinary ) ;
528551
529- const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect ( packageToolUpdate , {
530- binaryPath : kegBinary ,
531- env : { PATH : brewBinDir } ,
532- } ) . pipe (
533- Effect . provideService ( HostProcessPlatform , "darwin" ) ,
534- Effect . provideService (
535- ChildProcessSpawner . ChildProcessSpawner ,
536- stdoutSpawner ( ( ) => "/opt/homebrew\n" ) ,
537- ) ,
538- ) ;
552+ const capabilities = yield * resolveProviderMaintenanceCapabilitiesEffect (
553+ packageToolUpdate ,
554+ {
555+ binaryPath : kegBinary ,
556+ env : { PATH : brewBinDir } ,
557+ } ,
558+ ) . pipe (
559+ Effect . provideService ( HostProcessPlatform , "darwin" ) ,
560+ Effect . provideService (
561+ ChildProcessSpawner . ChildProcessSpawner ,
562+ stdoutSpawner ( ( ) => "/opt/homebrew\n" ) ,
563+ ) ,
564+ ) ;
539565
540- expect ( capabilities ) . toEqual ( manualPackageTool ) ;
541- } ) ,
566+ expect ( capabilities ) . toEqual ( manualPackageTool ) ;
567+ } ) ,
542568 ) ;
543569
544570 it ( "reads the stable formula version from brew info" , ( ) => {
@@ -548,7 +574,7 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
548574 expect ( parseHomebrewLatestVersion ( "not json" , formula ) ) . toBeNull ( ) ;
549575 } ) ;
550576
551- it . effect (
577+ it . effect . skipIf ( windowsHost ) (
552578 "disables one-click updates for explicit custom binary paths it cannot safely map" ,
553579 ( ) =>
554580 Effect . gen ( function * ( ) {
0 commit comments