sbs 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +33 -18
- data/exe/sbs +0 -0
- data/lib/sbs/version.rb +1 -1
- data/lib/sbs.rb +58 -31
- data/sbs.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c09b9e62e269e00ce7a59ea445749a7346ee6e1dfb865a71c35ebd45fac64e20
|
4
|
+
data.tar.gz: d7a42b7e217af7af1b3e93c14767c2b7c9a761ac4201c0acdb35a0708d4b033f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41275828fe782399f0be83335d66711c905eefc679ce7d2d9040f13382e2d72d9c9173d908c45e6db45bf53e4a6e47d76e69f766200ffe3193f28484c9962c60
|
7
|
+
data.tar.gz: 9d4c1747cbc25e69e1a1dedc2dc19914ef3202a9707569e2a9015c5296132cc1465a6122c7503f15fd7e68fa429120a990cbcc2930556228f5f3c257ac6972b1
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sbs (0.1.
|
4
|
+
sbs (0.1.5)
|
5
5
|
activesupport (~> 5.2.3)
|
6
|
+
colorize (~> 0.8.1)
|
6
7
|
thor (~> 0.20.3)
|
7
8
|
|
8
9
|
GEM
|
@@ -13,6 +14,7 @@ GEM
|
|
13
14
|
i18n (>= 0.7, < 2)
|
14
15
|
minitest (~> 5.1)
|
15
16
|
tzinfo (~> 1.1)
|
17
|
+
colorize (0.8.1)
|
16
18
|
concurrent-ruby (1.1.5)
|
17
19
|
i18n (1.6.0)
|
18
20
|
concurrent-ruby (~> 1.0)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sbs
|
2
2
|
|
3
|
-
A better
|
3
|
+
A better substrate up tool.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,23 +20,38 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
sbs new testchain
|
28
|
-
|
29
|
-
sbs new testchain -b v1.0
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
sbs
|
38
|
-
|
39
|
-
|
23
|
+
- **new**: generate new blockchain from node-template
|
24
|
+
|
25
|
+
```shell
|
26
|
+
# Default branch is master
|
27
|
+
sbs new testchain
|
28
|
+
|
29
|
+
sbs new testchain -b v1.0
|
30
|
+
|
31
|
+
sbs new testchain -b v1.0 -a author
|
32
|
+
```
|
33
|
+
|
34
|
+
- **check**: Check your rust environment and substrate commits used by your project. Do it in your project directory
|
35
|
+
|
36
|
+
```shell
|
37
|
+
sbs check
|
38
|
+
```
|
39
|
+
|
40
|
+
- **diff**: Compare the difference between your node-template and the branch's node-template
|
41
|
+
|
42
|
+
```shell
|
43
|
+
# If fzf installed, a selectable diff list will appear, and the diff content will be displayed when you choose.
|
44
|
+
# If no fzf, all diffs with content will be shown.
|
45
|
+
sbs diff -b v1.0
|
46
|
+
|
47
|
+
# Only list diffs without content.
|
48
|
+
sbs diff -l -b v1.0
|
49
|
+
|
50
|
+
# Default branch is master.
|
51
|
+
sbs diff
|
52
|
+
```
|
53
|
+
|
54
|
+
[fzf](https://github.com/junegunn/fzf) is a great command-line fuzzy finder.
|
40
55
|
|
41
56
|
## Development
|
42
57
|
|
data/exe/sbs
CHANGED
File without changes
|
data/lib/sbs/version.rb
CHANGED
data/lib/sbs.rb
CHANGED
@@ -3,6 +3,7 @@ require "thor"
|
|
3
3
|
require "fileutils"
|
4
4
|
require "find"
|
5
5
|
require "active_support/core_ext/string"
|
6
|
+
require "colorize"
|
6
7
|
|
7
8
|
module Sbs
|
8
9
|
class Error < StandardError; end
|
@@ -68,6 +69,8 @@ module Sbs
|
|
68
69
|
end
|
69
70
|
|
70
71
|
desc "diff", "Show the difference between your substrate version and branch head. Do it in your project directory."
|
72
|
+
option :list, :aliases => :l, :type => :boolean
|
73
|
+
option :full, :aliases => :f, :type => :boolean
|
71
74
|
option :branch, :aliases => :b, :default => "master"
|
72
75
|
def diff
|
73
76
|
commits = get_commits
|
@@ -86,54 +89,78 @@ module Sbs
|
|
86
89
|
FileUtils.mkdir_p(tmp_dir_2)
|
87
90
|
|
88
91
|
# Compare the differences between the node-template you depend on and the latest node-template of the branch
|
89
|
-
copy_node_template(commit, tmp_dir_1)
|
90
|
-
copy_node_template(options[:branch], tmp_dir_2)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
puts line.gsub(tmp, "")
|
106
|
-
puts "\n"
|
92
|
+
node_template_1 = copy_node_template(commit, tmp_dir_1)
|
93
|
+
node_template_2 = copy_node_template(options[:branch], tmp_dir_2)
|
94
|
+
|
95
|
+
diff_cmd = "diff -rq #{tmp_dir_1}/#{node_template_1} #{tmp_dir_2}/#{node_template_2}"
|
96
|
+
|
97
|
+
if (not options[:list]) && (not options[:full]) && (`fzf --version` =~ /^\d+\.\d+\.\d /)
|
98
|
+
diff = `#{diff_cmd} | fzf`
|
99
|
+
show_file_diff(tmp, diff)
|
100
|
+
else
|
101
|
+
diffs = `#{diff_cmd}`
|
102
|
+
diffs.each_line do |diff|
|
103
|
+
if options[:list]
|
104
|
+
puts(diff.gsub(tmp, "").colorize(:green).underline) unless diff.include?("Cargo.lock")
|
105
|
+
else
|
106
|
+
show_file_diff(tmp, diff) unless diff.include?("Cargo.lock")
|
107
|
+
end
|
107
108
|
end
|
108
|
-
end
|
109
|
-
|
110
|
-
`rm -rf #{tmp_dir_1} && rm -rf #{tmp_dir_2}`
|
109
|
+
end
|
111
110
|
end
|
112
111
|
|
113
112
|
private
|
114
113
|
def copy_node_template(branch_or_commit, dest_dir)
|
114
|
+
# clone or update substrate
|
115
115
|
home = File.join(Dir.home, ".sbs")
|
116
116
|
Dir.mkdir(home) if not Dir.exist?(home)
|
117
117
|
substrate_dir = File.join(home, "substrate")
|
118
118
|
|
119
119
|
if not Dir.exist?(substrate_dir)
|
120
|
-
`git clone https://github.com/paritytech/substrate #{substrate_dir}`
|
120
|
+
`git clone -q https://github.com/paritytech/substrate #{substrate_dir}`
|
121
121
|
end
|
122
122
|
|
123
|
-
|
123
|
+
Dir.chdir substrate_dir do
|
124
|
+
`git checkout -q master`
|
125
|
+
`git pull -q`
|
126
|
+
end
|
127
|
+
|
128
|
+
# check exist
|
124
129
|
Dir.chdir substrate_dir do
|
125
130
|
if `git cat-file -t #{branch_or_commit}`.strip != "commit"
|
126
|
-
|
127
|
-
return
|
128
|
-
else
|
129
|
-
`git checkout -q #{branch_or_commit}`
|
130
|
-
if `git show-ref refs/heads/#{branch_or_commit}`.strip != "" # this is a branch
|
131
|
-
`git pull`
|
132
|
-
end
|
131
|
+
raise "Not a valid branch or commit: #{branch_or_commit}"
|
133
132
|
end
|
134
133
|
end
|
135
134
|
|
136
|
-
|
135
|
+
# get commit if it is a branch
|
136
|
+
commit = `git ls-remote https://github.com/paritytech/substrate refs/heads/#{branch_or_commit} | cut -f 1`.strip
|
137
|
+
commit = branch_or_commit if commit == ""
|
138
|
+
|
139
|
+
# checkout commit and then copy to dest dir
|
140
|
+
node_template_name = "node-template-#{commit[0 .. 9]}"
|
141
|
+
if not Dir.exist?("#{dest_dir}/#{node_template_name}")
|
142
|
+
Dir.chdir substrate_dir do
|
143
|
+
`git checkout -q #{commit}`
|
144
|
+
`cp -R ./node-template #{dest_dir}/#{node_template_name}`
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
return node_template_name
|
149
|
+
end
|
150
|
+
|
151
|
+
def show_file_diff(tmp, diff)
|
152
|
+
if diff.start_with?("Files")
|
153
|
+
scans = diff.scan(/Files (.+) and (.+) differ/)
|
154
|
+
file1 = scans[0][0]
|
155
|
+
file2 = scans[0][1]
|
156
|
+
|
157
|
+
puts diff.gsub(tmp, "").colorize(:green).underline
|
158
|
+
puts `diff -u #{file1} #{file2}`.gsub(tmp, "")
|
159
|
+
puts "\n"
|
160
|
+
else
|
161
|
+
puts diff.gsub(tmp, "").colorize(:green).underline
|
162
|
+
puts "\n"
|
163
|
+
end
|
137
164
|
end
|
138
165
|
|
139
166
|
def generate_from_node_template(chain_name, branch_or_commit, author, dest_dir)
|
data/sbs.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wuminzhe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 5.2.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.1
|
69
83
|
description: A better cli tool for substrate development
|
70
84
|
email:
|
71
85
|
- wuminzhe@gmail.com
|