s3_website 2.1.8 → 2.1.9

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: fc1d24823a0b30335a6524aa084cee24dfe3a083
4
- data.tar.gz: f2d937e8222f7fab6185e6102772a32d7a689b44
3
+ metadata.gz: df1cb093bdc6d3949cb078641ce7386c282d682d
4
+ data.tar.gz: 869a59a879784cc67b29c44841dd48ed340385fb
5
5
  SHA512:
6
- metadata.gz: 1f564e6c389241b88e34ff261bb7e0b67bdc3744dae3e3f7dd69a5f448677fe1161496a3426d31f64ade4bf8bd73199a19e4b9ef5528b04db333afcc260019d3
7
- data.tar.gz: 03fe8d69bcc38e4e3e6992b8c9b7618ed3a5ff24a66d47dc32142efce31e2d494044796b3aa929fe593a2b992e22cbd45eb1e7cb34aae31b228684327f7a4c1a
6
+ metadata.gz: 5a0a88d0fa9418eb8eb36c4c293499f6368a07b6a1c90da4fe2f058a1e298f01f42ca37f20bfe661177e40514620bc9e5100a29018ae9550f13959a080757ef5
7
+ data.tar.gz: 1519465c473c2eaae724ef3de7722a68d9d81790680b2cd1c7f8af71a2210ace0b5cce6470dbc9cd3df118d202dd0f4a60e042a955db3485d68fd98de317dcea
data/bin/s3_website CHANGED
@@ -72,29 +72,47 @@ class Cli < Thor
72
72
  def push
73
73
  project_root = File.expand_path(File.dirname(__FILE__)+ '/..')
74
74
  logger = Logger.new(options[:verbose])
75
- # Find the jar
76
- jar_file = resolve_jar project_root, logger
77
- # Then run it
78
- run_s3_website_jar(jar_file, logger)
75
+ success =
76
+ if run_with_sbt(project_root)
77
+ Dir.chdir(project_root) {
78
+ system './sbt assembly' # Build the jar
79
+ }
80
+ system "java -cp #{project_root}/target/scala-2.11/s3_website.jar #{resolve_java_command 'push'}"
81
+ else
82
+ # Find the jar
83
+ jar_file = resolve_jar(project_root, logger)
84
+ # Then run it
85
+ run_s3_website_jar(jar_file, logger)
86
+ end
87
+
88
+ if success
89
+ exit 0
90
+ else
91
+ exit 1
92
+ end
79
93
  end
80
94
 
81
95
  desc 'cfg SUBCOMMAND ...ARGS', 'Operate on the config file'
82
96
  subcommand 'cfg', Cfg
83
97
  end
84
98
 
99
+ def run_with_sbt(project_root)
100
+ File.exists? (project_root + '/project/sbt-launch.jar')
101
+ end
102
+
103
+ def resolve_java_command(command_name)
104
+ args = ARGV.join(' ').sub(command_name, '')
105
+ "s3.website.#{command_name.capitalize} #{args}"
106
+ end
107
+
85
108
  def run_s3_website_jar(jar_file, logger)
86
109
  java_installed = resolve_exit_status('which java') or resolve_exit_status('java -version')
87
110
  unless java_installed
88
111
  logger.info_msg "Cannot find Java. s3_website push is implemented in Scala, and it needs Java to run."
89
112
  autoinstall_java_or_print_help_and_exit(logger)
90
113
  end
91
- args = ARGV.join(' ').sub('push', '')
92
114
  logger.debug_msg "Using #{jar_file}"
93
- if system("java -cp #{jar_file} s3.website.Push #{args}")
94
- exit 0
95
- else
96
- exit 1
97
- end
115
+ system("java -cp #{jar_file} #{resolve_java_command 'push'}")
98
116
  end
99
117
 
100
118
  def resolve_exit_status(cmd)
@@ -146,13 +164,11 @@ def autoinstall_java_or_print_help_and_exit(logger)
146
164
  end
147
165
 
148
166
  def resolve_jar(project_root, logger)
149
- development_jar_path =
150
- project_root + '/target/scala-2.11/s3_website.jar'
151
- released_jar_lookup_paths = [
167
+ jar_lookup_paths = [
152
168
  project_root + "/s3_website-#{S3Website::VERSION}.jar",
153
169
  (ENV['TMPDIR'] || '/tmp') + "/s3_website-#{S3Website::VERSION}.jar"
154
170
  ]
155
- found_jar = ([development_jar_path] + released_jar_lookup_paths).
171
+ found_jar = jar_lookup_paths.
156
172
  select { |jar_path|
157
173
  File.exists? jar_path
158
174
  }.
@@ -171,25 +187,17 @@ def resolve_jar(project_root, logger)
171
187
  if found_jar and jar_has_valid_checksum(found_jar, logger)
172
188
  found_jar
173
189
  else
174
- is_development = File.exists?(project_root + '/.git')
175
- if is_development
176
- Dir.chdir(project_root) {
177
- system "./sbt assembly"
178
- }
179
- development_jar_path
180
- else
181
- download_jar(released_jar_lookup_paths, logger)
182
- end
190
+ download_jar(jar_lookup_paths, logger)
183
191
  end
184
192
  end
185
193
 
186
- def download_jar(released_jar_lookup_paths, logger)
194
+ def download_jar(jar_lookup_paths, logger)
187
195
  tag_name = "v#{S3Website::VERSION}"
188
- downloaded_jar = released_jar_lookup_paths.select { |jar_path|
196
+ downloaded_jar = jar_lookup_paths.select { |jar_path|
189
197
  File.writable? File.dirname(jar_path)
190
198
  }.first
191
199
  unless downloaded_jar
192
- logger.fail_msg "Neither #{released_jar_lookup_paths.join ' or '} is writable. Cannot download s3_website.jar."
200
+ logger.fail_msg "Neither #{jar_lookup_paths.join ' or '} is writable. Cannot download s3_website.jar."
193
201
  logger.fail_msg "Set either directory as writable to the current user and try again."
194
202
  exit 1
195
203
  end
data/changelog.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 2.1.9
6
+
7
+ * Separate development and production code more clearly in the s3_website
8
+ executable
9
+
5
10
  ## 2.1.8
6
11
 
7
12
  * Remove unused code in the s3_website executable
@@ -1,3 +1,3 @@
1
1
  module S3Website
2
- VERSION = '2.1.8'
2
+ VERSION = '2.1.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8
4
+ version: 2.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki