MuranoCLI 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.ignore +1 -1
  4. data/.rubocop.yml +10 -5
  5. data/.trustme.sh +272 -106
  6. data/.trustme.vim +20 -1
  7. data/Gemfile +7 -5
  8. data/LICENSE.txt +14 -15
  9. data/MuranoCLI.gemspec +7 -5
  10. data/Rakefile +5 -5
  11. data/bin/murano +4 -4
  12. data/lib/MrMurano/Account.rb +13 -8
  13. data/lib/MrMurano/Business.rb +6 -7
  14. data/lib/MrMurano/Commander-Entry.rb +5 -5
  15. data/lib/MrMurano/Config-Migrate.rb +4 -4
  16. data/lib/MrMurano/Config.rb +27 -6
  17. data/lib/MrMurano/Content.rb +5 -5
  18. data/lib/MrMurano/Exchange-Element.rb +4 -4
  19. data/lib/MrMurano/Exchange.rb +4 -4
  20. data/lib/MrMurano/Gateway.rb +22 -11
  21. data/lib/MrMurano/Keystore.rb +4 -4
  22. data/lib/MrMurano/Logs.rb +87 -0
  23. data/lib/MrMurano/Mock.rb +5 -4
  24. data/lib/MrMurano/Passwords.rb +4 -5
  25. data/lib/MrMurano/ProjectFile.rb +4 -4
  26. data/lib/MrMurano/ReCommander.rb +4 -4
  27. data/lib/MrMurano/Setting.rb +5 -5
  28. data/lib/MrMurano/Settings-HttpService.rb +9 -6
  29. data/lib/MrMurano/Solution-ServiceConfig.rb +5 -5
  30. data/lib/MrMurano/Solution-Services.rb +76 -50
  31. data/lib/MrMurano/Solution-Users.rb +5 -4
  32. data/lib/MrMurano/Solution.rb +6 -6
  33. data/lib/MrMurano/SolutionId.rb +4 -4
  34. data/lib/MrMurano/SubCmdGroupContext.rb +4 -4
  35. data/lib/MrMurano/SyncAllowed.rb +4 -4
  36. data/lib/MrMurano/SyncRoot.rb +5 -5
  37. data/lib/MrMurano/SyncUpDown-Core.rb +515 -0
  38. data/lib/MrMurano/SyncUpDown-Item.rb +159 -0
  39. data/lib/MrMurano/SyncUpDown.rb +120 -688
  40. data/lib/MrMurano/Webservice-Cors.rb +4 -4
  41. data/lib/MrMurano/Webservice-Endpoint.rb +9 -6
  42. data/lib/MrMurano/Webservice-File.rb +5 -4
  43. data/lib/MrMurano/Webservice.rb +5 -5
  44. data/lib/MrMurano/commands/business.rb +4 -4
  45. data/lib/MrMurano/commands/completion.rb +6 -6
  46. data/lib/MrMurano/commands/config.rb +7 -5
  47. data/lib/MrMurano/commands/content.rb +5 -4
  48. data/lib/MrMurano/commands/cors.rb +4 -4
  49. data/lib/MrMurano/commands/devices.rb +6 -6
  50. data/lib/MrMurano/commands/domain.rb +4 -4
  51. data/lib/MrMurano/commands/exchange.rb +4 -4
  52. data/lib/MrMurano/commands/gb.rb +4 -4
  53. data/lib/MrMurano/commands/globals.rb +12 -4
  54. data/lib/MrMurano/commands/init.rb +5 -4
  55. data/lib/MrMurano/commands/keystore.rb +4 -4
  56. data/lib/MrMurano/commands/link.rb +4 -4
  57. data/lib/MrMurano/commands/login.rb +4 -4
  58. data/lib/MrMurano/commands/logs.rb +229 -76
  59. data/lib/MrMurano/commands/mock.rb +4 -4
  60. data/lib/MrMurano/commands/password.rb +4 -4
  61. data/lib/MrMurano/commands/postgresql.rb +4 -4
  62. data/lib/MrMurano/commands/settings.rb +4 -4
  63. data/lib/MrMurano/commands/show.rb +4 -4
  64. data/lib/MrMurano/commands/solution.rb +4 -4
  65. data/lib/MrMurano/commands/solution_picker.rb +4 -4
  66. data/lib/MrMurano/commands/status.rb +12 -4
  67. data/lib/MrMurano/commands/sync.rb +4 -4
  68. data/lib/MrMurano/commands/timeseries.rb +4 -4
  69. data/lib/MrMurano/commands/tsdb.rb +6 -7
  70. data/lib/MrMurano/commands/usage.rb +4 -4
  71. data/lib/MrMurano/commands.rb +4 -4
  72. data/lib/MrMurano/hash.rb +5 -5
  73. data/lib/MrMurano/http.rb +26 -22
  74. data/lib/MrMurano/makePretty.rb +194 -10
  75. data/lib/MrMurano/optparse.rb +1 -1
  76. data/lib/MrMurano/orderedhash.rb +1 -1
  77. data/lib/MrMurano/progress.rb +4 -4
  78. data/lib/MrMurano/verbosing.rb +6 -6
  79. data/lib/MrMurano/version.rb +5 -5
  80. data/lib/MrMurano.rb +7 -4
  81. data/spec/Account-Passwords_spec.rb +4 -4
  82. data/spec/Account_spec.rb +4 -4
  83. data/spec/Business_spec.rb +4 -4
  84. data/spec/ConfigFile_spec.rb +4 -4
  85. data/spec/ConfigMigrate_spec.rb +5 -4
  86. data/spec/Config_spec.rb +5 -4
  87. data/spec/Content_spec.rb +5 -4
  88. data/spec/GatewayBase_spec.rb +4 -4
  89. data/spec/GatewayDevice_spec.rb +4 -4
  90. data/spec/GatewayResource_spec.rb +5 -4
  91. data/spec/GatewaySettings_spec.rb +4 -4
  92. data/spec/Http_spec.rb +4 -4
  93. data/spec/MakePretties_spec.rb +20 -20
  94. data/spec/Mock_spec.rb +4 -4
  95. data/spec/ProjectFile_spec.rb +4 -4
  96. data/spec/Setting_spec.rb +4 -4
  97. data/spec/Solution-ServiceConfig_spec.rb +4 -4
  98. data/spec/Solution-ServiceEventHandler_spec.rb +5 -4
  99. data/spec/Solution-ServiceModules_spec.rb +5 -4
  100. data/spec/Solution-UsersRoles_spec.rb +5 -4
  101. data/spec/Solution_spec.rb +4 -4
  102. data/spec/SyncRoot_spec.rb +4 -4
  103. data/spec/SyncUpDown_spec.rb +67 -21
  104. data/spec/Verbosing_spec.rb +12 -10
  105. data/spec/Webservice-Cors_spec.rb +4 -4
  106. data/spec/Webservice-Endpoint_spec.rb +5 -4
  107. data/spec/Webservice-File_spec.rb +5 -4
  108. data/spec/Webservice-Setting_spec.rb +4 -4
  109. data/spec/_workspace.rb +4 -4
  110. data/spec/cmd_business_spec.rb +4 -5
  111. data/spec/cmd_common.rb +51 -20
  112. data/spec/cmd_config_spec.rb +4 -5
  113. data/spec/cmd_content_spec.rb +4 -5
  114. data/spec/cmd_cors_spec.rb +4 -5
  115. data/spec/cmd_device_spec.rb +5 -6
  116. data/spec/cmd_domain_spec.rb +4 -5
  117. data/spec/cmd_exchange_spec.rb +4 -5
  118. data/spec/cmd_help_spec.rb +4 -5
  119. data/spec/cmd_init_spec.rb +16 -35
  120. data/spec/cmd_keystore_spec.rb +4 -5
  121. data/spec/cmd_link_spec.rb +11 -12
  122. data/spec/cmd_logs_spec.rb +162 -0
  123. data/spec/cmd_password_spec.rb +4 -5
  124. data/spec/cmd_setting_application_spec.rb +4 -5
  125. data/spec/cmd_setting_product_spec.rb +4 -5
  126. data/spec/cmd_status_spec.rb +44 -81
  127. data/spec/cmd_syncdown_application_spec.rb +7 -10
  128. data/spec/cmd_syncdown_both_spec.rb +10 -25
  129. data/spec/cmd_syncup_spec.rb +31 -37
  130. data/spec/cmd_usage_spec.rb +4 -5
  131. data/spec/fixtures/dumped_config +1 -0
  132. data/spec/fixtures/websocket/logs_blather.rb +27 -0
  133. data/spec/fixtures/websocket/logs_faker.rb +153 -0
  134. data/spec/fixtures/websocket/simple_connection.rb +45 -0
  135. data/spec/fixtures/websocket/simple_options.rb +77 -0
  136. data/spec/fixtures/websocket/simple_server.rb +69 -0
  137. data/spec/fixtures/websocket/wss-echo.rb +48 -0
  138. data/spec/fixtures/websocket/wss-fake-logs.rb +20 -0
  139. metadata +55 -2
