bullet_train 1.2.8 → 1.2.10
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/app/helpers/attributes_helper.rb +2 -2
- data/app/models/billing/mock_limiter.rb +5 -1
- data/app/models/concerns/records/base.rb +8 -9
- data/app/models/concerns/users/base.rb +1 -1
- data/app/views/devise/passwords/edit.html.erb +1 -1
- data/docs/webhooks/incoming.md +5 -1
- data/lib/bullet_train/configuration.rb +15 -0
- data/lib/bullet_train/engine.rb +15 -0
- data/lib/bullet_train/version.rb +1 -1
- data/lib/bullet_train.rb +9 -0
- data/lib/tasks/bullet_train_tasks.rake +36 -42
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c6a06a235e23a68bf1e4855fb344aadba158538aa2ab823118fbebc252059649
         | 
| 4 | 
            +
              data.tar.gz: 2ec8399302ea2e4539e9593b8cabc741e5ad2eb1508a2f29e7591ec614d05098
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 23e1d1200c9139fd37e892cd6bd025a26a22960a9076567ca16b14e6ff24445dbaf2cfe16258078f670beda1d86a7300ed089f4b1fadc72e2d08ee0636747e5e
         | 
| 7 | 
            +
              data.tar.gz: b9ee30bfe129d2e9d7492599ead1fe82d0768853f4e39ba03621c12ec2990bd0e4c24359c1d31d171e22908be376628e6411c01c6e4b1376f5eb486d1c941da9
         | 
| @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            module AttributesHelper
         | 
| 2 2 | 
             
              def current_attributes_object
         | 
| 3 | 
            -
                @_attributes_helper_objects | 
| 3 | 
            +
                @_attributes_helper_objects&.last
         | 
| 4 4 | 
             
              end
         | 
| 5 5 |  | 
| 6 6 | 
             
              def current_attributes_strategy
         | 
| 7 | 
            -
                @_attributes_helper_strategies | 
| 7 | 
            +
                @_attributes_helper_strategies&.last
         | 
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 10 | 
             
              def with_attribute_settings(options)
         | 
| @@ -82,18 +82,17 @@ module Records::Base | |
| 82 82 |  | 
| 83 83 | 
             
              # TODO This should really be in the API package and included from there.
         | 
| 84 84 | 
             
              if defined?(BulletTrain::Api)
         | 
| 85 | 
            -
                 | 
| 86 | 
            -
             | 
| 87 | 
            -
                  controller = "Api | 
| 85 | 
            +
                # We default this to the current version of the API, but developers can request a specific version.
         | 
| 86 | 
            +
                def to_api_json(api_version = BulletTrain::Api.current_version_numeric)
         | 
| 87 | 
            +
                  controller = "Api::V#{api_version}::ApplicationController".constantize.new
         | 
| 88 88 | 
             
                  # TODO We need to fix host names here.
         | 
| 89 89 | 
             
                  controller.request = ActionDispatch::Request.new({})
         | 
| 90 90 | 
             
                  local_class_key = self.class.name.underscore.split("/").last.to_sym
         | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
                  )
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  # Returns a hash, not string.
         | 
| 93 | 
            +
                  JbuilderTemplate.new(controller.view_context) do |json|
         | 
| 94 | 
            +
                    json.partial! "api/#{BulletTrain::Api.current_version}/#{self.class.name.underscore.pluralize}/#{local_class_key}", local_class_key => self
         | 
| 95 | 
            +
                  end.attributes!
         | 
| 97 96 | 
             
                end
         | 
| 98 97 | 
             
              end
         | 
| 99 98 | 
             
            end
         | 
| @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
              <% p.content_for :title, @title %>
         | 
| 4 4 | 
             
              <% p.content_for :body do %>
         | 
| 5 5 | 
             
                <% within_fields_namespace(:update_self) do %>
         | 
| 6 | 
            -
                  <%= form_for(resource, as: resource_name, url: password_path(resource_name), class: 'form',  | 
| 6 | 
            +
                  <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: 'form', method: :put }) do |f| %>
         | 
