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
iapi-idlc-sdk-pfm-1.0.18 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.17 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.16 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.15 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.14 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.13 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.12 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.11 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.10 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.9 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.8 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.7 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.6 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.5 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
iapi-idlc-sdk-pfm-1.0.4 lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.2.2 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.2.1 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.2.0 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.1.4 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb
idlc-sdk-pfm-1.1.3 lib/idlc-sdk-pfm/command/generator_commands/server_build.rb