firespring_dev_commands 2.1.28 → 2.1.29.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/firespring_dev_commands/docker.rb +41 -16
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87729055135e487595d40ce6629354b1fc473ae963383965e2b5570c9938055c
|
4
|
+
data.tar.gz: adcc648f8bcbfd326b5aad54dc7868dc2ee93c3d18e7483f98eb8d5e98ff5d14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab9a8f2b52c1711e338917077aed4c32fa77b65da6518908c04f52e7f119a2abae8f5117e594d1e69597b889a385682d5e0e23d806ec56a3f328355185942e4
|
7
|
+
data.tar.gz: e8c21faaf030c75f1dccda8308ef15b5ada63e4ef6c2bd3f0a529f62b8300f062fc8286e948b74461ae442f89a893f43d8dfe36ca8e72a9a009ef44a6d3b9863
|
@@ -182,28 +182,53 @@ module Dev
|
|
182
182
|
end
|
183
183
|
|
184
184
|
# Copies the source path on your local machine to the destination path on the container
|
185
|
-
def copy_to_container(container,
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
185
|
+
def copy_to_container(container, source, destination)
|
186
|
+
# Add the working dir of the container onto the destination (if it doesn't start a path separator)
|
187
|
+
destination = File.join(working_dir(container), destination) unless destination.start_with?(File::SEPARATOR)
|
188
|
+
LOG.info "Copying #{source} to #{destination}..."
|
189
|
+
|
190
|
+
# Need to determine the type of the destination (file or directory or nonexistant)
|
191
|
+
noexist_code = 22
|
192
|
+
file_code = 33
|
193
|
+
directory_code = 44
|
194
|
+
unknown_code = 55
|
195
|
+
filetype_cmd = [
|
196
|
+
'bash',
|
197
|
+
'-c',
|
198
|
+
"set -e; [ ! -e '#{destination}' ] && exit #{noexist_code}; [ -f '#{destination}' ] " \
|
199
|
+
"&& exit #{file_code}; [ -d '#{destination}' ] && exit #{directory_code}; exit #{unknown_code}"
|
200
|
+
]
|
201
|
+
destination_filetype_code = container.exec(filetype_cmd).last
|
202
|
+
|
203
|
+
# If destination_filetype_code is a file - that means the user passed in a destination filename
|
204
|
+
# Unfortunately the archive_in command does not support that so we will strip it off and use it later (if needed)
|
205
|
+
source_filename = File.basename(source)
|
206
|
+
destination_filename = File.basename(source)
|
207
|
+
destination, _, destination_filename = destination.rpartition(File::SEPARATOR) if destination_filetype_code == file_code
|
208
|
+
|
209
|
+
container.archive_in(source, destination, overwrite: true)
|
210
|
+
|
211
|
+
if File.directory?(source)
|
212
|
+
# If the source was a directory, then the archive_in command leaves it as a tar on the system - so we need to unpack it
|
213
|
+
# TODO: Can we find a better solution for this? Seems pretty brittle
|
214
|
+
retcode = container.exec(['bash', '-c', "cd #{destination}; tar -xf #{destination_filename}; rm -f #{destination_filename}"]).last
|
215
|
+
raise 'Unable to unpack on container' unless retcode.zero?
|
216
|
+
elsif destination_filetype_code == file_code && source_filename != destination_filename
|
217
|
+
# If the destination was a file _and_ the filename is different than the source filename, then we need to rename it
|
218
|
+
retcode = container.exec(['bash', '-c', "cd #{destination}; mv #{source_filename} #{destination_filename}"]).last
|
219
|
+
raise "Unable to rename '#{source_filename}' to '#{destination_filename}' on container" unless retcode.zero?
|
220
|
+
end
|
196
221
|
end
|
197
222
|
|
198
223
|
# Copies the source path on the container to the destination path on your local machine
|
199
224
|
# If required is set to true, the command will fail if the source path does not exist on the container
|
200
|
-
def copy_from_container(container,
|
201
|
-
|
202
|
-
LOG.info "Copying #{
|
225
|
+
def copy_from_container(container, source, destination, required: true)
|
226
|
+
source = File.join(working_dir(container), source) unless source.start_with?(File::SEPARATOR)
|
227
|
+
LOG.info "Copying #{source} to #{destination}..."
|
203
228
|
|
204
229
|
tar = StringIO.new
|
205
230
|
begin
|
206
|
-
container.archive_out(
|
231
|
+
container.archive_out(source) do |chunk|
|
207
232
|
tar.write(chunk)
|
208
233
|
end
|
209
234
|
rescue => e
|
@@ -212,7 +237,7 @@ module Dev
|
|
212
237
|
puts 'Not Found'
|
213
238
|
end
|
214
239
|
|
215
|
-
Dev::Tar.new(tar).unpack(
|
240
|
+
Dev::Tar.new(tar).unpack(source, destination)
|
216
241
|
end
|
217
242
|
|
218
243
|
# rubocop:disable Metrics/ParameterLists
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.29.pre.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -412,9 +412,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
412
412
|
version: '3.1'
|
413
413
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
414
414
|
requirements:
|
415
|
-
- - "
|
415
|
+
- - ">"
|
416
416
|
- !ruby/object:Gem::Version
|
417
|
-
version:
|
417
|
+
version: 1.3.1
|
418
418
|
requirements: []
|
419
419
|
rubygems_version: 3.4.10
|
420
420
|
signing_key:
|