neetob 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +4 -5
  5. data/CHANGELOG.md +21 -0
  6. data/Gemfile +10 -0
  7. data/Gemfile.lock +15 -1
  8. data/README.md +197 -118
  9. data/bookmarks.md +30 -0
  10. data/data/branch-protection-rules.json +1 -1
  11. data/data/github-labels.json +54 -29
  12. data/images/commit-message-update.png +0 -0
  13. data/lib/neetob/cli/base.rb +22 -10
  14. data/lib/neetob/cli/fetchorupdate_repos/execute.rb +5 -3
  15. data/lib/neetob/cli/github/auth.rb +3 -3
  16. data/lib/neetob/cli/github/base.rb +7 -0
  17. data/lib/neetob/cli/github/commands.rb +6 -2
  18. data/lib/neetob/cli/github/labels/commands.rb +18 -10
  19. data/lib/neetob/cli/github/labels/delete.rb +5 -3
  20. data/lib/neetob/cli/github/labels/delete_all.rb +5 -3
  21. data/lib/neetob/cli/github/labels/list.rb +5 -3
  22. data/lib/neetob/cli/github/labels/show.rb +5 -3
  23. data/lib/neetob/cli/github/labels/update.rb +16 -4
  24. data/lib/neetob/cli/github/labels/upsert.rb +43 -7
  25. data/lib/neetob/cli/github/make_pr/base.rb +2 -1
  26. data/lib/neetob/cli/github/make_pr/commands.rb +4 -1
  27. data/lib/neetob/cli/github/make_pr/compliance_fix.rb +6 -1
  28. data/lib/neetob/cli/github/make_pr/script.rb +4 -3
  29. data/lib/neetob/cli/github/protect_branch.rb +5 -3
  30. data/lib/neetob/cli/heroku/config_vars/upsert.rb +6 -2
  31. data/lib/neetob/cli/heroku/execute.rb +2 -2
  32. data/lib/neetob/cli/ui.rb +1 -1
  33. data/lib/neetob/cli/users/commands.rb +3 -1
  34. data/lib/neetob/cli/users/commits.rb +71 -22
  35. data/lib/neetob/cli.rb +3 -1
  36. data/lib/neetob/exception_handler.rb +3 -1
  37. data/lib/neetob/version.rb +1 -1
  38. data/neetob.gemspec +1 -1
  39. metadata +8 -57
  40. data/LICENSE.txt +0 -21
  41. data/env.sample +0 -1
  42. data/neeto_compliance/lib/neeto_compliance/github_access.rb +0 -29
  43. data/neeto_compliance/lib/neeto_compliance/neeto_apps.rb +0 -35
  44. data/neeto_compliance/lib/neeto_compliance/neeto_commons.rb +0 -16
  45. data/neeto_compliance/lib/neeto_compliance/runner.rb +0 -35
  46. data/neeto_compliance/lib/neeto_compliance/skippable.rb +0 -19
  47. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb +0 -32
  48. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb +0 -35
  49. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb +0 -33
  50. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb +0 -36
  51. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb +0 -38
  52. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb +0 -36
  53. data/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb +0 -25
  54. data/neeto_compliance/lib/neeto_compliance/verifiers/base.rb +0 -72
  55. data/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb +0 -53
  56. data/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb +0 -25
  57. data/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb +0 -25
  58. data/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb +0 -25
  59. data/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb +0 -46
  60. data/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb +0 -25
  61. data/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb +0 -25
  62. data/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb +0 -38
  63. data/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb +0 -38
  64. data/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb +0 -34
  65. data/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb +0 -39
  66. data/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb +0 -100
  67. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb +0 -20
  68. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb +0 -42
  69. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb +0 -24
  70. data/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb +0 -25
  71. data/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb +0 -63
  72. data/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb +0 -62
  73. data/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb +0 -39
  74. data/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb +0 -22
  75. data/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb +0 -25
  76. data/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb +0 -162
  77. data/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb +0 -34
  78. data/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb +0 -28
  79. data/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb +0 -29
  80. data/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb +0 -25
  81. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb +0 -29
  82. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb +0 -29
  83. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb +0 -29
  84. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb +0 -29
  85. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb +0 -28
  86. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb +0 -31
  87. data/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb +0 -44
  88. data/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb +0 -29
  89. data/neeto_compliance/lib/neeto_compliance/verifiers_list.rb +0 -61
  90. data/neeto_compliance/lib/neeto_compliance/version.rb +0 -5
