summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-02-07 12:01:00 -0700
committermo khan <mo@mokhan.ca>2021-02-07 12:01:00 -0700
commit59cdccff5125ba75c9ae5d8aab06789a28d86c57 (patch)
tree07011ddc7502e48dab7cc08625d65dedf8e8145e /lib
parent2ddb427813c64fb11d52b94185f49eaddac73627 (diff)
feat: add bootstrap command
Diffstat (limited to 'lib')
-rw-r--r--lib/jive.rb1
-rw-r--r--lib/jive/cli.rb7
-rw-r--r--lib/jive/project.rb28
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/jive.rb b/lib/jive.rb
index 08e32c4..32cb194 100644
--- a/lib/jive.rb
+++ b/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"
diff --git a/lib/jive/cli.rb b/lib/jive/cli.rb
index 2a9982a..9aa334a 100644
--- a/lib/jive/cli.rb
+++ b/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
diff --git a/lib/jive/project.rb b/lib/jive/project.rb
new file mode 100644
index 0000000..5b9f634
--- /dev/null
+++ b/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