jive 0.2.3 → 0.4.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: 154a09fc65037768dd5356b9b09c02f2f25f8548be75663893e6867922d0f0d1
4
+ data.tar.gz: 9fa27240f2f7e0f009f271e95606ac3c162b8836fa5cf4b79b31ef79271bcf2d
5
5
  SHA512:
6
- metadata.gz: 851701b9f269cbdf0f56fe08a84cfe45551540d6b2916aee515315aef700378def2253cfbb6de9f75ca25e14982384c2a30ca3c04c4ffcea8b06c834aa82bb55
7
- data.tar.gz: 2966d909607b30a2db80b023f554c0f81eda2fdbb22feb161eb3716e87cf8afc92652788a3afd753af7109a25751512e99ff9f2ce3a9e224b3f58ae0f6d2ca35
6
+ metadata.gz: 3dffd40c02972768c156c6755b9f01af441ae64dc715f27fd515ed10f0a4d849c5c69919129dffaf82a68f052a0950693e4613c1d035c7d8ec318a35651b72fa
7
+ data.tar.gz: 5931d35f12bb6bd418ad4ac732992e3674c6dfb2dd7eec34e0691440fa4c279d3636dcd3a59564c794e5c35bf120a5839bb6436cd75dfa81a63d36bef927f094
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://github.com/xlgmokha/jive/workflows/ci/badge.svg)](https://github.com/xlgmokha/jive/actions)
4
4
 
5
- Hi!
5
+ 🐕 Woof!
6
6
 
7
7
  ## Installation
8
8
 
data/jive.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  "README.md",
21
21
  "jive.gemspec",
22
22
  "jive.sh"
23
- ]
23
+ ] + Dir["lib/**/templates/*.md"]
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
data/lib/jive.rb CHANGED
@@ -4,8 +4,11 @@ require "fileutils"
4
4
  require "open3"
5
5
 
6
6
  require "jive/batch_runner"
7
+ require "jive/docker"
7
8
  require "jive/git"
8
9
  require "jive/popen"
10
+ require "jive/project"
11
+ require "jive/pull_request"
9
12
  require "jive/runner"
10
13
  require "jive/shell"
11
14
  require "jive/version"
@@ -20,4 +23,8 @@ module Jive
20
23
  def self.run(tasks)
21
24
  Jive::BatchRunner.new.run(tasks)
22
25
  end
26
+
27
+ def self.shell
28
+ @shell ||= ::Jive::Shell.new
29
+ end
23
30
  end
data/lib/jive/cli.rb CHANGED
@@ -9,18 +9,52 @@ 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
 
16
- desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
17
- def cd(slug)
18
- runner.run_safely { Git.new(runner).cd(slug) }
18
+ def self.handle_no_command_error(name)
19
+ ::Jive::Cli::App.start(["exec", name])
19
20
  end
20
21
 
21
- desc "clone <org>/<project>", "git clone to ~/src/github.com/<org>/<project>"
22
- def clone(slug)
23
- runner.run_safely { Git.new(runner).clone(slug) }
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 Git.new.semantic_help
45
+ end
46
+
47
+ method_option :host, type: :string, default: "github.com"
48
+ desc "clone <org>/<project>", "git clone to ~/src/github.com/<org>/<project>"
49
+ def clone(slug)
50
+ host = options[:host]
51
+ Jive.shell.run_safely { Git.new(Jive.shell).clone(slug, host: host) }
52
+ end
53
+ end)
54
+
55
+ desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
56
+ def cd(slug)
57
+ Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
24
58
  end
25
59
 
26
60
  desc "exec <command>", "run command from jive.yml"
@@ -28,24 +62,27 @@ module Jive
28
62
  path = Pathname.pwd.join("jive.yml")
29
63
  return shell.error("Error: jive.yml not found") unless path.exist?
30
64
 
31
- runner.run_safely do
32
- runner.execute(YAML.safe_load(path.read).dig("commands", command))
65
+ Jive.shell.run_safely do
66
+ Jive.shell.execute(YAML.safe_load(path.read).dig("commands", command))
33
67
  end
34
68
  end
35
69
 
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
70
+ desc "bootstrap", "bootstrap the current project"
71
+ def bootstrap
72
+ Project
73
+ .new(Pathname.pwd)
74
+ .bootstrap(Jive.shell)
43
75
  end
44
76
 
45
- private
77
+ desc "pr URL", "pull request"
78
+ def pr(url)
79
+ pr = PullRequest.new(url)
80
+ pr.edit(ENV["EDITOR"])
81
+ end
46
82
 
47
- def runner
48
- @runner ||= ::Jive::Shell.new
83
+ desc "setup", "provide instructions to integrate into shell"
84
+ def setup
85
+ print "source #{::Jive.root.join("jive.sh")}"
49
86
  end
50
87
  end
51
88
  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
data/lib/jive/git.rb CHANGED
@@ -4,23 +4,21 @@ module Jive
4
4
  class Git
5
5
  attr_reader :shell
6
6
 
7
- def initialize(shell)
7
+ def initialize(shell = ::Jive.shell)
8
8
  @shell = shell
