Skip to content

Commit

Permalink
Merge pull request #2567 from AdmiringWorm/nodejs-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored Nov 11, 2024
2 parents aefb7f0 + a7f1fc6 commit c6649c6
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 26 deletions.
1 change: 1 addition & 0 deletions automatic/nodejs.install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This package runs the official Node JS installer, resulting in Node.exe and NPM
## Notes

- While this package now provides both **Current** and **LTS** releases of Node.js, it is still recommended to use the [nodejs-lts][] package if only targeting the latest LTS release is required.
- Starting with version 23.x, installations for 32bit platforms are no longer supported. If this is required, an older version is required to be used.
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**

[nodejs-lts]: https://chocolatey.org/packages/nodejs-lts "Node.js LTS Package"
18 changes: 18 additions & 0 deletions automatic/nodejs.install/legal/VERIFICATION.full.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's content are trustworthy.

The installer/archive has been downloaded from the authors official download link listed on <https://nodejs.org/en/download/prebuilt-installer>
and can be verified using the following:

1. Download the following installers/archives
- 32-Bit: <DIRECT_32BIT_DOWNLOAD_URL>
- 64-Bit: <DIRECT_64BIT_DOWNLOAD_URL>
2. Use one of the following methods to obtain the checksum
- Use powershell function 'Get-FileHash'
- Use chocolatey utility 'checksum.exe'
3. Verify the downloaded installers/archives matches the following CHECKSUM_TYPE checksum:
- 32-Bit Checksum: <32BIT_CHECKSUM>
- 64-Bit Checksum: <64BIT_CHECKSUM>

Additionally, the included 'LICENSE.txt' have been obtained from <https://github.com/nodejs/node/blob/03023fa7ae060c082a014f792d5d1f481a599460/LICENSE>.
16 changes: 16 additions & 0 deletions automatic/nodejs.install/legal/VERIFICATION.x64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's content are trustworthy.

The installer/archive has been downloaded from the authors official download link listed on <https://nodejs.org/en/download/prebuilt-installer>
and can be verified using the following:

1. Download the following installers/archives
- 64-Bit: <DIRECT_64BIT_DOWNLOAD_URL>
2. Use one of the following methods to obtain the checksum
- Use powershell function 'Get-FileHash'
- Use chocolatey utility 'checksum.exe'
3. Verify the downloaded installers/archives matches the following CHECKSUM_TYPE checksum:
- 64-Bit Checksum: <64BIT_CHECKSUM>

Additionally, the included 'LICENSE.txt' have been obtained from <https://github.com/nodejs/node/blob/03023fa7ae060c082a014f792d5d1f481a599460/LICENSE>.
13 changes: 4 additions & 9 deletions automatic/nodejs.install/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
$ErrorActionPreference = 'Stop'
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition

$filePath32 = "$toolsPath\node-v20.18.0-x86.msi"
$filePath64 = "$toolsPath\node-v20.18.0-x64.msi"
$installFile = if ((Get-OSArchitectureWidth 64) -and $env:chocolateyForceX86 -ne 'true') {
Write-Host "Installing 64 bit version"; $filePath64 }
else { Write-Host "Installing 32 bit version"; $filePath32 }

$packageArgs = @{
PackageName = 'nodejs.install'
FileType = 'msi'
SoftwareName = 'Node.js'
File = $installFile
File = "$toolsPath\"
File64 = "$toolsPath\"
SilentArgs = '/quiet ADDLOCAL=ALL'
ValidExitCodes = @(0)
}
Install-ChocolateyInstallPackage @packageArgs

Remove-Item -Force $filePath32, $filePath64 -ea 0
Remove-Item -Force "$toolsPath\*.exe","$toolsPath\*.msi" -ea 0
50 changes: 34 additions & 16 deletions automatic/nodejs.install/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ Import-Module Chocolatey-AU

