haplo 2.2.0-java → 2.2.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c0a878dd42f37f3aec318b396740eb2673cb94d
4
- data.tar.gz: 24bba608eb2e1aa21b5def4f12f8965e0e31e6e9
3
+ metadata.gz: 8aa2dd9157c3175e9f8d3fed20a596874c05d9b0
4
+ data.tar.gz: 8361a1db6e8c4f42836440501a2f988ccfbdffd3
5
5
  SHA512:
6
- metadata.gz: eeb2c6fe5e9c54846f8c8b7c697981adda3cd20b5ab45ca032597b9ac174c5d0b3a7f545c5a79677b88a4d2249099664f90d177514f0568521857e14f5fcfc4a
7
- data.tar.gz: ac136d52d8c9a2bacef648d826d72f142ef640c91b9e47f805f686bf062554ea6b7a65c85b545eec6b9d9e008b2e04858b6bd620a3b3b580caa5d312dd4cdd26
6
+ metadata.gz: b42f10605846cb71233fbfc65f6389e3d0e149a196bd60aef9f153f41ff57d70043021e406988f78833de936bd0cb2a96939773a153b946e26c8d69f301ffcd4
7
+ data.tar.gz: 919e97ab82fea366431ea02ee191c2f45146ab870ef5cd22fe8e471826ea148f8f947232f26b7e5f9a444bab4f556ddfe2425088014001daa0281ba2b017ab81
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  files = Dir.glob("#{root_dir}/**/*.*").map { |x| x[root_dir.length + 1, x.length]}
4
4
 
5
5
  s.name = 'haplo'
6
- s.version = '2.2.0'
7
- s.date = '2016-05-13'
6
+ s.version = '2.2.1'
7
+ s.date = '2016-05-16'
8
8
  s.summary = "Haplo Plugin Tool"
9
9
  s.description = "Development tools for developing Haplo plugins, see http://haplo.org"
10
10
  s.licenses = ["MPL-2.0"]
@@ -16,10 +16,9 @@ end
16
16
 
17
17
  PluginTool.try_load_custom
18
18
 
19
- PluginTool::LocalConfig.load
20
-
21
- # Commands not needing server
22
- LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true}
19
+ WORKSPACE_FILE = 'workspace.json'
20
+ LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true, "new" => true}
21
+ NO_DEPENDENCY_COMMANDS = LOCAL_ONLY_COMMANDS.dup
23
22
  PLUGIN_SEARCH_PATH = ['.']
24
23
 
25
24
  # Options for passing to plugin objects
