diff --git a/src/config-yaml.ts b/src/config-yaml.ts index 13e6a06..0ea836c 100644 --- a/src/config-yaml.ts +++ b/src/config-yaml.ts @@ -1,7 +1,11 @@ -import { readFileSync, writeFileSync } from 'fs' +import { existsSync, readFileSync, writeFileSync } from 'fs' import { dump, FAILSAFE_SCHEMA, load } from 'js-yaml' import { getPath } from './path' +export function configYamlExists(): boolean { + return existsSync(getPath('config.yaml')) +} + export function readConfigYaml(): Record { const raw = readFileSync(getPath('config.yaml'), 'utf-8') const data = load(raw, { diff --git a/src/index.ts b/src/index.ts index 363b8be..81f5e85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,12 @@ import { ensureApiKey } from './api-key' // @ts-ignore import squirrelInstallingExecution from 'electron-squirrel-startup' import { initSplash } from './splash' +import { configYamlExists, readConfigYaml, writeConfigYaml } from './config-yaml' + +// TODO: remove this after 1.0.0 release +// this is a migration path for pioneers +// who helped testing the early versions +if (configYamlExists() && !readConfigYaml().password) writeConfigYaml({ password: 'Test' }) if (squirrelInstallingExecution) { app.quit()