apollo_commons_ruby_cli 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -16
- data/lib/apollo_commons_ruby/NetworkUtils.rb +17 -17
- 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: b4ce703683dfe322f598ca199621e5d652a74b60893830b45f8fe3007cc23fdb
|
4
|
+
data.tar.gz: 1a6cb109ab110ae8a280532f749386d2cf2e9e0a6a0dfc43e814a462602c45bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd580a8d1a53c2bde077eeb725724fb63ffbfa022b8699112371c184b3de50ac5986d6eb9df801146a24d332e45acfd198d88ba2d5d48e110bbd89269fe22e83
|
7
|
+
data.tar.gz: e18896e425253d2a5ac28029d6d2254c845be4907e27828893b984df2031fe3f4b677a96752727f0f905028d93fb82344ae5b7e501e957ad21c1806bbe223415
|
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,27 @@ 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
|
|
158
|
+
newHeraAuthToken = "eyJhbGciOiJFZERTQSJ9.eyJzdWIiOiJOS2ppY0lWbHV4Mmo2YmVsWmpZUndBPT0iLCJ2ZXIiOiIyIiwiaXNzIjoiMC1hZG1pbi5JbmRpYSIsInNhbmRib3giOiIxIiwiYWRkaXRpb25hbF9jbGFpbXMiOnt9LCJhdWQiOiJjaXBoZXIiLCJzdWJqZWN0SklEIjoiTktqaWNJVmx1eDJqNmJlbFpqWVJ3QT09QGF1dGhQcm9maWxlLjAtYWRtaW4uSW5kaWEvOSIsInNjb3BlcyI6WyJhZG1pbiIsImFwaHJvZGl0ZS1hZG1pbiJdLCJleHAiOjE3NzcxMDMyODgsImlhdCI6MTc0NTk5OTI4OCwianRpIjoicHJvdGV1c18xNzQ1OTk5Mjg4ODU0X2ZhZGIwZThmLTkyOGYtNDNiOS05MzRiLTA5M2EyOWI4MmMyZiIsInRlbmFudCI6IjAifQ.Co1rEtIEyXcdCDYsB5N56gxF8YFJGEbuzQEohp57_L7tPWqdia15xOHfO9eRIz46az5sKXm8pa7wmipFgcvhBQ"
|
159
|
+
puts "Using Hera Auth Token: #{newHeraAuthToken}"
|
160
|
+
|
161
161
|
apolloAppUrl = apolloAppBaseUrl + "/apollo-app/1.0/tenants/#{tenantId}/access-token"
|
162
|
-
code, response = make_GET_request(apolloAppUrl,
|
162
|
+
code, response = make_GET_request(apolloAppUrl, newHeraAuthToken, nil, false)
|
163
163
|
|
164
164
|
jsonResponse = JSON.parse(response)
|
165
|
-
|
165
|
+
$tenant_token = jsonResponse["access_token"]
|
166
166
|
|
167
|
-
if (
|
167
|
+
if ($tenant_token == nil)
|
168
168
|
raise "Failed to get tenantAuthToken from apollo-app"
|
169
169
|
return nil
|
170
170
|
end
|
171
171
|
|
172
|
-
return
|
172
|
+
return $tenant_token
|
173
173
|
end
|
174
174
|
|
175
175
|
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"
|
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,21 @@ 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
|
+
sampleDataFilesMap = {}
|
223
|
+
Dir.glob("#{sample_data_file_path}/*.json") do |json_filename|
|
224
|
+
# Do work on files & directories ending in .json
|
225
|
+
sample_data_details = read_json_data_from_file_path("#{json_filename}")
|
226
|
+
json_filename.delete_prefix!("#{sample_data_file_path}/")
|
227
|
+
sampleDataFilesMap[:"#{json_filename}"] = JSON.parse(sample_data_details)
|
228
|
+
end
|
229
|
+
if sampleDataFilesMap == nil || sampleDataFilesMap == {}
|
230
|
+
return nil
|
231
|
+
end
|
232
|
+
return sampleDataFilesMap
|
233
|
+
end
|
234
|
+
|
220
235
|
def verify_and_get_template_version(version)
|
221
236
|
allowed_versions = {"v2" => "iOS_v2", "v3" => "iOS_v3"}
|
222
237
|
if version == nil
|
@@ -820,6 +835,10 @@ def upsert_template_group_apollo_config(is_mario_template, environment, configur
|
|
820
835
|
if is_mario_template
|
821
836
|
transformer_data = modify_data_template_if_its_mario_template(transformer_data)
|
822
837
|
end
|
838
|
+
sample_data_details = get_parsed_sample_data_details(configuration,template_group)
|
839
|
+
attrs = {
|
840
|
+
:sampleData => sample_data_details
|
841
|
+
}
|
823
842
|
|
824
843
|
field_ordering = template_group_details["fieldOrdering"]
|
825
844
|
expected_data = template_group_details["expectedData"]
|
@@ -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_json
|
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.4
|
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:
|
11
|
+
date: 2025-05-06 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.1
|
107
|
+
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Ruby utilities for apollo projects
|
109
110
|
test_files: []
|