data/bookmarks.md ADDED
@@ -0,0 +1,30 @@
1
+ [All UI issues](https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Abigbinary+label%3Aui)
2
+
3
+ [All UX issues](https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Abigbinary+label%3Aux)
4
+
5
+ [Engineer needed](https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Abigbinary+label%3Aengineer-needed)
6
+
7
+ - [ ] neeto-chat-web
8
+ - [ ] neeto-desk-web
9
+ - [ ] neeto-kb-web
10
+ - [ ] neeto-invoice-web
11
+ - [ ] neeto-form-web
12
+ - [ ] neeto-cal-web
13
+ - [ ] neeto-planner-web
14
+ - [ ] neeto-course-web
15
+ - [ ] neeto-runner-web
16
+ - [ ] neeto-social-web
17
+ - [ ] neeto-wireframe-web
18
+ - [ ] neeto-changelog-web
19
+ - [ ] neeto-quiz-web
20
+ - [ ] neeto-site-web
21
+ - [ ] neeto-crm-web
22
+ - [ ] neeto-replay-web
23
+ - [ ] neeto-invisible-web
24
+ - [ ] neeto-testify-web
25
+ - [ ] neeto-deploy-web
26
+ - [ ] neeto-bugtrap-web
27
+ - [ ] neeto-sign-web
28
+ - [ ] neeto-monitor-web
29
+ - [ ] neeto-ci-web
30
+ - [ ] neeto-git-web
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "required_status_checks": {
5
5
  "strict": true,
6
- "contexts": ["ci/semaphoreci/push: cicheck"]
6
+ "contexts": ["ci/semaphoreci/pr: cicheck"]
7
7
  },
8
8
  "required_conversation_resolution": true,
9
9
  "has_required_deployments": true,
@@ -44,11 +44,6 @@
44
44
  "description": "The issue has been reviewed and considered a valid issue.",
45
45
  "color": "A2D9CE"
46
46
  },
47
- {
48
- "name": "backend",
49
- "description": "Deals with Ruby & Rails code majorly.",
50
- "color": "C2E0C6"
51
- },
52
47
  {
53
48
  "name": "bug",
54
49
  "description": "Something isn't working.",
@@ -106,37 +101,62 @@
106
101
  },
107
102
  {
108
103
  "name": "epic",
109
- "description": "Will get closed when sub-issues fixed and this issue tracked in monthly milestone.",
110
- "color": "6A5ACD"
104
+ "description": "Will get closed when sub-issues are fixed and this issue is tracked in a monthly milestone.",
105
+ "color": "6A5ACD"
106
+ },
107
+ {
108
+ "name": "backend",
109
+ "description": "Deals with Ruby & Rails code majorly.",
110
+ "color": "C2E0C6"
111
111
  },
112
112
  {
113
113
  "name": "frontend",
114
- "description": "Deals with JS(React or JS configs etc) code majorly.",
114
+ "description": "Deals with JS(React or JS configs etc) code majorly. It can also include UI fixes without the help of the UI team.",
115
115
  "color": "C2E0C6"
116
116
  },
