Sha256: 09c469e5684444f54fbf3d3dc2d980b938bd62ca8e39d15ccfa642b3d937906a

Contents?: true

Size: 1.4 KB

Versions: 62

Compression:

Stored size: 1.4 KB

Contents

module Pfm
  module Command
    module GeneratorCommands
      class ServerBuild < Base
        banner 'Usage: pfm generate server-build NAME [options]'

        options.merge!(SharedGeneratorOptions.options)

        def run
          read_and_validate_params
          if params_valid?
            setup_context

            mk_build_dirs
            default_build_files
            default_cookbooks
          else
            errors.each { |error| err("Error: #{error}") }
            parse_options(params)
            msg(opt_parser)
            1
          end
        end

        def mk_build_dirs
          %w(
            chef/bake/cookbooks
            chef/fry/cookbooks
            chef/vendor/cookbooks
          ).each do |path|
            FileUtils.mkdir_p("#{base_dir}/#{path}", verbose: verbose?(params))
          end
        end

        def default_build_files
          %w(
            metadata
          ).each do |file|
            FileUtils.touch("#{base_dir}/#{file}", verbose: verbose?(params))
          end
        end

        def default_cookbooks
          %w(
            chef/bake/cookbooks/bake
            chef/fry/cookbooks/fry
          ).each do |cookbook|
            system("chef generate cookbook #{base_dir}/#{cookbook} -g #{__dir__}/skeletons/code_generator")
          end
        end

        def base_dir
          "builds/#{@params.first}"
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
idlc-sdk-pfm-1.0.3 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.2 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.1 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc18 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc17 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc16 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc15 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc14 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc13 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc12 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc11 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc10 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc9 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc8 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc7 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc6 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc5 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc4 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc3 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.0.0.rc2 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb