-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bee 1.8 support and installer removal (#264)
- Loading branch information
Showing
24 changed files
with
168 additions
and
670 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,62 @@ | ||
export type EnvironmentVariables = Partial<{ | ||
// Logging | ||
LOG_LEVEL: string | ||
}> | ||
import { existsSync, readFileSync, writeFileSync } from 'fs' | ||
import { getPath } from './path' | ||
import { dump, FAILSAFE_SCHEMA, load } from 'js-yaml' | ||
import PACKAGE_JSON from '../package.json' | ||
|
||
export const SUPPORTED_LEVELS = ['critical', 'error', 'warn', 'info', 'verbose', 'debug'] as const | ||
export type SupportedLevels = typeof SUPPORTED_LEVELS[number] | ||
export const DEFAULT_LOG_LEVEL = 'info' | ||
const DESKTOP_VERSION_FILE = 'desktop.version' | ||
|
||
export const logLevel = | ||
process.env.LOG_LEVEL && SUPPORTED_LEVELS.includes(process.env.LOG_LEVEL as SupportedLevels) | ||
? process.env.LOG_LEVEL | ||
: DEFAULT_LOG_LEVEL | ||
|
||
export function configYamlExists(): boolean { | ||
return existsSync(getPath('config.yaml')) | ||
} | ||
|
||
export function readConfigYaml(): Record<string, unknown> { | ||
const raw = readFileSync(getPath('config.yaml'), 'utf-8') | ||
const data = load(raw, { | ||
schema: FAILSAFE_SCHEMA, | ||
}) | ||
|
||
return data as Record<string, unknown> | ||
} | ||
|
||
export function writeConfigYaml(newValues: Record<string, unknown>) { | ||
const data = readConfigYaml() | ||
for (const [key, value] of Object.entries(newValues)) { | ||
data[key] = value | ||
} | ||
writeFileSync(getPath('config.yaml'), dump(data)) | ||
} | ||
|
||
export function getDesktopVersionFromFile(): string | undefined { | ||
try { | ||
const desktopFile = readFileSync(getPath(DESKTOP_VERSION_FILE)) | ||
|
||
return desktopFile.toString('utf-8') | ||
} catch (e) { | ||
return | ||
} | ||
} | ||
|
||
export function writeDesktopVersionFile() { | ||
writeFileSync(getPath(DESKTOP_VERSION_FILE), PACKAGE_JSON.version) | ||
} | ||
|
||
export function readWalletPasswordOrThrow(): string { | ||
if (!configYamlExists()) { | ||
throw Error('Attempted to read password, but config.yaml is not found') | ||
} | ||
const config = readConfigYaml() | ||
|
||
if (!config.password) { | ||
throw Error('Attempted to read password, but config.yaml does not contain it') | ||
} | ||
|
||
return config.password as string | ||
} |
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
Oops, something went wrong.