Skip to content

Commit

Permalink
Skript som starter vscode i rett folder
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhoh committed Dec 20, 2023
1 parent aa368c0 commit 0863746
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/Installasjon-på-VDI/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ start_vscode_dbt.ps1 c:\sti\til\dbt-prosjekt\ skjemanavn

Ideen er at man kan legge skriptet et sted på utviklerimage, f.eks. `c:\datavarehus\start_vscode_dbt.ps1`, og lage snarveier på skrivebordet til hvert av prosjektene, slik at miljøet for hvert prosjekt kan startes opp med et dobbeltklikk.

For slikt oppsett, gjør følgende:
For slikt oppsett, gjør følgende per komponent/dbt prosjekt du har:

1. Høyreklikk - hold - dra over skrivebordet - slipp. Velg `Lag snarveier her`.

Expand Down
41 changes: 24 additions & 17 deletions start_vscode_dbt.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Path to wher you would like to place the python virtual env
$dbtEnv_path = "C:\datavarehus\.dbtenv"




#Function to set up a virtual env for dbt
Expand All @@ -15,9 +15,22 @@ function Add-dbtenv {
# Latest pip
python -m pip install --upgrade pip
# Install the latest dbt
python -m pip install -r requirements.txt
python -m pip install -r https://raw.githubusercontent.com/navikt/dbt-i-nav/main/requirements.txt
}

#Check if environment exists
$dbtEnv_exists = Test-Path -Path $dbtEnv_path
if (-Not $dbtEnv_exists) {
Add-dbtenv
}
Else{
if ((Read-Host -Prompt "Update $dbtEnv_path`? (y/n)") -eq "y") {
Add-dbtenv
}
Else {
iex $dbtEnv_path"/Scripts/activate.ps1"
}
}

#path to dbt folder
if ($args[0]) {
Expand All @@ -34,7 +47,7 @@ if ($args[1]) {
$schema = $args[1].ToUpper()
Write-Host "Setting schema to: $schema"
} else {
Write-Host "Missing scheam. Pass schema as second argument this script."
Write-Host "Missing schema. Pass schema as second argument this script."
exit
}

Expand Down Expand Up @@ -85,19 +98,7 @@ $env:DBT_ENV_SECRET_PASS = $creds.GetNetworkCredential().password



#Check if environment exists
$dbtEnv_exists = Test-Path -Path $dbtEnv_path
if (-Not $dbtEnv_exists) {
Add-dbtenv
}
Else{
if ((Read-Host -Prompt "Update .dbtenv? (y/n)") -eq "y") {
Add-dbtenv
}
Else {
iex $dbtEnv_path"/Scripts/activate.ps1"
}
}


iex $dbtEnv_path"/Scripts/activate.ps1"
dbt deps
Expand All @@ -107,4 +108,10 @@ Remove-Item -Path Env:https_proxy
$env:ORA_PYTHON_DRIVER_TYPE = "thin"
echo "ORA_PYTHON_DRIVER_TYPE: $env:ORA_PYTHON_DRIVER_TYPE"

code .
$git_repo_detected = Test-Path -Path $dbtPath"\.git"

if ($git_repo_detected) {
code .
} else {
code ..
}

0 comments on commit 0863746

Please sign in to comment.