diff --git a/lib/pdk/cli.rb b/lib/pdk/cli.rb index 38c77ab3b..e23c2482a 100644 --- a/lib/pdk/cli.rb +++ b/lib/pdk/cli.rb @@ -153,7 +153,6 @@ def self.puppet_dev_option(dsl) require 'pdk/cli/test' require 'pdk/cli/update' require 'pdk/cli/validate' - require 'pdk/cli/module' require 'pdk/cli/console' require 'pdk/cli/release' require 'pdk/cli/remove' diff --git a/lib/pdk/cli/module.rb b/lib/pdk/cli/module.rb deleted file mode 100644 index 0ec1a7afb..000000000 --- a/lib/pdk/cli/module.rb +++ /dev/null @@ -1,16 +0,0 @@ -module PDK - module CLI - @module_cmd = @base_cmd.define_command do - name 'module' - usage 'module [options]' - summary 'Provide CLI-backwards compatibility to the puppet module tool.' - description 'This command is only for reminding you how to accomplish tasks with the PDK, when you were previously doing them with the puppet module command.' - default_subcommand 'help' - end - - @module_cmd.add_command Cri::Command.new_basic_help - end -end - -require 'pdk/cli/module/build' -require 'pdk/cli/module/generate' diff --git a/lib/pdk/cli/module/build.rb b/lib/pdk/cli/module/build.rb deleted file mode 100644 index 942dac031..000000000 --- a/lib/pdk/cli/module/build.rb +++ /dev/null @@ -1,14 +0,0 @@ -module PDK - module CLI - @module_build_cmd = @module_cmd.define_command do - name 'build' - usage 'build' - summary 'This command is now \'pdk build\'.' - - run do |_opts, _args, _cmd| - PDK.logger.warn("Modules are built using the 'pdk build' command.") - exit 1 - end - end - end -end diff --git a/lib/pdk/cli/module/generate.rb b/lib/pdk/cli/module/generate.rb deleted file mode 100644 index 614c3820c..000000000 --- a/lib/pdk/cli/module/generate.rb +++ /dev/null @@ -1,49 +0,0 @@ -module PDK - module CLI - @module_generate_cmd = @module_cmd.define_command do - name 'generate' - usage 'generate [options] ' - summary 'This command is now \'pdk new module\'.' - - PDK::CLI.template_url_option(self) - PDK::CLI.template_ref_option(self) - PDK::CLI.skip_interview_option(self) - - run do |opts, args, _cmd| - require 'pdk/generate/module' - require 'tty/prompt' - - module_name = args[0] - - if module_name.nil? || module_name.empty? - puts command.help - exit 1 - end - - PDK::CLI::Util.validate_template_opts(opts) - - PDK.logger.info("New modules are created using the 'pdk new module' command.") - prompt = TTY::Prompt.new(help_color: :cyan) - redirect = PDK::CLI::Util::CommandRedirector.new(prompt) - redirect.target_command('pdk new module') - answer = redirect.run - - if answer - module_name_parts = module_name.split('-', 2) - if module_name_parts.size > 1 - opts[:username] = module_name_parts[0] - opts[:module_name] = module_name_parts[1] - else - opts[:module_name] = module_name - end - opts[:target_dir] = opts[:module_name] - - PDK.logger.info(format('Creating new module: %{modname}', modname: module_name)) - PDK::Generate::Module.invoke(opts) - else - exit 1 - end - end - end - end -end diff --git a/spec/unit/pdk/cli/module/build_spec.rb b/spec/unit/pdk/cli/module/build_spec.rb deleted file mode 100644 index 4470aacc8..000000000 --- a/spec/unit/pdk/cli/module/build_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' -require 'pdk/cli' - -describe 'Running pdk module build' do - subject { PDK::CLI.instance_variable_get(:@module_build_cmd) } - - describe 'when called' do - it do - expect(logger).to receive(:warn).with(/Modules are built using the 'pdk build' command/i) - expect do - PDK::CLI.run(['module', 'build']) - end.to exit_nonzero - end - end -end diff --git a/spec/unit/pdk/cli/module/generate_spec.rb b/spec/unit/pdk/cli/module/generate_spec.rb deleted file mode 100644 index af663e463..000000000 --- a/spec/unit/pdk/cli/module/generate_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'spec_helper' -require 'pdk/cli' - -describe 'Running pdk module generate' do - subject { PDK::CLI.instance_variable_get(:@module_generate_cmd) } - - let(:module_name) { 'foo' } - - describe 'when not passed a module name' do - it do - expect do - PDK::CLI.run(['module', 'generate']) - end.to exit_nonzero.and output(a_string_matching(/^USAGE\s+pdk module generate/m)).to_stdout - end - end - - context 'with a yes at the prompt' do - before do - redirector = instance_double(PDK::CLI::Util::CommandRedirector) - allow(redirector).to receive(:target_command) - allow(redirector).to receive(:run).and_return(true) - expect(logger).to receive(:info).with(/New modules are created using the 'pdk new module' command/i) - expect(PDK::CLI::Util::CommandRedirector).to receive(:new).and_return(redirector) - end - - it 'to call to new module generator' do - expect(logger).to receive(:info).with(/Creating new module:/i) - expect(PDK::Generate::Module).to receive(:invoke) - PDK::CLI.run(['module', 'generate', module_name]) - end - - context 'when passed a module name with a forge user' do - let(:module_name) { 'user-test123' } - - it 'validates and parses the module name' do - expect(PDK::Generate::Module).to receive(:invoke).with(hash_including(module_name: 'test123', username: 'user')) - expect(logger).to receive(:info).with("Creating new module: #{module_name}") - PDK::CLI.run(['module', 'generate', module_name]) - end - end - end - - # context 'with a no at the prompt' do - # before(:each) do - # redirector = instance_double('PDK::CLI::Util::CommandRedirector') - # allow(redirector).to receive(:target_command) - # allow(redirector).to receive(:run).and_return(false) - # expect(logger).to receive(:info).with(%r{New modules are created using the ‘pdk new module’ command}i) - # expect(PDK::CLI::Util::CommandRedirector).to receive(:new).and_return(redirector) - # end - - # it 'to not call new module generator' do - # expect(logger).not_to receive(:info).with(%r{Creating new module:}i) - # expect(PDK::Generate::Module).not_to receive(:invoke) - # PDK::CLI.run(['module', 'generate', module_name]) - # end - # end -end diff --git a/spec/unit/pdk/cli/module_spec.rb b/spec/unit/pdk/cli/module_spec.rb deleted file mode 100644 index 8b3bb4fec..000000000 --- a/spec/unit/pdk/cli/module_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' -require 'pdk/cli' - -describe 'Running `pdk module`' do - subject { PDK::CLI.instance_variable_get(:@module_cmd) } - - context 'when no arguments or options are provided' do - it do - expect do - PDK::CLI.run(['module']) - end.to output(/^USAGE\s+pdk module/m).to_stdout - end - end -end