bullet_train-super_scaffolding 1.0.23 → 1.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70ece838f74f54649206711a4b47490b7b964a0f46a88b011f825991394b2b62
4
- data.tar.gz: 340950b5e4178927adcb07af2a8c66c4cafefb12f6d19d4c2c325553ec2dfe50
3
+ metadata.gz: c51b54399bb608b01931f86efd965719fe7bd4231107a903c72d06411fb9f6b3
4
+ data.tar.gz: 977733e8384c06ce13676a41f273783f9b8d1e90ad3ded2b82c6d7c533bf4225
5
5
  SHA512:
6
- metadata.gz: e8cb9655bb6ec31eda2d3f3a4b8cd06a888e40b840ac4f49757f980b645188dbf8f29f5e8f7e748fa64eaf55cc3b89af94ba5ff75407eb5b52628f461c9b0fa8
7
- data.tar.gz: 6f7cc7408eacecdcb81038d582fafec8b8085ce42929ce21c5976f53cff277d3506754f16c9a13eddc41f76b45bb7f2daa9f82c3a10ee4b0568ba5ca9213ce2b
6
+ metadata.gz: '063490810ef08ba8cbd454ffde388101538973e76c1fabbe80f1bc2362b73009485114a684ac373a9e0e0bc75eda107623959cd74f2742adace07fdea165168f'
7
+ data.tar.gz: 70713bf20a0addeb635a89b0dd7c45f80c39faf9c8d80f9d20046f39cb0781529ac74ac7258e83e0d67c5a8712c722733de8ac3e0fd3a30b280a8ba237380115
@@ -78,7 +78,9 @@ module BulletTrain
78
78
 
79
79
  # User OAuth.
80
80
  "./app/models/oauth/stripe_account.rb",
81
+ "./app/models/concerns/oauth/stripe_accounts/base.rb",
81
82
  "./app/models/webhooks/incoming/oauth/stripe_account_webhook.rb",
83
+ "./app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb",
82
84
  "./app/controllers/account/oauth/stripe_accounts_controller.rb",
83
85
  "./app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb",
84
86
  "./app/views/account/oauth/stripe_accounts",
@@ -89,6 +91,7 @@ module BulletTrain
89
91
 
90
92
  # Team Integration.
91
93
  "./app/models/integrations/stripe_installation.rb",
94
+ "./app/models/concerns/integrations/stripe_installations/base.rb",
92
95
  # './app/serializers/api/v1/integrations/stripe_installation_serializer.rb',
93
96
  "./app/controllers/account/integrations/stripe_installations_controller.rb",
94
97
  "./app/views/account/integrations/stripe_installations",
@@ -101,7 +104,7 @@ module BulletTrain
101
104
  "./app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb"
102
105
 
103
106
  ].each do |name|
104
- if File.directory?(name)
107
+ if File.directory?(legacy_resolve_template_path(name))
105
108
  oauth_scaffold_directory(name, options)
106
109
  else
107
110
  oauth_scaffold_file(name, options)
@@ -109,7 +112,7 @@ module BulletTrain
109
112
  end
110
113
 
111
114
  oauth_scaffold_add_line_to_file("./app/views/devise/shared/_oauth.html.erb", "<%= render 'devise/shared/oauth/stripe', verb: verb if stripe_enabled? %>", "<%# 🚅 super scaffolding will insert new oauth providers above this line. %>", options, prepend: true)
112
- oauth_scaffold_add_line_to_file("./app/views/account/users/edit.html.erb", "<%= render 'account/oauth/stripe_accounts/index', context: @user, stripe_accounts: @user.oauth_stripe_accounts if stripe_enabled? %>", "<% # 🚅 super scaffolding will insert new oauth providers above this line. %>", options, prepend: true)
115
+ oauth_scaffold_add_line_to_file("./app/views/account/users/_oauth.html.erb", "<%= render 'account/oauth/stripe_accounts/index', context: @user, stripe_accounts: @user.oauth_stripe_accounts if stripe_enabled? %>", "<% # 🚅 super scaffolding will insert new oauth providers above this line. %>", options, prepend: true)
113
116
  oauth_scaffold_add_line_to_file("./config/initializers/devise.rb", "config.omniauth :stripe_connect, ENV['STRIPE_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], {\n ## specify options for your oauth provider here, e.g.:\n # scope: 'read_products,read_orders,write_content',\n }\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
114
117
  oauth_scaffold_add_line_to_file("./app/controllers/account/oauth/omniauth_callbacks_controller.rb", "def stripe_connect\n callback(\"Stripe\", team_id_from_env)\n end\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
115
118
  oauth_scaffold_add_line_to_file("./app/models/team.rb", "has_many :integrations_stripe_installations, class_name: 'Integrations::StripeInstallation', dependent: :destroy if stripe_enabled?", "# 🚅 add oauth providers above.", options, prepend: true)
@@ -122,12 +125,7 @@ module BulletTrain
122
125
  oauth_scaffold_add_line_to_file("./Gemfile", "gem 'omniauth-stripe-connect'", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
123
126
  oauth_scaffold_add_line_to_file("./lib/bullet_train.rb", "def stripe_enabled?\n ENV['STRIPE_CLIENT_ID'].present? && ENV['STRIPE_SECRET_KEY'].present?\nend\n", "# 🚅 super scaffolding will insert new oauth providers above this line.", options, prepend: true)
124
127
  oauth_scaffold_add_line_to_file("./lib/bullet_train.rb", "stripe_enabled?,", "# 🚅 super scaffolding will insert new oauth provider checks above this line.", options, prepend: true)
125
- oauth_scaffold_add_line_to_file("./app/models/ability.rb", "if stripe_enabled?
126
- can [:read, :create, :destroy], Oauth::StripeAccount, user_id: user.id
127
- can :manage, Integrations::StripeInstallation, team_id: user.team_ids
128
- can :destroy, Integrations::StripeInstallation, oauth_stripe_account: {user_id: user.id}
129
- end
130
- ", "# 🚅 super scaffolding will insert any new oauth providers above.", options, prepend: true)
128
+ oauth_scaffold_add_line_to_file("./app/models/ability.rb", "if stripe_enabled?\n can [:read, :create, :destroy], Oauth::StripeAccount, user_id: user.id\n can :manage, Integrations::StripeInstallation, team_id: user.team_ids\n can :destroy, Integrations::StripeInstallation, oauth_stripe_account: {user_id: user.id}\n end\n", "# 🚅 super scaffolding will insert any new oauth providers above.", options, prepend: true)
131
129
 
132
130
  # find the database migration that defines this relationship.
133
131
  migration_file_name = `grep "create_table #{oauth_transform_string(":oauth_stripe_accounts", options)}" db/migrate/*`.split(":").first
@@ -147,6 +145,11 @@ module BulletTrain
147
145
  puts ""
148
146
  puts "You'll probably need to `bundle install`.".green
149
147
  puts ""
148
+ puts "You'll need to configure API keys for this provider in `config/application.yml`, like so:"
149
+ puts ""
150
+ puts oauth_transform_string(" STRIPE_CLIENT_ID: ...", options)
151
+ puts oauth_transform_string(" STRIPE_SECRET_KEY: ...", options)
152
+ puts ""
150
153
  puts "If the OAuth provider asks you for some whitelisted callback URLs, the URL structure for those is as so:"
151
154
  puts ""
152
155
  path = "users/auth/stripe_connect/callback"
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.0.23"
3
+ VERSION = "1.0.24"
4
4
  end
5
5
  end
@@ -1,3 +1,15 @@
1
+ def legacy_resolve_template_path(file)
2
+ # Figure out the actual location of the file.
3
+ # Originally all the potential source files were in the repository alongside the application.
4
+ # Now the files could be provided by an included Ruby gem, so we allow those Ruby gems to register their base
5
+ # path and then we check them in order to see which template we should use.
6
+ BulletTrain::SuperScaffolding.template_paths.map do |base_path|
7
+ base_path = Pathname.new(base_path)
8
+ resolved_path = base_path.join(file).to_s
9
+ File.exist?(resolved_path) ? resolved_path : nil
10
+ end.compact.first || raise("Couldn't find the Super Scaffolding template for `#{file}` in any of the following locations:\n\n#{BulletTrain::SuperScaffolding.template_paths.join("\n")}")
11
+ end
12
+
1
13
  def legacy_replace_in_file(file, before, after)
2
14
  puts "Replacing in '#{file}'."
3
15
  target_file_content = File.read(file)
@@ -61,14 +73,18 @@ def decode_double_replacement_fix(string)
61
73
  end
62
74
 
63
75
  def oauth_scaffold_directory(directory, options)
76
+ transformed_directory_name = oauth_transform_string(directory, options)
64
77
  begin
65
- Dir.mkdir(oauth_transform_string(directory, options))
66
- rescue
67
- nil
78
+ Dir.mkdir(transformed_directory_name)
79
+ rescue Errno::EEXIST => _
80
+ puts "The directory #{transformed_directory_name} already exists, skipping generation.".yellow
81
+ rescue Errno::ENOENT => _
82
+ puts "Proceeding to generate '#{transformed_directory_name}'."
68
83
  end
69
- Dir.foreach(directory) do |file|
84
+
85
+ Dir.foreach(legacy_resolve_template_path(directory)) do |file|
70
86
  file = "#{directory}/#{file}"
71
- unless File.directory?(file)
87
+ unless File.directory?(legacy_resolve_template_path(file))
72
88
  oauth_scaffold_file(file, options)
73
89
  end
74
90
  end
@@ -80,7 +96,7 @@ def oauth_scaffold_file(file, options)
80
96
  transformed_file_content = []
81
97
 
82
98
  skipping = false
83
- File.open(file).each_line do |line|
99
+ File.open(legacy_resolve_template_path(file)).each_line do |line|
84
100
  if line.include?("# 🚅 skip when scaffolding.")
85
101
  next
86
102
  end
@@ -64,11 +64,11 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
64
64
  puts ""
65
65
  puts "Attributes that end with `_id` or `_ids` trigger awesome, powerful magic in Super Scaffolding. However, because no `#{attribute_options[:class_name]}` class was found defined in `#{file_name}`, you'll need to specify a `class_name` that exists to let us know what model class is on the other side of the association, like so:".red
66
66
  puts ""
67
- puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}[class_name=#{name.gsub(/_ids?$/, "").classify}]".red
67
+ puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}{class_name=#{name.gsub(/_ids?$/, "").classify}}".red
68
68
  puts ""
69
- puts "If `#{name}` is just a regular field and isn't backed by an ActiveRecord association, you can skip all this with the `[vanilla]` option, e.g.:".red
69
+ puts "If `#{name}` is just a regular field and isn't backed by an ActiveRecord association, you can skip all this with the `{vanilla}` option, e.g.:".red
70
70
  puts ""
71
- puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}[vanilla]".red
71
+ puts " bin/super-scaffold #{scaffolding_type} #{child}#{" " + parent if parent.present?} #{name}:#{type}{vanilla}".red
72
72
  puts ""
73
73
  exit
74
74
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 1.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: standard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: 6.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bullet_train
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: indefinite_article
29
57
  requirement: !ruby/object:Gem::Requirement