Sha256: 0fcf4f2ee97dcac7c98953c209a1f001d07fdcb3f0ad6919d0897607b473649d

Contents?: true

Size: 1.78 KB

Versions: 19

Compression:

Stored size: 1.78 KB

Contents

require 'opal-webpack-loader/installer_cli'
require 'opal-webpack-loader/version'

module Isomorfeus
  module Installer
    class NewProject
      def self.execute(yarn_and_bundle: true)
        begin
          Dir.mkdir(Isomorfeus::Installer.project_dir)
          Dir.chdir(Isomorfeus::Installer.project_dir)
        rescue
          puts "Directory #{installer.project_dir} could not be created!"
          exit 1
        end

        begin
          Isomorfeus::Installer.create_directories
          Isomorfeus::Installer.install_framework

          OpalWebpackLoader::Installer::CLI.start(['iso'])
          Isomorfeus::Installer.install_webpack_config

          Isomorfeus::Installer.install_styles
          Isomorfeus::Installer.install_js_entries
          Isomorfeus::Installer.install_isomorfeus_entries

          Isomorfeus::Installer.create_components
          Isomorfeus::Installer.create_policy
          Isomorfeus::Installer.create_spec

          Isomorfeus::Installer.create_package_json
          Isomorfeus::Installer.create_gemfile
          Isomorfeus::Installer.create_procfile

          Isomorfeus::Installer.copy_source_dir_files if Isomorfeus::Installer.source_dir

          if yarn_and_bundle
            puts 'Executing yarn install:'
            system('env -i PATH=$PATH yarn install')
            puts 'Executing bundle install:'
            bundle_command =  Gem.bin_path("bundler", "bundle")
            Bundler.with_original_env do
              system("#{Gem.ruby} #{bundle_command} install")
            end
          end

          Dir.chdir('..')
          puts 'Project setup finished, make your dreams come true :)'
        rescue Exception => e
          puts e.backtrace.join("\n")
          puts "Installation failed: #{e.message}"
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
isomorfeus-1.0.0.zeta25 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta24 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta23 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta22 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta21 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta20 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta19 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta18 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta17 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta16 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta15 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta14 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta13 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta12 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta11 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta10 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta9 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta8 lib/isomorfeus/installer/new_project.rb
isomorfeus-1.0.0.zeta6 lib/isomorfeus/installer/new_project.rb