shopify_empty_gem 0.1.4 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5400fd07bf232601fad54346786f5cdf896521ee02abece4458c78df5ed50bcc
4
- data.tar.gz: f68c65df5d4ff09b319839443c5a7ad81e5d792f3cce50c2c19489fe307d2035
3
+ metadata.gz: f5ef1e92302ace4e5d4dc9cc5a5199aaabcae67e1524f67c889bbbc4d0786797
4
+ data.tar.gz: 209720e9e1c02dcdce58be14a39ec520ccbf5e874cf0fdfa94219817df756a46
5
5
  SHA512:
6
- metadata.gz: 130c92983f3e5341cdefed234dd1bf3777578c6665a7c5e30d6d55099cd354f6843390331845d4bcf826f455d0d0923cc381d44f1ce3b31c910c93179dae4b95
7
- data.tar.gz: cc51394eb8939e32463a255bad10dc50cbcfc8f74fcff604ec98e7c70c99842b8c1202f38dadf253f2a9780f59f7c47d216d26e9b14420c3e7d9bfca705278cb
6
+ metadata.gz: 167fce88d5c3f646e96a380a273c8a4205c452ea1a18fa18ed87b6c8cf493865b9cda054dca1ef8d7568dd39a764b3ca1bef4c13fa180b213bab0e72d3987876
7
+ data.tar.gz: 4447aec867fd1690df65a2b2bc61d961ef3621c2e6a6bcde331e934f34784a1390d545a9061de5f445686f3725f627a4f82b81939f850fa57bac6a95a70a5082
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_empty_gem (0.1.4)
4
+ shopify_empty_gem (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module ShopifyEmptyGem
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_empty_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-17 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,27 +44,24 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 12.3.3
47
- description:
47
+ description:
48
48
  email:
49
49
  - admins@shopify.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".gitignore"
55
54
  - Gemfile
56
55
  - Gemfile.lock
57
56
  - Rakefile
58
57
  - lib/shopify_empty_gem.rb
59
58
  - lib/shopify_empty_gem/version.rb
60
- - lib/snippets/release-gem-with-otp
61
- - shipit.rubygems_otp.yml
62
59
  homepage: https://example.com
63
60
  licenses:
64
61
  - MIT
65
62
  metadata:
66
63
  allowed_push_host: https://rubygems.org
67
- post_install_message:
64
+ post_install_message:
68
65
  rdoc_options: []
69
66
  require_paths:
70
67
  - lib
@@ -79,8 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
76
  - !ruby/object:Gem::Version
80
77
  version: '0'
81
78
  requirements: []
82
- rubygems_version: 3.2.32
83
- signing_key:
79
+ rubygems_version: 3.2.20
80
+ signing_key:
84
81
  specification_version: 4
85
82
  summary: Empty gem for testing purposes
86
83
  test_files: []
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'net/https'
4
- require 'uri'
5
- require 'json'
6
-
7
- module RubygemsAPI
8
- extend self
9
-
10
- def published?(name, version)
11
- uri = URI.parse("https://rubygems.org/api/v2/rubygems/#{name}/versions/#{version}.json")
12
- Net::HTTP.get_response(uri).is_a?(Net::HTTPSuccess)
13
- end
14
- end
15
-
16
- module Git
17
- extend self
18
-
19
- def tag_and_push(version)
20
- if tag_exists?(version)
21
- yield
22
- else
23
- tag(version) && yield && push_tags
24
- end
25
- end
26
-
27
- def tag_exists?(version)
28
- system('git', 'rev-parse', '--verify', "v#{version}^{commit}", out: File::NULL, err: File::NULL)
29
- end
30
-
31
- def tag(version)
32
- puts "Running: git tag -m 'Version #{version}' v#{version}"
33
- system('git', 'tag', '-m', "Version #{version}", "v#{version}")
34
- end
35
-
36
- def delete_tag(version)
37
- puts "Running: git tag -d v#{version}"
38
- system('git', 'tag', '-d', "v#{version}")
39
- end
40
-
41
- def push_tags
42
- puts "Running: git push --tags"
43
- system('git', 'push', '--tag')
44
- end
45
- end
46
-
47
- module Poll
48
- extend self
49
-
50
- def fetch_otp(wait_time: 3, timeout_threshold: 300, gem_name:)
51
- # The wait_time and time_threshold configs are temp placeholders, we can adjust as needed
52
- # TODO: Consider whether we should implement exponential backoff
53
- # Potential risk: Timing may be precarious given the 30 second time frame for otp expiry
54
- # If we don't implement an exponential backoff strategy, will we accidentally DDOS ourselves?
55
-
56
- puts "Polling for OTP code"
57
- otp_code = nil
58
- start_time = Time.now.utc
59
-
60
- until Time.now.utc > start_time + timeout_threshold
61
- # Printing '.' to the log to indicate each time we poll for an OTP code
62
- # This will also help prevent timing out on Shipit
63
- # Shipit's default task timeout is 5 minutes; if no new output is logged within 5 minutes, shipit will kill the task.
64
- print "."
65
-
66
- # Make GET request to web app's endpont
67
- uri = URI('https://api.agify.io/') # TODO: update endpoint when web service is created
68
- params = { :name => 'bella' }
69
- # params = { :gem_name => gem_name }
70
- uri.query = URI.encode_www_form(params)
71
-
72
- res = Net::HTTP.get_response(uri)
73
- otp_code = JSON.parse(res.body)["count"] if res.is_a?(Net::HTTPSuccess)
74
-
75
- return otp_code if !otp_code.nil?
76
-
77
- # TODO: Need to figure out what other responses we want to send back from web service when OTP does not exist
78
- # TODO: How do we handle OTP submissions on the web app side?
79
- # Do we persist the OTP for <x> time frame?
80
- # Do we create a job to destroy the OTP code after <x> time frame?
81
-
82
- sleep wait_time
83
- end
84
-
85
- # TODO: Opportunity for retry mechanism?
86
- # Exiting script, as OTP was not retrieved - will lead to a failed deploy
87
- exit(1)
88
- end
89
- end
90
-
91
- puts "🚀 Kicking off the release-gem-with-otp script!!"
92
-
93
- spec_path, temp_otp_code, *release_command = ARGV
94
-
95
- puts "📝 The otp code is: #{temp_otp_code}"
96
-
97
- spec = Gem::Specification.load(spec_path)
98
- if RubygemsAPI.published?(spec.name, spec.version)
99
- puts "#{spec.name} version #{spec.version} is already published."
100
- exit 0
101
- elsif !spec.metadata['allowed_push_host']
102
- puts "Can't release the gem: spec.metadata['allowed_push_host'] must be defined."
103
- exit 1
104
- else
105
- is_successful = Git.tag_and_push(spec.version) do
106
-
107
- if release_command.any?
108
- # If a custom release command is called with this script, just execute the custom command
109
- system(*release_command)
110
- else
111
- # TODO: If mechanism to check if account has mfa enabled, do the check here (is otp required?)
112
-
113
- # TODO: Notify user via Slack to enter OTP in web app
114
- # QUESTIONS:
115
- # How do we know who to notify?
116
-
117
-
118
-
119
- # Start polling web app's endpoint
120
- otp = Poll.fetch_otp(gem_name: spec.name)
121
-
122
- # Set the environment variable to the user inputted OTP code
123
- # See: https://guides.rubygems.org/command-reference/ under otp option for environment variable
124
- #
125
- # According to the docs: https://ruby-doc.org/core-3.1.0/Kernel.html#method-i-spawn
126
- # The keys and values passed to spawn (or system), except for `nil`, must be strings.
127
- # So we're calling `to_s` on the `otp_code` just to be safe.
128
- #
129
- # Since we've already tagged and built the gem with `bundle exec gem_push=no rake release`, the last step is to push the gem
130
- # Instead of re-building and re-tagging the gem, we'll complete the last step of the `rake release` command => (gem push)
131
- puts "💪 Preparing to release gem"
132
- puts "🎉 Running 'bundle exec rake release' with otp code #{temp_otp_code}"
133
-
134
- system(
135
- {'GEM_HOST_OTP_CODE' => temp_otp_code.to_s},
136
- 'bundle',
137
- 'exec',
138
- 'rake',
139
- 'release'
140
- )
141
-
142
- # TODO: What if OTP has expired? Add mechanism to retry.
143
- end
144
- end
145
- is_successful ? exit(0) : exit(1)
146
- end
147
-
148
-
@@ -1,4 +0,0 @@
1
- deploy:
2
- override:
3
- - lib/snippets/release-gem-with-otp shopify_empty_gem.gemspec 249493
4
-