Skip to content

Commit 79d9f2d

Browse files
authored
feat: add windows install script (#309)
* feat: add windows install script * cleanup * update wording
1 parent 4af25cf commit 79d9f2d

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

public/sendme.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$repo = "n0-computer/sendme"
2+
$release_url = "https://api.github.com/repos/$repo/releases/latest"
3+
4+
$target = "windows-x86_64"
5+
$zipFile = "sendme.zip"
6+
$extractPath = ".\sendme"
7+
8+
Write-Host "Fetching latest release for $target..."
9+
$releaseJson = Invoke-RestMethod -Uri $release_url
10+
$releaseUrl = ($releaseJson.assets | Where-Object { $_.browser_download_url -match $target }).browser_download_url
11+
12+
if (-not $releaseUrl) {
13+
Write-Host "Error: No release found for $target" -ForegroundColor Red
14+
exit 1
15+
}
16+
17+
Write-Host "Downloading from $releaseUrl..."
18+
Invoke-WebRequest -Uri $releaseUrl -OutFile $zipFile
19+
20+
Write-Host "Extracting..."
21+
Expand-Archive -Path $zipFile -DestinationPath $extractPath -Force
22+
23+
Write-Host "Cleaning up..."
24+
Remove-Item -Force $zipFile
25+
26+
Write-Host "Installation complete!"
27+
28+
# Add the 'sendme' folder to PATH
29+
$sendmePath = (Resolve-Path $extractPath).Path
30+
31+
# Add the folder to the PATH permanently (user level)
32+
$env:Path += ";$sendmePath"
33+
[System.Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)
34+
35+
Write-Host "'$sendmePath' has been permanently added to user PATH." -ForegroundColor Green

src/components/SendmePage.jsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@ const koulen = localFont({
2020

2121
export default function SendmePage() {
2222
const install = `curl -fsSL https://iroh.computer/sendme.sh | sh`
23+
const install_win = `iwr https://iroh.computer/sendme.ps1 -useb | iex`
2324
const [copied, setCopied] = React.useState(false)
25+
const [copiedWin, setCopiedWin] = React.useState(false)
26+
27+
const _handleCopy = (ins) => {
28+
navigator.clipboard.writeText(ins);
29+
}
2430

2531
const handleCopy = () => {
26-
navigator.clipboard.writeText(install);
32+
_handleCopy(install);
2733
setCopied(true);
2834
setTimeout(() => {
2935
setCopied(false);
3036
}, 1300);
3137
}
3238

39+
const handleCopyWin = () => {
40+
_handleCopy(install_win);
41+
setCopiedWin(true);
42+
setTimeout(() => {
43+
setCopiedWin(false);
44+
}, 1300);
45+
}
46+
3347
return (
3448
<div className={clsx('w-full h-full bg-white text-zinc-700', koulen.variable)}>
3549
<div className="pt-10 mx-auto lg:max-w-5xl">
@@ -50,7 +64,7 @@ export default function SendmePage() {
5064

5165
<div className='px-5 py-10 border-b flex-1 md:w-7/12'>
5266
<h3 className='text-3xl font-koulen'>Install</h3>
53-
<p className='mt-1 text-sm/6 text-gray-500'>Add sendme to your machine using shell:</p>
67+
<p className='mt-1 text-sm/6 text-gray-500'>Add sendme to your machine using bash:</p>
5468
<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}>
5569
<div className='grow mr-10 font-spaceMono'>$ {install}</div>
5670
{copied
@@ -60,6 +74,16 @@ export default function SendmePage() {
6074
? <ClipboardDocumentCheckIcon className="h-5 w-5 text-zinc-500" />
6175
: <ClipboardDocumentIcon className="h-5 w-5 text-zinc-500" />}
6276
</button>
77+
<p className='mt-1 text-sm/6 text-gray-500'>On windows with PowerShell:</p>
78+
<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}>
79+
<div className='grow mr-10 font-spaceMono'>$ {install_win}</div>
80+
{copiedWin
81+
? <span className='w-10 mr-1'>copied!</span>
82+
: <span className='w-10 mr-1'></span> }
83+
{copiedWin
84+
? <ClipboardDocumentCheckIcon className="h-5 w-5 text-zinc-500" />
85+
: <ClipboardDocumentIcon className="h-5 w-5 text-zinc-500" />}
86+
</button>
6387
<div className='mt-2 text-xs/6 text-gray-500'>
6488
<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>
6589
</div>

0 commit comments

Comments
 (0)