117
+ {
118
+ "name": "UI",
119
+ "description": "UI/CSS work needed.",
120
+ "color": "8250df"
121
+ },
122
+ {
123
+ "name": "UX",
124
+ "description": "UX design needed.",
125
+ "color": "366FB9"
126
+ },
127
+ {
128
+ "name": "fullstack",
129
+ "description": "This issue is not just frontend or backend but it's fullstack",
130
+ "color": "D0ECE7"
131
+ },
117
132
  {
118
133
  "name": "high-priority",
119
134
  "description": "Urgent fix required. Should be done within a day at max.",
120
135
  "color": "B60205"
121
136
  },
122
137
  {
123
- "name": "honeybadger",
124
- "description": "Issue created by honeybadger.",
125
- "color": "D3D3D3"
138
+ "name": "priority",
139
+ "description": "Means I am waiting for this issue to be fixed in order to take care of other issues.",
140
+ "color": "BA080D"
126
141
  },
127
142
  {
128
143
  "name": "low-priority",
129
144
  "description": "Other open issues can be taken up before this one.",
130
145
  "color": "BFDADC"
131
146
  },
147
+ {
148
+ "name": "honeybadger",
149
+ "description": "Issue created by honeybadger.",
150
+ "color": "D3D3D3"
151
+ },
132
152
  {
133
153
  "name": "neeto*-dependent",
134
- "description": "This issue depends upon some other issue from neeto engines/frontend packages.",
154
+ "description": "This issue depends upon some other issue from nano (engines/frontend packages).",
135
155
  "color": "E54D82"
136
156
  },
137
157
  {
138
158
  "name": "on-hold",
139
- "description": "Reason should be specified as a comment before putting issue/PR on-hold.",
159
+ "description": "The issue is on hold as per provided reason. The reason should be specified as a comment before putting the issue/PR on-hold.",
140
160
  "color": "E54D82"
141
161
  },
142
162
  {
@@ -147,18 +167,13 @@
147
167
  {
148
168
  "name": "POC",
149
169
  "description": "Proof of concept or doing spike work.",
150
- "color": "008080"
170
+ "color": "008080"
151
171
  },
152
172
  {
153
173
  "name": "PR",
154
174
  "description": "The issue has a PR associated with it.",
155
175
  "color": "D4C5F9"
156
176
  },
157
- {
158
- "name": "priority",
159
- "description": "Means I am waiting for this issue to be fixed in order to take care of other issues.",
160
- "color": "BA080D"
161
- },
162
177
  {
163
178
  "name": "refactoring",
164
179
  "description": "Code changes, better way to organize code etc.",
@@ -169,24 +184,34 @@
169
184
  "description": "Vulnerabilities, security concerns etc.",
170
185
  "color": "BA080D"
171
186
  },
172
- {
173
- "name": "UI",
174
- "description": "UI/CSS work needed.",
175
- "color": "8250df"
176
- },
177
187
  {
178
188
  "name": "UI-weekly-milestone",
179
- "description": "This issue is part of the UI weekly milestone.",
189
+ "description": "This issue is part of the currently ongoing UI weekly milestone.",
180
190
  "color": "F9D0C4"
181
191
  },
182
192
  {
183
- "name": "UX-design-needed",
184
- "description": "This issue is part of the UI weekly milestone.",
185
- "color": "366FB9"
193
+ "name": "engineer-needed",
194
+ "description": "Engineer is needed to work on the issue",
195
+ "color": "B0C4DE"
186
196
  },
187
197
  {
188
198
  "name": "working",
189
- "description": "This issue is part of the UI weekly milestone.",
199
+ "description": "A branch associated with this issue is created.",
190
200
  "color": "D0ECE7"
201
+ },
202
+ {
203
+ "name": "product-analysis",
204
+ "description": "This issue is related to product analysis",
205
+ "color": "D0ECE7"
206
+ },
207
+ {
208
+ "name": "manual-qa-needed",
209
+ "description": "Manual QA is needed to verify the changes.",
210
+ "color": "CCDDCD"
211
+ },
212
+ {
213
+ "name": "manual-qa-completed",
214
+ "description": "Manual QA team has finished verifying the changes.",
215
+ "color": "CCDDCD"
191
216
  }
192
217
  ]
