|
1 | 1 | {-# LANGUAGE ScopedTypeVariables #-}
|
2 | | -module UmuReactBasic.Capability.ManageCommand |
| 2 | +module UmuReactBasic.Capability.Command |
3 | 3 | ( ManageCommand (..)
|
4 | 4 | , generateProj
|
5 | 5 | ) where
|
6 | 6 |
|
7 | 7 | import Import
|
8 | 8 | -- Turtle
|
9 | 9 | import qualified Turtle
|
10 | | -import qualified Turtle.Prelude as TP |
| 10 | +import qualified Turtle.Prelude as TP |
11 | 11 | -- Umu
|
12 | | -import UmuReactBasic.Capability.LogMessage |
| 12 | +import UmuReactBasic.Capability.Log |
13 | 13 | import UmuReactBasic.Templates
|
14 | 14 | import UmuReactBasic.Util
|
15 | 15 |
|
@@ -122,116 +122,73 @@ writeTestDir mLoc = do
|
122 | 122 | --- FILE GENERATION
|
123 | 123 | ------------------------------------------
|
124 | 124 | writeIndexHtml :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
125 | | -writeIndexHtml mLoc = do |
126 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
127 | | - if isExists |
128 | | - then logError $ filePath <> " already exists!" |
129 | | - else do |
130 | | - liftIO $ TP.writeTextFile |
131 | | - ( Turtle.fromText $ mkPathName mLoc filePath ) |
132 | | - indexHtmlFile |
133 | | - logInfo $ "Generating " <> filePath <> "..." |
| 125 | +writeIndexHtml mPathInput = do |
| 126 | + isExists <- isFileExists mPathInput filePath |
| 127 | + generateWhenFileNotExists isExists mPathInput filePath indexHtmlFile |
134 | 128 | where
|
135 | 129 | filePath :: Text
|
136 | 130 | filePath = "assets/index.html"
|
137 | 131 |
|
138 | 132 | writeSrcMainFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
139 | | -writeSrcMainFile mLoc = do |
140 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
141 | | - if isExists |
142 | | - then logError $ filePath <> " already exists!" |
143 | | - else do |
144 | | - liftIO $ TP.writeTextFile |
145 | | - ( Turtle.fromText $ mkPathName mLoc filePath ) srcMainFile |
146 | | - logInfo $ "Generating " <> filePath <> "..." |
| 133 | +writeSrcMainFile mPathInput = do |
| 134 | + isExists <- isFileExists mPathInput filePath |
| 135 | + generateWhenFileNotExists isExists mPathInput filePath srcMainFile |
147 | 136 | where
|
148 | 137 | filePath :: Text
|
149 | 138 | filePath = "src/Main.purs"
|
150 | 139 |
|
151 | 140 | writeTitleComponentFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
152 | | -writeTitleComponentFile mLoc = do |
153 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
154 | | - if isExists |
155 | | - then logError $ filePath <> " already exists!" |
156 | | - else do |
157 | | - liftIO $ TP.writeTextFile |
158 | | - ( Turtle.fromText $ mkPathName mLoc filePath ) |
159 | | - titleComponentFile |
160 | | - logInfo $ "Generating " <> filePath <> "..." |
| 141 | +writeTitleComponentFile mPathInput = do |
| 142 | + isExists <- isFileExists mPathInput filePath |
| 143 | + generateWhenFileNotExists isExists mPathInput filePath titleComponentFile |
161 | 144 | where
|
162 | 145 | filePath :: Text
|
163 | 146 | filePath = "src/Component/Title.purs"
|
164 | 147 |
|
165 | 148 | writeSpagoDhallFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
166 | | -writeSpagoDhallFile mLoc = do |
167 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
168 | | - if isExists |
169 | | - then logError $ filePath <> " already exists!" |
170 | | - else do |
171 | | - liftIO $ TP.writeTextFile |
172 | | - ( Turtle.fromText $ mkPathName mLoc filePath ) spagoDhallFile |
173 | | - logInfo $ "Generating " <> filePath <> "..." |
| 149 | +writeSpagoDhallFile mPathInput = do |
| 150 | + isExists <- isFileExists mPathInput filePath |
| 151 | + generateWhenFileNotExists isExists mPathInput filePath spagoDhallFile |
174 | 152 | where
|
175 | 153 | filePath :: Text
|
176 | 154 | filePath = "spago.dhall"
|
177 | 155 |
|
178 | 156 | writePackagesDhallFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
179 | | -writePackagesDhallFile mLoc = do |
180 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
181 | | - if isExists |
182 | | - then logError $ filePath <> " already exists!" |
183 | | - else do |
184 | | - liftIO $ |
185 | | - TP.writeTextFile ( Turtle.fromText $ mkPathName mLoc filePath ) packagesDhallFile |
186 | | - logInfo $ "Generating " <> filePath <> "..." |
| 157 | +writePackagesDhallFile mPathInput = do |
| 158 | + isExists <- isFileExists mPathInput filePath |
| 159 | + generateWhenFileNotExists isExists mPathInput filePath packagesDhallFile |
187 | 160 | where
|
188 | 161 | filePath :: Text
|
189 | 162 | filePath = "packages.dhall"
|
190 | 163 |
|
191 | 164 | writeTestMainFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
192 | | -writeTestMainFile mLoc = do |
193 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
194 | | - if isExists |
195 | | - then logError $ filePath <> " already exists!" |
196 | | - else do |
197 | | - liftIO $ TP.writeTextFile ( Turtle.fromText $ mkPathName mLoc filePath ) testMainFile |
198 | | - logInfo $ "Generating " <> filePath <> "..." |
| 165 | +writeTestMainFile mPathInput = do |
| 166 | + isExists <- isFileExists mPathInput filePath |
| 167 | + generateWhenFileNotExists isExists mPathInput filePath testMainFile |
199 | 168 | where
|
200 | 169 | filePath :: Text
|
201 | 170 | filePath = "test/Main.purs"
|
202 | 171 |
|
203 | 172 | writeMakefile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
204 | | -writeMakefile mLoc = do |
205 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
206 | | - if isExists |
207 | | - then logError $ filePath <> " already exists!" |
208 | | - else do |
209 | | - liftIO $ TP.writeTextFile ( Turtle.fromText $ mkPathName mLoc filePath ) makeFile |
210 | | - logInfo $ "Generating " <> filePath <> "..." |
| 173 | +writeMakefile mPathInput = do |
| 174 | + isExists <- isFileExists mPathInput filePath |
| 175 | + generateWhenFileNotExists isExists mPathInput filePath makeFile |
211 | 176 | where
|
212 | 177 | filePath :: Text
|
213 | 178 | filePath = "Makefile"
|
214 | 179 |
|
215 | 180 | writePackageJsonFile :: ( MonadIO m, LogMessage m ) => Maybe Text -> m ()
|
216 | | -writePackageJsonFile mLoc = do |
217 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
218 | | - if isExists |
219 | | - then logError $ filePath <> " already exists!" |
220 | | - else do |
221 | | - liftIO $ TP.writeTextFile ( Turtle.fromText $ mkPathName mLoc filePath ) packageJsonFile |
222 | | - logInfo $ "Generating " <> filePath <> "..." |
| 181 | +writePackageJsonFile mPathInput = do |
| 182 | + isExists <- isFileExists mPathInput filePath |
| 183 | + generateWhenFileNotExists isExists mPathInput filePath packageJsonFile |
223 | 184 | where
|
224 | 185 | filePath :: Text
|
225 | 186 | filePath = "package.json"
|
226 | 187 |
|
227 | 188 | writeHotRelodingIndexJs :: ( MonadIO m , LogMessage m ) => Maybe Text -> m ()
|
228 | | -writeHotRelodingIndexJs mLoc = do |
229 | | - isExists <- TP.testfile $ Turtle.fromText $ mkPathName mLoc filePath |
230 | | - if isExists |
231 | | - then logError $ filePath <> " already exists!" |
232 | | - else do |
233 | | - liftIO $ TP.writeTextFile ( Turtle.fromText $ mkPathName mLoc filePath ) hotReloadIndexJS |
234 | | - logInfo $ "Generating " <> filePath <> "..." |
| 189 | +writeHotRelodingIndexJs mPathInput = do |
| 190 | + isExists <- isFileExists mPathInput filePath |
| 191 | + generateWhenFileNotExists isExists mPathInput filePath hotReloadIndexJS |
235 | 192 | where
|
236 | 193 | filePath :: Text
|
237 | 194 | filePath = "assets/index.js"
|
0 commit comments