neetob 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +10 -0
  3. data/.env +1 -0
  4. data/.rubocop.yml +596 -0
  5. data/.ruby-version +1 -0
  6. data/.semaphore/semaphore.yml +31 -0
  7. data/CHANGELOG.md +5 -0
  8. data/CODE_OF_CONDUCT.md +84 -0
  9. data/Gemfile +26 -0
  10. data/Gemfile.lock +249 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +381 -0
  13. data/Rakefile +16 -0
  14. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/github_access.rb +29 -0
  15. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_apps.rb +35 -0
  16. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_commons.rb +16 -0
  17. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/runner.rb +35 -0
  18. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/skippable.rb +19 -0
  19. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb +32 -0
  20. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb +35 -0
  21. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb +33 -0
  22. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb +36 -0
  23. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb +38 -0
  24. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb +36 -0
  25. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb +25 -0
  26. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb +72 -0
  27. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb +53 -0
  28. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb +25 -0
  29. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb +25 -0
  30. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb +25 -0
  31. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb +46 -0
  32. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb +25 -0
  33. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb +25 -0
  34. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb +38 -0
  35. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb +38 -0
  36. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb +34 -0
  37. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb +39 -0
  38. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb +100 -0
  39. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb +20 -0
  40. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb +42 -0
  41. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb +24 -0
  42. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb +25 -0
  43. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb +63 -0
  44. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb +62 -0
  45. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb +39 -0
  46. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb +22 -0
  47. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb +25 -0
  48. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb +162 -0
  49. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb +34 -0
  50. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb +28 -0
  51. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb +29 -0
  52. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb +25 -0
  53. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb +29 -0
  54. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb +29 -0
  55. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb +29 -0
  56. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb +29 -0
  57. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb +28 -0
  58. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb +31 -0
  59. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb +44 -0
  60. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb +29 -0
  61. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers_list.rb +61 -0
  62. data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/version.rb +5 -0
  63. data/data/branch-protection-rules.json +25 -0
  64. data/data/config-vars-audit.json +18 -0
  65. data/data/config-vars-list.json +1 -0
  66. data/data/config-vars-upsert.json +3 -0
  67. data/data/github-labels.json +192 -0
  68. data/env.sample +1 -0
  69. data/exe/neetob +25 -0
  70. data/install.sh +21 -0
  71. data/lib/neetob/cli/base.rb +85 -0
  72. data/lib/neetob/cli/fetchorupdate_repos/execute.rb +53 -0
  73. data/lib/neetob/cli/github/auth.rb +134 -0
  74. data/lib/neetob/cli/github/base.rb +35 -0
  75. data/lib/neetob/cli/github/commands.rb +50 -0
  76. data/lib/neetob/cli/github/issues/commands.rb +51 -0
  77. data/lib/neetob/cli/github/issues/create.rb +42 -0
  78. data/lib/neetob/cli/github/issues/list.rb +94 -0
  79. data/lib/neetob/cli/github/labels/commands.rb +62 -0
  80. data/lib/neetob/cli/github/labels/delete.rb +44 -0
  81. data/lib/neetob/cli/github/labels/delete_all.rb +48 -0
  82. data/lib/neetob/cli/github/labels/list.rb +36 -0
  83. data/lib/neetob/cli/github/labels/show.rb +37 -0
  84. data/lib/neetob/cli/github/labels/update.rb +40 -0
  85. data/lib/neetob/cli/github/labels/upsert.rb +62 -0
  86. data/lib/neetob/cli/github/login.rb +16 -0
  87. data/lib/neetob/cli/github/make_pr/base.rb +72 -0
  88. data/lib/neetob/cli/github/make_pr/commands.rb +37 -0
  89. data/lib/neetob/cli/github/make_pr/compliance_fix.rb +49 -0
  90. data/lib/neetob/cli/github/make_pr/script.rb +55 -0
  91. data/lib/neetob/cli/github/protect_branch.rb +46 -0
  92. data/lib/neetob/cli/github/search.rb +38 -0
  93. data/lib/neetob/cli/heroku/access/add.rb +38 -0
  94. data/lib/neetob/cli/heroku/access/commands.rb +41 -0
  95. data/lib/neetob/cli/heroku/access/list.rb +36 -0
  96. data/lib/neetob/cli/heroku/access/remove.rb +38 -0
  97. data/lib/neetob/cli/heroku/commands.rb +28 -0
  98. data/lib/neetob/cli/heroku/config_vars/audit.rb +64 -0
  99. data/lib/neetob/cli/heroku/config_vars/base.rb +19 -0
  100. data/lib/neetob/cli/heroku/config_vars/commands.rb +49 -0
  101. data/lib/neetob/cli/heroku/config_vars/list.rb +56 -0
  102. data/lib/neetob/cli/heroku/config_vars/remove.rb +39 -0
  103. data/lib/neetob/cli/heroku/config_vars/upsert.rb +80 -0
  104. data/lib/neetob/cli/heroku/execute.rb +37 -0
  105. data/lib/neetob/cli/local/commands.rb +19 -0
  106. data/lib/neetob/cli/local/ls.rb +29 -0
  107. data/lib/neetob/cli/sub_command_base.rb +17 -0
  108. data/lib/neetob/cli/ui.rb +41 -0
  109. data/lib/neetob/cli/users/audit.rb +121 -0
  110. data/lib/neetob/cli/users/commands.rb +28 -0
  111. data/lib/neetob/cli/users/commits.rb +125 -0
  112. data/lib/neetob/cli.rb +40 -0
  113. data/lib/neetob/exception_handler.rb +58 -0
  114. data/lib/neetob/utils.rb +16 -0
  115. data/lib/neetob/version.rb +5 -0
  116. data/lib/neetob.rb +10 -0
  117. data/overcommit.yml +43 -0
  118. data/scripts/delete_unused_assets.rb +67 -0
  119. metadata +235 -0
