Skip to content

Commit ce44be2

Browse files
committedMay 20, 2020
Unify copyrights, tidy for first release
<microsoft/winget-cli#256> is a showstopper here, but have confirmed that the code in here is working
1 parent 8202385 commit ce44be2

File tree

11 files changed

+47
-46
lines changed

11 files changed

+47
-46
lines changed
 

‎CHANGELOG.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# winget CHANGELOG
1+
# `winget` CHANGELOG
22

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

6-
# 0.1.0
6+
# 0.0.1
77

88
Initial release.
99

10-
- Installation of `winget` executable
11-
- `winget` resource to install arbitrary packages using `winget`
10+
- Installation of WinGet executable
11+
- `winget_package` resource to install arbitrary packages using WinGet
1212
- Unit tests

‎README.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
## Requirements
88

@@ -15,7 +15,7 @@ include_recipe 'winget'
1515

1616
winget_package 'Install GIMP' do
1717
id 'gimp.gimp'
18-
name 'GNU Image Manipulation Program'
18+
full_name 'GIMP 2.10.18'
1919
action :install
2020
end
2121
```
@@ -28,16 +28,26 @@ end
2828

2929
- `id`: ID of the application to install. This must be an exact match.
3030
Defaults to the resource name.
31-
- `name`: the name the application uses in the Windows Programs applet. Used
32-
to check if the application is already installed. Defaults to the `id`.
31+
- `full_name`: the name the application uses in the Windows Programs applet.
32+
Used to check if the application is already installed. Defaults to the
33+
`id`.
3334
- `version`: the specific version to install. Defaults to the latest version.
3435
- `manifest`: if installing from a file rather than the Microsoft package
35-
repository, the path to the manifest of the application. Defaults to empty.
36-
- `override`: arguments to be passed on to the installer. Defaults to empty.
37-
- `location`: location to install to (if supported).
36+
repository, the path to the manifest of the application. Defaults to unset.
37+
- `override`: arguments to be passed on to the installer. Defaults to unset.
38+
- `location`: location to install to (if supported). Defaults to unset.
39+
40+
## Notes and caveats
41+
42+
- WinGet does not work correctly under WinRM and so Test Kitchen will fail
43+
when trying to install a resource. As a workaround, you can log onto the
44+
instance that was created and manually run `chef-zero` from the Test
45+
Kitchen cache to complete the run. This is an upstream bug.
3846

3947
## TODO
4048

41-
- Add full support for existing options
49+
- Find and implement a workaround for the WinRM / UWP issue, or wait for this
50+
to be fixed in the upstream WinGet package.
51+
- Add full support for existing options.
4252
- Add support for extra features (uninstall, update) as they are added to
43-
the upstream application
53+
the upstream application.

‎attributes/default.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
# Author:: Chris Cunningham (<therealchriscunningham@outlook.com>)
23
# Cookbook:: winget
34
# Attributes:: default
45
#

‎kitchen.yml

-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ suites:
77
- windows-10-virtualbox
88
# - windows-10-docker
99
# - windows-2016
10-
# run_list:
11-
# # - recipe[default]
12-
# - test::default

‎metadata.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name 'winget'
22
maintainer 'Chris Cunningham'
3-
maintainer_email 'thumperward@hotmail.com'
3+
maintainer_email 'therealchriscunningham@outlook.com'
44
license 'Apache-2.0'
55
description 'Installs WinGet and adds a resource for WinGet packages'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))

‎recipes/default.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
# Author:: Chris Cunningham (<therealchriscunningham@outlook.com>)
23
# Cookbook:: winget
34
# Recipe:: default
45
#

‎resources/package.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#
2-
# Author:: Chris Cunningham (<thumperward@hotmail.com>)
2+
# Author:: Chris Cunningham (<therealchriscunningham@outlook.com>)
33
# Cookbook:: winget
44
# Resource:: package
55
#
6-
# Copyright:: 2019, Chris Cunningham
6+
# Copyright:: 2020, Chris Cunningham
77
#
88
# Licensed under the Apache License, Version 2.0 (the "License");
99
# you may not use this file except in compliance with the License.
@@ -18,21 +18,21 @@
1818
# limitations under the License.
1919
#
2020

21-
# include Windows::Helper
22-
2321
property :id, String, name_property: true
24-
property :name, String
22+
property :full_name, String
2523
property :version, String
2624
property :manifest, String
2725
property :override, String
2826
property :location, String
29-
# property :installed, [true, false], default: false, desired_state: false
3027

31-
# should be name, falling back to id
3228
action :install do
33-
unless node['packages'].keys.include?(new_resource.id)
34-
execute "Install #{new_resource.id}" do
35-
command "winget install #{new_resource.id} --id --exact"
29+
new_resource.full_name = new_resource.full_name ?
30+
new_resource.full_name :
31+
new_resource.id
32+
33+
unless node['packages'].keys.include?(new_resource.full_name)
34+
execute "Install #{new_resource.full_name}" do
35+
command "winget install --id #{new_resource.id} --exact -h"
3636
live_stream true
3737
end
3838
end

‎spec/unit/recipes/default_spec.rb

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
# Author:: Chris Cunningham (<therealchriscunningham@outlook.com>)
23
# Cookbook:: winget
34
# Spec:: default
45
#
@@ -20,20 +21,10 @@
2021
require 'spec_helper'
2122

2223
describe 'winget::default' do
23-
context 'When all attributes are default, on Ubuntu 18.04' do
24+
context 'When all attributes are default, on Windows 10' do
2425
# for a complete list of available platforms and versions see:
2526
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
26-
platform 'ubuntu', '18.04'
27-
28-
it 'converges successfully' do
29-
expect { chef_run }.to_not raise_error
30-
end
31-
end
32-
33-
context 'When all attributes are default, on CentOS 7' do
34-
# for a complete list of available platforms and versions see:
35-
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
36-
platform 'centos', '7'
27+
platform 'windows', '10.0.18363'
3728

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

‎test/cookbooks/test/metadata.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name 'test'
2-
maintainer 'Chef Software, Inc.'
3-
maintainer_email 'cookbooks@chef.io'
2+
maintainer 'Chris Cunningham'
3+
maintainer_email 'therealchriscunningham@outlook.com'
44
license 'Apache-2.0'
55
version '0.0.1'
66

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include_recipe 'winget'
22

3-
winget_package 'Gimp' do
4-
name 'gimp.gimp'
5-
# action :install
3+
winget_package 'gimp.gimp' do
4+
full_name 'GIMP 2.10.18'
5+
# version '2.10.18'
6+
# action :install
67
end

‎test/integration/default/default_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
end
1111
end
1212

13-
describe package('Gimp') do
14-
it { should exist }
13+
describe package('GIMP 2.10.18') do
14+
it { should be_installed }
1515
end

0 commit comments

Comments
 (0)
Please sign in to comment.