mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-25 18:13:52 +03:00
Adding uninstall command (#953)
* Adding uninstall command * Updates docs and changelog related to the uninstall command
This commit is contained in:
parent
0002414fa1
commit
1017e20bf4
@ -50,6 +50,13 @@ const getTasks: GetTasks<Task[]> = (args, context) => {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Uninstall command
|
||||||
|
If you want to uninstall Wasp from your system, you can now do so with:
|
||||||
|
```bash
|
||||||
|
wasp uninstall
|
||||||
|
```
|
||||||
|
It will remove all of the Wasp binaries and data from your system.
|
||||||
|
|
||||||
## v0.8.0
|
## v0.8.0
|
||||||
|
|
||||||
### BREAKING CHANGES
|
### BREAKING CHANGES
|
||||||
|
@ -21,6 +21,7 @@ import Wasp.Cli.Command.Dockerfile (printDockerfile)
|
|||||||
import Wasp.Cli.Command.Info (info)
|
import Wasp.Cli.Command.Info (info)
|
||||||
import Wasp.Cli.Command.Start (start)
|
import Wasp.Cli.Command.Start (start)
|
||||||
import qualified Wasp.Cli.Command.Telemetry as Telemetry
|
import qualified Wasp.Cli.Command.Telemetry as Telemetry
|
||||||
|
import Wasp.Cli.Command.Uninstall (uninstall)
|
||||||
import Wasp.Cli.Command.WaspLS (runWaspLS)
|
import Wasp.Cli.Command.WaspLS (runWaspLS)
|
||||||
import Wasp.Cli.Terminal (title)
|
import Wasp.Cli.Terminal (title)
|
||||||
import Wasp.Util (indent)
|
import Wasp.Util (indent)
|
||||||
@ -36,6 +37,7 @@ main = withUtf8 . (`E.catch` handleInternalErrors) $ do
|
|||||||
["clean"] -> Command.Call.Clean
|
["clean"] -> Command.Call.Clean
|
||||||
["compile"] -> Command.Call.Compile
|
["compile"] -> Command.Call.Compile
|
||||||
("db" : dbArgs) -> Command.Call.Db dbArgs
|
("db" : dbArgs) -> Command.Call.Db dbArgs
|
||||||
|
["uninstall"] -> Command.Call.Uninstall
|
||||||
["version"] -> Command.Call.Version
|
["version"] -> Command.Call.Version
|
||||||
["build"] -> Command.Call.Build
|
["build"] -> Command.Call.Build
|
||||||
["telemetry"] -> Command.Call.Telemetry
|
["telemetry"] -> Command.Call.Telemetry
|
||||||
@ -57,6 +59,7 @@ main = withUtf8 . (`E.catch` handleInternalErrors) $ do
|
|||||||
Command.Call.Compile -> runCommand compile
|
Command.Call.Compile -> runCommand compile
|
||||||
Command.Call.Db dbArgs -> dbCli dbArgs
|
Command.Call.Db dbArgs -> dbCli dbArgs
|
||||||
Command.Call.Version -> printVersion
|
Command.Call.Version -> printVersion
|
||||||
|
Command.Call.Uninstall -> runCommand uninstall
|
||||||
Command.Call.Build -> runCommand build
|
Command.Call.Build -> runCommand build
|
||||||
Command.Call.Telemetry -> runCommand Telemetry.telemetry
|
Command.Call.Telemetry -> runCommand Telemetry.telemetry
|
||||||
Command.Call.Deps -> runCommand deps
|
Command.Call.Deps -> runCommand deps
|
||||||
@ -92,6 +95,7 @@ printUsage =
|
|||||||
cmd " version Prints current version of CLI.",
|
cmd " version Prints current version of CLI.",
|
||||||
cmd " waspls Run Wasp Language Server. Add --help to get more info.",
|
cmd " waspls Run Wasp Language Server. Add --help to get more info.",
|
||||||
cmd " completion Prints help on bash completion.",
|
cmd " completion Prints help on bash completion.",
|
||||||
|
cmd " uninstall Removes Wasp from your system.",
|
||||||
title " IN PROJECT",
|
title " IN PROJECT",
|
||||||
cmd " start Runs Wasp app in development mode, watching for file changes.",
|
cmd " start Runs Wasp app in development mode, watching for file changes.",
|
||||||
cmd " db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.",
|
cmd " db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.",
|
||||||
|
@ -26,7 +26,7 @@ bashCompletion = do
|
|||||||
["db", cmdPrefix] -> listMatchingCommands cmdPrefix dbSubCommands
|
["db", cmdPrefix] -> listMatchingCommands cmdPrefix dbSubCommands
|
||||||
_ -> liftIO . putStrLn $ ""
|
_ -> liftIO . putStrLn $ ""
|
||||||
where
|
where
|
||||||
commands = ["new", "version", "waspls", "start", "db", "clean", "build", "telemetry", "deps", "info", "completion", "completion:generate"]
|
commands = ["new", "version", "waspls", "start", "db", "clean", "uninstall", "build", "telemetry", "deps", "info", "completion", "completion:generate"]
|
||||||
dbSubCommands = ["migrate-dev", "studio"]
|
dbSubCommands = ["migrate-dev", "studio"]
|
||||||
listMatchingCommands :: String -> [String] -> Command ()
|
listMatchingCommands :: String -> [String] -> Command ()
|
||||||
listMatchingCommands cmdPrefix cmdList = listCommands $ filter (cmdPrefix `isPrefixOf`) cmdList
|
listMatchingCommands cmdPrefix cmdList = listCommands $ filter (cmdPrefix `isPrefixOf`) cmdList
|
||||||
|
@ -4,6 +4,7 @@ data Call
|
|||||||
= New String -- project name
|
= New String -- project name
|
||||||
| Start
|
| Start
|
||||||
| Clean
|
| Clean
|
||||||
|
| Uninstall
|
||||||
| Compile
|
| Compile
|
||||||
| Db [String] -- db args
|
| Db [String] -- db args
|
||||||
| Build
|
| Build
|
||||||
|
@ -1,28 +1,27 @@
|
|||||||
module Wasp.Cli.Command.Telemetry.Common
|
module Wasp.Cli.Command.Telemetry.Common
|
||||||
( TelemetryCacheDir,
|
( TelemetryCacheDir,
|
||||||
ensureTelemetryCacheDirExists,
|
ensureTelemetryCacheDirExists,
|
||||||
getTelemetryCacheDirPath,
|
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import StrongPath (Abs, Dir, Path', reldir)
|
import StrongPath (Abs, Dir, Path', reldir, (</>))
|
||||||
import qualified StrongPath as SP
|
import qualified StrongPath as SP
|
||||||
import qualified System.Directory as SD
|
import qualified System.Directory as SD
|
||||||
|
import Wasp.Cli.FileSystem
|
||||||
data UserCacheDir
|
( UserCacheDir,
|
||||||
|
getUserCacheDir,
|
||||||
getUserCacheDirPath :: IO (Path' Abs (Dir UserCacheDir))
|
getWaspCacheDir,
|
||||||
getUserCacheDirPath = SD.getXdgDirectory SD.XdgCache "" >>= SP.parseAbsDir
|
)
|
||||||
|
|
||||||
data TelemetryCacheDir
|
data TelemetryCacheDir
|
||||||
|
|
||||||
|
getTelemetryCacheDir :: Path' Abs (Dir UserCacheDir) -> Path' Abs (Dir TelemetryCacheDir)
|
||||||
|
getTelemetryCacheDir userCacheDirPath = getWaspCacheDir userCacheDirPath </> [reldir|telemetry|]
|
||||||
|
|
||||||
ensureTelemetryCacheDirExists :: IO (Path' Abs (Dir TelemetryCacheDir))
|
ensureTelemetryCacheDirExists :: IO (Path' Abs (Dir TelemetryCacheDir))
|
||||||
ensureTelemetryCacheDirExists = do
|
ensureTelemetryCacheDirExists = do
|
||||||
userCacheDirPath <- getUserCacheDirPath
|
userCacheDirPath <- getUserCacheDir
|
||||||
SD.createDirectoryIfMissing False $ SP.fromAbsDir userCacheDirPath
|
SD.createDirectoryIfMissing False $ SP.fromAbsDir userCacheDirPath
|
||||||
let telemetryCacheDirPath = getTelemetryCacheDirPath userCacheDirPath
|
let telemetryCacheDir = getTelemetryCacheDir userCacheDirPath
|
||||||
SD.createDirectoryIfMissing True $ SP.fromAbsDir telemetryCacheDirPath
|
SD.createDirectoryIfMissing True $ SP.fromAbsDir telemetryCacheDir
|
||||||
return telemetryCacheDirPath
|
return telemetryCacheDir
|
||||||
|
|
||||||
getTelemetryCacheDirPath :: Path' Abs (Dir UserCacheDir) -> Path' Abs (Dir TelemetryCacheDir)
|
|
||||||
getTelemetryCacheDirPath userCacheDirPath = userCacheDirPath SP.</> [reldir|wasp/telemetry|]
|
|
||||||
|
54
waspc/cli/src/Wasp/Cli/Command/Uninstall.hs
Normal file
54
waspc/cli/src/Wasp/Cli/Command/Uninstall.hs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
module Wasp.Cli.Command.Uninstall
|
||||||
|
( uninstall,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Control.Monad (when)
|
||||||
|
import Control.Monad.IO.Class (liftIO)
|
||||||
|
import StrongPath (fromAbsDir, fromAbsFile, (</>))
|
||||||
|
import System.Exit (die)
|
||||||
|
import Wasp.Cli.Command (Command)
|
||||||
|
import Wasp.Cli.Command.Message (cliSendMessageC)
|
||||||
|
import Wasp.Cli.FileSystem
|
||||||
|
( getHomeDir,
|
||||||
|
getUserCacheDir,
|
||||||
|
getWaspCacheDir,
|
||||||
|
waspExecutableInHomeDir,
|
||||||
|
waspInstallationDirInHomeDir,
|
||||||
|
)
|
||||||
|
import qualified Wasp.Message as Msg
|
||||||
|
import Wasp.Util.IO (deleteDirectoryIfExists, deleteFileIfExists)
|
||||||
|
|
||||||
|
-- | Removes Wasp from the system.
|
||||||
|
uninstall :: Command ()
|
||||||
|
uninstall = do
|
||||||
|
cliSendMessageC $ Msg.Start "Uninstalling Wasp ..."
|
||||||
|
liftIO removeWaspFiles
|
||||||
|
cliSendMessageC $ Msg.Success "Uninstalled Wasp"
|
||||||
|
|
||||||
|
removeWaspFiles :: IO ()
|
||||||
|
removeWaspFiles = do
|
||||||
|
homeDir <- getHomeDir
|
||||||
|
userCacheDir <- getUserCacheDir
|
||||||
|
|
||||||
|
let waspInstallationDir = homeDir </> waspInstallationDirInHomeDir
|
||||||
|
waspExecutableFile = homeDir </> waspExecutableInHomeDir
|
||||||
|
waspCacheDir = getWaspCacheDir userCacheDir
|
||||||
|
|
||||||
|
putStr $
|
||||||
|
unlines
|
||||||
|
[ "We will remove the following directories:",
|
||||||
|
" " ++ fromAbsDir waspInstallationDir,
|
||||||
|
" " ++ fromAbsDir waspCacheDir,
|
||||||
|
"",
|
||||||
|
"We will also remove the following files:",
|
||||||
|
" " ++ fromAbsFile waspExecutableFile,
|
||||||
|
"",
|
||||||
|
"Are you sure you want to continue? [y/N]"
|
||||||
|
]
|
||||||
|
|
||||||
|
answer <- getLine
|
||||||
|
when (answer /= "y") $ die "Aborted."
|
||||||
|
deleteDirectoryIfExists waspInstallationDir
|
||||||
|
deleteFileIfExists waspExecutableFile
|
||||||
|
deleteDirectoryIfExists waspCacheDir
|
40
waspc/cli/src/Wasp/Cli/FileSystem.hs
Normal file
40
waspc/cli/src/Wasp/Cli/FileSystem.hs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
module Wasp.Cli.FileSystem
|
||||||
|
( getUserCacheDir,
|
||||||
|
getWaspCacheDir,
|
||||||
|
getHomeDir,
|
||||||
|
waspInstallationDirInHomeDir,
|
||||||
|
waspExecutableInHomeDir,
|
||||||
|
UserCacheDir,
|
||||||
|
WaspCacheDir,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
import StrongPath (Abs, Dir, Dir', File', Path', Rel, reldir, relfile, (</>))
|
||||||
|
import qualified StrongPath as SP
|
||||||
|
import System.Directory
|
||||||
|
import qualified System.Directory as SD
|
||||||
|
|
||||||
|
data UserHomeDir
|
||||||
|
|
||||||
|
data UserCacheDir
|
||||||
|
|
||||||
|
data WaspCacheDir
|
||||||
|
|
||||||
|
getHomeDir :: IO (Path' Abs (Dir UserHomeDir))
|
||||||
|
getHomeDir = fromJust . SP.parseAbsDir <$> getHomeDirectory
|
||||||
|
|
||||||
|
getWaspCacheDir :: Path' Abs (Dir UserCacheDir) -> Path' Abs (Dir WaspCacheDir)
|
||||||
|
getWaspCacheDir userCacheDirPath = userCacheDirPath </> [reldir|wasp|]
|
||||||
|
|
||||||
|
getUserCacheDir :: IO (Path' Abs (Dir UserCacheDir))
|
||||||
|
getUserCacheDir = SD.getXdgDirectory SD.XdgCache "" >>= SP.parseAbsDir
|
||||||
|
|
||||||
|
-- NOTE: these paths are based on the installer script and if you change them there
|
||||||
|
-- you need to change them here as well (and vice versa).
|
||||||
|
-- Task to improve this: https://github.com/wasp-lang/wasp/issues/980
|
||||||
|
waspInstallationDirInHomeDir :: Path' (Rel UserHomeDir) Dir'
|
||||||
|
waspInstallationDirInHomeDir = [reldir|.local/share/wasp-lang|]
|
||||||
|
|
||||||
|
waspExecutableInHomeDir :: Path' (Rel UserHomeDir) File'
|
||||||
|
waspExecutableInHomeDir = [relfile|.local/bin/wasp|]
|
@ -3,12 +3,15 @@
|
|||||||
module Wasp.Util.IO
|
module Wasp.Util.IO
|
||||||
( listDirectoryDeep,
|
( listDirectoryDeep,
|
||||||
listDirectory,
|
listDirectory,
|
||||||
|
deleteDirectoryIfExists,
|
||||||
|
deleteFileIfExists,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Control.Monad (filterM)
|
import Control.Monad (filterM, when)
|
||||||
import StrongPath (Abs, Dir, Dir', File, Path', Rel, basename, parseRelDir, parseRelFile, toFilePath, (</>))
|
import StrongPath (Abs, Dir, Dir', File, Path', Rel, basename, parseRelDir, parseRelFile, toFilePath, (</>))
|
||||||
import qualified System.Directory
|
import qualified StrongPath as SP
|
||||||
|
import qualified System.Directory as SD
|
||||||
import qualified System.FilePath as FilePath
|
import qualified System.FilePath as FilePath
|
||||||
import System.IO.Error (isDoesNotExistError)
|
import System.IO.Error (isDoesNotExistError)
|
||||||
import UnliftIO.Exception (catch, throwIO)
|
import UnliftIO.Exception (catch, throwIO)
|
||||||
@ -42,7 +45,7 @@ listDirectoryDeep absDirPath = do
|
|||||||
-- | Lists files and directories at top lvl of the directory.
|
-- | Lists files and directories at top lvl of the directory.
|
||||||
listDirectory :: forall d f. Path' Abs (Dir d) -> IO ([Path' (Rel d) (File f)], [Path' (Rel d) Dir'])
|
listDirectory :: forall d f. Path' Abs (Dir d) -> IO ([Path' (Rel d) (File f)], [Path' (Rel d) Dir'])
|
||||||
listDirectory absDirPath = do
|
listDirectory absDirPath = do
|
||||||
fpRelItemPaths <- System.Directory.listDirectory fpAbsDirPath
|
fpRelItemPaths <- SD.listDirectory fpAbsDirPath
|
||||||
relFilePaths <- filterFiles fpAbsDirPath fpRelItemPaths
|
relFilePaths <- filterFiles fpAbsDirPath fpRelItemPaths
|
||||||
relDirPaths <- filterDirs fpAbsDirPath fpRelItemPaths
|
relDirPaths <- filterDirs fpAbsDirPath fpRelItemPaths
|
||||||
return (relFilePaths, relDirPaths)
|
return (relFilePaths, relDirPaths)
|
||||||
@ -52,10 +55,22 @@ listDirectory absDirPath = do
|
|||||||
|
|
||||||
filterFiles :: FilePath -> [FilePath] -> IO [Path' (Rel d) (File f)]
|
filterFiles :: FilePath -> [FilePath] -> IO [Path' (Rel d) (File f)]
|
||||||
filterFiles absDir relItems =
|
filterFiles absDir relItems =
|
||||||
filterM (System.Directory.doesFileExist . (absDir FilePath.</>)) relItems
|
filterM (SD.doesFileExist . (absDir FilePath.</>)) relItems
|
||||||
>>= mapM parseRelFile
|
>>= mapM parseRelFile
|
||||||
|
|
||||||
filterDirs :: FilePath -> [FilePath] -> IO [Path' (Rel d) Dir']
|
filterDirs :: FilePath -> [FilePath] -> IO [Path' (Rel d) Dir']
|
||||||
filterDirs absDir relItems =
|
filterDirs absDir relItems =
|
||||||
filterM (System.Directory.doesDirectoryExist . (absDir FilePath.</>)) relItems
|
filterM (SD.doesDirectoryExist . (absDir FilePath.</>)) relItems
|
||||||
>>= mapM parseRelDir
|
>>= mapM parseRelDir
|
||||||
|
|
||||||
|
deleteDirectoryIfExists :: Path' r (Dir d) -> IO ()
|
||||||
|
deleteDirectoryIfExists dirPath = do
|
||||||
|
let dirPathStr = SP.toFilePath dirPath
|
||||||
|
exists <- SD.doesDirectoryExist dirPathStr
|
||||||
|
when exists $ SD.removeDirectoryRecursive dirPathStr
|
||||||
|
|
||||||
|
deleteFileIfExists :: Path' r (File f) -> IO ()
|
||||||
|
deleteFileIfExists filePath = do
|
||||||
|
let filePathStr = SP.toFilePath filePath
|
||||||
|
exists <- SD.doesFileExist filePathStr
|
||||||
|
when exists $ SD.removeFile filePathStr
|
||||||
|
@ -332,10 +332,12 @@ library cli-lib
|
|||||||
other-modules: Paths_waspc
|
other-modules: Paths_waspc
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Wasp.Cli.Command
|
Wasp.Cli.Command
|
||||||
|
Wasp.Cli.FileSystem
|
||||||
Wasp.Cli.Command.BashCompletion
|
Wasp.Cli.Command.BashCompletion
|
||||||
Wasp.Cli.Command.Build
|
Wasp.Cli.Command.Build
|
||||||
Wasp.Cli.Command.Call
|
Wasp.Cli.Command.Call
|
||||||
Wasp.Cli.Command.Clean
|
Wasp.Cli.Command.Clean
|
||||||
|
Wasp.Cli.Command.Uninstall
|
||||||
Wasp.Cli.Command.Common
|
Wasp.Cli.Command.Common
|
||||||
Wasp.Cli.Command.Compile
|
Wasp.Cli.Command.Compile
|
||||||
Wasp.Cli.Command.CreateNewProject
|
Wasp.Cli.Command.CreateNewProject
|
||||||
|
@ -18,6 +18,7 @@ COMMANDS
|
|||||||
version Prints current version of CLI.
|
version Prints current version of CLI.
|
||||||
waspls Run Wasp Language Server. Add --help to get more info.
|
waspls Run Wasp Language Server. Add --help to get more info.
|
||||||
completion Prints help on bash completion.
|
completion Prints help on bash completion.
|
||||||
|
uninstall Removes Wasp from your system.
|
||||||
IN PROJECT
|
IN PROJECT
|
||||||
start Runs Wasp app in development mode, watching for file changes.
|
start Runs Wasp app in development mode, watching for file changes.
|
||||||
db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.
|
db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.
|
||||||
@ -52,6 +53,25 @@ Newsletter: https://wasp-lang.dev/#signup
|
|||||||
|
|
||||||
0.2.0.1
|
0.2.0.1
|
||||||
```
|
```
|
||||||
|
- `wasp uninstall` removes Wasp from your system.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ wasp uninstall
|
||||||
|
|
||||||
|
🐝 --- Uninstalling Wasp ... ------------------------------------------------------
|
||||||
|
|
||||||
|
We will remove the following directories:
|
||||||
|
{home}/.local/share/wasp-lang/
|
||||||
|
{home}/.cache/wasp/
|
||||||
|
|
||||||
|
We will also remove the following files:
|
||||||
|
{home}/.local/bin/wasp
|
||||||
|
|
||||||
|
Are you sure you want to continue? [y/N]
|
||||||
|
y
|
||||||
|
|
||||||
|
✅ --- Uninstalled Wasp -----------------------------------------------------------
|
||||||
|
```
|
||||||
|
|
||||||
### Bash Completion
|
### Bash Completion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user