apollo_commons_ruby_cli 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -16
- data/lib/apollo_commons_ruby/NetworkUtils.rb +13 -16
- data/lib/apollo_commons_ruby/TemplatesHelper.rb +4 -0
- data/lib/apollo_commons_ruby/TemplatesRakefile.rb +21 -1
- data/lib/apollo_commons_ruby.rb +1 -0
- data/lib/tasks/delete_all_view_group_definition.rake +28 -0
- data/lib/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93befb033c2010ef88b1b46e79180dd9bf1642a78a12630c63232a2b37a4934
|
4
|
+
data.tar.gz: 18800ff299742001152de494b9f9f37eaa29448f3739b92183d8cf5bebf08e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2edd9a3a90858253829df08b7108d1eb9275e0555019013a3978db045d2db4557fdb59298288cfe24bbae701f331b5c806f3cfc90661169294a0ad3cd7ae0414
|
7
|
+
data.tar.gz: 7c00dc1992761d76957506aa07ae2194c76b0959038bc3e7487507486c4c12c8d5b7137c7706348f5f24a047ed85cfbb88197014a567fadd4370f788af582b3e
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'apollo_commons_ruby_cli'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,23 +18,22 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install
|
21
|
+
$ gem install apollo_commons_ruby_cli
|
22
22
|
|
23
|
-
##
|
23
|
+
## Release
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/apollo_commons_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/apollo_commons_ruby/blob/master/CODE_OF_CONDUCT.md).
|
25
|
+
1. Increament gem version here https://bitbucket.org/zetaengg/apollo_commons_ruby/src/master/lib/version.rb
|
36
26
|
|
27
|
+
2. Build gem
|
28
|
+
```ruby
|
29
|
+
gem build apollo_commons_ruby.gemspec
|
30
|
+
```
|
37
31
|
|
38
|
-
|
32
|
+
3. Gem will be created in root folder of repo with version in file name. Publish this gem.
|
33
|
+
```ruby
|
34
|
+
gem push apollo_commons_ruby_cli-1.0.0.gem
|
35
|
+
```
|
39
36
|
|
40
|
-
|
37
|
+
4. Use these credentials.
|
38
|
+
email - bibhorc@zeta.tech
|
39
|
+
password - Zeta@12345
|
@@ -4,6 +4,7 @@ require 'uri'
|
|
4
4
|
require 'openssl'
|
5
5
|
require 'base64'
|
6
6
|
|
7
|
+
$tenant_token = nil
|
7
8
|
def make_PUT_request (url, body, authtoken, query_params = nil, should_log = true)
|
8
9
|
if authtoken == nil
|
9
10
|
authtoken = ""
|
@@ -110,28 +111,20 @@ def get_token_and_make_request(type, environment, tenantId, projectId, url, body
|
|
110
111
|
else
|
111
112
|
authToken = conf["heraAuthToken"]
|
112
113
|
end
|
113
|
-
|
114
|
+
|
114
115
|
else
|
115
116
|
raise_exception_if_string_empty(environment, "environment")
|
116
117
|
raise_exception_if_string_empty(tenantId, "tenantId")
|
117
118
|
raise_exception_if_string_empty(projectId, "projectId")
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
puts "Making api call to get tenant token"
|
122
|
-
load_environment_properties(environment, tenantId, projectId)
|
123
|
-
raise_exception_if_string_empty($environmentProperties["apolloAppBaseUrl"], "apolloAppBaseUrl")
|
120
|
+
load_environment_properties(environment, tenantId, projectId)
|
121
|
+
raise_exception_if_string_empty($environmentProperties["apolloAppBaseUrl"], "apolloAppBaseUrl")
|
124
122
|
|
125
|
-
|
126
|
-
ENV[tenantTokenCacheKey] = authToken
|
127
|
-
else
|
128
|
-
puts "Using cached tenant token"
|
129
|
-
authToken = ENV[tenantTokenCacheKey]
|
130
|
-
end
|
123
|
+
authToken = get_token(tenantId, use_tenant_token)
|
131
124
|
end
|
132
125
|
|
133
126
|
if (authToken == nil)
|
134
|
-
raise "Failed to get authToken"
|
127
|
+
raise "Failed to get authToken from apollo-app"
|
135
128
|
return
|
136
129
|
end
|
137
130
|
|
@@ -156,20 +149,24 @@ def get_token(tenantId, use_tenant_token)
|
|
156
149
|
end
|
157
150
|
|
158
151
|
def get_tenant_token(apolloAppBaseUrl, tenantId, heraAuthToken)
|
152
|
+
if $tenant_token != nil
|
153
|
+
puts "Using cached token"
|
154
|
+
return $tenant_token
|
155
|
+
end
|
159
156
|
puts "getting tenant auth token from apollo app"
|
160
157
|
|
161
158
|
apolloAppUrl = apolloAppBaseUrl + "/apollo-app/1.0/tenants/#{tenantId}/access-token"
|
162
159
|
code, response = make_GET_request(apolloAppUrl, heraAuthToken, nil, false)
|
163
160
|
|
164
161
|
jsonResponse = JSON.parse(response)
|
165
|
-
|
162
|
+
$tenant_token = jsonResponse["access_token"]
|
166
163
|
|
167
|
-
if (
|
164
|
+
if ($tenant_token == nil)
|
168
165
|
raise "Failed to get tenantAuthToken from apollo-app"
|
169
166
|
return nil
|
170
167
|
end
|
171
168
|
|
172
|
-
return
|
169
|
+
return $tenant_token
|
173
170
|
end
|
174
171
|
|
175
172
|
def invoke_API(environment, url, type, query_params = nil, body = nil, authToken = nil)
|
@@ -422,6 +422,10 @@ class Configuration
|
|
422
422
|
"#{@base_folder_path}/#{template_group}/transformer.js"
|
423
423
|
end
|
424
424
|
|
425
|
+
def sample_data_file_path_for_template(template_group)
|
426
|
+
"#{@base_folder_path}/#{template_group}/sampleData.json"
|
427
|
+
end
|
428
|
+
|
425
429
|
def client_transfomer_file_path_for_template(template_group)
|
426
430
|
"#{@base_folder_path}/#{template_group}/clientTransformer.js"
|
427
431
|
end
|
@@ -217,6 +217,15 @@ def get_parsed_template_group_details(configuration,template_group)
|
|
217
217
|
return JSON.parse(template_group_details)
|
218
218
|
end
|
219
219
|
|
220
|
+
def get_parsed_sample_data_details(configuration,template_group)
|
221
|
+
sample_data_file_path = configuration.sample_data_file_path_for_template(template_group)
|
222
|
+
sample_data_details = read_json_data_from_file_path(sample_data_file_path)
|
223
|
+
if sample_data_details == nil || sample_data_details == {}
|
224
|
+
return nil
|
225
|
+
end
|
226
|
+
return JSON.parse(sample_data_details)
|
227
|
+
end
|
228
|
+
|
220
229
|
def verify_and_get_template_version(version)
|
221
230
|
allowed_versions = {"v2" => "iOS_v2", "v3" => "iOS_v3"}
|
222
231
|
if version == nil
|
@@ -821,6 +830,16 @@ def upsert_template_group_apollo_config(is_mario_template, environment, configur
|
|
821
830
|
transformer_data = modify_data_template_if_its_mario_template(transformer_data)
|
822
831
|
end
|
823
832
|
|
833
|
+
sample_data_details = get_parsed_sample_data_details(configuration,template_group)
|
834
|
+
sample_data = []
|
835
|
+
if sample_data_details != nil
|
836
|
+
sample_data = [sample_data_details]
|
837
|
+
end
|
838
|
+
# For any new entries in attrs, add the key values in this hash itself
|
839
|
+
attrs = {
|
840
|
+
'sampleData' => sample_data
|
841
|
+
}
|
842
|
+
|
824
843
|
field_ordering = template_group_details["fieldOrdering"]
|
825
844
|
expected_data = template_group_details["expectedData"]
|
826
845
|
|
@@ -828,7 +847,8 @@ def upsert_template_group_apollo_config(is_mario_template, environment, configur
|
|
828
847
|
:expectedData => expected_data,
|
829
848
|
:fieldOrdering => field_ordering,
|
830
849
|
:transformer => transformer_data,
|
831
|
-
:version => version
|
850
|
+
:version => version,
|
851
|
+
:attrs => attrs.to_s
|
832
852
|
}
|
833
853
|
|
834
854
|
puts "\n*[Apollo-config]: Upsert template group API call*\n"
|
data/lib/apollo_commons_ruby.rb
CHANGED
@@ -6,6 +6,7 @@ module MarioConfig
|
|
6
6
|
load 'tasks/delete_domain_event.rake'
|
7
7
|
load 'tasks/delete_view_group_component.rake'
|
8
8
|
load 'tasks/delete_view_group_definition.rake'
|
9
|
+
load 'tasks/delete_all_view_group_definition.rake'
|
9
10
|
load 'tasks/delete_view_group.rake'
|
10
11
|
load 'tasks/update_all_domain_events.rake'
|
11
12
|
load 'tasks/update_all_view_group_components.rake'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../apollo_commons_ruby/ViewGroupDefinition'
|
2
|
+
require_relative '../apollo_commons_ruby/ViewGroupComponent'
|
3
|
+
require_relative '../apollo_commons_ruby/DomainEvent'
|
4
|
+
require_relative '../apollo_commons_ruby/Operation'
|
5
|
+
|
6
|
+
desc "Delete All View Group Definition"
|
7
|
+
task :delete_all_view_group_definition do
|
8
|
+
environment = ENV["environment"]
|
9
|
+
tenantId = ENV["tenant_id"]
|
10
|
+
projectId = ENV["project_id"]
|
11
|
+
|
12
|
+
Dir.foreach('./configs/') do |viewGroupDefinition|
|
13
|
+
next if viewGroupDefinition == '.' || viewGroupDefinition == '..'
|
14
|
+
Dir.foreach('./configs/' + viewGroupDefinition) do |viewGroupComponent|
|
15
|
+
next if viewGroupComponent == '.' || viewGroupComponent == '..' || viewGroupComponent == 'view_group_definition_properties.json' || viewGroupComponent == '.DS_Store'
|
16
|
+
Dir.foreach('./configs/' + viewGroupDefinition + "/" + viewGroupComponent) do |topic|
|
17
|
+
next if topic == '.' || topic == '..' || topic == 'view_group_component_properties.json' || topic == '.DS_Store'
|
18
|
+
Dir.foreach('./configs/' + viewGroupDefinition + "/" + viewGroupComponent + "/" + topic) do |eventName|
|
19
|
+
next if eventName == '.' || eventName == '..' || eventName == '.DS_Store'
|
20
|
+
puts "Deleting domain event for topic " + topic + " and eventName = " + eventName + " and component = " + viewGroupComponent
|
21
|
+
handle_domain_event(viewGroupDefinition, environment, tenantId, projectId, viewGroupComponent, topic, eventName, Operation::DELETE)
|
22
|
+
end
|
23
|
+
handle_view_group_component(viewGroupDefinition, environment, tenantId, projectId, viewGroupComponent, Operation::DELETE)
|
24
|
+
end
|
25
|
+
handle_view_group_definition(viewGroupDefinition, environment, tenantId, projectId, Operation::DELETE)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apollo_commons_ruby_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sahil Prakash
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Used in ruby functions
|
14
14
|
email:
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/tasks/add_translations.rake
|
59
59
|
- lib/tasks/backfill_sample_data.rake
|
60
60
|
- lib/tasks/checkValidJson.rake
|
61
|
+
- lib/tasks/delete_all_view_group_definition.rake
|
61
62
|
- lib/tasks/delete_domain_event.rake
|
62
63
|
- lib/tasks/delete_view_group.rake
|
63
64
|
- lib/tasks/delete_view_group_component.rake
|
@@ -87,7 +88,7 @@ metadata:
|
|
87
88
|
homepage_uri: https://bitbucket.org/zetaengg/apollo_commons_ruby/src
|
88
89
|
source_code_uri: https://bitbucket.org/zetaengg/apollo_commons_ruby/src
|
89
90
|
changelog_uri: https://bitbucket.org/zetaengg/apollo_commons_ruby/src
|
90
|
-
post_install_message:
|
91
|
+
post_install_message:
|
91
92
|
rdoc_options: []
|
92
93
|
require_paths:
|
93
94
|
- lib
|
@@ -102,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
|
-
rubygems_version: 3.0.
|
106
|
-
signing_key:
|
106
|
+
rubygems_version: 3.0.3
|
107
|
+
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Ruby utilities for apollo projects
|
109
110
|
test_files: []
|