diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/install/base/Install.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/install/base/Install.kt index 83c09af..e1ca687 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/install/base/Install.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/install/base/Install.kt @@ -9,7 +9,7 @@ private var aptInit = false /** * Installs package(s) by using package manager "apt". * - * @param packages the packages to be installed, packages separated by space if there are more than one + * @param packages the packages to be installed, packages must be separated by space if there are more than one */ fun Prov.aptInstall(packages: String): ProvResult = def { if (!aptInit) { @@ -27,6 +27,21 @@ fun Prov.aptInstall(packages: String): ProvResult = def { } +/** + * Installs package(s) by using package manager "snap". + * + * @param packages the packages to be installed, packages must be separated by space if there are more than one + */ +// todo: add test +fun Prov.snapInstall(packages: String, classic: Boolean = false): ProvResult = def { + val packageList = packages.split(" ") + for (packg in packageList) { + cmd("sudo snap install $packg" + if (classic) " --classic" else "") + } + ProvResult(true) // dummy +} + + /** * Installs a package from a ppa (personal package archive) by using package manager "apt". * diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/application/CliWorkplace.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/application/CliWorkplace.kt index 90c861f..8287eb1 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/application/CliWorkplace.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/application/CliWorkplace.kt @@ -8,8 +8,8 @@ import kotlin.system.exitProcess /** - * Provisions according to the options either a meissa workplace, reposOnly or gopassOnly. - * Locally or on a remote machine. If remotely, the remote host and remote user are specified by args parameters. + * Provisions a workplace locally or on a remote machine. + * Specify option -h for help. */ fun main(args: Array) { diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/domain/ProvisionWorkplace.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/domain/ProvisionWorkplace.kt index 38ebc9c..e94bf56 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/domain/ProvisionWorkplace.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/domain/ProvisionWorkplace.kt @@ -86,10 +86,12 @@ fun Prov.provisionWorkplace( installDocker() // IDEs - cmd("sudo snap install intellij-idea-community --classic") installVSC("python", "clojure") + installIntelliJ() installDevOps() + + installPython() } ProvResult(true) // dummy diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/IntelliJ.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/IntelliJ.kt new file mode 100644 index 0000000..231e53e --- /dev/null +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/IntelliJ.kt @@ -0,0 +1,8 @@ +package org.domaindrivenarchitecture.provs.workplace.infrastructure + +import org.domaindrivenarchitecture.provs.core.Prov + + +fun Prov.installIntelliJ() = task { + cmd("sudo snap install intellij-idea-community --classic") +} diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Python.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Python.kt index 0fbf751..ec614c6 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Python.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Python.kt @@ -2,10 +2,9 @@ package org.domaindrivenarchitecture.provs.workplace.infrastructure import org.domaindrivenarchitecture.provs.core.Prov import org.domaindrivenarchitecture.provs.core.ProvResult -import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs -import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstall + fun Prov.installPython() = def { installPython3() installVenv() @@ -14,14 +13,12 @@ fun Prov.installPython() = def { installJupyterlab() } - - fun Prov.installPython3(): ProvResult = def { aptInstall("python3.8-venv") } fun Prov.installVenv(): ProvResult = def { - var venvHome = "~/.python/meissa" + val venvHome = "~/.python/meissa" cmd("python3 -m venv " + venvHome) cmd("source " + venvHome + "/bin/activate") cmd("pip install pip --upgrade") diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/PythonKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/PythonKtTest.kt new file mode 100644 index 0000000..41d366b --- /dev/null +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/PythonKtTest.kt @@ -0,0 +1,14 @@ +package org.domaindrivenarchitecture.provs.workplace.infrastructure + +import org.domaindrivenarchitecture.provs.test.defaultTestContainer +import org.domaindrivenarchitecture.provs.test.tags.ContainerTest +import org.junit.jupiter.api.Test + +internal class PythonKtTest { + + @Test + @ContainerTest + fun installPython() { + defaultTestContainer().installPython() + } +} \ No newline at end of file