Sha256: d6b0371c56c54fe6ba685b74765bc3c66160a84b0d002a992e279acc5656d90e

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env ruby

require 'thor'
require 'colorize'
require 'awesome_print'

###

if ARGV[0]
  if File.exist?('./config/application.rb')
    require './config/application.rb'
  end

  if !defined?(LuxAssets) && File.exist?('./config/environment.rb')
    require './config/environment.rb'
  end

  if !defined?(LuxAssets)
    require_relative '../lib/lux_assets'
  end
end

###

module ::Cli
  extend self

  def run what
    puts what.green
    system what
  end

  def die text
    puts text.red
    exit
  end

  def info text
    puts '* %s' % text.magenta
  end
end

###

class AssetsCli < Thor

  desc :install, 'Install all needed packages via yarn'
  def install
    packages  = ["coffee-script", "node-sass", "typescript", "babel-cli", "autoprefixer-cli"]

    if `which yarn`.empty?
      Cli.die('yarn not found -> install with "npm install yarn -g"')
    end

    for pkg in packages
      Cli.run 'yarn add %s' % pkg
    end

    puts '* Installed: %s' % packages.map(&:green).join(', ')

    if ENV['RACK_ENV'] != 'test'
      unless LuxAssets::CONFIG_PATH.exist?
        source = Pathname.new(__FILE__).join("../../misc/assets.rb")
        LuxAssets::CONFIG_PATH.write source.read
        puts '* Added template %s' % LuxAssets::CONFIG_PATH.to_s.green
      end

      puts "* To include LuxAssets rake tasks in Rakefile, just require 'lux_assets'".green
    end
  end

  desc :show, 'Show all files/data in manifest'
  def show
    LuxAssets.examine
  end

  desc :compile, 'Compile assets for production'
  def compile
    LuxAssets.compile_all do |name, path|
      puts "Compile #{name.green} -> #{path}"
    end
  end

  desc :clear, 'Clear all caches'
  def clear
    Cli.run 'rm -rf ./tmp/assets'
    Cli.run 'rm -rf ./public/assets'
    Cli.run 'rm ./public/manifest.json'
  end

end

AssetsCli.start ARGV

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
lux_assets-0.2.2 ./bin/lux_assets
lux_assets-0.2.2 bin/lux_assets