Commit 59cdccf

mo khan <mo@mokhan.ca>
2021-02-07 19:01:00
feat: add bootstrap command
1 parent 2ddb427
Changed files (3)
lib/jive/cli.rb
@@ -33,6 +33,13 @@ module Jive
         end
       end
 
+      desc "bootstrap", "bootstrap the current project"
+      def bootstrap
+        Project
+          .new(Pathname.pwd)
+          .bootstrap(runner)
+      end
+
       desc "setup", "provide instructions to integrate into shell"
       def setup
         say <<~MESSAGE
lib/jive/project.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Jive
+  class Project
+    attr_reader :path
+
+    def initialize(path)
+      @path = path
+    end
+
+    def bootstrap(shell)
+      tasks = []
+      tasks << [:asdf, "install"]
+      tasks << [:bundle, "install"] if bundler?
+
+      shell.run_safely do
+        shell.run_each(tasks)
+      end
+    end
+
+    private
+
+    def bundler?
+      path.join("Gemfile").exist? ||
+        path.glob("*.gemspec").any?
+    end
+  end
+end
lib/jive.rb
@@ -6,6 +6,7 @@ require "open3"
 require "jive/batch_runner"
 require "jive/git"
 require "jive/popen"
+require "jive/project"
 require "jive/runner"
 require "jive/shell"
 require "jive/version"