Sha256: 1402fb1b2cadbdfd0f77ea47a8900763f361d84a2b31dd08a40e5f7851c04836

Contents?: true

Size: 1.99 KB

Versions: 14

Compression:

Stored size: 1.99 KB

Contents

module Hobo
  module Lib
    module Seed
      class Project
        def initialize(opts = {})
          @opts = {
            :replacer => Replacer.new,
            :config_class => Hobo::Config::File,
            :project_config_file => Hobo.project_config_file
          }.merge! opts
        end

        def setup seed, config
          seed.update
          seed.export config[:project_path]
          config[:seed][:version] = seed.version
          config[:hostname] = "#{config[:name]}.dev"
          config[:asset_bucket] = "inviqa-assets-#{config[:name]}"
          config[:vm] = {
            :project_mount_path => "/vagrant"
          }

          @opts[:replacer].replace(config[:project_path], config)
          load_seed_init(config)

          project_path = config[:project_path]
          config.delete :project_path
          @opts[:config_class].save @opts[:project_config_file], config

          initialize_git project_path, config[:git_url]
        end

        private

        def load_seed_init config
          Hobo.project_config = DeepStruct.wrap(config)
          seed_init_file = File.join(config[:project_path], 'seedinit.rb')
          if File.exists?(seed_init_file)
            require seed_init_file
            File.unlink(seed_init_file)
          end
        end

        def initialize_git path, git_url
          Dir.chdir path do
            Hobo::Helper.shell 'git', 'init'
            Hobo::Helper.shell 'git', 'add', '--all'
            Hobo::Helper.shell 'git', 'commit', '-m', "'Initial hobo project'"
            Hobo::Helper.shell 'git', 'checkout', '-b', 'develop'

            # Github for windows gets clever adding origin / upstream remotes in system level gitconfig
            # :facepalm:
            begin
              Hobo::Helper.shell 'git', 'remote', 'add', 'origin', git_url
            rescue Hobo::ExternalCommandError
              Hobo::Helper.shell 'git', 'remote', 'set-url', 'origin', git_url
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.11 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc11 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc10 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc9 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc8 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc7 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc6 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc4 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.10.pre.rc2 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.9 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.9.pre.rc2 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.9.pre.rc1 lib/hobo/lib/seed/project.rb
hobo-inviqa-0.0.9.pre.alpha lib/hobo/lib/seed/project.rb