diff --git a/CHANGELOG.md b/CHANGELOG.md index 838cff3..05a79c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 42e7b24..819322e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` @@ -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. diff --git a/attributes/default.rb b/attributes/default.rb index c14a46f..565f26b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,4 +1,5 @@ # +# Author:: Chris Cunningham () # Cookbook:: winget # Attributes:: default # diff --git a/kitchen.yml b/kitchen.yml index aba5aa6..2bfe59b 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -7,6 +7,3 @@ suites: - windows-10-virtualbox # - windows-10-docker # - windows-2016 - # run_list: - # # - recipe[default] - # - test::default diff --git a/metadata.rb b/metadata.rb index e0f57aa..1d671fb 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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')) diff --git a/recipes/default.rb b/recipes/default.rb index c0400a0..0bb205e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,4 +1,5 @@ # +# Author:: Chris Cunningham () # Cookbook:: winget # Recipe:: default # diff --git a/resources/package.rb b/resources/package.rb index 9a6598f..9416cf2 100644 --- a/resources/package.rb +++ b/resources/package.rb @@ -1,9 +1,9 @@ # -# Author:: Chris Cunningham () +# Author:: Chris Cunningham () # 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. @@ -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 diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 27fb7ee..58828cc 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -1,4 +1,5 @@ # +# Author:: Chris Cunningham () # Cookbook:: winget # Spec:: default # @@ -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 diff --git a/test/cookbooks/test/metadata.rb b/test/cookbooks/test/metadata.rb index cae1bc1..af0bc71 100644 --- a/test/cookbooks/test/metadata.rb +++ b/test/cookbooks/test/metadata.rb @@ -1,6 +1,6 @@ name 'test' -maintainer 'Chef Software, Inc.' -maintainer_email 'cookbooks@chef.io' +maintainer 'Chris Cunningham' +maintainer_email 'therealchriscunningham@outlook.com' license 'Apache-2.0' version '0.0.1' diff --git a/test/cookbooks/test/recipes/default.rb b/test/cookbooks/test/recipes/default.rb index bea639b..82ae727 100644 --- a/test/cookbooks/test/recipes/default.rb +++ b/test/cookbooks/test/recipes/default.rb @@ -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 diff --git a/test/integration/default/default_test.rb b/test/integration/default/default_test.rb index 3059cbf..e050037 100644 --- a/test/integration/default/default_test.rb +++ b/test/integration/default/default_test.rb @@ -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