zendesk_apps_tools 1.35.11 → 1.35.12

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: b590166d112e3309f57870547f57b7e51921d703
4
- data.tar.gz: fbb76bd83735b89783189a77581c683a871c5956
3
+ metadata.gz: be55a0877485f6d34b67d629a6a1ca3562d121f9
4
+ data.tar.gz: 56ade4847ce3103595920229fcb26511a622f80a
5
5
  SHA512:
6
- metadata.gz: 5cf45f3def67a621d420b31bd4895b7a94892dd25583405a6db415b26773834089d1a0d65e06475ddcac0c42a2bc217a9319131e919a95dc23aa9a08b10148fb
7
- data.tar.gz: 23ddeac568077a45abfe5ae321ba59667652b4a939ab59c91d265fb344eea684615699e7c8b995cc0e03114b36e41093266723483aea0aefd8898dddf1f0be84
6
+ metadata.gz: 2a95c5c105d438134efbfe8b3331320af32026f0619cd5870a5679eeaacf51c07dd62a7f5aeeca9f39ab88fa93d7bb725a3a41eff57176a3d71517b0e6352a7a
7
+ data.tar.gz: aa19c646749f82cc54480117efd0d6eb026baec280c7fe51b2271f2d5607708511446069d74b2f39043fda2ee2bdfffd2295a782c2709abfdb55aff4db905e16
@@ -121,11 +121,11 @@ module ZendeskAppsTools
121
121
  DEFAULT_APP_ID = 0
122
122
 
123
123
  desc 'server', 'Run a http server to serve the local app'
124
- method_option :path, default: DEFAULT_SERVER_PATH, required: false, aliases: '-p'
124
+ shared_options(except: [:clean])
125
125
  method_option :config, default: DEFAULT_CONFIG_PATH, required: false, aliases: '-c'
126
126
  method_option :port, default: DEFAULT_SERVER_PORT, required: false
127
127
  method_option :app_id, default: DEFAULT_APP_ID, required: false
128
- method_option :bind, default: "127.0.0.1", required: false
128
+ method_option :bind, required: false
129
129
  def server
130
130
  setup_path(options[:path])
131
131
  manifest = app_package.manifest
@@ -142,7 +142,7 @@ module ZendeskAppsTools
142
142
  require 'zendesk_apps_tools/server'
143
143
  ZendeskAppsTools::Server.tap do |server|
144
144
  server.set :settings_helper, settings_helper
145
- server.set :bind, options[:bind]
145
+ server.set :bind, options[:bind] if options[:bind]
146
146
  server.set :port, options[:port]
147
147
  server.set :root, options[:path]
148
148
  server.set :public_folder, File.join(options[:path], 'assets')
@@ -38,29 +38,31 @@ module ZendeskAppsTools
38
38
  end
39
39
 
40
40
  def get_value_from_stdin(prompt, opts = {})
41
- error_if_unattended(prompt)
42
- options = {
43
- valid_regex: opts[:allow_empty] ? /^.*$/ : /\S+/,
44
- error_msg: 'Invalid, try again:',
45
- allow_empty: false
46
- }.merge(opts)
41
+ error_or_default_if_unattended(prompt, opts) do
42
+ options = {
43
+ valid_regex: opts[:allow_empty] ? /^.*$/ : /\S+/,
44
+ error_msg: 'Invalid, try again:',
45
+ allow_empty: false
46
+ }.merge(opts)
47
47
 
48
- thor_options = { default: options[:default] }
48
+ thor_options = { default: options[:default] }
49
49
 
50
- while input = ask(prompt, thor_options)
51
- return '' if options[:allow_empty] && input.empty?
52
- break if input.to_s =~ options[:valid_regex]
53
- say_error options[:error_msg]
54
- end
50
+ while input = ask(prompt, thor_options)
51
+ return '' if options[:allow_empty] && input.empty?
52
+ break if input.to_s =~ options[:valid_regex]
53
+ say_error options[:error_msg]
54
+ end
55
55
 
56
- input
56
+ input
57
+ end
57
58
  end
58
59
 
59
60
  def get_password_from_stdin(prompt)
