lib/pdk/cli/update.rb in pdk-1.17.0 vs lib/pdk/cli/update.rb in pdk-1.18.0
- old
+ new
@@ -8,18 +8,16 @@
flag nil, :force, _('Update the module automatically, with no prompts.')
PDK::CLI.template_ref_option(self)
run do |opts, _args, _cmd|
- require 'pdk/cli/util'
- require 'pdk/util'
- require 'pdk/module/update'
+ # Write the context information to the debug log
+ PDK.context.to_debug_log
- PDK::CLI::Util.ensure_in_module!(
- message: _('`pdk update` can only be run from inside a valid module directory.'),
- log_level: :info,
- )
+ unless PDK.context.is_a?(PDK::Context::Module)
+ raise PDK::CLI::ExitWithError, _('`pdk update` can only be run from inside a valid module directory.')
+ end
raise PDK::CLI::ExitWithError, _('This module does not appear to be PDK compatible. To make the module compatible with PDK, run `pdk convert`.') unless PDK::Util.module_pdk_compatible?
if opts[:noop] && opts[:force]
raise PDK::CLI::ExitWithError, _('You can not specify --noop and --force when updating a module')
@@ -44,10 +42,10 @@
end
end
PDK::CLI::Util.analytics_screen_view('update', opts)
- updater = PDK::Module::Update.new(PDK::Util.module_root, opts)
+ updater = PDK::Module::Update.new(PDK.context.root_path, opts)
if updater.pinned_to_puppetlabs_template_tag?
PDK.logger.info _(
'This module is currently pinned to version %{current_version} ' \
'of the default template. If you would like to update your ' \