| 7 7 | 
             
                    <%= f.hidden_field :reset_password_token %>
         | 
| 8 8 | 
             
                    <%= render 'account/shared/forms/errors', form: f, attributes: [:reset_password_token] %>
         | 
| 9 9 | 
             
                    <%= render 'shared/fields/password_field', form: f, method: :password, options: {autofocus: true, autocomplete: "off"} %>
         | 
    
        data/docs/webhooks/incoming.md
    CHANGED
    
    | @@ -1,3 +1,7 @@ | |
| 1 1 | 
             
            # Incoming Webhooks
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            Bullet Train makes it trivial to scaffold new endpoints where external systems can send you webhooks and they can be processed asyncronously in a background job. For more information, run:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ```
         | 
| 6 | 
            +
            bin/super-scaffold incoming-webhooks
         | 
| 7 | 
            +
            ```
         | 
    
        data/lib/bullet_train/engine.rb
    CHANGED
    
    | @@ -1,3 +1,18 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              # We hoist the Devise engine, so its app/views directory is always after ours in a Rails app's view_paths.
         | 
| 3 | 
            +
              #
         | 
| 4 | 
            +
              # This is a quirk of how Rails engines compose, since engines `prepend_view_path` with their views:
         | 
| 5 | 
            +
              # https://github.com/rails/rails/blob/9f141a423d551f7f421f54d1372e65ef6ed1f0be/railties/lib/rails/engine.rb#L606
         | 
| 6 | 
            +
              #
         | 
| 7 | 
            +
              # If users put devise after bullet_train in their Gemfile, Bundler requires the gems in that order,
         | 
| 8 | 
            +
              # and devise's `prepend_view_path` would be called last, thus being prepended ahead of BulletTrain when Rails looks up views.
         | 
| 9 | 
            +
              #
         | 
| 10 | 
            +
              # Note: if this breaks down in the future, we may want to look into config.railties_order.
         | 
| 11 | 
            +
              require "devise"
         | 
| 12 | 
            +
            rescue LoadError
         | 
| 13 | 
            +
              # Devise isn't in the Gemfile, and we don't have any other load order dependencies.
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 1 16 | 
             
            module BulletTrain
         | 
| 2 17 | 
             
              class Engine < ::Rails::Engine
         | 
| 3 18 | 
             
              end
         | 
    
        data/lib/bullet_train/version.rb
    CHANGED
    
    
    
        data/lib/bullet_train.rb
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require "bullet_train/version"
         | 
| 2 2 | 
             
            require "bullet_train/engine"
         | 
| 3 3 | 
             
            require "bullet_train/resolver"
         | 
| 4 | 
            +
            require "bullet_train/configuration"
         | 
| 4 5 |  | 
| 5 6 | 
             
            require "bullet_train/fields"
         | 
| 6 7 | 
             
            require "bullet_train/roles"
         | 
| @@ -37,6 +38,14 @@ module BulletTrain | |
| 37 38 | 
             
              mattr_accessor :linked_gems, default: ["bullet_train"]
         | 
| 38 39 | 
             
              mattr_accessor :parent_class, default: "Team"
         | 
| 39 40 | 
             
              mattr_accessor :base_class, default: "ApplicationRecord"
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def self.configure
         | 
| 43 | 
            +
                if block_given?
         | 
| 44 | 
            +
                  yield(BulletTrain::Configuration.default)
         | 
| 45 | 
            +
                else
         | 
| 46 | 
            +
                  BulletTrain::Configuration.default
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 40 49 | 
             
            end
         | 
| 41 50 |  | 
| 42 51 | 
             
            def default_url_options_from_base_url
         | 
| @@ -118,16 +118,22 @@ namespace :bullet_train do | |
| 118 118 | 
             
                      when "--link", "--reset"
         | 
| 119 119 | 
             
                        set_core_gems(process[:flag], framework_packages)
         | 
| 120 120 | 
             
                        stream "bundle install"
         | 
| 121 | 
            -
                      when "--watch-js"
         | 
| 122 | 
            -
                         | 
| 121 | 
            +
                      when "--watch-js", "--clean-js"
         | 
| 122 | 
            +
                        package_name = process[:values].pop
         | 
| 123 | 
            +
                        framework_package = framework_packages.select { |k, v| k.to_s == package_name }
         | 
| 124 | 
            +
                        if framework_package.empty?
         | 
| 125 | 
            +
                          puts "Sorry, we couldn't find the package you're looking for.".red
         | 
| 126 | 
            +
                          puts ""
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                          npm_packages = framework_packages.select { |name, details| details[:npm].present? }
         | 
| 129 | 
            +
                          puts "Please enter one of the following package names when running `bin/hack --watch-js` or `bin/hack --clean-js`:"
         | 
| 130 | 
            +
                          npm_packages.each_with_index do |package, idx|
         | 
| 131 | 
            +
                            puts "#{idx + 1}. #{package.first}"
         | 
| 132 | 
            +
                          end
         | 
| 133 | 
            +
                          exit 1
         | 
| 134 | 
            +
                        end
         | 
| 123 135 |  | 
| 124 | 
            -
                         | 
| 125 | 
            -
                        puts "If you press `Ctrl + C` before the process completely exits, just run `bin/hack --clean-js`".yellow
         | 
| 126 | 
            -
                        set_npm_packages("--clean-js", framework_packages)
         | 
| 127 | 
            -
                        break
         | 
| 128 | 
            -
                      when "--clean-js"
         | 
| 129 | 
            -
                        set_npm_packages(process[:flag], framework_packages)
         | 
| 130 | 
            -
                        break
         | 
| 136 | 
            +
                        set_npm_package(process[:flag], framework_package)
         | 
| 131 137 | 
             
                      end
         | 
| 132 138 | 
             
                    end
         | 
| 133 139 |  | 
| @@ -194,16 +200,13 @@ namespace :bullet_train do | |
| 194 200 | 
             
                `#{ENV["IDE"] || "code"} local/bullet_train-core`
         | 
| 195 201 | 
             
                puts ""
         | 
| 196 202 |  | 
| 197 | 
            -
                puts "Bullet Train has a few npm packages, so we will  | 
| 198 | 
            -
                puts " | 
| 203 | 
            +
                puts "Bullet Train has a few npm packages, but we can only watch one at a time, so we will watch the `bullet_train` package.".blue
         | 
| 204 | 
            +
                puts "Any changes in your JavaScript files in this package will be recompiled as we go.".blue
         | 
| 205 | 
            +
                puts "Run `bin/hack --watch-js` to see which other npm packages you can watch.".blue
         | 
| 199 206 | 
             
                puts "When you're done, you can hit <Control + C> and we'll clean all off this up.".blue
         | 
| 200 207 | 
             
                puts ""
         | 
| 201 | 
            -
                 | 
| 202 | 
            -
             | 
| 203 | 
            -
                # Clean up the npm packages after the developer enters `Ctrl + C`.
         | 
| 204 | 
            -
                puts "Cleaning up npm packages...".blue
         | 
| 205 | 
            -
                puts "If you cancel out of this process early, just run `bin/hack --clean-js` to revert to your original npm packages.".blue
         | 
| 206 | 
            -
                set_npm_packages("--clean-js", framework_packages)
         | 
| 208 | 
            +
                bt_package = framework_packages.select { |k, v| k == :bullet_train }
         | 
| 209 | 
            +
                set_npm_package("--watch-js", bt_package)
         | 
| 207 210 |  | 
| 208 211 | 
             
                puts ""
         | 
| 209 212 | 
             
                puts "OK, here's a list of things this script still doesn't do you for you:".yellow
         | 
| @@ -246,33 +249,24 @@ namespace :bullet_train do | |
| 246 249 | 
             
                File.write("./Gemfile", new_lines.join)
         | 
| 247 250 | 
             
              end
         | 
| 248 251 |  | 
| 249 | 
            -
              def  | 
| 250 | 
            -
                 | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
             | 
| 261 | 
            -
                     | 
| 262 | 
            -
                     | 
| 263 | 
            -
             | 
| 252 | 
            +
              def set_npm_package(flag, package)
         | 
| 253 | 
            +
                package.each do |name, details|
         | 
| 254 | 
            +
                  if flag == "--watch-js"
         | 
| 255 | 
            +
                    puts "Make sure your server is running before proceeding. When you're ready, press <Enter>".blue
         | 
| 256 | 
            +
                    $stdin.gets.strip
         | 
| 257 | 
            +
             | 
| 258 | 
            +
                    puts "Linking JavaScript for #{name}".blue
         | 
| 259 | 
            +
                    stream "cd local/bullet_train-core/#{name} && yarn install && npm_config_yes=true && npx yalc link && cd ../../.. && npm_config_yes=true npx yalc link \"#{details[:npm]}\""
         | 
| 260 | 
            +
                    puts "#{name} has been linked.".blue
         | 
| 261 | 
            +
                    puts "Preparing to watch changes.".blue
         | 
| 262 | 
            +
                    stream "yarn --cwd local/bullet_train-core/#{name} watch"
         | 
| 263 | 
            +
             | 
| 264 | 
            +
                    # Provide a help message after the developer kills the process with `Ctrl + C`.
         | 
| 265 | 
            +
                    puts "Run `bin/hack --clean-js #{name}` to revert to using the original npm package in your application.".blue
         | 
| 266 | 
            +
                  elsif flag == "--clean-js"
         | 
| 267 | 
            +
                    puts "Going back to using original `#{name}` npm package in application.".blue
         | 
| 264 268 | 
             
                    puts ""
         | 
| 265 | 
            -
                    yarn_watch_command << "yarn --cwd local/bullet_train-core/#{package_name} watch"
         | 
| 266 | 
            -
                  end
         | 
| 267 | 
            -
             | 
| 268 | 
            -
                  # We use `&` to run the processes in parallel.
         | 
| 269 | 
            -
                  puts "Preparing to watch changes".blue
         | 
| 270 | 
            -
                  stream yarn_watch_command.join(" & ")
         | 
| 271 | 
            -
                elsif flag == "--clean-js"
         | 
| 272 | 
            -
                  puts "Resetting packages to their original path".blue
         | 
| 273 | 
            -
                  puts ""
         | 
| 274 269 |  | 
| 275 | 
            -
                  packages.each do |package_name, details|
         | 
| 276 270 | 
             
                    system "yarn yalc remove #{details[:npm]}"
         | 
| 277 271 | 
             
                    system "yarn add #{details[:npm]}"
         | 
| 278 272 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bullet_train
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.10
         | 
| 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-12- | 
| 11 | 
            +
            date: 2022-12-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: standard
         | 
| @@ -664,6 +664,7 @@ files: | |
| 664 664 | 
             
            - docs/webhooks/outgoing.md
         | 
| 665 665 | 
             
            - docs/zapier.md
         | 
| 666 666 | 
             
            - lib/bullet_train.rb
         | 
| 667 | 
            +
            - lib/bullet_train/configuration.rb
         | 
| 667 668 | 
             
            - lib/bullet_train/core_ext/string_emoji_helper.rb
         | 
| 668 669 | 
             
            - lib/bullet_train/engine.rb
         | 
| 669 670 | 
             
            - lib/bullet_train/resolver.rb
         | 
| @@ -696,7 +697,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 696 697 | 
             
                - !ruby/object:Gem::Version
         | 
| 697 698 | 
             
                  version: '0'
         | 
| 698 699 | 
             
            requirements: []
         | 
| 699 | 
            -
            rubygems_version: 3. | 
| 700 | 
            +
            rubygems_version: 3.4.1
         | 
| 700 701 | 
             
            signing_key:
         | 
| 701 702 | 
             
            specification_version: 4
         | 
| 702 703 | 
             
            summary: Bullet Train
         |