bullet_train-super_scaffolding 1.6.0 → 1.6.2

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: deba742f563b6d3def090a3b04a3a8efdcac8750bc2828575cd6cc0804ae5390
4
- data.tar.gz: 5d15eae1ce2d7770ee8ef10cd49022974fd2dd746a10cee22dc032b7bea38b74
3
+ metadata.gz: 839704c2b3b349456b76b953e04d84a4c328261b3608b48fb8b80910103a632b
4
+ data.tar.gz: 16b194cc27b81d0fddd58c264b06eadc63631d1297e4267f4f35434a8b661983
5
5
  SHA512:
6
- metadata.gz: 601210d754a40a9d0d62555ba661a1ba35463e68aef0b2adbac930cd215def4bed94288783343bb68232a987980b8f6bc816e2ac4399469cecf4300e03928b12
7
- data.tar.gz: c1b8e0cc87d2a648b589fc00eb3eaba87699591f04e9e4daf47b1cff0356cc9bb8a207aecbf10ac28135882e853ebaa3e26dd8d66e371ea0332dd581f0acb4a9
6
+ metadata.gz: 0d38f9a63b1d5ca5cd2c058fb4e6c101692c54bcd493f40cc5cac6cdee747cf13b08252368c3e4673e275015eb58687f3239204b2e7686c41398d59372c4f64c
7
+ data.tar.gz: bbf19eae23f789dbdd75a905fa3a9e8b0bde3b1f0fe1f6a25716ed62a4b0b99a3a251a97c943e435877d17de04aaa093227a95254aa6d2ed47d4fc6e19b9b911
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.0"
3
+ VERSION = "1.6.2"
4
4
  end
5
5
  end
@@ -50,6 +50,19 @@ def standard_protip
50
50
  puts "If you do that, you can reset to your last commit state by using `git checkout .` and `git clean -d -f` ."
51
51
  end
52
52
 
53
+ def git_status
54
+ `git status`.split("\n")
55
+ end
56
+
57
+ def has_untracked_files?(status_lines)
58
+ status_lines.include?("Untracked files:")
59
+ end
60
+
61
+ # All untracked files begin with a tab (i.e. - "\tapp/models/model.rb").
62
+ def get_untracked_files(status_lines)
63
+ `git ls-files --other --exclude-standard`.split("\n")
64
+ end
65
+
53
66
  def check_required_options_for_attributes(scaffolding_type, attributes, child, parent = nil)
54
67
  tableized_parent = nil
55
68
 
@@ -183,7 +196,24 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
183
196
  puts "Adding new fields to #{child} with '#{generation_command}'".green
184
197
  end
185
198
  puts ""
186
- `#{generation_command}` unless @options["skip-migration-generation"]
199
+
200
+ unless @options["skip-migration-generation"]
201
+ untracked_files = has_untracked_files?(git_status) ? get_untracked_files(git_status) : []
202
+ generation_thread = Thread.new { `#{generation_command}` }
203
+ generation_thread.join # Wait for the process to finish.
204
+
205
+ newly_untracked_files = has_untracked_files?(git_status) ? get_untracked_files(git_status) : []
206
+ if (newly_untracked_files - untracked_files).size.zero?
207
+ error_message = <<~MESSAGE
208
+ Since you have already created the #{child} model, Super Scaffolding won't allow you to re-create it.
209
+ You can either delete the model and try Super Scaffolding again, or add the `--skip-migration-generation`
210
+ flag to Super Scaffold the classic Bullet Train way.
211
+ MESSAGE
212
+ puts ""
213
+ puts error_message.red
214
+ exit 1
215
+ end
216
+ end
187
217
  end
188
218
  end
189
219
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-04 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard