cardano-up 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/bin/cardano-up +9 -7
- data/lib/cardano-up/bins.rb +1 -1
- data/lib/cardano-up/err.rb +9 -2
- data/lib/cardano-up/launcher.rb +13 -0
- data/lib/cardano-up/tail.rb +3 -2
- data/lib/cardano-up/utils.rb +16 -30
- data/lib/cardano-up/version.rb +1 -1
- data/lib/cardano-up.rb +0 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ea3b59240dc0a0c2eca674edf54ba66fba8e8bb276f40f1f3aecd4b1e13c8b
|
4
|
+
data.tar.gz: 0f278da8551b805df01aa2c714fdfbba1272b5af3edea3e8101821a1cdae3263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c4f5f88c56f90fcc20e3b78bc994a2067760d70698f2bca1a4619d4b6fc809433fe6404776a0962c8be62b77ab08a41b1348589427a74631b79043c56f10bf5
|
7
|
+
data.tar.gz: 6796a8d67a93cbb5b0b99a2d8b0c97f9416baefb67e911b50b46ccd6a0c3177f68dac2039a58210460e47668099f7814a6bc2cc68898d8f5b3edcaba2f59c850
|
data/README.md
CHANGED
@@ -23,7 +23,19 @@ This Ruby gem provides easy way for:
|
|
23
23
|
|
24
24
|
## Installation
|
25
25
|
|
26
|
+
#### Rubygem:
|
27
|
+
|
26
28
|
$ gem install cardano-up
|
29
|
+
$ cardano-up --help
|
30
|
+
|
31
|
+
#### Nix:
|
32
|
+
|
33
|
+
$ nix develop github:piotr-iohk/cardano-up?dir=nix
|
34
|
+
$ cardano-up --help
|
35
|
+
|
36
|
+
or run directly
|
37
|
+
|
38
|
+
$ nix run github:piotr-iohk/cardano-up?dir=nix -- --help
|
27
39
|
|
28
40
|
## Usage
|
29
41
|
|
@@ -52,7 +64,7 @@ By default cardano-up keeps all files at `$HOME/.cardano-up/` however this can b
|
|
52
64
|
|
53
65
|
**Configurations** for the networks are downloaded from [Cardano Book](https://book.world.dev.cardano.org/environments.html).
|
54
66
|
|
55
|
-
**Binaries** come from [cardano-wallet](https://github.com/input-output-hk/cardano-wallet) which actually provides `cardano-node`, `cardano-cli`, `cardano-wallet`, `cardano-addresses` and `bech32` tools in each of its release bundles. This ensures that all components are compatible and work smoothly together. You can get any public release of the cardano-wallet bundle
|
67
|
+
**Binaries** come from [cardano-wallet](https://github.com/input-output-hk/cardano-wallet) which actually provides `cardano-node`, `cardano-cli`, `cardano-wallet`, `cardano-addresses` and `bech32` tools in each of its release bundles. This ensures that all components are compatible and work smoothly together. You can get any public release of the cardano-wallet bundle.
|
56
68
|
|
57
69
|
**Starting** `cardano-node` and `cardano-wallet`, cardano-up attempts to launch separate [`screen`](https://www.gnu.org/software/screen/) sessions for wallet and node respectively. If screen is not present on your system you can install it using package manager, e.g.:
|
58
70
|
|
data/bin/cardano-up
CHANGED
@@ -14,14 +14,14 @@ doc = <<~DOCOPT
|
|
14
14
|
#{File.basename(__FILE__)} ls
|
15
15
|
#{File.basename(__FILE__)} config [--set-default] [--bindir <path>] [--configdir <path>] [--logdir <path>] [--statedir <path>]
|
16
16
|
#{File.basename(__FILE__)} <env> [(node|wallet)] [(up|down|ping)] [--port <port>] [--session <name>]
|
17
|
-
#{File.basename(__FILE__)} <env> (node|wallet) tail [--session <name>]
|
17
|
+
#{File.basename(__FILE__)} <env> (node|wallet) tail [--lines <num_lines>] [--session <name>]
|
18
18
|
#{File.basename(__FILE__)} -v | --version
|
19
19
|
#{File.basename(__FILE__)} -e | --examples
|
20
20
|
#{File.basename(__FILE__)} -h | --help
|
21
21
|
|
22
22
|
Options:
|
23
23
|
install Install cardano-node, cardano-cli, cardano-wallet, cardano-addresses and bech32.
|
24
|
-
<release> latest | release tag
|
24
|
+
<release> latest | release tag [default: latest]
|
25
25
|
get-configs Get configs for particular Cardano environment.
|
26
26
|
<env> mainnet | preview | preprod etc.
|
27
27
|
up Start particular service. If any configs are missing #{File.basename(__FILE__)}
|
@@ -29,6 +29,7 @@ doc = <<~DOCOPT
|
|
29
29
|
ones from latest release.
|
30
30
|
down Stop particular service.
|
31
31
|
tail Follow logs for particular service.
|
32
|
+
-n --lines <num_lines> Number of lines to show from the end of the log file. [default: 10]
|
32
33
|
ping Ping service to check its status.
|
33
34
|
ls List sessions.
|
34
35
|
-p --port <port> Specify wallet port. [default: 8090]
|
@@ -122,7 +123,7 @@ Check health of node and wallet on mainnet:
|
|
122
123
|
Monitor mainnet wallet and node logs (Ctrl + c to stop):
|
123
124
|
|
124
125
|
$ #{File.basename(__FILE__)} mainnet node tail
|
125
|
-
$ #{File.basename(__FILE__)} mainnet wallet tail
|
126
|
+
$ #{File.basename(__FILE__)} mainnet wallet tail -n 100
|
126
127
|
|
127
128
|
Stop preprod node:
|
128
129
|
|
@@ -261,7 +262,7 @@ Stop mainnet node and wallet:
|
|
261
262
|
$stderr.puts
|
262
263
|
warn "Congratulations! You've just started cardano-node and cardano-wallet!"
|
263
264
|
end
|
264
|
-
rescue CardanoUp::EnvNotSupportedError => e
|
265
|
+
rescue CardanoUp::EnvNotSupportedError, CardanoUp::NoScreenError => e
|
265
266
|
warn "⚠️ #{e}"
|
266
267
|
exit 1
|
267
268
|
rescue CardanoUp::SessionHasNodeError => e
|
@@ -307,7 +308,7 @@ Stop mainnet node and wallet:
|
|
307
308
|
end
|
308
309
|
warn 'Wallet stopped.'
|
309
310
|
end
|
310
|
-
rescue CardanoUp::EnvNotSupportedError, CardanoUp::SessionNotExistsError => e
|
311
|
+
rescue CardanoUp::EnvNotSupportedError, CardanoUp::SessionNotExistsError, CardanoUp::NoScreenError => e
|
311
312
|
warn "⚠️ #{e}"
|
312
313
|
exit 1
|
313
314
|
end
|
@@ -316,14 +317,15 @@ Stop mainnet node and wallet:
|
|
316
317
|
elsif o['tail'] == true
|
317
318
|
env = o['<env>']
|
318
319
|
session_name = o['--session']
|
320
|
+
lines = o['--lines'].to_i
|
319
321
|
begin
|
320
322
|
log_dir = File.join(CardanoUp.config[:log_dir], session_name, env)
|
321
323
|
if o['node']
|
322
324
|
log_file = File.join(log_dir, 'node.log')
|
323
|
-
CardanoUp::Tail.tail(log_file)
|
325
|
+
CardanoUp::Tail.tail(log_file, lines)
|
324
326
|
elsif o['wallet']
|
325
327
|
log_file = File.join(log_dir, 'wallet.log')
|
326
|
-
CardanoUp::Tail.tail(log_file)
|
328
|
+
CardanoUp::Tail.tail(log_file, lines)
|
327
329
|
end
|
328
330
|
rescue CardanoUp::EnvNotSupportedError => e
|
329
331
|
warn(e.message)
|
data/lib/cardano-up/bins.rb
CHANGED
@@ -4,7 +4,7 @@ module CardanoUp
|
|
4
4
|
# Installing binaries for Cardano
|
5
5
|
module Bins
|
6
6
|
# Get cardano-wallet bundle binaries to your computer.
|
7
|
-
# @param release [String] - 'latest' | /^v20.{2}-.{2}-.{2}/
|
7
|
+
# @param release [String] - 'latest' | /^v20.{2}-.{2}-.{2}/
|
8
8
|
# @raise CardanoUp::VersionNotSupportedError
|
9
9
|
def self.install(release)
|
10
10
|
CardanoUp.configure_default unless CardanoUp.configured?
|
data/lib/cardano-up/err.rb
CHANGED
@@ -67,8 +67,15 @@ module CardanoUp
|
|
67
67
|
# Thrown when version of bundle to download is not supported
|
68
68
|
class VersionNotSupportedError < StandardError
|
69
69
|
def initialize(ver)
|
70
|
-
super(["Not supported version: #{ver}. Supported are: 'latest'
|
71
|
-
"tag (e.g. 'v2022-08-16')
|
70
|
+
super(["Not supported version: #{ver}. Supported are: 'latest' or",
|
71
|
+
"tag (e.g. 'v2022-08-16')"].join(' '))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Thrown when there is no screen on the system
|
76
|
+
class NoScreenError < StandardError
|
77
|
+
def initialize
|
78
|
+
super('There is no screen tool on the system!')
|
72
79
|
end
|
73
80
|
end
|
74
81
|
end
|
data/lib/cardano-up/launcher.rb
CHANGED
@@ -73,6 +73,7 @@ module CardanoUp
|
|
73
73
|
# @param configuration [Hash] output of setup
|
74
74
|
# @raise CardanoUp::SessionHasNodeError
|
75
75
|
# @raise CardanoUp::SessionHasWalletError
|
76
|
+
# @raise CardanoUp::NoScreenError
|
76
77
|
def self.node_up(configuration)
|
77
78
|
env = configuration[:env]
|
78
79
|
bin_dir = configuration[:bin_dir]
|
@@ -82,6 +83,8 @@ module CardanoUp
|
|
82
83
|
node_socket = configuration[:node_socket]
|
83
84
|
session_name = configuration[:session_name]
|
84
85
|
|
86
|
+
raise CardanoUp::NoScreenError if !CardanoUp::Utils.win? && !CardanoUp::Utils.screen?
|
87
|
+
|
85
88
|
exe = CardanoUp::Utils.win? ? '.exe' : ''
|
86
89
|
cardano_node = "#{File.join(bin_dir, 'cardano-node')}#{exe}"
|
87
90
|
version = CardanoUp::Utils.cmd "#{cardano_node} version"
|
@@ -146,11 +149,15 @@ module CardanoUp
|
|
146
149
|
end
|
147
150
|
|
148
151
|
# @param configuration [Hash] output of setup
|
152
|
+
# @raise CardanoUp::NoScreenError
|
153
|
+
# @raise CardanoUp::WalletPortUsedError
|
149
154
|
def self.wallet_up(configuration)
|
150
155
|
if CardanoUp::Utils.port_used?(configuration[:wallet_port].to_i)
|
151
156
|
raise CardanoUp::WalletPortUsedError, configuration[:wallet_port]
|
152
157
|
end
|
153
158
|
|
159
|
+
raise CardanoUp::NoScreenError if !CardanoUp::Utils.win? && !CardanoUp::Utils.screen?
|
160
|
+
|
154
161
|
env = configuration[:env]
|
155
162
|
wallet_port = configuration[:wallet_port]
|
156
163
|
token_metadata_server = configuration[:token_metadata_server]
|
@@ -211,9 +218,12 @@ module CardanoUp
|
|
211
218
|
end
|
212
219
|
|
213
220
|
# @raise CardanoUp::EnvNotSupportedError
|
221
|
+
# @raise CardanoUp::NoScreenError
|
214
222
|
def self.node_down(env, session_name = '0')
|
215
223
|
raise CardanoUp::EnvNotSupportedError, env unless CardanoUp::ENVS.include? env
|
216
224
|
|
225
|
+
raise CardanoUp::NoScreenError if !CardanoUp::Utils.win? && !CardanoUp::Utils.screen?
|
226
|
+
|
217
227
|
if CardanoUp::Utils.win?
|
218
228
|
CardanoUp::Utils.cmd "nssm stop cardano-node-#{env}-#{session_name}"
|
219
229
|
CardanoUp::Utils.cmd "nssm remove cardano-node-#{env}-#{session_name} confirm"
|
@@ -225,9 +235,12 @@ module CardanoUp
|
|
225
235
|
end
|
226
236
|
|
227
237
|
# @raise CardanoUp::EnvNotSupportedError
|
238
|
+
# @raise CardanoUp::NoScreenError
|
228
239
|
def self.wallet_down(env, session_name = '0')
|
229
240
|
raise CardanoUp::EnvNotSupportedError, env unless CardanoUp::ENVS.include? env
|
230
241
|
|
242
|
+
raise CardanoUp::NoScreenError if !CardanoUp::Utils.win? && !CardanoUp::Utils.screen?
|
243
|
+
|
231
244
|
if CardanoUp::Utils.win?
|
232
245
|
CardanoUp::Utils.cmd "nssm stop cardano-wallet-#{env}-#{session_name}"
|
233
246
|
CardanoUp::Utils.cmd "nssm remove cardano-wallet-#{env}-#{session_name} confirm"
|
data/lib/cardano-up/tail.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
module CardanoUp
|
4
4
|
# Tail log file
|
5
5
|
module Tail
|
6
|
-
def self.tail(file_path)
|
6
|
+
def self.tail(file_path, lines = nil)
|
7
|
+
lines_back = lines || 10
|
7
8
|
File.open(file_path) do |log|
|
8
9
|
log.extend(File::Tail)
|
9
10
|
log.interval
|
10
|
-
log.backward(
|
11
|
+
log.backward(lines_back.to_i)
|
11
12
|
log.tail { |line| warn line }
|
12
13
|
end
|
13
14
|
end
|
data/lib/cardano-up/utils.rb
CHANGED
@@ -11,6 +11,11 @@ module CardanoUp
|
|
11
11
|
res.gsub("\n", ' ').strip
|
12
12
|
end
|
13
13
|
|
14
|
+
# Check if screen command is available
|
15
|
+
def self.screen?
|
16
|
+
cmd('which screen').chomp.length.positive?
|
17
|
+
end
|
18
|
+
|
14
19
|
def self.wget(url, file = nil)
|
15
20
|
file ||= File.basename(url)
|
16
21
|
resp = HTTParty.get(url)
|
@@ -61,40 +66,21 @@ module CardanoUp
|
|
61
66
|
|
62
67
|
##
|
63
68
|
# Latest binary url for latest release or particular tag, from master or pr num.
|
64
|
-
# @param release [String] - 'latest' | /^v20.{2}-.{2}-.{2}/
|
69
|
+
# @param release [String] - 'latest' | /^v20.{2}-.{2}-.{2}/
|
65
70
|
# @raise CardanoUp::VersionNotSupportedError
|
66
71
|
def self.get_binary_url(release = 'latest')
|
67
|
-
|
68
|
-
|
72
|
+
raise CardanoUp::VersionNotSupportedError, release unless release == 'latest' || release =~ /^v20.{2}-.{2}-.{2}/
|
73
|
+
|
74
|
+
tag = release == 'latest' ? latest_tag : release
|
75
|
+
if linux?
|
76
|
+
file = "cardano-wallet-#{tag}-linux64.tar.gz"
|
77
|
+
elsif mac?
|
78
|
+
file = "cardano-wallet-#{tag}-macos-intel.tar.gz"
|
79
|
+
elsif win?
|
80
|
+
file = "cardano-wallet-#{tag}-win64.zip"
|
69
81
|
end
|
70
82
|
|
71
|
-
|
72
|
-
if release == 'latest' || release =~ /^v20.{2}-.{2}-.{2}/
|
73
|
-
tag = release == 'latest' ? latest_tag : release
|
74
|
-
if linux?
|
75
|
-
file = "cardano-wallet-#{tag}-linux64.tar.gz"
|
76
|
-
elsif mac?
|
77
|
-
file = "cardano-wallet-#{tag}-macos-intel.tar.gz"
|
78
|
-
elsif win?
|
79
|
-
file = "cardano-wallet-#{tag}-win64.zip"
|
80
|
-
end
|
81
|
-
url = "#{CardanoUp::BINS_BASE_URL}/releases/download/#{tag}/#{file}"
|
82
|
-
else
|
83
|
-
if linux?
|
84
|
-
os = 'linux.musl.cardano-wallet-linux64'
|
85
|
-
elsif mac?
|
86
|
-
os = 'macos.intel.cardano-wallet-macos-intel'
|
87
|
-
elsif win?
|
88
|
-
os = 'linux.windows.cardano-wallet-win64'
|
89
|
-
end
|
90
|
-
|
91
|
-
url = if release == 'master'
|
92
|
-
"#{CardanoUp::HYDRA_BASE_URL}/#{os}/latest/download-by-type/file/binary-dist"
|
93
|
-
else
|
94
|
-
"#{CardanoUp::HYDRA_BASE_URL}-pr-#{release}/#{os}/latest/download-by-type/file/binary-dist"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
url
|
83
|
+
"#{CardanoUp::BINS_BASE_URL}/releases/download/#{tag}/#{file}"
|
98
84
|
end
|
99
85
|
|
100
86
|
##
|
data/lib/cardano-up/version.rb
CHANGED
data/lib/cardano-up.rb
CHANGED
@@ -27,7 +27,6 @@ require 'cardano-up/tail'
|
|
27
27
|
module CardanoUp
|
28
28
|
CONFIGS_BASE_URL = 'https://book.world.dev.cardano.org/environments'
|
29
29
|
BINS_BASE_URL = 'https://github.com/input-output-hk/cardano-wallet'
|
30
|
-
HYDRA_BASE_URL = 'https://hydra.iohk.io/job/Cardano/cardano-wallet'
|
31
30
|
ENVS = %w[mainnet preview preprod shelley-qa
|
32
31
|
staging vasil-qa vasil-dev mixed testnet].freeze
|
33
32
|
CONFIG_FILES = ['alonzo-genesis.json', 'byron-genesis.json', 'shelley-genesis.json',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardano-up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Stachyra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.21.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.21.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubyzip
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.46'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.46'
|
111
111
|
description: |-
|
112
112
|
Cardano Up lets you get all essential Cardano
|
113
113
|
tools on your system: cardano-node, cardano-cli, cardano-wallet,
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.3.7
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Lightweight manager for Cardano binaries and configs.
|