MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -0,0 +1,24 @@
1
+ " 2017-08-02: Aha! EZ-CI at last!
2
+
3
+ " USAGE: See: .trustme.sh
4
+
5
+ "echomsg "You've been Vimmed! at " . expand('%')
6
+
7
+ " @% is same as expand('%'), which for some miraculous reason
8
+ " is the path relative to this file??
9
+ "autocmd BufWrite *.rb echomsg "Hooray! at " . expand('%')
10
+ "autocmd BufWrite *.rb echomsg "Hooray! at " . @%
11
+
12
+ " Use an autocmd group so it's easy to delete the group,
13
+ " since every time we call autocmd, the command is appended,
14
+ " and this file gets sourced every switch to a corresponding
15
+ " project buffer.
16
+ augroup trustme
17
+ " Remove! all trustme autocommands.
18
+ autocmd! trustme
19
+ "autocmd BufWrite *.rb silent !touch TOUCH
20
+ "autocmd BufWrite <buffer> echom "trustme is hooked!"
21
+ " MEH/2017-08-02: This won't hook bin/murano.
22
+ autocmd BufWrite <buffer> silent !./.trustme.sh &
23
+ augroup END
24
+
data/Gemfile CHANGED
@@ -1,24 +1,43 @@
1
+ # Last Modified: 2017.08.17 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  source 'http://rubygems.org'
2
9
 
3
10
  #gemspec
4
11
 
5
- gem 'commander', '~> 4.4.3'
6
12
  gem 'certified', '1.0.0'
13
+ gem 'commander', '~> 4.4.3'
7
14
  gem 'dotenv', '~> 2.1.1'
15
+ #gem 'eventmachine', '~> 1.2.3'
8
16
  gem 'highline', '~> 1.7.8'
9
- gem 'http-form_data', '1.0.2'
17
+ gem 'http-form_data', '~> 1.0.3'
18
+ gem 'inflecto'
10
19
  gem 'inifile', '~> 3.0'
20
+ gem 'json', '~> 2.1.0'
11
21
  gem 'json-schema', '~> 2.7.0'
12
22
  gem 'mime-types', '~> 3.1'
13
23
  gem 'mime-types-data', '~> 3.2016.0521'
24
+ gem 'orderedhash', '~> 0.0.6'
25
+ gem 'paint', '~> 2.0.0'
26
+ gem 'rainbow', '~> 2.2.2'
14
27
  gem 'terminal-table', '~> 1.7.3'
28
+ gem 'vine', '~> 0.4'
29
+ gem 'whirly', '~> 0.2.4'
15
30
 
16
31
  group :test do
17
- gem 'coderay', :require => false
32
+ #gem 'bundler', '~> 1.7.6'
33
+ gem 'byebug', '~> 9.0.6'
34
+ gem 'coderay', require: false
18
35
  gem 'rake', '~> 10.1.1'
19
36
  gem 'rspec', '~> 3.5'
20
- gem 'simplecov', :require => false
37
+ gem 'rubocop', '~> 0.49.1'
38
+ gem 'simplecov', require: false
21
39
  gem 'webmock', '~> 2.3.0'
40
+ #gem 'vcr'
22
41
  gem 'yard'
23
42
  end
24
43
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Exosite
1
+ Copyright (c) 2016-2017 Exosite
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
4
  software and associated documentation files (the "Software"), to deal in the
@@ -1,4 +1,10 @@
1
- # -*- encoding: utf-8 -*-
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
2
8
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
9
  require_relative 'lib/MrMurano/version.rb'
4
10
 
@@ -10,7 +16,7 @@ Gem::Specification.new do |s|
10
16
  s.license = 'MIT'
11
17
  s.homepage = 'https://github.com/exosite/MuranoCLI'
12
18
  s.summary = 'Do more from the command line with Murano'
13
- s.description = %{Do more from the command line with Murano
19
+ s.description = %(Do more from the command line with Murano
14
20
 
15
21
  Push and pull data from Murano.
16
22
  Get status on what things have changed.
@@ -19,32 +25,61 @@ Gem::Specification.new do |s|
19
25
  and so much more.
20
26
 
21
27
  This gem was formerly known as MrMurano.
22
- }
28
+ )
23
29
  s.required_ruby_version = '~> 2.0'
24
30
 
31
+ # FIXME: 2017-05-25: Remove this message eventually.
32
+ s.post_install_message = %(
33
+ MuranoCLI v3.0 introduces backwards-incompatible changes.
34
+
35
+ If your business was created with MuranoCLI v2.x, you will
36
+ want to continue using the old gem, which you can run by
37
+ explicitly specifying the version. For instance,
38
+
39
+ murano _2.2.4_ --version
40
+
41
+ )
42
+
25
43
  s.files = `git ls-files`.split("\n")
26
44
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
45
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
28
46
  s.require_paths = ['lib']
29
47
 
30
- s.add_runtime_dependency('commander', '~> 4.4.3')
31
48
  s.add_runtime_dependency('certified', '1.0.0')
49
+ s.add_runtime_dependency('commander', '~> 4.4.3')
32
50
  s.add_runtime_dependency('dotenv', '~> 2.1.1')
51
+ # 2017-08-15: Getting warning when running --user-install gem in 2.4.0. [lb]:
52
+ # Ignoring eventmachine-1.2.3 because its extensions are not built.
53
+ # Try: gem pristine eventmachine --version 1.2.3
54
+ # This might be because 'json' was also being complained about.
55
+ #s.add_runtime_dependency('eventmachine', '~> 1.2.3')
33
56
  s.add_runtime_dependency('highline', '~> 1.7.8')
34
- s.add_runtime_dependency('http-form_data', '1.0.2')
57
+ s.add_runtime_dependency('http-form_data', '~> 1.0.3')
58
+ s.add_runtime_dependency('inflecto')
35
59
  s.add_runtime_dependency('inifile', '~> 3.0')
60
+ s.add_runtime_dependency('json', '~> 2.1.0')
36
61
  s.add_runtime_dependency('json-schema', '~> 2.7.0')
37
62
  s.add_runtime_dependency('mime-types', '~> 3.1')
38
63
  s.add_runtime_dependency('mime-types-data', '~> 3.2016.0521')
64
+ s.add_runtime_dependency('orderedhash', '~> 0.0.6')
65
+ s.add_runtime_dependency('paint', '~> 2.0.0')
66
+ s.add_runtime_dependency('rainbow', '~> 2.2.2')
39
67
  s.add_runtime_dependency('terminal-table', '~> 1.7.3')
68
+ s.add_runtime_dependency('vine', '~> 0.4')
69
+ s.add_runtime_dependency('whirly', '~> 0.2.4')
40
70
 
41
71
  s.add_development_dependency('bundler', '~> 1.7.6')
42
- s.add_development_dependency('ocra', '~> 1.3.8')
72
+ s.add_development_dependency('byebug', '~> 9.0.6')
73
+ #s.add_development_dependency('coderay', '~> ???')
43
74
  s.add_development_dependency('rake', '~> 10.1.1')
44
75
  s.add_development_dependency('rspec', '~> 3.5')
76
+ s.add_development_dependency('rubocop', '~> 0.49.1')
45
77
  s.add_development_dependency('simplecov')
46
- s.add_development_dependency('webmock', '~> 2.1.0')
78
+ s.add_development_dependency('webmock', '~> 2.3.0')
47
79
  # maybe? s.add_development_dependency('vcr', '~> ???')
48
- end
80
+ s.add_development_dependency('yard')
49
81
 
82
+ # Windows:
83
+ s.add_development_dependency('ocra', '~> 1.3.8')
84
+ end
50
85
 
@@ -113,16 +113,16 @@ All of these can be toggled with command line options.
113
113
 
114
114
  ### CORS
115
115
 
116
- If you are developing you UI on seperate services and you need cross-origin
116
+ If you are developing you UI on separate services and you need cross-origin
117
117
  resource sharing, you will need to set the
118
118
  [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) options.
119
119
 
120
120
  The current CORS options can be fetched with `murano cors`
121
121
 
122
- There are three opitons for setting, the first and preferred way is to put your CORS
123
- opitons into a file named `cors.yaml`.
122
+ There are three options for setting, the first and preferred way is to put your CORS
123
+ options into a file named `cors.yaml`.
124
124
 
125
- Second and third are to put the CORS opitons in your project file. In the `routes`
125
+ Second and third are to put the CORS options in your project file. In the `routes`
126
126
  section, add a `cors` sub-section with either the name of the file to read, or the
127
127
  CORS options inline.
128
128
 
@@ -148,13 +148,13 @@ and path. You set this with the following line:
148
148
  ```
149
149
 
150
150
  Optionally, you can set what the expected content type is too. (If you don't set
151
- this, the value is application/json)
151
+ this, the value is `application/json`)
152
152
 
153
153
  ```lua
154
154
  --#ENDPOINT METHOD PATH CONTENT_TYPE
155
155
  ```
156
156
 
157
- An example of a route that puts csv data:
157
+ An example of a route that puts CSV data:
158
158
  ```lua
159
159
  --#ENDPOINT PUT /api/upload text/csv
160
160
  ```
@@ -203,8 +203,8 @@ Tsdb.write{
203
203
  ### MURANO_CONFIGFILE environment and Dotenv
204
204
 
205
205
  The environment variable `MURANO_CONFIGFILE` is checked for an additional config to
206
- load. This in conjunction with dotenv support, allows for easily switching between
207
- development, staging, and production setups.
206
+ load. This, in conjunction with [dotenv](https://github.com/bkeepers/dotenv) support,
207
+ allows for easily switching between development, staging, and production setups.
208
208
 
209
209
  To use this, write the three solution ids into `.murano.dev`, `.murano.stg`,
210
210
  and `.murano.prod`. Then write the `.env` file to point at the system you're
@@ -296,10 +296,8 @@ tests work with the live Murano servers (`--tag needs_password`).
296
296
 
297
297
  To use the live tests, the following environment variables need to be set:
298
298
  - `MURANO_CONFIGFILE` : A Config with the user.name, business.id, and net.host for
299
- the intergration tests.
299
+ the integration tests.
300
300
  - `MURANO_PASSWORD` : Password for the user.name above.
301
301
 
302
302
  A free account on Murano is sufficient for these tests.
303
303
 
304
-
305
-
data/Rakefile CHANGED
@@ -1,200 +1,244 @@
1
- require "bundler/gem_tasks"
1
+ # Last Modified: 2017.08.15 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
8
+ require 'bundler/gem_tasks'
2
9
  require 'shellwords'
3
10
 
4
- task :default => [:test]
11
+ task default: %i[test]
5
12
 
6
- tagName = "v#{Bundler::GemHelper.gemspec.version}"
7
- gemName = "MuranoCLI-#{Bundler::GemHelper.gemspec.version}.gem"
8
- builtGem = "pkg/#{gemName}"
13
+ tag_name = "v#{Bundler::GemHelper.gemspec.version}"
14
+ gem_name = "MuranoCLI-#{Bundler::GemHelper.gemspec.version}.gem"
15
+ built_gem = "pkg/#{gem_name}"
9
16
 
10
- desc "Install gem in user dir"
17
+ # NOTE: If you're looking for the :build task, look in the bundler code, e.g.,
18
+ # /usr/lib/ruby/vendor_ruby/bundler/gem_helper.rb::build_gem
19
+
20
+ desc 'Install gem in user dir'
11
21
  task :bob do
12
- sh %{gem install --user-install #{builtGem}}
22
+ sh %(gem install --user-install #{built_gem})
13
23
  end
14
24
 
15
- desc "Uninstall from user dir"
25
+ desc 'Uninstall from user dir'
16
26
  task :unbob do
17
- sh %{gem uninstall --user-install #{builtGem}}
27
+ sh %(gem uninstall --user-install #{built_gem})
28
+ end
29
+
30
+ desc 'Build and install into user gems directory (useful for rvm and chruby)'
31
+ task :'install:user' do
32
+ sh %(rake build)
33
+ # Bundler::GemHelper.gemspec.base_dir is the base of the project,
34
+ # and not the base of the gem directory.
35
+ sh %(gem install -i #{Gem.dir} #{built_gem})
36
+ end
37
+
38
+ desc 'Uninstall gem from user gems directory'
39
+ task :'uninstall:user' do
40
+ # HINT: Replace #{built_gem} with any version to uninstall a specific version.
41
+ # MAYBE/2017-08-04: A task to uninstall all installed versions?
42
+ sh %(gem uninstall --version #{built_gem})
18
43
  end
19
44
 
20
45
  task :echo do
21
- puts tagName
22
- puts gemName
23
- puts builtGem
46
+ puts tag_name
47
+ puts gem_name
48
+ puts built_gem
24
49
  end
25
50
 
26
- desc "display remind of how to release"
51
+ desc 'display remind of how to release'
27
52
  task :release_reminder do
28
- puts <<EOR
29
- git flow release start <newversion>
30
- gvim lib/MrMurano/version.rb
31
- git commit -a -m 'version bump'
32
- git flow release finish <newversion>
33
- # When editing message for tag, add release notes.
34
- #rake git:all
35
- # Wait for all tests to complete.
36
- # if all passed: rake gemit
37
- EOR
53
+ reminder = %(
54
+ git flow release start <newversion>
55
+ gvim lib/MrMurano/version.rb
56
+ git commit -a -m 'version bump'
57
+ git flow release finish <newversion>
58
+ # When editing message for tag, add release notes.
59
+ #rake git:all
60
+ # Wait for all tests to complete.
61
+ # if all passed: rake gemit
62
+ ).lines.map(&:strip).join("\n")
63
+ puts reminder
38
64
  end
39
65
 
40
- desc "Prints a cmd to test this in another directory"
66
+ desc 'Prints a cmd to test this in another directory'
41
67
  task :testwith do
42
- pwd=Dir.pwd.sub(Dir.home, '~')
43
- puts "ruby -I#{pwd}/lib #{pwd}/bin/murano "
68
+ pwd = Dir.pwd.sub(Dir.home, '~')
69
+ puts "ruby -I#{pwd}/lib #{pwd}/bin/murano "
44
70
  end
45
71
 
46
72
  desc 'Run RSpec'
47
73
  task :rspec do
48
- Dir.mkdir("report") unless File.directory?("report")
49
- rv=RUBY_VERSION.gsub(/\./,'_')
50
- sh %{rspec --format html --out report/index-#{rv}.html --format documentation}
74
+ Dir.mkdir('report') unless File.directory?('report')
75
+ rv = RUBY_VERSION.tr('.', '_')
76
+ sh %(rspec --format html --out report/index-#{rv}.html --format documentation)
51
77
  end
52
- task :test => [:test_clean_up, :rspec]
53
-
54
- desc "Clean out junk from prior hot tests"
55
- task :test_clean_up do
56
- if not ENV['MURANO_CONFIGFILE'].nil? then
78
+ task test: %i[test_clean_up rspec]
57
79
 
58
- ids = `ruby -Ilib bin/murano product list --idonly`.chomp
59
- puts "Found prodcuts #{ids}; deleteing"
60
- ids.split.each do |id|
61
- sh %{ruby -Ilib bin/murano product delete #{id}}
62
- end
80
+ desc 'Run Rubocop linter'
81
+ task :rubocop do
82
+ sh %(rubocop -D -c .rubocop.yml)
83
+ end
63
84
 
64
- ids = `ruby -Ilib bin/murano solution list --idonly`.chomp
65
- puts "Found solutions #{ids}; deleteing"
66
- ids.split.each do |id|
67
- sh %{ruby -Ilib bin/murano solution delete #{id}}
68
- end
69
- end
85
+ desc 'Clean out junk from prior hot tests'
86
+ task :test_clean_up do
87
+ unless ENV['MURANO_CONFIGFILE'].nil?
88
+ #ids = `ruby -Ilib bin/murano solution list --idonly`.chomp
89
+ #unless ids.empty?
90
+ # puts "Found solutions #{ids}; deleting"
91
+ # ids.split.each do |id|
92
+ # sh %(ruby -Ilib bin/murano solution delete #{id})
93
+ # end
94
+ #end
95
+ # rubocop:disable Style/BlockDelimiters
96
+ # "Prefer {...} over do...end for single-line blocks."
97
+ # Substituting braces for the do/end causes another problem:
98
+ # "syntax error, unexpected '{', expecting keyword_end"
99
+ sh %(ruby -Ilib bin/murano solutions expunge -y) do |_ok, _res| end
100
+ end
70
101
  end
71
102
 
72
103
  ###
73
104
  # When new tags are pushed to upstream, the CI will kick-in and build the release
74
105
  #namespace :git do
75
- # desc "Push only develop, master, and tags to origin"
106
+ # desc 'Push only develop, master, and tags to origin'
76
107
  # task :origin do
77
- # sh %{git push origin develop}
78
- # sh %{git push origin master}
79
- # sh %{git push origin --tags}
108
+ # sh %(git push origin develop)
109
+ # sh %(git push origin master)
110
+ # sh %(git push origin --tags)
80
111
  # end
81
112
  #
82
- # desc "Push only develop, master, and tags to upstream"
113
+ # desc 'Push only develop, master, and tags to upstream'
83
114
  # task :upstream do
84
- # sh %{git push upstream develop}
85
- # sh %{git push upstream master}
86
- # sh %{git push upstream --tags}
115
+ # sh %(git push upstream develop)
116
+ # sh %(git push upstream master)
117
+ # sh %(git push upstream --tags)
87
118
  # end
88
119
  #
89
- # desc "Push to origin and upstream"
90
- # task :all => [:origin, :upstream]
120
+ # desc 'Push to origin and upstream'
121
+ # task all: %i[origin upstream]
91
122
  #end
92
123
 
93
- desc "Build, install locally, and push gem"
124
+ desc 'Build, install locally, and push gem'
94
125
  task :gemit do
95
- mrt=Bundler::GemHelper.gemspec.version
96
- sh %{git checkout v#{mrt}}
97
- Rake::Task[:build].invoke
98
- Rake::Task[:bob].invoke
99
- Rake::Task['push:gem'].invoke
100
- sh %{git checkout develop}
126
+ mrt = Bundler::GemHelper.gemspec.version
127
+ sh %(git checkout v#{mrt})
128
+ Rake::Task[:build].invoke
129
+ Rake::Task[:bob].invoke
130
+ Rake::Task['push:gem'].invoke
131
+ sh %(git checkout develop)
101
132
  end
102
133
 
103
134
  ###########################################
104
135
  # Tasks below are largly used by CI systems
105
136
  namespace :push do
106
- desc 'Push gem up to RubyGems'
107
- task :gem do
108
- sh %{gem push #{builtGem}}
109
- end
110
-
111
- namespace :github do
112
- desc "Make a release in Github"
113
- task :makeRelease do
114
- # ENV['GITHUB_TOKEN'] set by CI.
115
- # ENV['GITHUB_USER'] set by CI.
116
- # ENV['GITHUB_REPO'] set by CI
117
- # Create Release
118
- sh %{github-release info --tag #{tagName}} do |ok, res|
119
- if not ok then
120
- sh %{github-release release --tag #{tagName}}
121
- end
122
- end
123
- end
124
-
125
- desc 'Push gem up to Github Releases'
126
- task :gem => [:makeRelease, :build] do
127
- # ENV['GITHUB_TOKEN'] set by CI.
128
- # ENV['GITHUB_USER'] set by CI.
129
- # ENV['GITHUB_REPO'] set by CI
130
- # upload gem
131
- sh %{github-release upload --tag #{tagName} --name #{gemName} --file #{builtGem}}
132
- end
133
-
134
- desc "Copy tag commit message into Release Notes"
135
- task :copyReleaseNotes do
136
- tagMsg = `git tag -l -n999 #{tagName}`.lines
137
- tagMsg.shift
138
- msg = tagMsg.join().shellescape
139
- sh %{github-release edit --tag #{tagName} --description #{msg}}
140
- end
137
+ desc 'Push gem up to RubyGems'
138
+ task :gem do
139
+ sh %(gem push #{built_gem})
140
+ end
141
+
142
+ namespace :github do
143
+ desc 'Verify that the computed tag exists'
144
+ task :verifyTag do
145
+ r = `git tag -l #{tag_name}`
146
+ raise "Tag doesn't exist (#{tag_name})" if r.empty?
141
147
  end
142
- end
143
148
 
144
- file "ReadMe.txt" => ['README.markdown'] do |t|
145
- File.open(t.prerequisites.first) do |rio|
146
- File.open(t.name, 'w') do |wio|
147
- wio << rio.read.gsub(/\n/,"\r\n")
149
+ desc 'Make a release in Github'
150
+ task :makeRelease do
151
+ # ENV['GITHUB_TOKEN'] set by CI.
152
+ # ENV['GITHUB_USER'] set by CI.
153
+ # ENV['GITHUB_REPO'] set by CI
154
+ # Create Release
155
+ sh %(github-release info --tag #{tag_name}) do |ok, _res|
156
+ unless ok
157
+ # if version contains more than #.#.#, mark it as pre-release
158
+ if /v\d+\.\d+\.\d+(.*)/.match(tag_name)[1].nil?
159
+ sh %(github-release release --tag #{tag_name})
160
+ else
161
+ sh %(github-release release --tag #{tag_name} -p)
162
+ end
148
163
  end
164
+ end
149
165
  end
150
- end
151
166
 
152
- if Gem.win_platform? then
153
- file 'murano.exe' => Dir['lib/**/*.{rb,erb,yaml}'] do
154
- # Need to find all dlls, because ocra isn't finding them for some reason.
155
- gemdir = `gem env gemdir`.chomp
156
- gemdlls = Dir[File.join(gemdir, 'extensions', '*')]
157
- dataFiles = Dir['lib/**/*.{erb,yaml}']
158
- others = gemdlls + dataFiles
159
- ENV['RUBYLIB'] = 'lib'
160
- sh %{ocra bin/murano #{others.join(' ')}}
167
+ desc 'Push gem up to Github Releases'
168
+ task gem: %i[makeRelease build] do
169
+ # ENV['GITHUB_TOKEN'] set by CI.
170
+ # ENV['GITHUB_USER'] set by CI.
171
+ # ENV['GITHUB_REPO'] set by CI
172
+ # upload gem
173
+ sh %(github-release upload --tag #{tag_name} --name #{gem_name} --file #{built_gem})
161
174
  end
162
- task :wexe => ['murano.exe']
163
175
 
164
- desc 'Run rspec on cmd tests using murano.exe'
165
- task :murano_exe_test => ['murano.exe'] do
166
- Dir.mkdir("report") unless File.directory?("report")
167
- ENV['CI_MR_EXE'] = '1'
168
- sh %{rspec --format html --out report/murano_exe.html --format documentation --tag cmd}
176
+ desc 'Copy tag commit message into Release Notes'
177
+ task :copyReleaseNotes do
178
+ tag_msg = `git tag -l -n999 #{tag_name}`.lines
179
+ tag_msg.shift
180
+ msg = tag_msg.join.shellescape
181
+ sh %(github-release edit --tag #{tag_name} --description #{msg})
169
182
  end
170
- task :test => [:murano_exe_test]
171
-
172
- installerName = "Output/MuranoCLI-#{Bundler::GemHelper.gemspec.version.to_s}-Setup.exe"
173
-
174
- desc "Build a Windows installer for MuranoCLI"
175
- task :inno => [installerName]
183
+ end
184
+ end
176
185
 
177
- file "Output/MuranoCLISetup.exe" => ['murano.exe', 'ReadMe.txt'] do
178
- ENV['MRVERSION'] = Bundler::GemHelper.gemspec.version.to_s
179
- sh %{"C:\\Program Files (x86)\\Inno Setup 5\\iscc.exe" MuranoCLI.iss}
180
- end
181
- file installerName => ['Output/MuranoCLISetup.exe'] do |t|
182
- FileUtils.move t.prerequisites.first, t.name, :verbose=>true
186
+ file 'ReadMe.txt' => ['README.markdown'] do |t|
187
+ File.open(t.prerequisites.first) do |rio|
188
+ File.open(t.name, 'w') do |wio|
189
+ wio << rio.read.gsub(/\n/, "\r\n")
183
190
  end
191
+ end
192
+ end
184
193
 
185
- namespace :push do
186
- namespace :github do
187
- desc "Push Windows installer to Github Releases"
188
- task :inno => [:makeRelease, installerName] do
189
- # ENV['GITHUB_TOKEN'] set by CI.
190
- # ENV['GITHUB_USER'] set by CI.
191
- # ENV['GITHUB_REPO'] set by CI
192
- iname = File.basename(installerName)
193
- sh %{github-release upload --tag #{tagName} --name #{iname} --file #{installerName}}
194
- end
195
- end
194
+ if Gem.win_platform?
195
+ desc 'Build as a single windows exe'
196
+ file 'murano.exe' => Dir['lib/**/*.{rb,erb,yaml}'] do
197
+ # Need to find all dlls, because ocra isn't finding them for some reason.
198
+ # NOTE: $: same as $LOAD_PATH
199
+ shadlls = Dir[*$LOAD_PATH.map { |i| File.join(i, 'digest/sha2.{so,dll}') }]
200
+ gemdir = `gem env gemdir`.chomp
201
+ gemdlls = Dir[File.join(gemdir, 'extensions', '*')]
202
+ data_files = Dir['lib/**/*.{erb,yaml}']
203
+ others = gemdlls + data_files + shadlls
204
+ ENV['RUBYLIB'] = 'lib'
205
+ sh %(ocra bin/murano #{others.join(' ')})
206
+ end
207
+ task wexe: ['murano.exe']
208
+
209
+ desc 'Run rspec on cmd tests using murano.exe'
210
+ task murano_exe_test: ['murano.exe'] do
211
+ Dir.mkdir('report') unless File.directory?('report')
212
+ rv = RUBY_VERSION.tr('.', '_')
213
+ ENV['CI_MR_EXE'] = '1'
214
+ sh %(rspec --format html --out report/murano_exe-#{rv}.html --format documentation --tag cmd)
215
+ end
216
+ task test: %i[murano_exe_test]
217
+
218
+ installer_name = "Output/MuranoCLI-#{Bundler::GemHelper.gemspec.version}-Setup.exe"
219
+
220
+ desc 'Build a Windows installer for MuranoCLI'
221
+ task inno: [installer_name]
222
+
223
+ file 'Output/MuranoCLISetup.exe' => ['murano.exe', 'ReadMe.txt'] do
224
+ ENV['MRVERSION'] = Bundler::GemHelper.gemspec.version.to_s
225
+ sh %("C:\\Program Files (x86)\\Inno Setup 5\\iscc.exe" MuranoCLI.iss)
226
+ end
227
+ file installer_name => ['Output/MuranoCLISetup.exe'] do |t|
228
+ FileUtils.move t.prerequisites.first, t.name, verbose: true
229
+ end
230
+
231
+ namespace :push do
232
+ namespace :github do
233
+ desc 'Push Windows installer to Github Releases'
234
+ task inno: [:makeRelease, installer_name] do
235
+ # ENV['GITHUB_TOKEN'] set by CI.
236
+ # ENV['GITHUB_USER'] set by CI.
237
+ # ENV['GITHUB_REPO'] set by CI
238
+ iname = File.basename(installer_name)
239
+ sh %(github-release upload --tag #{tag_name} --name #{iname} --file #{installer_name})
240
+ end
196
241
  end
242
+ end
197
243
  end
198
244
 
199
- # vim: set sw=4 ts=4 :
200
-