bullet_train-super_scaffolding 1.6.0 → 1.6.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: deba742f563b6d3def090a3b04a3a8efdcac8750bc2828575cd6cc0804ae5390
4
- data.tar.gz: 5d15eae1ce2d7770ee8ef10cd49022974fd2dd746a10cee22dc032b7bea38b74
3
+ metadata.gz: 9b7efadfb9aedfb0c4f903bd3a3d3cfb4434049c028f36ceba9e431bb9b7fe49
4
+ data.tar.gz: 1ed8a32334f0f72d859abfdea2ab689a5e7222f452344254a5bc46ebda8069c1
5
5
  SHA512:
6
- metadata.gz: 601210d754a40a9d0d62555ba661a1ba35463e68aef0b2adbac930cd215def4bed94288783343bb68232a987980b8f6bc816e2ac4399469cecf4300e03928b12
7
- data.tar.gz: c1b8e0cc87d2a648b589fc00eb3eaba87699591f04e9e4daf47b1cff0356cc9bb8a207aecbf10ac28135882e853ebaa3e26dd8d66e371ea0332dd581f0acb4a9
6
+ metadata.gz: 1f68150179ed016be2eb00f51500eaaedae7b5f84dd851118422c4fe78024e4506f83ce47aa35d9526b7a6cb2f1a1e3d3692c694d124551436bd9498a1dd531c
7
+ data.tar.gz: 6934fcc20f30bf18d9a29c3d5b878a83612b01697af0226defa7c94bf7543c5423534f6397bd6bef472d2f63578d5558059df9ebb73ca8f7894aae0063bddc7b
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.0"
3
+ VERSION = "1.6.1"
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.1
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