data/.trustme.vim CHANGED
@@ -23,8 +23,27 @@
23
23
  " autocmd BufWritePost <buffer> silent !./.trustme.sh &
24
24
  "augroup END
25
25
 
26
+ " NOTE: The tags path cannot be relative.
26
27
  autocmd BufRead *.rb set tags=/exo/clients/exosite/exosite-murcli/tags
27
28
 
28
29
  "echomsg 'Calling trustme.sh'
29
- silent !./.trustme.sh &
30
+ "echomsg "g:DUBS_TRUST_ME_ON_SAVE: " . g:DUBS_TRUST_ME_ON_SAVE
31
+ "silent !./.trustme.sh &
32
+ "silent !/exo/clients/exosite/exosite-murcli/.trustme.sh &
33
+
34
+ " If you open from project.vim (via the magic in=""),
35
+ " then neither of these globals will have been set
36
+ " by dubs_edit_juice.vim.
37
+ if !exists("g:DUBS_TRUST_ME_ON_FILE")
38
+ let g:DUBS_TRUST_ME_ON_FILE = '<project.vim>'
39
+ endif
40
+ if !exists("g:DUBS_TRUST_ME_ON_SAVE")
41
+ let g:DUBS_TRUST_ME_ON_SAVE = 0
42
+ endif
43
+
44
+ let s:cmd = '!' .
45
+ \ ' DUBS_TRUST_ME_ON_FILE=' . g:DUBS_TRUST_ME_ON_FILE .
46
+ \ ' DUBS_TRUST_ME_ON_SAVE=' . g:DUBS_TRUST_ME_ON_SAVE .
47
+ \ ' /exo/clients/exosite/exosite-murcli/.trustme.sh &'
48
+ silent exec s:cmd
30
49
 
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.12 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  source 'http://rubygems.org'
9
9
 
@@ -12,7 +12,8 @@ source 'http://rubygems.org'
12
12
  gem 'certified', '1.0.0'
13
13
  gem 'commander', '~> 4.4.3'
14
14
  gem 'dotenv', '~> 2.1.1'
15
- #gem 'eventmachine', '~> 1.2.3'
15
+ gem 'eventmachine', '~> 1.2.5'
16
+ gem 'faye-websocket', '~> 0.10.7'
16
17
  gem 'highline', '~> 1.7.8'
17
18
  gem 'http-form_data', '~> 1.0.3'
18
19
  gem 'inflecto'
@@ -44,6 +45,7 @@ group :test do
44
45
  gem 'rubocop', '~> 0.49.1'
45
46
  gem 'simplecov', require: false
46
47
  gem 'webmock', '~> 2.3.0'
48
+ gem 'websocket-driver', '~> 0.7.0'
47
49
  #gem 'vcr'
48
50
  gem 'yard'
49
51
  end
data/LICENSE.txt CHANGED
@@ -1,19 +1,18 @@
1
- Copyright (c) 2016-2017 Exosite
1
+ Copyright © 2016-2017 Exosite LLC.
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
- software and associated documentation files (the "Software"), to deal in the
5
- Software without restriction, including without limitation the rights to use, copy,
6
- modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7
- and to permit persons to whom the Software is furnished to do so, subject to the
8
- following conditions:
3
+ All Rights Reserved.
9
4
 
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
5
+ This software contains proprietary and confidential information of
6
+ Exosite LLC.
12
7
 
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
- CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
18
- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+ By accepting transfer of this copy, Recipient agrees to retain this
9
+ software in confidence, to prevent disclosure to others, and to make
10
+ no use of this software other than that for which it was delivered.
11
+
12
+ This is an unpublished copyrighted work of Exosite LLC.
13
+
14
+ Except as permitted by federal law, 17 U.S. Code § 117, copying is
15
+ strictly prohibited.
16
+
17
+ Exosite LLC. 275 Market St Suite 535, Minneapolis, MN 55405
19
18
 
data/MuranoCLI.gemspec CHANGED
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.12 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
9
9
  require_relative 'lib/MrMurano/version.rb'
