Skip to content

Commit 5c216cf

Browse files
committed
added contributors
1 parent 77cd92c commit 5c216cf

File tree

11 files changed

+186
-170
lines changed

11 files changed

+186
-170
lines changed

Diff for: README.md

+13
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ cargo run -- build --env prod --provider aws --region us-east-1
3737
./target/release/stackql-deploy shell
3838

3939
./target/release/stackql-deploy upgrade
40+
41+
# Using built-in provider template
42+
./target/release/stackql-deploy init my-project --provider aws
43+
44+
# Using relative path to template in GitHub
45+
./target/release/stackql-deploy init my-project --template google/starter
46+
47+
# Using full GitHub URL
48+
./target/release/stackql-deploy init my-project --template https://github.com/stackql/stackql-deploy-rust/tree/main/template-hub/azure/starter
49+
50+
./target/release/stackql-deploy init my-project --template https://raw.githubusercontent.com/stackql/stackql-deploy-rust/main/template-hub/azure/starter
51+
52+
./target/release/stackql-deploy init my-project --template https://raw.githubusercontent.com/stackql/stackql-deploy-rust/main/template-hub/azure/fred

Diff for: ci-scripts/build.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ echo "==============================================="
66
echo " Building stackql-deploy"
77
echo "==============================================="
88

9-
# Build in release mode
10-
echo "Building in release mode..."
11-
cargo build --release
9+
# Read contributors into a comma-separated string
10+
CONTRIBS=$(paste -sd, contributors.csv | sed 's/,$//')
11+
12+
# Build in release mode with env var for contributors
13+
echo "Building in release mode with contributors..."
14+
CONTRIBUTORS="$CONTRIBS" cargo rustc --release -- -C link-arg=-s
1215

1316
# Check if build was successful
1417
if [ $? -eq 0 ]; then
@@ -19,22 +22,19 @@ else
1922
exit 1
2023
fi
2124

22-
# Create binaries for different platforms if cross-compilation tools are available
25+
# Optional: Cross compile
2326
if command -v cross &> /dev/null; then
2427
echo -e "\nCross-compiling for multiple platforms..."
25-
26-
# Build for Windows
28+
2729
echo "Building for Windows..."
2830
cross build --release --target x86_64-pc-windows-gnu
29-
30-
# Build for macOS
31+
3132
echo "Building for macOS..."
3233
cross build --release --target x86_64-apple-darwin
33-
34-
# Build for Linux
34+
3535
echo "Building for Linux..."
3636
cross build --release --target x86_64-unknown-linux-gnu
37-
37+
3838
echo -e "\n✅ Cross-compilation completed!"
3939
echo "Binaries located in ./target/{target}/release/"
40-
fi
40+
fi

Diff for: contributors.csv

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
derek10cloud
2+
general-kroll-4-life
3+
jeffreyaven

Diff for: get-contributors.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./stackql exec --output csv -f contributors.csv -H "SELECT a.login FROM github.activity.repo_stargazers AS a JOIN github.repos.contributors AS c ON a.login = c.login WHERE a.owner = 'stackql' AND a.repo IN ('stackql','stackql-deploy') AND c.owner = 'stackql' AND c.repo = 'stackql-deploy' GROUP BY a.login HAVING COUNT(DISTINCT a.repo) = 2"

Diff for: src/commands/info.rs

+15
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,19 @@ pub fn execute() {
7171
println!(" {} {}", provider.name.bold(), provider.version);
7272
}
7373
}
74+
75+
// Display contributors
76+
let raw_contributors = option_env!("CONTRIBUTORS").unwrap_or("");
77+
let contributors: Vec<&str> = raw_contributors
78+
.split(',')
79+
.filter(|s| !s.trim().is_empty())
80+
.collect();
81+
82+
if !contributors.is_empty() {
83+
println!("\n{}", "Special thanks to:".green().bold());
84+
85+
for chunk in contributors.chunks(5) {
86+
println!(" {}", chunk.join(", "));
87+
}
88+
}
7489
}

Diff for: src/commands/init.rs

