From 8030176910390ad3a11708692f4b66ae7217ad83 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Sun, 26 May 2024 23:30:15 +0800 Subject: [PATCH] =?UTF-8?q?npm=E9=9D=99=E6=80=81=E5=8C=96=E5=88=B0oss?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/staticNpm.ps1 | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 script/staticNpm.ps1 diff --git a/script/staticNpm.ps1 b/script/staticNpm.ps1 new file mode 100644 index 00000000..054267bc --- /dev/null +++ b/script/staticNpm.ps1 @@ -0,0 +1,86 @@ +if ((Get-Command "rclone" -ErrorAction SilentlyContinue) -eq $null) +{ + Write-Host "Unable to find rclone in your PATH" + + exit 1 +} + +if ((Get-Command "npm" -ErrorAction SilentlyContinue) -eq $null) +{ + Write-Host "Unable to find npm in your PATH" + + exit 1 +} + + + +$pkgName = Read-Host "Enter the package name(element-plus):" + +if ($pkgName -eq "") +{ + + $pkgName = "element-plus" +} + + + +$remotePrefix = read-host "Enter the remote prefix(coal://licoal/npm/):" + +if ($remotePrefix -eq "") +{ + $remotePrefix = "coal://licoal/npm/" +} + +# create tmp dir + +$tmpDir = New-Item -Type Directory -Force -Path "tmp" + + +Write-Host "tmpDir: $tmpDir" + +try +{ + + + Set-Location $tmpDir + + + Write-Host "npm install $pkgName --save" + npm install $pkgName --save + + + + $pkgDir = (npm ls $pkgName -p) + + Write-Host "pkgDir: $pkgDir" + + $pkgVersion = (npm view $pkgName version) + + Write-Host "pkgVersion: $pkgVersion" + + + $pkgName = (npm view $pkgName name) + + + $pkgDist = "$pkgDir/dist" + + Write-Host "pkgDist: $pkgDist" + + + Write-Host "rclone copy $pkgDist ${remotePrefix}${pkgName}@${pkgVersion}/ " + + rclone copy "$pkgDist" "${remotePrefix}${pkgName}@${pkgVersion}/" + + + +} +catch +{ + +} +finally +{ + Set-Location .. + Write-Host "Remove tmp dir" + Remove-Item -Path $tmpDir -Recurse -Force +}