Binary file
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "neeto-compliance"
4
+
3
5
  require_relative "ui"
4
6
  require_relative "../utils"
5
- require_relative "../../../neeto_compliance/lib/neeto_compliance/neeto_apps.rb"
6
7
 
7
8
  module Neetob
8
9
  class CLI::Base
@@ -18,12 +19,12 @@ module Neetob
18
19
 
19
20
  private
20
21
 
21
- def find_all_matching_apps(apps, platform_name, sandbox_mode, quiet = false)
22
+ def find_all_matching_apps(apps, platform_name, sandbox_mode, quiet = false, all_neeto_repos = false)
22
23
  inform_about_current_working_mode(sandbox_mode, quiet)
23
24
  all_available_apps = sandbox_mode ?
24
25
  testing_apps(platform_name) :
25
- build_app_list_from_neeto_compliance(platform_name)
26
- matching_apps = match_apps(apps, all_available_apps)
26
+ build_app_list_from_neeto_compliance(platform_name, all_neeto_repos)
27
+ matching_apps = match_apps(apps || ["*"], all_available_apps)
27
28
  if matching_apps.length == 0
28
29
  error_msg = sandbox_mode ?
29
30
  "Only \"neeto-dummy\" app is available for sandbox mode. Remove the \"--sandbox\" flag to run the given command for all the neeto applications." :
@@ -36,9 +37,9 @@ module Neetob
36
37
  end
37
38
 
38
39
  def match_apps(required_apps, available_apps)
39
- apps = required_apps.map { |app| Regexp.new "#{app.gsub("*", "[-a-zA-Z0-9]*")}" }
40
+ apps = required_apps&.map { |app| Regexp.new "#{app.gsub("*", "[-a-zA-Z0-9]*")}" }
40
41
  available_apps.select do |available_app|
41
- apps.any? { |app| app.match?(available_app) }
42
+ apps&.any? { |app| app.match?(available_app) }
42
43
  end
43
44
  end
44
45
 
@@ -47,10 +48,9 @@ module Neetob
47
48
  JSON.parse(file)
48
49
  end
49
50
 
50
- def build_app_list_from_neeto_compliance(platform_name)
51
- apps = NeetoCompliance::NeetoApps.list.map { |app| camel_case_to_slug(app) }
52
- all_web_apps = suffix_slug(apps, :web)
53
- platform_name == :heroku ? add_env_suffix(all_web_apps) : prefix_org_name(all_web_apps)
51
+ def build_app_list_from_neeto_compliance(platform_name, all_neeto_repos)
52
+ apps = all_neeto_repos ? fetch_all_neeto_repos : NeetoCompliance::NeetoRepos.products.keys
53
+ platform_name == :heroku ? add_env_suffix(apps) : prefix_org_name(apps)
54
54
  end
55
55
 
56
56
  def add_env_suffix(apps)
@@ -81,5 +81,17 @@ module Neetob
81
81
  end
82
82
  ui.say(callout_message)
83
83
  end
84
+
85
+ def fetch_all_neeto_repos
86
+ NeetoCompliance::NeetoRepos::products.keys +
87
+ NeetoCompliance::NeetoRepos::nanos +
88
+ NeetoCompliance::NeetoRepos::widgets +
89
+ NeetoCompliance::NeetoRepos::chrome_extensions +
90
+ NeetoCompliance::NeetoRepos::helper_packages +
91
+ NeetoCompliance::NeetoRepos::electron_apps +
92
+ NeetoCompliance::NeetoRepos::executables +
93
+ NeetoCompliance::NeetoRepos::mobile_apps +
94
+ NeetoCompliance::NeetoRepos::other_repos
95
+ end
84
96
  end
85
97
  end
@@ -6,18 +6,20 @@ module Neetob
6
6
  class CLI