+37-25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::utils::display::print_unicode_box;
22
use clap::{Arg, ArgAction, ArgMatches, Command};
33
use colored::*;
44
use reqwest::blocking::Client;
5+
use reqwest::StatusCode;
56
use std::collections::HashSet;
67
use std::fs;
78
use std::io::Write;
@@ -173,10 +174,25 @@ fn validate_provider(provider: Option<&str>) -> String {
173174
// Function to fetch template content from URL
174175
fn fetch_template(url: &str) -> Result<String, String> {
175176
let client = Client::new();
176-
client
177+
let response = client
177178
.get(url)
178179
.send()
179-
.map_err(|e| format!("Failed to fetch template: {}", e))?
180+
.map_err(|e| format!("Failed to fetch template: {}", e))?;
181+
182+
// Check if response is successful (status code 200-299)
183+
if !response.status().is_success() {
184+
// Handle 404 and other error status codes
185+
if response.status() == StatusCode::NOT_FOUND {
186+
return Err(format!("Template not found at URL: {}", url));
187+
} else {
188+
return Err(format!(
189+
"Failed to fetch template: HTTP status {}",
190+
response.status()
191+
));
192+
}
193+
}
194+
195+
response
180196
.text()
181197
.map_err(|e| format!("Failed to read template content: {}", e))
182198
}
@@ -269,11 +285,6 @@ fn create_project_structure(
269285
return Err(format!("Directory '{}' already exists", stack_name));
270286
}
271287

272-
// Create necessary directories
273-
let resource_dir = base_path.join("resources");
274-
fs::create_dir_all(&resource_dir)
275-
.map_err(|e| format!("Failed to create directories: {}", e))?;
276-
277288
// Determine sample resource name based on provider
278289
let sample_res_name = template_source.get_sample_res_name();
279290

@@ -282,25 +293,32 @@ fn create_project_structure(
282293
context.insert("stack_name", stack_name);
283294
context.insert("stack_env", env);
284295

296+
// First validate that all templates can be fetched before creating any directories
297+
let manifest_template = get_template_content(template_source, "manifest", "")?;
298+
let readme_template = get_template_content(template_source, "readme", "")?;
299+
let resource_template = get_template_content(template_source, "resource", sample_res_name)?;
300+
301+
// Now create directories
302+
let resource_dir = base_path.join("resources");
303+
fs::create_dir_all(&resource_dir)
304+
.map_err(|e| format!("Failed to create directories: {}", e))?;
305+
285306
// Create files
286-
create_manifest_file(&base_path, template_source, &context)?;
287-
create_readme_file(&base_path, template_source, &context)?;
288-
create_resource_file(&resource_dir, sample_res_name, template_source, &context)?;
307+
create_manifest_file(&base_path, &manifest_template, &context)?;
308+
create_readme_file(&base_path, &readme_template, &context)?;
309+
create_resource_file(&resource_dir, sample_res_name, &resource_template, &context)?;
289310

290311
Ok(())
291312
}
292313

293314
fn create_resource_file(
294315
resource_dir: &Path,
295316
sample_res_name: &str,
296-
template_source: &TemplateSource,
317+
template_str: &str,
297318
context: &Context,
298319
) -> Result<(), String> {
299-
// Get template content
300-
let template_str = get_template_content(template_source, "resource", sample_res_name)?;
301-
302320
// Render template with Tera
303-
let resource_content = render_template(&template_str, context)
321+
let resource_content = render_template(template_str, context)
304322
.map_err(|e| format!("Template rendering error: {}", e))?;
305323

306324
let resource_path = resource_dir.join(format!("{}.iql", sample_res_name));
@@ -315,14 +333,11 @@ fn create_resource_file(
315333

316334
fn create_manifest_file(
317335
base_path: &Path,
318-
template_source: &TemplateSource,
336+
template_str: &str,
319337
context: &Context,
320338
) -> Result<(), String> {
321-
// Get template content
322-
let template_str = get_template_content(template_source, "manifest", "")?;
323-
324339
// Render template with Tera
325-
let manifest_content = render_template(&template_str, context)
340+
let manifest_content = render_template(template_str, context)
326341
.map_err(|e| format!("Template rendering error: {}", e))?;
327342

328343
let manifest_path = base_path.join("stackql_manifest.yml");
@@ -337,14 +352,11 @@ fn create_manifest_file(
337352

338353
fn create_readme_file(
339354
base_path: &Path,
340-
template_source: &TemplateSource,
355+
template_str: &str,
341356
context: &Context,
342357
) -> Result<(), String> {
343-
// Get template content
344-
let template_str = get_template_content(template_source, "readme", "")?;
345-
346358
// Render template with Tera
347-
let readme_content = render_template(&template_str, context)
359+
let readme_content = render_template(template_str, context)
348360
.map_err(|e| format!("Template rendering error: {}", e))?;
349361

350362
let readme_path = base_path.join("README.md");

Diff for: src/commands/shell.rs

+21-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::display::print_unicode_box;
2+
use crate::utils::query::{execute_query, QueryResult};
23
use crate::utils::server::{is_server_running, start_server, ServerOptions};
3-
use crate::utils::stackql::{execute_query_with_pg, QueryResult};
44
use clap::{Arg, ArgAction, ArgMatches, Command};
55
use colored::*;
66
use postgres::Client;
@@ -42,7 +42,6 @@ pub fn execute(matches: &ArgMatches) {
4242
let localhost = String::from("localhost");
4343
let host = matches.get_one::<String>("host").unwrap_or(&localhost);
4444

45-
// Check if server is running, start if not
4645
if host == "localhost" && !is_server_running(port) {
4746
println!("{}", "Server not running. Starting server...".yellow());
4847
let options = ServerOptions {
@@ -61,7 +60,6 @@ pub fn execute(matches: &ArgMatches) {
6160
}
6261
}
6362

64-
// Connect to the server
6563
let connection_string = format!(
6664
"host={} port={} user=postgres dbname=stackql application_name=stackql",
6765
host, port
@@ -78,11 +76,9 @@ pub fn execute(matches: &ArgMatches) {
7876
println!("Type 'exit' to quit the shell");
7977
println!("---");
8078

81-
// Set up command history with rustyline
8279
let mut rl = Editor::<()>::new().unwrap();
83-
let _ = rl.load_history("stackql_history.txt"); // Silently load history, ignore errors
80+
let _ = rl.load_history("stackql_history.txt");
8481

85-
// REPL loop
8682
loop {
8783
let prompt = format!("stackql ({}:{})=> ", host, port);
8884
let readline = rl.readline(&prompt);
@@ -94,22 +90,24 @@ pub fn execute(matches: &ArgMatches) {
9490
continue;
9591
}
9692

97-
// Add to history
9893
rl.add_history_entry(input);
9994

10095
if input.eq_ignore_ascii_case("exit") || input.eq_ignore_ascii_case("quit") {
10196
println!("Goodbye");
10297
break;
10398
}
10499

105-
// Execute the query
106-
match execute_query_with_pg(input, port) {
100+
match execute_query(input, port) {
107101
Ok(result) => match result {
108-
QueryResult::Data { columns, rows } => {
102+
QueryResult::Data {
103+
columns,
104+
rows,
105+
notices: _,
106+
} => {
109107
print_table(columns, rows);
110108
}
111109
QueryResult::Command(cmd) => {
112-
println!("{}", format!("Command completed: {}", cmd).green());
110+
println!("{}", cmd.green());
113111
}
114112
QueryResult::Empty => {
115113
println!("{}", "Query executed successfully. No results.".green());
@@ -135,19 +133,15 @@ pub fn execute(matches: &ArgMatches) {
135133
}
136134
}
137135

138-
// Save history
139-
let _ = rl.save_history("stackql_history.txt"); // Silently save history, ignore errors
136+
let _ = rl.save_history("stackql_history.txt");
140137
}
141138

142-
// Function to print a formatted table
143139
fn print_table(
144-
columns: Vec<crate::utils::stackql::QueryResultColumn>,
145-
rows: Vec<crate::utils::stackql::QueryResultRow>,
140+
columns: Vec<crate::utils::query::QueryResultColumn>,
141+
rows: Vec<crate::utils::query::QueryResultRow>,
146142
) {
147-
// Calculate column widths
148143
let mut column_widths: Vec<usize> = columns.iter().map(|col| col.name.len()).collect();
149144

150-
// Update widths based on data
151145
for row in &rows {
152146
for (i, value) in row.values.iter().enumerate() {
153147
if i < column_widths.len() && value.len() > column_widths[i] {
@@ -156,7 +150,7 @@ fn print_table(
156150
}
157151
}
158152

159-
// Print top border
153+
// Print header border
160154
print!("+");
161155
for width in &column_widths {
162156
print!("{}+", "-".repeat(width + 2));
@@ -174,14 +168,14 @@ fn print_table(
174168
}
175169
println!();
176170

177-
// Print header separator
171+
// Print border after header
178172
print!("+");
179173
for width in &column_widths {
180174
print!("{}+", "-".repeat(width + 2));
181175
}
182176
println!();
183177

184-
// Print row data
178+
// Print each row with a border after it
185179
let row_count = rows.len();
186180
for row in rows {
187181
print!("|");
@@ -191,16 +185,15 @@ fn print_table(
191185
}
192186
}
193187
println!();
194-
}
195188

196-
// Print bottom border
197-
print!("+");
198-
for width in &column_widths {
199-
print!("{}+", "-".repeat(width + 2));
189+
// Print border after each row
190+
print!("+");
191+
for width in &column_widths {
192+
print!("{}+", "-".repeat(width + 2));
193+
}
194+
println!();
200195
}
201-
println!();
202196

203-
// Print row count
204197
if row_count > 0 {
205198
println!("{} rows returned", row_count);
206199
}

Diff for: src/utils/binary.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ use std::env;
22
use std::path::PathBuf;
33
use std::process::Command;
44

5-
// /// Check if the stackql binary exists in the current directory
6-
// pub fn binary_exists_in_current_dir() -> bool {
7-
// if let Ok(current_dir) = env::current_dir() {
8-
// let binary_name = super::platform::get_binary_name();
9-
// let binary_path = current_dir.join(&binary_name);
10-
// binary_path.exists() && binary_path.is_file()
11-
// } else {
12-
// false
13-
// }
14-
// }
15-
165
/// Check if the stackql binary exists in PATH
176
pub fn binary_exists_in_path() -> bool {
187
let binary_name = super::platform::get_binary_name();

Diff for: src/utils/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ pub mod binary;
22
pub mod display;
33
pub mod download;
44
pub mod platform;
5+
pub mod query;
56
pub mod server;
67
pub mod stackql;

0 commit comments

Comments
 (0)