neetob 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2564fe05bb59da098c016b856bb7d1312264297f6d6368b2d21f6e910b1d1a5
4
- data.tar.gz: de8a95729d8bdb7a485773e9f0ee01d9fc5084d04c6cef6597b60eb5894d5103
3
+ metadata.gz: f3e12731a8a3d74e5ac458c05ce83d7f69c13de0d608bf018ae006e209f07060
4
+ data.tar.gz: 94def09aef6e13fec10d841b9e633ba98f1a24ec112e84385075a99e4472f67c
5
5
  SHA512:
6
- metadata.gz: 617a7cf01f06bb405fdc8b0d015e15630f4b2e1f7482be3bdc8d8e1a82941167216031c6167c25a6a2fdb89a119fd2785908559449e195b8fe0c71a7460e28bf
7
- data.tar.gz: 656a228e21d84f5792df78b89990d2dd87184dbca632aaa46375489f75bef692ffad046f0ad61e41a4f7faf3c35190ff59614fdcac2a23bc4002d0ba4c6a2ec1
6
+ metadata.gz: 5192c8564a6e23dc21d39f4c310db500cd01ba2fa147edc4b2f21ba9d3122d49e03bd98a671ba04da93439f3f0f88a161f9edfa3a710a6601070a1fd839ada64
7
+ data.tar.gz: c2f22c795b751fdd169f86cc8357044a8e42e7002ee1c685f6874ab8af70f6edf03f97da19fd69e7ef01c4e3cabd1672194a6fb27a44ee99443e65c0178c915d
data/.neetoci/neetoci.yml CHANGED
@@ -3,7 +3,7 @@ name: neetob
3
3
  global_job_config:
4
4
  setup:
5
5
  - checkout
6
- - neetoci-version ruby 3.1.3
6
+ - neetoci-version ruby 3.2.2
7
7
  - bundle config path 'vendor/bundle'
8
8
  - cache restore
9
9
  - bundle install --jobs 1
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.3
1
+ 3.2.2
@@ -9,7 +9,7 @@ global_job_config:
9
9
  prologue:
10
10
  commands:
11
11
  - checkout
12
- - sem-version ruby 3.1.3
12
+ - sem-version ruby 3.2.2
13
13
  - bundle config path 'vendor/bundle'
14
14
  - bundle install
15
15
  env_vars:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### [0.4.7](https://www.github.com/bigbinary/neetob/compare/v0.4.6...v0.4.7) (2023-06-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * neetodeploy cli support ([#270](https://www.github.com/bigbinary/neetob/issues/270)) ([61e08dc](https://www.github.com/bigbinary/neetob/commit/61e08dc6d6438edbc38afca63282ed8bb99f529b))
