pdk 2.7.0 → 3.0.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.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +2 -48
  4. data/lib/pdk/analytics/client/google_analytics.rb +22 -26
  5. data/lib/pdk/analytics/util.rb +0 -1
  6. data/lib/pdk/analytics.rb +1 -1
  7. data/lib/pdk/bolt.rb +1 -0
  8. data/lib/pdk/cli/build.rb +53 -56
  9. data/lib/pdk/cli/bundle.rb +34 -33
  10. data/lib/pdk/cli/console.rb +136 -134
  11. data/lib/pdk/cli/convert.rb +39 -41
  12. data/lib/pdk/cli/env.rb +49 -47
  13. data/lib/pdk/cli/errors.rb +1 -2
  14. data/lib/pdk/cli/exec/command.rb +23 -29
  15. data/lib/pdk/cli/exec/interactive_command.rb +7 -12
  16. data/lib/pdk/cli/exec.rb +4 -11
  17. data/lib/pdk/cli/exec_group.rb +3 -2
  18. data/lib/pdk/cli/get/config.rb +21 -19
  19. data/lib/pdk/cli/get.rb +15 -13
  20. data/lib/pdk/cli/new/class.rb +22 -22
  21. data/lib/pdk/cli/new/defined_type.rb +22 -22
  22. data/lib/pdk/cli/new/fact.rb +19 -19
  23. data/lib/pdk/cli/new/function.rb +20 -20
  24. data/lib/pdk/cli/new/module.rb +40 -38
  25. data/lib/pdk/cli/new/provider.rb +19 -19
  26. data/lib/pdk/cli/new/task.rb +23 -23
  27. data/lib/pdk/cli/new/test.rb +50 -48
  28. data/lib/pdk/cli/new/transport.rb +18 -18
  29. data/lib/pdk/cli/new.rb +11 -9
  30. data/lib/pdk/cli/release/prep.rb +27 -25
  31. data/lib/pdk/cli/release/publish.rb +39 -37
  32. data/lib/pdk/cli/release.rb +152 -149
  33. data/lib/pdk/cli/remove/config.rb +63 -60
  34. data/lib/pdk/cli/remove.rb +15 -13
  35. data/lib/pdk/cli/set/config.rb +91 -89
  36. data/lib/pdk/cli/set.rb +15 -13
  37. data/lib/pdk/cli/test/unit.rb +71 -69
  38. data/lib/pdk/cli/test.rb +9 -7
  39. data/lib/pdk/cli/update.rb +33 -38
  40. data/lib/pdk/cli/util/command_redirector.rb +10 -1
  41. data/lib/pdk/cli/util/interview.rb +11 -4
  42. data/lib/pdk/cli/util/option_normalizer.rb +2 -4
  43. data/lib/pdk/cli/util/option_validator.rb +7 -9
  44. data/lib/pdk/cli/util/update_manager_printer.rb +4 -4
  45. data/lib/pdk/cli/util.rb +32 -48
  46. data/lib/pdk/cli/validate.rb +98 -96
  47. data/lib/pdk/cli.rb +124 -120
  48. data/lib/pdk/config/ini_file.rb +4 -3
  49. data/lib/pdk/config/ini_file_setting.rb +6 -10
  50. data/lib/pdk/config/json.rb +1 -0
  51. data/lib/pdk/config/json_schema_namespace.rb +5 -10
  52. data/lib/pdk/config/json_schema_setting.rb +3 -5
  53. data/lib/pdk/config/json_with_schema.rb +2 -4
  54. data/lib/pdk/config/namespace.rb +19 -13
  55. data/lib/pdk/config/setting.rb +5 -6
  56. data/lib/pdk/config/task_schema.json +116 -0
  57. data/lib/pdk/config/validator.rb +4 -4
  58. data/lib/pdk/config/yaml.rb +3 -8
  59. data/lib/pdk/config/yaml_with_schema.rb +4 -12
  60. data/lib/pdk/config.rb +47 -51
  61. data/lib/pdk/context/control_repo.rb +3 -2
  62. data/lib/pdk/context/module.rb +2 -2
  63. data/lib/pdk/context/none.rb +2 -2
  64. data/lib/pdk/context.rb +4 -5
  65. data/lib/pdk/control_repo.rb +3 -4
  66. data/lib/pdk/generate/defined_type.rb +3 -3
  67. data/lib/pdk/generate/fact.rb +3 -2
  68. data/lib/pdk/generate/function.rb +5 -4
  69. data/lib/pdk/generate/module.rb +91 -106
  70. data/lib/pdk/generate/provider.rb +5 -4
  71. data/lib/pdk/generate/puppet_class.rb +3 -3
  72. data/lib/pdk/generate/puppet_object.rb +9 -12
  73. data/lib/pdk/generate/task.rb +11 -10
  74. data/lib/pdk/generate/transport.rb +8 -7
  75. data/lib/pdk/generate.rb +1 -1
  76. data/lib/pdk/logger.rb +3 -2
  77. data/lib/pdk/module/build.rb +34 -49
  78. data/lib/pdk/module/convert.rb +13 -22
  79. data/lib/pdk/module/metadata.rb +53 -61
  80. data/lib/pdk/module/release.rb +19 -25
  81. data/lib/pdk/module/update.rb +4 -13
  82. data/lib/pdk/module/update_manager.rb +18 -25
  83. data/lib/pdk/module.rb +1 -1
  84. data/lib/pdk/monkey_patches.rb +268 -0
  85. data/lib/pdk/report/event.rb +12 -37
  86. data/lib/pdk/report.rb +4 -4
  87. data/lib/pdk/template/fetcher/git.rb +7 -8
  88. data/lib/pdk/template/fetcher/local.rb +1 -0
  89. data/lib/pdk/template/fetcher.rb +4 -2
  90. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +4 -9
  91. data/lib/pdk/template/renderer/v1/renderer.rb +19 -20
  92. data/lib/pdk/template/renderer/v1/template_file.rb +4 -8
  93. data/lib/pdk/template/renderer/v1.rb +1 -1
  94. data/lib/pdk/template/renderer.rb +1 -0
  95. data/lib/pdk/template/template_dir.rb +3 -3
  96. data/lib/pdk/template.rb +2 -6
  97. data/lib/pdk/tests/unit.rb +36 -25
  98. data/lib/pdk/util/bundler.rb +10 -14
  99. data/lib/pdk/util/changelog_generator.rb +15 -12
  100. data/lib/pdk/util/env.rb +1 -0
  101. data/lib/pdk/util/filesystem.rb +18 -17
  102. data/lib/pdk/util/git.rb +16 -21
  103. data/lib/pdk/util/json_finder.rb +7 -6
  104. data/lib/pdk/util/puppet_strings.rb +1 -1
  105. data/lib/pdk/util/puppet_version.rb +16 -67
  106. data/lib/pdk/util/ruby_version.rb +9 -13
  107. data/lib/pdk/util/template_uri.rb +17 -29
  108. data/lib/pdk/util/vendored_file.rb +5 -18
  109. data/lib/pdk/util/windows/api_types.rb +70 -64
  110. data/lib/pdk/util/windows/file.rb +31 -27
  111. data/lib/pdk/util/windows/process.rb +59 -61
  112. data/lib/pdk/util/windows/string.rb +19 -12
  113. data/lib/pdk/util.rb +12 -20
  114. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +1 -1
  115. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +25 -25
  116. data/lib/pdk/validate/external_command_validator.rb +6 -1
  117. data/lib/pdk/validate/internal_ruby_validator.rb +5 -4
  118. data/lib/pdk/validate/invokable_validator.rb +30 -20
  119. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +12 -14
  120. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +13 -15
  121. data/lib/pdk/validate/metadata/metadata_validator_group.rb +1 -1
  122. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +16 -18
  123. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +14 -14
  124. data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +1 -1
  125. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +16 -18
  126. data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -1
  127. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +10 -11
  128. data/lib/pdk/validate/ruby/ruby_validator_group.rb +1 -1
  129. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +19 -24
  130. data/lib/pdk/validate/tasks/tasks_name_validator.rb +11 -13
  131. data/lib/pdk/validate/tasks/tasks_validator_group.rb +1 -1
  132. data/lib/pdk/validate/validator.rb +4 -2
  133. data/lib/pdk/validate/validator_group.rb +6 -3
  134. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +27 -36
  135. data/lib/pdk/validate/yaml/yaml_validator_group.rb +1 -1
  136. data/lib/pdk/validate.rb +6 -6
  137. data/lib/pdk/version.rb +2 -2
  138. data/lib/pdk.rb +12 -12
  139. metadata +27 -35
  140. data/lib/pdk/cli/config/get.rb +0 -26
  141. data/lib/pdk/cli/config.rb +0 -22
  142. data/lib/pdk/cli/module/build.rb +0 -12
  143. data/lib/pdk/cli/module/generate.rb +0 -47
  144. data/lib/pdk/cli/module.rb +0 -14