7
7
  module FetchorupdateRepos
8
8
  class Execute < Base
9
- attr_accessor :sandbox, :apps
9
+ attr_accessor :sandbox, :apps, :all_neeto_repos
10
10
 
11
- def initialize(sandbox = false, apps = ["*"])
11
+ def initialize(sandbox = false, all_neeto_repos = false, apps = ["*"])
12
12
  super()
13
13
  @sandbox = sandbox
14
14
  @apps = apps
15
+ @all_neeto_repos = all_neeto_repos
15
16
  end
16
17
 
17
18
  def run
18
- neeto_apps = find_all_matching_apps(apps, :github, sandbox)
19
+ neeto_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
19
20
  neeto_apps.each do |app|
20
21
  app_name = app.split("/").last
22
+ ui.info("\nWorking on #{app_name}\n")
21
23
  if directory_exists(app_name)
22
24
  checkout_to_main_and_fetch_commits(app_name)
23
25
  else
@@ -41,7 +41,7 @@ module Neetob
41
41
  end
42
42
 
43
43
  def request_authorization
44
- post(uris["auth_req"], params: { client_id: client_id, scope: scope })
44
+ post(uris["auth_req"], params: { client_id:, scope: })
45
45
  end
46
46
 
47
47
  private
@@ -87,9 +87,9 @@ module Neetob
87
87
  res = post(
88
88
  uris["token_req"],
89
89
  params: {
90
- client_id: client_id,
90
+ client_id:,
91
91
  device_code: auth_data[:device_code],
92
- grant_type: grant_type
92
+ grant_type:
93
93
  }
94
94
  )
95
95
 
@@ -23,6 +23,13 @@ module Neetob
23
23
  @client = Octokit::Client.new(access_token: auth_client.access_token)
24
24
  end
25
25
 
26
+ def check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
27
+ if (apps.nil? && !all_neeto_repos) || (!apps.nil? && all_neeto_repos)
28
+ ui.error("Please provide either \"apps\" or \"all-neeto-repos\" option.")
29
+ exit
30
+ end
31
+ end
32
+
26
33
  private
27
34
 
28
35
  def read_and_parse_auth_params_from_env
@@ -40,9 +40,13 @@ module Neetob
40
40
  desc: "Name of the branch whose protections rules needs to be updated", required: true
41
41
  option :path, type: :string, aliases: "-p",
42
42
  desc: "The JSON file path which specify all the required rules for branch protection"
43
- option :apps, type: :array, aliases: "-a", required: true, desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
43
+ option :apps, type: :array, aliases: "-a", desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
44
+ option :all_neeto_repos, type: :boolean, aliases: "--all",
45
+ desc: "Use this flag for working with all neeto repos", default: false
44
46
  def protect_branch
45
- ProtectBranch.new(options[:branch], options[:apps], options[:path], options[:sandbox]).run
47
+ ProtectBranch.new(
48
+ options[:branch], options[:apps], options[:path], options[:sandbox],
49
+ options[:all_neeto_repos]).run
46
50
  end
47
51
  end
48
52
  end
@@ -16,44 +16,52 @@ module Neetob
16
16
  module Labels
17
17
  class Commands < SubCommandBase
18
18
  class_option :apps,
19
- {
20
- type: :array, aliases: "-a", required: true,
21
- desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
22
- }
19
+ type: :array, aliases: "-a",
20
+ desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
21
+ class_option :all_neeto_repos,
22
+ type: :boolean, aliases: "--all", default: false,
23
+ desc: "Use this flag for working with all neeto repos"
23
24
 
24
25
  desc "list", "List all the labels in the Github repos"
25
26
  def list
26
- List.new(options[:apps], options[:sandbox]).run
27
+ List.new(options[:apps], options[:sandbox], options[:all_neeto_repos]).run
27
28
  end
28
29
 
29
30
  desc "show", "Show details about the given label in the Github repos"
