jive 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4e977bb29d50702ee9aa80637724df04b013cf102459d68253463f2054783a1
4
- data.tar.gz: fc7378411041145f99299af960523978bae18943444747f65b8ff6abdb311cb7
3
+ metadata.gz: bb4eb9f7fb9d9ff62d257c2ed146acd462cb2c4db1b07a4a3cc0a43399ce1073
4
+ data.tar.gz: bb87b75d4635bc12169def9878ab89c7822df1497cd2a39a7aa209c8d8e01489
5
5
  SHA512:
6
- metadata.gz: 851701b9f269cbdf0f56fe08a84cfe45551540d6b2916aee515315aef700378def2253cfbb6de9f75ca25e14982384c2a30ca3c04c4ffcea8b06c834aa82bb55
7
- data.tar.gz: 2966d909607b30a2db80b023f554c0f81eda2fdbb22feb161eb3716e87cf8afc92652788a3afd753af7109a25751512e99ff9f2ce3a9e224b3f58ae0f6d2ca35
6
+ metadata.gz: 7d72ccd8285b0726e1465f6caec69dfddec99b0a9b60594da5de94e4dc898356e009d4e924ec9ae863396e2f4fa2cefa2b912793ae69424c345443de16406ed2
7
+ data.tar.gz: 625c5dc105d2b53c9d9d7a6173761523439ea506dee48dc895252e4392b399a1c5b7d274a5f4bac1cffbdf72661f8c663f561c3ab4b5790f82d3c2b5df81b10c
data/lib/jive.rb CHANGED
@@ -6,6 +6,7 @@ require "open3"
6
6
  require "jive/batch_runner"
7
7
  require "jive/git"
8
8
  require "jive/popen"
9
+ require "jive/project"
9
10
  require "jive/runner"
10
11
  require "jive/shell"
11
12
  require "jive/version"
@@ -20,4 +21,8 @@ module Jive
20
21
  def self.run(tasks)
21
22
  Jive::BatchRunner.new.run(tasks)
22
23
  end
24
+
25
+ def self.shell
26
+ @shell ||= ::Jive::Shell.new
27
+ end
23
28
  end
data/lib/jive/cli.rb CHANGED
@@ -9,18 +9,69 @@ require "jive"
9
9
  module Jive
10
10
  module Cli
11
11
  class App < Thor
12
+ package_name "jive"
13
+
12
14
  def self.exit_on_failure?
13
15
  true
14
16
  end
15
17
 
18
+ def self.handle_no_command_error(name)
19
+ ::Jive::Cli::App.start(["exec", name])
20
+ end
21
+
22
+ desc "docker SUBCOMMAND ...ARGS", "docker commands"
23
+ subcommand "docker", (Class.new(Thor) do
24
+ desc "build", "build the Dockerfile in the current directory"
25
+ def build
26
+ Docker.new.build(Pathname.pwd)
27
+ end
28
+
29
+ desc "launch", "launch a shell into a container"
30
+ def launch
31
+ Docker.new.launch(Pathname.pwd)
32
+ end
33
+
34
+ desc "size", "print the size of each image"
35
+ def size
36
+ Docker.new.size(Pathname.pwd)
37
+ end
38
+ end)
39
+
40
+ desc "git SUBCOMMAND ...ARGS", "git commands"
41
+ subcommand "git", (Class.new(Thor) do
42
+ desc "semantic", "Print help for semantic commit messages"
43
+ def semantic
44
+ say <<~MESSAGE
45
+ Format: <type>(<scope>): <subject>
46
+
47
+ <scope> is optional
48
+
49
+ feat: add hat wobble
50
+ ^--^ ^------------^
51
+ | |
52
+ | +-> Summary in present tense.
53
+ |
54
+ +-------> Type: chore, docs, feat, fix, refactor, style, or test.
55
+
56
+ chore: updating grunt tasks etc; no production code change
57
+ docs: changes to the documentation
58
+ feat: new feature for the user, not a new feature for build script
59
+ fix: bug fix for the user, not a fix to a build script
60
+ refactor: refactoring production code, eg. renaming a variable
61
+ style: formatting, missing semi colons, etc; no production code change
62
+ test: adding missing tests, refactoring tests; no production code change
63
+ MESSAGE
64
+ end
65
+ end)
66
+
16
67
  desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
