Skip to content

Commit

Permalink
(PDK-748) Wireframe pdk build CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Jan 18, 2018
1 parent 0adbe18 commit 45c4661
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/pdk/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def self.skip_interview_option(dsl)
end

require 'pdk/cli/bundle'
require 'pdk/cli/build'
require 'pdk/cli/convert'
require 'pdk/cli/new'
require 'pdk/cli/test'
Expand Down
43 changes: 43 additions & 0 deletions lib/pdk/cli/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'pdk/cli/util'

module PDK::CLI
@build_cmd = @base_cmd.define_command do
name 'build'
usage _('build [options]')
summary _('Builds a package from the module that can be published to the Puppet Forge.')

option nil, 'target-dir',
_('The target directory where you want PDK to write the package.'),
argument: :required, default: File.join(Dir.pwd, 'pkg')

be_hidden

run do |opts, _args, _cmd|
require 'pdk/module/build'

PDK::CLI::Util.ensure_in_module!(
message: _('`pdk build` can only be run from inside a valid module directory.'),
log_level: :info,
)

module_metadata = PDK::Module::Metadata.from_file('metadata.json')

# TODO: Ensure forge metadata has been set, or call out to interview
# to set it.
#
# module_metadata.interview_for_forge! unless module_metadata.forge_ready?

PDK.logger.info _('Building %{module_name} version %{module_version}') % {
module_name: module_metadata.data['name'],
module_version: module_metadata.data['version'],
}

package_path = PDK::Module::Build.invoke(opts)

PDK.logger.info _('Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}') % {
package_name: 'something',
package_path: package_path,
}
end
end
end
9 changes: 9 additions & 0 deletions lib/pdk/module/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module PDK
module Module
class Build
def self.invoke(_options)
'pkg/dummy-path'
end
end
end
end

0 comments on commit 45c4661

Please sign in to comment.