wassup 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.gitignore +4 -0
- data/Gemfile.lock +19 -1
- data/README.md +45 -5
- data/bin/wassup +6 -1
- data/docs/.gitignore +20 -0
- data/docs/README.md +41 -0
- data/docs/babel.config.js +3 -0
- data/docs/blog/2021-12-09-welcome/index.md +8 -0
- data/docs/blog/authors.yml +5 -0
- data/docs/docs/Supfile-basics/_category_.json +4 -0
- data/docs/docs/Supfile-basics/understanding-the-supfile.md +50 -0
- data/docs/docs/intro.md +54 -0
- data/docs/docusaurus.config.js +110 -0
- data/docs/package-lock.json +21196 -0
- data/docs/package.json +43 -0
- data/docs/sidebars.js +31 -0
- data/docs/src/components/HomepageFeatures.module.css +10 -0
- data/docs/src/components/HomepageFeatures.tsx +60 -0
- data/docs/src/css/custom.css +28 -0
- data/docs/src/pages/index.module.css +36 -0
- data/docs/src/pages/index.tsx +39 -0
- data/docs/src/pages/markdown-page.md +7 -0
- data/docs/static/.nojekyll +0 -0
- data/docs/static/img/demo-supfile.png +0 -0
- data/docs/static/img/favicon.ico +0 -0
- data/docs/static/img/logo.svg +27 -0
- data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
- data/docs/static/img/tutorial/localeDropdown.png +0 -0
- data/docs/static/img/tutorial-intro-starter-screenshot.png +0 -0
- data/docs/static/img/undraw_docusaurus_mountain.svg +170 -0
- data/docs/static/img/undraw_docusaurus_react.svg +169 -0
- data/docs/static/img/undraw_docusaurus_tree.svg +1 -0
- data/docs/static/img/wassup-long.png +0 -0
- data/docs/static/img/wassup-screenshot.png +0 -0
- data/docs/static/img/wassup.png +0 -0
- data/docs/static/video/wassup-demo.mov +0 -0
- data/docs/tsconfig.json +7 -0
- data/examples/basic/Supfile +195 -0
- data/examples/debug/Supfile +131 -0
- data/examples/josh-fastlane/README.md +14 -0
- data/examples/josh-fastlane/Supfile +70 -109
- data/examples/josh-fastlane/demo.png +0 -0
- data/examples/simple/Supfile +17 -0
- data/examples/starter/Supfile +44 -0
- data/lib/wassup/app.rb +178 -10
- data/lib/wassup/color.rb +81 -0
- data/lib/wassup/helpers/circleci.rb +75 -0
- data/lib/wassup/helpers/github.rb +137 -0
- data/lib/wassup/helpers/netlify.rb +70 -0
- data/lib/wassup/helpers/shortcut.rb +114 -0
- data/lib/wassup/pane.rb +298 -90
- data/lib/wassup/pane_builder.rb +74 -3
- data/lib/wassup/version.rb +1 -1
- data/lib/wassup.rb +6 -0
- data/wassup.gemspec +1 -0
- metadata +61 -2
@@ -0,0 +1,75 @@
|
|
1
|
+
module Wassup
|
2
|
+
module Helpers
|
3
|
+
module CircleCI
|
4
|
+
def self.workflows(vcs:, org:, repo:, limit_days: nil)
|
5
|
+
require 'json'
|
6
|
+
require 'rest-client'
|
7
|
+
|
8
|
+
resp = RestClient::Request.execute(
|
9
|
+
method: :get,
|
10
|
+
url: "https://circleci.com/api/v2/project/#{vcs}/#{org}/#{repo}/pipeline",
|
11
|
+
headers: { "Circle-Token": ENV["WASSUP_CIRCLE_CI_API_TOKEN"] }
|
12
|
+
)
|
13
|
+
json = JSON.parse(resp)
|
14
|
+
|
15
|
+
return json["items"].select do |item|
|
16
|
+
if !limit_days.nil?
|
17
|
+
date = Time.parse(item["updated_at"])
|
18
|
+
days = (Time.now - date).to_i / (24 * 60 * 60)
|
19
|
+
days < limit_days
|
20
|
+
else
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end.map do |pipeline|
|
24
|
+
id = pipeline["id"]
|
25
|
+
|
26
|
+
resp = RestClient::Request.execute(
|
27
|
+
method: :get,
|
28
|
+
url: "https://circleci.com/api/v2/pipeline/#{id}/workflow",
|
29
|
+
headers: { "Circle-Token": ENV["WASSUP_CIRCLE_CI_API_TOKEN"] }
|
30
|
+
)
|
31
|
+
json = JSON.parse(resp)
|
32
|
+
workflow = json["items"].first
|
33
|
+
|
34
|
+
if workflow
|
35
|
+
workflow["pipeline"] = pipeline
|
36
|
+
end
|
37
|
+
|
38
|
+
workflow
|
39
|
+
end.compact
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module Wassup
|
46
|
+
module Helpers
|
47
|
+
module CircleCI
|
48
|
+
module Formatter
|
49
|
+
def self.workflow(workflow)
|
50
|
+
pipeline = workflow["pipeline"]
|
51
|
+
number = pipeline["number"]
|
52
|
+
message = (pipeline["vcs"]["commit"] || {})["subject"]
|
53
|
+
login = pipeline["trigger"]["actor"]["login"]
|
54
|
+
|
55
|
+
status = workflow["status"]
|
56
|
+
status_formatted = '%-8.8s' % status
|
57
|
+
|
58
|
+
number_formatted = '%-7.7s' % "##{number}"
|
59
|
+
|
60
|
+
if status == "failed"
|
61
|
+
status_formatted = "[fg=red]#{status_formatted}[fg=white]"
|
62
|
+
elsif status == "success"
|
63
|
+
status_formatted = "[fg=green]#{status_formatted}[fg=white]"
|
64
|
+
else
|
65
|
+
status_formatted = "[fg=yellow]#{status_formatted}[fg=white]"
|
66
|
+
end
|
67
|
+
|
68
|
+
display = "[fg=yellow]#{number_formatted} [fg=while]#{status_formatted} [fg=white]#{login} [fg=gray]#{message}"
|
69
|
+
|
70
|
+
return display
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module Wassup
|
2
|
+
module Helpers
|
3
|
+
module GitHub
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
# https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests
|
8
|
+
def self.issues(org:, repo:nil, q: nil)
|
9
|
+
q_parts = []
|
10
|
+
|
11
|
+
if repo.nil?
|
12
|
+
q_parts << "org:#{org}"
|
13
|
+
else
|
14
|
+
q_parts << "repo:#{org}/#{repo}"
|
15
|
+
end
|
16
|
+
|
17
|
+
if q
|
18
|
+
q_parts << q
|
19
|
+
end
|
20
|
+
|
21
|
+
q = q_parts.join(' ')
|
22
|
+
|
23
|
+
items = []
|
24
|
+
|
25
|
+
resp = RestClient::Request.execute(
|
26
|
+
method: :get,
|
27
|
+
url: "https://api.github.com/search/issues?q=#{q}",
|
28
|
+
user: ENV["WASSUP_GITHUB_USERNAME"],
|
29
|
+
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"],
|
30
|
+
headers: { "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json" },
|
31
|
+
)
|
32
|
+
partial_items = JSON.parse(resp)["items"]
|
33
|
+
items += partial_items
|
34
|
+
|
35
|
+
return items
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.repos(org:)
|
39
|
+
resp = RestClient::Request.execute(
|
40
|
+
method: :get,
|
41
|
+
url: "https://api.github.com/orgs/#{org}/repos",
|
42
|
+
user: ENV["WASSUP_GITHUB_USERNAME"],
|
43
|
+
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
|
44
|
+
)
|
45
|
+
return JSON.parse(resp)
|
46
|
+
end
|
47
|
+
|
48
|
+
Repo = Struct.new(:org, :repo)
|
49
|
+
def self.pull_requests(org:, repo: nil)
|
50
|
+
repos = []
|
51
|
+
if repo.nil?
|
52
|
+
repos += self.repos(org: org).map do |repo|
|
53
|
+
Repo.new(org, repo["name"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
repos << Repo.new(org, repo)
|
57
|
+
end
|
58
|
+
|
59
|
+
return repos.map do |repo|
|
60
|
+
resp = RestClient::Request.execute(
|
61
|
+
method: :get,
|
62
|
+
url: "https://api.github.com/repos/#{repo.org}/#{repo.repo}/pulls?per_page=100",
|
63
|
+
user: ENV["WASSUP_GITHUB_USERNAME"],
|
64
|
+
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
|
65
|
+
)
|
66
|
+
|
67
|
+
JSON.parse(resp)
|
68
|
+
end.flatten(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.releases(org:, repo:)
|
72
|
+
resp = RestClient::Request.execute(
|
73
|
+
method: :get,
|
74
|
+
url: "https://api.github.com/repos/#{org}/#{repo}/releases",
|
75
|
+
user: ENV["WASSUP_GITHUB_USERNAME"],
|
76
|
+
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
|
77
|
+
)
|
78
|
+
|
79
|
+
return JSON.parse(resp)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
module Wassup
|
86
|
+
module Helpers
|
87
|
+
module GitHub
|
88
|
+
module Formatter
|
89
|
+
def self.issue(issue, show_repo: false, show_interactions: false)
|
90
|
+
self.pr(issue, show_repo: show_repo, show_interactions: show_interactions)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.pr(pr, show_repo: false, show_interactions: false)
|
94
|
+
number = pr["number"]
|
95
|
+
title = pr["title"]
|
96
|
+
created_at = pr["created_at"]
|
97
|
+
|
98
|
+
repo_name = ""
|
99
|
+
if show_repo
|
100
|
+
repo_url_parts = pr["repository_url"].split("/")
|
101
|
+
repo_name = "[fg=gray]#{repo_url_parts.last} "
|
102
|
+
end
|
103
|
+
|
104
|
+
interactions = ""
|
105
|
+
if show_interactions
|
106
|
+
interaction_count = pr["comments"] + pr["reactions"]["total_count"]
|
107
|
+
interactions = "[fg=red]#{interaction_count} "
|
108
|
+
end
|
109
|
+
|
110
|
+
number_formatted = '%-7.7s' % "##{number}"
|
111
|
+
|
112
|
+
date = Time.parse(created_at)
|
113
|
+
days = (Time.now - date).to_i / (24 * 60 * 60)
|
114
|
+
days_formatted = '%3.3s' % days.to_s
|
115
|
+
|
116
|
+
display = "[fg=yellow]#{number_formatted}[fg=cyan] #{days_formatted}d ago #{interactions}#{repo_name}[fg=white]#{title}"
|
117
|
+
|
118
|
+
return display
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.release(release)
|
122
|
+
tag_name = release["tag_name"]
|
123
|
+
name = release["name"]
|
124
|
+
published_at = release["published_at"]
|
125
|
+
|
126
|
+
date = Time.parse(published_at)
|
127
|
+
days = (Time.now - date).to_i / (24 * 60 * 60)
|
128
|
+
days_formatted = '%3.3s' % days.to_s
|
129
|
+
|
130
|
+
display = "[fg=yellow]#{tag_name} [fg=cyan]#{days_formatted} ago [fg=gray]#{name}"
|
131
|
+
|
132
|
+
return display
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Wassup
|
2
|
+
module Helpers
|
3
|
+
module Netlify
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
def self.deploys(site_id:)
|
8
|
+
resp = RestClient::Request.execute(
|
9
|
+
method: :get,
|
10
|
+
url: "https://api.netlify.com/api/v1/sites/#{site_id}/deploys",
|
11
|
+
headers: { "Authorization": "Bearer #{ENV['WASSUP_NETLIFY_TOKEN']}", "User-Agent": "Wassup" }
|
12
|
+
)
|
13
|
+
return JSON.parse(resp)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Wassup
|
21
|
+
module Helpers
|
22
|
+
module Netlify
|
23
|
+
module Formatter
|
24
|
+
def self.deploy(deploy)
|
25
|
+
review_id = deploy["review_id"]
|
26
|
+
context = deploy["context"]
|
27
|
+
state = deploy["state"]
|
28
|
+
error_message = deploy["error_message"]
|
29
|
+
branch = deploy["branch"]
|
30
|
+
commit_ref = deploy["commit_ref"] || "HEAD"
|
31
|
+
url = deploy["deploy_url"]
|
32
|
+
|
33
|
+
if error_message.to_s.downcase.include?("canceled")
|
34
|
+
state = "cancelled"
|
35
|
+
end
|
36
|
+
|
37
|
+
color = "green"
|
38
|
+
if state == "building"
|
39
|
+
color = "yellow"
|
40
|
+
elsif state == "enqueued"
|
41
|
+
color = "magenta"
|
42
|
+
elsif state == "cancelled"
|
43
|
+
color = "gray"
|
44
|
+
elsif state == "error"
|
45
|
+
color = "red"
|
46
|
+
end
|
47
|
+
|
48
|
+
display_context = context.split('-').map(&:capitalize).join(' ')
|
49
|
+
display_context = "[fg=#{color}]#{display_context}"
|
50
|
+
|
51
|
+
if !review_id.nil?
|
52
|
+
display_context += " - ##{review_id}"
|
53
|
+
end
|
54
|
+
|
55
|
+
display_context += "[fg=gray]"
|
56
|
+
display_context += " (#{state})"
|
57
|
+
display_context += "[fg=white]"
|
58
|
+
|
59
|
+
if !branch.nil? && !commit_ref.nil?
|
60
|
+
display_context += "[fg=cyan]: #{branch}@#{commit_ref[0...7]}"
|
61
|
+
end
|
62
|
+
|
63
|
+
display = "#{display_context}"
|
64
|
+
|
65
|
+
return display
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Wassup
|
2
|
+
module Helpers
|
3
|
+
module Shortcut
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
def self.members
|
8
|
+
endpoint = "https://api.app.shortcut.com"
|
9
|
+
resp = RestClient::Request.execute(
|
10
|
+
method: :get,
|
11
|
+
url: "#{endpoint}/api/v3/members",
|
12
|
+
headers: { "Shortcut-Token": ENV['WASSUP_SHORTCUT_TOKEN'], "Content-Type": "application/json" }
|
13
|
+
)
|
14
|
+
return JSON.parse(resp)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.workflows
|
18
|
+
endpoint = "https://api.app.shortcut.com"
|
19
|
+
resp = RestClient::Request.execute(
|
20
|
+
method: :get,
|
21
|
+
url: "#{endpoint}/api/v3/workflows",
|
22
|
+
headers: { "Shortcut-Token": ENV['WASSUP_SHORTCUT_TOKEN'], "Content-Type": "application/json" }
|
23
|
+
)
|
24
|
+
return JSON.parse(resp)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.search_stories(query:, page_size: 25)
|
28
|
+
endpoint = "https://api.app.shortcut.com"
|
29
|
+
|
30
|
+
members = self.members
|
31
|
+
workflows = self.workflows
|
32
|
+
|
33
|
+
stories = []
|
34
|
+
|
35
|
+
resp = RestClient::Request.execute(
|
36
|
+
method: :get,
|
37
|
+
url: "#{endpoint}/api/v3/search/stories",
|
38
|
+
payload: { page_size: page_size, query: query },
|
39
|
+
headers: { "Shortcut-Token": ENV['WASSUP_SHORTCUT_TOKEN'], "Content-Type": "application/json" }
|
40
|
+
)
|
41
|
+
json = JSON.parse(resp)
|
42
|
+
stories += json["data"]
|
43
|
+
|
44
|
+
next_url = json["next"]
|
45
|
+
while !next_url.nil?
|
46
|
+
resp = RestClient::Request.execute(
|
47
|
+
method: :get,
|
48
|
+
url: "#{endpoint}#{next_url}",
|
49
|
+
headers: { "Shortcut-Token": ENV['WASSUP_SHORTCUT_TOKEN'], "Content-Type": "application/json" }
|
50
|
+
)
|
51
|
+
json = JSON.parse(resp)
|
52
|
+
stories += json["data"]
|
53
|
+
next_url = json["next"]
|
54
|
+
end
|
55
|
+
|
56
|
+
stories = stories.map do |story|
|
57
|
+
story["followers"] = story["follower_ids"].map do |owner_id|
|
58
|
+
members.find do |member|
|
59
|
+
member["id"] == owner_id
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
story["owners"] = story["owner_ids"].map do |owner_id|
|
64
|
+
members.find do |member|
|
65
|
+
member["id"] == owner_id
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if (workflow_id = story["workflow_id"]) && (workflow_state_id = story["workflow_state_id"])
|
70
|
+
workflow = workflows.find do |workflow|
|
71
|
+
workflow["id"] == workflow_id
|
72
|
+
end
|
73
|
+
|
74
|
+
story["workflow"] = workflow
|
75
|
+
if workflow
|
76
|
+
story["workflow_state"] = workflow["states"].find do |workflow_state|
|
77
|
+
workflow_state["id"] == workflow_state_id
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
story
|
83
|
+
end
|
84
|
+
|
85
|
+
return stories
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
module Wassup
|
93
|
+
module Helpers
|
94
|
+
module Shortcut
|
95
|
+
module Formatter
|
96
|
+
def self.story(story)
|
97
|
+
id = story["id"]
|
98
|
+
name = story["name"]
|
99
|
+
state = story["workflow_state"]["name"]
|
100
|
+
|
101
|
+
mention_name = (story["owners"] || {}).map do |member|
|
102
|
+
member["profile"]["mention_name"]
|
103
|
+
end.join(", ")
|
104
|
+
|
105
|
+
id_formatted = '%-7.7s' % "##{id}"
|
106
|
+
|
107
|
+
display = "[fg=yellow]#{id_formatted} [fg=cyan]#{state} [fg=white]#{mention_name} [fg=gray]#{name}"
|
108
|
+
|
109
|
+
return display
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|