9
9
  end
10
10
 
11
- def clone(slug)
12
- dir = target_dir_for(slug)
11
+ def clone(slug, host: "github.com")
12
+ dir = target_dir_for(slug, host: host)
13
13
  unless dir.exist?
14
- shell.run_each([
15
- [:mkdir, "-p", dir.parent.to_s],
16
- [:git, "clone", "git@github.com:#{slug}.git", dir]
17
- ])
14
+ shell.execute([:mkdir, "-p", dir.parent.to_s])
15
+ shell.execute([:git, "clone", "git@#{host}:#{slug}", dir])
18
16
  end
19
- cd(slug)
17
+ cd(slug, host: host) if dir.exist?
20
18
  end
21
19
 
22
- def cd(slug)
23
- dir = target_dir_for(slug)
20
+ def cd(slug, host: "github.com")
21
+ dir = target_dir_for(slug, host: host)
24
22
  if dir.exist?
25
23
  shell.after_run([
26
24
  ["cd", dir],
@@ -31,10 +29,33 @@ module Jive
31
29
  end
32
30
  end
33
31
 
32
+ def semantic_help
33
+ <<~MESSAGE
34
+ Format: <type>(<scope>): <subject>
35
+
36
+ <scope> is optional
37
+
38
+ feat: add hat wobble
39
+ ^--^ ^------------^
40
+ | |
41
+ | +-> Summary in present tense.
42
+ |
43
+ +-------> Type: chore, docs, feat, fix, refactor, style, or test.
44
+
45
+ chore: updating grunt tasks etc; no production code change
46
+ docs: changes to the documentation
47
+ feat: new feature for the user, not a new feature for build script
48
+ fix: bug fix for the user, not a fix to a build script
49
+ refactor: refactoring production code, eg. renaming a variable
50
+ style: formatting, missing semi colons, etc; no production code change
51
+ test: adding missing tests, refactoring tests; no production code change
52
+ MESSAGE
53
+ end
54
+
34
55
  private
35
56
 
36
- def target_dir_for(slug)
37
- Pathname.new(Dir.home).join("src/github.com/#{slug}")
57
+ def target_dir_for(slug, host:)
58
+ Pathname.new(Dir.home).join("src/#{host}/#{slug}")
38
59
  end
39
60
  end
40
61
  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
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class PullRequest
5
+ attr_reader :dir, :uri
6
+
7
+ def initialize(url)
8
+ @uri = URI.parse(url)
9
+ @dir = Pathname(Dir.home).join(".jive").join(uri.host).join(uri.path[1..-1])
10
+ Jive.shell.execute([:mkdir, "-p", @dir]) unless @dir.exist?
11
+ end
12
+
13
+ def edit(editor)
14
+ Jive.shell.execute([editor, readme.to_s])
15
+ end
16
+
17
+ private
18
+
19
+ def template
20
+ Jive.root.join("lib/jive/templates/pull_request_template.md")
21
+ end
22
+
23
+ def readme
24
+ @readme ||=
25
+ begin
26
+ dir.join("README.md").tap do |readme|
27
+ readme.write(template.read) unless readme.exist?
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,51 @@
1
+ # Pull Request Template
2
+
3
+ ## Why is this needed?
4
+
5
+ ## What does this do?
6
+
7
+ <!--
8
+ Include a summary of the change and which issue is fixed.
9
+ Include relevant motivation and context.
10
+ List any dependencies that are required for this change.
11
+ -->
12
+
13
+ Fixes # (issue)
14
+
15
+ ### Screenshots
16
+
17
+ Before:
18
+
19
+ ![before]()
20
+
21
+ After:
22
+
23
+ ![after]()
24
+
25
+ ## Type of change
26
+
27
+ Delete options that are not relevant.
28
+
29
+ - [ ] Bug fix (non-breaking change which fixes an issue)
30
+ - [ ] New feature (non-breaking change which adds functionality)
31
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
32
+ - [ ] This change requires a documentation update
33
+
34
+ ## Verification Plan
35
+
36
+ How are we going to verify this change?
37
+
38
+ - [ ] Step 1
39
+ - [ ] Step 2
40
+
41
+ ## Checklist
42
+
43
+ - [ ] Clear description explaining the relevancy of the contribution.
44
+ - [ ] Unit, integration, and system tests.
45
+ - [ ] Regression and bugs are covered with tests.
46
+ - [ ] [Performance guidelines][performance]
47
+ - [ ] [Secure coding guidelines][secure]
48
+ - [ ] Documentation Updated
49
+
50
+ [performance]: https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html
51
+ [secure]: https://docs.gitlab.com/ee/development/secure_coding_guidelines.html
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.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-07 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -110,10 +110,14 @@ 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
117
+ - lib/jive/pull_request.rb
115
118
  - lib/jive/runner.rb
116
119
  - lib/jive/shell.rb
120
+ - lib/jive/templates/pull_request_template.md
117
121
  - lib/jive/version.rb
118
122
  homepage: https://rubygems.org/gems/jive
119
123
  licenses: