phraseapp_updater 2.0.7 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd13cd155e4d1489c4eadba7a8fc5def83bfc86a28f43646a9ef1924706f85a5
4
- data.tar.gz: 341169c0beb43396cbf1b404a888ebc8ecae66a5acb57c2eb164e89d6cef856d
3
+ metadata.gz: c7c95df3029f6b77ecd8ea760f7d0cac9003879acfc04b9ac5674e47ea41d2cb
4
+ data.tar.gz: 86f123de84997ba31604aa207ac51aa55e1ba9fc05758e2d89b4720d2be9d4e6
5
5
  SHA512:
6
- metadata.gz: 830206a333355912b6ade08d4c73e1526d22c65fbde8c6674429071e3a12e9db5f9706c8fb5d7ddf29437af78b965db268635e1efa2fc3f9546ea4ed90f72aa9
7
- data.tar.gz: 8b80b6341dd8ae25edb861ddf67a8a86788179893204c46255c02686f7e0bc09428b3f9d5fe991892a05a4c9f97850b76d235b0a1e06d7d8555d65072972f668
6
+ metadata.gz: 2c3e5ccb85014ec287d027b41146c142bc7e291c07c7a00184375381983c00ba62988539314f37e194aeddf2e3ab7588f985c18ed019023c2324483121f35812
7
+ data.tar.gz: 80bdb49e97c0e41d931b04689e6b95dac234975cff532937cc25c0237c55700703810f9146bed7a7cc26583f24a1de38a910f8339fc4a2f12bf4e8ee3bcf57fb
@@ -41,15 +41,15 @@ jobs:
41
41
 
42
42
  - restore_cache:
43
43
  keys:
44
- - phraseapp_updater-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
45
- - phraseapp_updater-
44
+ - phraseapp_updater-v2-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
45
+ - phraseapp_updater-v2
46
46
 
47
47
  - run:
48
48
  name: Bundle Install
49
49
  command: bundle check || bundle install
50
50
 
51
51
  - save_cache:
52
- key: phraseapp_updater-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
52
+ key: phraseapp_updater-v2-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
53
53
  paths:
54
54
  - vendor/bundle
55
55
 
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ eval "$(lorri direnv)"
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
  gem 'byebug'
6
6
  gem 'rspec_junit_formatter'
7
+
8
+ gem 'irb', require: false
@@ -32,6 +32,20 @@ class PhraseAppUpdaterCLI < Thor
32
32
  end
33
33
  end
34
34
 
35
+ desc 'lookup', 'Lookup a phraseapp project by name'
36
+ method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
37
+ method_option :phraseapp_project_name, type: :string, required: true, desc: 'Name for new PhraseApp project.'
38
+
39
+ def lookup
40
+ handle_errors do
41
+ project_id = PhraseAppUpdater.lookup_project(
42
+ options[:phraseapp_api_key],
43
+ options[:phraseapp_project_name])
44
+
45
+ puts project_id
46
+ end
47
+ end
48
+
35
49
  desc 'synchronize <git_checkout_path>',
36
50
  'Synchronize locales in PhraseApp with '
37
51
  method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
@@ -237,6 +251,9 @@ class PhraseAppUpdaterCLI < Thor
237
251
  rescue PhraseAppUpdater::PhraseAppAPI::BadAPIKeyError
238
252
  STDERR.puts 'Bad PhraseApp API key.'
239
253
  exit(1)
254
+ rescue PhraseAppUpdater::PhraseAppAPI::ProjectNotFoundError => e
255
+ STDERR.puts "PhraseApp project not found: '#{e.name}'"
256
+ exit(1)
240
257
  rescue PhraseAppUpdater::PhraseAppAPI::BadProjectIDError => e
241
258
  STDERR.puts "Bad PhraseApp project ID: #{e.project_id}"
242
259
  exit(1)
@@ -27,7 +27,7 @@ current_branch=$(git rev-parse "${REMOTE}/${BRANCH}")
27
27
 
28
28
  # If there's a local checkout of that branch, for safety's sake make sure that
29
29
  # it's up to date with the remote one.
30
- local_branch=$(git rev-parse "${BRANCH}")
30
+ local_branch=$(git rev-parse --quiet --verify "${BRANCH}" || true)
31
31
  if [ "$local_branch" ] && [ "$current_branch" != "$local_branch" ]; then
32
32
  echo "Error: local branch '${BRANCH}' exists but does not match '${REMOTE}/${BRANCH}'." >&2
33
33
  exit 1
@@ -16,6 +16,11 @@ class PhraseAppUpdater
16
16
  return self.new(phraseapp_api_key, project_id, file_format, verbose: verbose), project_id
17
17
  end
18
18
 
19
+ def self.lookup_project(phraseapp_api_key, phraseapp_project_name)
20
+ api = PhraseAppAPI.new(phraseapp_api_key, nil, nil)
21
+ api.lookup_project_id(phraseapp_project_name)
22
+ end
23
+
19
24
  def initialize(phraseapp_api_key, phraseapp_project_id, file_format, default_locale: 'en', verbose: false)
20
25
  @locale_file_class = LocaleFile.class_for_file_format(file_format)
21
26
  @default_locale = default_locale
@@ -74,7 +79,7 @@ class PhraseAppUpdater
74
79
  end
75
80
  end
76
81
 
77
- HashDiff.diff(our_content, their_content)
82
+ Hashdiff.diff(our_content, their_content)
78
83
  end
79
84
 
80
85
  def merge_locale_files(our_locales, their_locales, ancestor_locales)
@@ -63,7 +63,7 @@ class PhraseAppUpdater
63
63
  end
64
64
 
65
65
  def apply_diffs(hash, diffs)
66
- deep_compact!(HashDiff.patch!(hash, diffs))
66
+ deep_compact!(Hashdiff.patch!(hash, diffs))
67
67
  end
68
68
 
69
69
  def resolve!(original:, primary:, secondary:)
@@ -73,8 +73,8 @@ class PhraseAppUpdater
73
73
  f_primary = flatten(primary)
74
74
  f_secondary = flatten(secondary)
75
75
 
76
- primary_diffs = HashDiff.diff(f_original, f_primary)
77
- secondary_diffs = HashDiff.diff(f_original, f_secondary)
76
+ primary_diffs = Hashdiff.diff(f_original, f_primary)
77
+ secondary_diffs = Hashdiff.diff(f_original, f_secondary)
78
78
 
79
79
  # However, flattening discards one critical piece of information: when we
80
80
  # have deleted or clobbered an entire prefix (subtree) from the original,
@@ -88,7 +88,7 @@ class PhraseAppUpdater
88
88
  #
89
89
  # Additionally calculate subtree prefixes that were deleted in `secondary`:
90
90
  secondary_deleted_prefixes =
91
- HashDiff.diff(original, secondary, delimiter: SEPARATOR).lazy
91
+ Hashdiff.diff(original, secondary, delimiter: SEPARATOR).lazy
92
92
  .select { |op, path, from, to| (op == "-" || op == "~") && from.is_a?(Hash) && !to.is_a?(Hash) }
93
93
  .map { |op, path, from, to| path }
94
94
  .to_a
@@ -109,7 +109,7 @@ class PhraseAppUpdater
109
109
  resolved_diffs.each { |d| STDERR.puts(d.inspect) }
110
110
  end
111
111
 
112
- HashDiff.patch!(f_original, resolved_diffs)
112
+ Hashdiff.patch!(f_original, resolved_diffs)
113
113
 
114
114
  expand(f_original)
115
115
  end
@@ -22,7 +22,10 @@ class PhraseAppUpdater
22
22
 
23
23
  def dump(hash)
24
24
  # Add indentation for better diffs
25
- Oj.dump(hash, indent: 2, mode: :strict)
25
+ json = Oj.dump(hash, indent: ' ', space: ' ', object_nl: "\n", array_nl: "\n", mode: :strict)
26
+ # Oj omits end of file newline unless using the integer form of :indent
27
+ json << "\n"
28
+ json
26
29
  end
27
30
 
28
31
  def extension
@@ -10,6 +10,7 @@ class PhraseAppUpdater
10
10
  using IndexBy
11
11
  class PhraseAppAPI
12
12
  GIT_TAG_PREFIX = 'gitancestor_'
13
+ PAGE_SIZE = 100
13
14
 
14
15
  def initialize(api_key, project_id, locale_file_class)
15
16
  @client = PhraseApp::Client.new(PhraseApp::Auth::Credentials.new(token: api_key))
@@ -30,11 +31,19 @@ class PhraseAppUpdater
30
31
  project.id
31
32
  end
32
33
 
34
+ def lookup_project_id(name)
35
+ result, = paginate_request(:projects_list, limit: 1) { |p| p.name == name }
36
+ raise ProjectNotFoundError.new(name) if result.nil?
37
+
38
+ result.id
39
+ end
40
+
33
41
  # We mark projects with their parent git commit using a tag with a
34
42
  # well-known prefix. We only allow one tag with this prefix at once.
35
43
  def read_parent_commit
36
- tags = phraseapp_request { @client.tags_list(@project_id, 1, 100) }
37
- git_tag = tags.detect { |t| t.name.start_with?(GIT_TAG_PREFIX) }
44
+ git_tag, = paginate_request(:tags_list, @project_id, limit: 1) do |t|
45
+ t.name.start_with?(GIT_TAG_PREFIX)
46
+ end
38
47
  raise MissingGitParentError.new if git_tag.nil?
39
48
 
40
49
  git_tag.name.delete_prefix(GIT_TAG_PREFIX)
@@ -146,6 +155,32 @@ class PhraseAppUpdater
146
155
  phraseapp_request { @client.tag_create(@project_id, params) }
147
156
  end
148
157
 
158
+ def paginate_request(method, *params, limit: nil, &filter)
159
+ page = 1
160
+ results = []
161
+
162
+ loop do
163
+ response = phraseapp_request do
164
+ @client.public_send(method, *params, page, PAGE_SIZE)
165
+ end
166
+
167
+ break if response.empty?
168
+
169
+ matches = response.filter(&filter)
170
+ matches = matches[0, limit - results.size] if limit
171
+
172
+ unless matches.empty?
173
+ results.concat(matches)
174
+
175
+ break if results.size == limit
176
+ end
177
+
178
+ page += 1
179
+ end
180
+
181
+ results
182
+ end
183
+
149
184
  def phraseapp_request(&block)
150
185
  res, err = block.call
151
186
 
@@ -219,6 +254,15 @@ class PhraseAppUpdater
219
254
  end
220
255
  end
221
256
 
257
+ class ProjectNotFoundError < RuntimeError
258
+ attr_reader :name
259
+
260
+ def initialize(name)
261
+ @name = name
262
+ super("Project '#{name}' not found")
263
+ end
264
+ end
265
+
222
266
  class BadAPIKeyError < RuntimeError
223
267
  def initialize(original_error)
224
268
  super(original_error.message)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PhraseAppUpdater
4
- VERSION = '2.0.7'
4
+ VERSION = '2.1.1'
5
5
  end
@@ -0,0 +1,24 @@
1
+ source "https://rubygems.org/"
2
+
3
+ gem "byebug", "11.0.1"
4
+ gem "coderay", "1.1.2"
5
+ gem "deep_merge", "1.2.1"
6
+ gem "diff-lcs", "1.3"
7
+ gem "hashdiff", "0.4.0"
8
+ gem "io-console", "0.5.4"
9
+ gem "irb", "1.2.1"
10
+ gem "method_source", "0.9.2"
11
+ gem "multi_json", "1.14.1"
12
+ gem "oj", "2.18.5"
13
+ gem "parallel", "1.19.1"
14
+ gem "phraseapp-ruby", "1.6.0"
15
+ gem "pry", "0.12.2"
16
+ gem "rake", "10.5.0"
17
+ gem "reline", "0.1.2"
18
+ gem "rspec", "3.8.0"
19
+ gem "rspec-core", "3.8.0"
20
+ gem "rspec-expectations", "3.8.3"
21
+ gem "rspec-mocks", "3.8.0"
22
+ gem "rspec-support", "3.8.0"
23
+ gem "rspec_junit_formatter", "0.4.1"
24
+ gem "thor", "0.20.3"
@@ -0,0 +1,68 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ byebug (11.0.1)
5
+ coderay (1.1.2)
6
+ deep_merge (1.2.1)
7
+ diff-lcs (1.3)
8
+ hashdiff (0.4.0)
9
+ io-console (0.5.4)
10
+ irb (1.2.1)
11
+ reline (>= 0.0.1)
12
+ method_source (0.9.2)
13
+ multi_json (1.14.1)
14
+ oj (2.18.5)
15
+ parallel (1.19.1)
16
+ phraseapp-ruby (1.6.0)
17
+ pry (0.12.2)
18
+ coderay (~> 1.1.0)
19
+ method_source (~> 0.9.0)
20
+ rake (10.5.0)
21
+ reline (0.1.2)
22
+ io-console (~> 0.5)
23
+ rspec (3.8.0)
24
+ rspec-core (~> 3.8.0)
25
+ rspec-expectations (~> 3.8.0)
26
+ rspec-mocks (~> 3.8.0)
27
+ rspec-core (3.8.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-expectations (3.8.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-mocks (3.8.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-support (3.8.0)
36
+ rspec_junit_formatter (0.4.1)
37
+ rspec-core (>= 2, < 4, != 2.12.0)
38
+ thor (0.20.3)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ byebug (= 11.0.1)
45
+ coderay (= 1.1.2)
46
+ deep_merge (= 1.2.1)
47
+ diff-lcs (= 1.3)
48
+ hashdiff (= 0.4.0)
49
+ io-console (= 0.5.4)
50
+ irb (= 1.2.1)
51
+ method_source (= 0.9.2)
52
+ multi_json (= 1.14.1)
53
+ oj (= 2.18.5)
54
+ parallel (= 1.19.1)
55
+ phraseapp-ruby (= 1.6.0)
56
+ pry (= 0.12.2)
57
+ rake (= 10.5.0)
58
+ reline (= 0.1.2)
59
+ rspec (= 3.8.0)
60
+ rspec-core (= 3.8.0)
61
+ rspec-expectations (= 3.8.3)
62
+ rspec-mocks (= 3.8.0)
63
+ rspec-support (= 3.8.0)
64
+ rspec_junit_formatter (= 0.4.1)
65
+ thor (= 0.20.3)
66
+
67
+ BUNDLED WITH
68
+ 1.17.3
@@ -0,0 +1,230 @@
1
+ {
2
+ byebug = {
3
+ groups = ["default"];
4
+ platforms = [];
5
+ source = {
6
+ remotes = ["https://rubygems.org"];
7
+ sha256 = "1mmkls9n56l4gx2k0dnyianwz36z2zgpxli5bpsbr7jbw7hn2x6j";
8
+ type = "gem";
9
+ };
10
+ version = "11.0.1";
11
+ };
12
+ coderay = {
13
+ groups = ["default"];
14
+ platforms = [];
15
+ source = {
16
+ remotes = ["https://rubygems.org"];
17
+ sha256 = "15vav4bhcc2x3jmi3izb11l4d9f3xv8hp2fszb7iqmpsccv1pz4y";
18
+ type = "gem";
19
+ };
20
+ version = "1.1.2";
21
+ };
22
+ deep_merge = {
23
+ groups = ["default"];
24
+ platforms = [];
25
+ source = {
26
+ remotes = ["https://rubygems.org"];
27
+ sha256 = "1q3picw7zx1xdkybmrnhmk2hycxzaa0jv4gqrby1s90dy5n7fmsb";
28
+ type = "gem";
29
+ };
30
+ version = "1.2.1";
31
+ };
32
+ diff-lcs = {
33
+ groups = ["default"];
34
+ platforms = [];
35
+ source = {
36
+ remotes = ["https://rubygems.org"];
37
+ sha256 = "18w22bjz424gzafv6nzv98h0aqkwz3d9xhm7cbr1wfbyas8zayza";
38
+ type = "gem";
39
+ };
40
+ version = "1.3";
41
+ };
42
+ hashdiff = {
43
+ groups = ["default"];
44
+ platforms = [];
45
+ source = {
46
+ remotes = ["https://rubygems.org"];
47
+ sha256 = "1ncwxv7jbm3jj9phv6dd514463bkjwggxk10n2z100wf4cjcicrk";
48
+ type = "gem";
49
+ };
50
+ version = "0.4.0";
51
+ };
52
+ io-console = {
53
+ groups = ["default"];
54
+ platforms = [];
55
+ source = {
56
+ remotes = ["https://rubygems.org"];
57
+ sha256 = "109yzpv9kslwra2mxnjsg3r6mwxkbqmxihj266qdvccapghi05wg";
58
+ type = "gem";
59
+ };
60
+ version = "0.5.4";
61
+ };
62
+ irb = {
63
+ dependencies = ["reline"];
64
+ groups = ["default"];
65
+ platforms = [];
66
+ source = {
67
+ remotes = ["https://rubygems.org"];
68
+ sha256 = "1r1y8i46qd5izdszzzn5jxvwvq00m89rk0hm8cs8f21p7nlwmh5w";
69
+ type = "gem";
70
+ };
71
+ version = "1.2.1";
72
+ };
73
+ method_source = {
74
+ groups = ["default"];
75
+ platforms = [];
76
+ source = {
77
+ remotes = ["https://rubygems.org"];
78
+ sha256 = "1pviwzvdqd90gn6y7illcdd9adapw8fczml933p5vl739dkvl3lq";
79
+ type = "gem";
80
+ };
81
+ version = "0.9.2";
82
+ };
83
+ multi_json = {
84
+ groups = ["default"];
85
+ platforms = [];
86
+ source = {
87
+ remotes = ["https://rubygems.org"];
88
+ sha256 = "0xy54mjf7xg41l8qrg1bqri75agdqmxap9z466fjismc1rn2jwfr";
89
+ type = "gem";
90
+ };
91
+ version = "1.14.1";
92
+ };
93
+ oj = {
94
+ groups = ["default"];
95
+ platforms = [];
96
+ source = {
97
+ remotes = ["https://rubygems.org"];
98
+ sha256 = "1jli4mi1xpmm8564pc09bfvv7znzqghidwa3zfw21r365ihmbv2p";
99
+ type = "gem";
100
+ };
101
+ version = "2.18.5";
102
+ };
103
+ parallel = {
104
+ groups = ["default"];
105
+ platforms = [];
106
+ source = {
107
+ remotes = ["https://rubygems.org"];
108
+ sha256 = "12jijkap4akzdv11lm08dglsc8jmc87xcgq6947i1s3qb69f4zn2";
109
+ type = "gem";
110
+ };
111
+ version = "1.19.1";
112
+ };
113
+ phraseapp-ruby = {
114
+ groups = ["default"];
115
+ platforms = [];
116
+ source = {
117
+ remotes = ["https://rubygems.org"];
118
+ sha256 = "14n2hhwjn32xk0qk6rprs3awnrddhnd4zckyd0a4j8lv8k648pnn";
119
+ type = "gem";
120
+ };
121
+ version = "1.6.0";
122
+ };
123
+ pry = {
124
+ dependencies = ["coderay" "method_source"];
125
+ groups = ["default"];
126
+ platforms = [];
127
+ source = {
128
+ remotes = ["https://rubygems.org"];
129
+ sha256 = "00rm71x0r1jdycwbs83lf9l6p494m99asakbvqxh8rz7zwnlzg69";
130
+ type = "gem";
131
+ };
132
+ version = "0.12.2";
133
+ };
134
+ rake = {
135
+ groups = ["default"];
136
+ platforms = [];
137
+ source = {
138
+ remotes = ["https://rubygems.org"];
139
+ sha256 = "0jcabbgnjc788chx31sihc5pgbqnlc1c75wakmqlbjdm8jns2m9b";
140
+ type = "gem";
141
+ };
142
+ version = "10.5.0";
143
+ };
144
+ reline = {
145
+ dependencies = ["io-console"];
146
+ groups = ["default"];
147
+ platforms = [];
148
+ source = {
149
+ remotes = ["https://rubygems.org"];
150
+ sha256 = "0908ijrngc3wkn5iny7d0kxkp74w6ixk2nwzzngplplfla1vkp8x";
151
+ type = "gem";
152
+ };
153
+ version = "0.1.2";
154
+ };
155
+ rspec = {
156
+ dependencies = ["rspec-core" "rspec-expectations" "rspec-mocks"];
157
+ groups = ["default"];
158
+ platforms = [];
159
+ source = {
160
+ remotes = ["https://rubygems.org"];
161
+ sha256 = "15ppasvb9qrscwlyjz67ppw1lnxiqnkzx5vkx1bd8x5n3dhikxc3";
162
+ type = "gem";
163
+ };
164
+ version = "3.8.0";
165
+ };
166
+ rspec-core = {
167
+ dependencies = ["rspec-support"];
168
+ groups = ["default"];
169
+ platforms = [];
170
+ source = {
171
+ remotes = ["https://rubygems.org"];
172
+ sha256 = "1p1s5bnbqp3sxk67y0fh0x884jjym527r0vgmhbm81w7aq6b7l4p";
173
+ type = "gem";
174
+ };
175
+ version = "3.8.0";
176
+ };
177
+ rspec-expectations = {
178
+ dependencies = ["diff-lcs" "rspec-support"];
179
+ groups = ["default"];
180
+ platforms = [];
181
+ source = {
182
+ remotes = ["https://rubygems.org"];
183
+ sha256 = "1c4gs5ybf7km0qshdm92p38zvg32n1j2kr5fgs2icacz7xf2y6fy";
184
+ type = "gem";
185
+ };
186
+ version = "3.8.3";
187
+ };
188
+ rspec-mocks = {
189
+ dependencies = ["diff-lcs" "rspec-support"];
190
+ groups = ["default"];
191
+ platforms = [];
192
+ source = {
193
+ remotes = ["https://rubygems.org"];
194
+ sha256 = "06y508cjqycb4yfhxmb3nxn0v9xqf17qbd46l1dh4xhncinr4fyp";
195
+ type = "gem";
196
+ };
197
+ version = "3.8.0";
198
+ };
199
+ rspec-support = {
200
+ groups = ["default"];
201
+ platforms = [];
202
+ source = {
203
+ remotes = ["https://rubygems.org"];
204
+ sha256 = "0p3m7drixrlhvj2zpc38b11x145bvm311x6f33jjcxmvcm0wq609";
205
+ type = "gem";
206
+ };
207
+ version = "3.8.0";
208
+ };
209
+ rspec_junit_formatter = {
210
+ dependencies = ["rspec-core"];
211
+ groups = ["default"];
212
+ platforms = [];
213
+ source = {
214
+ remotes = ["https://rubygems.org"];
215
+ sha256 = "1aynmrgnv26pkprrajvp7advb8nbh0x4pkwk6jwq8qmwzarzk21p";
216
+ type = "gem";
217
+ };
218
+ version = "0.4.1";
219
+ };
220
+ thor = {
221
+ groups = ["default"];
222
+ platforms = [];
223
+ source = {
224
+ remotes = ["https://rubygems.org"];
225
+ sha256 = "1yhrnp9x8qcy5vc7g438amd5j9sw83ih7c30dr6g6slgw9zj3g29";
226
+ type = "gem";
227
+ };
228
+ version = "0.20.3";
229
+ };
230
+ }
@@ -0,0 +1,41 @@
1
+ #! /usr/bin/env nix-shell
2
+ #! nix-shell -i ruby -p ruby -p bundler -p bundix
3
+ # frozen_string_literal: true
4
+
5
+ # Bundix doesn't support `gemspec` directive in Gemfiles, as it doesn't copy the
6
+ # gemspec (and its dependencies) into the store.
7
+ # This workaround is from https://github.com/manveru/bundix/issues/10#issuecomment-405879379
8
+
9
+ require 'shellwords'
10
+
11
+ def sh(*args)
12
+ warn args.shelljoin
13
+ system(*args) || raise
14
+ end
15
+
16
+ sh 'bundle', 'lock'
17
+
18
+ require 'fileutils'
19
+ require 'bundler'
20
+
21
+ lockfile = Bundler::LockfileParser.new(File.read('Gemfile.lock'))
22
+ gems = lockfile.specs.select { |spec| spec.source.is_a?(Bundler::Source::Rubygems) }
23
+ sources = [URI('https://rubygems.org/')] | gems.map(&:source).flat_map(&:remotes)
24
+
25
+ FileUtils.mkdir_p 'nix/gem'
26
+ Dir.chdir 'nix/gem' do
27
+ ['Gemfile', 'Gemfile.lock', 'gemset.nix'].each do |f|
28
+ File.delete(f) if File.exist?(f)
29
+ end
30
+
31
+ File.open('Gemfile', 'w') do |gemfile|
32
+ sources.each { |source| gemfile.puts "source #{source.to_s.inspect}" }
33
+ gemfile.puts
34
+
35
+ gems.each do |gem|
36
+ gemfile.puts "gem #{gem.name.inspect}, #{gem.version.to_s.inspect}"
37
+ end
38
+ end
39
+
40
+ sh 'bundix', '-l'
41
+ end
@@ -0,0 +1,10 @@
1
+ with (import <nixpkgs> {});
2
+ let
3
+ env = bundlerEnv {
4
+ name = "bundler-env";
5
+ gemdir = ./nix/gem;
6
+ };
7
+ in stdenv.mkDerivation {
8
+ name = "shell";
9
+ buildInputs = [ env ];
10
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Griffin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-08 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -174,6 +174,7 @@ extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
176
  - ".circleci/config.yml"
177
+ - ".envrc"
177
178
  - ".gitignore"
178
179
  - ".rspec"
179
180
  - ".travis.yml"
@@ -196,7 +197,12 @@ files:
196
197
  - lib/phraseapp_updater/phraseapp_api.rb
197
198
  - lib/phraseapp_updater/version.rb
198
199
  - lib/phraseapp_updater/yml_config_loader.rb
200
+ - nix/gem/Gemfile
201
+ - nix/gem/Gemfile.lock
202
+ - nix/gem/gemset.nix
203
+ - nix/generate.rb
199
204
  - phraseapp_updater.gemspec
205
+ - shell.nix
200
206
  homepage: https://app.engoo.com
201
207
  licenses:
202
208
  - MIT