@@ -27,11 +26,9 @@ options = Struct.new(:output, :minimiser, :no_dependency, :no_console, :show_sys
27
26
 
28
27
  # Parse arguments
29
28
  show_help = false
30
- workspace_file = nil
31
29
  requested_plugins = []
32
30
  opts = GetoptLong.new(
33
31
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
34
- ['--workspace', '-w', GetoptLong::REQUIRED_ARGUMENT],
35
32
  ['--plugin', '-p', GetoptLong::OPTIONAL_ARGUMENT],
36
33
  ['--no-dependency', GetoptLong::NO_ARGUMENT],
37
34
  ['--server', '-s', GetoptLong::REQUIRED_ARGUMENT],
@@ -46,8 +43,6 @@ opts.each do |opt, argument|
46
43
  case opt
47
44
  when '--help'
48
45
  show_help = true
49
- when '--workspace'
50
- workspace_file = argument
51
46
  when '--plugin'
52
47
  requested_plugins = argument.split(',').map {|n| n.gsub(/[\/\\]+\z/,'')} # remove trailing dir separators
53
48
  when '--no-dependency'
@@ -71,17 +66,14 @@ PLUGIN_TOOL_COMMAND = (ARGV.shift || 'develop')
71
66
  options.args = ARGV
72
67
 
73
68
  # Parse workspace file
74
- if workspace_file
75
- workspace_json = JSON.parse(File.read(workspace_file))
76
- if workspace_json.has_key?("base")
77
- workspace_base_json = JSON.parse(File.read(File.dirname(workspace_file)+'/'+workspace_json["base"]))
78
- workspace_json = workspace_base_json.merge(workspace_json)
79
- end
69
+ auto_uninstall_unexpected_plugins = false
70
+ if File.exist?(WORKSPACE_FILE)
71
+ workspace_json = JSON.parse(File.read(WORKSPACE_FILE))
80
72
  if workspace_json.has_key?("search")
81
73
  PLUGIN_SEARCH_PATH.clear
82
74
  workspace_json["search"].each do |entry|
83
75
  if entry.has_key?("path")
84
- path = File.expand_path(File.dirname(workspace_file)+'/'+entry["path"])
76
+ path = File.expand_path('./'+entry["path"])
85
77
  unless Dir.exist?(path)
86
78
  puts "Can't find directory: #{path}"
87
79
  puts " #{entry["name"]}" if entry.has_key?("name")
@@ -92,15 +84,11 @@ if workspace_file
92
84
  end
93
85
  end
94
86
  end
95
- if workspace_json.has_key?("plugins")
96
- if requested_plugins.empty?
97
- requested_plugins = workspace_json["plugins"]
98
- end
87
+ if workspace_json.has_key?("autoUninstallPlugins")
88
+ auto_uninstall_unexpected_plugins= !!(workspace_json["autoUninstallPlugins"])
99
89
  end
100
90
  end
101
91
 
102
- automatic_plugin_exclusion = false
103
-
104
92
  # Help message?
105
93
  if show_help || PLUGIN_TOOL_COMMAND == 'help'
106
94
  puts File.open("#{File.dirname(__FILE__)}/usage.txt") { |f| f.read }
@@ -119,7 +107,6 @@ end
119
107
 
120
108
  if plugin_paths.length == 1 && plugin_paths[0] == 'ALL'
121
109
  plugin_paths = find_all_plugins()
122
- automatic_plugin_exclusion = true
123
110
  end
124
111
 
125
112
  # Some commands don't require a server or plugin to be specified
@@ -137,9 +124,24 @@ when 'server'
137
124
  exit 0
138
125
  end
139
126
 
140
- # Check that the user requested a plugin
127
+ # Set up server communications and get application info
128
+ application_info = nil
129
+ unless LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND]
130
+ PluginTool.setup_auth(options)
131
+ PluginTool.check_for_certificate_file
132
+ application_info = PluginTool.get_application_info
133
+ puts "Remote application name: #{(application_info["name"]||'').to_s.strip.gsub(/\s+/,' ')}"
134
+ end
135
+
136
+ # If the user didn't requested a plugin, try to use the application info to select the root plugin
137
+ if requested_plugins.empty? && application_info
138
+ application_root_plugin = application_info["config"]["applicationRootPlugin"]
139
+ if application_root_plugin
140
+ requested_plugins = [application_root_plugin.to_s]
141
+ end
142
+ end
141
143
  if requested_plugins.empty?
142
- end_on_error "No plugin specified, use -p plugin_name to specify or use workspace"
144
+ end_on_error "No plugin specified and remote application isn't configured with an application root plugin, use -p plugin_name to specify"
143
145
  end
144
146
 
145
147
  def find_plugin_in_list(list, name)
@@ -147,20 +149,20 @@ def find_plugin_in_list(list, name)
147
149
  end
148
150
 
149
151
  # Make plugin objects, start them, sort by order the server will load them
150
- plugins = plugin_paths.map do |path|
152
+ ALL_PLUGINS = plugin_paths.map do |path|
151
153
  PluginTool::Plugin.new(path, options)
152
154
  end
153
- unless requested_plugins == ["ALL"]
154
- selected_plugins = plugins.select { |plugin| requested_plugins.include?(plugin.name) }
155
+ def plugins_with_dependencies(plugin_names, no_dependency=false)
156
+ selected_plugins = ALL_PLUGINS.select { |plugin| plugin_names.include?(plugin.name) }
155
157
  # Attempt to resolve dependencies
156
- unless options.no_dependency
158
+ unless no_dependency
157
159
  while true
158
160
  selected_plugins_expanded = selected_plugins.dup
159
161
  selected_plugins.each do |plugin|
160
162
  plugin.depend.each do |name|
161
163
  unless name =~ /\Astd_/
162
164
  unless find_plugin_in_list(selected_plugins_expanded, name)
163
- add_plugin = find_plugin_in_list(plugins, name)
165
+ add_plugin = find_plugin_in_list(ALL_PLUGINS, name)
164
166
  if add_plugin
165
167
  selected_plugins_expanded << add_plugin
166
168
  else
@@ -174,11 +176,58 @@ unless requested_plugins == ["ALL"]
174
176
  selected_plugins = selected_plugins_expanded
175
177
  end
176
178
  end
177
- plugins = selected_plugins
179
+ selected_plugins
180
+ end
181
+
182
+ if requested_plugins == ["ALL"]
183
+ plugins = ALL_PLUGINS.dup
184
+ else
185
+ plugins = plugins_with_dependencies(requested_plugins, options.no_dependency || NO_DEPENDENCY_COMMANDS[PLUGIN_TOOL_COMMAND])
178
186
  end
179
187
  if plugins.length == 0
180
188
  end_on_error "No plugins selected, check -p option (requested: #{requested_plugins.join(',')})"
181
189
  end
190
+
191
+ # Check requested plugins should be installed on this server
192
+ unless LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND]
193
+ application_root_plugin = application_info["config"]["applicationRootPlugin"]
194
+ if application_root_plugin
195
+ root_plugin_dependent_plugins = plugins_with_dependencies([application_root_plugin.to_s])
196
+ root_plugin_dependent_plugin_names = root_plugin_dependent_plugins.map { |p| p.name }
197
+ # Check for plugins which aren't dependents of this plugin, as user might be uploading plugins
198
+ # in error and break their development application.
199
+ bad_plugin_requests = false
200
+ plugins.each do |plugin|
201
+ unless root_plugin_dependent_plugin_names.include?(plugin.name)
202
+ puts "Not a dependent of the application root plugin: #{plugin.name}"
203
+ bad_plugin_requests = true
204
+ end
205
+ end
206
+ # Error if any of the requested plugins aren't in this list
207
+ if bad_plugin_requests
208
+ end_on_error("Stopping because some requested plugins are not dependents of the application root plugin: #{application_root_plugin}")
209
+ end
210
+ # So that you can switch between repo branchs without worrying about having to
211
+ # uninstall the plugins in that branch, there's an option to remove anything
212
+ # that's not expected.
213
+ if auto_uninstall_unexpected_plugins
214
+ application_info["installedPlugins"].each do |name|
215
+ unless name =~ /\Astd_/
216
+ unless root_plugin_dependent_plugin_names.include?(name)
217
+ s_found_info = PluginTool.post_with_json_response("/api/development-plugin-loader/find-registration", {:name => name})
218
+ if s_found_info["found"]
219
+ puts "Uninstalling plugin #{name} from server..."
220
+ res = PluginTool.post_with_json_response("/api/development-plugin-loader/uninstall/#{s_found_info['plugin_id']}")
221
+ end_on_error "Couldn't uninstall plugin" unless res["result"] == 'success'
222
+ end
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
228
+ end
229
+
230
+ # Sort plugins by load order, and prepare local plugin objects
182
231
  plugins.each { |p| p.start }