17
68
  def cd(slug)
18
- runner.run_safely { Git.new(runner).cd(slug) }
69
+ Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
19
70
  end
20
71
 
21
72
  desc "clone <org>/<project>", "git clone to ~/src/github.com/<org>/<project>"
22
73
  def clone(slug)
23
- runner.run_safely { Git.new(runner).clone(slug) }
74
+ Jive.shell.run_safely { Git.new(Jive.shell).clone(slug) }
24
75
  end
25
76
 
26
77
  desc "exec <command>", "run command from jive.yml"
@@ -28,24 +79,21 @@ module Jive
28
79
  path = Pathname.pwd.join("jive.yml")
29
80
  return shell.error("Error: jive.yml not found") unless path.exist?
30
81
 
31
- runner.run_safely do
32
- runner.execute(YAML.safe_load(path.read).dig("commands", command))
82
+ Jive.shell.run_safely do
83
+ Jive.shell.execute(YAML.safe_load(path.read).dig("commands", command))
33
84
  end
34
85
  end
35
86
 
36
- desc "setup", "provide instructions to integrate into shell"
37
- def setup
38
- say <<~MESSAGE
39
- Include the following in your ~/.bash_profile
40
-
41
- source #{::Jive.root.join("jive.sh")}
42
- MESSAGE
87
+ desc "bootstrap", "bootstrap the current project"
88
+ def bootstrap
89
+ Project
90
+ .new(Pathname.pwd)
91
+ .bootstrap(Jive.shell)
43
92
  end
44
93
 
45
- private
46
-
47
- def runner
48
- @runner ||= ::Jive::Shell.new
94
+ desc "setup", "provide instructions to integrate into shell"
95
+ def setup
96
+ print "source #{::Jive.root.join("jive.sh")}"
49
97
  end
50
98
  end
51
99
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class Docker
5
+ attr_reader :shell
6
+
7
+ def initialize(shell = ::Jive.shell)
8
+ @shell = shell
9
+ end
10
+
11
+ def build(path)
12
+ shell.execute([
13
+ "docker",
14
+ "build",
15
+ "--network=host",
16
+ "-t", image_tag_for(path),
17
+ "."
18
+ ], env: { "DOCKER_BUILDKIT" => "1" })
19
+ end
20
+
21
+ def launch(path)
22
+ shell.execute([
23
+ "docker",
24
+ "run",
25
+ "--network=host",
26
+ '--entrypoint=""',
27
+ "-it", image_tag_for(path),
28
+ "/bin/bash -l"
29
+ ])
30
+ end
31
+
32
+ def size(path)
33
+ shell.execute([
34
+ :docker, "image", "inspect", '--format="{{.Size}}"',
35
+ image_tag_for(path)
36
+ ])
37
+ end
38
+
39
+ private
40
+
41
+ def image_tag_for(path)
42
+ "#{path.basename.to_s.downcase}:latest"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class Project
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ end
10
+
11
+ def bootstrap(shell)
12
+ tasks = []
13
+ tasks << [:asdf, "install"]
14
+ tasks << [:bundle, "install"] if bundler?
15
+ tasks << [:yarn, "install"] if yarn?
16
+
17
+ shell.run_safely do
18
+ shell.run_each(tasks)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def bundler?
25
+ path.join("Gemfile").exist? ||
26
+ path.glob("*.gemspec").any?
27
+ end
28
+
29
+ def yarn?
30
+ path.join("yarn.lock").exist?
31
+ end
32
+ end
33
+ end
data/lib/jive/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jive
4
- VERSION = "0.2.3"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
@@ -110,8 +110,10 @@ files:
110
110
  - lib/jive.rb
111
111
  - lib/jive/batch_runner.rb
112
112
  - lib/jive/cli.rb
113
+ - lib/jive/docker.rb
113
114
  - lib/jive/git.rb
114
115
  - lib/jive/popen.rb
116
+ - lib/jive/project.rb
115
117
  - lib/jive/runner.rb
116
118
  - lib/jive/shell.rb
117
119
  - lib/jive/version.rb