MuranoCLI 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +1 -0
  3. data/.rubocop.yml +67 -5
  4. data/Gemfile +6 -3
  5. data/MuranoCLI.gemspec +14 -10
  6. data/README.markdown +299 -126
  7. data/Rakefile +6 -1
  8. data/bin/murano +2 -2
  9. data/docs/completions/murano_completion-bash +93 -0
  10. data/lib/MrMurano.rb +19 -2
  11. data/lib/MrMurano/Business.rb +22 -19
  12. data/lib/MrMurano/Config.rb +19 -9
  13. data/lib/MrMurano/Content.rb +4 -4
  14. data/lib/MrMurano/Exchange-Element.rb +99 -0
  15. data/lib/MrMurano/Exchange.rb +137 -0
  16. data/lib/MrMurano/Gateway.rb +9 -9
  17. data/lib/MrMurano/Keystore.rb +4 -2
  18. data/lib/MrMurano/ReCommander.rb +3 -5
  19. data/lib/MrMurano/Solution-ServiceConfig.rb +12 -12
  20. data/lib/MrMurano/Solution-Services.rb +15 -14
  21. data/lib/MrMurano/Solution-Users.rb +2 -2
  22. data/lib/MrMurano/Solution.rb +43 -49
  23. data/lib/MrMurano/SolutionId.rb +28 -28
  24. data/lib/MrMurano/SyncUpDown.rb +32 -22
  25. data/lib/MrMurano/Webservice-Endpoint.rb +2 -1
  26. data/lib/MrMurano/Webservice.rb +5 -5
  27. data/lib/MrMurano/commands.rb +2 -1
  28. data/lib/MrMurano/commands/business.rb +21 -19
  29. data/lib/MrMurano/commands/domain.rb +16 -2
  30. data/lib/MrMurano/commands/exchange.rb +272 -0
  31. data/lib/MrMurano/commands/globals.rb +17 -1
  32. data/lib/MrMurano/commands/init.rb +3 -3
  33. data/lib/MrMurano/commands/link.rb +16 -16
  34. data/lib/MrMurano/commands/postgresql.rb +2 -2
  35. data/lib/MrMurano/commands/show.rb +13 -7
  36. data/lib/MrMurano/commands/solution.rb +23 -17
  37. data/lib/MrMurano/commands/solution_picker.rb +49 -44
  38. data/lib/MrMurano/commands/sync.rb +2 -1
  39. data/lib/MrMurano/commands/timeseries.rb +2 -2
  40. data/lib/MrMurano/commands/tsdb.rb +2 -2
  41. data/lib/MrMurano/hash.rb +19 -7
  42. data/lib/MrMurano/http.rb +12 -2
  43. data/lib/MrMurano/orderedhash.rb +200 -0
  44. data/lib/MrMurano/spec_commander.rb +98 -0
  45. data/lib/MrMurano/verbosing.rb +2 -2
  46. data/lib/MrMurano/version.rb +2 -2
  47. data/spec/Business_spec.rb +8 -6
  48. data/spec/Solution-ServiceConfig_spec.rb +1 -1
  49. data/spec/SyncUpDown_spec.rb +6 -6
  50. data/spec/_workspace.rb +9 -4
  51. data/spec/cmd_business_spec.rb +8 -2
  52. data/spec/cmd_common.rb +266 -25
  53. data/spec/cmd_exchange_spec.rb +118 -0
  54. data/spec/cmd_help_spec.rb +54 -13
  55. data/spec/cmd_init_spec.rb +1 -12
  56. data/spec/cmd_link_spec.rb +94 -72
  57. data/spec/spec_helper.rb +11 -16
  58. metadata +23 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e6cce4e91f5060a854bb7994fe2f5692aa6e9a0
4
- data.tar.gz: 24c9ea0a2c2f8f2889740e60aa79fedfe4f4e7eb
3
+ metadata.gz: 0ea22792f25e5418a7687bbffaad2bf0b14f2c28
4
+ data.tar.gz: cbb94dd03d104a310c3f34c85381f1ce2dd455ff
5
5
  SHA512:
6
- metadata.gz: 5ef371516ac2ae1a8b308a08b81b0d64f3458d4bb7f2b74ef36b3c4628eba2ba04aa9a3273cbf7ed43e30a77e384c24bb3c1451724576f30c1f6408095c1fb61
7
- data.tar.gz: 97c8dfafc76608f74ea8e87ff35f4a5208e74d27766316119c78bb0e4ad5cda0bead9fb23a0155d6b1a725760188aa74d0b258a39da817de5c7a51c694f12baf
6
+ metadata.gz: 728ee381c09f8e361d368a2971f8a031e17900186f114ddda941085eafa5ed7f921be17d57347a1051eab0348c0a9e8965858bcf1e8aefee2d8796c6b988f103
7
+ data.tar.gz: c81a425d2122475db3ecccee78389df533ed4f0dd050d086cea6418e65361c2b804f363d3143e6f074176916cbd78b66bcbc99c1fe6a85e7a6f494d47aef5d99
data/.agignore CHANGED
@@ -10,6 +10,7 @@ Gemfile.lock
10
10
 
11
11
  # 2017-05-12: Testing!
12
12
  *.out
13
+ .rake_build.out
13
14
 
14
15
  rspec-*.html
15
16
  *.rspec.html
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.22 /coding: utf-8
1
+ # Last Modified: 2017.08.31 /coding: utf-8
2
2
  # Copyright © 2016-2017 Exosite LLC.
3
3
  # License: MIT. See LICENSE.txt.
4
4
  # vim:tw=0:ts=2:sw=2:et:ai
@@ -28,6 +28,8 @@ Layout/TrailingBlankLines:
28
28
  Lint/ScriptPermission:
29
29
  Exclude:
30
30
  - 'bin/murano'
31
+ # Also the rspec shim-link:
32
+ - 'lib/MrMurano/spec_commander.rb'
31
33
 
32
34
  # "Assignment Branch Condition size for XXX is too high."
33
35
  # http://wiki.c2.com/?AbcMetric
@@ -122,6 +124,8 @@ Style/FileName:
122
124
  - 'lib/MrMurano/Config-Migrate.rb'
123
125
  - 'lib/MrMurano/Config.rb'
124
126
  - 'lib/MrMurano/Content.rb'
127
+ - 'lib/MrMurano/Exchange.rb'
128
+ - 'lib/MrMurano/Exchange-Element.rb'
125
129
  - 'lib/MrMurano/Gateway.rb'
126
130
  - 'lib/MrMurano/Keystore.rb'
127
131
  - 'lib/MrMurano/Mock.rb'
@@ -232,14 +236,72 @@ AllCops:
232
236
  # HINT: You can use regexp in this list.
233
237
  #- !ruby/regexp /old_and_unused\.rb$/
234
238
  #
235
- # 2017-07-25: It's probably not worth our time to lint the spec tests.
236
- # 2017-07-31: 7735 offenses in the Spec tests -- not worth it to fix!!
237
- - 'spec/**/*'
238
- #
239
239
  # Not sure if the templates are included by default or not, but ignore.
240
240
  - 'lib/MrMurano/commands/completion-bash.erb'
241
241
  - 'lib/MrMurano/commands/completion-zsh.erb'
242
242
  #
243
243
  # 2017-08-16: Ug.
244
244
  - 'lib/MrMurano/optparse.rb'
245
+ #
246
+ # 2017-08-29: A hack for rspec.
247
+ #- 'lib/Murano/spec_commander.rb'
248
+ #
249
+ # 2017-08-30: Ug. Loading orderedhash spits out warning gobbled by rspec fails test.
250
+ - 'lib/MrMurano/orderedhash.rb'
251
+ #
252
+ # The spec_helper is a generated file; don't care.
253
+ - 'spec/spec_helper.rb'
254
+ #
255
+ # 2017-07-25: It's probably not worth our time to lint the spec tests.
256
+ # 2017-07-31: 7735 offenses in the Spec tests -- not worth it to fix!!
257
+ #- 'spec/**/*'
258
+ - 'spec/Account-Passwords_spec.rb'
259
+ - 'spec/Account_spec.rb'
260
+ - 'spec/Business_spec.rb'
261
+ - 'spec/ConfigFile_spec.rb'
262
+ - 'spec/ConfigMigrate_spec.rb'
263
+ - 'spec/Config_spec.rb'
264
+ - 'spec/Content_spec.rb'
265
+ - 'spec/GatewayBase_spec.rb'
266
+ - 'spec/GatewayDevice_spec.rb'
267
+ - 'spec/GatewayResource_spec.rb'
268
+ - 'spec/GatewaySettings_spec.rb'
269
+ - 'spec/Http_spec.rb'
270
+ - 'spec/MakePretties_spec.rb'
271
+ - 'spec/Mock_spec.rb'
272
+ - 'spec/ProjectFile_spec.rb'
273
+ - 'spec/Setting_spec.rb'
274
+ - 'spec/Solution-ServiceConfig_spec.rb'
275
+ - 'spec/Solution-ServiceEventHandler_spec.rb'
276
+ - 'spec/Solution-ServiceModules_spec.rb'
277
+ - 'spec/Solution-UsersRoles_spec.rb'
278
+ - 'spec/Solution_spec.rb'
279
+ - 'spec/SyncRoot_spec.rb'
280
+ - 'spec/SyncUpDown_spec.rb'
281
+ - 'spec/Verbosing_spec.rb'
282
+ - 'spec/Webservice-Cors_spec.rb'
283
+ - 'spec/Webservice-Endpoint_spec.rb'
284
+ - 'spec/Webservice-File_spec.rb'
285
+ - 'spec/Webservice-Setting_spec.rb'
286
+ #- 'spec/_workspace.rb'
287
+ - 'spec/cmd_business_spec.rb'
288
+ #- 'spec/cmd_common.rb'
289
+ - 'spec/cmd_config_spec.rb'
290
+ - 'spec/cmd_content_spec.rb'
291
+ - 'spec/cmd_cors_spec.rb'
292
+ - 'spec/cmd_device_spec.rb'
293
+ - 'spec/cmd_domain_spec.rb'
294
+ #- 'spec/cmd_exchange_spec.rb'
295
+ #- 'spec/cmd_help_spec.rb'
296
+ - 'spec/cmd_init_spec.rb'
297
+ - 'spec/cmd_keystore_spec.rb'
298
+ - 'spec/cmd_link_spec.rb'
299
+ - 'spec/cmd_password_spec.rb'
300
+ - 'spec/cmd_setting_application_spec.rb'
301
+ - 'spec/cmd_setting_product_spec.rb'
302
+ - 'spec/cmd_status_spec.rb'
303
+ - 'spec/cmd_syncdown_spec.rb'
304
+ - 'spec/cmd_syncup_spec.rb'
305
+ - 'spec/cmd_usage_spec.rb'
306
+ #- 'spec/cmd_version_spec.rb'
245
307
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.17 /coding: utf-8
1
+ # Last Modified: 2017.08.30 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -21,10 +21,13 @@ gem 'json', '~> 2.1.0'
21
21
  gem 'json-schema', '~> 2.7.0'
22
22
  gem 'mime-types', '~> 3.1'
23
23
  gem 'mime-types-data', '~> 3.2016.0521'
24
- gem 'orderedhash', '~> 0.0.6'
24
+ #gem 'orderedhash', '~> 0.0.6'
25
25
  gem 'paint', '~> 2.0.0'
26
+ # 2017-08-04: public_suffix 3.0.0 is for Ruby >= 2.1.
27
+ # It's included by json, so make sure it's the old one.
28
+ gem 'public_suffix', '~> 2.0.5'
26
29
  gem 'rainbow', '~> 2.2.2'
27
- gem 'terminal-table', '~> 1.7.3'
30
+ gem 'terminal-table', '~> 1.8.0'
28
31
  gem 'vine', '~> 0.4'
29
32
  gem 'whirly', '~> 0.2.4'
30
33
 
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.16 /coding: utf-8
1
+ # Last Modified: 2017.08.30 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -16,16 +16,17 @@ Gem::Specification.new do |s|
16
16
  s.license = 'MIT'
17
17
  s.homepage = 'https://github.com/exosite/MuranoCLI'
18
18
  s.summary = 'Do more from the command line with Murano'
19
- s.description = %(Do more from the command line with Murano
19
+ s.description = %(
20
+ Do more from the command line with Murano.
20
21
 
21
- Push and pull data from Murano.
22
- Get status on what things have changed.
23
- See a diff of the changes before you push.
22
+ Push and pull data from Murano.
23
+ Get status on what things have changed.
24
+ See a diff of the changes before you push.
24
25
 
25
- and so much more.
26
+ And so much more.
26
27
 
27
- This gem was formerly known as MrMurano.
28
- )
28
+ (This gem was formerly known as MrMurano.)
29
+ ).strip
29
30
  s.required_ruby_version = '~> 2.0'
30
31
 
31
32
  # FIXME: 2017-05-25: Remove this message eventually.
@@ -61,10 +62,13 @@ explicitly specifying the version. For instance,
61
62
  s.add_runtime_dependency('json-schema', '~> 2.7.0')
62
63
  s.add_runtime_dependency('mime-types', '~> 3.1')
63
64
  s.add_runtime_dependency('mime-types-data', '~> 3.2016.0521')
64
- s.add_runtime_dependency('orderedhash', '~> 0.0.6')
65
+ #s.add_runtime_dependency('orderedhash', '~> 0.0.6')
65
66
  s.add_runtime_dependency('paint', '~> 2.0.0')
67
+ # 2017-08-04: public_suffix 3.0.0 is for Ruby >= 2.1.
68
+ # It's included by json, so make sure it's the old one.
69
+ s.add_runtime_dependency('public_suffix', '~> 2.0.5')
66
70
  s.add_runtime_dependency('rainbow', '~> 2.2.2')
67
- s.add_runtime_dependency('terminal-table', '~> 1.7.3')
71
+ s.add_runtime_dependency('terminal-table', '~> 1.8.0')
68
72
  s.add_runtime_dependency('vine', '~> 0.4')
69
73
  s.add_runtime_dependency('whirly', '~> 0.2.4')
70
74
 
@@ -7,163 +7,308 @@ Version](https://badge.fury.io/rb/MuranoCLI.svg)](https://badge.fury.io/rb/Muran
7
7
 
8
8
  Do more from the command line with [Murano](https://exosite.com/platform/).
9
9
 
10
- MuranoCLI is the command-line tool that interacts with Murano and makes different
11
- tasks easier. MuranoCLI makes it easy to deploy code to a solution, import many
12
- product definitions at once, set up endpoints and APIs, and more.
13
-
14
- MuranoCLI works around the idea of syncing, much like rsync. Files from your project
15
- directory are synced up (or down) from Murano.
16
-
10
+ MuranoCLI interacts with Murano and makes different tasks easier.
11
+
12
+ MuranoCLI makes it easy to deploy code to a project, import
13
+ product definitions, set up endpoints and APIs, and more.
14
+
15
+ MuranoCLI works around the idea of syncing, much like [`rsync`](https://rsync.samba.org/).
16
+ Your project files are synced up (or down) from Murano.
17
+
18
+ ## Contents
19
+
20
+ * [Contents](#contents)
21
+ * [Usage](#usage)
22
+ * [Start a new project easily with init](#start-a-new-project-easily-with-init)
23
+ * [Start a new project manually, step-by-step](#start-a-new-project-manually-step-by-step)
24
+ * [Install](#install)
25
+ * [Gem Install (Linux and macOS)](#gem-install-linux-and-macos)
26
+ * [Working With Different Versions of MuranoCLI](#working-with-different-versions-of-muranocli)
27
+ * [Windows Install](#windows-install)
28
+ * [Features](#features)
29
+ * [Logs](#logs)
30
+ * [CORS](#cors)
31
+ * [Writing Routes (a.k.a. Endpoints)](#writing-routes-aka-endpoints)
32
+ * [Writing Service Event Handlers](#writing-service-event-handlers)
33
+ * [MURANO_CONFIGFILE Environment Variable and Dotenv](#murano_configfile-environment-variable-and-dotenv)
34
+ * [Direct Service Access](#direct-service-access)
35
+ * [Output Format](#output-format)
36
+ * [Product Content Area](#product-content-area)
37
+ * [Developing](#developing)
38
+ * [Testing](#testing)
17
39
 
18
40
  ## Usage
19
41
 
42
+ ### Start a new project easily with `init`
43
+
20
44
  ```
21
45
  mkdir myproject
22
46
  cd myproject
23
47
  murano init
24
48
  ```
25
49
 
26
- Update `myproject.murano` with the info about your project.
50
+ If you want to add information about your project, edit `myproject.murano`.
51
+ You can add a description, the list of authors, a version number, and more.
52
+
53
+ If you are connecting to an existing project
54
+ created with the [web interface](https://www.exosite.io/business/),
55
+ you may need to run `murano link set` to connect the product and the application.
56
+ But if you create a new product and application using MuranoCLI, they will
57
+ automatically be connected.
58
+
59
+ If you are connecting to an existing project, you may want to run
60
+ `murano syncdown` to pull down your project files from Murano.
61
+
62
+ Now do stuff, like add and edit files.
63
+
64
+ To see what files have changed, run `murano status`.
65
+
66
+ To see exactly what changed, try `murano diff`.
67
+
68
+ When you are ready to deploy, run `murano syncup`.
69
+
70
+ ### Start a new project manually, step-by-step
71
+
72
+ If you would like to setup a project without using `murano init`,
73
+ follow these steps.
74
+
75
+ - Find your business ID. Run the command
76
+
77
+ `murano business list`
78
+
79
+ and copy its ID from the list.
80
+
81
+ - If this is the first time you've run `murano`, you will
82
+ need to enter your Murano username and password.
83
+
84
+ (To sign up for a free account, visit [exosite.com](https://exosite.com/signup/).)
85
+
86
+ - If you need to change change accounts, try
87
+
88
+ `murano logout`
89
+
90
+ `murano login`.
91
+
92
+ - To manually change you username and password, run
93
+
94
+ `murano config user.name <USERNAME>`
95
+
96
+ `murano password set <USERNAME>`.
97
+
98
+ - Add the copied Business ID to your project config.
99
+
100
+ `murano config business.id <BUSINESS-ID>`
27
101
 
28
- If this is a new project, you will also need to run `murano assign set` to connect
29
- the product and solution.
102
+ - Create a new Application and save its ID to the project config.
30
103
 
31
- If this is an existing project, you want to run `murano syncdown -V` after
32
- running `murano init`.
104
+ `murano application create myawesomeapplication --save`
33
105
 
34
- Now do stuff, see what changed: `murano status` or `murano diff`.
35
- Then deploy with `murano syncup`
106
+ - Alternatively, choose an existing Application.
36
107
 
37
- ### To start a brand new project the hard way.
38
- There are a few steps and pieces to getting a solution with a product up and
39
- running in Murano. Here is the list.
108
+ `murano config application.id <APPLICATION-ID>`
40
109
 
41
- - Pick a business: `murano business list`
42
- If this is the first time you've run `murano` it will ask for your Murano username
43
- and password.
44
- - Set it: `murano config business.id ZZZZZZZZZ`
45
- - Create a product: `murano product create myawesomeproduct --save`
46
- - Add resource aliases to specs/resources.yaml
47
- - Sync the product definition up: `murano syncup -V --specs`
48
- - Create a solution: `murano solution create myawesomesolution --save`
49
- - Sync solution code up: `murano syncup -V`
50
- - Assign the product to the solution: `murano assign set`
110
+ - Create a new Product and save its ID to the project config.
51
111
 
52
- Do stuff, see what changed: `murano status` or `murano diff`.
53
- Then deploy with `murano syncup`
112
+ `murano product create myawesomeproduct --save`
113
+
114
+ - Alternatively, choose an existing Product.
115
+
116
+ `murano config product.id <PRODUCT-ID>`
117
+
118
+ - Link the Product to the Application.
119
+
120
+ `murano link set`
121
+
122
+ - Build your project.
123
+
124
+ - Edit and create event handlers under `services/`.
125
+
126
+ - Create API endpoints under `routes/`.
127
+
128
+ - Add Lua modules under `modules/`.
129
+
130
+ - Add static files under `files/`.
131
+
132
+ - Add resource aliases to the file, `specs/resources.yaml`.
133
+
134
+ - See what changed.
135
+
136
+ `murano status`
137
+
138
+ or
139
+
140
+ `murano diff`
141
+
142
+ - Deploy your project. Sync up resources, code and files.
143
+
144
+ `murano syncup`
54
145
 
55
146
  ## Install
56
147
 
57
- ### Gem Install (Linux and Macos)
148
+ ### Gem Install (Linux and macOS)
149
+
150
+ The easiest way to install MuranoCLI is using the Gem installer.
58
151
 
59
- When upgrading from a 1.\* version to a 2.0, you should uninstall the old versions
60
- first.
61
152
  ```sh
62
- > gem uninstall MuranoCLI MrMurano
153
+ gem install MuranoCLI
63
154
  ```
64
155
 
65
- And then install:
156
+ - If you are upgrading from a `1.*` version, uninstall the old versions first.
66
157
 
67
158
  ```sh
68
- > gem install MuranoCLI
159
+ gem uninstall MuranoCLI MrMurano
69
160
  ```
70
- Or
161
+
162
+ - If you would like to install a specific version, such as the older,
163
+ pre-Murano CLI tool, you can specify the version to install.
164
+
165
+ ```sh
166
+ gem install MuranoCLI -v 2.2.4
167
+ ```
168
+
169
+ - To update to the latest gem (rather than installing a new gem side by
170
+ side with an older version of the same gem), update it.
171
+
71
172
  ```sh
72
- > gem update MuranoCLI
173
+ gem update MuranoCLI
73
174
  ```
74
175
 
75
- You will likely need to be root for the above commands. If you would rather not
76
- install as root, you can install gems in the user directory.
176
+ You will likely need to be root for the above commands. If you would rather
177
+ not install as root, you can install gems in the user directory.
77
178
 
78
179
  ```sh
79
- > gem install MuranoCLI --user-install
180
+ gem install MuranoCLI --user-install
80
181
  ```
81
182
 
82
- Your `PATH` may need to be updated to find the installed `murano` command. See the
83
- [Ruby Gem FAQ](http://guides.rubygems.org/faqs/#user-install). In short, you need
84
- to add the output of `ruby -rubygems -e 'puts Gem.user_dir'` to your `PATH`.
183
+ Your `PATH` may need to be updated to find the installed `murano` command.
184
+ See the [Ruby Gem FAQ](http://guides.rubygems.org/faqs/#user-install).
185
+
186
+ - In short, you need to add the output of
187
+ `ruby -rubygems -e 'puts Gem.user_dir'` to your `PATH`.
188
+
189
+ E.g., you may want to add this to your `~/.bashrc` file:
190
+
191
+ `export PATH=$PATH:$(ruby -rubygems -e 'puts Gem.user_dir')`
192
+
193
+ #### Working With Different Versions of MuranoCLI
194
+
195
+ The `murano` command line tool is a Ruby gem and, as such, you can install
196
+ different versions of MuranoCLI and choose which one to execute.
197
+
198
+ The following example shows how you can reference a specific version of the
199
+ `murano` gem:
200
+
201
+ ```sh
202
+ $ gem list MuranoCLI --local
203
+
204
+ *** LOCAL GEMS ***
205
+
206
+ MuranoCLI (3.0.1, 2.2.4)
207
+
208
+ $ murano --version
209
+ murano 3.0.1
210
+
211
+ $ murano _2.2.4_ --version
212
+ murano 2.2.4
213
+ ```
214
+
215
+ Note: Not all OSes support multiple versions and will only execute the
216
+ latest Gem installed. In this case, you will need to uninstall newer
217
+ versions of MuranoCLI in order to use older versions.
85
218
 
86
219
  ### Windows Install
87
220
 
88
- The MuranoCLI gem will install on Windows. There is also a single Windows binary
89
- Setup installer available in [releases](https://github.com/exosite/MuranoCLI/releases)
221
+ The MuranoCLI gem will install on Windows.
222
+
223
+ There is also a single Windows binary Setup installer available in
224
+ [releases](https://github.com/exosite/MuranoCLI/releases).
90
225
 
91
226
  If you do not already use Ruby on Windows, then you should use the binary
92
227
  installer.
93
228
 
94
- When upgrading, it is best to run the uninstaller for the old version before
95
- installing the new version.
96
-
229
+ When upgrading, it is best to run the uninstaller for the old version
230
+ before installing the new version.
97
231
 
98
232
  ## Features
99
233
 
100
- ### Project File
101
-
102
234
  ### Logs
103
235
 
104
- You can monitor the log messages from your solution with the `murano logs --follow`.
105
- Or quickly get the last few with `murano logs`
236
+ You can monitor the log messages from your Application by running
237
+ `murano logs application --follow`.
238
+
239
+ Or quickly get the last few logs with simply `murano logs application`.
106
240
 
107
- MuranoCLI does a few things to make your log output easier to follow.
108
- - Adds color to easily see where each log message starts.
109
- - Reformats the timestamps to be in local time.
110
- - Finds JSON blobs and pretty prints them.
241
+ MuranoCLI does a few things to make the log output easier to follow.
111
242
 
112
- All of these can be toggled with command line options.
243
+ - It adds color to easily see where each log message starts.
244
+
245
+ - It reformats the timestamps to be in local time.
246
+
247
+ - It finds JSON blobs and pretty prints them.
248
+
249
+ Each of these options can be disabled with command line options.
113
250
 
114
251
  ### CORS
115
252
 
116
- If you are developing you UI on separate services and you need cross-origin
253
+ If you are developing a UI on separate services and need cross-origin
117
254
  resource sharing, you will need to set the
118
255
  [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) options.
119
256
 
120
- The current CORS options can be fetched with `murano cors`
257
+ The current CORS options can be fetched with `murano cors`.
121
258
 
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`.
259
+ There are three different ways to configure CORS.
124
260
 
125
- Second and third are to put the CORS options in your project file. In the `routes`
126
- section, add a `cors` sub-section with either the name of the file to read, or the
127
- CORS options inline.
261
+ The first and preferred way is to add your CORS options to a file named
262
+ `cors.yaml`.
128
263
 
129
- ```yaml
130
- routes:
131
- cors: my_cors_file.json
132
- ```
133
- OR:
134
- ```yaml
135
- routes:
136
- cors: {"origin": true}
137
- ```
264
+ The second and third options are to put the CORS options in your project file.
138
265
 
139
- Then use `murano cors set` to push these options up to your solution.
266
+ - In the `routes` section, add a `cors` sub-section with either the name of
267
+ the file to read, or the CORS options inline.
140
268
 
141
- ### Writing Routes (or endpoints)
269
+ ```yaml
270
+ routes:
271
+ cors: my_cors_file.json
272
+ ```
142
273
 
143
- All of the routes that you create in your solution are identified by their method
144
- and path. You set this with the following line:
274
+ OR:
275
+
276
+ ```yaml
277
+ routes:
278
+ cors: {"origin": true}
279
+ ```
280
+
281
+ Then use `murano cors set` to push these options up to your application.
282
+
283
+ ### Writing Routes (a.k.a. Endpoints)
284
+
285
+ All of the routes that you create in your application are identified
286
+ by their method and path. You set this with the following line:
145
287
 
146
288
  ```lua
147
289
  --#ENDPOINT METHOD PATH
148
290
  ```
149
291
 
150
- Optionally, you can set what the expected content type is too. (If you don't set
151
- this, the value is `application/json`)
292
+ Optionally, you can set what the expected content type is, too.
293
+ (If you don't set this, it defaults to `application/json`.)
152
294
 
153
295
  ```lua
154
296
  --#ENDPOINT METHOD PATH CONTENT_TYPE
155
297
  ```
156
298
 
157
- An example of a route that puts CSV data:
299
+ Here is an example of a route that puts CSV data:
300
+
158
301
  ```lua
159
302
  --#ENDPOINT PUT /api/upload text/csv
160
303
  ```
161
304
 
162
- After this header line, the script to handle the route follows. Since many routes
163
- end up being a couple of lines or less, you can put multiple routes into a single
164
- file.
305
+ After the magic header, add the script to handle the route.
306
+
307
+ Since many routes end up being a couple of lines or less,
308
+ you can put multiple routes into a single file.
309
+
310
+ A routes file might look like this:
165
311
 
166
- Which looks like this:
167
312
  ```lua
168
313
  --#ENDPOINT GET /api/somedata
169
314
  return Tsdb.query(…)
@@ -177,18 +322,24 @@ return Tsdb.deleteAll()
177
322
 
178
323
  ### Writing Service Event Handlers
179
324
 
180
- All of the event handlers you add to your solution are identified by which service
181
- they are watching and which event in that service triggers the script.
325
+ Each event handler in your project is identified by which service
326
+ it watches and which event in that service triggers the script.
327
+
328
+ This is set with the following magic header line:
182
329
 
183
- This is set with the following line:
184
330
  ```lua
185
331
  --#EVENT SERVICE EVENT
186
332
  ```
187
333
 
188
- For example, the event handler that processes all data coming from your devices
189
- could be:
334
+ To make working with the Product ID easier, you can use the magic
335
+ variable `{product.id}` instead of the actual Product ID.
336
+ You can use this variable in both the filename and the magic header.
337
+
338
+ For example, the event handler that processes all data coming from your
339
+ devices might look like:
340
+
190
341
  ```lua
191
- --#EVENT device datapoint
342
+ --#EVENT {product.id} event
192
343
  local stamped = nil
193
344
  if data.api == "record" then
194
345
  stamped = tostring(data.value[1]) .. 's'
@@ -200,31 +351,40 @@ Tsdb.write{
200
351
  }
201
352
  ```
202
353
 
203
- ### MURANO_CONFIGFILE environment and Dotenv
354
+ ### MURANO_CONFIGFILE Environment Variable and Dotenv
355
+
356
+ The environment variable `MURANO_CONFIGFILE` is checked for an additional config
357
+ to load. This, in conjunction with [dotenv](https://github.com/bkeepers/dotenv)
358
+ support, allows you to easily switch between development, staging, and production
359
+ setups.
204
360
 
205
- The environment variable `MURANO_CONFIGFILE` is checked for an additional config to
206
- load. This, in conjunction with [dotenv](https://github.com/bkeepers/dotenv) support,
207
- allows for easily switching between development, staging, and production setups.
361
+ To use this, write the three Application IDs and three Product IDs for your three
362
+ deployments into the three files, `.murano.dev`, `.murano.stg`, and `.murano.prod`.
208
363
 
209
- To use this, write the three solution ids into `.murano.dev`, `.murano.stg`,
210
- and `.murano.prod`. Then write the `.env` file to point at the system you're
211
- currently working on.
364
+ Then, write the `.env` file to point at the system you're currently working on.
212
365
 
213
366
  The files for this are then:
367
+
214
368
  ```sh
215
369
  cat >> .murano.dev <<EOF
216
- [solution]
370
+ [application]
217
371
  id=AAAAAAAA
372
+ [product]
373
+ id=BBBBBBBB
218
374
  EOF
219
375
 
220
376
  cat >> .murano.stg <<EOF
221
- [solution]
222
- id=BBBBBBBB
377
+ [application]
378
+ id=LLLLLLLL
379
+ [product]
380
+ id=MMMMMMMM
223
381
  EOF
224
382
 
225
383
  cat >> .murano.prod <<EOF
226
- [solution]
227
- id=CCCCCCCC
384
+ [application]
385
+ id=XXXXXXXX
386
+ [product]
387
+ id=YYYYYYYY
228
388
  EOF
229
389
 
230
390
  cat > .env <<EOF
@@ -232,23 +392,25 @@ MURANO_CONFIGFILE=.murano.dev
232
392
  EOF
233
393
  ```
234
394
 
235
- This also allows for keeping private things in a separate config file and having
236
- the shared things checked into source control.
395
+ This also allows for keeping private things in a separate config file and
396
+ having the shared things checked into source control.
237
397
 
238
398
  ### Direct Service Access
239
399
 
240
- To aid with debugging, MuranoCLI has direct access to some of the services in a
241
- solution.
400
+ To aid with debugging, MuranoCLI has direct access to some of the services
401
+ in an application.
242
402
 
243
403
  Currently these are:
404
+
244
405
  - Keystore: `murano keystore`
406
+
245
407
  - TSDB: `murano tsdb`
246
408
 
247
409
  ### Output Format
248
410
 
249
- Many sub-commands respect the `outformat` setting. This lets you switch the output
250
- between YAML, JSON, Ruby, CSV, and pretty tables. Not all formats work with all
251
- commands.
411
+ Many sub-commands respect the `outformat` setting. This lets you switch the
412
+ output between YAML, JSON, Ruby, CSV, and pretty tables. (Not all formats
413
+ work with all commands, however.)
252
414
 
253
415
  ```
254
416
  > murano tsdb product list
@@ -260,13 +422,14 @@ commands.
260
422
 
261
423
  ### Product Content Area
262
424
 
263
- MuranoCLI can manage the content area for a product. This area is a place to store
264
- files for use by devices. Typically holding firmware images for Over-The-Air
265
- updating. Although any kind of fleet wide data that devices may need to download
266
- can be stored here.
425
+ MuranoCLI can manage the content area for a product. This area is a place to
426
+ store files for use by devices. Storing firmware images for over-the-air
427
+ updates is one typical use, although any kind of fleet-wide data that devices
428
+ may need to download can be stored here.
429
+
430
+ Once the `product.id` is set, the content for that product can be accessed
431
+ with the following commands:
267
432
 
268
- Once the `product.id` is set, the content for that product can be accessed with the
269
- following commands:
270
433
  ```
271
434
  > murano content list
272
435
  > murano content upload
@@ -275,7 +438,7 @@ following commands:
275
438
  > murano content download
276
439
  ```
277
440
 
278
- Call them with `--help` for details.
441
+ Call `murano` with `--help` for more details.
279
442
 
280
443
  ## Developing
281
444
 
@@ -284,20 +447,30 @@ MuranoCLI uses [git flow](https://github.com/nvie/gitflow#getting-started) for
284
447
 
285
448
  MuranoCLI also uses [bundler](http://bundler.io).
286
449
 
287
- When submitting pull requests, please do them against the develop branch.
450
+ When submitting pull requests, please do them against the `develop` branch.
451
+
452
+ ### Testing
288
453
 
289
- ### Tests
290
454
  All test for MuranoCLI are done with rspec.
291
455
 
292
- The tests are internal (`--tag ~cmd`) or command (`--tag cmd`). The internal tests
293
- are for the objects that build up the internals. The command tests run `murano` from
294
- the shell and are for testing the user facing components. A subset of the command
295
- tests work with the live Murano servers (`--tag needs_password`).
456
+ The tests are internal (`--tag ~cmd`) or command (`--tag cmd`).
457
+
458
+ - The internal tests are for the objects that build up the internals.
459
+
460
+ - The command tests run `murano` from the shell and are for testing
461
+ the user facing components.
462
+
463
+ A subset of the command tests work with the live Murano servers
464
+ (`--tag needs_password`).
296
465
 
297
466
  To use the live tests, the following environment variables need to be set:
298
- - `MURANO_CONFIGFILE` : A Config with the user.name, business.id, and net.host for
299
- the integration tests.
300
- - `MURANO_PASSWORD` : Password for the user.name above.
301
467
 
302
- A free account on Murano is sufficient for these tests.
468
+ - `MURANO_CONFIGFILE`:
469
+ A Config with the user.name, business.id, and net.host for the integration tests.
470
+
471
+ - `MURANO_PASSWORD`:
472
+ Password for the user.name above.
473
+
474
+ A free account on [Murano](https://exosite.com/signup/) is sufficient for
475
+ these tests.
303
476