From 1aeeff9ddc20b8d4989453cf4232d247abcb54c8 Mon Sep 17 00:00:00 2001 From: Ciro Lo Sapio Date: Tue, 23 Jul 2024 00:20:19 +0200 Subject: [PATCH] fix envman update function --- README.md | 2 +- main.ts | 15 ++++++++++----- softwares.ts | 10 +++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 208679f..2f6ab22 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,6 @@ ### Install ``` -sudo curl -L https://github.com/cirolosapio/envman/releases/download/v0.0.16/envman -o /usr/local/bin/envman +sudo curl -L https://github.com/cirolosapio/envman/releases/download/v0.0.17/envman -o /usr/local/bin/envman sudo chmod +x /usr/local/bin/envman ``` diff --git a/main.ts b/main.ts index 27365a6..7426f9f 100644 --- a/main.ts +++ b/main.ts @@ -3,7 +3,7 @@ import { colors } from 'https://deno.land/x/cliffy@v1.0.0-rc.4/ansi/colors.ts' import { checkOption, dockerServiceStartsAutomatically, getLastEnvmanVersion, isCurrentUserInDockerGroup, isDocker, isOhMyZshInstalled, isWsl, run, selectWsl } from './functions.ts' import { dockerEnginePostInstall, installBottom, installCarootOnWsl, installCtop, installDeno, installDockerEngine, installEnvman, installJetBrainsGateway, installMage2Postman, installMagentoCloudCli, installMkcert, installMkcertWin, installOhMyZsh, installSig, installSshs, installStarship } from './softwares.ts' -export const VERSION = 'v0.0.16' +export const VERSION = 'v0.0.17' async function main() { if (await isDocker()) { @@ -43,7 +43,13 @@ async function main() { const installed = [] const options: CheckboxOption[] = [] - if (lastEnvmanVersion !== VERSION) options.push({ name: colors.yellow('envman - Update needed!'), value: 'envman', checked: true }) + if (lastEnvmanVersion !== VERSION) { + console.log(colors.yellow(`New version of envman available: ${lastEnvmanVersion}`)) + if (await Confirm.prompt({ message: 'Do you want to update envman?', default: true })) { + await installEnvman(lastEnvmanVersion) + return + } + } if (showDocker.disabled) { installed.push('Docker Engine') @@ -112,10 +118,9 @@ async function main() { if (softwares.includes('mgc')) toInstall.push(installMagentoCloudCli()) if (softwares.includes('mage2postman')) toInstall.push(installMage2Postman()) if (softwares.includes('starship')) toInstall.push(installStarship()) - if (softwares.includes('envman')) toInstall.push(installEnvman()) await Promise.all(toInstall) - if (await Confirm.prompt('Do you want to install another software?')) await main() + if (await Confirm.prompt({ message: 'Do you want to install another software?', default: false })) await main() } else console.log(colors.green('All software are installed ✔')) } else { const softwares = await Checkbox.prompt({ @@ -155,7 +160,7 @@ async function main() { await child.stdin.close() } - if (await Confirm.prompt('Do you want to install another software?')) await main() + if (await Confirm.prompt({ message: 'Do you want to install another software?', default: false })) await main() } } diff --git a/softwares.ts b/softwares.ts index f4951a8..9441f38 100644 --- a/softwares.ts +++ b/softwares.ts @@ -1,6 +1,5 @@ import { bash, exists, getJetBrainsGatewayVersion, getUser, hasDockerDesktop, isCurrentUserInDockerGroup, isInstalled, ps, run, runn } from './functions.ts' import { colors } from 'https://deno.land/x/cliffy@v1.0.0-rc.4/ansi/colors.ts' -import { VERSION } from './main.ts' export async function installDockerEngine() { console.log(colors.blue('installing docker engine...')) @@ -146,12 +145,13 @@ export async function installMage2Postman() { console.log(colors.green(`mage2postman installed ✔\n`)) } -export async function installEnvman() { - console.log(colors.blue('installing evnman...')) +export async function installEnvman(version: string) { + console.log(colors.blue('updating evnman...')) await run('sudo rm /usr/local/bin/envman'.split(' ')) - await run(`sudo curl -L https://github.com/cirolosapio/envman/releases/download/${VERSION}/envman -o /usr/local/bin/envman`.split(' ')) + await run(`sudo curl -L https://github.com/cirolosapio/envman/releases/download/${version}/envman -o /usr/local/bin/envman`.split(' ')) await run('sudo chmod +x /usr/local/bin/envman'.split(' ')) - console.log(colors.green(`evnman installed ✔\n`)) + console.log(colors.green(`evnman updated ✔\n`)) + console.log(colors.underline('you can now re-run envman')) } export async function installJetBrainsGateway() {