elm-init 1.0.2 → 1.0.3
raw patch · 3 files changed
+46/−42 lines, 3 files
Files
- elm-init.cabal +1/−1
- src/ElmInit/Types.hs +2/−2
- src/Main.hs +43/−39
elm-init.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: elm-init-version: 1.0.2+version: 1.0.3 synopsis: Set up basic structure for an elm project description: Initialize a new empty elm project with some basic scaffolding according to 'https://github.com/evancz/elm-architecture-tutorial'.
src/ElmInit/Types.hs view
@@ -87,7 +87,7 @@ emptyDecisions = Default { summary = "" , repository = ""- , version = makeVersion [0, 0, 0]+ , version = makeVersion [1, 0, 0] , license = "" , sourceFolder = "" , projectName = ""@@ -103,7 +103,7 @@ ⊛ summary ⊛ repository ⊛ license- ⊛ const (object [("elm-lang/core", "2.0.0 <= v < 3.0.0")])+ ⊛ const (object [("elm-lang/core", "3.0.0 <= v < 4.0.0")]) ⊛ const [] ⊛ elmVersion ⊛ (:[]) . pack . sourceFolder
src/Main.hs view
@@ -35,7 +35,7 @@ withCurrentDirectory) import System.Environment (getArgs) import System.FilePath (isValid, takeBaseName,- takeExtension, (</>))+ takeExtension, (</>), takeDirectory) import System.IO (IOMode (WriteMode), withFile) import System.Process (callProcess) import Text.Printf (printf)@@ -118,44 +118,48 @@ getUserDecisions ∷ FilePath → IO UserDecisions-getUserDecisions wd = Default- <$> askChoicesWithOther- "project name?"- 0- return- [pack $ takeBaseName wd]- ⊛ askChoicesWithOther- "choose a source folder name"- 0- ((bool (Left "The filepath must be valid") <$> return ⊛ isValid) ∘ unpack) -- filepath path verifier- (map pack standardSourceFolders)- ⊛ askChoicesWithOther- "initial project version?"- 0- (verifyElmVersion ∘ unpack)- [pack $ showVersion defaultProjectVersion]- ⊛ (TextIO.putStrLn "a quick summary" ≫ TextIO.getLine)- ⊛ (TextIO.putStrLn "project repository url" ≫ TextIO.getLine)- ⊛ askChoicesWithOther- "choose a license"- 0- return- availableLicenses- ⊛ askChoicesWithOther- "select the elm-version"- 0- return- [defaultElmVersion]- ⊛ askChoicesWithOther- "What sould be the Main file?"- 0- (isValidMainFile . unpack)- ["Main.elm"]- ⊛ ((≡ "Yes") <$> askChoices- "Should I create an index.html file?"- 0- ["Yes", "No"]- )+getUserDecisions wd = do+ dir <- makeAbsolute wd+ let basename = takeBaseName dir+ dirname = if null basename then takeBaseName $ takeDirectory dir else basename+ Default+ <$> askChoicesWithOther+ "project name?"+ 0+ return+ [pack dirname]+ ⊛ askChoicesWithOther+ "choose a source folder name"+ 0+ ((bool (Left "The filepath must be valid") <$> return ⊛ isValid) ∘ unpack) -- filepath path verifier+ (map pack standardSourceFolders)+ ⊛ askChoicesWithOther+ "initial project version?"+ 0+ (verifyElmVersion ∘ unpack)+ [pack $ showVersion defaultProjectVersion]+ ⊛ (TextIO.putStrLn "a quick summary" ≫ TextIO.getLine)+ ⊛ (TextIO.putStrLn "project repository url" ≫ TextIO.getLine)+ ⊛ askChoicesWithOther+ "choose a license"+ 0+ return+ availableLicenses+ ⊛ askChoicesWithOther+ "select the elm-version"+ 0+ return+ [defaultElmVersion]+ ⊛ askChoicesWithOther+ "What sould be the Main file?"+ 0+ (isValidMainFile . unpack)+ ["Main.elm"]+ ⊛ ((≡ "Yes") <$> askChoices+ "Should I create an index.html file?"+ 0+ ["Yes", "No"]+ ) isValidMainFile ∷ String → Either Text String