Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metanorma/metanorma#202 add socksify dependency and support SOCKS_PROXY env var #247

Merged
merged 2 commits into from Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions exe/metanorma
Expand Up @@ -11,10 +11,26 @@ $:.unshift File.expand_path("../../lib", bin_file)
# Fixes https://github.com/rubygems/rubygems/issues/1420
require "rubygems/specification"

class Gem::Specification
def this; self; end
module Gem
class Specification
def this; self; end
end
end

# start up the CLI
require "metanorma/cli"
Metanorma::Cli.start(ARGV)
metanorma_cli = proc { Metanorma::Cli.start(ARGV) }
if ENV["SOCKS_PROXY"]
require "socksify"
require "uri"
begin
proxy = URI.parse(ENV["SOCKS_PROXY"])
Socksify::proxy(proxy.host, proxy.port, &metanorma_cli)
rescue URI::InvalidURIError
warn "Value of ENV.SOCKS_PROXY=#{ENV['SOCKS_PROXY']} is invalid! Droping it"
ENV.delete("SOCKS_PROXY")
metanorma_cli.call
end
else
metanorma_cli.call
end
7 changes: 3 additions & 4 deletions lib/metanorma/cli/git_template.rb
Expand Up @@ -10,16 +10,15 @@ def initialize(name, options = {})

def remove!
remove_template
return true
true
end

def download
remove!
clone_git_template(options[:repo])

rescue Git::GitExecuteError
UI.say("Invalid template reoository!")
return nil
nil
end

def find_or_download
Expand Down Expand Up @@ -86,7 +85,7 @@ def git_repos
iso: "https://github.com/metanorma/mn-templates-iso",
iec: "https://github.com/metanorma/mn-templates-iec",
itu: "https://github.com/metanorma/mn-templates-itu",
ietf: "https://github.com/metanorma/mn-templates-ietf"
ietf: "https://github.com/metanorma/mn-templates-ietf",
}
end

Expand Down
2 changes: 2 additions & 0 deletions metanorma-cli.gemspec
Expand Up @@ -58,4 +58,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "metanorma-ogc", "~> 1.3.0"
spec.add_runtime_dependency "metanorma-un", "~> 0.6.0"
spec.add_runtime_dependency "relaton-cli", ">= 0.8.2"

spec.add_runtime_dependency "socksify"
end