Skip to content

Commit

Permalink
ask before updating PAL
Browse files Browse the repository at this point in the history
  • Loading branch information
CSchank committed May 6, 2019
1 parent 61b3fe7 commit 41c4430
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ _Static files will be rebuilt if there are changes, so don't edit them as you wi
#Updating your version of PAL
1. Ensure that you have run `stack build` for your project.
2. Run `stack exec pal-update`
3. The newest version of PAL will be installed.
4. Rebuild your project using `stack build` to use the newest version of PAL.
3. If an update is available, type y/Y to install the update.
4. The newest version of PAL and the templates will be installed.
5. Rebuild your project using `stack build` to use the newest version of PAL.

## Compiling Net Graphs
When you generate your code, you will be given the code to generate codegraphs with `dot`. Either run them through dot, or use the
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: petri-app-land
version: 0.1.3.0
version: 0.1.4.0
github: "cschank/petri-app-land"
license: BSD3
author: "Christopher William Schankula"
Expand Down
32 changes: 19 additions & 13 deletions src/Git.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,25 @@ updatePAL = do
if currentVersion == rel then do
putStrLn $ "PAL is already on the latest version (" ++ rel ++ ")"
else do
putStrLn $ "You are using an older version of PAL (" ++ currentVersion ++ "). Updating to version " ++ rel ++ "..."
stackYaml <- T.lines <$> TIO.readFile "stack.yaml"
case "#PALCOMMIT" `elemIndex` stackYaml of
Just line -> do
let newYaml = replaceNth (line+1) (T.concat[" commit: ",T.pack rel]) stackYaml
TIO.writeFile "stack.yaml" $ T.unlines newYaml
putStrLn $ "stack.yaml file updated to reflect new version of PAL"
TIO.writeFile ".palversion" $ T.pack rel
loadTemplates rel -- download the PAL templates for this version
putStrLn $ "Update complete. Version is now " ++ rel ++ "."
putStrLn "Run `stack build` again to rebuild your project with the newest version of PAL."
Nothing ->
return ()
putStrLn $ "You are using an older version of PAL (" ++ currentVersion ++ ")."
putStrLn $ "The newest version is " ++ rel ++ "."
putStrLn $ "See changelog at https://github.com/CSchank/petri-app-land/releases/tag/" ++ rel ++ "."
putStrLn $ "Update to version " ++ rel ++ "? (Y/N)"
resp <- getLine
if resp == "y" || resp == "Y" then do
stackYaml <- T.lines <$> TIO.readFile "stack.yaml"
case "#PALCOMMIT" `elemIndex` stackYaml of
Just line -> do
let newYaml = replaceNth (line+1) (T.concat[" commit: ",T.pack rel]) stackYaml
TIO.writeFile "stack.yaml" $ T.unlines newYaml
putStrLn $ "stack.yaml file updated to reflect new version of PAL"
TIO.writeFile ".palversion" $ T.pack rel
loadTemplates rel -- download the PAL templates for this version
putStrLn $ "Update complete. Version is now " ++ rel ++ "."
putStrLn "Run `stack build` again to rebuild your project with the newest version of PAL."
Nothing ->
return ()
else putStrLn "Update aborted. Run `stack exec pal-update` again to update."
Nothing -> do
setSGR [SetColor Foreground Vivid Red]
putStrLn "Error: Could not decode latest release from GitHub. You may have exceeded the API limit."
Expand Down

0 comments on commit 41c4430

Please sign in to comment.