74 lines
2.7 KiB
PowerShell
74 lines
2.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Installs shared @deepseek-ai/* plugins from the Gitea npm registry into a
|
|
DSH profile and wires them into cordis.patch.yml.
|
|
|
|
.DESCRIPTION
|
|
Ensures the profile .npmrc maps the @deepseek-ai scope to the Gitea npm
|
|
registry, installs the three shared plugins into the profile, removes stale
|
|
link: dependencies, and idempotently appends insert rows to cordis.patch.yml.
|
|
|
|
.PARAMETER Profile
|
|
Profile name (directory under $DshHome\profiles). Default: 'web'.
|
|
|
|
.PARAMETER DshHome
|
|
DSH config root. Default: $env:DSH_HOME, else ~/.dsh.
|
|
|
|
.PARAMETER Token
|
|
Gitea token for the private npm registry. Default: $env:GITEA_NPM_TOKEN.
|
|
|
|
.EXAMPLE
|
|
.\scripts\dsh-plugin-install.ps1 -Token <GITEA_NPM_TOKEN>
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$Profile = 'web',
|
|
[string]$DshHome,
|
|
[string]$Token = $env:GITEA_NPM_TOKEN
|
|
)
|
|
|
|
$registry = 'https://git.byte-mate.ru/api/packages/Coder/npm/'
|
|
$plugins = @(
|
|
@{ Name = '@deepseek-ai/dsh-tool-lab'; Version = '0.1.0-rc.7'; Id = 'tool-lab' },
|
|
@{ Name = '@deepseek-ai/dsh-web-search-searxng'; Version = '0.1.0-rc.7'; Id = 'web-search-searxng' },
|
|
@{ Name = '@deepseek-ai/dsh-telegram-remote'; Version = '0.1.0'; Id = 'telegram-remote' }
|
|
)
|
|
|
|
if (-not $DshHome) { $DshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $HOME '.dsh' } }
|
|
$profileDir = Join-Path $DshHome "profiles\$Profile"
|
|
if (-not (Test-Path $profileDir)) {
|
|
Write-Error "Profile dir not found: $profileDir"
|
|
exit 1
|
|
}
|
|
Write-Host "Profile dir: $profileDir"
|
|
|
|
# 1. Ensure .npmrc scoped registry + token.
|
|
$npmrc = Join-Path $profileDir '.npmrc'
|
|
$npmrcLines = if (Test-Path $npmrc) { Get-Content $npmrc } else { @() }
|
|
$scopeLine = "@deepseek-ai:registry=$registry"
|
|
$authLine = "//$($registry -replace 'https://','')/:_authToken=$token"
|
|
if ($npmrcLines -notcontains $scopeLine) { $npmrcLines += $scopeLine }
|
|
if ($Token) {
|
|
$npmrcLines = ($npmrcLines | Where-Object { $_ -notlike '//*:_authToken=*' })
|
|
$npmrcLines += $authLine
|
|
}
|
|
Set-Content -Path $npmrc -Value $npmrcLines -Encoding ascii
|
|
Write-Host "Wrote $npmrc"
|
|
|
|
# 2. Remove stale link: dependencies.
|
|
& pnpm --dir $profileDir remove @deepseek-ai/dsh-web-search-searxng dsh-telegram-remote 2>$null | Out-Null
|
|
Write-Host "Removed stale link dependencies (if any)"
|
|
|
|
# 3. Install the shared plugins from the Gitea registry.
|
|
$specs = $plugins | ForEach-Object { "$($_.Name)@$($_.Version)" }
|
|
& pnpm --dir $profileDir add $specs
|
|
|
|
# 4. Idempotently append insert blocks to cordis.patch.yml.
|
|
$patchFile = Join-Path $profileDir 'cordis.patch.yml'
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
foreach ($p in $plugins) {
|
|
& node (Join-Path $scriptDir 'patch-cordis.mjs') --file $patchFile --name $p.Name --id $p.Id
|
|
}
|
|
|
|
Write-Host "`nDone. Plugins installed into $Profile profile. Restart dsh to load them."
|
|
exit 0 |