|
|
@ -158,8 +158,14 @@ class DocsCLI < Thor
|
|
|
|
option :packaged, type: :boolean
|
|
|
|
option :packaged, type: :boolean
|
|
|
|
def upload(*names)
|
|
|
|
def upload(*names)
|
|
|
|
require 'net/sftp'
|
|
|
|
require 'net/sftp'
|
|
|
|
names = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') } if options[:packaged]
|
|
|
|
|
|
|
|
docs = find_docs(names)
|
|
|
|
if options[:packaged]
|
|
|
|
|
|
|
|
slugs = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') }
|
|
|
|
|
|
|
|
docs = find_docs_by_slugs(slugs)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
docs = find_docs(names)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
assert_docs(docs)
|
|
|
|
assert_docs(docs)
|
|
|
|
|
|
|
|
|
|
|
|
# Sync files with S3 (used by the web app)
|
|
|
|
# Sync files with S3 (used by the web app)
|
|
|
@ -251,6 +257,13 @@ class DocsCLI < Thor
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_docs_by_slugs(slugs)
|
|
|
|
|
|
|
|
slugs.flat_map do |slug|
|
|
|
|
|
|
|
|
slug, version = slug.split(/~/)
|
|
|
|
|
|
|
|
Docs.find_by_slug(slug, version)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def assert_docs(docs)
|
|
|
|
def assert_docs(docs)
|
|
|
|
if docs.empty?
|
|
|
|
if docs.empty?
|
|
|
|
puts 'ERROR: called with no arguments.'
|
|
|
|
puts 'ERROR: called with no arguments.'
|
|
|
|