183
232
  plugins.sort! do |a,b|
184
233
  pri_a = a.plugin_load_priority
@@ -200,25 +249,9 @@ when 'check'
200
249
  exit 0
201
250
  end
202
251
 
203
- # Set up server communications
252
+ # Set up local plugin objects against server
204
253
  unless LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND]
205
- PluginTool.setup_auth(options)
206
- PluginTool.check_for_certificate_file
207
-
208
254
  PluginTool.custom_behaviour.server_ready(plugins, PLUGIN_TOOL_COMMAND, options)
209
-
210
- if automatic_plugin_exclusion
211
- exclusions = PluginTool::LocalConfig.get_list("exclude")
212
- plugins = plugins.select do |plugin|
213
- if exclusions.include?(plugin.name)
214
- puts "NOTICE: Excluded plugin #{plugin.name}"
215
- false
216
- else
217
- true
218
- end
219
- end
220
- end
221
-
222
255
  plugins.each { |p| p.setup_for_server }
223
256
  end
224
257
 
data/lib/run.rb CHANGED
@@ -56,7 +56,6 @@ end
56
56
  require TEMPLATES_JAR
57
57
 
58
58
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/hmac.rb"
59
- require "#{PLUGIN_TOOL_ROOT_DIR}/lib/local_config.rb"
60
59
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/manifest.rb"
61
60
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/auth.rb"
62
61
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/server.rb"
@@ -1 +1 @@
1
- 6a8b347
1
+ 65c45bc
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haplo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: java
6
6
  authors:
7
7
  - Haplo Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Development tools for developing Haplo plugins, see http://haplo.org
14
14
  email: client.services@haplo-services.com
@@ -31,7 +31,6 @@ files:
31
31
  - lib/js_min.js
32
32
  - lib/js_syntax_test.js
33
33
  - lib/jshint.js
34
- - lib/local_config.rb
35
34
  - lib/manifest.rb
36
35
  - lib/minimise.rb
37
36
  - lib/misc.rb
@@ -1,34 +0,0 @@
1
- # Haplo Plugin Tool http://docs.haplo.org/dev/tool/plugin
2
- # (c) Haplo Services Ltd 2006 - 2016 http://www.haplo-services.com
3
- # This Source Code Form is subject to the terms of the Mozilla Public
4
- # License, v. 2.0. If a copy of the MPL was not distributed with this
5
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
-
7
-
8
- module PluginTool
9
-
10
- module LocalConfig
11
-
12
- LOCAL_CONFIG_FILENAME = "server.config.json"
13
-
14
- def self.load
15
- if File.exist? LOCAL_CONFIG_FILENAME
16
- @@local_config = JSON.parse(File.open(LOCAL_CONFIG_FILENAME) { |f| f.read })
17
- else
18
- @@local_config = {}
19
- end
20
- end
21
-
22
- def self.get_list(list_name)
23
- lookup = @@local_config[list_name]
24
- return [] unless lookup
25
- list = []
26
- server_name = PluginTool.get_server_hostname
27
- list.concat(lookup['*']) if lookup.has_key?('*')
28
- list.concat(lookup[server_name]) if server_name && lookup.has_key?(server_name)
29
- list
30
- end
31
-
32
- end
33
-
34
- end