Skip to content

feat: add windows install script #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025
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
35 changes: 35 additions & 0 deletions public/sendme.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$repo = "n0-computer/sendme"
$release_url = "https://api.github.com/repos/$repo/releases/latest"

$target = "windows-x86_64"
$zipFile = "sendme.zip"
$extractPath = ".\sendme"

Write-Host "Fetching latest release for $target..."
$releaseJson = Invoke-RestMethod -Uri $release_url
$releaseUrl = ($releaseJson.assets | Where-Object { $_.browser_download_url -match $target }).browser_download_url

if (-not $releaseUrl) {
Write-Host "Error: No release found for $target" -ForegroundColor Red
exit 1
}

Write-Host "Downloading from $releaseUrl..."
Invoke-WebRequest -Uri $releaseUrl -OutFile $zipFile

Write-Host "Extracting..."
Expand-Archive -Path $zipFile -DestinationPath $extractPath -Force

Write-Host "Cleaning up..."
Remove-Item -Force $zipFile

Write-Host "Installation complete!"

# Add the 'sendme' folder to PATH
$sendmePath = (Resolve-Path $extractPath).Path

# Add the folder to the PATH permanently (user level)
$env:Path += ";$sendmePath"
[System.Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)

Write-Host "'$sendmePath' has been permanently added to user PATH." -ForegroundColor Green
28 changes: 26 additions & 2 deletions src/components/SendmePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,30 @@ const koulen = localFont({

export default function SendmePage() {
const install = `curl -fsSL https://iroh.computer/sendme.sh | sh`
const install_win = `iwr https://iroh.computer/sendme.ps1 -useb | iex`
const [copied, setCopied] = React.useState(false)
const [copiedWin, setCopiedWin] = React.useState(false)

const _handleCopy = (ins) => {
navigator.clipboard.writeText(ins);
}

const handleCopy = () => {
navigator.clipboard.writeText(install);
_handleCopy(install);
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 1300);
}

const handleCopyWin = () => {
_handleCopy(install_win);
setCopiedWin(true);
setTimeout(() => {
setCopiedWin(false);
}, 1300);
}

return (
<div className={clsx('w-full h-full bg-white text-zinc-700', koulen.variable)}>
<div className="pt-10 mx-auto lg:max-w-5xl">
Expand All @@ -50,7 +64,7 @@ export default function SendmePage() {

<div className='px-5 py-10 border-b flex-1 md:w-7/12'>
<h3 className='text-3xl font-koulen'>Install</h3>
<p className='mt-1 text-sm/6 text-gray-500'>Add sendme to your machine using shell:</p>
<p className='mt-1 text-sm/6 text-gray-500'>Add sendme to your machine using bash:</p>
<button className='text-xs md:text rounded bg-zinc-100 p-2 mt-2 flex plausible-event-name=Sendme+Copy+Install+Script+Click' onClick={handleCopy}>
<div className='grow mr-10 font-spaceMono'>$ {install}</div>
{copied
Expand All @@ -60,6 +74,16 @@ export default function SendmePage() {
? <ClipboardDocumentCheckIcon className="h-5 w-5 text-zinc-500" />
: <ClipboardDocumentIcon className="h-5 w-5 text-zinc-500" />}
</button>
<p className='mt-1 text-sm/6 text-gray-500'>On windows with PowerShell:</p>
<button className='text-xs md:text rounded bg-zinc-100 p-2 mt-2 flex plausible-event-name=Sendme+Copy+Install+Script+Click' onClick={handleCopyWin}>
<div className='grow mr-10 font-spaceMono'>$ {install_win}</div>
{copiedWin
? <span className='w-10 mr-1'>copied!</span>
: <span className='w-10 mr-1'></span> }
{copiedWin
? <ClipboardDocumentCheckIcon className="h-5 w-5 text-zinc-500" />
: <ClipboardDocumentIcon className="h-5 w-5 text-zinc-500" />}
</button>
<div className='mt-2 text-xs/6 text-gray-500'>
<p>This will copy the sendme binary to the path you ran the script from.<br />Run it with <pre className='font-mono text-sm/6 rounded bg-zinc-100 px-2 py-1 inline'>./sendme</pre> on unix systems</p>
</div>
Expand Down
Loading