jive 0.4.4 → 0.5.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: a034483cc87f821d9da5acd3205a179fbbcc28a9f91b8ef491e9e95802272d2f
4
- data.tar.gz: 30712e04895db03f07c1ea07d784a7f0ca39f6ecd7e6b8cf8fcb455e97f6f23f
3
+ metadata.gz: 907ad4223ef1469a013283c0dc7c781e27ee5da0b4cb0ee6e3b7b9651cb4d986
4
+ data.tar.gz: 9bae7e21dc61f89d4272896280673e28e687f3f88d98ecddea1918f8bad92c3d
5
5
  SHA512:
6
- metadata.gz: 53f26b41d34b6e58f68aac53a4618daddba1380a7d8a0e1f5c1cf3b1f0ea9401d4d0ef04a66ea67c6e6d5ef924bf8aa75099f43f0a9c17002266d42e2384f385
7
- data.tar.gz: 3815d23eb9aee2d09fda3784e7bd0f35f0721648b14a3e266f6c5606747efe21049425553f20017730d7eb345da3b5e507f882fae75fd4231251ad12f9d6a8ee
6
+ metadata.gz: 51b4173ac6ad187e61f911418fc022d664d93ced8c540e59c6fb73cdcded37531d223160902227f95fcf2b5fb559ec73fedb42f517090d111672c035c9f82adc
7
+ data.tar.gz: 9a25ed11f67d138d940f0dcc0c3b294f99115a9cf8ebd0a725379435d8faf7fbd9fd1bd54d236b1ea63d2883f5188946e9cd05c2c95aca54ce48ff6cb1e35577
data/exe/jive CHANGED
@@ -3,4 +3,13 @@
3
3
 
4
4
  require "jive/cli"
5
5
 
6
- ::Jive::Cli::App.start(ARGV)
6
+ Signal.trap("INT") do
7
+ exit 1
8
+ end
9
+
10
+ begin
11
+ ::Jive::Cli::App.start(ARGV)
12
+ rescue StandardError => e
13
+ puts "ERROR: #{e.message}"
14
+ exit 1
15
+ end
data/jive.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  $ jive setup
31
31
  MESSAGE
32
32
 
33
+ spec.add_dependency "cli-ui", "~> 1.5"
33
34
  spec.add_dependency "rugged", "~> 1.1"
34
35
  spec.add_dependency "thor", "~> 1.1"
35
36
  spec.add_development_dependency "minitest", "~> 5.0"
data/lib/jive.rb CHANGED
@@ -8,6 +8,7 @@ require "uri"
8
8
  require "jive/batch_runner"
9
9
  require "jive/docker"
10
10
  require "jive/git"
11
+ require "jive/issue"
11
12
  require "jive/popen"
12
13
  require "jive/project"
13
14
  require "jive/pull_request"
@@ -30,4 +31,18 @@ module Jive
30
31
  def self.shell
31
32
  @shell ||= ::Jive::Shell.new
32
33
  end
34
+
35
+ def self.home
36
+ @home ||= Pathname(Dir.home).join(".jive")
37
+ end
38
+
39
+ def self.prompt?(items, display: ->(x) { x })
40
+ CLI::UI::Prompt.ask("Choose?") do |handler|
41
+ items.each do |item|
42
+ handler.option(display.call(item)) do |_selection|
43
+ return item
44
+ end
45
+ end
46
+ end
47
+ end
33
48
  end
data/lib/jive/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "cli/ui"
3
4
  require "pathname"
4
5
  require "thor"
5
6
  require "yaml"
@@ -52,6 +53,22 @@ module Jive
52
53
  end
53
54
  end)
54
55
 
56
+ desc "issue SUBCOMMAND ...ARGS", "issue things"
57
+ subcommand "issue", (Class.new(Thor) do
58
+ desc "list <type>", "List the issues"
59
+ def list(type = Issue.what_type?)
60
+ issues = Issue.for(type)
61
+ issue = Jive.prompt?(issues, display: ->(x) { x.file_name })
62
+ issue.edit
63
+ end
64
+
65
+ desc "create <type>", "Create a new issue"
66
+ def create(type = Issue.what_type?)
67
+ issue = Issue.create!(name: ask("Name:"), type: type)
68
+ issue.edit
69
+ end
70
+ end)
71
+
55
72
  desc "cd <org>/<project>", "cd to ~/src/github.com/<org>/<project>"
