diff --git a/pi.ps1 b/pi.ps1 index 80d23c5..4f1ad8f 100644 --- a/pi.ps1 +++ b/pi.ps1 @@ -3,10 +3,9 @@ if ($args.Count) { throw 'Usage: .\pi.ps1' } $installer = Invoke-RestMethod https://pi.dev/install.ps1 & ([scriptblock]::Create($installer + "`n" + @' $pi = Join-Path (Get-PiBinDir) 'pi.cmd' -$version = & $pi --version +& $pi --version if ($LASTEXITCODE) { exit $LASTEXITCODE } -if ($version -notmatch '^0\.(86\.[1-9]\d*|87\.\d+)$') { Write-Warning "Pi $version installed; LMM alpha supports 0.86.1 through 0.87.x, plugin skipped."; exit 0 } $env:LMM_PI_BIN = $pi -npm.cmd exec --yes --package=@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2 -- lmm-pi-provider npm:@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2 +npm.cmd exec --yes --package=@tokennotincluded/pi-lmm-provider@alpha -- lmm-pi-provider git:github.com/TokenNotIncluded/pi-lmm-provider exit $LASTEXITCODE '@)) diff --git a/pi.sh b/pi.sh index 6aec997..ebbc3da 100755 --- a/pi.sh +++ b/pi.sh @@ -7,7 +7,6 @@ if [[ -n ${TERMUX_VERSION:-} || ${PREFIX:-} == */com.termux/files/usr ]]; then fi installer=$(curl -fsSL https://pi.dev/install.sh) exec sh -c "$installer"' -pi=$(pi_installed_path); version=$("$pi" --version) -case "$version" in 0.86.[1-9]*|0.87.*) ;; *) echo "Pi $version installed; LMM alpha supports 0.86.1 through 0.87.x, plugin skipped." >&2; exit 0;; esac +pi=$(pi_installed_path); "$pi" --version command -v npm >/dev/null 2>&1 || { echo "npm is required to install the LMM plugin and remove conflicting sources." >&2; exit 1; } -LMM_PI_BIN="$pi" npm exec --yes --package=@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2 -- lmm-pi-provider npm:@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2' +LMM_PI_BIN="$pi" npm exec --yes --package=@tokennotincluded/pi-lmm-provider@alpha -- lmm-pi-provider git:github.com/TokenNotIncluded/pi-lmm-provider' diff --git a/test.ps1 b/test.ps1 index 8d5a78f..22020ef 100644 --- a/test.ps1 +++ b/test.ps1 @@ -40,10 +40,12 @@ function npm.cmd { } function pi.cmd { throw 'must not invoke stale pi on PATH' } '@ -Check 'pi.ps1' $piSetup 0 'lmm-pi-provider\|npm:@tokennotincluded/pi-lmm-provider' +Check 'pi.ps1' $piSetup 0 'lmm-pi-provider\|git:github.com/TokenNotIncluded/pi-lmm-provider' Check 'pi.ps1' ($piSetup+"`n`$env:PI_TEST_INSTALLER='Write-Output cancelled; exit 0'") 0 'cancelled' Check 'pi.ps1' ($piSetup+"`n`$env:PI_TEST_INSTALLER='Write-Output failed; exit 9'") 9 'failed' -Check 'pi.ps1' ($piSetup+"`n`$env:PI_TEST_VERSION='0.88.0'; function official-pi { if (`$args[0] -ne '--version') { throw 'unsupported plugin must not run' }; `$env:PI_TEST_VERSION }") 0 'plugin skipped' +foreach ($version in @('0.88.0', '0.99.2', '1.2.0')) { + Check 'pi.ps1' ($piSetup+"`n`$env:PI_TEST_VERSION='$version'") 0 'lmm-pi-provider\|git:github.com/TokenNotIncluded/pi-lmm-provider' +} Check 'pi.ps1' ($piSetup+"`nfunction official-pi { if (`$args[0] -ne '--version') { throw 'plugin must not run' }; `$global:LASTEXITCODE=8 }") 8 '' Check 'pi.ps1' ($piSetup+"`nfunction npm.cmd { Write-Output plugin-failed; `$global:LASTEXITCODE=7 }") 7 'plugin-failed' Check 'pi.ps1' "function Invoke-RestMethod { throw 'download-failed' }" 1 'download-failed' diff --git a/test.py b/test.py index 9102930..313f149 100644 --- a/test.py +++ b/test.py @@ -107,7 +107,7 @@ def test_pi_delegates_to_official_installer_and_uses_its_environment(self): self.assertEqual(self.calls(),[ ['curl',['-fsSL','https://pi.dev/install.sh']], ['official-pi',['--version']], - ['npm',['exec','--yes','--package=@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2','--','lmm-pi-provider','npm:@tokennotincluded/pi-lmm-provider@0.1.0-alpha.2']], + ['npm',['exec','--yes','--package=@tokennotincluded/pi-lmm-provider@alpha','--','lmm-pi-provider','git:github.com/TokenNotIncluded/pi-lmm-provider']], ]) def test_pi_official_failure_or_cancellation_stops_plugin(self): @@ -118,11 +118,16 @@ def test_pi_official_failure_or_cancellation_stops_plugin(self): self.assertTrue(all(name=='curl' for name,_ in self.calls())) shutil.rmtree(self.home/"official pi's bin") - def test_pi_unsupported_host_is_not_downgraded_for_plugin(self): - result=self.run_script('pi.sh',PI_VERSION='0.88.0') - self.assertEqual(result.returncode,0,result.stderr) - self.assertIn('plugin skipped',result.stderr) - self.assertEqual([name for name,_ in self.calls()],['curl','official-pi']) + def test_pi_latest_and_future_hosts_always_install_current_plugin(self): + for version in ('0.88.0', '0.99.2', '1.2.0'): + with self.subTest(version=version): + result=self.run_script('pi.sh',PI_VERSION=version) + self.assertEqual(result.returncode,0,result.stderr) + self.assertNotIn('plugin skipped',result.stderr) + self.assertEqual([name for name,_ in self.calls()],['curl','official-pi','npm']) + self.assertEqual(self.calls()[-1][1][-1], 'git:github.com/TokenNotIncluded/pi-lmm-provider') + shutil.rmtree(self.home/"official pi's bin") + self.log.write_text('') def test_pi_version_and_plugin_failures_propagate(self): for env in ({'PI_VERSION_EXIT':'8'},{'NPM_EXIT':'7'}):