fix: add support for NPM_CONFIG_REGISTRY

This commit is contained in:
Ruben Fiszel
2024-01-30 12:58:52 +01:00
parent 26d5c6c1ba
commit 47fcfbbbdf
3 changed files with 49 additions and 18 deletions
+31 -2
View File
@@ -243,11 +243,35 @@ pub async fn install_lockfile(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
if npm_mode {
logs.push_str("NPM mode\n")
}
let has_file = if npm_mode {
let registry = NPM_CONFIG_REGISTRY.read().await.clone();
if let Some(registry) = registry {
child_cmd.env("NPM_CONFIG_REGISTRY", registry);
let content = registry
.trim_start_matches("https:")
.trim_start_matches("http:");
let mut splitted = registry.split(":_authToken=");
let custom_registry = splitted.next().unwrap_or_default();
logs.push_str(&format!(
"Using custom npm registry: {custom_registry} {}\n",
if splitted.next().is_some() {
"with authToken"
} else {
"without authToken"
}
));
child_cmd.env("NPM_CONFIG_REGISTRY", custom_registry);
write_file(job_dir, ".npmrc", content).await?;
true
} else {
false
}
}
} else {
false
};
let child_process = start_child_process(child_cmd, &*BUN_PATH).await?;
@@ -267,6 +291,11 @@ pub async fn install_lockfile(
false,
)
.await?;
if has_file {
tokio::fs::remove_file(format!("{job_dir}/.npmrc")).await?;
}
Ok(())
}
@@ -63,7 +63,7 @@
values['base_url'] = window.location.origin
}
if (values['retention_period_secs'] == undefined) {
values['retention_period_secs'] = 60 * 60 * 24 * 60
values['retention_period_secs'] = 60 * 60 * 24 * 30
}
if (values['base_url'] == undefined) {
values['base_url'] = 'http://localhost'
@@ -368,7 +368,7 @@
{#if setting.ee_only != undefined && !$enterpriseLicense}
<div class="flex text-xs items-center gap-1 text-yellow-500 whitespace-nowrap">
<AlertTriangle size={16} />
EE only <Tooltip>{setting.ee_only}</Tooltip>
EE only {#if setting.ee_only != ''}<Tooltip>{setting.ee_only}</Tooltip>{/if}
</div>
{/if}
<label class="block pb-2">
@@ -455,7 +455,10 @@
</div>
{:else if setting.fieldType == 'seconds'}
<div>
<SecondsInput bind:seconds={values[setting.key]} />
<SecondsInput
disabled={true || (setting.ee_only != undefined && !$enterpriseLicense)}
bind:seconds={values[setting.key]}
/>
</div>
{/if}
+12 -13
View File
@@ -51,15 +51,6 @@ export const settings: Record<string, Setting[]> = {
placeholder: '50',
storage: 'setting'
},
{
label: 'Retention Period in secs',
key: 'retention_period_secs',
description: 'How long to keep the jobs data in the database.',
fieldType: 'seconds',
placeholder: '60',
storage: 'setting',
cloudonly: false
},
{
label: 'Default timeout',
key: 'job_default_timeout',
@@ -84,14 +75,23 @@ export const settings: Record<string, Setting[]> = {
placeholder: 'only needed to prepare upgrade to EE',
storage: 'setting'
},
{
label: 'Retention Period in secs',
key: 'retention_period_secs',
description: 'How long to keep the jobs data in the database.',
fieldType: 'seconds',
placeholder: '30',
storage: 'setting',
ee_only: 'You can only adjust this setting in the EE version',
cloudonly: false
},
{
label: 'Expose metrics',
description: 'Expose prometheus metrics for workers and servers on port 8001 at /metrics',
key: 'expose_metrics',
fieldType: 'boolean',
storage: 'setting',
ee_only: 'No workaround around this'
ee_only: ''
},
{
label: 'Azure OpenAI base path',
@@ -100,8 +100,7 @@ export const settings: Record<string, Setting[]> = {
key: 'openai_azure_base_path',
fieldType: 'text',
storage: 'setting',
ee_only:
'You can still set this setting by using OPENAI_AZURE_BASE_PATH as env variable to the server containers'
ee_only: ''
}
],
'SSO/OAuth': [