mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
terminal+make: encode and print LiT version
Fixes #328 by encoding the LiT version and also printing it on startup.
This commit is contained in:
parent
80ee9aed31
commit
2e596e2cd2
4 changed files with 79 additions and 6 deletions
1
Makefile
1
Makefile
|
|
@ -60,6 +60,7 @@ make_ldflags = $(2) -X $(LND_PKG)/build.Commit=lightning-terminal-$(COMMIT) \
|
|||
-X $(LND_PKG)/build.GoVersion=$(GOVERSION) \
|
||||
-X $(LND_PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g') \
|
||||
-X $(PKG).appFilesPrefix=$(PUBLIC_URL) \
|
||||
-X $(PKG).Commit=$(COMMIT) \
|
||||
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT) \
|
||||
-X $(POOL_PKG).Commit=$(POOL_COMMIT)
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ Lightning Terminal is backwards compatible with `lnd` back to version v0.13.3-be
|
|||
|
||||
| LiT | LND |
|
||||
|------------------| ------------ |
|
||||
| **v0.6.4-alpha** | v0.13.3-beta |
|
||||
| **v0.6.3-alpha** | v0.13.3-beta |
|
||||
| **v0.6.2-alpha** | v0.13.3-beta |
|
||||
| **v0.6.1-alpha** | v0.13.3-beta |
|
||||
|
|
@ -113,6 +114,7 @@ The following table shows the supported combinations:
|
|||
|
||||
| LiT | LND | Loop | Faraday | Pool |
|
||||
|------------------|--------------| ----------- | ------------ |--------------|
|
||||
| **v0.6.4-alpha** | v0.14.2-beta | v0.15.1-beta | v0.2.7-alpha | v0.5.4-alpha |
|
||||
| **v0.6.3-alpha** | v0.14.2-beta | v0.15.1-beta | v0.2.7-alpha | v0.5.4-alpha |
|
||||
| **v0.6.2-alpha** | v0.14.1-beta | v0.15.1-beta | v0.2.7-alpha | v0.5.4-alpha |
|
||||
| **v0.6.1-alpha** | v0.14.1-beta | v0.15.1-beta | v0.2.7-alpha | v0.5.2-alpha |
|
||||
|
|
|
|||
16
terminal.go
16
terminal.go
|
|
@ -187,6 +187,9 @@ func (g *LightningTerminal) Run() error {
|
|||
g.cfg = cfg
|
||||
g.defaultImplCfg = g.cfg.Lnd.ImplementationConfig(shutdownInterceptor)
|
||||
|
||||
// Show version at startup.
|
||||
log.Infof("LiT version: %s", Version())
|
||||
|
||||
// Create the instances of our subservers now so we can hook them up to
|
||||
// lnd once it's fully started.
|
||||
bufRpcListener := bufconn.Listen(100)
|
||||
|
|
@ -1349,14 +1352,15 @@ func (g *LightningTerminal) showStartupInfo() error {
|
|||
"----------------------------------------------------------\n" +
|
||||
" Lightning Terminal (LiT) by Lightning Labs \n" +
|
||||
" \n" +
|
||||
" Operating mode %s \n" +
|
||||
" Node status %s \n" +
|
||||
" Alias %s \n" +
|
||||
" Version %s \n" +
|
||||
" Web interface %s (open %s in your browser) \n" +
|
||||
" LND Operating mode %s \n" +
|
||||
" LND Node status %s \n" +
|
||||
" LND Alias %s \n" +
|
||||
" LND Version %s \n" +
|
||||
" LiT Version %s \n" +
|
||||
" Web interface %s (open %s in your browser) \n" +
|
||||
"----------------------------------------------------------\n"
|
||||
fmt.Printf(str, info.mode, info.status, info.alias, info.version,
|
||||
listenAddr, info.webURI)
|
||||
Version(), listenAddr, info.webURI)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
66
version.go
Normal file
66
version.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package terminal
|
||||
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Copyright (c) 2015-2016 The Decred developers
|
||||
// Heavily inspired by https://github.com/btcsuite/btcd/blob/master/version.go
|
||||
// Copyright (C) 2015-2022 The Lightning Network Developers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Commit stores the current commit hash of this build, this should be set
|
||||
// using the -ldflags during compilation.
|
||||
var Commit string
|
||||
|
||||
// semanticAlphabet
|
||||
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
|
||||
|
||||
// These constants define the application version and follow the semantic
|
||||
// versioning 2.0.0 spec (http://semver.org/).
|
||||
const (
|
||||
appMajor uint = 0
|
||||
appMinor uint = 6
|
||||
appPatch uint = 4
|
||||
|
||||
// appPreRelease MUST only contain characters from semanticAlphabet per
|
||||
// the semantic versioning spec.
|
||||
appPreRelease = "alpha"
|
||||
)
|
||||
|
||||
// Version returns the application version as a properly formed string per the
|
||||
// semantic versioning 2.0.0 spec (http://semver.org/).
|
||||
func Version() string {
|
||||
// Start with the major, minor, and patch versions.
|
||||
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch)
|
||||
|
||||
// Append pre-release version if there is one. The hyphen called for
|
||||
// by the semantic versioning spec is automatically appended and should
|
||||
// not be contained in the pre-release string. The pre-release version
|
||||
// is not appended if it contains invalid characters.
|
||||
preRelease := normalizeVerString(appPreRelease)
|
||||
if preRelease != "" {
|
||||
version = fmt.Sprintf("%s-%s", version, preRelease)
|
||||
}
|
||||
|
||||
// Append commit hash of current build to version.
|
||||
version = fmt.Sprintf("%s commit=%s", version, Commit)
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
// normalizeVerString returns the passed string stripped of all characters
|
||||
// which are not valid according to the semantic versioning guidelines for
|
||||
// pre-release version and build metadata strings. In particular they MUST
|
||||
// only contain characters in semanticAlphabet.
|
||||
func normalizeVerString(str string) string {
|
||||
var result bytes.Buffer
|
||||
for _, r := range str {
|
||||
if strings.ContainsRune(semanticAlphabet, r) {
|
||||
result.WriteRune(r)
|
||||
}
|
||||
}
|
||||
return result.String()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue