mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
npm静态化到oss脚本
This commit is contained in:
86
script/staticNpm.ps1
Normal file
86
script/staticNpm.ps1
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user