30
31
  option :name, type: :string, aliases: "-n", required: true, desc: "Name of the label"
31
32
  def show
32
- Show.new(options[:apps], options[:name], options[:sandbox]).run
33
+ Show.new(options[:apps], options[:name], options[:sandbox], options[:all_neeto_repos]).run
33
34
  end
34
35
 
35
36
  desc "upsert", "Create and update labels in the Github repos"
36
37
  option :path, type: :string, aliases: "-p", desc: "The JSON file path which has a list of all the required labels. Each label should have name. The color and description are optional"
38
+ option :name, type: :string, desc: "Name of the label you want to upsert"
39
+ option :color, type: :string, desc: "Color of the label you want to upsert"
40
+ option :description, type: :string, desc: "Description of the label you want to upsert"
37
41
  def upsert
38
- Upsert.new(options[:apps], options[:path], options[:sandbox]).run
42
+ Upsert.new(
43
+ options[:apps], options[:path], options[:sandbox], options[:all_neeto_repos], options[:name],
44
+ options[:color], options[:description]).run
39
45
  end
40
46
 
41
47
  desc "delete_all", "Delete all the labels from the Github repos"
42
48
  def delete_all
43
- DeleteAll.new(options[:apps], options[:sandbox]).run
49
+ DeleteAll.new(options[:apps], options[:sandbox], options[:all_neeto_repos]).run
44
50
  end
45
51
 
46
52
  desc "delete", "Delete some labels from the Github repos"
47
53
  option :labels, type: :array, required: true, desc: "Labels you want to delete from the repos."
48
54
  def delete
49
- Delete.new(options[:apps], options[:labels], options[:sandbox]).run
55
+ Delete.new(options[:apps], options[:labels], options[:sandbox], options[:all_neeto_repos]).run
50
56
  end
51
57
 
52
58
  desc "update", "Update a label name in Github repos"
53
59
  option :old_name, type: :string, required: true, desc: "Current label name which needs to be updated"
54
60
  option :new_name, type: :string, required: true, desc: "New name for the updated label"
55
61
  def update
56
- Update.new(options[:apps], options[:old_name], options[:new_name], options[:sandbox]).run
62
+ Update.new(
63
+ options[:apps], options[:old_name], options[:new_name], options[:sandbox],
64
+ options[:all_neeto_repos]).run
57
65
  end
58
66
  end
59
67
  end
@@ -9,17 +9,19 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class Delete < Base
12
- attr_accessor :apps, :sandbox, :labels
12
+ attr_accessor :apps, :sandbox, :labels, :all_neeto_repos
13
13
 
14
- def initialize(apps, labels, sandbox = false)
14
+ def initialize(apps, labels, sandbox = false, all_neeto_repos = false)
15
15
  super()
16
16
  @labels = labels
17
17
  @apps = apps
18
18
  @sandbox = sandbox
19
+ @all_neeto_repos = all_neeto_repos
19
20
  end
20
21
 
21
22
  def run
22
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
23
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
24
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
23
25
  matching_apps.each do |app|
24
26
  ui.info("\n Deleting labels from #{app} repo \n")
25
27
  labels.each do |label|
@@ -9,16 +9,18 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class DeleteAll < Base
12
- attr_accessor :apps, :sandbox
12
+ attr_accessor :apps, :sandbox, :all_neeto_repos
13
13
 
14
- def initialize(apps, sandbox = false)
14
+ def initialize(apps, sandbox = false, all_neeto_repos = false)
15
15
  super()
16
16
  @apps = apps
17
17
  @sandbox = sandbox
18
+ @all_neeto_repos = all_neeto_repos
18
19
  end
19
20
 
20
21
  def run
21
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
22
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
23
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
22
24
  matching_apps.each do |app|
23
25
  ui.info("\n Working on #{app} repo \n")
24
26
  begin
