feat(cli): make default typescript configurable

This commit is contained in:
Ruben Fiszel
2024-01-27 20:29:31 +01:00
parent 414ebee0f1
commit 59bbff662e
8 changed files with 69 additions and 58 deletions
+16 -2
View File
@@ -1981,6 +1981,7 @@ struct ArchiveQueryParams {
skip_variables: Option<bool>,
skip_resources: Option<bool>,
include_schedules: Option<bool>,
default_ts: Option<String>,
}
#[inline]
@@ -2038,6 +2039,7 @@ async fn tarball_workspace(
skip_secrets,
skip_variables,
include_schedules,
default_ts,
}): Query<ArchiveQueryParams>,
) -> Result<([(headers::HeaderName, String); 2], impl IntoResponse)> {
// require_admin(authed.is_admin, &authed.username)?;
@@ -2087,7 +2089,13 @@ async fn tarball_workspace(
for script in scripts {
let ext = match script.language {
ScriptLang::Python3 => "py",
ScriptLang::Deno => "ts",
ScriptLang::Deno => {
if default_ts.as_ref().is_some_and(|x| x == "bun") {
"deno.ts"
} else {
"ts"
}
}
ScriptLang::Go => "go",
ScriptLang::Bash => "sh",
ScriptLang::Powershell => "ps1",
@@ -2098,7 +2106,13 @@ async fn tarball_workspace(
ScriptLang::Mssql => "ms.sql",
ScriptLang::Graphql => "gql",
ScriptLang::Nativets => "fetch.ts",
ScriptLang::Bun => "bun.ts",
ScriptLang::Bun => {
if default_ts.as_ref().is_some_and(|x| x == "bun") {
"ts"
} else {
"bun.ts"
}
}
};
archive
.write_to_archive(&script.content, &format!("{}.{}", script.path, ext))