gemstash 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/gemstash/cache.rb +2 -1
  4. data/lib/gemstash/cli/info.rb +29 -0
  5. data/lib/gemstash/cli/setup.rb +11 -3
  6. data/lib/gemstash/cli/start.rb +4 -0
  7. data/lib/gemstash/cli.rb +8 -0
  8. data/lib/gemstash/config.ru +2 -1
  9. data/lib/gemstash/configuration.rb +5 -0
  10. data/lib/gemstash/db/version.rb +0 -5
  11. data/lib/gemstash/env.rb +5 -2
  12. data/lib/gemstash/http_client.rb +2 -1
  13. data/lib/gemstash/logging.rb +4 -1
  14. data/lib/gemstash/man/gemstash-authorize.1 +36 -17
  15. data/lib/gemstash/man/gemstash-authorize.1.txt +15 -17
  16. data/lib/gemstash/man/gemstash-configuration.5 +136 -63
  17. data/lib/gemstash/man/gemstash-configuration.5.txt +80 -64
  18. data/lib/gemstash/man/gemstash-customize.7 +114 -61
  19. data/lib/gemstash/man/gemstash-customize.7.txt +56 -51
  20. data/lib/gemstash/man/gemstash-debugging.7 +27 -9
  21. data/lib/gemstash/man/gemstash-debugging.7.txt +6 -8
  22. data/lib/gemstash/man/gemstash-deploy.7 +39 -16
  23. data/lib/gemstash/man/gemstash-deploy.7.txt +19 -21
  24. data/lib/gemstash/man/gemstash-mirror.7 +31 -11
  25. data/lib/gemstash/man/gemstash-mirror.7.txt +6 -8
  26. data/lib/gemstash/man/gemstash-multiple-sources.7 +68 -35
  27. data/lib/gemstash/man/gemstash-multiple-sources.7.txt +20 -22
  28. data/lib/gemstash/man/gemstash-private-gems.7 +102 -52
  29. data/lib/gemstash/man/gemstash-private-gems.7.txt +31 -33
  30. data/lib/gemstash/man/gemstash-readme.7 +75 -30
  31. data/lib/gemstash/man/gemstash-readme.7.txt +24 -26
  32. data/lib/gemstash/man/gemstash-setup.1 +33 -14
  33. data/lib/gemstash/man/gemstash-setup.1.txt +12 -14
  34. data/lib/gemstash/man/gemstash-start.1 +23 -6
  35. data/lib/gemstash/man/gemstash-start.1.txt +5 -7
  36. data/lib/gemstash/man/gemstash-status.1 +23 -6
  37. data/lib/gemstash/man/gemstash-status.1.txt +6 -8
  38. data/lib/gemstash/man/gemstash-stop.1 +23 -6
  39. data/lib/gemstash/man/gemstash-stop.1.txt +5 -7
  40. data/lib/gemstash/man/gemstash-version.1 +24 -5
  41. data/lib/gemstash/man/gemstash-version.1.txt +1 -3
  42. data/lib/gemstash/puma.rb +2 -0
  43. data/lib/gemstash/specs_builder.rb +16 -2
  44. data/lib/gemstash/upstream.rb +1 -1
  45. data/lib/gemstash/version.rb +1 -1
  46. metadata +37 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28d034f028f3c57f42d3caa7eb9ac6d49e03d5004c327897b025df04502ed72c
4
- data.tar.gz: e9773d54c789184da719c94585cf28e832bc064866c5a53c78ecfa0071705c04
3
+ metadata.gz: 8f80b73d078f2392411200b75d9996704f7bbaea178db429992e74fa96b681a7
4
+ data.tar.gz: 21cac95f93c8cb94853ba20864b601d6d72abbc6e54df3f1eaae9d0bec1a9bab
5
5
  SHA512:
6
- metadata.gz: a14333d426e19d86375607d5127320a8675bc4f5112806a5f4c1ad5fcd27bb5e89e9588d2fbe91e1c13cf8681efd6769bf48cdfc8c472a499b7a518f5a930e0d
7
- data.tar.gz: 7bdd6cb9c797a47048371f66dac3cc23fd627cf72742c76ef36df373eb8e1c3a8aaccc6799d21c622fd9aead2262ffc5752210c645478b749bad0c9e1ec7405c
6
+ metadata.gz: 4beb40f63f25653547bef5e5518ff56e49a2d5eee97d69403775b0a9b95f3bbd472188eb0d5ec7ac5f3486d10f6f780afa363c9e66d9f825ecf650bc15b547f8
7
+ data.tar.gz: fc24ed09963daa42ac8e4224d1995e1ed5beb75c97b970c37cdafce0cf5ff9f3c26734c17d0e640dbd63b77f5cb2b5926139ca05b3cbb56c874066367bcc74c4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.7.1 (2023-10-12)
2
+
3
+ ### Fixes
4
+
5
+ - Reinstate NOOP --daemonize and --no-daemonize that warn about them doing nothing. ([#381](https://github.com/rubygems/gemstash/pull/381) [@olleolleolle](https://github.com/olleolleolle))
6
+
1
7
  ## 2.7.0 (2023-10-08)
2
8
 
3
9
  ### Fixes
@@ -101,9 +101,10 @@ module Gemstash
101
101
  end
102
102
 
103
103
  def get_multi(keys)
104
- @cache.mget(*keys).each do |k, v|
104
+ @cache.mget(*keys).each_with_index do |v, idx|
105
105
  next if v.nil?
106
106
 
107
+ k = keys[idx]
107
108
  yield(k, YAML.load(v))
108
109
  end
109
110
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "gemstash"
4
+ require "puma/control_cli"
5
+
6
+ module Gemstash
7
+ class CLI
8
+ # This implements the command line info task:
9
+ # $ gemstash info
10
+ class Info < Gemstash::CLI::Base
11
+ include Gemstash::Env::Helper
12
+ def run
13
+ prepare
14
+ list_config
15
+ end
16
+
17
+ private
18
+
19
+ def list_config
20
+ config = gemstash_env.config
21
+ config_str = +""
22
+ config.keys.map do |key|
23
+ config_str << "#{key}: #{config[key]}\n"
24
+ end
25
+ config_str
26
+ end
27
+ end
28
+ end
29
+ end
@@ -25,7 +25,8 @@ module Gemstash
25
25
  ask_cache
26
26
  ask_database
27
27
  ask_protected_fetch
28
- ask_timeout
28
+ ask_fetch_timeout
29
+ ask_open_timeout
29
30
  check_cache
30
31
  check_storage
31
32
  check_database
@@ -123,13 +124,20 @@ module Gemstash
123
124
  @config[:protected_fetch] = value
124
125
  end
125
126
 
126
- def ask_timeout
127
+ def ask_fetch_timeout
127
128
  say_current_config(:fetch_timeout, "Fetch timeout")
128
- timeout = @cli.ask "How many seconds to wait when fetching a gem? [20]"
129
+ timeout = @cli.ask "How many seconds to wait for fetching a gem to complete? [20]"
129
130
  timeout = Gemstash::Configuration::DEFAULTS[:fetch_timeout] if timeout.to_i < 1
130
131
  @config[:fetch_timeout] = timeout.to_i
131
132
  end
132
133
 
134
+ def ask_open_timeout
135
+ say_current_config(:open_timeout, "Open timeout")
136
+ timeout = @cli.ask "How many seconds to wait for connection to upstream gem server to be established? [2]"
137
+ timeout = Gemstash::Configuration::DEFAULTS[:open_timeout] if timeout.to_i < 1
138
+ @config[:open_timeout] = timeout.to_i
139
+ end
140
+
133
141
  def check_cache
134
142
  try("cache") { gemstash_env.cache_client.alive! }
135
143
  end
@@ -11,6 +11,10 @@ module Gemstash
11
11
  def run
12
12
  prepare
13
13
  @cli.say("Starting gemstash!", :green)
14
+ case @cli.options[:daemonize]
15
+ when false then warn "The --no-daemonize option was removed and has no effect."
16
+ when true then warn "The --daemonize option was removed and has no effect."
17
+ end
14
18
  Puma::CLI.new(args, Gemstash::Logging::StreamLogger.puma_events).run
15
19
  end
16
20
 
data/lib/gemstash/cli.rb CHANGED
@@ -13,6 +13,7 @@ module Gemstash
13
13
  autoload :Start, "gemstash/cli/start"
14
14
  autoload :Status, "gemstash/cli/status"
15
15
  autoload :Stop, "gemstash/cli/stop"
16
+ autoload :Info, "gemstash/cli/info"
16
17
 
17
18
  # Thor::Error for the CLI, which colors the message red.
18
19
  class Error < Thor::Error
@@ -75,6 +76,8 @@ module Gemstash
75
76
  end
76
77
 
77
78
  desc "start", "Starts your gemstash server"
79
+ method_option :daemonize, :type => :boolean, :default => nil, :desc =>
80
+ "No effect - functionality removed, option kept for compatibility"
78
81
  method_option :config_file, :type => :string, :desc =>
79
82
  "Config file to load when starting"
80
83
  def start
@@ -101,6 +104,11 @@ module Gemstash
101
104
  end
102
105
  map %w[-v --version] => :version
103
106
 
107
+ desc "info", "Check current gemstash instance info"
108
+ def info
109
+ say Gemstash::CLI::Info.new(self).run
110
+ end
111
+
104
112
  private
105
113
 
106
114
  def manpage(command)
@@ -4,9 +4,10 @@ require "gemstash"
4
4
  require "puma/commonlogger"
5
5
 
6
6
  use Rack::Deflater
7
- use Gemstash::Logging::RackMiddleware
8
7
 
9
8
  use Gemstash::Env::RackMiddleware, Gemstash::Env.current
9
+ use Gemstash::Logging::RackMiddleware
10
+
10
11
  use Gemstash::GemSource::RackMiddleware
11
12
  use Gemstash::Health::RackMiddleware
12
13
  run Gemstash::Web.new(gemstash_env: Gemstash::Env.current)
@@ -15,6 +15,7 @@ module Gemstash
15
15
  ignore_gemfile_source: false,
16
16
  protected_fetch: false,
17
17
  fetch_timeout: 20,
18
+ open_timeout: 2,
18
19
  # Actual default for db_connection_options is dynamic based on the adapter
19
20
  db_connection_options: {},
20
21
  puma_threads: 16,
@@ -60,6 +61,10 @@ module Gemstash
60
61
  @config[key]
61
62
  end
62
63
 
64
+ def keys
65
+ @config.keys
66
+ end
67
+
63
68
  # @return [Hash] Sequel connection configuration hash
64
69
  def database_connection_config
65
70
  case self[:db_adapter]
@@ -16,11 +16,6 @@ module Gemstash
16
16
  update(indexed: true)
17
17
  end
18
18
 
19
- # This converts to the format used by /private/specs.4.8.gz
20
- def to_spec
21
- [rubygem.name, Gem::Version.new(number), platform]
22
- end
23
-
24
19
  def self.slug(params)
25
20
  version = params[:version]
26
21
  platform = params[:platform]
data/lib/gemstash/env.rb CHANGED
@@ -129,10 +129,13 @@ module Gemstash
129
129
  db = if RUBY_PLATFORM == "java"
130
130
  Sequel.connect("jdbc:sqlite:#{db_path}", config.database_connection_config)
131
131
  else
132
- Sequel.connect("sqlite://#{CGI.escape(db_path)}", config.database_connection_config)
132
+ Sequel.connect("sqlite://#{db_path}", config.database_connection_config)
133
133
  end
134
134
  when "postgres", "mysql", "mysql2"
135
- db = Sequel.connect(config[:db_url], config.database_connection_config)
135
+ db_url = config[:db_url]
136
+ raise "Missing DB URL" unless db_url
137
+
138
+ db = Sequel.connect(db_url, config.database_connection_config)
136
139
  else
137
140
  raise "Unsupported DB adapter: '#{config[:db_adapter]}'"
138
141
  end
@@ -25,6 +25,7 @@ module Gemstash
25
25
  # :nodoc:
26
26
  class HTTPClient
27
27
  extend Gemstash::Env::Helper
28
+ include Gemstash::Env::Helper
28
29
  include Gemstash::Logging
29
30
 
30
31
  DEFAULT_USER_AGENT = "Gemstash/#{Gemstash::VERSION}"
@@ -55,7 +56,7 @@ module Gemstash
55
56
  response = with_retries do
56
57
  @client.get(path) do |req|
57
58
  req.headers["User-Agent"] = @user_agent
58
- req.options.open_timeout = 2
59
+ req.options.open_timeout = gemstash_env.config[:open_timeout]
59
60
  end
60
61
  end
61
62
 
@@ -12,6 +12,8 @@ end
12
12
  module Gemstash
13
13
  # :nodoc:
14
14
  module Logging
15
+ extend Gemstash::Env::Helper
16
+
15
17
  LEVELS = {
16
18
  debug: Logger::DEBUG,
17
19
  info: Logger::INFO,
@@ -45,7 +47,7 @@ module Gemstash
45
47
  end
46
48
 
47
49
  def self.logger
48
- @logger ||= setup_logger($stdout)
50
+ @logger ||= setup_logger(gemstash_env.log_file)
49
51
  end
50
52
 
51
53
  def self.reset
@@ -61,6 +63,7 @@ module Gemstash
61
63
 
62
64
  def call(env)
63
65
  env["rack.logger"] = Gemstash::Logging.logger
66
+ env["rack.errors"] = Gemstash::Env.current.log_file
64
67
  @app.call(env)
65
68
  end
66
69
  end
@@ -1,54 +1,73 @@
1
- <!-- Automatically generated by Pandoc -->
2
- .\" Automatically generated by Pandoc 3.1.8
1
+ .\" Automatically generated by Pandoc 3.1.3
3
2
  .\"
3
+ .\" Define V font for inline verbatim, using C font in formats
4
+ .\" that render this, and otherwise B font.
5
+ .ie "\f[CB]x\f[]"x" \{\
6
+ . ftr V B
7
+ . ftr VI BI
8
+ . ftr VB B
9
+ . ftr VBI BI
10
+ .\}
11
+ .el \{\
12
+ . ftr V CR
13
+ . ftr VI CI
14
+ . ftr VB CB
15
+ . ftr VBI CBI
16
+ .\}
4
17
  .TH "gemstash-authorize" "1" "October 9, 2015" "" ""
18
+ .hy
5
19
  .SH Name
20
+ .PP
6
21
  gemstash-authorize - Adds or removes authorization to interact with
7
22
  privately stored gems
8
23
  .SH Synopsis
9
- \f[CR]gemstash authorize [permissions] [--remove] [--list] [--key SECURE_KEY] [--name NAME] [--config-file FILE]\f[R]
24
+ .PP
25
+ \f[V]gemstash authorize [permissions] [--remove] [--list] [--key SECURE_KEY] [--name NAME] [--config-file FILE]\f[R]
10
26
  .SH Description
27
+ .PP
11
28
  Adds or removes authorization to interact with privately stored gems.
12
29
  .PP
13
30
  Any arguments will be used as specific permissions.
14
- Valid permissions include \f[CR]push\f[R], \f[CR]yank\f[R], and
15
- \f[CR]fetch\f[R].
31
+ Valid permissions include \f[V]push\f[R], \f[V]yank\f[R], and
32
+ \f[V]fetch\f[R].
16
33
  If no permissions are provided, then all permissions will be granted
17
34
  (including any that may be added in future versions of Gemstash).
18
35
  .SS Usage
19
36
  .IP
20
- .EX
37
+ .nf
38
+ \f[C]
21
39
  gemstash authorize
22
40
  gemstash authorize push yank
23
41
  gemstash authorize push --name my-auth
24
42
  gemstash authorize yank --key <secure-key>
25
43
  gemstash authorize --remove --key <secure-key>
26
44
  gemstash authorize --list
27
- .EE
45
+ \f[R]
46
+ .fi
28
47
  .SH Options
29
48
  .IP \[bu] 2
30
- \f[CR]--config-file FILE\f[R]: Specify the config file to use.
49
+ \f[V]--config-file FILE\f[R]: Specify the config file to use.
31
50
  If you aren\[cq]t using the default config file at
32
- \f[CR]\[ti]/.gemstash/config.yml\f[R] or
33
- \f[CR]\[ti]/.gemstash/config.yml.erb\f[R], then you must specify the
51
+ \f[V]\[ti]/.gemstash/config.yml\f[R] or
52
+ \f[V]\[ti]/.gemstash/config.yml.erb\f[R], then you must specify the
34
53
  config file via this option.
35
54
  .IP \[bu] 2
36
- \f[CR]--key SECURE_KEY\f[R]: Specify the API key to affect.
55
+ \f[V]--key SECURE_KEY\f[R]: Specify the API key to affect.
37
56
  This should be the actual key value, not a name.
38
- This option is required when using \f[CR]--remove\f[R] but is optional
57
+ This option is required when using \f[V]--remove\f[R] but is optional
39
58
  otherwise.
40
59
  If adding an authorization, using this will either create or update the
41
60
  permissions for the specified API key.
42
61
  If missing, a new API key will always be generated.
43
62
  Note that a key can only have a maximum length of 255 chars.
44
63
  .IP \[bu] 2
45
- \f[CR]--name\f[R]: Name of the authorization.
64
+ \f[V]--name\f[R]: Name of the authorization.
46
65
  Purely for ease of identification, not required.
47
66
  .IP \[bu] 2
48
- \f[CR]--remove\f[R]: Remove an authorization rather than add or update
67
+ \f[V]--remove\f[R]: Remove an authorization rather than add or update
49
68
  one.
50
69
  When removing, permission values are not allowed.
51
- The \f[CR]--key <secure-key>\f[R] option is required.
70
+ The \f[V]--key <secure-key>\f[R] option is required.
52
71
  .IP \[bu] 2
53
- \f[CR]--list\f[R]: List current authorizations.
54
- Provide \f[CR]--name\f[R] or \f[CR]--key\f[R] to show only one result.
72
+ \f[V]--list\f[R]: List current authorizations.
73
+ Provide \f[V]--name\f[R] or \f[V]--key\f[R] to show only one result.
@@ -1,20 +1,18 @@
1
1
  4mgemstash-authorize24m(1) 4mgemstash-authorize24m(1)
2
2
 
3
- <!-- Automatically generated by Pandoc -->
4
-
5
3
  1mName0m
6
4
  gemstash-authorize - Adds or removes authorization to interact with
7
5
  privately stored gems
8
6
 
9
7
  1mSynopsis0m
10
- gemstash authorize [permissions] [--remove] [--list] [--key SECURE_KEY]
11
- [--name NAME] [--config-file FILE]
8
+ 1mgemstash authorize [permissions] [--remove] [--list] [--key SECURE_KEY]0m
9
+ 1m[--name NAME] [--config-file FILE]0m
12
10
 
13
11
  1mDescription0m
14
12
  Adds or removes authorization to interact with privately stored gems.
15
13
 
16
14
  Any arguments will be used as specific permissions. Valid permissions
17
- include push, yank, and fetch. If no permissions are provided, then
15
+ include 1mpush22m, 1myank22m, and 1mfetch22m. If no permissions are provided, then
18
16
  all permissions will be granted (including any that may be added in fu-
19
17
  ture versions of Gemstash).
20
18
 
@@ -27,26 +25,26 @@
27
25
  gemstash authorize --list
28
26
 
29
27
  1mOptions0m
30
- o --config-file FILE: Specify the config file to use. If you aren't
31
- using the default config file at ~/.gemstash/config.yml or ~/.gem-
32
- stash/config.yml.erb, then you must specify the config file via this
28
+ o 1m--config-file FILE22m: Specify the config file to use. If you aren't
29
+ using the default config file at 1m~/.gemstash/config.yml 22mor 1m~/.gem-0m
30
+ 1mstash/config.yml.erb22m, then you must specify the config file via this
33
31
  option.
34
32
 
35
- o --key SECURE_KEY: Specify the API key to affect. This should be the
36
- actual key value, not a name. This option is required when using
37
- --remove but is optional otherwise. If adding an authorization, us-
33
+ o 1m--key SECURE_KEY22m: Specify the API key to affect. This should be the
34
+ actual key value, not a name. This option is required when using
35
+ 1m--remove 22mbut is optional otherwise. If adding an authorization, us-
38
36
  ing this will either create or update the permissions for the speci-
39
37
  fied API key. If missing, a new API key will always be generated.
40
38
  Note that a key can only have a maximum length of 255 chars.
41
39
 
42
- o --name: Name of the authorization. Purely for ease of identifica-
40
+ o 1m--name22m: Name of the authorization. Purely for ease of identifica-
43
41
  tion, not required.
44
42
 
45
- o --remove: Remove an authorization rather than add or update one.
46
- When removing, permission values are not allowed. The --key <secure-
47
- key> option is required.
43
+ o 1m--remove22m: Remove an authorization rather than add or update one.
44
+ When removing, permission values are not allowed. The 1m--key <secure-0m
45
+ 1mkey> 22moption is required.
48
46
 
49
- o --list: List current authorizations. Provide --name or --key to show
47
+ o 1m--list22m: List current authorizations. Provide 1m--name 22mor 1m--key 22mto show
50
48
  only one result.
51
49
 
52
- October 9, 2015 4mgemstash-authorize24m(1)
50
+ October 9, 2015 4mgemstash-authorize24m(1)