9
+ * Updated make-pr cmds for local repos support ([#269](https://www.github.com/bigbinary/neetob/issues/269)) ([cd00d5d](https://www.github.com/bigbinary/neetob/commit/cd00d5d05da47c3802ed1c75f5de868bcb807f3e))
10
+
3
11
  ### [0.4.6](https://www.github.com/bigbinary/neetob/compare/v0.4.5...v0.4.6) (2023-06-05)
4
12
 
5
13
 
data/Gemfile CHANGED
@@ -29,6 +29,7 @@ end
29
29
  gem "byebug"
30
30
  gem "chronic"
31
31
  gem "fury"
32
+ gem "neetodeploy"
32
33
 
33
34
  source "https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com" do
34
35
 
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetob (0.4.6)
4
+ neetob (0.4.7)
5
5
  brakeman (~> 5.0)
6
6
  chronic
7
7
  dotenv (~> 2.8.1)
8
8
  launchy (~> 2.5.0)
9
+ neetodeploy
9
10
  octokit (~> 4.0)
10
11
  terminal-table (~> 3.0.2)
11
12
  thor (~> 1.2.1)
@@ -13,7 +14,7 @@ PATH
13
14
  GEM
14
15
  remote: https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com/
15
16
  specs:
16
- neeto-compliance (1.0.68)
17
+ neeto-compliance (1.0.79)
17
18
  colorize
18
19
  deep_merge
19
20
  hashdiff
@@ -106,6 +107,7 @@ GEM
106
107
  docile (1.4.0)
107
108
  dotenv (2.8.1)
108
109
  erubi (1.11.0)
110
+ event_emitter (0.2.6)
109
111
  faraday (2.7.1)
110
112
  faraday-net_http (>= 2.0, < 3.1)
111
113
  ruby2_keywords (>= 0.0.4)
@@ -116,6 +118,9 @@ GEM
116
118
  globalid (1.0.1)
117
119
  activesupport (>= 5.0)
118
120
  hashdiff (1.0.1)
121
+ httparty (0.21.0)
122
+ mini_mime (>= 1.0.0)
123
+ multi_xml (>= 0.5.2)
119
124
  i18n (1.12.0)
120
125
  concurrent-ruby (~> 1.0)
121
126
  iniparse (1.5.0)
@@ -141,6 +146,14 @@ GEM
141
146
  ruby-progressbar
142
147
  mocha (2.0.2)
143
148
  ruby2_keywords (>= 0.0.5)
149
+ multi_xml (0.6.0)
150
+ neetodeploy (1.0.8)
151
+ dotenv (~> 2.8.1)
152
+ httparty (~> 0.21.0)
153
+ launchy (~> 2.5.0)
154
+ terminal-table (~> 3.0.2)
155
+ thor (~> 1.2.1)
156
+ websocket-client-simple
144
157
  net-imap (0.3.1)
145
158
  net-protocol
146
159
  net-pop (0.1.2)
@@ -236,6 +249,10 @@ GEM
236
249
  addressable (>= 2.8.0)
237
250
  crack (>= 0.3.2)
238
251
  hashdiff (>= 0.4.0, < 2.0.0)
252
+ websocket (1.2.9)
253
+ websocket-client-simple (0.6.1)
254
+ event_emitter
255
+ websocket
239
256
  websocket-driver (0.7.5)
240
257
  websocket-extensions (>= 0.1.0)
241
258
  websocket-extensions (0.1.5)
@@ -257,6 +274,7 @@ DEPENDENCIES
257
274
  mocha
258
275
  neeto-compliance!
259
276
  neetob!
277
+ neetodeploy
260
278
  overcommit (~> 0.59.1)
261
279
  pry
262
280
  rails
data/README.md CHANGED
@@ -21,15 +21,17 @@ The `neetob` gem gives a different set of commands for interacting with Github r
21
21
  1. [Config Vars](#config-vars)
22
22
  2. [Access](#access)
23
23
  3. [Execute](#execute)
24
- 5. [Working with Users](#working-with-users)
24
+ 5. [Working with neetoDeploy](#working-with-neetodeploy)
25
+ 1. [Config Vars](#config-vars)
26
+ 6. [Working with Users](#working-with-users)
25
27
  1. [Audit](#audit)
26
28
  2. [Commits](#commits)
27
- 6. [Make Repos Uptodate](#make-repos-uptodate)
28
- 7. [Working with neeto Repos](#working-with-neeto-repos)
29
+ 7. [Make Repos Uptodate](#make-repos-uptodate)
30
+ 8. [Working with neeto Repos](#working-with-neeto-repos)
29
31
  1. [Audit](#audit-1)
30
- 8. [Working with local Repos](#working-with-local-repos)
32
+ 9. [Working with local Repos](#working-with-local-repos)
31
33
  1. [ls](#ls)
32
- 9. [Testing](docs/testing.md)
34
+ 10. [Testing](docs/testing.md)
33
35
 
34
36
  ## Usage
35
37
 
@@ -243,6 +245,9 @@ neetob github make-pr compliance-fix --nanos
243
245
  # Add labels to PRs
244
246
  neetob github make-pr compliance-fix --labels "bug,priority"
245
247
 
248
+ # Use local repos to make PRs
249
+ neetob github make-pr compliance-fix --local
250
+
246
251
  # The `script` command runs the given script for each product and create a PR
247
252
  neetob github make-pr script --path ~/Desktop/fix-folders.sh --branch "neetob-test" \
248
253
  --title "PR title" --description "PR description"
@@ -383,6 +388,72 @@ neetob heroku execute -c "Sidekiq::Cron::Job.destroy \"server_side_worker\"" --a
383
388
  "neeto-*-staging" --rails
384
389
  ```
385
390
 
391
+ ## Working with neetoDeploy
392
+
393
+ Utilize the `help` command to list all the available subcommands under the `NeetoDeploy` module for interacting with the neetoDeploy resources.
394
+
395
+ ```sh
396
+ neetob neetoDeploy help
397
+ ```
398
+
399
+ ### Config vars
400
+
401
+ The `config_vars` command interacts with neetoDeploy config variables.
402
+
403
+ ```sh
404
+ # The `list` command lists all the neetoDeploy config variables
405
+ neetob neetodeploy config_vars list --apps "neeto-*-staging"
406
+
407
+ # The `upsert` command adds or updates config variables from the
408
+ # `data/config-vars-upsert.json` file present at the root of installed `neetob` gem
409
+ neetob neetodeploy config_vars upsert --apps "neeto-*-staging"
410
+
411
+ # The `remove` command deletes config variables
412
+ neetob neetodeploy config_vars remove --keys=TEST_KEY_1 TEST_KEY_2 --apps "neeto-*-staging"
413
+ ```
414
+
415
+ We can use a custom JSON file with `upsert` command using the `--path` option.
416
+
417
+ For example, assume we have a file named `config.json` on the Desktop, like so:
418
+
419
+ ```json
420
+ {
421
+ "NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD",
422
+ "NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834",
423
+ "NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
424
+ }
425
+ ```
426
+
427
+ To update the above-mentioned config variables to all staging apps, we can use the `upsert` command like so:
428
+
429
+ ```sh
430
+ neetob neetodeploy config_vars upsert --path ~/Desktop/config.json --apps "neeto-*-staging"
431
+ ```
432
+
433
+ The `upsert` command can also update or insert project-specific config variables.
434
+
435
+ For example, assume we have a file named `config.json` on the `Desktop` with the following properties:
436
+
437
+ ```json
438
+ {
439
+ "neeto-chat-web-staging": {
440
+ "NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD"
441
+ },
442
+ "neeto-testify-web-production": {
443
+ "NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834"
444
+ },
445
+ "neeto-desk-web-staging": {
446
+ "NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
447
+ }
448
+ }
449
+ ```
450
+
451
+ To update the above-mentioned config variables under the defined project, we can use the upsert command like so:
452
+
453
+ ```sh
454
+ neetob neetodeploy config_vars upsert --path_with_project_keys ~/Desktop/config.json --apps "neeto-*-staging"
455
+ ```
456
+
386
457
  ## Working with users
387
458
 
388
459
  The `users` command interacts with the contributors of neeto applications.
@@ -52,7 +52,7 @@ module Neetob
52
52
  def build_app_list_from_neeto_compliance(platform_name, all_neeto_repos)
53
53
  neeto_products = NeetoCompliance::NeetoRepos.products
54
54
  apps = all_neeto_repos ? fetch_all_neeto_repos : neeto_products.keys
55
- platform_name == :heroku ? add_env_suffix(apps, neeto_products) : prefix_org_name(apps)
55
+ [:heroku, :neetodeploy].include?(platform_name) ? add_env_suffix(apps, neeto_products) : prefix_org_name(apps)
56
56
  end
57
57
 
58
58
  def add_env_suffix(apps, neeto_products)
@@ -71,7 +71,7 @@ module Neetob
71
71
  end
72
72
 
73
73
  def testing_apps(platform_name)
74
- platform_name == :heroku ? ["neeto-dummy"] : ["bigbinary/neeto-dummy"]
74
+ [:heroku, :neetodeploy].include?(platform_name) ? ["neeto-dummy"] : ["bigbinary/neeto-dummy"]
75
75
  end
76
76
 
77
77
  def inform_about_current_working_mode(sandbox_mode, quiet = false)
@@ -39,7 +39,7 @@ module Neetob
39
39
  private
40
40
 
41
41
  def run_brakeman(repo)
42
- `#{cd_to_repo_in_tmp_dir(repo)} && brakeman`
42
+ `#{cd_to_repo(repo)} && brakeman`
43
43
  end
44
44
 
45
45
  def parse_description(warnings)
@@ -39,11 +39,11 @@ module Neetob
39
39
  private
40
40
 
41
41
  def build_gem(gem)
42
- ui.info(`#{cd_to_repo_in_tmp_dir(gem)} && gem build`)
42
+ ui.info(`#{cd_to_repo(gem)} && gem build`)
43
43
  end
44
44
 
45
45
  def release_gem(gem)
46
- ui.info(`#{cd_to_repo_in_tmp_dir(gem)} && fury push #{gem}-*.gem --as neeto-live`)
46
+ ui.info(`#{cd_to_repo(gem)} && fury push #{gem}-*.gem --as neeto-live`)
47
47
  end
48
48
  end
49
49
  end
@@ -19,8 +19,8 @@ module Neetob
19
19
 
20
20
  private
21
21
 
22
- def bundle_install(repo)
23
- `#{cd_to_repo_in_tmp_dir(repo)} && bundle install`
22
+ def bundle_install(repo, local_repo)
23
+ `#{cd_to_repo(repo, local_repo)} && bundle install`
24
24
  end
25
25
 
26
26
  def delete_and_create_temp_neetob_dir
@@ -40,39 +40,39 @@ module Neetob
40
40
  `git clone --quiet git@github.com:#{repo}.git /tmp/neetob/#{repo_name_without_org_suffix(repo)}`
41
41
  end
42
42
 
43
- def add_commmit_and_push_changes(repo)
44
- `#{cd_to_repo_in_tmp_dir(repo)} && git add . && \\
43
+ def add_commmit_and_push_changes(repo, local_repo = false)
44
+ `#{cd_to_repo(repo, local_repo)} && git add . && \\
45
45
  git commit -m "#{pr_title}" && git push -u origin #{branch_name} --force`
46
46
  end
47
47
 
48
- def delete_local_feature_branch(repo)
49
- `#{cd_to_repo_in_tmp_dir(repo)} && git checkout main && git branch -D #{branch_name}`
48
+ def delete_local_feature_branch(repo, local_repo = false)
49
+ `#{cd_to_repo(repo, local_repo)} && git checkout main && git branch -D #{branch_name}`
50
50
  end
51
51
 
52
- def checkout_to_new_branch(repo)
53
- `#{cd_to_repo_in_tmp_dir(repo)} && git checkout -b #{branch_name}`
52
+ def checkout_to_new_branch(repo, local_repo)
53
+ `#{cd_to_repo(repo, local_repo)} && git checkout -b #{branch_name}`
54
54
  end
55
55
 
56
- def checkout_to_feature_branch(repo)
57
- `#{cd_to_repo_in_tmp_dir(repo)} && git checkout #{branch_name}`
56
+ def checkout_to_feature_branch(repo, local_repo)
57
+ `#{cd_to_repo(repo, local_repo)} && git checkout #{branch_name}`
58
58
  end
59
59
 
60
- def delete_remote_feature_branch(repo)
61
- `#{cd_to_repo_in_tmp_dir(repo)} && git push origin --delete #{branch_name}`
60
+ def delete_remote_feature_branch(repo, local_repo)
61
+ `#{cd_to_repo(repo, local_repo)} && git push origin --delete #{branch_name}`
62
62
  end
63
63
 
64
- def check_and_delete_remote_branch(repo)
65
- checkout_to_feature_branch(repo)
64
+ def check_and_delete_remote_branch(repo, local_repo = false)
65
+ checkout_to_feature_branch(repo, local_repo)
66
66
  if $?.success?
67
67
  ui.info("Remote branch found with the name \"#{branch_name}\"")
68
- delete_remote_feature_branch(repo)
69
- delete_local_feature_branch(repo)
68
+ delete_remote_feature_branch(repo, local_repo)
69
+ delete_local_feature_branch(repo, local_repo)
70
70
  end
71
- checkout_to_new_branch(repo)
71
+ checkout_to_new_branch(repo, local_repo)
72
72
  end
73
73
 
74
- def cd_to_repo_in_tmp_dir(repo)
75
- "cd /tmp/neetob/#{repo_name_without_org_suffix(repo)}"
74
+ def cd_to_repo(repo, local = false)
75
+ local ? "cd ./#{repo_name_without_org_suffix(repo)}" : "cd /tmp/neetob/#{repo_name_without_org_suffix(repo)}"
76
76
  end
77
77
 
78
78
  def add_org_suffix(repos)
@@ -86,6 +86,14 @@ module Neetob
86
86
 
87
87
  find_all_matching_apps_or_repos(repos, :github, sandbox)
88
88
  end
89
+
90
+ def stash_local_changes(repo, local_repo)
91
+ `#{cd_to_repo(repo, local_repo)} && git stash && git checkout main && git pull origin main`
92
+ end
93
+
94
+ def warn_about_local_repos
95
+ ui.say("The above mentioned command will be using the local repos. Local changes will be lost!\n")
96
+ end
89
97
  end
90
98
  end
91
99
  end
@@ -17,10 +17,14 @@ module Neetob
17
17
  desc: "Use this flag to make PRs for the neeto gems"
18
18
  class_option :labels, type: :string, default: "",
19
19
  desc: "Labels you want to add in the PRs. Example: --labels \"bug,priority\""
20
+ class_option :local, type: :boolean, default: false,
21
+ desc: "Use local repos for creating the PRs"
20
22
 
21
23
  desc "compliance-fix", "Create PRs for fixing neeto compliance in all products"
22
24
  def compliance_fix
23
- ComplianceFix.new(options[:repos], options[:nanos], options[:sandbox], options[:labels]).run
25
+ ComplianceFix.new(
26
+ options[:repos], options[:nanos], options[:sandbox], options[:labels],
27
+ options[:local]).run
24
28
  end
25
29
 
26
30
  desc "script", "Create PRs after running the given script for each product."
@@ -33,7 +37,7 @@ module Neetob
33
37
  def script
34
38
  Script.new(
35
39
  options[:repos], options[:path], options[:title], options[:branch], options[:description],
36
- options[:nanos], options[:frontend_packages], options[:sandbox], options[:labels]).run
40
+ options[:nanos], options[:frontend_packages], options[:sandbox], options[:labels], options[:local]).run
37
41
  end
38
42
  end
39
43
  end
@@ -9,30 +9,40 @@ module Neetob
9
9
  module Github
10
10
  module MakePr
11
11
  class ComplianceFix < Base
12
- attr_accessor :repos, :sandbox, :should_fix_nanos, :labels
12
+ attr_accessor :repos, :sandbox, :should_fix_nanos, :labels, :local
13
13
 
14
- def initialize(repos, should_fix_nanos = false, sandbox = false, labels = "")
14
+ def initialize(repos, should_fix_nanos = false, sandbox = false, labels = "", local = false)
15
15
  super()
16
16
  @repos = repos
17
17
  @sandbox = sandbox
18
18
  @should_fix_nanos = should_fix_nanos
19
19
  @failed_repos = []
20
20
  @labels = labels
21
+ @local = local
21
22
  end
22
23
 
23
24
  def run
24
25
  matching_repos = build_matching_repos_list(should_fix_nanos)
25
26
  @failed_repos = matching_repos.clone
26
- delete_and_create_temp_neetob_dir
27
+ local ?
28
+ warn_about_local_repos :
29
+ delete_and_create_temp_neetob_dir
27
30
  matching_repos.each do |repo|
28
31
  ui.info("\nWorking on #{repo}\n")
29
32
  begin
30
- shallow_clone_repo_in_tmp_dir(repo)
31
- check_and_delete_remote_branch(repo)
32
- bundle_install(repo)
33
- fix_neeto_audit(repo)
34
- ui.info(add_commmit_and_push_changes(repo))
35
- delete_local_feature_branch(repo)
33
+ if local
34
+ unless Dir.exist?("./#{repo_name_without_org_suffix(repo)}")
35
+ ui.error("#{repo_name_without_org_suffix(repo)} don't exist in current dir")
36
+ next
37
+ end
38
+ stash_local_changes(repo, local)
39
+ end
40
+ shallow_clone_repo_in_tmp_dir(repo) if !local
41
+ check_and_delete_remote_branch(repo, local)
42
+ bundle_install(repo, local)
43
+ fix_neeto_audit(repo, local)
44
+ ui.info(add_commmit_and_push_changes(repo, local))
45
+ delete_local_feature_branch(repo, local)
36
46
  pull_request = client.create_pull_request(repo, "main", BRANCH_NAME, PR_TITLE)
37
47
  ui.success("PR created in \"#{repo}\" project successfully.")
38
48
  client.add_labels_to_an_issue(repo, pull_request[:number], labels.split(","))
@@ -42,13 +52,13 @@ module Neetob
42
52
  end
43
53
  end
44
54
  print_failed_repos if @failed_repos.length > 0
45
- `rm -rf /tmp/neetob`
55
+ `rm -rf /tmp/neetob` if !local
46
56
  end
47
57
 
48
58
  private
49
59
 
50
- def fix_neeto_audit(repo)
51
- `#{cd_to_repo_in_tmp_dir(repo)} && bundle exec neeto-audit -a`
60
+ def fix_neeto_audit(repo, local_repo)
61
+ `#{cd_to_repo(repo, local_repo)} && bundle exec neeto-audit -a`
52
62
  end
53
63
 
54
64
  def print_failed_repos
@@ -10,11 +10,11 @@ module Neetob
10
10
  module MakePr
11
11
  class Script < Base
12
12
  attr_accessor :repos, :sandbox, :path_to_the_script_file, :pr_description, :should_fix_nanos,
13
- :should_fix_frontend_packages, :labels
13
+ :should_fix_frontend_packages, :labels, :local
14
14
 
15
15
  def initialize(repos, path_to_the_script_file, pr_title,
16
16
  branch_name, pr_description, should_fix_nanos,
17
- should_fix_frontend_packages = false, sandbox = false, labels = "")
17
+ should_fix_frontend_packages = false, sandbox = false, labels = "", local = false)
18
18
  super(pr_title, branch_name)
19
19
  @repos = repos
20
20
  @sandbox = sandbox
@@ -23,20 +23,30 @@ module Neetob
23
23
  @should_fix_nanos = should_fix_nanos
24
24
  @should_fix_frontend_packages = should_fix_frontend_packages
25
25
  @labels = labels
26
+ @local = local
26
27
  end
27
28
 
28
29
  def run
29
30
  matching_repos = build_matching_repos_list(should_fix_nanos, should_fix_frontend_packages)
30
- delete_and_create_temp_neetob_dir
31
+ local ?
32
+ warn_about_local_repos :
33
+ delete_and_create_temp_neetob_dir
31
34
  matching_repos.each do |repo|
32
35
  ui.info("\n Working on #{repo} \n")
33
36
  begin
34
- shallow_clone_repo_in_tmp_dir(repo)
35
- check_and_delete_remote_branch(repo)
37
+ if local
38
+ unless Dir.exist?("./#{repo}")
39
+ ui.error("#{repo} don't exist in current dir")
40
+ next
41
+ end
42
+ stash_local_changes(repo, local)
43
+ end
44
+ shallow_clone_repo_in_tmp_dir(repo) if !local
45
+ check_and_delete_remote_branch(repo, local)
36
46
  update_script_file_permissions
37
- execute_script(repo)
38
- ui.info(add_commmit_and_push_changes(repo))
39
- delete_local_feature_branch(repo)
47
+ execute_script(repo, local)
48
+ ui.info(add_commmit_and_push_changes(repo, local))
49
+ delete_local_feature_branch(repo, local)
40
50
  pull_request = client.create_pull_request(repo, "main", branch_name, pr_title, pr_description)
41
51
  ui.success("PR created in \"#{repo}\" project successfully.")
42
52
  client.add_labels_to_an_issue(repo, pull_request[:number], labels.split(","))
@@ -44,7 +54,7 @@ module Neetob
44
54
  ExceptionHandler.new(e).process
45
55
  end
46
56
  end
47
- `rm -rf /tmp/neetob`
57
+ `rm -rf /tmp/neetob` if !local
48
58
  end
49
59
 
50
60
  private
@@ -53,8 +63,8 @@ module Neetob
53
63
  `chmod +x #{path_to_the_script_file}`
54
64
  end
55
65
 
56
- def execute_script(repo)
57
- `#{cd_to_repo_in_tmp_dir(repo)} && #{path_to_the_script_file}`
66
+ def execute_script(repo, local_repo)
67
+ `#{cd_to_repo(repo, local_repo)} && #{path_to_the_script_file}`
58
68
  end
59
69
  end
60
70
  end
@@ -48,7 +48,7 @@ module Neetob
48
48
  private
49
49
 
50
50
  def search_for_keyword(repo)
51
- `#{cd_to_repo_in_tmp_dir(repo)} && \
51
+ `#{cd_to_repo(repo)} && \
52
52
  find . -type f -iregex "#{search_file_path}" | xargs grep -E "#{key_to_search}"`
53
53
  end
54
54
 
@@ -76,12 +76,12 @@ module Neetob
76
76
  end
77
77
 
78
78
  def are_changes_made?(repo)
79
- changes_made = `#{cd_to_repo_in_tmp_dir(repo)} && git checkout #{branch_name} && git status`
79
+ changes_made = `#{cd_to_repo(repo)} && git checkout #{branch_name} && git status`
80
80
  !changes_made.include?("nothing to commit")
81
81
  end
82
82
 
83
83
  def find_and_replace_keyword(repo)
84
- `#{cd_to_repo_in_tmp_dir(repo)} && \
84
+ `#{cd_to_repo(repo)} && \
85
85
  find . -type f -regex #{search_file_path} -print0 | \
86
86
  xargs -0 sed -i '' 's/#{key_to_search}/#{replacement_term}/g'`
87
87
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "config_vars/commands"
5
+
6
+ module Neetob
7
+ class CLI
8
+ module NeetoDeploy
9
+ class Commands < Thor
10
+ desc "config_vars", "Interact with the config(env) variables on neetoDeploy apps"
11
+ subcommand "config_vars", ConfigVars::Commands
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module NeetoDeploy
8
+ module ConfigVars
9
+ class Base < CLI::Base
10
+ attr_accessor :client
11
+
12
+ def initialize
13
+ super()
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ require_relative "list"
6
+ require_relative "upsert"
7
+ require_relative "remove"
8
+ require_relative "../../sub_command_base"
9
+
10
+ module Neetob
11
+ class CLI
12
+ module NeetoDeploy
13
+ module ConfigVars
14
+ class Commands < SubCommandBase
15
+ class_option :apps,
16
+ {
17
+ type: :array, required: true,
18
+ desc: "neetoDeploy app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web-staging\""
19
+ }
20
+
21
+ desc "list", "List all the config variables in the neetoDeploy apps"
22
+ option :apps, type: :array, required: true, desc: "neetoDeploy app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web-staging\""
23
+ def list
24
+ List.new(options[:apps], options[:sandbox]).run
25
+ end
26
+
27
+ desc "upsert", "Update and insert the config vars in neetoDeploy apps"
28
+ option :apps, type: :array, desc: "neetoDeploy app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web-staging\""
29
+ option :path, type: :string, aliases: :p, desc: "The JSON file path from which config vars will be upserted"
30
+ option :path_with_project_keys, type: :string, desc: "The JSON file path with the project names as the key containing required config vars for each project."
31
+ def upsert
32
+ Upsert.new(options[:apps], options[:path], options[:path_with_project_keys], options[:sandbox]).run
33
+ end
34
+
35
+ desc "remove", "Remove the config vars from neetoDeploy apps"
36
+ option :apps, type: :array, required: true, desc: "neetoDeploy app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web-staging\""
37
+ option :keys, type: :array, required: true, desc: "Array of config vars to be removed."
38
+ def remove
39
+ Remove.new(options[:apps], options[:keys], options[:sandbox]).run
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module NeetoDeploy
8
+ module ConfigVars
9
+ class List < Base
10
+ attr_accessor :apps, :sandbox
11
+
12
+ def initialize(apps, sandbox = false)
13
+ super()
14
+ @apps = apps
15
+ @sandbox = sandbox
16
+ end
17
+
18
+ def run
19
+ matching_apps = find_all_matching_apps_or_repos(apps, :neetodeploy, sandbox)
20
+ matching_apps.each do |app|
21
+ ui.info("\nConfig of #{app}\n")
22
+ ui.success(`neetodeploy config list -a #{app}`)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module NeetoDeploy
8
+ module ConfigVars
9
+ class Remove < Base
10
+ attr_accessor :apps, :keys, :sandbox
11
+
12
+ def initialize(apps, keys = [], sandbox = false)
13
+ super()
14
+ @apps = apps
15
+ @keys = keys
16
+ @sandbox = sandbox
17
+ end
18
+
19
+ def run
20
+ matching_apps = find_all_matching_apps_or_repos(apps, :neetodeploy, sandbox)
21
+ matching_apps.each do |app|
22
+ ui.info("\nWorking on #{app}")
23
+ keys.each do |key|
24
+ ui.info(`neetodeploy config unset #{key} -a #{app}`)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module NeetoDeploy
8
+ module ConfigVars
9
+ class Upsert < Base
10
+ attr_accessor :apps, :required_config_vars_json_file_path,
11
+ :required_config_vars_with_project_keys_json_file_path, :sandbox
12
+
13
+ def initialize(apps, required_config_vars_json_file_path,
14
+ required_config_vars_with_project_keys_json_file_path, sandbox = false)
15
+ super()
16
+ @apps = apps
17
+ @required_config_vars_json_file_path = required_config_vars_json_file_path
18
+ @required_config_vars_with_project_keys_json_file_path =
19
+ required_config_vars_with_project_keys_json_file_path
20
+ @sandbox = sandbox
21
+ end
22
+
23
+ def run
24
+ check_the_given_arguments
25
+ inform_about_current_working_mode(sandbox) if apps.nil?
26
+ apps_to_be_updated = apps.nil? ?
27
+ read_json_file(required_config_vars_with_project_keys_json_file_path) :
28
+ find_all_matching_apps_or_repos(apps, :neetodeploy, sandbox)
29
+ inform_about_default_config_vars_file
30
+
31
+ apps_to_be_updated.each do |app|
32
+ required_config = apps.nil? ?
33
+ app[1]
34
+ : read_json_file(required_config_vars_json_file_path || default_config_vars_upsert_file_path)
35
+ app = app[0] if apps.nil?
36
+
37
+ if apps.nil? && sandbox && app != "neeto-dummy"
38
+ ui.error("The \"#{app}\" app is not available in sandbox mode.")
39
+ next
40
+ end
41
+
42
+ upsert_config_variables(app, required_config)
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def upsert_config_variables(app, vars)
49
+ ui.info("\nWorking on #{app}")
50
+ vars.each do |key, val|
51
+ ui.info(`neetodeploy config set #{key}='#{val}' -a #{app}`)
52
+ end
53
+ end
54
+
55
+ def check_the_given_arguments
56
+ if (!apps.nil? && !required_config_vars_with_project_keys_json_file_path.nil?) ||
57
+ (apps.nil? && required_config_vars_with_project_keys_json_file_path.nil?)
58
+ ui.error("Please provide either apps or path to the config file with project keys")
59
+ exit
60
+ end
61
+ end
62
+
63
+ def default_config_vars_upsert_file_path
64
+ File.expand_path("../../../../../data/config-vars-upsert.json", __dir__)
65
+ end
66
+
67
+ def inform_about_default_config_vars_file
68
+ if !apps.nil? &&
69
+ required_config_vars_with_project_keys_json_file_path.nil? && required_config_vars_json_file_path.nil?
70
+
71
+ ui.info("Upserting config vars from the \"neetob/data/config-vars-upsert.json\" file")
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
data/lib/neetob/cli.rb CHANGED
@@ -10,6 +10,7 @@ module Neetob
10
10
  require_relative "cli/fetchorupdate_repos/execute"
11
11
  require_relative "cli/local/commands"
12
12
  require_relative "cli/code/commands"
13
+ require_relative "cli/neeto_deploy/commands"
13
14
 
14
15
  class_option :sandbox,
15
16
  {
@@ -27,6 +28,9 @@ module Neetob
27
28
  desc "github", "Interact with any resource in Github"
28
29
  subcommand "github", Github::Commands
29
30
 
31
+ desc "neetodeploy", "Interact with resources in neetoDeploy"
32
+ subcommand "neetodeploy", NeetoDeploy::Commands
33
+
30
34
  desc "users", "Interact with the contributors of neeto apps"
31
35
  subcommand "users", Users::Commands
32
36
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neetob
4
- VERSION = "0.4.6"
4
+ VERSION = "0.4.7"
5
5
  end
data/neetob.gemspec CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "dotenv", "~> 2.8.1" # for loading env variables
38
38
  spec.add_dependency "chronic" # for natural language date and time parsing
39
39
  spec.add_dependency "brakeman", "~> 5.0" # for running brakeman commands
40
+ spec.add_dependency "neetodeploy" # for neetodeploy cli support
40
41
 
41
42
  # To add the files from submodules
42
43
  `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neetob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Udai Gupta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-05 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: neetodeploy
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: This gem gives different commands for interacting with Github and Heroku
112
126
  instances of existing neeto repos.
113
127
  email:
@@ -183,6 +197,12 @@ files:
183
197
  - lib/neetob/cli/heroku/execute.rb
184
198
  - lib/neetob/cli/local/commands.rb
185
199
  - lib/neetob/cli/local/ls.rb
200
+ - lib/neetob/cli/neeto_deploy/commands.rb
201
+ - lib/neetob/cli/neeto_deploy/config_vars/base.rb
202
+ - lib/neetob/cli/neeto_deploy/config_vars/commands.rb
203
+ - lib/neetob/cli/neeto_deploy/config_vars/list.rb
204
+ - lib/neetob/cli/neeto_deploy/config_vars/remove.rb
205
+ - lib/neetob/cli/neeto_deploy/config_vars/upsert.rb
186
206
  - lib/neetob/cli/sub_command_base.rb
187
207
  - lib/neetob/cli/ui.rb
188
208
  - lib/neetob/cli/users/audit.rb
@@ -216,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
236
  - !ruby/object:Gem::Version
217
237
  version: '0'
218
238
  requirements: []
219
- rubygems_version: 3.3.26
239
+ rubygems_version: 3.4.10
220
240
  signing_key:
221
241
  specification_version: 4
222
242
  summary: Provides a set of helper scripts for Github and Heroku.