Skip to content

Commit

Permalink
Unify copyrights, tidy for first release
Browse files Browse the repository at this point in the history
<microsoft/winget-cli#256> is a showstopper 
here, but have confirmed that the code in here is working
  • Loading branch information
thumperward committed May 20, 2020
1 parent 8202385 commit ce44be2
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 46 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# winget CHANGELOG
# `winget` CHANGELOG

This file is used to list changes made in each version of the `winget`
cookbook.

# 0.1.0
# 0.0.1

Initial release.

- Installation of `winget` executable
- `winget` resource to install arbitrary packages using `winget`
- Installation of WinGet executable
- `winget_package` resource to install arbitrary packages using WinGet
- Unit tests
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This cookbook installs [WinGet](https://github.com/microsoft/winget-cli) on a
Windows system and provides a custom resource for installing other packages
using WinGet.
using it.

## Requirements

Expand All @@ -15,7 +15,7 @@ include_recipe 'winget'

winget_package 'Install GIMP' do
id 'gimp.gimp'
name 'GNU Image Manipulation Program'
full_name 'GIMP 2.10.18'
action :install
end
```
Expand All @@ -28,16 +28,26 @@ end

- `id`: ID of the application to install. This must be an exact match.
Defaults to the resource name.
- `name`: the name the application uses in the Windows Programs applet. Used
to check if the application is already installed. Defaults to the `id`.
- `full_name`: the name the application uses in the Windows Programs applet.
Used to check if the application is already installed. Defaults to the
`id`.
- `version`: the specific version to install. Defaults to the latest version.
- `manifest`: if installing from a file rather than the Microsoft package
repository, the path to the manifest of the application. Defaults to empty.
- `override`: arguments to be passed on to the installer. Defaults to empty.
- `location`: location to install to (if supported).
repository, the path to the manifest of the application. Defaults to unset.
- `override`: arguments to be passed on to the installer. Defaults to unset.
- `location`: location to install to (if supported). Defaults to unset.

## Notes and caveats

- WinGet does not work correctly under WinRM and so Test Kitchen will fail
when trying to install a resource. As a workaround, you can log onto the
instance that was created and manually run `chef-zero` from the Test
Kitchen cache to complete the run. This is an upstream bug.

## TODO

- Add full support for existing options
- Find and implement a workaround for the WinRM / UWP issue, or wait for this
to be fixed in the upstream WinGet package.
- Add full support for existing options.
- Add support for extra features (uninstall, update) as they are added to
the upstream application
the upstream application.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
# Author:: Chris Cunningham (<[email protected]>)
# Cookbook:: winget
# Attributes:: default
#
Expand Down
3 changes: 0 additions & 3 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ suites:
- windows-10-virtualbox
# - windows-10-docker
# - windows-2016
# run_list:
# # - recipe[default]
# - test::default
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'winget'
maintainer 'Chris Cunningham'
maintainer_email 'thumperward@hotmail.com'
maintainer_email 'therealchriscunningham@outlook.com'
license 'Apache-2.0'
description 'Installs WinGet and adds a resource for WinGet packages'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
Expand Down
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
# Author:: Chris Cunningham (<[email protected]>)
# Cookbook:: winget
# Recipe:: default
#
Expand Down
20 changes: 10 additions & 10 deletions resources/package.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# Author:: Chris Cunningham (<thumperward@hotmail.com>)
# Author:: Chris Cunningham (<therealchriscunningham@outlook.com>)
# Cookbook:: winget
# Resource:: package
#
# Copyright:: 2019, Chris Cunningham
# Copyright:: 2020, Chris Cunningham
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,21 +18,21 @@
# limitations under the License.
#

# include Windows::Helper

property :id, String, name_property: true
property :name, String
property :full_name, String
property :version, String
property :manifest, String
property :override, String
property :location, String
# property :installed, [true, false], default: false, desired_state: false

# should be name, falling back to id
action :install do
unless node['packages'].keys.include?(new_resource.id)
execute "Install #{new_resource.id}" do
command "winget install #{new_resource.id} --id --exact"
new_resource.full_name = new_resource.full_name ?
new_resource.full_name :
new_resource.id

unless node['packages'].keys.include?(new_resource.full_name)
execute "Install #{new_resource.full_name}" do
command "winget install --id #{new_resource.id} --exact -h"
live_stream true
end
end
Expand Down
15 changes: 3 additions & 12 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
# Author:: Chris Cunningham (<[email protected]>)
# Cookbook:: winget
# Spec:: default
#
Expand All @@ -20,20 +21,10 @@
require 'spec_helper'

describe 'winget::default' do
context 'When all attributes are default, on Ubuntu 18.04' do
context 'When all attributes are default, on Windows 10' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'ubuntu', '18.04'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end

context 'When all attributes are default, on CentOS 7' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'centos', '7'
platform 'windows', '10.0.18363'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
Expand Down
4 changes: 2 additions & 2 deletions test/cookbooks/test/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'test'
maintainer 'Chef Software, Inc.'
maintainer_email '[email protected]'
maintainer 'Chris Cunningham'
maintainer_email '[email protected]'
license 'Apache-2.0'
version '0.0.1'

Expand Down
7 changes: 4 additions & 3 deletions test/cookbooks/test/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include_recipe 'winget'

winget_package 'Gimp' do
name 'gimp.gimp'
# action :install
winget_package 'gimp.gimp' do
full_name 'GIMP 2.10.18'
# version '2.10.18'
# action :install
end
4 changes: 2 additions & 2 deletions test/integration/default/default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
end
end

describe package('Gimp') do
it { should exist }
describe package('GIMP 2.10.18') do
it { should be_installed }
end

0 comments on commit ce44be2

Please sign in to comment.