@@ -4,6 +4,7 @@ module PDK
4
4
  module CLI
5
5
  module Exec
6
6
  class InteractiveCommand < Command
7
+ # rubocop :disable Lint/MissingSuper
7
8
  def initialize(*argv)
8
9
  @argv = argv
9
10
 
@@ -13,6 +14,7 @@ module PDK
13
14
  # Extra environment vars to add to base set.
14
15
  @environment = {}
15
16
  end
17
+ # rubocop :enable Lint/MissingSuper
16
18
 
17
19
  def register_spinner(_spinner, _opts = {})
18
20
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
@@ -42,9 +44,7 @@ module PDK
42
44
  if [:module, :pwd].include?(context)
43
45
  mod_root = PDK::Util.module_root
44
46
 
45
- unless mod_root
46
- raise PDK::CLI::FatalError, 'Current working directory is not part of a module. (No metadata.json was found.)'
47
- end
47
+ raise PDK::CLI::FatalError, 'Current working directory is not part of a module. (No metadata.json was found.)' unless mod_root
48
48
 
49
49
  unless context == :pwd || Dir.pwd == mod_root
50
50
  orig_workdir = Dir.pwd
@@ -61,7 +61,7 @@ module PDK
61
61
  stdout: nil,
62
62
  stderr: nil,
