-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from kaspa-live/about
Add version information for all application tiers and for the embedded kaspad
- Loading branch information
Showing
21 changed files
with
337 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import fs from "fs"; | ||
|
||
const getPackageVersion = (): string => { | ||
const packagejson:any = JSON.parse(fs.readFileSync('package.json', 'utf8')) | ||
return packagejson.version; | ||
}; | ||
|
||
const packageVersion = getPackageVersion(); | ||
|
||
export { | ||
packageVersion | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE app_config | ||
( | ||
id BOOLEAN PRIMARY KEY DEFAULT TRUE, | ||
kaspad_version TEXT NOT NULL, | ||
processing_version TEXT NOT NULL, | ||
CONSTRAINT unique_row CHECK (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// validCharacters is a list of characters valid in the appBuild string | ||
const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-" | ||
|
||
const ( | ||
appMajor uint = 0 | ||
appMinor uint = 1 | ||
appPatch uint = 17 | ||
) | ||
|
||
// appBuild is defined as a variable so it can be overridden during the build | ||
// process with '-ldflags "-X github.com/kaspanet/kaspad/version.appBuild=foo"' if needed. | ||
// It MUST only contain characters from validCharacters. | ||
var appBuild string | ||
|
||
var version = "" // string used for memoization of version | ||
|
||
func init() { | ||
if version == "" { | ||
// Start with the major, minor, and patch versions. | ||
version = fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch) | ||
|
||
// Append build metadata if there is any. | ||
// Panic if any invalid characters are encountered | ||
if appBuild != "" { | ||
checkAppBuild(appBuild) | ||
|
||
version = fmt.Sprintf("%s-%s", version, appBuild) | ||
} | ||
} | ||
} | ||
|
||
// Version returns the application version as a properly formed string | ||
func Version() string { | ||
return version | ||
} | ||
|
||
// checkAppBuild verifies that appBuild does not contain any characters outside of validCharacters. | ||
// In case of any invalid characters checkAppBuild panics | ||
func checkAppBuild(appBuild string) { | ||
for _, r := range appBuild { | ||
if !strings.ContainsRune(validCharacters, r) { | ||
panic(fmt.Errorf("appBuild string (%s) contains forbidden characters. Only alphanumeric characters and dashes are allowed", appBuild)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.