openvox-editor-services 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +183 -0
  3. data/Gemfile +55 -0
  4. data/LICENSE +201 -0
  5. data/README.md +305 -0
  6. data/Rakefile +260 -0
  7. data/bin/openvox-debugserver +8 -0
  8. data/bin/openvox-languageserver +8 -0
  9. data/bin/openvox-languageserver-sidecar +8 -0
  10. data/bin/puppet-debugserver +8 -0
  11. data/bin/puppet-languageserver +7 -0
  12. data/bin/puppet-languageserver-sidecar +7 -0
  13. data/lib/dsp/dsp.rb +7 -0
  14. data/lib/dsp/dsp_base.rb +62 -0
  15. data/lib/dsp/dsp_protocol.rb +4619 -0
  16. data/lib/lsp/lsp.rb +10 -0
  17. data/lib/lsp/lsp_base.rb +63 -0
  18. data/lib/lsp/lsp_custom.rb +178 -0
  19. data/lib/lsp/lsp_enums.rb +143 -0
  20. data/lib/lsp/lsp_protocol.rb +2785 -0
  21. data/lib/lsp/lsp_protocol_callhierarchy.proposed.rb +239 -0
  22. data/lib/lsp/lsp_protocol_colorprovider.rb +100 -0
  23. data/lib/lsp/lsp_protocol_configuration.rb +82 -0
  24. data/lib/lsp/lsp_protocol_declaration.rb +73 -0
  25. data/lib/lsp/lsp_protocol_foldingrange.rb +129 -0
  26. data/lib/lsp/lsp_protocol_implementation.rb +75 -0
  27. data/lib/lsp/lsp_protocol_progress.rb +200 -0
  28. data/lib/lsp/lsp_protocol_selectionrange.rb +79 -0
  29. data/lib/lsp/lsp_protocol_sematictokens.proposed.rb +340 -0
  30. data/lib/lsp/lsp_protocol_typedefinition.rb +75 -0
  31. data/lib/lsp/lsp_protocol_workspacefolders.rb +174 -0
  32. data/lib/lsp/lsp_types.rb +1534 -0
  33. data/lib/openfact_runtime.rb +26 -0
  34. data/lib/openvox_runtime.rb +61 -0
  35. data/lib/puppet-debugserver/debug_session/break_points.rb +137 -0
  36. data/lib/puppet-debugserver/debug_session/flow_control.rb +161 -0
  37. data/lib/puppet-debugserver/debug_session/hook_handlers.rb +295 -0
  38. data/lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb +66 -0
  39. data/lib/puppet-debugserver/debug_session/puppet_session_state.rb +122 -0
  40. data/lib/puppet-debugserver/hooks.rb +132 -0
  41. data/lib/puppet-debugserver/message_handler.rb +277 -0
  42. data/lib/puppet-debugserver/puppet_debug_session.rb +541 -0
  43. data/lib/puppet-debugserver/puppet_monkey_patches.rb +118 -0
  44. data/lib/puppet-languageserver/client_session_state.rb +119 -0
  45. data/lib/puppet-languageserver/crash_dump.rb +50 -0
  46. data/lib/puppet-languageserver/epp/validation_provider.rb +34 -0
  47. data/lib/puppet-languageserver/facter_helper.rb +25 -0
  48. data/lib/puppet-languageserver/global_queues/sidecar_queue.rb +205 -0
  49. data/lib/puppet-languageserver/global_queues/single_instance_queue.rb +126 -0
  50. data/lib/puppet-languageserver/global_queues/validation_queue.rb +102 -0
  51. data/lib/puppet-languageserver/global_queues.rb +16 -0
  52. data/lib/puppet-languageserver/manifest/completion_provider.rb +331 -0
  53. data/lib/puppet-languageserver/manifest/definition_provider.rb +99 -0
  54. data/lib/puppet-languageserver/manifest/document_symbol_provider.rb +228 -0
  55. data/lib/puppet-languageserver/manifest/folding_provider.rb +226 -0
  56. data/lib/puppet-languageserver/manifest/format_on_type_provider.rb +143 -0
  57. data/lib/puppet-languageserver/manifest/hover_provider.rb +221 -0
  58. data/lib/puppet-languageserver/manifest/signature_provider.rb +169 -0
  59. data/lib/puppet-languageserver/manifest/validation_provider.rb +130 -0
  60. data/lib/puppet-languageserver/message_handler.rb +470 -0
  61. data/lib/puppet-languageserver/providers.rb +18 -0
  62. data/lib/puppet-languageserver/puppet_helper.rb +108 -0
  63. data/lib/puppet-languageserver/puppet_lexer_helper.rb +55 -0
  64. data/lib/puppet-languageserver/puppet_lint.rb +9 -0
  65. data/lib/puppet-languageserver/puppet_monkey_patches.rb +39 -0
  66. data/lib/puppet-languageserver/puppet_parser_helper.rb +212 -0
  67. data/lib/puppet-languageserver/puppetfile/validation_provider.rb +185 -0
  68. data/lib/puppet-languageserver/server_capabilities.rb +48 -0
  69. data/lib/puppet-languageserver/session_state/document_store.rb +272 -0
  70. data/lib/puppet-languageserver/session_state/language_client.rb +239 -0
  71. data/lib/puppet-languageserver/session_state/object_cache.rb +162 -0
  72. data/lib/puppet-languageserver/sidecar_protocol.rb +532 -0
  73. data/lib/puppet-languageserver/uri_helper.rb +46 -0
  74. data/lib/puppet-languageserver-sidecar/cache/base.rb +36 -0
  75. data/lib/puppet-languageserver-sidecar/cache/filesystem.rb +111 -0
  76. data/lib/puppet-languageserver-sidecar/cache/null.rb +27 -0
  77. data/lib/puppet-languageserver-sidecar/facter_helper.rb +41 -0
  78. data/lib/puppet-languageserver-sidecar/puppet_environment_monkey_patches.rb +52 -0
  79. data/lib/puppet-languageserver-sidecar/puppet_helper.rb +281 -0
  80. data/lib/puppet-languageserver-sidecar/puppet_modulepath_monkey_patches.rb +146 -0
  81. data/lib/puppet-languageserver-sidecar/puppet_monkey_patches.rb +9 -0
  82. data/lib/puppet-languageserver-sidecar/puppet_parser_helper.rb +77 -0
  83. data/lib/puppet-languageserver-sidecar/puppet_strings_helper.rb +399 -0
  84. data/lib/puppet-languageserver-sidecar/puppet_strings_monkey_patches.rb +16 -0
  85. data/lib/puppet-languageserver-sidecar/sidecar_protocol_extensions.rb +16 -0
  86. data/lib/puppet-languageserver-sidecar/workspace.rb +89 -0
  87. data/lib/puppet_debugserver.rb +163 -0
  88. data/lib/puppet_editor_services/connection/base.rb +62 -0
  89. data/lib/puppet_editor_services/connection/stdio.rb +25 -0
  90. data/lib/puppet_editor_services/connection/tcp.rb +34 -0
  91. data/lib/puppet_editor_services/handler/base.rb +16 -0
  92. data/lib/puppet_editor_services/handler/debug_adapter.rb +63 -0
  93. data/lib/puppet_editor_services/handler/json_rpc.rb +133 -0
  94. data/lib/puppet_editor_services/logging.rb +45 -0
  95. data/lib/puppet_editor_services/protocol/base.rb +27 -0
  96. data/lib/puppet_editor_services/protocol/debug_adapter.rb +135 -0
  97. data/lib/puppet_editor_services/protocol/debug_adapter_messages.rb +171 -0
  98. data/lib/puppet_editor_services/protocol/json_rpc.rb +241 -0
  99. data/lib/puppet_editor_services/protocol/json_rpc_messages.rb +200 -0
  100. data/lib/puppet_editor_services/server/base.rb +42 -0
  101. data/lib/puppet_editor_services/server/stdio.rb +85 -0
  102. data/lib/puppet_editor_services/server/tcp.rb +349 -0
  103. data/lib/puppet_editor_services/server.rb +15 -0
  104. data/lib/puppet_editor_services/version.rb +36 -0
  105. data/lib/puppet_editor_services.rb +8 -0
  106. data/lib/puppet_languageserver.rb +265 -0
  107. data/lib/puppet_languageserver_sidecar.rb +364 -0
  108. metadata +256 -0
data/README.md ADDED
@@ -0,0 +1,305 @@
1
+ # OpenVox Editor Services
2
+
3
+ A Ruby implementation of a [Language Server](https://github.com/Microsoft/language-server-protocol) and [Debug Server](https://github.com/microsoft/debug-adapter-protocol) for OpenVox. The internal `Puppet` Ruby namespace and `puppet/*` protocol methods are retained for compatibility.
4
+
5
+ ## Requirements
6
+
7
+ * OpenVox 8 or above
8
+
9
+ * Ruby 3.1 or above
10
+
11
+ ## Setting up editor services for development
12
+
13
+ * Ensure a modern ruby is installed (3.1+)
14
+
15
+ The editor services support OpenVox 8.0.0 and above.
16
+
17
+ * Clone this repository
18
+
19
+ ```bash
20
+ > git clone https://github.com/voxpupuli/openvox-editor-services.git
21
+
22
+ > cd openvox-editor-services
23
+ ```
24
+
25
+ * Bundle the development gems
26
+
27
+ ```bash
28
+ > bundle install
29
+
30
+ ... < lots of text >
31
+ ```
32
+
33
+ * Installed vendored gems
34
+
35
+ ```bash
36
+ > bundle exec rake gem_revendor
37
+
38
+ ... < lots of text >
39
+ ```
40
+
41
+ # Language Server
42
+
43
+ ## How to run the Language Server for Development
44
+
45
+ By default the language server will stop if no connection is made within 10 seconds and will also stop after a client disconnects. Adding `--debug=stdout` will log messages to the console
46
+
47
+ ```bash
48
+ > bundle exec ruby ./puppet-languageserver --debug=stdout
49
+ I, [2018-12-05T15:19:51.853802 #28756] INFO -- : Language Server is v0.16.0
50
+ I, [2018-12-05T15:19:51.854809 #28756] INFO -- : Using Puppet v5.5.8
51
+ D, [2018-12-05T15:19:51.856726 #28756] DEBUG -- : Detected additional puppet settings []
52
+ I, [2018-12-05T15:19:51.867798 #28756] INFO -- : Initializing Puppet Helper...
53
+ D, [2018-12-05T15:19:51.867798 #28756] DEBUG -- : Initializing Document Store...
54
+ I, [2018-12-05T15:19:51.868726 #28756] INFO -- : Initializing settings...
55
+ I, [2018-12-05T15:19:51.870728 #28756] INFO -- : Starting RPC Server...
56
+ D, [2018-12-05T15:19:51.870728 #28756] DEBUG -- : Using Simple TCP
57
+ I, [2018-12-05T15:19:51.871729 #28756] INFO -- : Using Facter v2.5.1
58
+ I, [2018-12-05T15:19:51.871729 #28756] INFO -- : Preloading Puppet Types (Async)...
59
+ I, [2018-12-05T15:19:51.872728 #28756] INFO -- : Preloading Facter (Async)...
60
+ I, [2018-12-05T15:19:51.873727 #28756] INFO -- : Preloading Functions (Async)...
61
+ I, [2018-12-05T15:19:51.876727 #28756] INFO -- : Preloading Classes (Async)...
62
+ D, [2018-12-05T15:19:51.876727 #28756] DEBUG -- : SidecarQueue Thread: Running sidecar ["ruby", "C:/Source/puppet-editor-services/puppet-languageserver-sidecar", "--action", "default_types", "--feature-flags="]
63
+ D, [2018-12-05T15:19:51.899795 #28756] DEBUG -- : SidecarQueue Thread: Running sidecar ["ruby", "C:/Source/puppet-editor-services/puppet-languageserver-sidecar", "--action", "default_functions", "--feature-flags="]
64
+ D, [2018-12-05T15:19:51.919794 #28756] DEBUG -- : TCPSRV: Services running. Press ^C to stop
65
+ D, [2018-12-05T15:19:51.920795 #28756] DEBUG -- : TCPSRV: Will stop the server in 10 seconds if no connection is made.
66
+ D, [2018-12-05T15:19:51.921809 #28756] DEBUG -- : TCPSRV: Will stop the server when client disconnects
67
+ LANGUAGE SERVER RUNNING localhost:55087
68
+ D, [2018-12-05T15:19:51.923800 #28756] DEBUG -- : TCPSRV: Started listening on localhost:55087.
69
+ A, [2018-12-05T15:19:54.520501 #28756] ANY -- : SidecarQueue Thread: Calling sidecar with --action default_functions --feature-flags= returned exitcode 0,
70
+ D, [2018-12-05T15:19:54.532525 #28756] DEBUG -- : SidecarQueue Thread: default_functions returned 270 items
71
+ D, [2018-12-05T15:19:54.533522 #28756] DEBUG -- : SidecarQueue Thread: Running sidecar ["ruby", "C:/Source/puppet-editor-services/puppet-languageserver-sidecar", "--action", "default_classes", "--feature-flags="]
72
+ A, [2018-12-05T15:19:54.576503 #28756] ANY -- : SidecarQueue Thread: Calling sidecar with --action default_types --feature-flags= returned exitcode 0,
73
+ D, [2018-12-05T15:19:54.638503 #28756] DEBUG -- : SidecarQueue Thread: default_types returned 81 items
74
+ A, [2018-12-05T15:19:56.732112 #28756] ANY -- : SidecarQueue Thread: Calling sidecar with --action default_classes --feature-flags= returned exitcode 0,
75
+ D, [2018-12-05T15:19:56.732112 #28756] DEBUG -- : SidecarQueue Thread: default_classes returned 0 items
76
+ ...
77
+ D, [2018-12-05T15:20:03.319045 #28756] DEBUG -- : TCPSRV: No connection has been received in 10 seconds. Shutting down server.
78
+ D, [2018-12-05T15:20:03.320049 #28756] DEBUG -- : TCPSRV: Stopping services
79
+ D, [2018-12-05T15:20:03.377052 #28756] DEBUG -- : TCPSRV: Stopped listening on localhost:55087
80
+ D, [2018-12-05T15:20:03.377052 #28756] DEBUG -- : TCPSRV: Started shutdown process. Press ^C to force quit.
81
+ D, [2018-12-05T15:20:03.378052 #28756] DEBUG -- : TCPSRV: Stopping services
82
+ D, [2018-12-05T15:20:03.379050 #28756] DEBUG -- : TCPSRV: Waiting for workers to cycle down
83
+ I, [2018-12-05T15:20:03.632011 #28756] INFO -- : Language Server exited.
84
+ ```
85
+
86
+ To make the server run continuously add `--timeout=0` and `--no-stop` to the command line. For example;
87
+
88
+ ```bash
89
+ > bundle exec ruby ./puppet-languageserver --debug=stdout --timeout=0 --no-stop
90
+ I, [2018-12-05T15:20:56.302414 #29752] INFO -- : Language Server is v0.16.0
91
+ I, [2018-12-05T15:20:56.303391 #29752] INFO -- : Using Puppet v5.5.8
92
+ D, [2018-12-05T15:20:56.306343 #29752] DEBUG -- : Detected additional puppet settings []
93
+ I, [2018-12-05T15:20:56.318333 #29752] INFO -- : Initializing Puppet Helper...
94
+ D, [2018-12-05T15:20:56.318333 #29752] DEBUG -- : Initializing Document Store...
95
+ I, [2018-12-05T15:20:56.319346 #29752] INFO -- : Initializing settings...
96
+ I, [2018-12-05T15:20:56.321337 #29752] INFO -- : Starting RPC Server...
97
+ D, [2018-12-05T15:20:56.321337 #29752] DEBUG -- : Using Simple TCP
98
+ I, [2018-12-05T15:20:56.322332 #29752] INFO -- : Using Facter v2.5.1
99
+ I, [2018-12-05T15:20:56.323335 #29752] INFO -- : Preloading Puppet Types (Async)...
100
+ I, [2018-12-05T15:20:56.325337 #29752] INFO -- : Preloading Facter (Async)...
101
+ I, [2018-12-05T15:20:56.326335 #29752] INFO -- : Preloading Functions (Async)...
102
+ I, [2018-12-05T15:20:56.327333 #29752] INFO -- : Preloading Classes (Async)...
103
+ ...
104
+ D, [2018-12-05T15:20:56.365334 #29752] DEBUG -- : TCPSRV: Services running. Press ^C to stop
105
+ LANGUAGE SERVER RUNNING localhost:55180
106
+ D, [2018-12-05T15:20:56.374333 #29752] DEBUG -- : TCPSRV: Started listening on localhost:55180.
107
+ ...
108
+ ```
109
+
110
+ ## How to run the Language Server in Production
111
+
112
+ * Ensure that Puppet Agent is installed
113
+ * [Linux](https://puppet.com/docs/puppet/latest/install_agents.html#install_nix_agents)
114
+ * [Windows](https://puppet.com/docs/puppet/latest/install_agents.html#install_windows_agents)
115
+ * [macOS](https://puppet.com/docs/puppet/latest/install_agents.html#install_mac_agents)
116
+
117
+ * Run the `puppet-languageserver` with ruby
118
+
119
+ > On Windows you need to run ruby with the `Puppet Command Prompt` which can be found in the Start Menu. This enables the Puppet Agent ruby environment.
120
+
121
+ ```bash
122
+ > ruby puppet-languageserver
123
+ LANGUAGE SERVER RUNNING 127.0.0.1:55086
124
+ ```
125
+
126
+ > Note the language server will stop after 10 seconds if no client connection is made.
127
+
128
+ Note that the Language Server will use TCP as the default transport on `localhost` at a random port. The IP Address and Port can be changed using the `--ip` and `--port` arguments respectively. For example to listen on all interfaces on port 9000;
129
+
130
+ ```bash
131
+ > ruby ./puppet-languageserver --ip=0.0.0.0 --port=9000
132
+ ```
133
+
134
+ To change the protocol to STDIO, that is using STDOUT and STDIN, use the `--stdio` argument.
135
+
136
+ ## Command line arguments
137
+
138
+ ```bash
139
+ Usage: puppet-languageserver.rb [options]
140
+ -p, --port=PORT TCP Port to listen on. Default is random port
141
+ -i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is localhost
142
+ -c, --no-stop Do not stop the language server once a client disconnects. Default is to stop
143
+ -t, --timeout=TIMEOUT Stop the language server if a client does not connection within TIMEOUT seconds. A value of zero will not timeout. Default is 10 seconds
144
+ -d, --no-preload ** DEPRECATED ** Do not preload Puppet information when the language server starts. Default is to preload
145
+ --debug=DEBUG Output debug information. Either specify a filename or 'STDOUT'. Default is no debug output
146
+ -s, --slow-start Delay starting the Language Server until Puppet initialisation has completed. Default is to start fast
147
+ --stdio Runs the server in stdio mode, without a TCP listener
148
+ --enable-file-cache ** DEPRECATED ** Enables the file system cache for Puppet Objects (types, class etc.)
149
+ --[no-]cache Enable or disable all caching inside the sidecar. By default caching is enabled.
150
+ --feature-flags=FLAGS A list of comma delimited feature flags
151
+ --openvox-version=TEXT The OpenVox Gem version to use
152
+ --puppet-settings=TEXT Comma delimited list of settings to pass into Puppet e.g. --vardir,/opt/test-fixture
153
+ --local-workspace=PATH The workspace or file path that will be used to provide module-specific functionality. Default is no workspace path.
154
+ -h, --help Prints this help
155
+ -v, --version Prints the Langauge Server version
156
+ ```
157
+
158
+ # Language Server Sidecar
159
+
160
+ ## How to run the Language Server for Development
161
+
162
+ The Language Server Sidecar is a process used by the Language Server to get information about Puppet's environment, for example, all available functions, classes, and custom types. This tool is typically only run by the Language Server itself, but it can be used to diagnose issues.
163
+
164
+ The sidecar is told to perform an action (using the `action`) parameter and then, by default, outputs the JSON encoded result to STDOUT. This can be changed to a text file using the `--output=PATH` argument.
165
+
166
+ Note that using the `--debug=STDOUT` option without directing the output to a text file will generate output on STDOUT which cannot be deserialized correctly. Typically this only used by a developer to inspect what the Sidecar is doing.
167
+
168
+ ### Example usage
169
+
170
+ #### Confirm that the Sidecar loads correctly
171
+
172
+ The `noop` action just outputs an empty JSON array but can be used to confirm that the Sidecar does not error while loading Puppet.
173
+
174
+ ```bash
175
+ > bundle exec ruby ./puppet-languageserver-sidecar --action=noop
176
+ []
177
+ ```
178
+
179
+ #### Output all default Puppet Types
180
+
181
+ ```bash
182
+ > bundle exec ruby ./puppet-languageserver-sidecar --action=default_types
183
+ [{"key":"anchor","calling_source":"puppet/cache/lib/puppet/type/anchor.rb","sou ...
184
+ ```
185
+
186
+ #### Output all default Puppet Functions with a different puppet configuration, and debug information
187
+
188
+ ```bash
189
+ > bundle exec ruby ./puppet-languageserver-sidecar --action=default_types --puppet-settings=--vardir,./test/vardir,--confdir,./test/confdir --debug=STDOUT
190
+ I, [2018-12-05T15:42:56.679837 #51864] INFO -- : Language Server Sidecar is v0.16.0
191
+ I, [2018-12-05T15:42:56.679837 #51864] INFO -- : Using Puppet v5.5.8
192
+ D, [2018-12-05T15:42:56.680820 #51864] DEBUG -- : Detected additional puppet settings ["--vardir", "./test/vardir", "--confdir", "./test/confdir"]
193
+ D, [2018-12-05T15:42:56.690876 #51864] DEBUG -- : [PuppetHelper::load_functions] Starting
194
+ D, [2018-12-05T15:42:56.752804 #51864] DEBUG -- : [PuppetLanguageServerSidecar::load] Loading lib/puppet/parser/functions/assert_type.rb from cache
195
+ ...
196
+ [{"key":"debug","calling_source":"lib/puppet/parser/functions.rb", ...
197
+ ```
198
+
199
+ #### Output all Puppet Classes in a workspace directory
200
+
201
+ ```bash
202
+ > bundle exec ruby ./puppet-languageserver-sidecar --action=workspace_classes --local-workspace=C:\source\puppetlabs-sqlserver
203
+ [{"key":"sqlserver::config","calling_source":"C:/Source/puppetlabs-sqlserver/manifests/config.pp","source":"C:/Source/puppetlabs-sqlserver/manifests/config.pp","line":25,"ch...
204
+ ```
205
+
206
+ ## Command line arguments
207
+
208
+ ```bash
209
+ Usage: puppet-languageserver-sidecar.rb [options]
210
+ -a, --action=NAME The action for the sidecar to take. Expected ["noop", "default_classes", "default_functions", "default_types", "node_graph", "resource_list", "workspace_classes", "workspace_functions", "workspace_types"]
211
+ -c, --action-parameters=JSON JSON Encoded string containing the parameters for the sidecar action
212
+ -w, --local-workspace=PATH The workspace or file path that will be used to provide module-specific functionality. Default is no workspace path
213
+ -o, --output=PATH The file to save the output from the sidecar. Default is output to STDOUT
214
+ -p, --puppet-settings=TEXT Comma delimited list of settings to pass into Puppet e.g. --vardir,/opt/test-fixture
215
+ -f, --feature-flags=FLAGS A list of comma delimited feature flags to pass the the sidecar
216
+ -n, --[no-]cache Enable or disable all caching inside the sidecar. By default caching is enabled.
217
+ --debug=DEBUG Output debug information. Either specify a filename or 'STDOUT'. Default is no debug output
218
+ -h, --help Prints this help
219
+ -v, --version Prints the Langauge Server version
220
+ ```
221
+
222
+ # Debug Server
223
+
224
+ ## How to run the Debug Server for Development
225
+
226
+ By default the debug server will stop if no connection is made within 10 seconds and will also stop after a client disconnects. Adding `--debug=stdout` will log messages to the console
227
+
228
+ ```bash
229
+ > bundle exec ruby ./puppet-debugserver --debug=stdout
230
+ I, [2018-04-17T14:19:24.131869 #6940] INFO -- : Debug Server is v0.10.0
231
+ I, [2018-04-17T14:19:24.132871 #6940] INFO -- : Starting RPC Server...
232
+ D, [2018-04-17T14:19:24.135373 #6940] DEBUG -- : TCPSRV: Services running. Press ^C to stop
233
+ D, [2018-04-17T14:19:24.135870 #6940] DEBUG -- : TCPSRV: Will stop the server in 10 seconds if no connection is made.
234
+ D, [2018-04-17T14:19:24.135870 #6940] DEBUG -- : TCPSRV: Will stop the server when client disconnects
235
+ DEBUG SERVER RUNNING 127.0.0.1:8082
236
+ D, [2018-04-17T14:19:24.136871 #6940] DEBUG -- : TCPSRV: Started listening on 127.0.0.1:8082.
237
+ D, [2018-04-17T14:19:34.140900 #6940] DEBUG -- : TCPSRV: No connection has been received in 10 seconds. Shutting down server.
238
+ D, [2018-04-17T14:19:34.140900 #6940] DEBUG -- : TCPSRV: Stopping services
239
+ D, [2018-04-17T14:19:34.141400 #6940] DEBUG -- : TCPSRV: Stopped listening on 127.0.0.1:8082
240
+ D, [2018-04-17T14:19:34.141900 #6940] DEBUG -- : TCPSRV: Started shutdown process. Press ^C to force quit.
241
+ D, [2018-04-17T14:19:34.141900 #6940] DEBUG -- : TCPSRV: Stopping services
242
+ D, [2018-04-17T14:19:34.142401 #6940] DEBUG -- : TCPSRV: Waiting for workers to cycle down
243
+ I, [2018-04-17T14:19:34.150402 #6940] INFO -- : Debug Server exited.
244
+ ```
245
+
246
+ To make the server run continuously add `--timeout=0` to the command line. For example;
247
+
248
+ ```bash
249
+ > bundle exec ruby ./puppet-debugserver --debug=stdout --timeout=0
250
+ I, [2018-04-17T14:21:10.542332 #12424] INFO -- : Debug Server is v0.10.0
251
+ I, [2018-04-17T14:21:10.543334 #12424] INFO -- : Starting RPC Server...
252
+ D, [2018-04-17T14:21:10.545836 #12424] DEBUG -- : TCPSRV: Services running. Press ^C to stop
253
+ D, [2018-04-17T14:21:10.546336 #12424] DEBUG -- : TCPSRV: Will stop the server when client disconnects
254
+ DEBUG SERVER RUNNING 127.0.0.1:8082
255
+ D, [2018-04-17T14:21:10.546834 #12424] DEBUG -- : TCPSRV: Started listening on 127.0.0.1:8082.
256
+ ...
257
+ ```
258
+
259
+ ## How to run the Debug Server for Production
260
+
261
+ * Ensure that Puppet Agent is installed
262
+ * [Linux](https://puppet.com/docs/puppet/latest/install_agents.html#install_nix_agents)
263
+ * [Windows](https://puppet.com/docs/puppet/latest/install_agents.html#install_windows_agents)
264
+ * [macOS](https://puppet.com/docs/puppet/latest/install_agents.html#install_mac_agents)
265
+
266
+ * Run the `puppet-debugserver` with ruby
267
+
268
+ > On Windows you need to run ruby with the `Puppet Command Prompt` which can be found in the Start Menu. This enables the Puppet Agent ruby environment.
269
+
270
+ ```bash
271
+ > ruby puppet-debugserver
272
+ DEBUG SERVER RUNNING 127.0.0.1:8082
273
+ ```
274
+
275
+ Note the debug server will stop after 10 seconds if no client connection is made.
276
+
277
+ ## Command line arguments
278
+
279
+ ```bash
280
+ Usage: puppet-debugserver.rb [options]
281
+ -p, --port=PORT TCP Port to listen on. Default is random port}
282
+ -i, --ip=ADDRESS IP Address to listen on (0.0.0.0 for all interfaces). Default is localhost
283
+ -t, --timeout=TIMEOUT Stop the Debug Server if a client does not connection within TIMEOUT seconds. A value of zero will not timeout. Default is 10 seconds
284
+ --debug=DEBUG Output debug information. Either specify a filename or 'STDOUT'. Default is no debug output
285
+ -h, --help Prints this help
286
+ -v, --version Prints the Debug Server version
287
+ ```
288
+
289
+ ## License
290
+
291
+ This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.
292
+
293
+ # Other information
294
+
295
+ ## Reporting bugs
296
+
297
+ If you find a bug in puppet-editor-services or its results, please create an issue in the [repo issues tracker](https://github.com/puppetlabs/puppet-editor-services/issues). Bonus points will be awarded if you also include a patch that fixes the issue.
298
+
299
+ ## Development
300
+
301
+ If you run into an issue with this tool or would like to request a feature you can raise a PR with your suggested changes. Alternatively, you can raise a Github issue with a feature request or to report any bugs. Every other Tuesday the DevX team holds office hours in the Puppet Community Slack, where you can ask questions about this and any other supported tools. This session runs at 15:00 (GMT) for about an hour.
302
+
303
+ ## Why are there vendored gems and why only native ruby
304
+
305
+ When used by editors this language server will be running using the Ruby runtime provided by Puppet Agent. That means no native extensions and no bundler. Also, only the gems provided by Puppet Agent would be available by default. To work around this limitation all runtime dependencies should be re-vendored and then the load path modified appropriately.
data/Rakefile ADDED
@@ -0,0 +1,260 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ rubocop_available = Gem::Specification::find_all_by_name('rubocop').any?
4
+ require 'rubocop/rake_task' if rubocop_available
5
+
6
+ namespace :test do
7
+ desc 'Run tests with code coverage'
8
+ task :coverage do
9
+ ENV['COVERAGE'] = 'yes'
10
+ Rake::Task['test_languageserver'].execute
11
+ Rake::Task['test_languageserver_sidecar'].execute
12
+ Rake::Task['test_debugserver'].execute
13
+ end
14
+ end
15
+
16
+ desc 'Run rspec tests for the Language Server with coloring.'
17
+ RSpec::Core::RakeTask.new(:test_languageserver) do |t|
18
+ t.rspec_opts = %w[--color --format documentation --default-path spec/languageserver]
19
+ t.pattern = ['spec/languageserver/unit/**/*_spec.rb', 'spec/languageserver/integration/**/*_spec.rb']
20
+ end
21
+
22
+ desc 'Run acceptance tests for the Language Server with coloring.'
23
+ RSpec::Core::RakeTask.new(:acceptance_languageserver) do |t|
24
+ t.rspec_opts = %w[--color --format documentation --default-path spec/languageserver]
25
+ t.pattern = ['spec/languageserver/acceptance/**/*_spec.rb']
26
+ end
27
+
28
+ desc 'Run rspec tests for the Language Server Sidecar with coloring.'
29
+ RSpec::Core::RakeTask.new(:test_languageserver_sidecar) do |t|
30
+ t.rspec_opts = %w[--color --format documentation --default-path spec/languageserver-sidecar]
31
+ t.pattern = 'spec/languageserver-sidecar'
32
+ end
33
+
34
+ desc 'Run rspec tests for the Debug Server with coloring.'
35
+ RSpec::Core::RakeTask.new(:test_debugserver) do |t|
36
+ t.rspec_opts = %w[--color --format documentation --default-path spec/debugserver]
37
+ t.pattern = 'spec/debugserver'
38
+ end
39
+
40
+ if rubocop_available
41
+ desc 'Run RuboCop'
42
+ RuboCop::RakeTask.new(:rubocop) do |task|
43
+ task.options << '--display-cop-names'
44
+ task.options << '--config'
45
+ task.options << '.rubocop.yml'
46
+ end
47
+ end
48
+
49
+ namespace :rubocop do
50
+ desc "Generate the Rubocop Todo file"
51
+ task :generate do
52
+ begin
53
+ sh "rubocop --auto-gen-config"
54
+ rescue => exception
55
+ # Ignore any errors
56
+ end
57
+ end
58
+ end
59
+
60
+ desc "Download and vendor required gems"
61
+ task :gem_revendor do
62
+ require 'fileutils'
63
+ require 'rubygems/package'
64
+ require 'tmpdir'
65
+
66
+ gem_list = [
67
+ {
68
+ :directory => 'hiera-eyaml',
69
+ :github_repo => 'https://github.com/voxpupuli/hiera-eyaml',
70
+ :github_ref => 'v2.1.0',
71
+ },
72
+ {
73
+ :directory => 'puppetfile-resolver',
74
+ :github_repo => 'https://github.com/puppetlabs/puppetfile-resolver.git',
75
+ :github_ref => 'v0.6.3',
76
+ },
77
+ {
78
+ :directory => 'molinillo',
79
+ :github_repo => 'https://github.com/CocoaPods/Molinillo.git',
80
+ :github_ref => '0.6.6',
81
+ },
82
+ {
83
+ :directory => 'openvox-strings',
84
+ :github_repo => 'https://github.com/voxpupuli/openvox-strings.git',
85
+ :github_ref => 'v7.1.0',
86
+ },
87
+ {
88
+ :directory => 'rgen',
89
+ :github_repo => 'https://github.com/mthiede/rgen.git',
90
+ :github_ref => 'v0.10.2',
91
+ },
92
+ {
93
+ :directory => 'yard',
94
+ :github_repo => 'https://github.com/lsegal/yard.git',
95
+ :github_ref => 'v0.9.24',
96
+ },
97
+ ]
98
+
99
+ # voxpupuli-puppet-lint-plugins 7.0.0 is a metadata-only gem. Its complete runtime
100
+ # dependency set must be vendored explicitly because the packaged language
101
+ # server runs without Bundler or access to installed gems.
102
+ puppet_lint_gems = {
103
+ 'puppet-lint' => '5.1.1',
104
+ 'puppet-lint-absolute_classname-check' => '5.0.0',
105
+ 'puppet-lint-anchor-check' => '3.0.0',
106
+ 'puppet-lint-exec_idempotency-check' => '2.0.0',
107
+ 'puppet-lint-file_ensure-check' => '3.0.0',
108
+ 'puppet-lint-leading_zero-check' => '3.0.0',
109
+ 'puppet-lint-lookup_in_parameter-check' => '3.0.0',
110
+ 'puppet-lint-manifest_whitespace-check' => '2.0.0',
111
+ 'puppet-lint-optional_default-check' => '3.0.0',
112
+ 'puppet-lint-package_ensure-check' => '0.2.0',
113
+ 'puppet-lint-param-docs' => '3.0.0',
114
+ 'puppet-lint-param-types' => '3.0.0',
115
+ 'puppet-lint-params_empty_string-check' => '3.0.0',
116
+ 'puppet-lint-params_not_optional_with_undef-check' => '1.0.0',
117
+ 'puppet-lint-resource_reference_syntax' => '3.0.0',
118
+ 'puppet-lint-strict_indent-check' => '5.0.0',
119
+ 'puppet-lint-topscope-variable-check' => '3.0.0',
120
+ 'puppet-lint-trailing_comma-check' => '3.0.1',
121
+ 'puppet-lint-unquoted_string-check' => '4.1.0',
122
+ 'puppet-lint-variable_contains_upcase' => '3.0.0',
123
+ 'puppet-lint-version_comparison-check' => '3.0.0',
124
+ }
125
+
126
+ # Clean out the vendor directory first
127
+ puts "Clearing the vendor directory..."
128
+ vendor_dir = File.join(File.dirname(__FILE__),'vendor')
129
+ FileUtils.rm_rf(File.join(vendor_dir, 'puppet-strings'))
130
+ gem_list.each do |vendor|
131
+ gem_dir = File.join(vendor_dir,vendor[:directory])
132
+ FileUtils.rm_rf(gem_dir) if Dir.exist?(gem_dir)
133
+ end
134
+ puppet_lint_gems.each_key do |gem_name|
135
+ gem_dir = File.join(vendor_dir, gem_name)
136
+ FileUtils.rm_rf(gem_dir) if Dir.exist?(gem_dir)
137
+ end
138
+ Dir.mkdir(vendor_dir) unless Dir.exist?(vendor_dir)
139
+
140
+ gem_list.each do |vendor|
141
+ puts "Vendoring #{vendor[:directory]}..."
142
+ gem_dir = File.join(vendor_dir,vendor[:directory])
143
+
144
+ sh "git clone #{vendor[:github_repo]} #{gem_dir}"
145
+ Dir.chdir(gem_dir) do
146
+ sh 'git fetch origin'
147
+ sh "git reset --hard #{vendor[:github_ref]}"
148
+ end
149
+
150
+ # Cleanup the gem directory...
151
+ FileUtils.rm_rf(File.join(gem_dir,'.git'))
152
+ FileUtils.rm_rf(File.join(gem_dir,'spec'))
153
+ FileUtils.rm_rf(File.join(gem_dir,'features'))
154
+ FileUtils.rm_rf(File.join(gem_dir,'docs'))
155
+ end
156
+
157
+ Dir.mktmpdir('openvox-editor-services-gems') do |download_dir|
158
+ puppet_lint_gems.each do |gem_name, gem_version|
159
+ puts "Vendoring #{gem_name} #{gem_version}..."
160
+ gem_filename = "#{gem_name}-#{gem_version}.gem"
161
+
162
+ Dir.chdir(download_dir) do
163
+ sh Gem.ruby, '-S', 'gem', 'fetch', gem_name,
164
+ '--version', gem_version,
165
+ '--clear-sources',
166
+ '--source', 'https://rubygems.org'
167
+ end
168
+
169
+ gem_dir = File.join(vendor_dir, gem_name)
170
+ Gem::Package.new(File.join(download_dir, gem_filename)).extract_files(gem_dir)
171
+ FileUtils.rm_rf(File.join(gem_dir, 'spec'))
172
+ FileUtils.rm_rf(File.join(gem_dir, 'features'))
173
+ FileUtils.rm_rf(File.join(gem_dir, 'docs'))
174
+ end
175
+ end
176
+
177
+ # Generate the README
178
+ readme = <<-HEREDOC
179
+ # Vendored Gems
180
+
181
+ The OpenVox Puppet DSL server is designed to run within the OpenVox Agent Ruby environment, which means no access to native extensions or Gem bundling.
182
+
183
+ This means any Gems required outside of the OpenVox runtime for the language server must be vendored in this directory and the load path modified in the `openvox-languageserver` file.
184
+
185
+ Note - To comply with Licensing, the Gem source should be MIT licensed or even more unrestricted.
186
+
187
+ Note - To improve the packaging size, test files etc. were stripped from the Gems prior to committing.
188
+
189
+ Gem List
190
+ --------
191
+
192
+ * voxpupuli-puppet-lint-plugins (metadata dependency version 7.0.0)
193
+ HEREDOC
194
+ gem_list.each { |vendor| readme += "* #{vendor[:directory]} (#{vendor[:github_repo]} ref #{vendor[:github_ref]})\n"}
195
+ puppet_lint_gems.each { |gem_name, gem_version| readme += "* #{gem_name} (RubyGems version #{gem_version})\n" }
196
+ File.open(File.join(vendor_dir,'README.md'), 'wb') { |file| file.write(readme) }
197
+ end
198
+
199
+ desc "Create compressed files of the language and debug servers for release"
200
+ task build: [:gem_revendor] do
201
+ require 'fileutils'
202
+ require 'archive/zip'
203
+ require 'zlib'
204
+ require 'minitar'
205
+ require 'digest'
206
+
207
+ project_dir = File.dirname(__FILE__)
208
+ output_dir = File.join(project_dir, './pkg/')
209
+
210
+ file_list = ['lib', 'vendor', 'openvox-languageserver', 'openvox-debugserver', 'openvox-languageserver-sidecar', 'LICENSE']
211
+ # Remove files in the list that do not exist.
212
+ file_list.reject! { |filepath| !File.exist?(filepath) }
213
+
214
+ puts "Cleaning output directory..."
215
+ FileUtils.rm_rf Dir.glob("#{output_dir}/*") if Dir.exist?(output_dir)
216
+ Dir.mkdir(output_dir) unless Dir.exist?(output_dir)
217
+
218
+ puts "Fetch editor services version..."
219
+ require_relative 'lib/puppet_editor_services/version'
220
+ version = PuppetEditorServices.version
221
+ puts "Editor services is v#{version}"
222
+
223
+ puts "Creating zip file..."
224
+ zip_archive_file = File.join(output_dir,"openvox_editor_services_v#{version}.zip")
225
+ Archive::Zip.archive(zip_archive_file, file_list)
226
+ puts "Created #{zip_archive_file}"
227
+
228
+ puts "Creating tar file..."
229
+ tar_archive_file = File.join(output_dir,"openvox_editor_services_v#{version}.tar.gz")
230
+ Minitar.pack(file_list, Zlib::GzipWriter.new(File.open(tar_archive_file, 'wb')))
231
+ puts "Created #{tar_archive_file}"
232
+
233
+ puts "Creating checksums..."
234
+ [zip_archive_file, tar_archive_file].each do |filepath|
235
+ sha = Digest::SHA256.hexdigest(File.open(filepath, 'rb') { |file| file.read })
236
+ File.open(filepath + '.sha256', 'wb') { |file| file.write(sha) }
237
+ end
238
+ puts "Created checksums"
239
+
240
+ puts 'Building gem..'
241
+ require 'bundler/gem_tasks'
242
+ Rake::Task['build'].invoke
243
+ puts 'Gem built'
244
+ end
245
+
246
+ task :default => [:test]
247
+
248
+ begin
249
+ require 'rubygems'
250
+ require 'github_changelog_generator/task'
251
+ rescue LoadError
252
+ else
253
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
254
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog dependencies]
255
+ config.user = 'voxpupuli'
256
+ config.project = 'openvox-editor-services'
257
+ gem_version = Gem::Specification.load("#{config.project}.gemspec").version
258
+ config.future_release = "#{gem_version}"
259
+ end
260
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_debugserver'
5
+
6
+ options = PuppetDebugServer::CommandLineParser.parse(ARGV)
7
+ PuppetDebugServer.init_puppet(options)
8
+ PuppetDebugServer.execute(PuppetDebugServer.rpc_server_async(options))
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_languageserver'
5
+
6
+ options = PuppetLanguageServer::CommandLineParser.parse(ARGV)
7
+ PuppetLanguageServer.init_puppet(options)
8
+ PuppetLanguageServer.rpc_server(options)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_languageserver_sidecar'
5
+
6
+ options = PuppetLanguageServerSidecar::CommandLineParser.parse(ARGV)
7
+ PuppetLanguageServerSidecar.init_puppet_sidecar(options)
8
+ PuppetLanguageServerSidecar.execute_and_output(options)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_debugserver'
5
+
6
+ PuppetDebugServer.init_puppet(PuppetDebugServer::CommandLineParser.parse(ARGV))
7
+ rpc_thread = PuppetDebugServer.rpc_server_async(PuppetDebugServer::CommandLineParser.parse(ARGV))
8
+ PuppetDebugServer.execute(rpc_thread)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_languageserver'
5
+
6
+ PuppetLanguageServer.init_puppet(PuppetLanguageServer::CommandLineParser.parse(ARGV))
7
+ PuppetLanguageServer.rpc_server(PuppetLanguageServer::CommandLineParser.parse(ARGV))
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'puppet_languageserver_sidecar'
5
+
6
+ PuppetLanguageServerSidecar.init_puppet_sidecar(PuppetLanguageServerSidecar::CommandLineParser.parse(ARGV))
7
+ PuppetLanguageServerSidecar.execute_and_output(PuppetLanguageServerSidecar::CommandLineParser.parse(ARGV))
data/lib/dsp/dsp.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[dsp_base dsp_protocol].each do |lib|
4
+ require "dsp/#{lib}"
5
+ rescue LoadError
6
+ require File.expand_path(File.join(__dir__, lib))
7
+ end