63
63
  exit_code: result[:exit_code],
64
- duration: result[:duration],
64
+ duration: result[:duration]
65
65
  }
66
66
  ensure
67
67
  Dir.chdir(orig_workdir) if orig_workdir
@@ -72,7 +72,7 @@ module PDK
72
72
  # TODO: debug logging
73
73
  def run_process!
74
74
  command_string = argv.join(' ')
75
- PDK.logger.debug("Executing '%{command}' interactively" % { command: command_string })
75
+ PDK.logger.debug(format("Executing '%{command}' interactively", command: command_string))
76
76
 
77
77
  if context == :module
78
78
  PDK.logger.debug('Command environment:')
@@ -88,13 +88,8 @@ module PDK
88
88
  exit_code = child_status.exitstatus
89
89
  duration = Time.now - start_time
90
90
 
91
- PDK.logger.debug("Execution of '%{command}' complete (duration: \
92
- %{duration_in_seconds}s; exit code: %{exit_code})" %
93
- {
94
- command: command_string,
95
- exit_code: exit_code,
96
- duration_in_seconds: duration,
97
- })
91
+ PDK.logger.debug(format("Execution of '%{command}' complete (duration: \
92
+ %{duration_in_seconds}s; exit code: %{exit_code})", command: command_string, exit_code: exit_code, duration_in_seconds: duration))
98
93
 
99
94
  { exit_code: exit_code, duration: duration }
100
95
  end
data/lib/pdk/cli/exec.rb CHANGED
@@ -33,9 +33,7 @@ module PDK
33
33
  def self.ensure_bin_present!(bin_path, bin_name)
34
34
  require 'tty-which'
35
35
 
36
- message = 'Unable to find `%{name}`. Check that it is installed and try again.' % {
37
- name: bin_name,
38
- }
36
+ message = format('Unable to find `%{name}`. Check that it is installed and try again.', name: bin_name)
39
37
 
40
38
  raise PDK::CLI::FatalError, message unless TTY::Which.exist?(bin_path)
41
39
  end
@@ -59,9 +57,7 @@ module PDK
59
57
  require 'pdk/util'
60
58
 
61
59
  unless PDK::Util.package_install?
62
- PDK.logger.debug("PDK package installation not found. Trying '%{fallback}' from the system PATH instead." % {
63
- fallback: fallback,
64
- })
60
+ PDK.logger.debug(format("PDK package installation not found. Trying '%{fallback}' from the system PATH instead.", fallback: fallback))
65
61
  return fallback
66
62
  end
67
63
 
@@ -69,14 +65,11 @@ module PDK
69
65
 
70
66
  require 'pdk/util/filesystem'
71
67
  unless PDK::Util::Filesystem.exist?(vendored_bin_full_path)
72
- PDK.logger.debug("Could not find '%{vendored_bin}' in PDK package. Trying '%{fallback}' from the system PATH instead." % {
73
- fallback: fallback,
74
- vendored_bin: vendored_bin_full_path,
75
- })
68
+ PDK.logger.debug(format("Could not find '%{vendored_bin}' in PDK package. Trying '%{fallback}' from the system PATH instead.", fallback: fallback, vendored_bin: vendored_bin_full_path))
76
69
  return fallback
77
70
  end
78
71
 
79
- PDK.logger.debug "Using '%{vendored_bin}' from PDK package." % { vendored_bin: vendored_bin_full_path }
72
+ PDK.logger.debug format("Using '%{vendored_bin}' from PDK package.", vendored_bin: vendored_bin_full_path)
80
73
  vendored_bin_full_path
81
74
  end
82
75
  end
@@ -37,8 +37,8 @@ module PDK
37
37
  # @param block [Block] A block of ruby to execute
38
38
  #
39
39
  # @api private
40
- def register(&_block)
41
- raise PDK::CLI::FatalError, 'No block registered' unless block_given?
40
+ def register(&block)
41
+ raise PDK::CLI::FatalError, 'No block registered' unless block
42
42
  end
43
43
 
44
44
  # The return code of running all registered blocks
@@ -95,6 +95,7 @@ module PDK
95
95
  def exit_code
96
96
  @threads.each(&:join)
97
97
  return 0 if @exit_codes.empty?
98
+
98
99
  @exit_codes.max
99
100
  end
100
101
  end
@@ -1,24 +1,26 @@
1
- module PDK::CLI
2
- @get_config_cmd = @get_cmd.define_command do
3
- name 'config'
4
- usage 'config [name]'
5
- summary 'Retrieve the configuration for <name>. If not specified, retrieve all configuration settings'
1
+ module PDK
2
+ module CLI
3
+ @get_config_cmd = @get_cmd.define_command do
4
+ name 'config'
5
+ usage 'config [name]'
6
+ summary 'Retrieve the configuration for <name>. If not specified, retrieve all configuration settings'
6
7
 
7
- run do |_opts, args, _cmd|
8
- item_name = args[0]
9
- resolved_config = PDK.config.resolve(item_name)
10
- # If the user wanted to know a setting but it doesn't exist, raise an error
11
- if resolved_config.empty? && !item_name.nil?
12
- PDK.logger.error("Configuration item '%{name}' does not exist" % { name: item_name })
13
- exit 1
8
+ run do |_opts, args, _cmd|
9
+ item_name = args[0]
10
+ resolved_config = PDK.config.resolve(item_name)
11
+ # If the user wanted to know a setting but it doesn't exist, raise an error
12
+ if resolved_config.empty? && !item_name.nil?
13
+ PDK.logger.error(format("Configuration item '%{name}' does not exist", name: item_name))
14
+ exit 1
15
+ end
16
+ # If the user requested a setting and it's the only one resolved, then just output the value
17
+ if resolved_config.count == 1 && resolved_config.keys[0] == item_name
18
+ puts format('%{value}', value: resolved_config.values[0])
19
+ exit 0
20
+ end
21
+ # Otherwise just output everything
22
+ resolved_config.keys.sort.each { |key| puts format('%{name}=%{value}', name: key, value: resolved_config[key]) }
14
23
  end
15
- # If the user requested a setting and it's the only one resolved, then just output the value
16
- if resolved_config.count == 1 && resolved_config.keys[0] == item_name
17
- puts '%{value}' % { value: resolved_config.values[0] }
18
- exit 0
19
- end
20
- # Otherwise just output everything
21
- resolved_config.keys.sort.each { |key| puts '%{name}=%{value}' % { name: key, value: resolved_config[key] } }
22
24
  end
23
25
  end
24
26
  end
data/lib/pdk/cli/get.rb CHANGED
@@ -1,20 +1,22 @@
1
- module PDK::CLI
2
- @get_cmd = @base_cmd.define_command do
3
- name 'get'
4
- usage 'get [subcommand] [options]'
5
- summary 'Retrieve information about the PDK or current project.'
6
- default_subcommand 'help'
1
+ module PDK
2
+ module CLI
3
+ @get_cmd = @base_cmd.define_command do
4
+ name 'get'
5
+ usage 'get [subcommand] [options]'
6
+ summary 'Retrieve information about the PDK or current project.'
7
+ default_subcommand 'help'
7
8
 
8
- run do |_opts, args, _cmd|
9
- if args == ['help']
10
- PDK::CLI.run(%w[get --help])
11
- exit 0
12
- end
9
+ run do |_opts, args, _cmd|
10
+ if args == ['help']
11
+ PDK::CLI.run(['get', '--help'])
12
+ exit 0
13
+ end
13
14
 
14
- PDK::CLI.run(%w[get help]) if args.empty?
15
+ PDK::CLI.run(['get', 'help']) if args.empty?
16
+ end
15
17
  end
18
+ @get_cmd.add_command Cri::Command.new_basic_help
16
19
  end
17
- @get_cmd.add_command Cri::Command.new_basic_help
18
20
  end
19
21
 
20
22
  require 'pdk/cli/get/config'
@@ -1,32 +1,32 @@
1
- module PDK::CLI
2
- @new_class_cmd = @new_cmd.define_command do
3
- name 'class'
4
- usage 'class [options] <class_name>'
5
- summary 'Create a new class named <class_name> using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_class_cmd = @new_cmd.define_command do
4
+ name 'class'
5
+ usage 'class [options] <class_name>'
6
+ summary 'Create a new class named <class_name> using given options'
6
7
 
7
- run do |opts, args, _cmd|
8
- require 'pdk/generate/puppet_class'
8
+ run do |opts, args, _cmd|
9
+ require 'pdk/generate/puppet_class'
9
10
 
10
- PDK::CLI::Util.ensure_in_module!(
11
- message: 'Classes can only be created from inside a valid module directory.',
12
- log_level: :info,
13
- )
11
+ PDK::CLI::Util.ensure_in_module!(
12
+ message: 'Classes can only be created from inside a valid module directory.',
13
+ log_level: :info
14
+ )
14
15
 
15
- class_name = args[0]
16
+ class_name = args[0]
16
17
 
17
- if class_name.nil? || class_name.empty?
18
- puts command.help
19
- exit 1
20
- end
18
+ if class_name.nil? || class_name.empty?
19
+ puts command.help
20
+ exit 1
21
+ end
21
22
 
22
- unless Util::OptionValidator.valid_class_name?(class_name)
23
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid class name" % { name: class_name }
24
- end
23
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid class name", name: class_name) unless Util::OptionValidator.valid_class_name?(class_name)
25
24
 
26
- PDK::CLI::Util.analytics_screen_view('new_class', opts)
25
+ PDK::CLI::Util.analytics_screen_view('new_class', opts)
27
26
 
28
- updates = PDK::Generate::PuppetClass.new(PDK.context, class_name, opts).run
29
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
27
+ updates = PDK::Generate::PuppetClass.new(PDK.context, class_name, opts).run
28
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
29
+ end
30
30
  end
31
31
  end
32
32
  end
@@ -1,32 +1,32 @@
1
- module PDK::CLI
2
- @new_define_cmd = @new_cmd.define_command do
3
- name 'defined_type'
4
- usage 'defined_type [options] <name>'
5
- summary 'Create a new defined type named <name> using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_define_cmd = @new_cmd.define_command do
4
+ name 'defined_type'
5
+ usage 'defined_type [options] <name>'
6
+ summary 'Create a new defined type named <name> using given options'
6
7
 
7
- run do |opts, args, _cmd|
8
- PDK::CLI::Util.ensure_in_module!(
9
- message: 'Defined types can only be created from inside a valid module directory.',
10
- log_level: :info,
11
- )
8
+ run do |opts, args, _cmd|
9
+ PDK::CLI::Util.ensure_in_module!(
10
+ message: 'Defined types can only be created from inside a valid module directory.',
11
+ log_level: :info
12
+ )
12
13
 
13
- defined_type_name = args[0]
14
+ defined_type_name = args[0]
14
15
 
15
- if defined_type_name.nil? || defined_type_name.empty?
16
- puts command.help
17
- exit 1
18
- end
16
+ if defined_type_name.nil? || defined_type_name.empty?
17
+ puts command.help
18
+ exit 1
19
+ end
19
20
 
20
- unless Util::OptionValidator.valid_defined_type_name?(defined_type_name)
21
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid defined type name" % { name: defined_type_name }
22
- end
21
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid defined type name", name: defined_type_name) unless Util::OptionValidator.valid_defined_type_name?(defined_type_name)
23
22
 
24
- PDK::CLI::Util.analytics_screen_view('new_defined_type', opts)
23
+ PDK::CLI::Util.analytics_screen_view('new_defined_type', opts)
25
24
 
26
- require 'pdk/generate/defined_type'
25
+ require 'pdk/generate/defined_type'
27
26
 
28
- updates = PDK::Generate::DefinedType.new(PDK.context, defined_type_name, opts).run
29
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
27
+ updates = PDK::Generate::DefinedType.new(PDK.context, defined_type_name, opts).run
28
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
29
+ end
30
30
  end
31
31
  end
32
32
  end
@@ -1,29 +1,29 @@
1
- module PDK::CLI
2
- @new_fact_cmd = @new_cmd.define_command do
3
- name 'fact'
4
- usage 'fact [options] <name>'
5
- summary 'Create a new custom fact named <name> using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_fact_cmd = @new_cmd.define_command do
4
+ name 'fact'
5
+ usage 'fact [options] <name>'
6
+ summary 'Create a new custom fact named <name> using given options'
6
7
 
7
- run do |opts, args, _cmd|
8
- PDK::CLI::Util.ensure_in_module!
8
+ run do |opts, args, _cmd|
9
+ PDK::CLI::Util.ensure_in_module!
9
10
 
10
- fact_name = args[0]
11
+ fact_name = args[0]
11
12
 
12
- if fact_name.nil? || fact_name.empty?
13
- puts command.help
14
- exit 1
15
- end
13
+ if fact_name.nil? || fact_name.empty?
14
+ puts command.help
15
+ exit 1
16
+ end
16
17
 
17
- unless Util::OptionValidator.valid_fact_name?(fact_name)
18
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid fact name" % { name: fact_name }
19
- end
18
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid fact name", name: fact_name) unless Util::OptionValidator.valid_fact_name?(fact_name)
20
19
 
21
- PDK::CLI::Util.analytics_screen_view('new_fact', opts)
20
+ PDK::CLI::Util.analytics_screen_view('new_fact', opts)
22
21
 
23
- require 'pdk/generate/fact'
22
+ require 'pdk/generate/fact'
24
23
 
25
- updates = PDK::Generate::Fact.new(PDK.context, fact_name, opts).run
26
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
24
+ updates = PDK::Generate::Fact.new(PDK.context, fact_name, opts).run
25
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -1,29 +1,29 @@
1
- module PDK::CLI
2
- @new_function_cmd = @new_cmd.define_command do
3
- name 'function'
4
- usage 'function [options] <name>'
5
- summary 'Create a new function named <name> using given options'
6
- option :t, :type, 'The function type, (native or v4)', argument: :required, default: 'native'
1
+ module PDK
2
+ module CLI
3
+ @new_function_cmd = @new_cmd.define_command do
4
+ name 'function'
5
+ usage 'function [options] <name>'
6
+ summary 'Create a new function named <name> using given options'
7
+ option :t, :type, 'The function type, (native or v4)', argument: :required, default: 'native'
7
8
 
8
- run do |opts, args, _cmd|
9
- PDK::CLI::Util.ensure_in_module!
9
+ run do |opts, args, _cmd|
10
+ PDK::CLI::Util.ensure_in_module!
10
11
 
11
- function_name = args[0]
12
+ function_name = args[0]
12
13
 
13
- if function_name.nil? || function_name.empty?
14
- puts command.help
15
- exit 1
16
- end
14
+ if function_name.nil? || function_name.empty?
15
+ puts command.help
16
+ exit 1
17
+ end
17
18
 
18
- unless Util::OptionValidator.valid_function_name?(function_name)
19
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid function name" % { name: function_name }
20
- end
19
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid function name", name: function_name) unless Util::OptionValidator.valid_function_name?(function_name)
21
20
 
22
- PDK::CLI::Util.analytics_screen_view('new_function', opts)
21
+ PDK::CLI::Util.analytics_screen_view('new_function', opts)
23
22
 
24
- require 'pdk/generate/function'
25
- updates = PDK::Generate::Function.new(PDK.context, function_name, opts).run
26
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
23
+ require 'pdk/generate/function'
24
+ updates = PDK::Generate::Function.new(PDK.context, function_name, opts).run
25
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -1,52 +1,54 @@
1
- module PDK::CLI
2
- @new_module_cmd = @new_cmd.define_command do
3
- name 'module'
4
- usage 'module [options] [module_name] [target_dir]'
5
- summary 'Create a new module named [module_name] using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_module_cmd = @new_cmd.define_command do
4
+ name 'module'
5
+ usage 'module [options] [module_name] [target_dir]'
6
+ summary 'Create a new module named [module_name] using given options'
6
7
 
7
- PDK::CLI.template_url_option(self)
8
- PDK::CLI.template_ref_option(self)
9
- PDK::CLI.skip_interview_option(self)
10
- PDK::CLI.full_interview_option(self)
8
+ PDK::CLI.template_url_option(self)
9
+ PDK::CLI.template_ref_option(self)
10
+ PDK::CLI.skip_interview_option(self)
11
+ PDK::CLI.full_interview_option(self)
11
12
 
12
- option nil, 'license', 'Specifies the license this module is written under. ' \
13
- "This should be a identifier from https://spdx.org/licenses/. Common values are 'Apache-2.0', 'MIT', or 'proprietary'.", argument: :required
14
- option nil, 'skip-bundle-install', 'Do not automatically run `bundle install` after creating the module.', hidden: true
13
+ option nil, 'license', 'Specifies the license this module is written under. ' \
14
+ "This should be a identifier from https://spdx.org/licenses/. Common values are 'Apache-2.0', 'MIT', or 'proprietary'.", argument: :required
15
+ option nil, 'skip-bundle-install', 'Do not automatically run `bundle install` after creating the module.', hidden: true
15
16
 
16
- run do |opts, args, _cmd|
17
- require 'pdk/generate/module'
17
+ run do |opts, args, _cmd|
18
+ require 'pdk/generate/module'
18
19
 
19
- module_name = args[0]
20
- target_dir = args[1]
20
+ module_name = args[0]
21
+ target_dir = args[1]
21
22
 
22
- PDK::CLI::Util.validate_template_opts(opts)
23
+ PDK::CLI::Util.validate_template_opts(opts)
23
24
 
24
- PDK::CLI::Util.analytics_screen_view('new_module', opts)
25
+ PDK::CLI::Util.analytics_screen_view('new_module', opts)
25
26
 
26
- if opts[:'skip-interview'] && opts[:'full-interview']
27
- PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
28
- opts[:'full-interview'] = false
29
- end
30
-
31
- if module_name.nil? || module_name.empty?
32
- if opts[:'skip-interview']
33
- raise PDK::CLI::ExitWithError,
34
- 'You must specify a module name on the command line when running ' \
35
- 'with --skip-interview.'
27
+ if opts[:'skip-interview'] && opts[:'full-interview']
28
+ PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
29
+ opts[:'full-interview'] = false
36
30
  end
37
- else
38
- module_name_parts = module_name.split('-', 2)
39
- if module_name_parts.size > 1
40
- opts[:username] = module_name_parts[0]
41
- opts[:module_name] = module_name_parts[1]
31
+
32
+ if module_name.nil? || module_name.empty?
33
+ if opts[:'skip-interview']
34
+ raise PDK::CLI::ExitWithError,
35
+ 'You must specify a module name on the command line when running ' \
36
+ 'with --skip-interview.'
37
+ end
42
38
  else
43
- opts[:module_name] = module_name
39
+ module_name_parts = module_name.split('-', 2)
40
+ if module_name_parts.size > 1
41
+ opts[:username] = module_name_parts[0]
42
+ opts[:module_name] = module_name_parts[1]
43
+ else
44
+ opts[:module_name] = module_name
45
+ end
46
+ opts[:target_dir] = target_dir.nil? ? opts[:module_name] : target_dir
44
47
  end
45
- opts[:target_dir] = target_dir.nil? ? opts[:module_name] : target_dir
46
- end
47
48
 
48
- PDK.logger.info('Creating new module: %{modname}' % { modname: module_name })
49
- PDK::Generate::Module.invoke(opts)
49
+ PDK.logger.info(format('Creating new module: %{modname}', modname: module_name))
50
+ PDK::Generate::Module.invoke(opts)
51
+ end
50
52
  end
51
53
  end
52
54
  end
@@ -1,29 +1,29 @@
1
- module PDK::CLI
2
- @new_provider_cmd = @new_cmd.define_command do
3
- name 'provider'
4
- usage 'provider [options] <name>'
5
- summary '[experimental] Create a new ruby provider named <name> using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_provider_cmd = @new_cmd.define_command do
4
+ name 'provider'
5
+ usage 'provider [options] <name>'
6
+ summary '[experimental] Create a new ruby provider named <name> using given options'
6
7
 
7
- run do |opts, args, _cmd|
8
- PDK::CLI::Util.ensure_in_module!
8
+ run do |opts, args, _cmd|
9
+ PDK::CLI::Util.ensure_in_module!
9
10
 
10
- provider_name = args[0]
11
+ provider_name = args[0]
11
12
 
12
- if provider_name.nil? || provider_name.empty?
13
- puts command.help
14
- exit 1
15
- end
13
+ if provider_name.nil? || provider_name.empty?
14
+ puts command.help
15
+ exit 1
16
+ end
16
17
 
17
- unless Util::OptionValidator.valid_provider_name?(provider_name)
18
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid provider name" % { name: provider_name }
19
- end
18
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid provider name", name: provider_name) unless Util::OptionValidator.valid_provider_name?(provider_name)
20
19
 
21
- PDK::CLI::Util.analytics_screen_view('new_provider', opts)
20
+ PDK::CLI::Util.analytics_screen_view('new_provider', opts)
22
21
 
23
- require 'pdk/generate/provider'
22
+ require 'pdk/generate/provider'
24
23
 
25
- updates = PDK::Generate::Provider.new(PDK.context, provider_name, opts).run
26
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
24
+ updates = PDK::Generate::Provider.new(PDK.context, provider_name, opts).run
25
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -1,34 +1,34 @@
1
- module PDK::CLI
2
- @new_task_cmd = @new_cmd.define_command do
3
- name 'task'
4
- usage 'task [options] <name>'
5
- summary 'Create a new task named <name> using given options'
1
+ module PDK
2
+ module CLI
3
+ @new_task_cmd = @new_cmd.define_command do
4
+ name 'task'
5
+ usage 'task [options] <name>'
6
+ summary 'Create a new task named <name> using given options'
6
7
 
7
- option nil, :description, 'A short description of the purpose of the task', argument: :required
8
+ option nil, :description, 'A short description of the purpose of the task', argument: :required
8
9
 
9
- run do |opts, args, _cmd|
10
- require 'pdk/generate/task'
10
+ run do |opts, args, _cmd|
11
+ require 'pdk/generate/task'
11
12
 
12
- PDK::CLI::Util.ensure_in_module!(
13
- message: 'Tasks can only be created from inside a valid module directory.',
14
- log_level: :info,
15
- )
13
+ PDK::CLI::Util.ensure_in_module!(
14
+ message: 'Tasks can only be created from inside a valid module directory.',
15
+ log_level: :info
16
+ )
16
17
 
17
- task_name = args[0]
18
+ task_name = args[0]
18
19
 
19
- if task_name.nil? || task_name.empty?
20
- puts command.help
21
- exit 1
22
- end
20
+ if task_name.nil? || task_name.empty?
21
+ puts command.help
22
+ exit 1
23
+ end
23
24
 
24
- unless Util::OptionValidator.valid_task_name?(task_name)
25
- raise PDK::CLI::ExitWithError, "'%{name}' is not a valid task name" % { name: task_name }
26
- end
25
+ raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid task name", name: task_name) unless Util::OptionValidator.valid_task_name?(task_name)
27
26
 
28
- PDK::CLI::Util.analytics_screen_view('new_task', opts)
27
+ PDK::CLI::Util.analytics_screen_view('new_task', opts)
29
28
 
30
- updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
31
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
29
+ updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
30
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
31
+ end
32
32
  end
33
33
  end
34
34
  end