if ($MyInvocation.InvocationName -ne '.') {
# run the update only if the script is not sourced
function global:au_BeforeUpdate { Get-RemoteFiles -NoSuffix -Purge }
function global:au_BeforeUpdate {
Get-RemoteFiles -NoSuffix -Purge

if ($Latest.URL32) {
Copy-Item "$PSScriptRoot\legal\VERIFICATION.full.txt" "$PSScriptRoot\legal\VERIFICATION.txt" -Force
}
else {
Copy-Item "$PSScriptRoot\legal\VERIFICATION.x64.txt" "$PSScriptRoot\legal\VERIFICATION.txt" -Force
}
}
}

function global:au_SearchReplace {
Expand All @@ -15,20 +24,24 @@ function global:au_SearchReplace {
}
$silentArgs = "/quiet ADDLOCAL=ALL${silentArgs}"

$verificationReplacements = @{
"(?i)(64-Bit:).*" = "`$1 <$($Latest.URL64)>"
"(?i)(the following).*(checksum:)" = "`${1} $($Latest.ChecksumType64.ToUpper()) `$2"
"(?i)(64-Bit Checksum:).*" = "`$1 <$($Latest.Checksum64)>"
}

if ($Latest.URL32) {
$verificationReplacements['(?i)(32-Bit:).*'] = "`${1} <$($Latest.URL32)>"
$verificationReplacements['(?i)(32-Bit Checksum:).*'] = "`${1} <$($Latest.Checksum32)>"
}

@{
".\tools\chocolateyInstall.ps1" = @{
"(^[$]filePath32\s*=\s*`"[$]toolsPath\\)(.*)`"" = "`$1$($Latest.FileName32)`""
"(^[$]filePath64\s*=\s*`"[$]toolsPath\\)(.*)`"" = "`$1$($Latest.FileName64)`""
"(?i)(^\s*SilentArgs\s*=\s*)'.*'" = "`${1}'$silentArgs'"
}
".\legal\verification.txt" = @{
"(?i)(32-Bit.+)\<.*\>" = "`${1}<$($Latest.URL32)>"
"(?i)(64-Bit.+)\<.*\>" = "`${1}<$($Latest.URL64)>"
"(?i)(checksum type:\s+).*" = "`${1}$($Latest.ChecksumType32)"
"(?i)(checksum32:\s+).*" = "`${1}$($Latest.Checksum32)"
"(?i)(checksum64:\s+).*" = "`${1}$($Latest.Checksum64)"
"(?i)(\s*file\s*=\s*)[`"']([$]toolsPath\\)?.*"= if ($Latest.FileName32) { "`${1}`"`$toolsPath\$($Latest.FileName32)`"" } else { "`${1}''" }
"(?i)(^\s*file64\s*=\s*`"[$]toolsPath\\).*" = "`${1}$($Latest.FileName64)`""
"(?i)(^\s*SilentArgs\s*=\s*)'.*'" = "`${1}'$silentArgs'"
}
".\legal\verification.txt" = $verificationReplacements
}
}

Expand Down Expand Up @@ -63,11 +76,16 @@ function global:au_GetLatest {
$url32 = "https://nodejs.org/dist/$version/node-$version-x86.msi"
$url64 = "https://nodejs.org/dist/$version/node-$version-x64.msi"

$streams.Add($versionStrict.Major.ToString(), @{
Version = $versionStrict.ToString()
URL32 = $url32
URL64 = $url64
})
$streamData = @{
Version = $versionStrict.ToString()
URL64 = $url64
}

if ($versionStrict.Major -lt 23) {
$streamData['URL32'] = $url32
}

$streams.Add($versionStrict.Major.ToString(), $streamData)
}

return @{ Streams = $streams }
Expand Down
3 changes: 2 additions & 1 deletion automatic/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This package runs the official Node JS installer, resulting in Node.exe and NPM
## Notes

- While this package now provides both **Current** and **LTS** releases of Node.js, it is still recommended to use the [nodejs-lts][] package if only targeting the latest LTS release is required.
- - **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
- Starting with version 23.x, installations for 32bit platforms are no longer supported. If this is required, an older version is required to be used.
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**

[nodejs-lts]: https://chocolatey.org/packages/nodejs-lts "Node.js LTS Package"

0 comments on commit c6649c6

Please sign in to comment.