Sha256: 22389a021d39d3bd2603175f68bd0852ca0e6bc1c79a2b7357d5de3cdb606d37

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

require 'flok'
require 'thor'
require 'fileutils'
require 'closure-compiler'

class FlokCLI < Thor
  desc "new <path>", "Create a new flok project and/or module, you may supply an absolute path or relative, the last entry in the path will be the module name and folder name of the project"
  def new path
    name = File.basename(path)
    Dir.chdir File.dirname(path) do
      `bundle gem #{name}`

      Dir.chdir name do
        Dir.mkdir "app"
        Dir.mkdir "config"
      end
    end
  end

  option :compress, type: :boolean
  desc "build", "Build a flok project, you must be in the root of the project"
  def build
    Dir.mkdir("./public") unless File.exists?("./public")
    FileUtils.touch "./products/application.js"
    FileUtils.touch "../FlokTest/app/assets/javascripts/flok.js"

    src = Flok::MergeSource.merge_all

    #Compress by writing to a temporary dir, run closure, and then put back
    if options["compress"] == true
      src = Closure::Compiler.new.compile(src)
    end

    File.write("./products/application.js", src)
    File.write("../FlokTest/app/assets/javascripts/flok.js", src)
  end
end

FlokCLI.start(ARGV)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flok-0.0.12 bin/flok
flok-0.0.11 bin/flok