60
- error_if_unattended(prompt)
61
- password = ask(prompt, echo: false)
62
- say ''
63
- password
61
+ error_or_default_if_unattended(prompt) do
62
+ password = ask(prompt, echo: false)
63
+ say ''
64
+ password
65
+ end
64
66
  end
65
67
 
66
68
  def json_or_die(value)
@@ -72,10 +74,14 @@ module ZendeskAppsTools
72
74
 
73
75
  private
74
76
 
75
- def error_if_unattended(prompt)
76
- return unless options[:unattended]
77
- say_error 'Would have prompted for a value interactively, but we are running unattended.'
78
- say_error_and_exit prompt
77
+ def error_or_default_if_unattended(prompt, opts = {})
78
+ if options[:unattended]
79
+ return opts[:default] if opts.key? :default
80
+ say_error 'Would have prompted for a value interactively, but zat is not listening to keyboard input.'
81
+ say_error_and_exit prompt
82
+ else
83
+ yield
84
+ end
79
85
  end
80
86
  end
81
87
  end
@@ -4,8 +4,8 @@ require 'zendesk_apps_support/package'
4
4
 
5
5
  module ZendeskAppsTools
6
6
  class Server < Sinatra::Base
7
- set :protection, :except => :frame_options
8
- ZENDESK_DOMAINS_REGEX = /^http(?:s)?:\/\/[a-z0-9-]+\.(?:zendesk|zopim|zd-(?:dev|master|staging))\.com$/
7
+ set :protection, except: :frame_options
8
+ ZENDESK_DOMAINS_REGEX = %r{^http(?:s)?://[a-z0-9-]+\.(?:zendesk|zopim|zd-(?:dev|master|staging))\.com$}
9
9
 
10
10
  get '/app.js' do
11
11
  access_control_allow_origin
@@ -44,18 +44,23 @@ module ZendeskAppsTools
44
44
  super(*args)
45
45
  end
46
46
 
47
+ def request_from_zendesk?
48
+ request.env['HTTP_ORIGIN'] =~ ZENDESK_DOMAINS_REGEX
49
+ end
50
+
47
51
  # This is for any preflight request
48
52
  # It reads 'Access-Control-Request-Headers' to set 'Access-Control-Allow-Headers'
49
53
  # And also sets 'Access-Control-Allow-Origin' header
50
- options "*" do
54
+ options '*' do
51
55
  access_control_allow_origin
52
- headers 'Access-Control-Allow-Headers' => request.env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] if request.env['HTTP_ORIGIN'] =~ ZENDESK_DOMAINS_REGEX
56
+ if request_from_zendesk?
57
+ headers 'Access-Control-Allow-Headers' => request.env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']
58
+ end
53
59
  end
54
60
 
55
61
  # This sets the 'Access-Control-Allow-Origin' header for requests coming from zendesk
56
62
  def access_control_allow_origin
57
- origin = request.env['HTTP_ORIGIN']
58
- headers 'Access-Control-Allow-Origin' => origin if origin =~ ZENDESK_DOMAINS_REGEX
63
+ headers 'Access-Control-Allow-Origin' => request.env['HTTP_ORIGIN'] if request_from_zendesk?
59
64
  end
60
65
  end
61
66
  end
@@ -10,7 +10,7 @@ module ZendeskAppsTools
10
10
  return {} if parameters.nil?
11
11
 
12
12
  parameters.inject({}) do |settings, param|
13
- if param['default']
13
+ if param.key? 'default'
14
14
  input = @cli.get_value_from_stdin("Enter a value for parameter '#{param['name']}':\n", default: param['default'])
15
15
  elsif param['required']
16
16
  input = @cli.get_value_from_stdin("Enter a value for required parameter '#{param['name']}':\n")
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ZendeskAppsTools
3
- VERSION = '1.35.11'
3
+ VERSION = '1.35.12'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.35.11
4
+ version: 1.35.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-11-17 00:00:00.000000000 Z
14
+ date: 2016-11-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  version: 1.3.6
254
254
  requirements: []
255
255
  rubyforge_project:
256
- rubygems_version: 2.5.1
256
+ rubygems_version: 2.6.8
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: Tools to help you develop Zendesk Apps.