gem-coop 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/gem/commands/coop_command.rb +106 -0
- data/lib/gem/coop/version.rb +1 -1
- data/lib/gem/coop.rb +0 -7
- data/lib/rubygems_plugin.rb +1 -81
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 578a6efc2f230ceac621b9cfc4c01523d8e6cf796a45fbd7ed90a07629a1dcc9
|
|
4
|
+
data.tar.gz: 897fd6666701e595bdea3ad47b1097bf4f4f4240fc6fa74f7bb5aebc83219780
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76ae875375b285017e8a746418cbd6f82c57363e10bb3c6b8d845be9e9f988044cccdd0271ea3eb9283ec56f18f3a79176299c8720ae992d82590b511f2a625b
|
|
7
|
+
data.tar.gz: f02f68dc9dc47acef4d073b24eee1f88607b6e30598584a1c7a22647e5897711d48e1bf43a6ccf0b6d1a41901ad84c80d09dd542f1341c2e8b68a919c5197dd0
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rubygems/command"
|
|
4
|
+
|
|
5
|
+
module Gem
|
|
6
|
+
module Commands
|
|
7
|
+
class CoopCommand < Gem::Command
|
|
8
|
+
def initialize
|
|
9
|
+
super("coop", "Commands to interact with gem.coop")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def handle_options(args)
|
|
13
|
+
@host = ENV.fetch("GEM_HOST", "gem.coop")
|
|
14
|
+
@subcommand = args.shift
|
|
15
|
+
@namespace = args.shift
|
|
16
|
+
@args = args # Sidestep Gem::Command option parsing
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# gem coop release @namespace --platform darwin21 # Calls `gem build`s then `gem push`
|
|
20
|
+
# gem coop push @namespace peak-0.1.0.gem # Wraps `gem push`
|
|
21
|
+
def execute
|
|
22
|
+
case subcommand
|
|
23
|
+
when "release" then release
|
|
24
|
+
when "build" then build
|
|
25
|
+
when "push" then push(package_path: @args.first)
|
|
26
|
+
else
|
|
27
|
+
say "USAGE: gem coop COMMAND"
|
|
28
|
+
say ""
|
|
29
|
+
say "Passing --dev creates a development build of your gem: `<name>.<sha>.<year>.<month>.<day>.gem`"
|
|
30
|
+
say ""
|
|
31
|
+
say ""
|
|
32
|
+
say "Commands:"
|
|
33
|
+
say " release @NAME [--dev] # Build and push to (#{@host}/@name)"
|
|
34
|
+
say " build @NAME [--dev] # Build a gemspec"
|
|
35
|
+
say " push @NAME PATH # Push a built gem to (#{@host}/@name)"
|
|
36
|
+
say ""
|
|
37
|
+
say "Examples:"
|
|
38
|
+
say ""
|
|
39
|
+
say " GEM_HOST_API_KEY= gem coop build # Build the current .gemspec to pkg/"
|
|
40
|
+
say " GEM_HOST_API_KEY= gem coop build --dev # Create a dev-build of .gemspec in pkg/"
|
|
41
|
+
say ""
|
|
42
|
+
say " GEM_HOST_API_KEY= gem coop push @name pkg/name-1.0.0.gem # Push a pre-built gem to your namespace"
|
|
43
|
+
say ""
|
|
44
|
+
say " GEM_HOST_API_KEY= gem coop release @name # Build and push a gem to your namespace"
|
|
45
|
+
say " GEM_HOST_API_KEY= gem coop release @name/beta # Build and push a separate /beta index"
|
|
46
|
+
say " GEM_HOST_API_KEY= gem coop release @name/dev --dev # Build and push a dev build to a separate /dev index"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
attr_reader :subcommand, :namespace, :args
|
|
53
|
+
|
|
54
|
+
def build
|
|
55
|
+
require "rubygems/commands/build_command"
|
|
56
|
+
build = Gem::Commands::BuildCommand.new
|
|
57
|
+
|
|
58
|
+
build_path = if args.include?("--dev")
|
|
59
|
+
require "fileutils"
|
|
60
|
+
require "rubygems/specification"
|
|
61
|
+
|
|
62
|
+
path = args.first && build.find_gemspec(args.first) || build.find_gemspec
|
|
63
|
+
spec = Gem::Specification.load path
|
|
64
|
+
date = Time.now.strftime("%Y.%m.%d")
|
|
65
|
+
sha = `git rev-parse --short head`.chomp
|
|
66
|
+
spec.version = version = "#{spec.version}.#{date}.#{sha}"
|
|
67
|
+
|
|
68
|
+
FileUtils.mkdir_p "pkg"
|
|
69
|
+
build_path = "pkg/#{spec.name}-#{version}.gemspec"
|
|
70
|
+
File.binwrite build_path, spec.to_ruby
|
|
71
|
+
build_path
|
|
72
|
+
else
|
|
73
|
+
args.shift
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
build.invoke build_path, *args # Haven't figured out how to get options[:build_path] to trigger so we Dir.chdir internally.
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def release
|
|
80
|
+
ensure_push_key
|
|
81
|
+
require "rubygems/commands/build_command"
|
|
82
|
+
build = Gem::Commands::BuildCommand.new
|
|
83
|
+
build.invoke(*args) # Haven't figured out how to get options[:build_path] to trigger so we Dir.chdir internally.
|
|
84
|
+
|
|
85
|
+
package_path = build
|
|
86
|
+
push(package_path:)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def push(package_path: args.first)
|
|
90
|
+
ensure_push_key
|
|
91
|
+
require "rubygems/commands/push_command"
|
|
92
|
+
push = Gem::Commands::PushCommand.new
|
|
93
|
+
push.invoke package_path, "--host", File.join("https://#{@host}", namespace)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def beta? = true # Add as an option or just don't host gem pushing on beta.?
|
|
97
|
+
|
|
98
|
+
def ensure_push_key
|
|
99
|
+
ENV.fetch("GEM_HOST_API_KEY") {
|
|
100
|
+
say "Prefix command with your GEM_HOST_API_KEY= to push gems"
|
|
101
|
+
exit 1
|
|
102
|
+
}
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
data/lib/gem/coop/version.rb
CHANGED
data/lib/gem/coop.rb
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
|
@@ -1,84 +1,4 @@
|
|
|
1
|
-
require "rubygems"
|
|
2
1
|
require "rubygems/command_manager"
|
|
3
|
-
require "
|
|
2
|
+
require "gem/commands/coop_command"
|
|
4
3
|
|
|
5
4
|
Gem::CommandManager.instance.register_command :coop
|
|
6
|
-
|
|
7
|
-
class Gem::Commands::CoopCommand < Gem::Command
|
|
8
|
-
def initialize
|
|
9
|
-
super "coop", "Commands to interact with gem.coop"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def handle_options(args)
|
|
13
|
-
@host = ENV.fetch("GEM_HOST", "gem.coop")
|
|
14
|
-
@subcommand = args.shift
|
|
15
|
-
@namespace = args.shift
|
|
16
|
-
@args = args # Sidestep Gem::Command option parsing
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# gem coop release @namespace --platform darwin21 # Calls `gem build`s then `gem push`
|
|
20
|
-
# gem coop push @namespace peak-0.1.0.gem # Wraps `gem push`
|
|
21
|
-
def execute
|
|
22
|
-
case subcommand
|
|
23
|
-
when "release-dev" then release_dev
|
|
24
|
-
when "release" then release
|
|
25
|
-
when "push" then push(package_path: @args.first)
|
|
26
|
-
else
|
|
27
|
-
puts "USAGE: gem coop COMMAND"
|
|
28
|
-
puts ""
|
|
29
|
-
puts "Commands:"
|
|
30
|
-
puts " push @NAME PATH # Push a pre-built gem to your namespace (#{@host}/@name)"
|
|
31
|
-
puts " release @NAME # Build and push to your namespace (#{@host}/@name)"
|
|
32
|
-
puts " release-dev @NAME # Build and push to your dev index (#{@host}/@name/dev)"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
attr_reader :subcommand, :namespace, :args
|
|
38
|
-
|
|
39
|
-
def release_dev
|
|
40
|
-
ensure_push_key
|
|
41
|
-
require "fileutils"
|
|
42
|
-
require "rubygems/specification"
|
|
43
|
-
require "rubygems/commands/build_command"
|
|
44
|
-
|
|
45
|
-
@namespace += "/dev"
|
|
46
|
-
|
|
47
|
-
build = Gem::Commands::BuildCommand.new
|
|
48
|
-
path = args.first && build.find_gemspec(args.first) || build.find_gemspec
|
|
49
|
-
|
|
50
|
-
spec = Gem::Specification.load path
|
|
51
|
-
date = Time.now.strftime("%Y.%m.%d")
|
|
52
|
-
sha = `git rev-parse --short head`.chomp
|
|
53
|
-
spec.version = version = "#{spec.version}.#{date}.#{sha}"
|
|
54
|
-
|
|
55
|
-
FileUtils.mkdir_p "pkg"
|
|
56
|
-
build_path = "pkg/#{spec.name}-#{version}.gemspec"
|
|
57
|
-
File.binwrite build_path, spec.to_ruby
|
|
58
|
-
|
|
59
|
-
package_path = build.invoke build_path, *args # Haven't figured out how to get options[:build_path] to trigger so we Dir.chdir internally.
|
|
60
|
-
push(package_path:)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def release
|
|
64
|
-
ensure_push_key
|
|
65
|
-
require "rubygems/commands/build_command"
|
|
66
|
-
build = Gem::Commands::BuildCommand.new
|
|
67
|
-
package_path = build.invoke *args # Haven't figured out how to get options[:build_path] to trigger so we Dir.chdir internally.
|
|
68
|
-
|
|
69
|
-
push(package_path:)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def push(package_path: args.first)
|
|
73
|
-
ensure_push_key
|
|
74
|
-
require "rubygems/commands/push_command"
|
|
75
|
-
push = Gem::Commands::PushCommand.new
|
|
76
|
-
push.invoke package_path, "--host", File.join("https://#{@host}", namespace)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def beta? = true # Add as an option or just don't host gem pushing on beta.?
|
|
80
|
-
|
|
81
|
-
def ensure_push_key
|
|
82
|
-
ENV.fetch("GEM_HOST_API_KEY") { say "Prefix command with your GEM_HOST_API_KEY= to push gems"; exit 1 }
|
|
83
|
-
end
|
|
84
|
-
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem-coop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The Gem Cooperative
|
|
@@ -21,6 +21,7 @@ files:
|
|
|
21
21
|
- LICENSE.txt
|
|
22
22
|
- README.md
|
|
23
23
|
- Rakefile
|
|
24
|
+
- lib/gem/commands/coop_command.rb
|
|
24
25
|
- lib/gem/coop.rb
|
|
25
26
|
- lib/gem/coop/version.rb
|
|
26
27
|
- lib/rubygems_plugin.rb
|