filecoin-big-head
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -16,2 +16,4 @@ #!/usr/bin/env node | ||
var _useFilecoinNetworkInfo = _interopRequireDefault(require("./useFilecoinNetworkInfo")); | ||
var _inkWatchForExitKey = _interopRequireDefault(require("./inkWatchForExitKey")); | ||
@@ -32,3 +34,3 @@ | ||
Colors: | ||
cyan cyanBright black red redBright green greeBright | ||
cyan cyanBright black red redBright green greenBright | ||
yellow yellowBright blue blueBright magenta magentaBright | ||
@@ -52,4 +54,11 @@ white whiteBright gray | ||
Interval to poll local filecoin node | ||
-net-interval <seconds> (default: 30) | ||
Interval to poll devnet block explorer API | ||
--no-nickname | ||
--no-seconds | ||
--no-net-info | ||
`, { | ||
@@ -82,2 +91,7 @@ flags: { | ||
}, | ||
netInterval: { | ||
type: 'string', | ||
alias: 'i', | ||
default: '30' | ||
}, | ||
nickname: { | ||
@@ -90,2 +104,6 @@ type: 'boolean', | ||
default: true | ||
}, | ||
netInfo: { | ||
type: 'boolean', | ||
default: true | ||
} | ||
@@ -101,9 +119,13 @@ } | ||
const interval = Number(args.interval) * 1000; | ||
const netInterval = Number(args.netInterval) * 1000; | ||
const Main = () => { | ||
const [nickname] = (0, _useFilecoinConfig.default)('heartbeat.nickname'); | ||
const [_, height, updateTime] = (0, _useFilecoinHead.default)({ | ||
const [, height, updateTime] = (0, _useFilecoinHead.default)({ | ||
interval, | ||
flashDuration | ||
}); | ||
const [netName,, netHeight] = (0, _useFilecoinNetworkInfo.default)({ | ||
interval: netInterval | ||
}); | ||
const { | ||
@@ -120,2 +142,3 @@ columns, | ||
const seconds = args.seconds ? _react.default.createElement(_ink.Box, null, Math.floor((Date.now() - updateTime) / 1000), "s ago") : null; | ||
const netInfo = args.netInfo ? _react.default.createElement(_ink.Box, null, netName, ": ", netHeight >= 0 ? netHeight : 'Loading...') : null; | ||
return _react.default.createElement(_ink.Box, { | ||
@@ -129,3 +152,5 @@ flexDirection: "column", | ||
colors: displayColors | ||
})), seconds, _react.default.createElement(_inkWatchForExitKey.default, null)); | ||
})), _react.default.createElement(_ink.Box, null, _react.default.createElement(_ink.Box, { | ||
flexGrow: 1 | ||
}, seconds), _react.default.createElement(_ink.Box, null, netInfo)), _react.default.createElement(_inkWatchForExitKey.default, null)); | ||
}; | ||
@@ -135,4 +160,6 @@ | ||
const { | ||
rerender, | ||
waitUntilExit | ||
} = (0, _ink.render)(_react.default.createElement(Main, null)); | ||
process.on('SIGWINCH', () => rerender(_react.default.createElement(Main, null))); | ||
@@ -139,0 +166,0 @@ try { |
40
index.js
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
import useFilecoinHead from './useFilecoinHead' | ||
import useFilecoinNetworkInfo from './useFilecoinNetworkInfo' | ||
import InkWatchForExitKey from './inkWatchForExitKey' | ||
@@ -22,3 +23,3 @@ | ||
Colors: | ||
cyan cyanBright black red redBright green greeBright | ||
cyan cyanBright black red redBright green greenBright | ||
yellow yellowBright blue blueBright magenta magentaBright | ||
@@ -42,4 +43,11 @@ white whiteBright gray | ||
Interval to poll local filecoin node | ||
-net-interval <seconds> (default: 30) | ||
Interval to poll devnet block explorer API | ||
--no-nickname | ||
--no-seconds | ||
--no-net-info | ||
`, | ||
@@ -73,2 +81,7 @@ { | ||
}, | ||
netInterval: { | ||
type: 'string', | ||
alias: 'i', | ||
default: '30' | ||
}, | ||
nickname: { | ||
@@ -81,2 +94,6 @@ type: 'boolean', | ||
default: true | ||
}, | ||
netInfo: { | ||
type: 'boolean', | ||
default: true | ||
} | ||
@@ -94,9 +111,13 @@ } | ||
const interval = Number(args.interval) * 1000 | ||
const netInterval = Number(args.netInterval) * 1000 | ||
const Main = () => { | ||
const [nickname] = useFilecoinConfig('heartbeat.nickname') | ||
const [_, height, updateTime] = useFilecoinHead({ | ||
const [, height, updateTime] = useFilecoinHead({ | ||
interval, | ||
flashDuration | ||
}) | ||
const [netName, , netHeight] = useFilecoinNetworkInfo({ | ||
interval: netInterval | ||
}) | ||
@@ -118,2 +139,8 @@ const { columns, rows } = process.stdout | ||
const netInfo = args.netInfo ? | ||
<Box> | ||
{netName}: {netHeight >= 0 ? netHeight : 'Loading...'} | ||
</Box> | ||
: null | ||
return ( | ||
@@ -130,3 +157,6 @@ <Box flexDirection="column" width={columns} height={rows - 1}> | ||
</Box> | ||
{seconds} | ||
<Box> | ||
<Box flexGrow={1}>{seconds}</Box> | ||
<Box>{netInfo}</Box> | ||
</Box> | ||
<InkWatchForExitKey /> | ||
@@ -138,4 +168,6 @@ </Box> | ||
async function run () { | ||
const { waitUntilExit } = render(<Main/>) | ||
const { rerender, waitUntilExit } = render(<Main/>) | ||
process.on('SIGWINCH', () => rerender(<Main/>)) | ||
try { | ||
@@ -142,0 +174,0 @@ await waitUntilExit() |
{ | ||
"name": "filecoin-big-head", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Displays Filecoin chain height in big letters in terminal", | ||
@@ -21,2 +21,3 @@ "scripts": { | ||
"meow": "^5.0.0", | ||
"node-fetch": "^2.3.0", | ||
"react": "^16.8.6" | ||
@@ -31,3 +32,3 @@ }, | ||
"babel-plugin-shebang": "^1.0.0", | ||
"nodemon": "^1.18.10" | ||
"nodemon": "^1.18.11" | ||
}, | ||
@@ -34,0 +35,0 @@ "babel": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
738607
16
609
6
2
+ Addednode-fetch@^2.3.0