Skip to content
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

Merged
merged 2 commits into from
Jun 17, 2018
Merged

New: Add chocolatey files #91

merged 2 commits into from
Jun 17, 2018

Conversation

molant
Copy link
Contributor

@molant molant commented Jun 7, 2018

Fix #31

Here is what I have so far. I've tested the install/uninstall process and things seem to work fine. Haven't published the package yet.

I'll make some comments on the files (especially around the .nuspec) with questions I have.

Thanks!

Copy link
Contributor Author

@molant molant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the code in here comes from running choco new providing the url to the msi. I'm just filling the metadata and removing comments.

<id>nvs</id>
<version>1.4.2</version>
<packageSourceUrl>https://github.com/jasongin/nvs</packageSourceUrl>
<owners>jasongin molant</owners>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added you as a maintainer for the package as well.

<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>-->
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

<authors>jasongin</authors>
<projectUrl>https://github.com/jasongin/nvs</projectUrl>
<!--<iconUrl>http://cdn.rawgit.com/__REPLACE_YOUR_REPO__/master/icons/nvs.png</iconUrl>-->
<copyright>Microsoft 2018</copyright>
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.)

Copy link
Owner

@jasongin jasongin Jun 7, 2018

Choose a reason for hiding this comment

The 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.

<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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically copy paste of what you have in GitHub

$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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Owner

Choose a reason for hiding this comment

The 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.)

fileType = 'msi' #only one of these: exe, msi, msu
url = $url
# url64bit = $url64
#file = $fileLocation
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, will delete once I have the 👍

<metadata>
<!-- == PACKAGE SPECIFIC SECTION == -->
<id>nvs</id>
<version>1.4.2</version>
Copy link
Owner

Choose a reason for hiding this comment

The 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 package.json?

Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 package.json is updated should be fine.

Copy link
Owner

Choose a reason for hiding this comment

The 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.

To test this package locally you will need to:

1. Install [Chocolatey](https://chocolatey.org/install)
1. Open an elevated PowerShell window
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@molant molant Jun 7, 2018

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:

Installing the following packages:
nvs
By installing you accept licenses for the packages.
nvs not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\nvs\tools' is denied.
nvs package files install completed. Performing other installation steps.
No package information as package is null.
No package information to save as package is null.
The install of nvs was NOT successful.
nvs not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\nvs\tools' is denied.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - nvs (exited 1) - nvs not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\nvs\tools' is denied.
Exiting with 1

Copy link
Owner

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 in C:\ProgramData\chocolatey. Since I'm not very familiar with Chocolatey I don't know if that's expected or avoidable.

Copy link
Contributor Author

@molant molant Jun 7, 2018

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.

<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.
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Owner

Choose a reason for hiding this comment

The 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 nvs to your PATH.


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'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the checksum needs to be updated every release also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

validExitCodes= @(0, 3010, 1605, 1614, 1641) # https://msdn.microsoft.com/en-us/library/aa376931(v=vs.85).aspx
}

$uninstalled = $false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uninstalled variable doesn't appear to do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@molant
Copy link
Contributor Author

molant commented Jun 7, 2018

I've updated the PR with your feedback. I'll squash everything once you are OK.

@molant
Copy link
Contributor Author

molant commented Jun 14, 2018

@jasongin is there anything else I should change? Can I go ahead and start the publishing process while you merge this whenever you have the time?

@jasongin jasongin merged commit 5237fd2 into jasongin:master Jun 17, 2018
@jasongin
Copy link
Owner

Sorry for the delay. Merged!

@molant
Copy link
Contributor Author

molant commented Jun 18, 2018

Thanks!
I've started the publish process and is now awaiting moderation. I'll let you know once it's published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants