#!/usr/bin/env ruby require 'flok' require 'thor' require 'fileutils' require 'closure-compiler' class FlokCLI < Thor desc "new ", "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)