You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.2 KiB
Kotlin
94 lines
3.2 KiB
Kotlin
2 years ago
|
package org.domaindrivenarchitecture.provs.desktop.infrastructure
|
||
3 years ago
|
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||
|
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
|
||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackageInstalled
|
||
3 years ago
|
|
||
|
|
||
|
fun Prov.installVSC(vararg options: String) = requireAll {
|
||
|
val clojureExtensions =
|
||
|
arrayListOf("betterthantomorrow.calva", "martinklepsch.clojure-joker-linter", "DavidAnson.vscode-markdownlint")
|
||
|
val pythonExtensions = arrayListOf("ms-python.python")
|
||
|
|
||
|
prerequisitesVSCinstall()
|
||
|
|
||
|
installVSCPackage()
|
||
2 years ago
|
installVSCodiumPackage()
|
||
3 years ago
|
|
||
|
if (options.contains("clojure")) {
|
||
2 years ago
|
installExtensionsCode(clojureExtensions)
|
||
|
installExtensionsCodium(clojureExtensions)
|
||
3 years ago
|
}
|
||
|
if (options.contains("python")) {
|
||
2 years ago
|
installExtensionsCode(pythonExtensions)
|
||
|
installExtensionsCodium(pythonExtensions)
|
||
3 years ago
|
}
|
||
|
|
||
|
provisionAdditionalTools()
|
||
|
}
|
||
|
|
||
|
|
||
|
private fun Prov.prerequisitesVSCinstall() = def {
|
||
|
aptInstall("curl gpg unzip apt-transport-https")
|
||
|
}
|
||
|
|
||
|
|
||
|
@Suppress("unused") // only required for installation of vscode via apt
|
||
3 years ago
|
private fun Prov.installVscWithApt() = requireAll {
|
||
|
val packageName = "code"
|
||
|
if (!isPackageInstalled(packageName)) {
|
||
3 years ago
|
// see https://code.visualstudio.com/docs/setup/linux
|
||
3 years ago
|
// alternatively install with snapd (but this cannot be tested within docker as snapd within docker is not working/supported)
|
||
|
sh("""
|
||
|
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
|
||
|
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
|
||
|
sudo sh -c 'echo \"deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main\" > /etc/apt/sources.list.d/vscode.list'
|
||
|
""")
|
||
|
aptInstall("apt-transport-https")
|
||
|
aptInstall(packageName)
|
||
|
} else {
|
||
|
ProvResult(true, out = "Package $packageName already installed.")
|
||
|
}
|
||
3 years ago
|
}
|
||
|
|
||
|
|
||
|
private fun Prov.installVSCPackage() = def {
|
||
|
cmd("sudo snap install code --classic")
|
||
|
|
||
|
// to install via apt use:
|
||
3 years ago
|
// installVscWithApt()
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
private fun Prov.installVSCodiumPackage() = def {
|
||
|
cmd("sudo snap install codium --classic")
|
||
|
}
|
||
|
|
||
3 years ago
|
|
||
2 years ago
|
private fun Prov.installExtensionsCode(extensions: List<String>) = optional {
|
||
3 years ago
|
var res = ProvResult(true)
|
||
|
for (ext in extensions) {
|
||
|
res = cmd("code --install-extension $ext")
|
||
|
}
|
||
|
res
|
||
|
// Settings can be found at $HOME/.config/Code/User/settings.json
|
||
|
}
|
||
|
|
||
2 years ago
|
private fun Prov.installExtensionsCodium(extensions: List<String>) = optional {
|
||
|
var res = ProvResult(true)
|
||
|
for (ext in extensions) {
|
||
|
res = cmd("codium --install-extension $ext")
|
||
|
}
|
||
|
res
|
||
|
// Settings can be found at $HOME/.config/Code/User/settings.json
|
||
|
}
|
||
|
|
||
3 years ago
|
|
||
2 years ago
|
internal fun Prov.provisionAdditionalTools() = requireAll {
|
||
3 years ago
|
// Joker
|
||
2 years ago
|
val version = "0.18.0"
|
||
|
cmd("curl -Lo joker-${version}-linux-amd64.zip https://github.com/candid82/joker/releases/download/v${version}/joker-${version}-linux-amd64.zip")
|
||
|
cmd("unzip joker-${version}-linux-amd64.zip")
|
||
3 years ago
|
cmd("sudo mv joker /usr/local/bin/")
|
||
|
}
|