Skip to content

Commit 5128d02

Browse files
committed
New: Add chocolatey files
Fix jasongin#31
1 parent 133bbbd commit 5128d02

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
!/doc/
1818
!/tools/
1919
!/setup/
20+
!/chocolatey/
2021

2122
# Temporary files generated during testing
2223
/test/temp

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Following are basic setup instructions. [For more details and options for settin
1212
### Windows
1313
A Windows Installer (MSI) package is available from the [NVS releases page on GitHub](https://github.com/jasongin/nvs/releases).
1414

15+
You can also use [chocolatey](https://chocolatey.org) to install it:
16+
```
17+
choco install nvs
18+
```
19+
1520
### Mac, Linux
1621
Specify the installation path, clone the repo, and *source* the `install` command:
1722
```

chocolatey/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# nvs chocolatey package
2+
3+
Chocolatey package for [nvs](https://github.com/jasongin/nvs/)
4+
5+
## Test the package locally
6+
7+
To test this package locally you will need to:
8+
9+
1. Install [Chocolatey](https://chocolatey.org/install)
10+
1. Open an elevated PowerShell window
11+
1. From the root of the project, execute `choco pack`
12+
1. Then run `choco install nvs -dv -s .`
13+
14+
For more information you can check the [Chocolatey documentation](https://chocolatey.org/docs/create-packages)

chocolatey/nvs.nuspec

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Read this before creating packages: https://chocolatey.org/docs/create-packages -->
3+
<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org (https://chocolatey.org/packages). -->
4+
5+
<!-- Test your packages in a test environment: https://github.com/chocolatey/chocolatey-test-environment -->
6+
7+
<!--
8+
This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Reference. Chocolatey uses a special version of NuGet.Core that allows us to do more than was initially possible. As such there are certain things to be aware of:
9+
10+
* the package xmlns schema url may cause issues with nuget.exe
11+
* Any of the following elements can ONLY be used by choco tools - projectSourceUrl, docsUrl, mailingListUrl, bugTrackerUrl, packageSourceUrl, provides, conflicts, replaces
12+
* nuget.exe can still install packages with those elements but they are ignored. Any authoring tools or commands will error on those elements
13+
-->
14+
15+
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
16+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
17+
<metadata>
18+
<!-- == PACKAGE SPECIFIC SECTION == -->
19+
<id>nvs</id>
20+
<version>1.4.2</version>
21+
<packageSourceUrl>https://github.com/jasongin/nvs</packageSourceUrl>
22+
<owners>jasongin molant</owners>
23+
<!-- ============================== -->
24+
25+
<!-- == SOFTWARE SPECIFIC SECTION == -->
26+
<!-- This section is about the software itself -->
27+
<title>nvs</title>
28+
<authors>jasongin</authors>
29+
<projectUrl>https://github.com/jasongin/nvs</projectUrl>
30+
<!--<iconUrl>http://cdn.rawgit.com/__REPLACE_YOUR_REPO__/master/icons/nvs.png</iconUrl>-->
31+
<copyright>Microsoft 2018</copyright>
32+
<!-- If there is a license Url available, it is required for the community feed -->
33+
<licenseUrl>https://github.com/jasongin/nvs/blob/master/LICENSE.txt</licenseUrl>
34+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
35+
<projectSourceUrl>https://github.com/jasongin/nvs</projectSourceUrl>
36+
<docsUrl>https://github.com/jasongin/nvs/tree/master/doc</docsUrl>
37+
<bugTrackerUrl>https://github.com/jasongin/nvs/issues</bugTrackerUrl>
38+
<tags>nvs nodejs node</tags>
39+
<summary>Node Version Switcher - A cross-platform tool for switching between versions and forks of Node.js </summary>
40+
<description>NVS is a cross-platform utility for switching between different versions and forks of [Node.js](http://nodejs.org/). NVS is itself written in node JavaScript.
41+
This tool is obviously inspired by other node version manager tools, especially [nvm](https://github.com/creationix/nvm), from which it borrows a lot of ideas and some command-line syntax.</description>
42+
</metadata>
43+
<files>
44+
<!-- this section controls what actually gets packaged into the Chocolatey package -->
45+
<file src="tools\**" target="tools" />
46+
</files>
47+
</package>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$ErrorActionPreference = 'Stop'; # stop on all errors
2+
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
3+
$url = 'https://github.com/jasongin/nvs/releases/download/v1.4.2/nvs-1.4.2.msi' # download url, HTTPS preferred
4+
# $url64 = '' # 64bit URL here (HTTPS preferred) or remove - if installer contains both (very rare), use $url
5+
6+
$packageArgs = @{
7+
packageName = $env:ChocolateyPackageName
8+
unzipLocation = $toolsDir
9+
fileType = 'msi' #only one of these: exe, msi, msu
10+
url = $url
11+
# url64bit = $url64
12+
#file = $fileLocation
13+
14+
softwareName = 'nvs' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique
15+
16+
checksum = '87fa567001baea5604e4be03188d6d11ae2a2e055781e5168da5ea2f0f8fb5479aa0c3511b641f5147ef7bbffe03cbff1a36588c1f37a8dd2c27010e24d0d3f9'
17+
checksumType = 'sha512' #default is md5, can also be sha1, sha256 or sha512
18+
# checksum64 = ''
19+
# checksumType64= 'sha256' #default is checksumType
20+
21+
# MSI
22+
silentArgs = "/quiet" # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0
23+
validExitCodes= @(0, 3010, 1641)
24+
}
25+
26+
Install-ChocolateyPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-package
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
$ErrorActionPreference = 'Stop'; # stop on all errors
2+
$packageArgs = @{
3+
packageName = $env:ChocolateyPackageName
4+
softwareName = 'nvs' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique
5+
fileType = 'msi' #only one of these: MSI or EXE (ignore MSU for now)
6+
# MSI
7+
silentArgs = "/qn /norestart"
8+
validExitCodes= @(0, 3010, 1605, 1614, 1641) # https://msdn.microsoft.com/en-us/library/aa376931(v=vs.85).aspx
9+
}
10+
11+
$uninstalled = $false
12+
13+
[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName']
14+
15+
if ($key.Count -eq 1) {
16+
$key | % {
17+
$packageArgs['file'] = "$($_.UninstallString)"
18+
if ($packageArgs['fileType'] -eq 'MSI') {
19+
# The Product Code GUID is all that should be passed for MSI, and very
20+
# FIRST, because it comes directly after /x, which is already set in the
21+
# Uninstall-ChocolateyPackage msiargs (facepalm).
22+
$packageArgs['silentArgs'] = "$($_.PSChildName) $($packageArgs['silentArgs'])"
23+
24+
# Don't pass anything for file, it is ignored for msi (facepalm number 2)
25+
# Alternatively if you need to pass a path to an msi, determine that and
26+
# use it instead of the above in silentArgs, still very first
27+
$packageArgs['file'] = ''
28+
}
29+
30+
Uninstall-ChocolateyPackage @packageArgs
31+
}
32+
} elseif ($key.Count -eq 0) {
33+
Write-Warning "$packageName has already been uninstalled by other means."
34+
} elseif ($key.Count -gt 1) {
35+
Write-Warning "$($key.Count) matches found!"
36+
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
37+
Write-Warning "Please alert package maintainer the following keys were matched:"
38+
$key | % {Write-Warning "- $($_.DisplayName)"}
39+
}

0 commit comments

Comments
 (0)