data/README.md ADDED
@@ -0,0 +1,381 @@
1
+ # neetob
2
+
3
+ The `neetob` gem gives different commands for interacting with Github and Heroku instances of existing neeto projects.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Getting Started](#getting-started)
8
+ 1. [Installation](#installation)
9
+ 2. [Usage](#usage)
10
+ 3. [Working with GitHub](#working-with-github)
11
+ 1. [Issues](#issues)
12
+ 2. [Labels](#labels)
13
+ 3. [Search](#search)
14
+ 4. [Protect Branch](#protect-branch)
15
+ 5. [Make PR](#make-pr)
16
+ 6. [Login](#login)
17
+ 4. [Working with Heroku](#working-with-heroku)
18
+ 1. [Config Vars](#config-vars)
19
+ 2. [Access](#access)
20
+ 3. [Execute](#execute)
21
+ 5. [Working with Users](#working-with-users)
22
+ 1. [Audit](#audit)
23
+ 2. [Commits](#commits)
24
+ 6. [Working with Make Repos Uptodate](#working-with-make-repos-uptodate)
25
+ 7. [Working with local Repos](#working-with-local-repos)
26
+ 1. [ls](#ls)
27
+ 8. [Testing](#testing)
28
+
29
+ ## Getting started
30
+
31
+ ### Installation
32
+
33
+ Clone the repository onto your system using the following command:
34
+
35
+ ```sh
36
+ git clone https://github.com/bigbinary/neetob.git
37
+ ```
38
+
39
+ Navigate to the root of the application directory.
40
+
41
+ ```sh
42
+ cd neetob
43
+ ```
44
+
45
+ To set up `neetob`, execute the below command from the root of the application directory.
46
+
47
+ ```sh
48
+ bin/setup
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ Utilize the `help` keyword to access a comprehensive list of all the available commands and options.
54
+
55
+ ```
56
+ neetob help
57
+
58
+ Commands:
59
+ neetob github # Interact with any resource in Github
60
+ neetob help [COMMAND] # Describe available commands or one specific command
61
+ neetob heroku # Interact with any resource in Heroku
62
+ neetob users # Interact with the contributors of neeto apps
63
+ neetob make-repos-uptodate # Update all neeto repos
64
+
65
+ Options:
66
+ [--sandbox] # All the commands in sandbox mode will run only on the "neeto-dummy" app.
67
+ ```
68
+
69
+ **By default, all commands will be executed in non-sandbox mode.**
70
+
71
+ ### Useful command-line options
72
+
73
+ | Option | Meaning |
74
+ | ------------ | --------------------------------- |
75
+ | --apps | Target app names |
76
+ | --sandbox | Sandbox mode |
77
+ | --no-sandbox | Non-Sandbox mode |
78
+ | --help | Provides information on a command |
79
+
80
+ **Note:** The commands within `neetob` should be used with caution, as improper usage may result in unintended consequences, and some actions may not be reversible.
81
+
82
+ ## Working with GitHub
83
+
84
+ Efficiently gain access to a comprehensive list of all the available subcommands for the `github` command by utilizing the `help` keyword.
85
+
86
+ ```sh
87
+ neetob github help
88
+ ```
89
+
90
+ ### Issues
91
+
92
+ The `issues` command offers valuable insights into GitHub issues.
93
+
94
+ ```sh
95
+ # To efficiently list and count all the open issues that are currently unassigned
96
+ neetob github issues list --count --state open --assignee none --apps "neeto-*-web"
97
+
98
+ # To list, count and filter all unassigned open issues that are labeled as "bug" .
99
+ neetob github issues list --count --label bug --state open --assignee none --apps "neeto-*-web"
100
+ ```
101
+
102
+ ### Labels
103
+
104
+ The `labels` command provides an intuitive interface for interacting with Github labels.
105
+
106
+ ```sh
107
+ # The `list` command lists the details of all the labels in the Github repo.
108
+ neetob github labels list --apps "neeto-*-web"
109
+
110
+ # The `show` command gives the details for a specific label in the Github repo.
111
+ neetob github labels show --name priority --apps "neeto-*-web"
112
+
113
+ # The `update` command can be used to update the name of a label.
114
+ neetob github labels update --old-name "High Priority" --new-name \
115
+ "high-priority" --apps neeto-dummy
116
+
117
+ # The `upsert` command updates and inserts all the labels mentioned in default
118
+ # labels JSON file that is "github-labels.json" file inside "data" directory.
119
+ neetob github labels upsert --apps neeto-dummy
120
+
121
+ # The `upsert` command can also be used with a different JSON file using `path` option.
122
+ neetob github labels upsert --path ~/Desktop/labels.json --apps neeto-dummy
123
+
124
+ # The `delete` command deletes the given labels from the Github repos.
125
+ neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
126
+ --apps neeto-dummy
127
+
128
+ # The `delete_all` command deletes all the labels from the Github repos.
129
+ neetob github labels delete_all --apps neeto-dummy
130
+ ```
131
+
132
+ Check out the default labels [file](data/github-labels.json) for the required JSON file structure.
133
+
134
+ ### Search
135
+
136
+ Easily search for keywords across multiple neeto projects within specified files by utilizing the `search` command.
137
+
138
+ ```sh
139
+ neetob github search --keyword neeto --path README.md --apps "neeto-*-web"
140
+ ```
141
+
142
+ ### Protect branch
143
+
144
+ Efficiently update branch protection rules across various neeto applications by utilizing the `protect_branch` command.
145
+
146
+ ```sh
147
+ neetob github protect_branch --branch main --apps neeto-dummy
148
+ ```
149
+
150
+ By default, this [file](data/branch-protection-rules.json) will be used for updating the branch protection rules.
151
+
152
+ The `protect_branch` command can also be used with a different JSON file using `path` option.
153
+
154
+ For example, assume we have a file named `branch-protection-rules.json` on the `Desktop` with the following rules:
155
+
156
+ ```json
157
+ {
158
+ "required_conversation_resolution": true,
159
+ "has_required_deployments": true
160
+ }
161
+ ```
162
+
163
+ To update the above-mentioned branch protection rules for the `main` branch of all the neeto applications, use the following command:
164
+
165
+ ```sh
166
+ neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
167
+ --apps neeto-dummy
168
+ ```
169
+
170
+ **Note:** Unfortunately, utilizing the Github API, we are unable to update the `Require deployments to succeed before merging` rule, as it is currently not defined as a parameter within the API. For further information on available options to update different branch protection rules, kindly refer to the official Github [documentation](https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection).
171
+
172
+ ### Make PR
173
+
174
+ The `make-pr` command can create pull requests across Github repos.
175
+
176
+ ```sh
177
+ # The `compliance-fix` command will do a `bundle` inside all repos and create a PR.
178
+ neetob github make-pr compliance-fix
179
+
180
+ # The `script` command will run the given script for each product and create a PR.
181
+ neetob github make-pr script --path ~/Desktop/fix-folders.sh --branch "neetob-test" \
182
+ --title "PR title"
183
+ ```
184
+
185
+ ### Login
186
+
187
+ Authenticate through your browser and update your Github access token by utilizing the `login` command.
188
+
189
+ ```sh
190
+ neetob github login
191
+ ```
192
+
193
+ ## Working with Heroku
194
+
195
+ Utilize the `help` command to list all the available subcommands under the Heroku module for interacting with the Heroku resources.
196
+
197
+ ```sh
198
+ neetob heroku help
199
+ ```
200
+
201
+ ### Config vars
202
+
203
+ The `config_vars` command is useful to interact with Heroku config variables.
204
+
205
+ ```sh
206
+ # The `list` command lists all the Heroku config variables.
207
+ neetob heroku config_vars list --apps "neeto-*-production"
208
+
209
+ # We can list specific Heroku config variables using `keys` option.
210
+ neetob heroku config_vars list --apps "neeto-*-production" --keys key1 key2 key3
211
+
212
+ # We can also use a file to specify required config vars for `list` command
213
+ # Checkout the `data/config-vars-list.json` file for the required structure.
214
+ neetob heroku config_vars list --apps "neeto-*-production" --path \
215
+ neetob/data/config-vars-list.json
216
+
217
+ # The `audit` command will check the config variables against the JSON file named as
218
+ # `required-config-vars.json` that is present inside the `data` directory at the root of
219
+ # installed `neetob` gem.
220
+ neetob heroku config_vars audit --apps "neeto-*-production"
221
+
222
+ # The `audit` command can also be used with a different JSON file using `--path` option.
223
+ neetob heroku config_vars audit --path ~/Desktop/config.json --apps "neeto-*-production"
224
+
225
+ # The `upsert` command adds or updates the config variables from the
226
+ # `data/config-vars-upsert.json` file present at the root of installed `neetob` gem.
227
+ neetob heroku config_vars upsert --apps "neeto-*-staging"
228
+
229
+ # The `remove` command is used to delete `config_vars`.
230
+ neetob heroku config_vars remove --keys=TEST_KEY_1 TEST_KEY_2 --apps "neeto-*-staging"
231
+ ```
232
+
233
+ We can use a custom JSON file with `upsert` command using the `path` option.
234
+
235
+ For example, assume we have a file named `config.json` on the Desktop, like so:
236
+
237
+ ```json
238
+ {
239
+ "NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD",
240
+ "NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834",
241
+ "NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
242
+ }
243
+ ```
244
+
245
+ To update the above-mentioned config variables to all staging apps, we can use the upsert command like so:
246
+
247
+ ```sh
248
+ neetob heroku config_vars upsert --path ~/Desktop/config.json --apps "neeto-*-staging"
249
+ ```
250
+
251
+ The `upsert` command can also be used to update and insert project-specific config variables.
252
+
253
+ For example, assume we have a file named `config.json` on the `Desktop` with the following properties:
254
+
255
+ ```json
256
+ {
257
+ "neeto-chat-web-staging": {
258
+ "NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD"
259
+ },
260
+ "neeto-testify-web-production": {
261
+ "NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834"
262
+ },
263
+ "neeto-desk-web-staging": {
264
+ "NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
265
+ }
266
+ }
267
+ ```
268
+
269
+ To update the above-mentioned config variables under the defined project, we can use the upsert command like so:
270
+
271
+ ```sh
272
+ neetob heroku config_vars upsert --path_with_project_keys ~/Desktop/config.json
273
+ ```
274
+
275
+ ### Access
276
+
277
+ We can list, add, and remove users from multiple Heroku apps using the `access` command.
278
+
279
+ ```sh
280
+ # The `list` command retrieves a list of all the users from Heroku apps.
281
+ neetob heroku access list --apps "neeto-*-production"
282
+
283
+ # Add new users to the Heroku apps.
284
+ neetob heroku access add --users oliver@bigbinary.com eve@bigbinary.com --apps "neeto-*-staging"
285
+
286
+ # Remove the users from the Heroku apps.
287
+ neetob heroku access remove --users oliver@bigbinary.com eve@bigbinary.com --apps \
288
+ "neeto-*-staging"
289
+ ```
290
+
291
+ ### Execute
292
+
293
+ Utilize the `execute` command to run a Heroku CLI command or a Rails console command for multiple neeto apps in one go.
294
+
295
+ ```sh
296
+ # We can check who has access to the neeto Heroku apps like so:
297
+ neetob heroku execute -c "heroku access" --apps "neeto-*-production"
298
+
299
+ # We can run a command in the Rails console for different neeto Heroku apps like so:
300
+ neetob heroku execute -c "Sidekiq::Cron::Job.destroy \"server_side_worker\"" --apps \
301
+ "neeto-*-staging" --rails
302
+ ```
303
+
304
+ ## Working with users
305
+
306
+ Using the `users` command, we can interact with the contributors of neeto applications.
307
+
308
+ ### Audit
309
+
310
+ The `audit` command enables the ability to comprehensively audit contributors across all neeto applications by providing functionality to check for contributors with multiple emails and users with third-party domain emails.
311
+
312
+ This command will search and use the neeto repos in the current working directory.
313
+ To fetch and update all neeto repos execute [make_repos_uptodate](#working-with-make-repos-uptodate) command before the `audit` command.
314
+
315
+ ```sh
316
+ neetob users audit
317
+ ```
318
+
319
+ ### Commits
320
+
321
+ Using `commits` command we can list the commits for a user in a defined duration.
322
+
323
+ This command will search and use the neeto repos in the current working directory.
324
+ To fetch and update all neeto repos execute [make_repos_uptodate](#working-with-make-repos-uptodate) command before the `commits` command.
325
+
326
+ ```sh
327
+ # The below mentioned command will open a list of all the commits across neeto
328
+ # repos made by "udai1931" in the duration of last 6 months
329
+ neetob users commits --author udai1931 --duration 6.months
330
+
331
+ # We can list commits for a specific product using `--apps` option
332
+ neetob users commits --author udai1931 --duration 6.months --apps neeto-kb-web
333
+ ```
334
+
335
+ ## Working with Make Repos Uptodate
336
+
337
+ Using the `make_repos_uptodate` command, we can uptodate all neeto repos.
338
+ The list of neeto repos is picked up from [neeto_compliance](https://github.com/bigbinary/neeto-compliance/blob/main/lib/neeto_compliance/neeto_repos.rb).
339
+
340
+ ```sh
341
+ neetob make_repos_uptodate
342
+ ```
343
+
344
+ Executing the above mentioned command will check and clone all the missing neeto repos in the current working directory and will update all of them to the latest version. After the execution of command the directories will look something like this:
345
+
346
+ ```
347
+ neeto-chat-web
348
+ neeto-desk-web
349
+ neeto-kb-web
350
+ ```
351
+
352
+ ## Working with local Repos
353
+
354
+ Using the `local` command, we can interact with the local neeto repos.
355
+
356
+ ### ls
357
+
358
+ The `ls` command can list the files from all the local neeto repos.
359
+
360
+ This command will search and use the neeto repos in the current working directory.
361
+ To fetch and update all neeto repos execute [make_repos_uptodate](#working-with-make-repos-uptodate) command before the `ls` command.
362
+
363
+ ```sh
364
+ # The `ls` command will list all the files in the root directory of neeto repos.
365
+ neetob local ls --apps "*"
366
+
367
+ # The `ls` command can also list files in a specific directory using the
368
+ # `--dir` option.
369
+ neetob local ls --dir public --apps "*"
370
+
371
+ # We can also list files in a nested directory.
372
+ neetob local ls --dir app/controllers --apps "*"
373
+ ```
374
+
375
+ ## Testing
376
+
377
+ For testing `github` commands use - [neeto-dummy](https://github.com/bigbinary/neeto-dummy) repo.
378
+
379
+ For testing `heroku` commands use - [neeto-dummy](https://dashboard.heroku.com/apps/neeto-dummy) app.
380
+
381
+ **Note:** Contact your respective Team Lead if you don't have access.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "base64"
4
+
5
+ module NeetoCompliance
6
+ class GithubAccess
7
+ def self.token
8
+ Base64.decode64(
9
+ File.read("Gemfile.common.rb")
10
+ .split("encoded_github_auth_string =")[1]
11
+ .split("%{")[1]
12
+ .split("}")[0]
13
+ .gsub("\\r", "\r")
14
+ .gsub("\\n", "\n")
15
+ ).split(":")[1]
16
+ end
17
+
18
+ def self.latest_commit_sha(uri)
19
+ JSON.parse(get(uri))["sha"]
20
+ end
21
+
22
+ def self.get(uri)
23
+ response = Net::HTTP.get_response(
24
+ URI(uri), {
25
+ "Authorization" => "Bearer #{token}"
26
+ }).body
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NeetoCompliance
4
+ class NeetoApps
5
+ def self.list
6
+ [ "neetoWheel",
7
+ "neetoChat",
8
+ "neetoDesk",
9
+ "neetoKB",
10
+ "neetoForm",
11
+ "neetoInvoice",
12
+ "neetoChangelog",
13
+ "neetoInvisible",
14
+ "neetoSocial",
15
+ "neetoWireframe",
16
+ "neetoRunner",
17
+ "neetoPlanner",
18
+ "neetoCourse",
19
+ "neetoCrm",
20
+ "neetoCal",
21
+ "neetoAuth",
22
+ "neetoReplay",
23
+ "neetoQuiz",
24
+ "neetoTestify",
25
+ "neetoSite",
26
+ "neetoDeploy",
27
+ "neetoMonitor",
28
+ "neetoCI",
29
+ "neetoSign",
30
+ "neetoBugtrap",
31
+ "neetoGit"
32
+ ]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "base64"
4
+
5
+ module NeetoCompliance
6
+ class NeetoCommons
7
+ def self.path
8
+ @@_neeto_commons_path ||= get_path
9
+ end
10
+
11
+ def self.get_path
12
+ path = `bundle info neeto-commons-backend`.split(" ").last
13
+ Pathname.new(path).join("lib", "neeto_commons_backend")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NeetoCompliance
4
+ class Runner
5
+ def verifiers
6
+ app_name == "neeto-auth-web" ? VerifiersList.neeto_auth : VerifiersList.neeto_apps
7
+ end
8
+
9
+ def process
10
+ results = verifiers.map do |verifier|
11
+ verifier.new.process
12
+ end
13
+
14
+ results.all? ? exit(0) : exit(1)
15
+ end
16
+
17
+ def auto_correct
18
+ puts "Running auto_correct ...".yellow
19
+ results = verifiers.map do |verifier|
20
+ verifier.new.auto_correct!
21
+ end
22
+
23
+ puts %(
24
+ Auto fixing got completed \n
25
+ Please run bundle exec neeto-audit once again to fix other errors manually if any \n
26
+ ).yellow
27
+
28
+ results.all? ? exit(0) : exit(1)
29
+ end
30
+
31
+ def app_name
32
+ @_app_name ||= `git config --get remote.origin.url`.split("/").last.strip.split(".git").first
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skippable
4
+ def self.included(base)
5
+ base.class_eval do
6
+ include InstanceMethods
7
+ end
8
+ end
9
+
10
+ module InstanceMethods
11
+ def skip?
12
+ `git config --get remote.origin.url`.split("/").last.strip.include? "neeto-auth-web"
13
+ end
14
+
15
+ def app_is?(git_repo)
16
+ `git config --get remote.origin.url`.split("/").last.strip.include? "#{git_repo}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "neeto_compliance/github_access"
4
+ require "neeto_compliance/sync_neeto_commons"
5
+
6
+ module NeetoCompliance
7
+ class SyncNeetoCommons
8
+ class SyncBin
9
+ def self.BIN_FILES
10
+ [
11
+ "bin/bundle",
12
+ "bin/setup",
13
+ "bin/update",
14
+ "bin/webpacker",
15
+ "bin/webpacker-dev-server",
16
+ "bin/yarn"
17
+ ]
18
+ end
19
+
20
+ def self.process
21
+ sync_bin_files
22
+ end
23
+
24
+ def self.sync_bin_files
25
+ self.BIN_FILES.each do |file|
26
+ print "Downloading #{file}...\n"
27
+ system(`cp #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} #{file}`)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "neeto_compliance/github_access"
4
+ require "neeto_compliance/sync_neeto_commons"
5
+
6
+ module NeetoCompliance
7
+ class SyncNeetoCommons
8
+ class SyncFormatters
9
+ def self.CONFIG_FILES
10
+ [
11
+ ".eslintrc.js",
12
+ ".eslintignore",
13
+ ".eslint-rules/helpers/index.js",
14
+ ".eslint-rules/imports/enforced.js",
15
+ ".eslint-rules/imports/order.js",
16
+ ".eslint-rules/globals.js",
17
+ ".eslint-rules/overrides.js",
18
+ ".eslint-rules/promise.js",
19
+ ".eslint-rules/react.js",
20
+ # ".rubocop.yml",
21
+ ".prettierrc.js",
22
+ "cypress-tests/.eslintrc.js",
23
+ ".erb-lint.yml",
24
+ ]
25
+ end
26
+
27
+ def self.process
28
+ self.CONFIG_FILES.each do |file|
29
+ print "Copying #{file}...\n"
30
+ system(`cp #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} #{file}`)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "neeto_compliance/github_access"
4
+ require "neeto_compliance/sync_neeto_commons"
5
+
6
+ module NeetoCompliance
7
+ class SyncNeetoCommons
8
+ class SyncHusky
9
+ def self.HUSKY_FILES
10
+ [
11
+ ".husky/pre-push",
12
+ ".husky/pre-commit",
13
+ ".husky/helpers/lint_staged.sh",
14
+ ".husky/helpers/prevent_conflict_markers.sh",
15
+ ".husky/helpers/prevent_pushing_to_main.sh",
16
+ ".husky/helpers/verify_neeto_audit.sh"
17
+ ]
18
+ end
19
+
20
+ def self.process
21
+ sync_with_husky_files_in_neeto_commons
22
+ end
23
+
24
+ def self.sync_with_husky_files_in_neeto_commons
25
+ self.HUSKY_FILES.each do |file|
26
+ print "Downloading #{file}...\n"
27
+ system(`cp #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} #{file}`)
28
+ system("chmod +x #{file}")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "neeto_compliance/github_access"
4
+ require "neeto_compliance/sync_neeto_commons"
5
+
6
+ module NeetoCompliance
7
+ class SyncNeetoCommons
8
+ class SyncMisc
9
+ def self.MISC_FILES
10
+ [
11
+ ".editorconfig",
12
+ ".vscode/extensions.json",
13
+ ".vscode/settings.json",
14
+ ".semaphore/commands/run_eslint_on_modified_files.sh",
15
+ ".node-version",
16
+ ".nvmrc",
17
+ ".ruby-version",
18
+ ".postcssrc.yml",
19
+ "babel.config.js",
20
+ "app/javascript/src/types.d.ts"
21
+ ]
22
+ end
23
+
24
+ def self.process
25
+ sync_misc_files
26
+ end
27
+
28
+ def self.sync_misc_files
29
+ self.MISC_FILES.each do |file|
30
+ print "Downloading #{file}...\n"
31
+ system(`cp #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} #{file}`)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end