@@ -9,16 +9,18 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class List < Base
12
- attr_accessor :apps, :sandbox
12
+ attr_accessor :apps, :sandbox, :all_neeto_repos
13
13
 
14
- def initialize(apps, sandbox = false)
14
+ def initialize(apps, sandbox = false, all_neeto_repos = false)
15
15
  super()
16
16
  @apps = apps
17
17
  @sandbox = sandbox
18
+ @all_neeto_repos = all_neeto_repos
18
19
  end
19
20
 
20
21
  def run
21
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
22
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
23
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
22
24
  matching_apps.each do |app|
23
25
  ui.info("\n Labels of #{app} \n")
24
26
  begin
@@ -9,17 +9,19 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class Show < Base
12
- attr_accessor :apps, :label_name, :sandbox
12
+ attr_accessor :apps, :label_name, :sandbox, :all_neeto_repos
13
13
 
14
- def initialize(apps, label_name, sandbox = false)
14
+ def initialize(apps, label_name, sandbox = false, all_neeto_repos = false)
15
15
  super()
16
16
  @apps = apps
17
17
  @label_name = label_name
18
18
  @sandbox = sandbox
19
+ @all_neeto_repos = all_neeto_repos
19
20
  end
20
21
 
21
22
  def run
22
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
23
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
24
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
23
25
  matching_apps.each do |app|
24
26
  ui.info("\n \"#{label_name}\" label details from #{app} \n")
25
27
  begin
@@ -9,29 +9,41 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class Update < Base
12
- attr_accessor :apps, :sandbox, :old_name, :new_name
12
+ attr_accessor :apps, :sandbox, :old_name, :new_name, :all_neeto_repos
13
13
 
14
- def initialize(apps, old_name, new_name, sandbox = false)
14
+ def initialize(apps, old_name, new_name, sandbox = false, all_neeto_repos = false)
15
15
  super()
16
16
  @apps = apps
17
17
  @sandbox = sandbox
18
18
  @old_name = old_name
19
19
  @new_name = new_name
20
+ @all_neeto_repos = all_neeto_repos
20
21
  end
21
22
 
22
23
  def run
23
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
24
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
25
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
24
26
  matching_apps.each do |app|
25
27
  ui.info("\n Updating label for #{app} repo \n")
26
- update_label!(app, old_name, new_name)
28
+ begin
29
+ update_label!(app, old_name, new_name)
30
+ rescue StandardError => e
31
+ ExceptionHandler.new(e).process
32
+ end
27
33
  end
28
34
  end
29
35
 
30
36
  private
31
37
 
32
38
  def update_label!(app, old_name, new_name)
39
+ client.label(app, new_name)
40
+ ui.error("Label with name \"#{new_name}\" already exists.")
41
+ nil
42
+ rescue Octokit::NotFound
33
43
  client.update_label(app, old_name, { name: new_name })
34
44
  ui.success("Label \"#{old_name}\" updated to \"#{new_name}\" successfully")
45
+ rescue StandardError => e
46
+ ExceptionHandler.new(e).process
35
47
  end
36
48
  end
37
49
  end
@@ -9,24 +9,33 @@ module Neetob
9
9
  module Github
10
10
  module Labels
11
11
  class Upsert < Base
12
- attr_accessor :apps, :required_labels_json_file_path, :sandbox
12
+ WHITE_COLOR_HEX_CODE = "ffffff"
13
13
 
14
- def initialize(apps, required_labels_json_file_path = "", sandbox = false)
14
+ attr_accessor :apps, :required_labels_json_file_path, :sandbox, :all_neeto_repos, :name, :color, :description
15
+
16
+ def initialize(apps, required_labels_json_file_path = "", sandbox = false, all_neeto_repos = false,
17
+ name = "", color = "", description = "")
15
18
  super()
16
19
  @apps = apps
17
20
  @required_labels_json_file_path = required_labels_json_file_path
18
21
  @sandbox = sandbox
