Created
April 26, 2023 07:18
-
-
Save BetimBeja/9f4a15a0daec19e5d689260c3103e09c to your computer and use it in GitHub Desktop.
track the changes for pcf-scripts and pcf-start NPM packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If(!(Test-Path "./PCF")){ | |
New-Item "./PCF" -ItemType Directory | |
} | |
Set-Location "./PCF" | |
If(!(Test-Path "./.git")){ | |
& git init | |
} | |
$pcfScripts = & npm view pcf-scripts versions --json | ConvertFrom-Json | |
$pcfStart = & npm view pcf-start versions --json | ConvertFrom-Json | |
$orphanPcfScripts = $pcfScripts | Where { $_ -notin $pcfStart } | |
$orphanPcfStart = $pcfStart | Where { $_ -notin $pcfScripts } | |
If($orphanPcfScripts.Length -gt 0){ | |
Write-Host "The following pcf-scripts versions are orphan: " $orphanPcfScripts | |
$pcfScripts = $pcfScripts | Where { $_ -notin $orphanPcfScripts } | |
} | |
If($orphanPcfStart.Length -gt 0){ | |
Write-Host "The following pcf-scripts versions are orphan: " $orphanPcfStrart | |
} | |
if(!(Test-Path "./package.json")){ | |
& npm init --y | |
& git add . | |
& git commit -m "Initialized Package" | |
& git tag 0.0.0 | |
} | |
& git checkout tags/0.0.0 | |
foreach ($version in $pcfScripts){ | |
if((& git tag --list $version).Length -gt 0){ | |
& git checkout tags/$version | |
continue; | |
} | |
If( Test-Path "./node_modules"){ | |
Remove-Item "./node_modules" -Recurse -Force | |
} | |
& npm install pcf-scripts@$version pcf-start@$version | |
$folders = Get-ChildItem "./node_modules/" | |
foreach($folder in $folders){ | |
if($folder.Name -in @(".bin", ".package-lock.json", "pcf-start","pcf-scripts")){ | |
continue; | |
} | |
Remove-Item "./node_modules/$folder" -Recurse -Force | |
} | |
& git add . | |
git commit -m "$version" | |
git tag $version | |
} | |
Set-Location ".." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment