MuranoCLI 3.2.1.pre.beta.6 → 3.2.1.pre.beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +10 -0
  3. data/MuranoCLI.gemspec +37 -6
  4. data/Rakefile +38 -11
  5. data/lib/MrMurano/commands/business.rb +0 -4
  6. data/lib/MrMurano/version.rb +1 -1
  7. metadata +2 -251
  8. data/dockers/Dockerfile.2.2.9 +0 -40
  9. data/dockers/Dockerfile.2.3.6 +0 -40
  10. data/dockers/Dockerfile.2.4.3 +0 -40
  11. data/dockers/Dockerfile.2.5.0 +0 -40
  12. data/dockers/Dockerfile.GemRelease +0 -49
  13. data/dockers/Dockerfile.m4 +0 -122
  14. data/dockers/README.rst +0 -362
  15. data/dockers/RELEASE.rst +0 -135
  16. data/dockers/docker-test.sh +0 -163
  17. data/dockers/gem-release.sh +0 -4
  18. data/docs/basic_example.rst +0 -436
  19. data/docs/ci/.trustme.plugin +0 -140
  20. data/docs/ci/.trustme.sh +0 -516
  21. data/docs/ci/.trustme.vim +0 -55
  22. data/docs/completions/murano_completion-bash +0 -4484
  23. data/docs/demo.md +0 -109
  24. data/docs/develop.rst +0 -392
  25. data/docs/release.rst +0 -295
  26. data/spec/Account-Passwords_spec.rb +0 -245
  27. data/spec/Account_spec.rb +0 -256
  28. data/spec/Business_spec.rb +0 -307
  29. data/spec/ConfigFile_spec.rb +0 -55
  30. data/spec/ConfigMigrate_spec.rb +0 -108
  31. data/spec/Config_spec.rb +0 -440
  32. data/spec/Content_spec.rb +0 -422
  33. data/spec/GatewayBase_spec.rb +0 -65
  34. data/spec/GatewayDevice_spec.rb +0 -403
  35. data/spec/GatewayResource_spec.rb +0 -283
  36. data/spec/GatewaySettings_spec.rb +0 -130
  37. data/spec/HttpAuthed_spec.rb +0 -87
  38. data/spec/Http_spec.rb +0 -220
  39. data/spec/MakePretties_spec.rb +0 -127
  40. data/spec/Mock_spec.rb +0 -62
  41. data/spec/ProjectFile_spec.rb +0 -381
  42. data/spec/Setting_spec.rb +0 -120
  43. data/spec/Solution-ServiceConfig_spec.rb +0 -272
  44. data/spec/Solution-ServiceEventHandler_spec.rb +0 -442
  45. data/spec/Solution-ServiceModules_spec.rb +0 -562
  46. data/spec/Solution-UsersRoles_spec.rb +0 -269
  47. data/spec/Solution_spec.rb +0 -140
  48. data/spec/SyncRoot_spec.rb +0 -111
  49. data/spec/SyncUpDown_spec.rb +0 -868
  50. data/spec/Verbosing_spec.rb +0 -332
  51. data/spec/Webservice-Cors_spec.rb +0 -225
  52. data/spec/Webservice-Endpoint_spec.rb +0 -650
  53. data/spec/Webservice-File_spec.rb +0 -282
  54. data/spec/Webservice-Setting_spec.rb +0 -105
  55. data/spec/_workspace.rb +0 -43
  56. data/spec/cmd_business_spec.rb +0 -64
  57. data/spec/cmd_common.rb +0 -507
  58. data/spec/cmd_config_spec.rb +0 -73
  59. data/spec/cmd_content_spec.rb +0 -109
  60. data/spec/cmd_cors_spec.rb +0 -54
  61. data/spec/cmd_device_spec.rb +0 -130
  62. data/spec/cmd_domain_spec.rb +0 -62
  63. data/spec/cmd_element_spec.rb +0 -401
  64. data/spec/cmd_exchange_spec.rb +0 -114
  65. data/spec/cmd_help_spec.rb +0 -72
  66. data/spec/cmd_init_spec.rb +0 -475
  67. data/spec/cmd_keystore_spec.rb +0 -97
  68. data/spec/cmd_link_spec.rb +0 -105
  69. data/spec/cmd_logs_spec.rb +0 -162
  70. data/spec/cmd_password_spec.rb +0 -64
  71. data/spec/cmd_setting_application_spec.rb +0 -300
  72. data/spec/cmd_setting_product_spec.rb +0 -246
  73. data/spec/cmd_status_spec.rb +0 -300
  74. data/spec/cmd_syncdown_application_spec.rb +0 -128
  75. data/spec/cmd_syncdown_both_spec.rb +0 -178
  76. data/spec/cmd_syncdown_unit_spec.rb +0 -861
  77. data/spec/cmd_syncup_spec.rb +0 -148
  78. data/spec/cmd_token_spec.rb +0 -53
  79. data/spec/cmd_usage_spec.rb +0 -79
  80. data/spec/dry_run_formatter.rb +0 -28
  81. data/spec/fixtures/.mrmuranorc +0 -9
  82. data/spec/fixtures/ProjectFiles/invalid.yaml +0 -9
  83. data/spec/fixtures/ProjectFiles/only_meta.yaml +0 -24
  84. data/spec/fixtures/ProjectFiles/with_routes.yaml +0 -27
  85. data/spec/fixtures/SolutionFiles/0.2.0.json +0 -20
  86. data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +0 -18
  87. data/spec/fixtures/SolutionFiles/0.2.json +0 -21
  88. data/spec/fixtures/SolutionFiles/0.3.0.json +0 -20
  89. data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +0 -19
  90. data/spec/fixtures/SolutionFiles/0.3.json +0 -20
  91. data/spec/fixtures/SolutionFiles/basic.json +0 -20
  92. data/spec/fixtures/SolutionFiles/secret.json +0 -6
  93. data/spec/fixtures/configfile +0 -9
  94. data/spec/fixtures/dumped_config +0 -57
  95. data/spec/fixtures/exchange_element/element-show.json +0 -1
  96. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +0 -282
  97. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +0 -588
  98. data/spec/fixtures/gateway_resource_files/resources.notyaml +0 -12
  99. data/spec/fixtures/gateway_resource_files/resources.yaml +0 -13
  100. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +0 -13
  101. data/spec/fixtures/mrmuranorc_deleted_bob +0 -6
  102. data/spec/fixtures/mrmuranorc_tool_bob +0 -3
  103. data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +0 -116
  104. data/spec/fixtures/product_spec_files/example.murano.spec.yaml +0 -14
  105. data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +0 -21
  106. data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +0 -16
  107. data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +0 -11
  108. data/spec/fixtures/product_spec_files/lightbulb.yaml +0 -21
  109. data/spec/fixtures/roles-three.yaml +0 -11
  110. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +0 -98
  111. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +0 -98
  112. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +0 -98
  113. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +0 -98
  114. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +0 -72
  115. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +0 -98
  116. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +0 -98
  117. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +0 -98
  118. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +0 -98
  119. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +0 -98
  120. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +0 -98
  121. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +0 -98
  122. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +0 -98
  123. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +0 -98
  124. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +0 -72
  125. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +0 -72
  126. data/spec/fixtures/snapshots/murano business list as json.webmock +0 -27
  127. data/spec/fixtures/snapshots/murano business list as table.webmock +0 -27
  128. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +0 -27
  129. data/spec/fixtures/snapshots/murano business list only ids.webmock +0 -27
  130. data/spec/fixtures/snapshots/murano business list output to file.webmock +0 -27
  131. data/spec/fixtures/snapshots/murano business without project help.webmock +0 -9
  132. data/spec/fixtures/snapshots/murano config Needs a key.webmock +0 -9
  133. data/spec/fixtures/snapshots/murano config Reads a key.webmock +0 -9
  134. data/spec/fixtures/snapshots/murano config Removes a key.webmock +0 -9
  135. data/spec/fixtures/snapshots/murano config Sets a key.webmock +0 -9
  136. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +0 -9
  137. data/spec/fixtures/snapshots/murano content life cycle.webmock +0 -144
  138. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +0 -78
  139. data/spec/fixtures/snapshots/murano cors show CORS.webmock +0 -64
  140. data/spec/fixtures/snapshots/murano device activates.webmock +0 -86
  141. data/spec/fixtures/snapshots/murano device enables a batch.webmock +0 -76
  142. data/spec/fixtures/snapshots/murano device enables and lists.webmock +0 -78
  143. data/spec/fixtures/snapshots/murano device writes and reads.webmock +0 -136
  144. data/spec/fixtures/snapshots/murano domain show domain.webmock +0 -101
  145. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +0 -43
  146. data/spec/fixtures/snapshots/murano element show --help.webmock +0 -9
  147. data/spec/fixtures/snapshots/murano element show as csv.webmock +0 -43
  148. data/spec/fixtures/snapshots/murano element show as default-table.webmock +0 -43
  149. data/spec/fixtures/snapshots/murano element show as json.webmock +0 -43
  150. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +0 -43
  151. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +0 -43
  152. data/spec/fixtures/snapshots/murano element show as yaml.webmock +0 -43
  153. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +0 -43
  154. data/spec/fixtures/snapshots/murano element without project usage.webmock +0 -9
  155. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +0 -59
  156. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +0 -59
  157. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +0 -59
  158. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +0 -59
  159. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +0 -59
  160. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +0 -83
  161. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +0 -59
  162. data/spec/fixtures/snapshots/murano exchange without project help.webmock +0 -9
  163. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +0 -9
  164. data/spec/fixtures/snapshots/murano help using commander no args.webmock +0 -9
  165. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +0 -9
  166. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +0 -9
  167. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +0 -9
  168. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +0 -201
  169. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +0 -193
  170. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +0 -213
  171. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +0 -213
  172. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +0 -213
  173. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +0 -213
  174. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +0 -108
  175. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +0 -124
  176. data/spec/fixtures/snapshots/murano keystore deletes.webmock +0 -112
  177. data/spec/fixtures/snapshots/murano keystore gets.webmock +0 -96
  178. data/spec/fixtures/snapshots/murano keystore infos.webmock +0 -96
  179. data/spec/fixtures/snapshots/murano keystore lists.webmock +0 -96
  180. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +0 -149
  181. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +0 -165
  182. data/spec/fixtures/snapshots/murano link without project help.webmock +0 -9
  183. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +0 -27
  184. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +0 -27
  185. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +0 -9
  186. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +0 -9
  187. data/spec/fixtures/snapshots/murano password deletes a password.webmock +0 -9
  188. data/spec/fixtures/snapshots/murano password sets a password.webmock +0 -9
  189. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +0 -90
  190. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +0 -90
  191. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +0 -64
  192. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +0 -90
  193. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +0 -90
  194. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +0 -90
  195. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +0 -90
  196. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +0 -90
  197. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +0 -322
  198. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +0 -153
  199. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +0 -153
  200. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +0 -153
  201. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +0 -153
  202. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +0 -153
  203. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +0 -153
  204. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +0 -151
  205. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +0 -479
  206. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +0 -357
  207. data/spec/fixtures/snapshots/murano token with project list as table.webmock +0 -9
  208. data/spec/fixtures/snapshots/murano token without project help.webmock +0 -9
  209. data/spec/fixtures/snapshots/murano usage show usage.webmock +0 -93
  210. data/spec/fixtures/syncable_conflict/services/devdata.lua +0 -18
  211. data/spec/fixtures/syncable_conflict/services/timers.lua +0 -4
  212. data/spec/fixtures/syncable_content/assets/icon.png +0 -0
  213. data/spec/fixtures/syncable_content/assets/index.html +0 -0
  214. data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
  215. data/spec/fixtures/syncable_content/modules/table_util.lua +0 -58
  216. data/spec/fixtures/syncable_content/routes/manyRoutes.lua +0 -11
  217. data/spec/fixtures/syncable_content/routes/singleRoute.lua +0 -5
  218. data/spec/fixtures/websocket/README.rst +0 -110
  219. data/spec/fixtures/websocket/logs_blather.rb +0 -27
  220. data/spec/fixtures/websocket/logs_faker.rb +0 -153
  221. data/spec/fixtures/websocket/simple_connection.rb +0 -45
  222. data/spec/fixtures/websocket/simple_options.rb +0 -77
  223. data/spec/fixtures/websocket/simple_server.rb +0 -69
  224. data/spec/fixtures/websocket/wss-echo.rb +0 -48
  225. data/spec/fixtures/websocket/wss-fake-logs.rb +0 -20
  226. data/spec/spec_helper.rb +0 -131
  227. data/spec/variegated_TruthyFalsey_spec.rb +0 -29
  228. data/spec/webmock_snapshot.rb +0 -296
@@ -1,140 +0,0 @@
1
- #!/bin/bash
2
- # vim:tw=0:ts=2:sw=2:et:norl:spell:ft=sh
3
-
4
- assign_globals() {
5
- assign_globals_
6
- }
7
-
8
- init_it() {
9
- init_it_
10
-
11
- if [[ -f ${HOME}/.fries/lib/ruby_util.sh ]]; then
12
- source ${HOME}/.fries/lib/ruby_util.sh
13
- else
14
- say 'Missing ruby_util.sh and chruby'
15
- exit 1
16
- fi
17
- # FIXME/2017-12-01: Make this more flexible? Allow many versions??
18
- # Redirect "Monkey patching!" output.
19
- chruby 2.3.3 &> /dev/null
20
- }
21
-
22
- lang_it() {
23
- lang_it_
24
- }
25
-
26
- build_it() {
27
- build_it_
28
-
29
- say "- cwd : $(pwd)"
30
- say "- ruby -v : $(ruby -v)"
31
- say "- rubocop -v : $(rubocop -v)"
32
- #say "- cmd rubocop: $(command -v rubocop)"
33
- say
34
-
35
- local projpath="/exo/clients/exosite/MuranoCLIs"
36
- rake build &>> ${OUT_FILE} && \
37
- gem install -i $(ruby -rubygems -e 'puts Gem.dir') \
38
- pkg/MuranoCLI-$(\
39
- ruby -e "
40
- require \"${projpath}/active+MuranoCLI/lib/MrMurano/version.rb\";
41
- puts MrMurano::VERSION
42
- "
43
- ).gem \
44
- &>> ${OUT_FILE} 2>&1 &
45
- wait_maybe_fail
46
- #alert_success_toast 'Murano CLI says, "Woot woot!!"' 'Wheeee!' 666
47
- alert_success_flash
48
-
49
- say '' true
50
- }
51
-
52
- lint_it() {
53
- lint_it_
54
-
55
- rubocop -D -c .rubocop.yml &>> ${OUT_FILE}
56
-
57
- say '' true
58
- }
59
-
60
- test_it() {
61
- test_it_
62
- # 2017-10-02: (lb): Testing takes too long (20 minutes!), and saving often
63
- # just means constant churn, so skip tests.
64
- return
65
-
66
- rake rspec &>> ${OUT_FILE}
67
-
68
- say '' true
69
- }
70
-
71
- ctags_it() {
72
- ctags_it_
73
-
74
- local ctags_out=$( { \
75
- ctags -R \
76
- --exclude=coverage \
77
- --exclude=docs \
78
- --exclude=pkg \
79
- --exclude=report \
80
- --verbose=yes \
81
- ; \
82
- } 2>&1 )
83
- if [[ $? -ne 0 ]]; then
84
- say
85
- say 'ctags FAILED!'
86
- say '                    '
87
- say
88
- say "${ctags_out}"
89
- say
90
- say '                    '
91
- say
92
- fi
93
- /bin/ls -la tags >> "${OUT_FILE}"
94
-
95
- say '' true
96
- }
97
-
98
- wait_maybe_fail_pre_exit() {
99
- if ``command -v notify-send >/dev/null 2>&1``; then
100
- # 2018-03-12 13:23: Whatever, I cannot test this, why is it so hard to
101
- # make the build fail??
102
- notify-send \
103
- -u critical \
104
- -i "${HOME}/.waffle/home/Pictures/Landonb-Bitmoji-Game.Over.png" \
105
- 'Murano CLI Build Failed!' \
106
- "Error: ${wait_for_what}"
107
- fi
108
- }
109
-
110
- wait_maybe_fail_success() {
111
- if ``command -v notify-send >/dev/null 2>&1``; then
112
- #notify-send -i face-wink -t 1234 \
113
- # 'Build Success!' 'Murano CLI says, "Woot woot!!"'
114
- # 2018-03-19: 1234 msec. is a tad too long. Something quicker,
115
- # so I can train myself to ignore if it's a blip in the corner of my eye.
116
- # Just make sure your mouse into over popup, or it won't go away!
117
- # Hahaha, at 333 msec. it's basically a flash on the screen...
118
- # in that case, there's probably a better way to implement this!
119
- notify-send \
120
- -t 333 \
121
- -u normal \
122
- -i '/home/landonb/.waffle/home/Pictures/Landonb-Bitmoji-Thumbs.Up.png' \
123
- 'Build Success!' \
124
- 'Murano CLI says, "Woot woot!!"'
125
- fi
126
- }
127
- wait_maybe_fail_success() {
128
- # 2018-03-19 18:04: This just gets better!
129
- # sudo apt-get install xcalib
130
- ##xcalib -invert -alter
131
- #xcalib -alter -invert
132
- # xcalib, because of X, only works on the first monitor!
133
- # 2018-04-12: But I found a solution that works on all!!
134
- /srv/opt/bin/xrandr-invert-colors.bin
135
- sleep 0.075
136
- ##xcalib -invert -alter
137
- #xcalib -alter -invert
138
- /srv/opt/bin/xrandr-invert-colors.bin
139
- }
140
-
data/docs/ci/.trustme.sh DELETED
@@ -1,516 +0,0 @@
1
- #!/bin/bash
2
- # vim:tw=0:ts=2:sw=2:et:norl:spell
3
-
4
- # WHAT: A Continuous Integration (CI) script that's async-safe.
5
-
6
- # USAGE: If you have Vim, check out the Dubsacks Vim plugin:
7
- #
8
- # https://github.com/landonb/dubs_edit_juice
9
- #
10
- # which automatically looks for a .trustme.vim above
11
- # any file you load into a buffer.
12
- #
13
- # You can install the plugin or just copy the BufEnter
14
- # autocmd that loads for the .trustme.vim file, from:
15
- #
16
- # plugin/dubs_edit_juice.vim
17
- #
18
- # To wire it yourself instead, check out inotifywait:
19
- #
20
- # https://linux.die.net/man/1/inotifywait
21
- #
22
- # Ubuntu users can install from Aptitude
23
- #
24
- # apt-get install inotify-tools
25
- #
26
- # and then watch files from a shell script, e.g.,
27
- #
28
- # inotifywait \
29
- # -mr \
30
- # --timefmt '%d/%m/%y %H:%M' \
31
- # --format '%T %w %f %e' \
32
- # -e close_write /path/to/project \
33
- # | while read date time dir file events; do
34
- # /path/to/project/.trustme.sh
35
- # done
36
- #
37
- # NOTE: On Vim, if you're using the project.vim plugin, you'll need
38
- # to add a reference to the script from the directory entry.
39
- # Otherwise, when you double-click files in the project window
40
- # to open them, the BufEnter event doesn't trigger properly.
41
- # E.g.,
42
- #
43
- # MY_PROJ=/path/to/proj in=".trustme.vim" filter=".* *" {
44
- # # ...
45
- # }
46
- #
47
- # WATCH: All script output gets writ to a file. Use a terminal to tail it:
48
- #
49
- # tail -F .trustme.log
50
- #
51
- # TEST: From one terminal:
52
- #
53
- # tail -F .trustme.log
54
- #
55
- # From another terminal:
56
- #
57
- # TRUSTME_VERBOSE=true DUBS_TRUST_ME_ON_SAVE=1 ./.trustme.sh
58
-
59
- source_plugin() {
60
- # This script is run relative to Vim's working directory,
61
- # so be deliberate about paths.
62
- # ${BASH_SOURCE[0]} should be the absolute path to this script.
63
- # If you add libraries to the trust_me source, source it:
64
- # TRUSTME_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
65
- # source "${TRUSTME_DIR}/file"
66
- PROJECT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
67
- DOTFILENAME=${TRUSTME_BASENAME:-.trustme}
68
-
69
- source_home_fries_util 'color_util.sh'
70
- source_home_fries_util 'logger.sh'
71
-
72
- PROJ_PLUGIN="${PROJECT_DIR}/${DOTFILENAME}.plugin"
73
- if [[ ! -f "${PROJ_PLUGIN}" ]]; then
74
- say "No project plugin! Nothing to do. Hint: Create and edit: ${PROJ_PLUGIN}"
75
- exit 1
76
- fi
77
- source "${PROJ_PLUGIN}"
78
- }
79
-
80
- source_home_fries_util() {
81
- local home_fries_util="$1"
82
- local source_path="${home_fries_util}"
83
- # If the /user/home/.fries/lib path is on $PATH, you can just source it.
84
- if ! source "${source_path}" &> /dev/null; then
85
- # But if it's not on $PATH, see if this script is a symlink, and if so,
86
- # see if the util file is part of this file's owning repo.
87
- if [[ -h "${BASH_SOURCE[0]}" ]]; then
88
- source_path="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/${home_fries_util}"
89
- fi
90
- if ! source "${source_path}" &> /dev/null; then
91
- >&2 echo "Unable to find and source ${home_fries_util}. You're missing out!"
92
- fi
93
- fi
94
- }
95
-
96
- # ***
97
-
98
- assign_globals_() {
99
- OUT_FILE="${PROJECT_DIR}/${DOTFILENAME}.log"
100
-
101
- LOCK_DIR="${PROJECT_DIR}/${DOTFILENAME}.lock"
102
- KILL_DIR="${PROJECT_DIR}/${DOTFILENAME}.kill"
103
- PID_FILE="${PROJECT_DIR}/${DOTFILENAME}.pid"
104
- # Hrm. The bang might not work without
105
- KILL_BIN="${PROJECT_DIR}/${DOTFILENAME}.kill!"
106
-
107
- # DEVS: You may want to set this, e.g., to 1, or to 300, depending on
108
- # how heavy your CI is. If it's a lot of CPU, set a longer delay.
109
- BUILD_DELAY_SECS=${TRUSTME_DELAYSECS:-0}
110
-
111
- # FIXME: Add an --arg parser, and add a --verbose/-V flag.
112
- TRUSTME_VERBOSE=${TRUSTME_VERBOSE:-false}
113
- }
114
-
115
- assign_globals() {
116
- assign_globals_
117
- }
118
-
119
- # ***
120
-
121
- say() {
122
- FORCE_ECHO=${2:-false}
123
- # Restrict newlines to no more than 2 in a row.
124
- TRUSTME_SAID_NEWLINE=${TRUSTME_SAID_NEWLINE:-false}
125
- if ${FORCE_ECHO} || ! ${TRUSTME_SAID_NEWLINE} || [[ ("$1" != "") ]]; then
126
- # Use -e so colors are included.
127
- echo -e "$1" >> "${OUT_FILE}"
128
- fi
129
- if [[ "$1" != "" ]]; then
130
- TRUSTME_SAID_NEWLINE=false
131
- else
132
- TRUSTME_SAID_NEWLINE=true
133
- fi
134
- }
135
-
136
- verbose() {
137
- ${TRUSTME_VERBOSE} && say "$@"
138
- }
139
-
140
- announcement() {
141
- local slugline="$2"
142
- local bordelimiter="${3-#}"
143
- local hlit="${4-${FG_REG}${BG_MAROON}}"
144
- #local hlit="${4-${FG_REG}${BG_MAROON}${FONT_LINE}}"
145
- say
146
- local bord=$(repeat_char ${bordelimiter} 67)
147
- local norm="${FONT_NORM}"
148
- say "${hlit}${bord}${norm}"
149
- say "$1"
150
- say "${hlit}${bord}${norm}"
151
- [[ "${slugline}" != '' ]] && say "${slugline}"
152
- say
153
- }
154
-
155
- verbose_announcement() {
156
- ${TRUSTME_VERBOSE} && announcement "$@"
157
- }
158
-
159
- repeat_char() {
160
- [[ -z $1 ]] && >&2 echo 'repeat_char: expecting 1st arg: character to repeat' && return 1
161
- [[ -z $2 ]] && >&2 echo 'repeat_char: expecting 2nd arg: num. of repetitions' && return 1
162
- # Bash expands {1..n} so the command becomes:
163
- # printf '=%.0s' 1 2 3 4 ... 100
164
- # Where printf's format is =%.0s which means that it will always
165
- # print a single '=' no matter what argument it is given.
166
- printf "$1"'%.s' $(eval "echo {1.."$(($2))"}")
167
- }
168
-
169
- # ***
170
-
171
- death() {
172
- if [[ -n ${WAIT_PID} ]]; then
173
- say "Sub-killing ‘${WAIT_PID}’"
174
- kill -s 9 ${WAIT_PID}
175
- fi
176
- # The other script waits for us to cleanup the PID file.
177
- remove_pid_files
178
- # Note that output gets interleaved with the killing process,
179
- # so keep this to one line (don't use `announcement`).
180
- say "☠☠☠ DEATH! ☠☠☠ ‘$$’ is now dead"
181
- exit 1
182
- }
183
-
184
- lock_kill_die() {
185
- say "Desperately Seeking Lock on $(date)..."
186
- [[ "$1" == true ]] && local AFTER_WAIT=true || local AFTER_WAIT=false
187
- local build_it=false
188
- # mkdir is atomic. Isn't that nice.
189
- if $(mkdir "${LOCK_DIR}" 2> /dev/null); then
190
- say "- Scored the lock!"
191
- say
192
- kill_other ${AFTER_WAIT} true
193
- elif [[ -d "${LOCK_DIR}" ]]; then
194
- if ! ${AFTER_WAIT}; then
195
- # There's another script waiting to build, or a build going on.
196
- # Kill it if you can.
197
- say "Could not lock, but can still kill!"
198
- kill_other ${AFTER_WAIT} false
199
- else
200
- # This script got the lock earlier, released it, and slept, and now
201
- # it cannot get the lock...
202
- say "i waited for you but you locked me out"
203
- exit
204
- fi
205
- else
206
- announcement "WARNING: could not mkdir ‘${LOCK_DIR}’ and it does not exist, later!"
207
- exit
208
- fi
209
- }
210
-
211
- kill_other() {
212
- [[ "$1" == true ]] && local AFTER_WAIT=true || local AFTER_WAIT=false
213
- [[ "$2" == true ]] && local OUR_LOCK=true || local OUR_LOCK=false
214
- if $(mkdir "${KILL_DIR}" 2> /dev/null); then
215
- if [[ -f "${PID_FILE}" ]]; then
216
- local build_pid=$(cat "${PID_FILE}")
217
- if ${AFTER_WAIT}; then
218
- if [[ "$$" != "${build_pid}" ]]; then
219
- echo "Panic, jerks! The build_pid is not our PID! ${build_pid} != $$"
220
- exit
221
- fi
222
- elif [[ "${build_pid}" != '' ]]; then
223
- #say "Locked the kill directory! time for mischiefs"
224
- say "Killing ‘${build_pid}’"
225
- # Process, your time has come.
226
- kill -s SIGUSR1 "${build_pid}" &>> "${OUT_FILE}"
227
- if [[ $? -ne 0 ]]; then
228
- say "Kill failed! On PID ‘${build_pid}’"
229
- # So, what happened? Did the build complete?
230
- # Should we just move along? Probably...
231
- # Get the name of the process. If it still exists, die.
232
- if [[ $(ps -p "${build_pid}" -o comm=) != '' ]]; then
233
- say "Said process still exists!"
234
- exit
235
- fi
236
- # The process is a ghost.
237
- remove_pid_files
238
- else
239
- # Wait for the other trustme to clean up.
240
- WAIT_PATIENCE=10
241
- sleep 0.1
242
- while [[ -f "${PID_FILE}" ]]; do
243
- say "Waiting on PID ${build_pid} to cleanup..."
244
- sleep 0.5
245
- WAIT_PATIENCE=$((WAIT_PATIENCE - 1))
246
- [[ ${WAIT_PATIENCE} -eq 0 ]] && echo "Done waiting!" && exit
247
- done
248
- fi
249
- else
250
- say "WARNING: Empty PID file? Whatever, we'll take it!"
251
- fi
252
- elif ! ${OUR_LOCK}; then
253
- # This is after waiting, which seems weird, eh.
254
- say "Kill okay without build lock, but no PID file. Is someone tinkering?"
255
- exit
256
- else
257
- say "Got the build lock and kill lock, and there's no PID. Fresh powder!"
258
- fi
259
- else
260
- say "Someone else has the kill lock. We're boned!"
261
- exit
262
- fi
263
- }
264
-
265
- lock_or_die() {
266
- lock_kill_die false
267
- }
268
-
269
- lock_kill_or_die() {
270
- lock_kill_die true
271
- }
272
-
273
- # ***
274
-
275
- wait_maybe_fail_pre_exit() {
276
- : # no-op
277
- }
278
-
279
- wait_maybe_fail_success() {
280
- : # no-op
281
- }
282
-
283
- wait_maybe_fail() {
284
- WAIT_PID=$!
285
- wait ${WAIT_PID}
286
- local wait_for_what=$?
287
- if [[ ${wait_for_what} -ne 0 ]]; then
288
- say "ERROR: See previous error: we sniffed a ${wait_for_what}!"
289
- wait_maybe_fail_pre_exit
290
- exit ${wait_for_what}
291
- fi
292
- wait_maybe_fail_success
293
- WAIT_PID=
294
- }
295
-
296
- # ***
297
-
298
- alert_success_toast() {
299
- local message
300
- local title
301
- local timeout
302
- message="${1:-Yay!}"
303
- title="${2:-Build Success!}"
304
- timeout=${3:-2123}
305
- if ``command -v notify-send >/dev/null 2>&1``; then
306
- #notify-send -i face-wink -t 1234 \
307
- # 'Build Success!' 'Murano CLI says, "Woot woot!!"'
308
- # 2018-03-19: 1234 msec. is a tad too long. Something quicker,
309
- # so I can train myself to ignore if it's a blip in the corner of my eye.
310
- # Just make sure your mouse into over popup, or it won't go away!
311
- # Hahaha, at 333 msec. it's basically a flash on the screen...
312
- # in that case, there's probably a better way to implement this!
313
- notify-send \
314
- -t ${timeout} \
315
- -u normal \
316
- -i '/home/landonb/.waffle/home/Pictures/Landonb-Bitmoji-Thumbs.Up.png' \
317
- "${title}" \
318
- "${message}"
319
- fi
320
- }
321
-
322
- alert_success_flash() {
323
- local duration
324
- duration=${1:-0.075}
325
- # 2018-03-19 18:04: This just gets better!
326
- # sudo apt-get install xcalib
327
- ##xcalib -invert -alter
328
- #xcalib -alter -invert
329
- # xcalib, because of X, only works on the first monitor!
330
- # 2018-04-12: But I found a solution that works on all!!
331
- /srv/opt/bin/xrandr-invert-colors.bin
332
- sleep ${duration}
333
- ##xcalib -invert -alter
334
- #xcalib -alter -invert
335
- /srv/opt/bin/xrandr-invert-colors.bin
336
- }
337
-
338
- # ***
339
-
340
- prepare_to_build() {
341
- rmdir "${KILL_DIR}"
342
- say
343
- say "See you on the other side!"
344
- say
345
- touch "${OUT_FILE}"
346
- truncate -s 0 "${OUT_FILE}"
347
- say '' true
348
- }
349
-
350
- # ***
351
-
352
- init_it_() {
353
- announcement "INIT IT"
354
- }
355
-
356
- init_it() {
357
- init_it_
358
- }
359
-
360
- lang_it_() {
361
- announcement "LANG IT"
362
- }
363
-
364
- lang_it() {
365
- lang_it_
366
- }
367
-
368
- build_it_() {
369
- announcement "BUILD IT"
370
- }
371
-
372
- build_it() {
373
- build_it_
374
- }
375
-
376
- lint_it_() {
377
- announcement "LINT IT"
378
- }
379
-
380
- lint_it() {
381
- lint_it_
382
- }
383
-
384
- test_it_() {
385
- announcement "TEST IT"
386
- }
387
-
388
- test_it() {
389
- test_it_
390
- }
391
-
392
- ctags_it_() {
393
- announcement "CTAGS IT"
394
- }
395
-
396
- ctags_it() {
397
- ctags_it_
398
- }
399
-
400
- # ***
401
-
402
- drop_locks() {
403
- # FIXME/2017-10-03: Riddle me this: is a two-fer rmdir atomic like a 1 dir?
404
- rmdir "${LOCK_DIR}" "${KILL_DIR}"
405
- }
406
-
407
- remove_pid_files() {
408
- /bin/rm "${PID_FILE}"
409
- /bin/rm "${KILL_BIN}"
410
- }
411
-
412
- # ***
413
-
414
- main() {
415
- source_plugin
416
-
417
- assign_globals
418
-
419
- # We're called on both save, and on simple buffer enter.
420
- if [[ ${DUBS_TRUST_ME_ON_SAVE} != 1 ]]; then
421
- # We've got nothing to do on simple buffer enter...
422
- verbose_announcement "DUBS_TRUST_ME_ON_FILE: ${DUBS_TRUST_ME_ON_FILE}"
423
- verbose "Nothing to do on open"
424
- exit 1
425
- fi
426
-
427
- trap death SIGUSR1
428
-
429
- say
430
- say " 󷎟 󲁹 󲁭 󲁨 🚷 🐧 🐨 🐫 🐬 🐰 🐳 🐎 "
431
- announcement " ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎ ❎"
432
-
433
- init_it
434
-
435
- # Get the lock.
436
- lock_or_die
437
-
438
- say "- ‘$$’ has the lock"
439
- echo "$$" > "${PID_FILE}"
440
- echo "kill -s SIGUSR1 $$" > "${KILL_BIN}"
441
- chmod 755 "${KILL_BIN}"
442
-
443
- # Ctags builder. Before the build. In case BUILD_DELAY_SECS is a while.
444
- ctags_it
445
-
446
- announcement "WAITING ON BUILD" "Countdown: ${BUILD_DELAY_SECS} secs..."
447
-
448
- # Defer the build!
449
- drop_locks
450
- # The trap on SIGUSR1 only fires when this script is active and
451
- # not blocked on a subshell. And sleep is it's own command, so we
452
- # background it.
453
- sleep ${BUILD_DELAY_SECS} &
454
- # Fortunately, we can use the Bash wait command, which does not
455
- # block signals.
456
- # Get the process ID of the last command.
457
- # LPID=$!
458
- # wait ${LPID}
459
- # Or just wait.
460
- wait
461
-
462
- say "READY TO BUILD..."
463
- say
464
-
465
- # Get the lock.
466
- lock_kill_or_die
467
-
468
- say "BUILDING!"
469
-
470
- if ${TESTING:-false}; then
471
- drop_locks
472
- remove_pid_files
473
- say "DONE! (ONLY TESTING)"
474
- exit
475
- fi
476
-
477
- prepare_to_build
478
-
479
- time_0=$(date +%s.%N)
480
- announcement "WARMING UP"
481
- say "Build started at $(date '+%Y-%m-%d_%H-%M-%S')"
482
- verbose
483
- verbose "- Cwd: $(pwd)"
484
-
485
- lang_it
486
-
487
- build_it
488
- function test_concurrency() {
489
- for i in $(seq 1 5); do build_it; done
490
- }
491
- # DEVs: Wanna test CTRL-C more easily by keeping the script alive longer?
492
- # Then uncomment this.
493
- #test_concurrency
494
- # A fancy, colorful "Built!" message, meant to be easy to spot.
495
- say "${FG_LIME}$(repeat_char '>' 67)${FONT_NORM}"
496
- say "${FG_LIME}$(repeat_char '|' 67) BUILT!${FONT_NORM}"
497
- say "${FG_LIME}$(repeat_char '<' 67) ${FONT_NORM}"
498
-
499
- lint_it
500
-
501
- # Unit tests.
502
- test_it
503
-
504
- time_n=$(date +%s.%N)
505
- time_elapsed=$(echo "$time_n - $time_0" | bc -l)
506
- announcement "DONE!"
507
- say "Build finished at $(date '+%H:%M:%S') on $(date '+%Y-%m-%d') in ${time_elapsed} secs."
508
-
509
- trap - SIGUSR1
510
-
511
- remove_pid_files
512
- rmdir "${LOCK_DIR}"
513
- }
514
-
515
- main "$@"
516
-