bullet_train-super_scaffolding 1.6.34 → 1.6.36

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: 348e2d1c3d553ea106a60c2e600a3f886f2a851f12b1e7c628325e290af9ac6f
4
- data.tar.gz: fdae29e7f29e70a45dca618d0caeb6c6d2b3d90aecd4130918fe758f349e47cc
3
+ metadata.gz: 78fc168b87086abdff9a77f6fca18414f48ecfa480b96675e5d57d5b15461834
4
+ data.tar.gz: 3a219e7452a7d1cee87498fff9626636758efbd9c6276b38fc8071689271299c
5
5
  SHA512:
6
- metadata.gz: 50231140243f71280e6dfc7ce8388d1e892d83c79a791b3b6b0a20d31d55fd33bb768c0613eefb02e5c82af623b1e79d0a6f0d7ca4fbb6bf7b65555c66aba2c3
7
- data.tar.gz: f2f991e16c416add60d8c0571ec45dce46aa28303f176b1e5fd9dde1fd8950cc63010c65bbcc313a84d236ab202bf517a175e216b06b84c2547d6bed66aff8e6
6
+ metadata.gz: 86f8893e04227ba822300e981e1a606ccb8242d22c6e3c628fa226b044f50c060dc1a4401b9ae1150bfc9be67718d349d3a8ab23e6c0b12a4d682a8babcd9c00
7
+ data.tar.gz: 89ea52f90b89ffde18b3458ccbb20df62848be892c823feb8fe69508b09a46dd451b376e9ec6e298f98dfe6bcfa0d78ff365e292000e470ae1750cd74b684097
@@ -40,7 +40,7 @@
40
40
 
41
41
  <%# 🚅 super scaffolding will insert new targets one parent action model buttons above this line. %>
42
42
  <%# 🚅 super scaffolding will insert new bulk action model buttons above this line. %>
43
- <%= render "shared/bulk_action_select" if creative_concepts.many? %>
43
+ <%= render "shared/bulk_action_select" if creative_concepts.any? %>
44
44
 
45
45
  <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:absolutely_abstract_creative_concept)} back" unless hide_back %>
46
46
  <% end %>
@@ -51,7 +51,7 @@
51
51
 
52
52
  <%# 🚅 super scaffolding will insert new targets one parent action model buttons above this line. %>
53
53
  <%# 🚅 super scaffolding will insert new bulk action model buttons above this line. %>
54
- <%= render "shared/bulk_action_select" if tangible_things.many? %>
54
+ <%= render "shared/bulk_action_select" if tangible_things.any? %>
55
55
 
56
56
  <% unless hide_back %>
57
57
  <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:completely_concrete_tangible_thing)} back" %>
@@ -45,16 +45,41 @@ module BulletTrain
45
45
  unless File.exist?(oauth_transform_string("./app/models/oauth/stripe_account.rb", options)) &&
46
46
  File.exist?(oauth_transform_string("./app/models/integrations/stripe_installation.rb", options)) &&
47
47
  File.exist?(oauth_transform_string("./app/models/webhooks/incoming/oauth/stripe_account_webhook.rb", options))
48
- puts ""
49
- puts oauth_transform_string("🚨 Before doing the actual Super Scaffolding, you'll need to generate the models like so:", options).red
50
- puts ""
51
- puts oauth_transform_string(" rails g model Oauth::StripeAccount uid:string data:jsonb user:references", options).red
52
- puts oauth_transform_string(" rails g model Integrations::StripeInstallation team:references oauth_stripe_account:references name:string", options).red
53
- puts oauth_transform_string(" rails g model Webhooks::Incoming::Oauth::StripeAccountWebhook data:jsonb processed_at:datetime verified_at:datetime oauth_stripe_account:references", options).red
54
- puts ""
55
- puts "However, don't do the `rake db:migrate` until after you re-run Super Scaffolding, as it will need to update some settings in those migrations.".red
56
- puts ""
57
- return
48
+
49
+ oauth_model_data = {
50
+ "Oauth::StripeAccount": "rails generate model Oauth::StripeAccount uid:string data:jsonb user:references",
51
+ "Integrations::StripeInstallation": "rails generate model Integrations::StripeInstallation team:references oauth_stripe_account:references name:string",
52
+ "Webhooks::Incoming::Oauth::StripeAccountWebhook": "rails generate model Webhooks::Incoming::Oauth::StripeAccountWebhook data:jsonb processed_at:datetime verified_at:datetime oauth_stripe_account:references"
53
+ }
54
+
55
+ # Transform class names and model migrations.
56
+ transformed_data = {}
57
+ oauth_model_data.each do |key, value|
58
+ transformed_data[oauth_transform_string(key.to_s, options)] = oauth_transform_string(value, options)
59
+ end
60
+
61
+ if @options["skip-migration-generation"]
62
+ undefined_models = transformed_data.keys.each { |key| key.safe_constantize.nil? }
63
+ if undefined_models.any?
64
+ puts ""
65
+ puts "We could not find the following models:".red
66
+ undefined_models.each { |model| puts " #{model}".red }
67
+ puts ""
68
+ puts "🚨 Before doing the actual Super Scaffolding, you'll need to generate the models like so:".red
69
+ puts ""
70
+ transformed_data.each { |_, migration| puts " #{migration}".red }
71
+ puts ""
72
+ puts "However, don't do the `rake db:migrate` until after you re-run Super Scaffolding, as it will need to update some settings in those migrations.".red
73
+ puts ""
74
+ return
75
+ end
76
+ else
77
+ transformed_data.each do |klass, generation_command|
78
+ puts "Generating #{klass} model with '#{generation_command}'".green
79
+ generation_thread = Thread.new { `#{generation_command}` }
80
+ generation_thread.join # Wait for the process to finish.
81
+ end
82
+ end
58
83
  end
59
84
 
60
85
  icon_name = nil
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.6.34"
3
+ VERSION = "1.6.36"
4
4
  end
5
5
  end
@@ -37,6 +37,19 @@ class Scaffolding::ClassNamesTransformer
37
37
  parts.last
38
38
  end
39
39
 
40
+ # "In context" here means all of the parts in a namespace
41
+ # without reference to the parts that overlap.
42
+ #
43
+ # For example:
44
+ # Returns everything because there is no overlap.
45
+ # Parent: Team
46
+ # Child: Projects::Site
47
+ # Return value: [["Projects", "Site"], ["Team"]]
48
+ #
49
+ # Returns the namespaces/classes without the parts that overlap.
50
+ # Parent: Projects::Site
51
+ # Child: Projects::Sites::Url
52
+ # Return value: [["Url"], ["Site"]]
40
53
  def all_parts_in_context
41
54
  working_parts = parts
42
55
  working_parent_parts = parent_parts
@@ -316,6 +316,9 @@ class Scaffolding::RoutesFileManipulator
316
316
 
317
317
  within = find_or_create_namespaces(base_namespaces)
318
318
 
319
+ # Add any concerns passed as options.
320
+ add_concern(:sortable) if transformer_options["sortable"]
321
+
319
322
  # e.g. Project and Projects::Deliverable
320
323
  if parent_namespaces.empty? && child_namespaces.any? && parent_resource == child_namespaces.first
321
324
 
@@ -352,9 +355,13 @@ class Scaffolding::RoutesFileManipulator
352
355
  child_namespaces_without_parent = child_namespaces.dup
353
356
  child_namespaces_without_parent.shift
354
357
  deeply_nested_within = find_or_create_namespaces(child_namespaces_without_parent, scope_within)
355
- find_or_create_resource([child_resource], options: "shallow: false", within: deeply_nested_within)
358
+ routing_options = "shallow: false"
359
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
360
+ find_or_create_resource([child_resource], options: routing_options, within: deeply_nested_within)
356
361
  else
357
- find_or_create_resource([child_resource], options: "only: collection_actions", within: scope_within)
362
+ routing_options = "only: collection_actions"
363
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
364
+ find_or_create_resource([child_resource], options: routing_options, within: scope_within)
358
365
 
359
366
  # namespace :projects do
360
367
  # resources :deliverables, except: collection_actions
@@ -364,7 +371,9 @@ class Scaffolding::RoutesFileManipulator
364
371
  # because namespaces with the same name as the resource can exist on the same level.
365
372
  parent_block_start = Scaffolding::BlockManipulator.find_block_parent(parent_within, lines)
366
373
  namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
367
- find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
374
+ routing_options = "except: collection_actions"
375
+ routing_options += ", #{formatted_concerns}" if formatted_concerns
376
+ find_or_create_resource([child_resource], options: routing_options, within: namespace_line_within)
368
377
  unless find_namespaces(child_namespaces, within)[child_namespaces.last]
369
378
  raise "tried to insert `namespace :#{child_namespaces.last}` but it seems we failed"
370
379
  end
@@ -377,7 +386,7 @@ class Scaffolding::RoutesFileManipulator
377
386
  # resources :deliverables
378
387
  # end
379
388
  top_parent_namespace = find_namespaces(parent_namespaces, within)[parent_namespaces.first]
380
- find_or_create_resource(child_namespaces + [child_resource], within: top_parent_namespace)
389
+ find_or_create_resource(child_namespaces + [child_resource], options: formatted_concerns, within: top_parent_namespace)
381
390
 
382
391
  # resources :projects_deliverables, path: 'projects/deliverables' do
383
392
  # resources :objectives
@@ -394,7 +403,6 @@ class Scaffolding::RoutesFileManipulator
394
403
  within = find_or_convert_resource_block(parent_resource, options: "except: collection_actions", within: within)
395
404
  end
396
405
 
397
- add_concern(:sortable) if transformer_options["sortable"]
398
406
  find_or_create_resource(child_namespaces + [child_resource], options: formatted_concerns, within: within)
399
407
 
400
408
  end
@@ -174,7 +174,8 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
174
174
  # Generate the models/migrations with the attributes passed.
175
175
  if attributes_to_generate.any?
176
176
  case scaffolding_type
177
- # "join-model" is not here because the `rails g` command is written inline in its own scaffolder.
177
+ # "join-model" and "oauth-provider" are not here because the
178
+ # `rails g` command is written inline in their own respective scaffolders.
178
179
  when "crud"
179
180
  puts "Generating #{child} model with '#{generation_command}'".green
180
181
  when "crud-field"
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.34
4
+ version: 1.6.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-27 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard