I use this every time im working on new control for ud.
hope you find that useful .
function Update-PackageJsPackages {
param(
[Parameter()]
[string]$Path
)
begin{
$PackageHashTable = @{}
}
process{
$PackageFromJson = Get-Content -Path $Path | ConvertFrom-Json
$PackageDependencies = $PackageFromJson.dependencies.psobject.Properties | Select-Object -Property Name,Value
$PackageDevDependencies = $PackageFromJson.devDependencies.psobject.Properties | Select-Object -Property Name,Value
$PackageDependencies | ForEach-Object {
$Package = $_
$PackageLatestVersion = Invoke-RestMethod "https://unpkg.com/$($Package.Name)/package.json" | Select-Object -ExpandProperty Version
if($Package.Value -notmatch $PackageLatestVersion){
$($PackageFromJson.dependencies).$($Package.Name) = "^$($PackageLatestVersion)"
}
This file has been truncated. show original
1 Like
psDevUK
October 21, 2019, 12:29pm
2
Sorry may seem a thick question to those in the know. But you run this script pointing at at the current component you are trying to build? Like do you run this before or after you build your custom component?
you can run it after you finish creating your package.json file with the dependencies already in
1 Like