22
+ @all_neeto_repos = all_neeto_repos
23
+ @name = name
24
+ @color = color
25
+ @description = description
19
26
  end
20
27
 
21
28
  def run
22
- matching_apps = find_all_matching_apps(apps, :github, sandbox)
29
+ check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
30
+ matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
23
31
  inform_about_default_labels_file
24
32
  matching_apps.each do |app|
25
- ui.info("\n Working on #{app} repo \n")
33
+ ui.info("\nWorking on #{app} repo\n")
26
34
  begin
27
- required_labels = read_json_file(required_labels_json_file_path || default_labels_file_path)
35
+ required_labels = get_required_labels
28
36
  required_labels.each do |label|
29
37
  create_or_update_label(app, label)
38
+ sleep(1)
30
39
  end
31
40
  rescue StandardError => e
32
41
  ExceptionHandler.new(e).process
@@ -36,13 +45,40 @@ module Neetob
36
45
 
37
46
  private
38
47
 
48
+ def get_required_labels
49
+ if name.blank? && (!color.blank? || !description.blank?)
50
+ ui.error("Please provide \"name\" for the label you want to upsert.")
51
+ exit
52
+ end
53
+
54
+ if !name.blank?
55
+ return create_label_payload
56
+ end
57
+
58
+ read_json_file(required_labels_json_file_path || default_labels_file_path)
59
+ end
60
+
61
+ def create_label_payload
62
+ [
63
+ {
64
+ "name" => name,
65
+ "color" => color,
66
+ "description" => description
67
+ }.compact
68
+ ]
69
+ end
70
+
39
71
  def create_or_update_label(app, label_details)
40
72
  begin
41
73
  client.update_label(app, label_details["name"], label_details)
42
74
  ui.success("Label \"#{label_details["name"]}\" updated successfully")
43
75
  rescue Octokit::NotFound
44
- client.add_label(app, label_details["name"], label_details["color"], label_details)
76
+ client.add_label(
77
+ app, label_details["name"], label_details["color"] || WHITE_COLOR_HEX_CODE,
78
+ label_details)
45
79
  ui.success("Label \"#{label_details["name"]}\" created successfully")
80
+ rescue StandardError => e
81
+ ExceptionHandler.new(e).process
46
82
  end
47
83
  end
48
84
 
@@ -51,7 +87,7 @@ module Neetob
51
87
  end
52
88
 
53
89
  def inform_about_default_labels_file
54
- if required_labels_json_file_path.nil?
90
+ if required_labels_json_file_path.nil? && name.nil?
55
91
  ui.info("Upserting labels from the \"neetob/data/github-labels.json\" file")
56
92
  end
57
93
  end
@@ -33,7 +33,8 @@ module Neetob
33
33
  end
34
34
 
35
35
  def add_commmit_and_push_changes(app)
36
- `#{cd_to_app_in_tmp_dir(app)} && git add . && git commit -m "#{pr_title}" && git push -u origin #{branch_name} --force`
36
+ `#{cd_to_app_in_tmp_dir(app)} && git add . && \\
37
+ git commit -m "#{pr_title}" && git push -u origin #{branch_name} --force`
37
38
  end
38
39
 
39
40
  def delete_local_feature_branch(app)
@@ -27,8 +27,11 @@ module Neetob
27
27
  desc: "Path to UNIX executable script which will be run for each product", required: true
28
28
  option :title, type: :string, aliases: "-t", desc: "Title for the PR"
29
29
  option :branch, type: :string, aliases: "-b", desc: "Feature branch name for the PR"
30
+ option :description, type: :string, aliases: "-d", desc: "Description of the PR"
30
31
  def script
31
- Script.new(options[:apps], options[:path], options[:title], options[:branch], options[:sandbox]).run
32
+ Script.new(
33
+ options[:apps], options[:path], options[:title], options[:branch], options[:description],
34
+ options[:sandbox]).run
32
35
  end
33
36
  end
34
37
  end