@@ -53,7 +53,8 @@ explicitly specifying the version. For instance,
53
53
  # Ignoring eventmachine-1.2.3 because its extensions are not built.
54
54
  # Try: gem pristine eventmachine --version 1.2.3
55
55
  # This might be because 'json' was also being complained about.
56
- #s.add_runtime_dependency('eventmachine', '~> 1.2.3')
56
+ s.add_runtime_dependency('eventmachine', '~> 1.2.5')
57
+ s.add_runtime_dependency('faye-websocket', '~> 0.10.7')
57
58
  s.add_runtime_dependency('highline', '~> 1.7.8')
58
59
  s.add_runtime_dependency('http-form_data', '~> 1.0.3')
59
60
  s.add_runtime_dependency('inflecto')
@@ -85,6 +86,7 @@ explicitly specifying the version. For instance,
85
86
  s.add_development_dependency('rubocop', '~> 0.49.1')
86
87
  s.add_development_dependency('simplecov')
87
88
  s.add_development_dependency('webmock', '~> 2.3.0')
89
+ s.add_development_dependency('websocket-driver', '~> 0.7.0')
88
90
  # maybe? s.add_development_dependency('vcr', '~> ???')
89
91
  s.add_development_dependency('yard')
90
92
 
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.08.29 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'bundler/gem_tasks'
9
9
  require 'shellwords'
@@ -50,7 +50,7 @@ end
50
50
 
51
51
  desc 'Tail the CI build file and the curl file'
52
52
  task :tail do
53
- sh %(tail -F .rake_build.out curldebug.out)
53
+ sh %(tail -F .trustme.log curldebug.out)
54
54
  end
55
55
 
56
56
  desc 'display remind of how to release'
data/bin/murano CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- # Last Modified: 2017.09.12 /coding: utf-8
2
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
3
3
  # frozen_string_literal: true
4
4
 
5
- # Copyright © 2016-2017 Exosite LLC.
6
- # License: MIT. See LICENSE.txt.
7
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # License: PROPRIETARY. See LICENSE.txt.
6
+ # Unauthorized copying of this file is strictly prohibited.
7
+ # vim:tw=0:ts=2:sw=2:et:ai
8
8
 
9
9
  require 'MrMurano/Commander-Entry'
10
10
 
@@ -1,14 +1,12 @@
1
- # Last Modified: 2017.09.21 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
- require 'date'
9
8
  require 'json'
10
9
  require 'net/http'
11
- require 'pathname'
12
10
  require 'uri'
13
11
  require 'yaml'
14
12
  require 'MrMurano/hash'
@@ -31,6 +29,7 @@ module MrMurano
31
29
 
32
30
  def initialize
33
31
  @token = nil
32
+ @twofactor_token = nil
34
33
  end
35
34
 
36
35
  def host
@@ -42,7 +41,7 @@ module MrMurano
42
41
  end
43
42
 
44
43
  def endpoint(path)
45
- URI('https://' + host + '/api:1/' + path.to_s)
44
+ URI($cfg['net.protocol'] + '://' + host + '/api:1/' + path.to_s)
46
45
  end
47
46
 
48
47
  # ---------------------------------------------------------------------
@@ -219,6 +218,7 @@ Or set your password with `murano password set <username>`.
219
218
 
220
219
  # First, delete/invalidate the remote token.
221
220
  unless twoftoken.to_s.empty?
221
+ verbose 'Removing two-factor token.'
222
222
  @suppress_error = true
223
223
  delete('token/' + twoftoken)
224
224
  # The response is nil if the token was not recognized, otherwise it's
@@ -235,6 +235,8 @@ Or set your password with `murano password set <username>`.
235
235
  pwd_file.remove(net_host, user_name) unless token_delete_only
236
236
  pwd_file.remove(net_host, user_name + '/twofactor')
237
237
  pwd_file.save
238
+ else
239
+ verbose 'Skipping password scrub: need both net.host and user.name to remove.'
238
240
  end
239
241
 
240
242
  clear_from_config(net_host, user_name) unless token_delete_only
@@ -249,7 +251,10 @@ Or set your password with `murano password set <username>`.
249
251
  # Only clear user name from the user config if the net.host
250
252
  # or user.name did not come from a different config, like the
251
253
  # --project config.
252
- return unless (user_net_host == net_host) && (user_user_name == user_name)
254
+ unless (user_net_host == net_host) && (user_user_name == user_name)
255
+ verbose 'Skipping config scrub: net.host and/or user.name do not match.'
256
+ return
257
+ end
253
258
  $cfg.set('user.name', nil, :user)
254
259
  $cfg.set('business.id', nil, :user)
255
260
  $cfg.set('business.name', nil, :user)
@@ -1,15 +1,13 @@
1
- # Last Modified: 2017.09.20 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
- require 'date'
9
8
  require 'inflecto'
10
9
  require 'json'
11
10
  require 'net/http'
12
- require 'pathname'
13
11
  require 'rainbow'
14
12
  require 'uri'
15
13
  require 'yaml'
@@ -109,7 +107,7 @@ module MrMurano
109
107
 
110
108
  def self.missing_business_id_msg
111
109
  %(
112
- business ID not specified. For hints: #{MrMurano::EXE_NAME} business --help
110
+ business ID not specified. For hints: #{MrMurano::EXE_NAME} business --help
113
111
  ).strip
114
112
  end
115
113
 
@@ -183,6 +181,7 @@ business ID not specified. For hints: #{MrMurano::EXE_NAME} business --help
183
181
  nil
184
182
  else
185
183
  showHttpError(request, response)
184
+ nil
186
185
  end
187
186
  end
188
187
 
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.12 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'commander/import'
9
9
  require 'dotenv'
@@ -66,7 +66,7 @@ unless ARGV.include? '--skip-plugins'
66
66
  require plugin.to_s
67
67
  #rescue Exception => err
68
68
  rescue StandardError => err
69
- $stderr.puts "Failed to load plugin at #{plugin} because #{err}"
69
+ warn "Failed to load plugin at #{plugin} because #{err}"
70
70
  end
71
71
  end
72
72
  end
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.08.20 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'fileutils'
9
9
  require 'pathname'
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.20 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'highline'
9
9
  require 'inifile'
@@ -27,6 +27,8 @@ module MrMurano
27
27
  # mask values of the same keys in the lower scopes.
28
28
  CFG_SCOPES = %i[internal specified env project user defaults].freeze
29
29
 
30
+ CFG_HOST_BIZAPI = 'bizapi.hosted.exosite.io'
31
+
30
32
  ConfigFile = Struct.new(:kind, :path, :data) do
31
33
  def load
32
34
  return if kind == :internal
@@ -149,7 +151,8 @@ module MrMurano
149
151
  set('tool.fullerror', false, :defaults)
150
152
  set('tool.outformat', 'best', :defaults)
151
153
 
152
- set('net.host', 'bizapi.hosted.exosite.io', :defaults)
154
+ set('net.host', CFG_HOST_BIZAPI, :defaults)
155
+ set('net.protocol', 'https', :defaults)
153
156
 
154
157
  set('location.base', @project_dir, :defaults) unless @project_dir.nil?
155
158
  set('location.files', 'files', :defaults)
@@ -414,7 +417,7 @@ module MrMurano
414
417
  else
415
418
  # *.blah query
416
419
  path.data.each do |ini|
417
- path.data[ini].keys.each do |skey|
420
+ path.data[ini].each_key do |skey|
418
421
  next unless ikey == '*' || skey == ikey
419
422
  kvid = "#{ini}.#{skey}"
420
423
  next if seen[kvid]
@@ -580,6 +583,24 @@ module MrMurano
580
583
  @curlfile_f = nil
581
584
  end
582
585
  end
586
+
587
+ # To set a different protocol://host, i.e., for local developing.
588
+ def set_net_host(url_or_host, scope=:internal)
589
+ return if url_or_host.nil?
590
+ if url_or_host.to_s.empty?
591
+ $cfg.set('net.protocol', 'https', scope)
592
+ $cfg.set('net.host', CFG_HOST_BIZAPI, scope)
593
+ return
594
+ end
595
+ protocol_or_host, host_maybe = url_or_host.split('://', 2)
596
+ if !host_maybe.nil?
597
+ $cfg.set('net.protocol', protocol_or_host, scope)
598
+ $cfg.set('net.host', host_maybe, scope)
599
+ else
600
+ $cfg.set('net.protocol', 'https', scope)
601
+ $cfg.set('net.host', protocol_or_host, scope)
602
+ end
603
+ end
583
604
  end
584
605
 
585
606
  class ConfigError < StandardError
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.11 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'uri'
9
9
  require 'cgi'
@@ -43,7 +43,7 @@ module MrMurano
43
43
  # @return URI: The full URI for this enpoint.
44
44
  def endpoint(path='')
45
45
  super
46
- parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts
46
+ parts = [$cfg['net.protocol'] + ':/', $cfg['net.host'], 'api:1'] + @uriparts
47
47
  s = parts.map(&:to_s).join('/')
48
48
  URI(s + path.to_s)
49
49
  end
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.27 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  module MrMurano
9
9
  class ExchangeElement
@@ -1,9 +1,9 @@
1
- # Last Modified: 2017.09.27 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'MrMurano/Exchange-Element'
9
9
 
@@ -1,13 +1,14 @@
1
- # Last Modified: 2017.09.11 /coding: utf-8
1
+ # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
+ # License: PROPRIETARY. See LICENSE.txt.
2
3
  # frozen_string_literal: true
3
4
 
4
- # Copyright © 2016-2017 Exosite LLC.
5
- # License: MIT. See LICENSE.txt.
6
- # vim:tw=0:ts=2:sw=2:et:ai
5
+ # vim:tw=0:ts=2:sw=2:et:ai
6
+ # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'http/form_data'
9
9
  require 'json-schema'
10
10
  require 'net/http'
11
+ require 'pathname'
11
12
  require 'uri'
12
13
  require 'MrMurano/hash'
13
14
  require 'MrMurano/http'
@@ -42,7 +43,7 @@ module MrMurano
42
43
  # @return URI: The full URI for this enpoint.
43
44
  def endpoint(path='')
44
45
  super
45
- parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts
46
+ parts = [$cfg['net.protocol'] + ':/', $cfg['net.host'], 'api:1'] + @uriparts
46
47
  s = parts.map(&:to_s).join('/')
47
48
  URI(s + path.to_s)
48
49
  end
@@ -168,11 +169,12 @@ module MrMurano
168
169
  end
169
170
 
170
171
  def syncup_after
171
- super
172
+ num_synced = super
172
173
  if !@there.empty?
173
174
  if !$cfg['tool.dry']
174
- sync_update_progress('Updating product resources')
175
+ sync_update_progress('Updating remote product resources')
175
176
  upload_all(@there)
177
+ num_synced += 1
176
178
  else
177
179
  MrMurano::Verbose.whirly_interject do
178
180
  say('--dry: Not updating resources')
@@ -184,6 +186,7 @@ module MrMurano
184
186
  end
185
187
  end
186
188
  @there = nil
189
+ num_synced
187
190
  end
188
191
 
189
192
  ###################################################
@@ -234,12 +237,14 @@ module MrMurano
234
237
  end
235
238
 
236
239
  def syncdown_after(local)
237
- super
238
- resources_write(local)
240
+ num_synced = super
241
+ num_synced += resources_write(local)
239
242
  @here = nil
243
+ num_synced
240
244
  end
241
245
 
242
246
  def resources_write(file_path)
247
+ num_synced = 0
243
248
  # User can blow away specs/ directory if they want; we'll just make
244
249
  # a new one. [This code somewhat copy-paste from make_directory.]
245
250
  basedir = file_path
@@ -263,16 +268,22 @@ module MrMurano
263
268
  return
264
269
  end
265
270
 
271
+ sync_update_progress('Updating local product resources')
272
+
266
273
  file_path.open('wb') do |io|
267
274
  # convert array to hash
268
275
  res = {}
269
276
  @here.each do |value|
270
277
  key = value[:alias]
271
- res[key] = Hash.transform_keys_to_strings(value.reject { |k, _v| k == :alias })
278
+ res[key] = Hash.transform_keys_to_strings(
279
+ value.reject { |k, _v| k == :alias }
280
+ )
272
281
  end
273
282
  ohash = ordered_hash(res)
274
283
  io.write ohash.to_yaml
275
284
  end
285
+
286
+ num_synced + 1
276
287
  end
277
288
 
278
289
  def diff_item_write(io, _merged, local, remote)
@@ -397,7 +408,7 @@ module MrMurano
397
408
  props[:auth][:expire] = Integer(opts[:expire])
398
409
  rescue ArgumentError
399
410
  # Callers should prevent this, so ugly raise is okay.
400
- raise ':expire option is not a valid number: #{fancy_ticks(opts[:expire])}'
411
+ raise ":expire option is not a valid number: #{fancy_ticks(opts[:expire])}"
401
412
  end
402
413
  end
403
414
  unless opts[:type].nil?