lib/raykit.rb
# frozen_string_literal: true require "rainbow" require "rake/clean" require "open3" require "rake/testtask" require "digest" lib_dir = File.dirname(__FILE__) Dir.glob("#{lib_dir}/raykit/**/*.rb").sort.each { |file| require file } PROJECT = Raykit::Project.new SECRETS = Raykit::Secrets.new REPOSITORIES = Raykit::Git::Repositories.new("#{Raykit::Environment.get_dev_dir("log")}/Raykit.Git.Repositories.json") GIT_DIRECTORY = Raykit::Git::Directory.new(Rake.application.original_dir) NUGET_DIR = Raykit::Environment::get_dev_dir("nuget") PUBLISH_DIR = Raykit::Environment::get_dev_dir("publish") Raykit::MsBuild::fix_msbuild_path # include Raykit::TopLevel to make run method accessible from the global scope module Raykit module TopLevel def self.run(command, quit_on_failure = true) PROJECT.run(command, quit_on_failure) end end end RAYKIT_GLOBALS = true if defined?(RAYKIT_GLOBALS) def run(command, quit_on_failure = true) Raykit::TopLevel.run(command, quit_on_failure) end def try(command) Raykit::TopLevel.run(command, false) end def make(artifact, command) if (File.exists?(artifact)) puts " #{artifact} exists" else cmd = run(command) if (cmd.exitstatus != 0) File.delete(artifact) if (File.exists?(artifact)) end cmd end end def make_log(artifact, command) if (File.exists?(artifact)) puts " #{artifact} exists" else cmd = run(command).log_to_file(artifact) if (cmd.exitstatus != 0) File.delete(artifact) if (File.exists?(artifact)) end cmd end end def start_task(task_name) Raykit::Log.start_task(task_name) end def show(symbol) show_binding(symbol, binding) end def show_binding(symbol, the_binding) show_value symbol.to_s, eval(symbol.to_s, the_binding) end def show_value(name, value) Raykit::Log.show_value(name, value) PROJECT.values[name] = value end def show_table(symbols) Raykit::Log.show_table(symbols) end def copy_files(src_dir, target_dir, glob) Raykit::FileSystem::copy_files(src_dir, target_dir, glob) end def copy_file_to_dir(file, dir) Raykit::FileSystem::copy_file_to_dir(file, dir) end end