belt 0.4.2 → 0.4.3
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/CHANGELOG.md +16 -0
- data/lib/belt/cli/doctor_command.rb +21 -7
- data/lib/belt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2a6059e3ba3ce67327476626815d9a1b61b441836877277c44d04978dfa2727
|
|
4
|
+
data.tar.gz: d714bba5f18070ed1504e33f473a9fd2497019da7fe7c5609b9d97e4676d70ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6feaddb7cb071ee7cb75427544d2d32b65ddf9354c3fa08461a67247485fdd6adddf986d93d0ee3fa778ab491136ca14395e5b6dc67fc918eb19b748b8a4214
|
|
7
|
+
data.tar.gz: 56b99bafbc94e4abcb7fa64cb3ca7b1744591c17c84afea3fe1cab07bb1cbeffe6c76f7af5b6c6f19a51bebffecba10091a70125de012f885709e417cf817bd2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
- **`belt deploy` preflight no longer false-fails on `belongs_to ..., index: false`.**
|
|
8
|
+
The deploy preflight added in 0.4.2 demanded a `{Assoc}Index` GSI for *every*
|
|
9
|
+
`belongs_to`, ignoring `index: false` and `index: 'CustomName'` — the exact
|
|
10
|
+
opt-outs the table generator honours. The two halves of the gem disagreed: a
|
|
11
|
+
model that opts out (its reverse lookup is covered by another GSI, or it doesn't
|
|
12
|
+
need one) got a passing `belt setup tables` and a failing `belt deploy`, with no
|
|
13
|
+
way out but `--force`-ing the generator or pinning back to 0.4.1. The preflight's
|
|
14
|
+
index extraction now mirrors the generator exactly: it skips `index: false` and
|
|
15
|
+
honours an explicit `index: 'Name'`. `foreign_key:`-remapped associations
|
|
16
|
+
(`belongs_to :user, foreign_key: 'cognito_sub', index: false`) no longer demand a
|
|
17
|
+
phantom `UserIndex` either.
|
|
18
|
+
|
|
3
19
|
## Unreleased
|
|
4
20
|
|
|
5
21
|
### Bug Fix
|
|
@@ -262,19 +262,33 @@ module Belt
|
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
+
# Which GSIs a model's belongs_to declarations require. This MUST agree with the
|
|
266
|
+
# generator (TablesCommand#extract_belongs_to_indexes) or the two halves of the gem
|
|
267
|
+
# disagree: the generator refuses to create an index the preflight then demands,
|
|
268
|
+
# and `belt setup tables` → `belt deploy` loops forever.
|
|
269
|
+
#
|
|
270
|
+
# `index: false` opts out — the reverse lookup is covered some other way (the
|
|
271
|
+
# model's own indexes() entry under a different key, or no reverse lookup at all).
|
|
272
|
+
# The generator skips those, so the preflight must too.
|
|
273
|
+
#
|
|
274
|
+
# An explicit `index: 'Name'` overrides the convention name; we honour it so the
|
|
275
|
+
# check matches the GSI the model actually declared.
|
|
265
276
|
def extract_expected_indexes(content)
|
|
266
277
|
indexes = []
|
|
267
|
-
content.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
278
|
+
uncommented(content).scan(/belongs_to\s+:(\w+)([^\n]*)/) do |association_name, options|
|
|
279
|
+
next if options.match?(/index:\s*false/)
|
|
280
|
+
|
|
281
|
+
explicit = options.match(/index:\s*['"]([^'"]+)['"]/)
|
|
282
|
+
name = explicit ? explicit[1] : "#{Belt::Inflector.classify(association_name)}Index"
|
|
283
|
+
indexes << { name: name, association: association_name }
|
|
274
284
|
end
|
|
275
285
|
indexes
|
|
276
286
|
end
|
|
277
287
|
|
|
288
|
+
def uncommented(content)
|
|
289
|
+
content.lines.reject { |line| line.strip.start_with?('#') }.join
|
|
290
|
+
end
|
|
291
|
+
|
|
278
292
|
def check_cognito_auth
|
|
279
293
|
return unless Belt.root?
|
|
280
294
|
|
data/lib/belt/version.rb
CHANGED