2023-12-07 11:18:16 +01:00
|
|
|
module Twenty
|
2023-12-09 22:37:39 +01:00
|
|
|
module DB
|
|
|
|
require "json"
|
|
|
|
DEFAULTS = { connections: [] }
|
|
|
|
|
|
|
|
##
|
|
|
|
# FIXME:
|
|
|
|
# The following methods are required by
|
|
|
|
# both twenty-cli, and twenty-backend. Eventually
|
|
|
|
# they should be moved into their own package.
|
|
|
|
|
|
|
|
def home
|
|
|
|
File.join Dir.home, ".local", "share", "twenty"
|
|
|
|
end
|
|
|
|
|
|
|
|
def database
|
|
|
|
Ryo.from DEFAULTS.dup.merge(JSON.parse(database_path))
|
|
|
|
rescue
|
|
|
|
Ryo.from(DEFAULTS.dup)
|
|
|
|
end
|
|
|
|
|
|
|
|
def database_path
|
|
|
|
File.join(home, "database.json")
|
|
|
|
end
|
|
|
|
|
|
|
|
def save!(db)
|
|
|
|
File.binwrite database_path,
|
|
|
|
JSON.dump(Ryo.table_of(db, recursive: true))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-10 23:15:42 +01:00
|
|
|
require "twenty-backend"
|
2023-12-08 19:27:00 +01:00
|
|
|
require "twenty/frontend"
|
2023-12-09 22:46:13 +01:00
|
|
|
require_relative "twenty-cli/command"
|
2023-12-07 11:18:16 +01:00
|
|
|
end
|