56
73
  def cd(slug)
57
74
  Jive.shell.run_safely { Git.new(Jive.shell).cd(slug) }
@@ -74,11 +91,9 @@ module Jive
74
91
  .bootstrap(Jive.shell)
75
92
  end
76
93
 
77
- desc "pr URL", "pull request"
78
- def pr(url = Repo.current.canonical_url)
79
- return say("Invalid url") && exit(1) unless url
80
-
81
- pr = PullRequest.new(url)
94
+ desc "pr", "pull request"
95
+ def pr
96
+ pr = PullRequest.new(repo: Repo.current)
82
97
  pr.edit(ENV["EDITOR"])
83
98
  end
84
99
 
data/lib/jive/issue.rb ADDED
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jive
4
+ class Issue
5
+ class << self
6
+ def what_type?
7
+ Jive.prompt?(
8
+ Jive.root
9
+ .join("lib/jive/templates")
10
+ .glob("*.md")
11
+ .map { |x| x.basename.to_s.gsub(".md", "") }
12
+ )
13
+ end
14
+
15
+ def create!(name:, type:, repo: Repo.current)
16
+ new(repo: repo, name: name, type: type)
17
+ end
18
+
19
+ def for(type, repo: Repo.current)
20
+ dir_for(type, repo: repo).glob("*.md").map do |x|
21
+ name = x.basename.to_s.gsub(".md", "")
22
+ new(repo: repo, name: name, type: type)
23
+ end
24
+ end
25
+
26
+ def dir_for(type, repo: Repo.current)
27
+ Jive.home
28
+ .join(repo.uri.host)
29
+ .join(repo.nwo)
30
+ .join(type)
31
+ end
32
+ end
33
+
34
+ def initialize(name:, type:, repo: Repo.current)
35
+ @repo = repo
36
+ @type = type
37
+ @name = name
38
+ end
39
+
40
+ def file_name
41
+ "#{name.gsub(/[^a-z0-9\-_]+/i, "-").downcase}.md"
42
+ end
43
+
44
+ def edit(editor: ENV["EDITOR"])
45
+ Jive.shell.execute([editor, issue.to_s])
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :repo, :name, :type
51
+
52
+ def issue
53
+ @issue ||=
54
+ begin
55
+ dir = self.class.dir_for(type, repo: repo)
56
+ Jive.shell.execute([:mkdir, "-p", dir])
57
+ dir.join(file_name).tap do |file|
58
+ file.write(template_for(type).read) unless file.exist?
59
+ end
60
+ end
61
+ end
62
+
63
+ def template_for(type)
64
+ Jive.root.join("lib/jive/templates/#{type}.md")
65
+ end
66
+ end
67
+ end
@@ -4,9 +4,8 @@ module Jive
4
4
  class PullRequest
5
5
  attr_reader :dir, :uri
6
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])
7
+ def initialize(repo: Repo.current)
8
+ @dir = Jive.home.join(repo.uri.host).join(repo.branch)
10
9
  Jive.shell.execute([:mkdir, "-p", @dir]) unless @dir.exist?
11
10
  end
12
11
 
@@ -17,7 +16,7 @@ module Jive
17
16
  private
18
17
 
19
18
  def template
20
- Jive.root.join("lib/jive/templates/pull_request_template.md")
19
+ Jive.root.join("lib/jive/templates/pull_request.md")
21
20
  end
22
21
 
23
22
  def readme
data/lib/jive/repo.rb CHANGED
@@ -8,6 +8,10 @@ module Jive
8
8
  @repo = Rugged::Repository.new(path.to_s)
9
9
  end
10
10
 
11
+ def uri
12
+ @uri ||= URI.parse(canonical_url)
13
+ end
14
+
11
15
  def canonical_url
12
16
  remote = @repo.remotes.find { |x| x.name == "origin" }
13
17
  return if remote.nil?
@@ -15,6 +19,15 @@ module Jive
15
19
  ssh?(remote) ? url_for_ssh(remote) : url_for(remote)
16
20
  end
17
21
 
22
+ def nwo
23
+ segments = uri.path.split("/")
24
+ "#{segments[1]}/#{segments[2].gsub(".git", "")}"
25
+ end
26
+
27
+ def branch
28
+ uri.path[1..-1]
29
+ end
30
+
18
31
  class << self
19
32
  def current
20
33
  @current ||= new(Pathname.pwd)
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: "Defect Template"
3
+ description: |
4
+ ---
5
+
6
+ ### Summary
7
+
8
+ <!-- Summarize the defect encountered concisely. -->
9
+
10
+ ### Steps to reproduce
11
+
12
+ <!--
13
+ Describe how one can reproduce the issue - this is very important.
14
+ Please use an ordered list.
15
+ -->
16
+
17
+ ### Example Project
18
+
19
+ <!--
20
+ Please create an example project here on GitHub.com that exhibits the problematic
21
+ behavior, and link to it here in the bug report.
22
+
23
+ If you are using an older version of GitHub.com,
24
+ this will also determine whether the bug is fixed
25
+ in a more recent version.
26
+ -->
27
+
28
+ ### What is the current *bug* behavior?
29
+
30
+ <!-- Describe what actually happens. -->
31
+
32
+ ### What is the expected *correct* behavior?
33
+
34
+ <!-- Describe what you should see instead. -->
35
+
36
+ ### Relevant logs and/or screenshots
37
+
38
+ <!--
39
+ Paste any relevant logs - please use code blocks (```) to format console output,
40
+ logs, and code.
41
+ -->
42
+
43
+ ### Possible fixes
44
+
45
+ <!-- If you can, link to the line of code that might be responsible for the problem. -->
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: "Feature Template"
3
+ description: |
4
+ This is used to break-up a large piece of work into smaller,
5
+ discrete tasks that can move independently through the build workflow steps.
6
+ ---
7
+
8
+ As a `[persona]`, I `[want to]`, so that `[goal]`.
9
+
10
+ # Why are we doing this work?
11
+
12
+ <!--
13
+ A brief explanation of the why, not the what or how.
14
+ Assume the reader doesn't know the background and won't have time to dig-up
15
+ information from comment threads.
16
+ -->
17
+
18
+ # Tasks
19
+
20
+ <!--
21
+ Steps and the parts of the code that will need to get updated.
22
+ The plan can also call-out responsibilities for other team members or teams.
23
+
24
+ e.g.:
25
+
26
+ - [ ] ~frontend Step 1
27
+ - [ ] `@person` Step 1a
28
+ - [ ] ~frontend Step 2
29
+ - [ ] ~backend Step 3
30
+ -->
31
+
32
+ # Relevant links
33
+
34
+ <!--
35
+ Information that developers might need to refer to when implementing the issue.
36
+
37
+ - [Design Issue](https://github.com/xlgmokha/project/issues/<id>)
38
+ - [Similar implementation](https://github.com/xlgmokha/project/pull/<id>)
39
+ -->
40
+
41
+ # Non-functional requirements
42
+
43
+ <!-- Add details for required items and delete others. -->
44
+
45
+ - [ ] Documentation:
46
+ - [ ] Feature flag:
47
+ - [ ] Observability:
48
+ - [ ] Performance:
49
+ - [ ] Testing:
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.4.4"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.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-03-20 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cli-ui
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rugged
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -126,13 +140,16 @@ files:
126
140
  - lib/jive/cli.rb
127
141
  - lib/jive/docker.rb
128
142
  - lib/jive/git.rb
143
+ - lib/jive/issue.rb
129
144
  - lib/jive/popen.rb
130
145
  - lib/jive/project.rb
131
146
  - lib/jive/pull_request.rb
132
147
  - lib/jive/repo.rb
133
148
  - lib/jive/runner.rb
134
149
  - lib/jive/shell.rb
135
- - lib/jive/templates/pull_request_template.md
150
+ - lib/jive/templates/bug.md
151
+ - lib/jive/templates/feature.md
152
+ - lib/jive/templates/pull_request.md
136
153
  - lib/jive/version.rb
137
154
  homepage: https://rubygems.org/gems/jive
138
155
  licenses: