pakyow-assets 0.1.2 → 1.0.0.rc1
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 +5 -5
- data/LICENSE +3 -19
- data/lib/pakyow/assets.rb +19 -0
- data/lib/pakyow/assets/actions/process.rb +63 -0
- data/lib/pakyow/assets/actions/public.rb +75 -0
- data/lib/pakyow/assets/asset.rb +238 -0
- data/lib/pakyow/assets/babel.rb +34 -0
- data/lib/pakyow/assets/behavior/assets.rb +45 -0
- data/lib/pakyow/assets/behavior/config.rb +137 -0
- data/lib/pakyow/assets/behavior/externals.rb +58 -0
- data/lib/pakyow/assets/behavior/packs.rb +162 -0
- data/lib/pakyow/assets/behavior/prelaunching.rb +19 -0
- data/lib/pakyow/assets/behavior/processing.rb +27 -0
- data/lib/pakyow/assets/behavior/rendering/install_assets.rb +39 -0
- data/lib/pakyow/assets/behavior/silencing.rb +35 -0
- data/lib/pakyow/assets/behavior/watching.rb +25 -0
- data/lib/pakyow/assets/errors.rb +16 -0
- data/lib/pakyow/assets/external.rb +103 -0
- data/lib/pakyow/assets/framework.rb +52 -0
- data/lib/pakyow/assets/pack.rb +171 -0
- data/lib/pakyow/assets/precompiler.rb +63 -0
- data/lib/pakyow/assets/source_map.rb +99 -0
- data/lib/pakyow/assets/tasks/precompile.rake +9 -0
- data/lib/pakyow/assets/tasks/update.rake +20 -0
- data/lib/pakyow/assets/types/css.rb +45 -0
- data/lib/pakyow/assets/types/js.rb +98 -0
- data/lib/pakyow/assets/types/sass.rb +69 -0
- data/lib/pakyow/assets/types/scss.rb +14 -0
- data/src/@babel/standalone@7.3.1/babel.min.js +165 -0
- data/src/@babel/standalone@7.4.5/babel.min.js +92359 -0
- metadata +146 -46
- data/CHANGELOG.md +0 -18
- data/README.md +0 -58
- data/lib/assets.rb +0 -221
- data/lib/config.rb +0 -37
- data/lib/middleware.rb +0 -42
- data/lib/pakyow-assets.rb +0 -31
- data/lib/preprocessors/css-preprocessor.rb +0 -16
- data/lib/preprocessors/image-preprocessor.rb +0 -1
- data/lib/preprocessors/javascript-preprocessor.rb +0 -16
- data/lib/preprocessors/sass-preprocessor.rb +0 -23
- data/lib/version.rb +0 -5
- data/pakyow-assets.gemspec +0 -21
    
        data/lib/config.rb
    DELETED
    
    | @@ -1,37 +0,0 @@ | |
| 1 | 
            -
            Pakyow::Config.register(:assets) { |config|
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              # registered asset stores
         | 
| 4 | 
            -
              config.opt :stores, lambda {
         | 
| 5 | 
            -
                @stores ||= {
         | 
| 6 | 
            -
                  default: File.join(Pakyow::Config.app.root, 'app', 'assets')
         | 
| 7 | 
            -
                }
         | 
| 8 | 
            -
              }
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              # whether or not pakyow should host assets
         | 
| 11 | 
            -
              config.opt :compile_on_request
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              # whether pakyow should compile assets on startup
         | 
| 14 | 
            -
              config.opt :compile_on_startup
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              # where assets should be compiled to
         | 
| 17 | 
            -
              config.opt :compiled_asset_path
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              # whether or not to cache the assets
         | 
| 20 | 
            -
              config.opt :cache
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              # whether or not to minify the assets
         | 
| 23 | 
            -
              config.opt :minify
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            }.env(:development) { |opts|
         | 
| 26 | 
            -
              opts.cache = false
         | 
| 27 | 
            -
              opts.compile_on_request = true
         | 
| 28 | 
            -
              opts.compile_on_startup = false
         | 
| 29 | 
            -
              opts.compiled_asset_path = '.assets'
         | 
| 30 | 
            -
              opts.minify = false
         | 
| 31 | 
            -
            }.env(:production) { |opts|
         | 
| 32 | 
            -
              opts.cache = true
         | 
| 33 | 
            -
              opts.compile_on_request = false
         | 
| 34 | 
            -
              opts.compile_on_startup = true
         | 
| 35 | 
            -
              opts.compiled_asset_path = 'public'
         | 
| 36 | 
            -
              opts.minify = true
         | 
| 37 | 
            -
            }
         | 
    
        data/lib/middleware.rb
    DELETED
    
    | @@ -1,42 +0,0 @@ | |
| 1 | 
            -
            require 'time'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Pakyow
         | 
| 4 | 
            -
              module Assets
         | 
| 5 | 
            -
                class Middleware
         | 
| 6 | 
            -
                  def initialize(app)
         | 
| 7 | 
            -
                    @app = app
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def call(env)
         | 
| 11 | 
            -
                    if Pakyow::Config.assets.compile_on_request
         | 
| 12 | 
            -
                      path = Pakyow::Assets.compiled_asset_path_for_request_path(env['PATH_INFO'])
         | 
| 13 | 
            -
                    else
         | 
| 14 | 
            -
                      path = File.join(Pakyow::Config.assets.compiled_asset_path, env['PATH_INFO'])
         | 
| 15 | 
            -
                    end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                    if path =~ /\.(.*)$/ && File.exists?(path)
         | 
| 18 | 
            -
                      catch :halt do
         | 
| 19 | 
            -
                        app = Pakyow.app.dup
         | 
| 20 | 
            -
                        app.context = AppContext.new(Request.new(env), Response.new)
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                        headers = {
         | 
| 23 | 
            -
                          'Content-Type' => Rack::Mime.mime_type(File.extname(path))
         | 
| 24 | 
            -
                        }
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                        if Pakyow::Config.assets.cache && Pakyow::Assets.fingerprinted?(File.extname(path))
         | 
| 27 | 
            -
                          mtime = File.mtime(path)
         | 
| 28 | 
            -
                          headers['Age'] = (Time.now - mtime).to_i
         | 
| 29 | 
            -
                          headers['Cache-Control'] = 'public, max-age=31536000'
         | 
| 30 | 
            -
                          headers['Vary'] = 'Accept-Encoding'
         | 
| 31 | 
            -
                          headers['Last-Modified'] = mtime.httpdate
         | 
| 32 | 
            -
                        end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                        [200, headers, File.open(path)]
         | 
| 35 | 
            -
                      end
         | 
| 36 | 
            -
                    else
         | 
| 37 | 
            -
                      @app.call(env)
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
                  end
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
            end
         | 
    
        data/lib/pakyow-assets.rb
    DELETED
    
    | @@ -1,31 +0,0 @@ | |
| 1 | 
            -
            require_relative 'assets'
         | 
| 2 | 
            -
            require_relative 'config'
         | 
| 3 | 
            -
            require_relative 'middleware'
         | 
| 4 | 
            -
            require_relative 'version'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require_relative 'preprocessors/css-preprocessor'
         | 
| 7 | 
            -
            require_relative 'preprocessors/image-preprocessor'
         | 
| 8 | 
            -
            require_relative 'preprocessors/javascript-preprocessor'
         | 
| 9 | 
            -
            require_relative 'preprocessors/sass-preprocessor'
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            Pakyow::App.after :configure do
         | 
| 12 | 
            -
              config.assets.stores.each_pair do |name, path|
         | 
| 13 | 
            -
                Pakyow::Assets.register_path_with_name(path, name)
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              if config.assets.compile_on_startup
         | 
| 17 | 
            -
                Pakyow::App.processor :html do |content|
         | 
| 18 | 
            -
                  Pakyow::Assets.mixin_fingerprints(content)
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                Pakyow.logger.debug 'Precompiling assets...'
         | 
| 22 | 
            -
                Pakyow::Assets.precompile
         | 
| 23 | 
            -
                Pakyow.logger.debug 'Finished precompiling!'
         | 
| 24 | 
            -
              end
         | 
| 25 | 
            -
            end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            # make sure this middleware executes first
         | 
| 28 | 
            -
            # FIXME: need an api for this on Pakyow::App
         | 
| 29 | 
            -
            Pakyow::App.class_variable_get(:@@middleware).unshift(lambda  { |builder|
         | 
| 30 | 
            -
              builder.use Pakyow::Assets::Middleware
         | 
| 31 | 
            -
            })
         | 
| @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            require 'yui/compressor'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Pakyow::Assets.preprocessor :css, fingerprint: true, fingerprint_contents: true do |path|
         | 
| 4 | 
            -
              content = File.read(path)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              if Pakyow::Config.assets.minify
         | 
| 7 | 
            -
                begin
         | 
| 8 | 
            -
                  YUI::CssCompressor.new.compress(content)
         | 
| 9 | 
            -
                rescue YUI::Compressor::RuntimeError
         | 
| 10 | 
            -
                  Pakyow.logger.warn "Unable to minify #{path}; using raw content"
         | 
| 11 | 
            -
                  content
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
              else
         | 
| 14 | 
            -
                content
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
            end
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            Pakyow::Assets.preprocessor :png, :jpg, :gif, :ico, fingerprint: true
         | 
| @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            require 'yui/compressor'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Pakyow::Assets.preprocessor :js, fingerprint: true, fingerprint_contents: true do |path|
         | 
| 4 | 
            -
              content = File.read(path)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              if Pakyow::Config.assets.minify
         | 
| 7 | 
            -
                begin
         | 
| 8 | 
            -
                  YUI::JavaScriptCompressor.new(munge: true).compress(content)
         | 
| 9 | 
            -
                rescue YUI::Compressor::RuntimeError
         | 
| 10 | 
            -
                  Pakyow.logger.warn "Unable to minify #{path}; using raw content"
         | 
| 11 | 
            -
                  content
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
              else
         | 
| 14 | 
            -
                content
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
            end
         | 
| @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            require 'sass'
         | 
| 2 | 
            -
            require 'yui/compressor'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            Pakyow::Assets.preprocessor :scss, :sass, output: :css, fingerprint: true, fingerprint_contents: true do |path|
         | 
| 5 | 
            -
              content = Sass::Engine.for_file(path, {}).render
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              if Pakyow::Config.assets.minify
         | 
| 8 | 
            -
                begin
         | 
| 9 | 
            -
                  YUI::CssCompressor.new.compress(content)
         | 
| 10 | 
            -
                rescue YUI::Compressor::RuntimeError
         | 
| 11 | 
            -
                  Pakyow.logger.warn "Unable to minify #{path}; using raw content"
         | 
| 12 | 
            -
                  content
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              else
         | 
| 15 | 
            -
                content
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
            end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            Pakyow::Assets.dependencies :scss, :sass do |path|
         | 
| 20 | 
            -
              Sass::Engine.for_file(path, {}).dependencies.map { |dependency|
         | 
| 21 | 
            -
                dependency.options[:filename]
         | 
| 22 | 
            -
              }
         | 
| 23 | 
            -
            end
         | 
    
        data/lib/version.rb
    DELETED
    
    
    
        data/pakyow-assets.gemspec
    DELETED
    
    | @@ -1,21 +0,0 @@ | |
| 1 | 
            -
            require File.expand_path('../lib/version', __FILE__)
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Gem::Specification.new do |spec|
         | 
| 4 | 
            -
              spec.name          = 'pakyow-assets'
         | 
| 5 | 
            -
              spec.summary       = 'Pakyow Assets'
         | 
| 6 | 
            -
              spec.description   = 'Asset Handling for Pakyow'
         | 
| 7 | 
            -
              spec.author        = 'Bryan Powell'
         | 
| 8 | 
            -
              spec.email         = 'bryan@metabahn.com'
         | 
| 9 | 
            -
              spec.homepage      = 'http://pakyow.org'
         | 
| 10 | 
            -
              spec.version       = Pakyow::Assets::VERSION
         | 
| 11 | 
            -
              spec.require_path  = 'lib'
         | 
| 12 | 
            -
              spec.files         = `git ls-files`.split("\n")
         | 
| 13 | 
            -
              spec.license       = 'MIT'
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              spec.add_dependency('pakyow-support', '~> 0')
         | 
| 16 | 
            -
              spec.add_dependency('pakyow-core', '~> 0')
         | 
| 17 | 
            -
              spec.add_dependency('pakyow-presenter', '~> 0')
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              spec.add_dependency('sass', '~> 3.4')
         | 
| 20 | 
            -
              spec.add_dependency('yui-compressor', '~> 0.12')
         | 
| 21 | 
            -
            end
         |