pdk 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -1
- data/README.md +54 -71
- data/exe/pdk +6 -1
- data/lib/pdk/answer_file.rb +2 -2
- data/lib/pdk/cli/exec.rb +22 -5
- data/lib/pdk/cli/new/module.rb +0 -3
- data/lib/pdk/cli/test/unit.rb +1 -0
- data/lib/pdk/cli/util/interview.rb +1 -1
- data/lib/pdk/cli/validate.rb +7 -2
- data/lib/pdk/generators/module.rb +27 -4
- data/lib/pdk/generators/puppet_object.rb +22 -2
- data/lib/pdk/logger.rb +1 -2
- data/lib/pdk/module/metadata.rb +2 -2
- data/lib/pdk/module/templatedir.rb +1 -1
- data/lib/pdk/tests/unit.rb +67 -23
- data/lib/pdk/util.rb +52 -0
- data/lib/pdk/util/bundler.rb +18 -7
- data/lib/pdk/validators/base_validator.rb +1 -1
- data/lib/pdk/validators/metadata/metadata_json_lint.rb +1 -0
- data/lib/pdk/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6dcde45f10e3958c18de937239e90bdd7f4a4b50
|
|
4
|
+
data.tar.gz: ed1a5dafcf13c2b7a40a028caf59625a4694b967
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4addbf8f2b767b3a5774b142acabf289710d6cb5eb7c0e32ef199dc352fe853b6e1291236ce3535ebf99f1c2173ef89d0643c0a489b90ad6a39aef315c9f99cb
|
|
7
|
+
data.tar.gz: 78ce8ece339647fbcbeda887b3a3e5af7fabd59a90afb7640bb638d5432a43841307cd079ba39a25874c7e02b4f5d3b8ddbd358ebf0ec322d1e79e1a90cec966
|
data/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,37 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## [v0.6.0](https://github.com/puppetlabs/pdk/tree/v0.6.0) (2017-08-08)
|
|
7
|
+
|
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.5.0...v0.6.0)
|
|
9
|
+
|
|
10
|
+
**Implemented enhancements:**
|
|
11
|
+
|
|
12
|
+
- \(MAINT\) Improve moduleroot error message [\#224](https://github.com/puppetlabs/pdk/pull/224) ([DavidS](https://github.com/DavidS))
|
|
13
|
+
- \(PDK-354\) Change PDK::Logger to write to STDERR [\#217](https://github.com/puppetlabs/pdk/pull/217) ([scotje](https://github.com/scotje))
|
|
14
|
+
- \(SDK-331\) Use vendored Gemfile.lock when available and needed [\#215](https://github.com/puppetlabs/pdk/pull/215) ([scotje](https://github.com/scotje))
|
|
15
|
+
- \(maint\) Expose message when FileUtils.mkdir\_p fails during module generation [\#209](https://github.com/puppetlabs/pdk/pull/209) ([rodjek](https://github.com/rodjek))
|
|
16
|
+
- \(SDK-323\) Change color of default answer to cyan [\#206](https://github.com/puppetlabs/pdk/pull/206) ([austb](https://github.com/austb))
|
|
17
|
+
- \(maint\) Remove unimplemented `add provider` from docs [\#200](https://github.com/puppetlabs/pdk/pull/200) ([DavidS](https://github.com/DavidS))
|
|
18
|
+
- Update PowerShell install instructions [\#194](https://github.com/puppetlabs/pdk/pull/194) ([jpogran](https://github.com/jpogran))
|
|
19
|
+
- \(maint\) Remove unused vcs option from 'pdk new module' [\#192](https://github.com/puppetlabs/pdk/pull/192) ([rodjek](https://github.com/rodjek))
|
|
20
|
+
- Document compatibility policy and upgrade strategy [\#188](https://github.com/puppetlabs/pdk/pull/188) ([turbodog](https://github.com/turbodog))
|
|
21
|
+
- \(MAINT\) Remove spinner for `bundle check` command [\#187](https://github.com/puppetlabs/pdk/pull/187) ([scotje](https://github.com/scotje))
|
|
22
|
+
- \(SDK-321\) add `pdk validate help` [\#183](https://github.com/puppetlabs/pdk/pull/183) ([DavidS](https://github.com/DavidS))
|
|
23
|
+
- \(SDK-317\) Ensure parent of 'pdk new module' is writable before generation [\#175](https://github.com/puppetlabs/pdk/pull/175) ([rodjek](https://github.com/rodjek))
|
|
24
|
+
- \(SDK-312\) Add option --parallel to `pdk test unit` [\#154](https://github.com/puppetlabs/pdk/pull/154) ([austb](https://github.com/austb))
|
|
25
|
+
|
|
26
|
+
**Fixed bugs:**
|
|
27
|
+
|
|
28
|
+
- \(SDK-325\) Validate all should run all validators [\#230](https://github.com/puppetlabs/pdk/pull/230) ([bmjen](https://github.com/bmjen))
|
|
29
|
+
- \(PDK-373\) Make test unit --list consistent with test unit [\#216](https://github.com/puppetlabs/pdk/pull/216) ([james-stocks](https://github.com/james-stocks))
|
|
30
|
+
- \(MAINT\) Add --strict-dependencies to metadata-json-lint invocation [\#213](https://github.com/puppetlabs/pdk/pull/213) ([scotje](https://github.com/scotje))
|
|
31
|
+
- \(SDK-317\) Replace File.writable? test with actually creating a test file [\#207](https://github.com/puppetlabs/pdk/pull/207) ([scotje](https://github.com/scotje))
|
|
32
|
+
- \(SDK-333\) Rescue Interrupt cleanly [\#199](https://github.com/puppetlabs/pdk/pull/199) ([scotje](https://github.com/scotje))
|
|
33
|
+
- \(\#137\) Nicer response when binary doesn't exist [\#149](https://github.com/puppetlabs/pdk/pull/149) ([rodjek](https://github.com/rodjek))
|
|
34
|
+
|
|
6
35
|
## [v0.5.0](https://github.com/puppetlabs/pdk/tree/v0.5.0) (2017-07-20)
|
|
36
|
+
|
|
7
37
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.4...v0.5.0)
|
|
8
38
|
|
|
9
39
|
**Implemented enhancements:**
|
|
@@ -16,6 +46,7 @@ All notable changes to this project will be documented in this file.
|
|
|
16
46
|
- \(SDK-331\) allow additional gems to be installed [\#178](https://github.com/puppetlabs/pdk/pull/178) ([DavidS](https://github.com/DavidS))
|
|
17
47
|
|
|
18
48
|
## [v0.4.4](https://github.com/puppetlabs/pdk/tree/v0.4.4) (2017-07-18)
|
|
49
|
+
|
|
19
50
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.3...v0.4.4)
|
|
20
51
|
|
|
21
52
|
**Fixed bugs:**
|
|
@@ -26,6 +57,7 @@ All notable changes to this project will be documented in this file.
|
|
|
26
57
|
- \(SDK-319\) force usage of our ruby [\#168](https://github.com/puppetlabs/pdk/pull/168) ([DavidS](https://github.com/DavidS))
|
|
27
58
|
|
|
28
59
|
## [v0.4.3](https://github.com/puppetlabs/pdk/tree/v0.4.3) (2017-07-17)
|
|
60
|
+
|
|
29
61
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.2...v0.4.3)
|
|
30
62
|
|
|
31
63
|
**Fixed bugs:**
|
|
@@ -33,6 +65,7 @@ All notable changes to this project will be documented in this file.
|
|
|
33
65
|
- \(FIXUP\) Fix default subprocess success/failure messages on Windows [\#164](https://github.com/puppetlabs/pdk/pull/164) ([scotje](https://github.com/scotje))
|
|
34
66
|
|
|
35
67
|
## [v0.4.2](https://github.com/puppetlabs/pdk/tree/v0.4.2) (2017-07-17)
|
|
68
|
+
|
|
36
69
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.1...v0.4.2)
|
|
37
70
|
|
|
38
71
|
**Fixed bugs:**
|
|
@@ -42,6 +75,7 @@ All notable changes to this project will be documented in this file.
|
|
|
42
75
|
- Use default username when Etc.getlogin fails [\#160](https://github.com/puppetlabs/pdk/pull/160) ([austb](https://github.com/austb))
|
|
43
76
|
|
|
44
77
|
## [v0.4.1](https://github.com/puppetlabs/pdk/tree/v0.4.1) (2017-07-14)
|
|
78
|
+
|
|
45
79
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.0...v0.4.1)
|
|
46
80
|
|
|
47
81
|
**Fixed bugs:**
|
|
@@ -49,6 +83,7 @@ All notable changes to this project will be documented in this file.
|
|
|
49
83
|
- \(FIXUP\) Resolve conflation of cachedir concepts [\#153](https://github.com/puppetlabs/pdk/pull/153) ([scotje](https://github.com/scotje))
|
|
50
84
|
|
|
51
85
|
## [v0.4.0](https://github.com/puppetlabs/pdk/tree/v0.4.0) (2017-07-14)
|
|
86
|
+
|
|
52
87
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.3.0...v0.4.0)
|
|
53
88
|
|
|
54
89
|
**Implemented enhancements:**
|
|
@@ -64,6 +99,7 @@ All notable changes to this project will be documented in this file.
|
|
|
64
99
|
- \(SDK-298\) Handle exception raised when an invalid report format is specified on the CLI [\#125](https://github.com/puppetlabs/pdk/pull/125) ([rodjek](https://github.com/rodjek))
|
|
65
100
|
|
|
66
101
|
## [v0.3.0](https://github.com/puppetlabs/pdk/tree/v0.3.0) (2017-06-29)
|
|
102
|
+
|
|
67
103
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.2.0...v0.3.0)
|
|
68
104
|
|
|
69
105
|
**Implemented enhancements:**
|
|
@@ -83,6 +119,7 @@ All notable changes to this project will be documented in this file.
|
|
|
83
119
|
- \(SDK-277\) Exit cleanly if pdk commands are run outside of a module [\#100](https://github.com/puppetlabs/pdk/pull/100) ([rodjek](https://github.com/rodjek))
|
|
84
120
|
|
|
85
121
|
## [v0.2.0](https://github.com/puppetlabs/pdk/tree/v0.2.0) (2017-06-21)
|
|
122
|
+
|
|
86
123
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.1.0...v0.2.0)
|
|
87
124
|
|
|
88
125
|
**Implemented enhancements:**
|
|
@@ -103,6 +140,7 @@ All notable changes to this project will be documented in this file.
|
|
|
103
140
|
- \(maint\) nokogiri: avoid versions without ruby 2.1 support [\#60](https://github.com/puppetlabs/pdk/pull/60) ([DavidS](https://github.com/DavidS))
|
|
104
141
|
|
|
105
142
|
## [v0.1.0](https://github.com/puppetlabs/pdk/tree/v0.1.0) (2017-06-05)
|
|
143
|
+
|
|
106
144
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/2be9329bed4715c888f273814b99f2cf37ee9341...v0.1.0)
|
|
107
145
|
|
|
108
146
|
**Implemented enhancements:**
|
|
@@ -126,4 +164,4 @@ All notable changes to this project will be documented in this file.
|
|
|
126
164
|
|
|
127
165
|
|
|
128
166
|
|
|
129
|
-
|
|
167
|
+
* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
1
|
-
# pdk [](https://travis-ci.org/puppetlabs/pdk) [](https://ci.appveyor.com/project/puppetlabs/pdk)
|
|
1
|
+
# pdk [](https://travis-ci.org/puppetlabs/pdk) [](https://ci.appveyor.com/project/puppetlabs/pdk) [](https://coveralls.io/github/puppetlabs/pdk?branch=master)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
A CLI to facilitate easy, unified development workflows for Puppet modules. pdk is a key part of the Puppet Development Kit, the shortest path to better modules.
|
|
4
|
+
A CLI to facilitate easy, unified development workflows for Puppet modules. `pdk` is a key part of the Puppet Development Kit, the shortest path to better modules.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
8
|
-
Download and install the newest package matching your platform from [here](https://drive.google.com/drive/folders/0Bz0tCHSb1u41alR4MmZfRHBTV1k?usp=sharing).
|
|
8
|
+
Download and install the newest package matching your platform from [here](https://drive.google.com/drive/folders/0Bz0tCHSb1u41alR4MmZfRHBTV1k?usp=sharing). If you are using Windows, please remember to close any open PowerShell windows.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Windows
|
|
11
|
+
|
|
12
|
+
On Windows you should run PDK from PowerShell and `pdk` will be available in your PowerShell prompt after installation.
|
|
13
|
+
|
|
14
|
+
If the `pdk` command does not appear, check that the `PuppetDevelopmentKit` PowerShell module is loaded in your PowerShell prompt:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Get-Module -Name PuppetDevelopmentKit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If no output is returned, load the `PuppetDevelopmentKit` module by running the following command:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Import-Module -Name PuppetDevelopmentKit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> Note: On PowerShell version 3 and above, PowerShell modules are loaded automatically so this step shouldn't be necessary.
|
|
27
|
+
|
|
28
|
+
You should set your script execution policy to at least [RemoteSigned](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.security/set-executionpolicy), if it's not already, to allow the PowerShell integration to work.
|
|
29
|
+
|
|
30
|
+
You can check your ExecutionPolicy by running the following command from a PowerShell prompt:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Get-ExecutionPolicy
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To set the `ExecutionPolicy`, run the following command:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If you can't change the system `ExecutionPolicy`, you can change the `ExecutionPolicy` for just the current session by using the `Scope` paramter:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For more information about PowerShell `ExecutionPolicies` or how to change them, see [about_Execution_Policies](http://go.microsoft.com/fwlink/?LinkID=135170).
|
|
11
49
|
|
|
12
50
|
## Usage
|
|
13
51
|
|
|
@@ -98,7 +136,7 @@ Generates a new module.
|
|
|
98
136
|
Usage:
|
|
99
137
|
|
|
100
138
|
```
|
|
101
|
-
pdk new module [--template-url=git_url] [--license=spdx_identifier]
|
|
139
|
+
pdk new module [--template-url=git_url] [--license=spdx_identifier] module_name [target_dir]
|
|
102
140
|
```
|
|
103
141
|
|
|
104
142
|
The `pdk new module` command accepts the following arguments and options. Arguments are optional unless otherwise specified.
|
|
@@ -111,10 +149,6 @@ Overrides the template to use for this module. If possible, please contribute yo
|
|
|
111
149
|
|
|
112
150
|
Specifies the license this module is written under. See https://spdx.org/licenses/ for a list of open source licenses, or use `proprietary`. Defaults to `Apache-2.0`.
|
|
113
151
|
|
|
114
|
-
#### `--vcs=vcs_provider`
|
|
115
|
-
|
|
116
|
-
Specifies the version control driver. Valid values: `git`, `none`. Default: `git`.
|
|
117
|
-
|
|
118
152
|
#### `--skip-interview`
|
|
119
153
|
|
|
120
154
|
Suppress interactive queries for initial values. All questions will use the default values.
|
|
@@ -166,30 +200,6 @@ to be added to the generated class. Optionally, the data type of the parameter
|
|
|
166
200
|
can be specified along with the parameter name, separated by a colon. Any
|
|
167
201
|
number of parameters can be provided on the command line.
|
|
168
202
|
|
|
169
|
-
### `pdk add provider` command
|
|
170
|
-
|
|
171
|
-
Adds a new resource provider to an existing module.
|
|
172
|
-
|
|
173
|
-
Usage:
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
pdk add provider [--template-url=git_url] provider_name [data_type:attribute_name]*
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
The `pdk add provider` command accepts the following arguments. Arguments are optional unless specified.
|
|
180
|
-
|
|
181
|
-
#### `--template-url=git_url`
|
|
182
|
-
|
|
183
|
-
Overrides the template to use for this module. If possible please contribute your improvements back to the default template at [puppetlabs/pdk](https://github.com/puppetlabs/pdk).
|
|
184
|
-
|
|
185
|
-
#### `provider_name`
|
|
186
|
-
|
|
187
|
-
**Required**. Specifies the name of the resource provider being created.
|
|
188
|
-
|
|
189
|
-
#### `data_type:attribute_name`
|
|
190
|
-
|
|
191
|
-
Specifies a list of attributes with their expected data types, such as `'Enum[absent, present]:ensure'`. If not specified, the data type will have no attributes.
|
|
192
|
-
|
|
193
203
|
### `pdk validate` command
|
|
194
204
|
|
|
195
205
|
Runs all static validations. Any errors are reported to the console in the format requested. The exit code is non-zero when errors occur.
|
|
@@ -293,48 +303,21 @@ rake build # Build puppet module package
|
|
|
293
303
|
[...]
|
|
294
304
|
```
|
|
295
305
|
|
|
296
|
-
##
|
|
297
|
-
|
|
298
|
-
In cases where `pdk` needs to run in a working directory outside the cloned repository, either set `BUNDLE_GEMFILE` to the pdk's Gemfile location, or install and use the [binstubs of bundler](http://bundler.io/v1.15/bundle_binstubs.html), which are small proxy binaries, that set up the environment for running the tool.
|
|
299
|
-
|
|
300
|
-
```
|
|
301
|
-
# assuming ~/bin is already on your path:
|
|
302
|
-
$ bundle binstubs pdk --path ~/bin
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/pdk/issues.
|
|
306
|
+
## Module Compatibility
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
**PDK Version Compatibility:** modules created with a specific PDK version should validate against and run on all Puppet andRuby version combinations currently under maintenance (see https://docs.puppet.com/puppet/latest/about_agent.html and https://puppet.com/misc/puppet-enterprise-lifecycle)
|
|
308
309
|
|
|
309
|
-
|
|
310
|
+
**Module Template Compatibility:** Modules created with a specific version of the PDK will remain compatible to newer versions of the PDK with the following exceptions:
|
|
311
|
+
* access to new PDK functionality might require an update of the module to the current Template version
|
|
312
|
+
* access to a new major PDK version might require an update of the module to the current Template version, after a one year deprecation cycle
|
|
313
|
+
* validation against new Puppet versions might require new PDK functionality, a new major PDK version, and changes to the module itself.
|
|
310
314
|
|
|
311
|
-
|
|
315
|
+
## Upgrading
|
|
316
|
+
* In the common case, Puppet and the PDK will be forward-compatible so that minor Puppet updates will not require a new version of the PDK.
|
|
317
|
+
* Some new Puppet versions will require changes to the PDK. In that case, upgrading the PDK for validation prior to roll-out of Puppet is strongly recommended.
|
|
312
318
|
|
|
313
|
-
Run unit tests.
|
|
314
319
|
|
|
315
|
-
#### acceptance:local
|
|
316
320
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
#### acceptance:package
|
|
320
|
-
|
|
321
|
-
Run acceptance tests against a package install. This task is for Puppet's packaging CI, and contributors outside of Puppet, Inc. don't need to worry about executing it. It uses [beaker](https://github.com/puppetlabs/beaker) to provision a VM, fetch and install a pdk installation package, and then run the acceptance tests on that VM.
|
|
322
|
-
It requires some environment variables to be set in order to specify what beaker will set up:
|
|
323
|
-
|
|
324
|
-
Environment Variable | Usage
|
|
325
|
-
---------------------|------
|
|
326
|
-
**SHA** | The SHA or tag of a package build i.e. the folder name on the build server that packages will be found in.
|
|
327
|
-
**TEST_TARGET** | A beaker-hostgenerator string for the OS of the VM you want to test on e.g. _redhat7-64workstation._ or _windows2012r2-64workstation._ (The period character after workstation is required by beaker-hostgenerator).
|
|
328
|
-
**BUILD_SERVER** | (Only required if the tests will run on a Windows VM). The hostname of the build server that hosts packages. A Puppet JIRA ticket ([BKR-1109](https://tickets.puppetlabs.com/browse/BKR-1109)) has been filed to update beaker so this would never be required.
|
|
329
|
-
|
|
330
|
-
On completion of this testing task, the results from the VM will be available in a folder named _archive_.
|
|
331
|
-
|
|
332
|
-
### Release Process
|
|
321
|
+
## Contributing
|
|
333
322
|
|
|
334
|
-
|
|
335
|
-
1. In a clean checkout of master, run `bundle exec rake changelog`.
|
|
336
|
-
1. Edit PR titles and tags, until `bundle exec rake changelog` output makes sense.
|
|
337
|
-
1. Commit and PR the changes.
|
|
338
|
-
1. When the PR is merged, get a clean checkout of the merged commit, and run `bundle exec rake release[upstream]` (where "upstream" is your local name of the puppetlabs remote)
|
|
339
|
-
1. Profit!
|
|
340
|
-
1. Update `lib/pdk/version.rb` with `x.y.z.pre` version bump, commit, and PR to prepare for next release.
|
|
323
|
+
See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
data/exe/pdk
CHANGED
data/lib/pdk/answer_file.rb
CHANGED
|
@@ -13,8 +13,8 @@ module PDK
|
|
|
13
13
|
#
|
|
14
14
|
# @param path [String] A path on disk to the file where the PDK should store
|
|
15
15
|
# answers to interactive questions.
|
|
16
|
-
def self.answer_file=(
|
|
17
|
-
@answer_file = PDK::AnswerFile.new(
|
|
16
|
+
def self.answer_file=(path)
|
|
17
|
+
@answer_file = PDK::AnswerFile.new(path)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
class AnswerFile
|
data/lib/pdk/cli/exec.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'bundler'
|
|
|
2
2
|
require 'childprocess'
|
|
3
3
|
require 'tempfile'
|
|
4
4
|
require 'tty-spinner'
|
|
5
|
+
require 'tty-which'
|
|
5
6
|
|
|
6
7
|
require 'pdk/util'
|
|
7
8
|
|
|
@@ -12,22 +13,35 @@ module PDK
|
|
|
12
13
|
Command.new(*cmd).execute!
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def self.ensure_bin_present!(bin_path, bin_name)
|
|
17
|
+
message = _('Unable to find `%{name}`. Check that it is installed and try again.') % {
|
|
18
|
+
name: bin_name,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
raise PDK::CLI::FatalError, message unless TTY::Which.exist?(bin_path)
|
|
22
|
+
end
|
|
23
|
+
|
|
15
24
|
def self.git_bindir
|
|
16
25
|
@git_dir ||= File.join('private', 'git', Gem.win_platform? ? 'cmd' : 'bin')
|
|
17
26
|
end
|
|
18
27
|
|
|
19
|
-
def self.
|
|
28
|
+
def self.git_bin
|
|
20
29
|
git_bin = Gem.win_platform? ? 'git.exe' : 'git'
|
|
21
30
|
vendored_bin_path = File.join(git_bindir, git_bin)
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
try_vendored_bin(vendored_bin_path, git_bin)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.git(*args)
|
|
36
|
+
ensure_bin_present!(git_bin, 'git')
|
|
37
|
+
|
|
38
|
+
execute(git_bin, *args)
|
|
24
39
|
end
|
|
25
40
|
|
|
26
41
|
def self.bundle(*args)
|
|
27
|
-
bundle_bin
|
|
28
|
-
vendored_bin_path = File.join('private', 'ruby', '2.1.9', 'bin', bundle_bin)
|
|
42
|
+
ensure_bin_present!(bundle_bin, 'bundler')
|
|
29
43
|
|
|
30
|
-
execute(
|
|
44
|
+
execute(bundle_bin, *args)
|
|
31
45
|
end
|
|
32
46
|
|
|
33
47
|
def self.bundle_bin
|
|
@@ -156,6 +170,7 @@ module PDK
|
|
|
156
170
|
stdout: @stdout.read,
|
|
157
171
|
stderr: @stderr.read,
|
|
158
172
|
exit_code: @process.exit_code,
|
|
173
|
+
duration: @duration,
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
return process_data
|
|
@@ -169,6 +184,7 @@ module PDK
|
|
|
169
184
|
def run_process!
|
|
170
185
|
command_string = argv.join(' ')
|
|
171
186
|
PDK.logger.debug(_("Executing '%{command}'") % { command: command_string })
|
|
187
|
+
start_time = Time.now
|
|
172
188
|
begin
|
|
173
189
|
@process.start
|
|
174
190
|
rescue ChildProcess::LaunchError => e
|
|
@@ -185,6 +201,7 @@ module PDK
|
|
|
185
201
|
# Wait indfinitely if no timeout set.
|
|
186
202
|
@process.wait
|
|
187
203
|
end
|
|
204
|
+
@duration = Time.now - start_time
|
|
188
205
|
end
|
|
189
206
|
end
|
|
190
207
|
|
data/lib/pdk/cli/new/module.rb
CHANGED
|
@@ -10,8 +10,6 @@ module PDK::CLI
|
|
|
10
10
|
option nil, 'license', _('Specifies the license this module is written under. ' \
|
|
11
11
|
"This should be a identifier from https://spdx.org/licenses/. Common values are 'Apache-2.0', 'MIT', or 'proprietary'."), argument: :required
|
|
12
12
|
|
|
13
|
-
option nil, 'vcs', _("Specifies the version control driver. Valid values: 'git', 'none'. Default: 'git'."), argument: :required
|
|
14
|
-
|
|
15
13
|
flag nil, 'skip-interview', _('When specified, skips interactive querying of metadata.')
|
|
16
14
|
|
|
17
15
|
run do |opts, args, _cmd|
|
|
@@ -35,7 +33,6 @@ module PDK::CLI
|
|
|
35
33
|
|
|
36
34
|
opts[:name] = module_name
|
|
37
35
|
opts[:target_dir] = target_dir.nil? ? module_name : target_dir
|
|
38
|
-
opts[:vcs] ||= 'git'
|
|
39
36
|
|
|
40
37
|
PDK.logger.info(_('Creating new module: %{modname}') % { modname: module_name })
|
|
41
38
|
PDK::Generate::Module.invoke(opts)
|
data/lib/pdk/cli/test/unit.rb
CHANGED
|
@@ -8,6 +8,7 @@ module PDK::CLI
|
|
|
8
8
|
summary _('Run unit tests.')
|
|
9
9
|
|
|
10
10
|
flag nil, :list, _('list all available unit tests and their descriptions')
|
|
11
|
+
flag nil, :parallel, _('run unit tests in parallel'), hidden: true
|
|
11
12
|
|
|
12
13
|
option nil, :tests, _('a comma-separated list of tests to run'), argument: :required, default: '' do |values|
|
|
13
14
|
PDK::CLI::Util::OptionValidator.comma_separated_list?(values)
|
data/lib/pdk/cli/validate.rb
CHANGED
|
@@ -17,6 +17,11 @@ module PDK::CLI
|
|
|
17
17
|
flag :a, 'auto-correct', _('automatically correct problems (where possible)')
|
|
18
18
|
|
|
19
19
|
run do |opts, args, _cmd|
|
|
20
|
+
if args == ['help']
|
|
21
|
+
PDK::CLI.run(['validate', '--help'])
|
|
22
|
+
exit 0
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
validator_names = PDK::Validate.validators.map { |v| v.name }
|
|
21
26
|
validators = PDK::Validate.validators
|
|
22
27
|
targets = []
|
|
@@ -77,8 +82,8 @@ module PDK::CLI
|
|
|
77
82
|
PDK::Util::Bundler.ensure_bundle!
|
|
78
83
|
|
|
79
84
|
validators.each do |validator|
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
validator_exit_code = validator.invoke(report, options)
|
|
86
|
+
exit_code = validator_exit_code if validator_exit_code != 0
|
|
82
87
|
end
|
|
83
88
|
|
|
84
89
|
report_formats.each do |format|
|
|
@@ -24,6 +24,18 @@ module PDK
|
|
|
24
24
|
raise PDK::CLI::FatalError, _("The destination directory '%{dir}' already exists") % { dir: target_dir }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
parent_dir = File.dirname(target_dir)
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
test_file = File.join(parent_dir, '.pdk-test-writable')
|
|
31
|
+
File.open(test_file, 'w') { |f| f.write('This file was created by the Puppet Development Kit to test if this folder was writable, you can safely remove this file.') }
|
|
32
|
+
FileUtils.rm_f(test_file)
|
|
33
|
+
rescue Errno::EACCES
|
|
34
|
+
raise PDK::CLI::FatalError, _("You do not have permission to write to '%{parent_dir}'") % {
|
|
35
|
+
parent_dir: parent_dir,
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
27
39
|
metadata = prepare_metadata(opts)
|
|
28
40
|
|
|
29
41
|
temp_target_dir = PDK::Util.make_tmpdir_name('pdk-module-target')
|
|
@@ -50,7 +62,15 @@ module PDK
|
|
|
50
62
|
|
|
51
63
|
PDK.answers.update!('template-url' => template_url)
|
|
52
64
|
|
|
53
|
-
|
|
65
|
+
begin
|
|
66
|
+
FileUtils.mv(temp_target_dir, target_dir)
|
|
67
|
+
rescue Errno::EACCES => e
|
|
68
|
+
raise PDK::CLI::FatalError, _("Failed to move '%{source}' to '%{target}': %{message}") % {
|
|
69
|
+
source: temp_target_dir,
|
|
70
|
+
target: target_dir,
|
|
71
|
+
message: e.message,
|
|
72
|
+
}
|
|
73
|
+
end
|
|
54
74
|
end
|
|
55
75
|
|
|
56
76
|
def self.username_from_login
|
|
@@ -97,8 +117,11 @@ module PDK
|
|
|
97
117
|
].each do |dir|
|
|
98
118
|
begin
|
|
99
119
|
FileUtils.mkdir_p(dir)
|
|
100
|
-
rescue SystemCallError
|
|
101
|
-
raise PDK::CLI::FatalError, _("Unable to create directory '%{dir}'") % {
|
|
120
|
+
rescue SystemCallError => e
|
|
121
|
+
raise PDK::CLI::FatalError, _("Unable to create directory '%{dir}': %{message}") % {
|
|
122
|
+
dir: dir,
|
|
123
|
+
message: e.message,
|
|
124
|
+
}
|
|
102
125
|
end
|
|
103
126
|
end
|
|
104
127
|
end
|
|
@@ -165,7 +188,7 @@ module PDK
|
|
|
165
188
|
},
|
|
166
189
|
]
|
|
167
190
|
|
|
168
|
-
prompt = TTY::Prompt.new
|
|
191
|
+
prompt = TTY::Prompt.new(help_color: :cyan)
|
|
169
192
|
|
|
170
193
|
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
171
194
|
|
|
@@ -44,7 +44,7 @@ module PDK
|
|
|
44
44
|
|
|
45
45
|
# @abstract Subclass and implement {#template_data} to provide data to
|
|
46
46
|
# the templates during rendering. Implementations of this method should
|
|
47
|
-
# return a Hash
|
|
47
|
+
# return a Hash!{Symbol => Object}.
|
|
48
48
|
def template_data
|
|
49
49
|
raise NotImplementedError
|
|
50
50
|
end
|
|
@@ -79,6 +79,7 @@ module PDK
|
|
|
79
79
|
# point for the class.
|
|
80
80
|
#
|
|
81
81
|
# @raise [PDK::CLI::FatalError] if the target files already exist.
|
|
82
|
+
# @raise [PDK::CLI::FatalError] (see #render_file)
|
|
82
83
|
#
|
|
83
84
|
# @api public
|
|
84
85
|
def run
|
|
@@ -105,14 +106,33 @@ module PDK
|
|
|
105
106
|
# @param data [Hash{Object => Object}] The data to be provided to the
|
|
106
107
|
# template when rendering.
|
|
107
108
|
#
|
|
109
|
+
# @raise [PDK::CLI::FatalError] if the parent directories to `dest_path`
|
|
110
|
+
# do not exist and could not be created.
|
|
111
|
+
# @raise [PDK::CLI::FatalError] if the rendered file could not be written
|
|
112
|
+
# to `dest_path`.
|
|
113
|
+
#
|
|
108
114
|
# @return [void]
|
|
109
115
|
#
|
|
110
116
|
# @api private
|
|
111
117
|
def render_file(dest_path, template_path, data)
|
|
112
118
|
PDK.logger.info(_("Creating '%{file}' from template.") % { file: dest_path })
|
|
113
119
|
file_content = PDK::TemplateFile.new(template_path, data).render
|
|
114
|
-
|
|
120
|
+
|
|
121
|
+
begin
|
|
122
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
|
123
|
+
rescue SystemCallError => e
|
|
124
|
+
raise PDK::CLI::FatalError, _("Unable to create directory '%{path}': %{message}") % {
|
|
125
|
+
path: File.dirname(dest_path),
|
|
126
|
+
message: e.message,
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
|
|
115
130
|
File.open(dest_path, 'w') { |f| f.write file_content }
|
|
131
|
+
rescue SystemCallError => e
|
|
132
|
+
raise PDK::CLI::FatalError, _("Unable to write to file '%{path}': %{message}") % {
|
|
133
|
+
path: dest_path,
|
|
134
|
+
message: e.message,
|
|
135
|
+
}
|
|
116
136
|
end
|
|
117
137
|
|
|
118
138
|
# Search the possible template directories in order of preference to find
|
data/lib/pdk/logger.rb
CHANGED
data/lib/pdk/module/metadata.rb
CHANGED
|
@@ -178,7 +178,7 @@ module PDK
|
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
unless File.directory?(@moduleroot_dir) # rubocop:disable Style/GuardClause
|
|
181
|
-
raise ArgumentError, _("The template at '%{path}' does not contain a moduleroot directory") % { path: @path }
|
|
181
|
+
raise ArgumentError, _("The template at '%{path}' does not contain a 'moduleroot/' directory") % { path: @path }
|
|
182
182
|
end
|
|
183
183
|
end
|
|
184
184
|
|
data/lib/pdk/tests/unit.rb
CHANGED
|
@@ -6,9 +6,16 @@ require 'json'
|
|
|
6
6
|
module PDK
|
|
7
7
|
module Test
|
|
8
8
|
class Unit
|
|
9
|
-
def self.cmd(_tests)
|
|
9
|
+
def self.cmd(_tests, opts = {})
|
|
10
10
|
# TODO: test selection
|
|
11
|
-
|
|
11
|
+
rake_task = opts.key?(:parallel) ? 'parallel_spec' : 'spec'
|
|
12
|
+
[File.join(PDK::Util.module_root, 'bin', 'rake'), rake_task]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.parallel_with_no_tests?(ran_in_parallel, json_result, result)
|
|
16
|
+
ran_in_parallel && json_result.empty? &&
|
|
17
|
+
!result[:exit_code].zero? &&
|
|
18
|
+
result[:stderr].strip =~ %r{Pass files or folders to run$}
|
|
12
19
|
end
|
|
13
20
|
|
|
14
21
|
def self.invoke(report, options = {})
|
|
@@ -17,12 +24,13 @@ module PDK
|
|
|
17
24
|
|
|
18
25
|
tests = options.fetch(:tests)
|
|
19
26
|
|
|
20
|
-
cmd_argv = cmd(tests)
|
|
27
|
+
cmd_argv = cmd(tests, options)
|
|
21
28
|
cmd_argv.unshift('ruby') if Gem.win_platform?
|
|
22
29
|
|
|
23
30
|
command = PDK::CLI::Exec::Command.new(*cmd_argv).tap do |c|
|
|
24
31
|
c.context = :module
|
|
25
|
-
|
|
32
|
+
spinner_msg = options.key?(:parallel) ? _('Running unit tests in parallel') : _('Running unit tests')
|
|
33
|
+
c.add_spinner(spinner_msg)
|
|
26
34
|
c.environment['CI_SPEC_OPTIONS'] = '--format j'
|
|
27
35
|
end
|
|
28
36
|
|
|
@@ -30,20 +38,20 @@ module PDK
|
|
|
30
38
|
|
|
31
39
|
result = command.execute!
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
json_result = if options.key?(:parallel)
|
|
42
|
+
PDK::Util.find_all_json_in(result[:stdout])
|
|
43
|
+
else
|
|
44
|
+
PDK::Util.find_first_json_in(result[:stdout])
|
|
45
|
+
end
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
break
|
|
41
|
-
rescue JSON::ParserError
|
|
42
|
-
next
|
|
43
|
-
end
|
|
47
|
+
if parallel_with_no_tests?(options.key?(:parallel), json_result, result)
|
|
48
|
+
json_result = [{ 'messages' => ['No examples found.'] }]
|
|
49
|
+
result[:exit_code] = 0
|
|
44
50
|
end
|
|
45
51
|
|
|
46
|
-
raise PDK::CLI::FatalError, _('Unit test output did not contain a valid JSON result: %{output}') % { output: result[:stdout] }
|
|
52
|
+
raise PDK::CLI::FatalError, _('Unit test output did not contain a valid JSON result: %{output}') % { output: result[:stdout] } if json_result.nil? || json_result.empty?
|
|
53
|
+
|
|
54
|
+
json_result = merge_json_results(json_result, result[:duration]) if options.key?(:parallel)
|
|
47
55
|
|
|
48
56
|
parse_output(report, json_result)
|
|
49
57
|
|
|
@@ -99,32 +107,68 @@ module PDK
|
|
|
99
107
|
}
|
|
100
108
|
end
|
|
101
109
|
|
|
110
|
+
def self.merge_json_results(json_data, duration)
|
|
111
|
+
merged_json_result = {}
|
|
112
|
+
|
|
113
|
+
# Merge messages
|
|
114
|
+
message_set = Set.new
|
|
115
|
+
json_data.each do |json|
|
|
116
|
+
next unless json['messages']
|
|
117
|
+
message_set |= json['messages']
|
|
118
|
+
end
|
|
119
|
+
merged_json_result['messages'] = message_set.to_a
|
|
120
|
+
|
|
121
|
+
# Merge examples
|
|
122
|
+
all_examples = []
|
|
123
|
+
json_data.each do |json|
|
|
124
|
+
next unless json['examples']
|
|
125
|
+
all_examples.concat json['examples']
|
|
126
|
+
end
|
|
127
|
+
merged_json_result['examples'] = all_examples
|
|
128
|
+
|
|
129
|
+
# Merge summaries
|
|
130
|
+
summary_hash = {
|
|
131
|
+
'duration' => duration,
|
|
132
|
+
'example_count' => 0,
|
|
133
|
+
'failure_count' => 0,
|
|
134
|
+
'pending_count' => 0,
|
|
135
|
+
}
|
|
136
|
+
json_data.each do |json|
|
|
137
|
+
next unless json['summary']
|
|
138
|
+
summary_hash['example_count'] += json['summary']['example_count']
|
|
139
|
+
summary_hash['failure_count'] += json['summary']['failure_count']
|
|
140
|
+
summary_hash['pending_count'] += json['summary']['pending_count']
|
|
141
|
+
end
|
|
142
|
+
merged_json_result['summary'] = summary_hash
|
|
143
|
+
|
|
144
|
+
merged_json_result
|
|
145
|
+
end
|
|
146
|
+
|
|
102
147
|
# @return array of { :id, :full_description }
|
|
103
148
|
def self.list
|
|
104
149
|
PDK::Util::Bundler.ensure_bundle!
|
|
105
|
-
PDK::Util::Bundler.ensure_binstubs!('
|
|
150
|
+
PDK::Util::Bundler.ensure_binstubs!('rake')
|
|
106
151
|
|
|
107
|
-
command_argv = [File.join(PDK::Util.module_root, 'bin', '
|
|
152
|
+
command_argv = [File.join(PDK::Util.module_root, 'bin', 'rake'), 'spec_list_json']
|
|
108
153
|
command_argv.unshift('ruby') if Gem.win_platform?
|
|
109
154
|
list_command = PDK::CLI::Exec::Command.new(*command_argv)
|
|
110
155
|
list_command.context = :module
|
|
111
156
|
output = list_command.execute!
|
|
112
157
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
158
|
+
rspec_json = PDK::Util.find_first_json_in(output[:stdout])
|
|
159
|
+
raise PDK::CLI::FatalError, _('Failed to find valid JSON in output from rspec: %{output}' % { output: output[:stdout] }) unless rspec_json
|
|
160
|
+
if rspec_json['examples'].empty?
|
|
161
|
+
rspec_message = rspec_json['messages'][0]
|
|
116
162
|
return [] if rspec_message == 'No examples found.'
|
|
117
163
|
|
|
118
164
|
raise PDK::CLI::FatalError, _('Unable to enumerate examples. rspec reported: %{message}' % { message: rspec_message })
|
|
119
165
|
else
|
|
120
166
|
examples = []
|
|
121
|
-
|
|
167
|
+
rspec_json['examples'].each do |example|
|
|
122
168
|
examples << { id: example['id'], full_description: example['full_description'] }
|
|
123
169
|
end
|
|
124
170
|
examples
|
|
125
171
|
end
|
|
126
|
-
rescue JSON::ParserError => e
|
|
127
|
-
raise PDK::CLI::FatalError, _('Failed to parse output from rspec: %{message}' % { message: e.message })
|
|
128
172
|
end
|
|
129
173
|
end
|
|
130
174
|
end
|
data/lib/pdk/util.rb
CHANGED
|
@@ -100,5 +100,57 @@ module PDK
|
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
module_function :module_root
|
|
103
|
+
|
|
104
|
+
# Iterate through possible JSON documents until we find one that is valid.
|
|
105
|
+
#
|
|
106
|
+
# @param [String] text the text in which to find a JSON document
|
|
107
|
+
# @return [Hash, nil] subset of text as Hash of first valid JSON found, or nil if no valid
|
|
108
|
+
# JSON found in the text
|
|
109
|
+
def find_first_json_in(text)
|
|
110
|
+
find_valid_json_in(text)
|
|
111
|
+
end
|
|
112
|
+
module_function :find_first_json_in
|
|
113
|
+
|
|
114
|
+
# Iterate through possible JSON documents for all valid JSON
|
|
115
|
+
#
|
|
116
|
+
# @param [String] text the text in which to find JSON document(s)
|
|
117
|
+
# @return [Array<Hash>] subset of text as Array of all JSON object found, empty Array if none are found
|
|
118
|
+
# JSON found in the text
|
|
119
|
+
def find_all_json_in(text)
|
|
120
|
+
find_valid_json_in(text, break_on_first: false)
|
|
121
|
+
end
|
|
122
|
+
module_function :find_all_json_in
|
|
123
|
+
|
|
124
|
+
# Iterate through possible JSON documents until we find one that is valid.
|
|
125
|
+
#
|
|
126
|
+
# @param [String] text the text in which to find a JSON document
|
|
127
|
+
# @param [Hash] opts options
|
|
128
|
+
# @option opts [Boolean] :break_on_first Whether or not to break after valid JSON is found, defaults to true
|
|
129
|
+
#
|
|
130
|
+
# @return [Hash, Array<Hash>, nil] subset of text as Hash of first valid JSON found, array of all valid JSON found, or nil if no valid
|
|
131
|
+
# JSON found in the text
|
|
132
|
+
#
|
|
133
|
+
# @private
|
|
134
|
+
def find_valid_json_in(text, opts = {})
|
|
135
|
+
break_on_first = opts.key?(:break_on_first) ? opts[:break_on_first] : true
|
|
136
|
+
|
|
137
|
+
json_result = break_on_first ? nil : []
|
|
138
|
+
|
|
139
|
+
text.scan(%r{\{(?:[^{}]|(?:\g<0>))*\}}x) do |str|
|
|
140
|
+
begin
|
|
141
|
+
if break_on_first
|
|
142
|
+
json_result = JSON.parse(str)
|
|
143
|
+
break
|
|
144
|
+
else
|
|
145
|
+
json_result.push(JSON.parse(str))
|
|
146
|
+
end
|
|
147
|
+
rescue JSON::ParserError
|
|
148
|
+
next
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
json_result
|
|
153
|
+
end
|
|
154
|
+
module_function :find_valid_json_in
|
|
103
155
|
end
|
|
104
156
|
end
|
data/lib/pdk/util/bundler.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
|
+
require 'fileutils'
|
|
2
3
|
require 'tty-spinner'
|
|
3
4
|
require 'pdk/util'
|
|
4
5
|
require 'pdk/cli/exec'
|
|
@@ -22,8 +23,20 @@ module PDK
|
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
unless bundle.locked?
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if PDK::Util.package_install?
|
|
27
|
+
# In packaged installs, try to use vendored Gemfile.lock as a starting point.
|
|
28
|
+
# The 'bundle install' below will pick up any new dependencies.
|
|
29
|
+
vendored_gemfile_lock = File.join(PDK::Util.package_cachedir, 'Gemfile.lock')
|
|
30
|
+
|
|
31
|
+
if File.exist?(vendored_gemfile_lock)
|
|
32
|
+
PDK.logger.debug(_("No Gemfile.lock found in module, using vendored Gemfile.lock from '%{source}'") % { source: vendored_gemfile_lock })
|
|
33
|
+
FileUtils.cp(vendored_gemfile_lock, File.join(PDK::Util.module_root, 'Gemfile.lock'))
|
|
34
|
+
end
|
|
35
|
+
else
|
|
36
|
+
# In non-packaged installs, just let bundler resolve deps as normal.
|
|
37
|
+
unless bundle.lock!
|
|
38
|
+
raise PDK::CLI::FatalError, _('Unable to resolve Gemfile dependencies.')
|
|
39
|
+
end
|
|
27
40
|
end
|
|
28
41
|
end
|
|
29
42
|
|
|
@@ -62,14 +75,12 @@ module PDK
|
|
|
62
75
|
end
|
|
63
76
|
|
|
64
77
|
def installed?
|
|
78
|
+
PDK.logger.debug(_('Checking for missing Gemfile dependencies.'))
|
|
79
|
+
|
|
65
80
|
argv = ['check', "--gemfile=#{gemfile}"]
|
|
66
81
|
argv << "--path=#{bundle_cachedir}" if PDK::Util.gem_install?
|
|
67
82
|
|
|
68
|
-
|
|
69
|
-
c.add_spinner(_('Checking for missing Gemfile dependencies'))
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
result = command.execute!
|
|
83
|
+
result = bundle_command(*argv).execute!
|
|
73
84
|
|
|
74
85
|
unless result[:exit_code].zero?
|
|
75
86
|
$stderr.puts result[:stdout]
|
data/lib/pdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppet, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: 2.1.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: tty-which
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.3.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.3.0
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: deep_merge
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
216
|
version: '0'
|
|
203
217
|
requirements: []
|
|
204
218
|
rubyforge_project:
|
|
205
|
-
rubygems_version: 2.5
|
|
219
|
+
rubygems_version: 2.2.5
|
|
206
220
|
signing_key:
|
|
207
221
|
specification_version: 4
|
|
208
222
|
summary: A key part of the Puppet Development Kit, the shortest path to better modules
|