Updated testing
This commit is contained in:
+33
-9
@@ -9,20 +9,21 @@ function Install-Obsidian-Windows {
|
||||
Write-Output "Installing Obsidian for Windows..."
|
||||
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Output "Chocolatey is not installed. Installing Chocolatey..."
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force;
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||
$script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
|
||||
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
|
||||
}
|
||||
choco install -y jq
|
||||
|
||||
Write-Output "Downloading Obsidian installer..."
|
||||
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile "ObsidianInstaller.exe"
|
||||
$installerPath = "$env:TEMP\ObsidianInstaller.exe"
|
||||
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile $installerPath
|
||||
|
||||
# Check if the installer was downloaded
|
||||
if (Test-Path "ObsidianInstaller.exe") {
|
||||
if (Test-Path $installerPath) {
|
||||
Write-Output "Running Obsidian installer..."
|
||||
$startProcess = Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -PassThru -Wait
|
||||
$startProcess = Start-Process -FilePath $installerPath -ArgumentList "/S" -PassThru -Wait
|
||||
Write-Output "Installer exit code: $($startProcess.ExitCode)"
|
||||
|
||||
# Check for Obsidian executable in possible installation paths
|
||||
@@ -62,27 +63,50 @@ function Install-Plugin {
|
||||
Stop-Process -Name "Obsidian" -Force
|
||||
}
|
||||
|
||||
# Define the vault path and plugins directory
|
||||
$vaultPath = "$env:USERPROFILE\Documents\ObsidianVault" # Update this path as needed
|
||||
$pluginsDir = "$vaultPath\.obsidian\plugins"
|
||||
|
||||
# Create the plugins directory if it doesn't exist
|
||||
$pluginsDir = "$env:APPDATA\obsidian\plugins"
|
||||
if (-Not (Test-Path $pluginsDir)) {
|
||||
New-Item -ItemType Directory -Path $pluginsDir | Out-Null
|
||||
}
|
||||
|
||||
# Read plugins configuration file
|
||||
$pluginsConfig = Get-Content -Raw -Path "plugins.json" | ConvertFrom-Json
|
||||
$pluginsConfigPath = ".\plugins.json" # Ensure this is the correct path to your plugins.json file
|
||||
if (-Not (Test-Path $pluginsConfigPath)) {
|
||||
Write-Output "plugins.json file not found."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$pluginsConfig = Get-Content -Raw -Path $pluginsConfigPath | ConvertFrom-Json
|
||||
$corePlugins = $pluginsConfig.core_plugins
|
||||
$communityPlugins = $pluginsConfig.community_plugins
|
||||
|
||||
# Enable core plugins
|
||||
$configPath = "$vaultPath\.obsidian\config"
|
||||
if (-Not (Test-Path $configPath)) {
|
||||
Write-Output "Obsidian config not found. Ensure Obsidian has been started at least once with the vault."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$config = Get-Content -Raw -Path $configPath | ConvertFrom-Json
|
||||
foreach ($plugin in $corePlugins) {
|
||||
Write-Output "Enabling core plugin: $plugin"
|
||||
New-Item -ItemType File -Path "$pluginsDir\$plugin" | Out-Null
|
||||
$config["plugin:$plugin"] = $true
|
||||
}
|
||||
$config | ConvertTo-Json -Compress | Set-Content -Path $configPath
|
||||
|
||||
# Install community plugins
|
||||
foreach ($plugin in $communityPlugins) {
|
||||
Write-Output "Installing community plugin: $plugin"
|
||||
New-Item -ItemType Directory -Path "$pluginsDir\$plugin" | Out-Null
|
||||
$pluginName = $plugin -replace '/','-'
|
||||
$pluginUrl = "https://github.com/$plugin/releases/latest/download/main.js"
|
||||
$pluginDir = "$pluginsDir\$pluginName"
|
||||
if (-Not (Test-Path $pluginDir)) {
|
||||
New-Item -ItemType Directory -Path $pluginDir | Out-Null
|
||||
}
|
||||
Invoke-WebRequest -Uri $pluginUrl -OutFile "$pluginDir\main.js"
|
||||
}
|
||||
|
||||
Write-Output "Plugins installed successfully."
|
||||
|
||||
Reference in New Issue
Block a user