-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: Add chocolatey files #91
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
!/doc/ | ||
!/tools/ | ||
!/setup/ | ||
!/chocolatey/ | ||
|
||
# Temporary files generated during testing | ||
/test/temp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# nvs chocolatey package | ||
|
||
Chocolatey package for [nvs](https://github.com/jasongin/nvs/) | ||
|
||
## Test the package locally | ||
|
||
To test this package locally you will need to: | ||
|
||
1. Install [Chocolatey](https://chocolatey.org/install) | ||
1. Open an elevated PowerShell window | ||
1. From the root of the project, execute `choco pack` | ||
1. Then run `choco install nvs -dv -s .` | ||
|
||
For more information you can check the [Chocolatey documentation](https://chocolatey.org/docs/create-packages) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Read this before creating packages: https://chocolatey.org/docs/create-packages --> | ||
<!-- 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). --> | ||
|
||
<!-- Test your packages in a test environment: https://github.com/chocolatey/chocolatey-test-environment --> | ||
|
||
<!-- | ||
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: | ||
|
||
* the package xmlns schema url may cause issues with nuget.exe | ||
* Any of the following elements can ONLY be used by choco tools - projectSourceUrl, docsUrl, mailingListUrl, bugTrackerUrl, packageSourceUrl, provides, conflicts, replaces | ||
* nuget.exe can still install packages with those elements but they are ignored. Any authoring tools or commands will error on those elements | ||
--> | ||
|
||
<!-- 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. --> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<!-- == PACKAGE SPECIFIC SECTION == --> | ||
<id>nvs</id> | ||
<version>1.4.2</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this will this need to be manually updated whenever publishing a new version. Is there an easy way it could be pulled from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the version is also in the MSI URL in the install script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values need to be "hardcoded". I can probably write a script that updates it. Is just a question of ROI. If you are going to publish new versions regularly then I'll do it. If it's going to be once every few months I think that changing a couple values at the same time the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine for now. Releases aren't that frequent. If it gets annoying then I can script it. |
||
<packageSourceUrl>https://github.com/jasongin/nvs</packageSourceUrl> | ||
<owners>jasongin molant</owners> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added you as a maintainer for the package as well. |
||
<!-- ============================== --> | ||
|
||
<!-- == SOFTWARE SPECIFIC SECTION == --> | ||
<!-- This section is about the software itself --> | ||
<title>nvs</title> | ||
<authors>jasongin</authors> | ||
<projectUrl>https://github.com/jasongin/nvs</projectUrl> | ||
<!--<iconUrl>http://cdn.rawgit.com/__REPLACE_YOUR_REPO__/master/icons/nvs.png</iconUrl>--> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does nvs have a logo? I'm not sure what to put in here TBH. Need to check the documentation if it can be blank. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is not any logo. Maybe it could use the node.js logo? But I don't know if that would be appropriate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think we can use the nodejs logo for trademark issues. Will publish with out a logo, it's not required and they have a default one. |
||
<copyright>Microsoft 2018</copyright> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put Microsoft because the MIT license mentions the company. Not sure if this still applies or not as I haven't seen any of the regular things Microsoft projects have (CLA, CoC, etc.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally wrote nvs as part of my job on the Node.js runtime team at Microsoft. As a small tool, it was not required to comply with all the policies of larger company-sponsored open-source projects. And since then, I maintain it on my own time. |
||
<!-- If there is a license Url available, it is required for the community feed --> | ||
<licenseUrl>https://github.com/jasongin/nvs/blob/master/LICENSE.txt</licenseUrl> | ||
<requireLicenseAcceptance>true</requireLicenseAcceptance> | ||
<projectSourceUrl>https://github.com/jasongin/nvs</projectSourceUrl> | ||
<docsUrl>https://github.com/jasongin/nvs/tree/master/doc</docsUrl> | ||
<bugTrackerUrl>https://github.com/jasongin/nvs/issues</bugTrackerUrl> | ||
<tags>nvs nodejs node</tags> | ||
<summary>Node Version Switcher - A cross-platform tool for switching between versions and forks of Node.js </summary> | ||
<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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically copy paste of what you have in GitHub There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just keep the first sentence? I don't think the following sentences are a good fit for a package description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or is this meant to be more expansive README-style content? According to the doc it should probably indicate the installation target directory, and mention that it adds |
||
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> | ||
</metadata> | ||
<files> | ||
<!-- this section controls what actually gets packaged into the Chocolatey package --> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$ErrorActionPreference = 'Stop'; # stop on all errors | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$url = 'https://github.com/jasongin/nvs/releases/download/v1.4.2/nvs-1.4.2.msi' # download url, HTTPS preferred | ||
# $url64 = '' # 64bit URL here (HTTPS preferred) or remove - if installer contains both (very rare), use $url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know if the installer is x86 or x64. In any case with how things are everything works so once you confirm I can probably delete these commented lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MSI has dual x86/x64 support. (Maybe very rare but I had some background with MSI so I knew how to do it.) |
||
|
||
$packageArgs = @{ | ||
packageName = $env:ChocolateyPackageName | ||
unzipLocation = $toolsDir | ||
fileType = 'msi' #only one of these: exe, msi, msu | ||
url = $url | ||
# url64bit = $url64 | ||
#file = $fileLocation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before, will delete once I have the 👍 |
||
|
||
softwareName = 'nvs' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique | ||
|
||
checksum = '87fa567001baea5604e4be03188d6d11ae2a2e055781e5168da5ea2f0f8fb5479aa0c3511b641f5147ef7bbffe03cbff1a36588c1f37a8dd2c27010e24d0d3f9' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the checksum needs to be updated every release also? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
checksumType = 'sha512' #default is md5, can also be sha1, sha256 or sha512 | ||
# checksum64 = '' | ||
# checksumType64= 'sha256' #default is checksumType | ||
|
||
# MSI | ||
silentArgs = "/quiet" # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0 | ||
validExitCodes= @(0, 3010, 1641) | ||
} | ||
|
||
Install-ChocolateyPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-package |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
$ErrorActionPreference = 'Stop'; # stop on all errors | ||
$packageArgs = @{ | ||
packageName = $env:ChocolateyPackageName | ||
softwareName = 'nvs' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique | ||
fileType = 'msi' #only one of these: MSI or EXE (ignore MSU for now) | ||
# MSI | ||
silentArgs = "/qn /norestart" | ||
validExitCodes= @(0, 3010, 1605, 1614, 1641) # https://msdn.microsoft.com/en-us/library/aa376931(v=vs.85).aspx | ||
} | ||
|
||
$uninstalled = $false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, it came with the autogenerated scripts so I wasn't sure about removing it because maybe it's used somewhere else in the chocolatey process. I'll try removing it see what happens. |
||
|
||
[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName'] | ||
|
||
if ($key.Count -eq 1) { | ||
$key | % { | ||
$packageArgs['file'] = "$($_.UninstallString)" | ||
if ($packageArgs['fileType'] -eq 'MSI') { | ||
# The Product Code GUID is all that should be passed for MSI, and very | ||
# FIRST, because it comes directly after /x, which is already set in the | ||
# Uninstall-ChocolateyPackage msiargs (facepalm). | ||
$packageArgs['silentArgs'] = "$($_.PSChildName) $($packageArgs['silentArgs'])" | ||
|
||
# Don't pass anything for file, it is ignored for msi (facepalm number 2) | ||
# Alternatively if you need to pass a path to an msi, determine that and | ||
# use it instead of the above in silentArgs, still very first | ||
$packageArgs['file'] = '' | ||
} | ||
|
||
Uninstall-ChocolateyPackage @packageArgs | ||
} | ||
} elseif ($key.Count -eq 0) { | ||
Write-Warning "$packageName has already been uninstalled by other means." | ||
} elseif ($key.Count -gt 1) { | ||
Write-Warning "$($key.Count) matches found!" | ||
Write-Warning "To prevent accidental data loss, no programs will be uninstalled." | ||
Write-Warning "Please alert package maintainer the following keys were matched:" | ||
$key | % {Write-Warning "- $($_.DisplayName)"} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why elevated? Does the installer install the MSI in all-users mode by default? Or does it require elevation for some other reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy pasted the instructions for another project I'm working on and had trouble installing without elevation. If nvs can get installed without admin privileges then I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried testing locally without privileges and it fails:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nvs MSI can install either in a per-user location or a per-machine location, depending on the
ALLUSERS
property. For the per-user installation, it does not require elevation. From the error above it looks like Chocolatey requires elevation because it tries to put some files inC:\ProgramData\chocolatey
. Since I'm not very familiar with Chocolatey I don't know if that's expected or avoidable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've read it is expected. There's an option to install it with non admin privileges that will prevent it but that's not what most users do. Chocolatey installation docs.