Class: Sbs::Cli
- Inherits:
-
Thor
- Object
- Thor
- Sbs::Cli
- Defined in:
- lib/sbs.rb
Instance Method Summary collapse
Instance Method Details
#check ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/sbs.rb', line 39 def check if `which rustc`.strip != "" puts "Your rust environment:" puts " default: #{`rustc --version`}" puts "" puts " stable: #{`rustc +stable --version`}" puts " targets: " `rustup target list --installed --toolchain stable`.each_line do |line| puts " #{line}" end puts "" puts " nightly: #{`rustc +nightly --version`}" puts " targets: " `rustup target list --installed --toolchain nightly`.each_line do |line| puts " #{line}" end puts "" puts " all toolchains: " `rustup toolchain list`.each_line do |line| puts " #{line}" end puts "" end puts "The substrate version your project depends:" get_commits.each do |commit| puts "#{commit}" end puts "" end |
#diff ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/sbs.rb', line 77 def diff commits = get_commits if commits.length > 1 puts "Your project seems to depend on more than one substrate commit" return end commit = commits[0] home = File.join(Dir.home, ".sbs") substrate_dir = File.join(home, "substrate") tmp = File.join(home, "tmp", "/") tmp_dir_1 = File.join(tmp, "your") tmp_dir_2 = File.join(tmp, [:version]) FileUtils.mkdir_p(tmp_dir_1) FileUtils.mkdir_p(tmp_dir_2) # Compare the differences between the node-template you depend on and the latest node-template of the branch node_template_1 = copy_node_template(commit, tmp_dir_1) node_template_2 = copy_node_template([:branch], tmp_dir_2) diff_cmd = "diff -rq #{tmp_dir_1}/#{node_template_1} #{tmp_dir_2}/#{node_template_2}" if (not [:list]) && (not [:full]) && (`fzf --version` =~ /^\d+\.\d+\.\d /) diff = `#{diff_cmd} | fzf` show_file_diff(tmp, diff) else diffs = `#{diff_cmd}` diffs.each_line do |diff| if [:list] puts(diff.gsub(tmp, "").colorize(:green).underline) unless diff.include?("Cargo.lock") else show_file_diff(tmp, diff) unless diff.include?("Cargo.lock") end end end end |
#new(chain_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sbs.rb', line 15 def new(chain_name) dest_dir = "." # generate your chain if generate_from_node_template(chain_name, [:version], [:author], dest_dir) # build Dir.chdir("#{dest_dir}/#{chain_name}") do puts "*** Initializing WebAssembly build environment..." `./scripts/init.sh` puts "*** Building '#{chain_name}' ..." if File.exist?("./scripts/build.sh") `./scripts/build.sh` end `cargo build` end puts "" puts "Your blockchain '#{chain_name}' has been generated." puts "" end end |