Skip to content

Commit

Permalink
Merge branch 'feature/migrations'
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Nov 13, 2024
2 parents c8c268a + fffe3e7 commit 1e4dda3
Show file tree
Hide file tree
Showing 528 changed files with 27,729 additions and 12,097 deletions.
18 changes: 18 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
"search": {
"whole_word": false,
"case_sensitive": false,
"include_ignored": true,
"regex": false
},
"languages": {
"SQL": {
"remove_trailing_whitespace_on_save": false,
"format_on_save": "off"
}
}
}
4 changes: 4 additions & 0 deletions cli/shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ shards:
git: https://github.com/17dec/crystal-pg.git
version: 0.27.0+git.commit.ed26146a226f31acf77c1949dea6d3e7c6b5674e

poncho:
git: https://github.com/icyleaf/poncho.git
version: 0.4.0+git.commit.f9e29066cfc1a7521de45fb5f7d97659dd4357ff

7 changes: 5 additions & 2 deletions cli/shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ targets:
statbus:
main: src/statbus.cr

crystal: '>= 1.10.1'
crystal: ">= 1.10.1"

license: MIT

dependencies:
pg:
github: 17dec/crystal-pg
branch: copyout
branch: copyout
poncho:
github: icyleaf/poncho
branch: master
36 changes: 36 additions & 0 deletions cli/src/config.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require "poncho"

class StatBusConfig
include Poncho

property postgres_host : String
property postgres_port : String
property postgres_db : String
property postgres_user : String
property postgres_password : String

def initialize(project_directory : Path, @verbose : Bool)
@postgres_host = "127.0.0.1"
@postgres_user = "postgres"
env_path = project_directory.join(".env")
if @verbose
puts "Looking for .env at: #{env_path}"
puts "Current directory: #{Dir.current}"
puts "Project directory: #{project_directory}"
end

if File.exists?(env_path)
puts "Found .env file" if @verbose
env_config = Poncho.from_file(env_path.to_s)
else
raise "Could not find .env file at #{env_path}"
end
@postgres_port = env_config["DB_PUBLIC_LOCALHOST_PORT"]? || raise "Missing DB_PUBLIC_LOCALHOST_PORT in .env"
@postgres_db = env_config["POSTGRES_DB"]? || raise "Missing POSTGRES_DB in .env"
@postgres_password = env_config["POSTGRES_PASSWORD"]? || raise "Missing POSTGRES_PASSWORD in .env"
end

def connection_string : String
"postgres://#{postgres_user}:#{postgres_password}@#{postgres_host}:#{postgres_port}/#{postgres_db}"
end
end
Loading

0 comments on commit 1e4dda3

Please sign in to comment.