@@ -28,6 +28,7 @@ import NeatInterpolation
2828
2929import Lamdera
3030import Lamdera.Progress
31+ import qualified Lamdera.Init
3132import qualified Ext.Common
3233
3334
@@ -67,7 +68,7 @@ runChecks_ root = do
6768
6869 if initialiseLamderaFiles
6970 then do
70- liftIO $ writeDefaultImplementations
71+ liftIO $ Lamdera.Init. writeDefaultImplementations
7172 -- @TODO future
7273 -- It would be nice if when coming from an existing elm project, we installed the missing
7374 -- deps as well, but the UI impact is a little bit weird as it's not transparent to the user
@@ -103,29 +104,14 @@ runChecks_ root = do
103104 envExists <- liftIO $ doesFileExist " src/Env.elm"
104105
105106 onlyWhen (not envExists) $ do
106- liftIO $ writeUtf8 " src/Env.elm" emptyEnv
107+ liftIO $ writeUtf8 " src/Env.elm" Lamdera.Init. emptyEnv
107108 progressPointer " Created empty Env.elm"
108109
109110
110111progressPointer t =
111112 report $ D. fillSep [ D. fromChars " ───>" , D. dullgreen $ t <> " \n " ]
112113
113114
114- writeDefaultImplementations :: IO ()
115- writeDefaultImplementations = do
116- root <- getProjectRoot " writeDefaultImplementations"
117- defaultImplementations
118- & mapM (\ (filename, implementation) -> do
119- exists <- doesFileExist (root </> filename)
120- if exists
121- then atomicPutStrLn $ " Skipping " <> (root </> filename) <> " , already exists"
122- else writeUtf8 (root </> filename) implementation
123- )
124- writeLineIfMissing " elm-stuff" (root </> " .gitignore" )
125- onlyWhen_ (fmap not $ Dir. doesDirectoryExist (root </> " .git" )) $ do
126- Ext.Common. cq_ " git" [" init" ] " "
127- pure ()
128-
129115
130116checkMissingFiles :: FilePath -> [FilePath ] -> IO [FilePath ]
131117checkMissingFiles root paths = do
@@ -158,183 +144,3 @@ checkMsgHasTypes typeNames = do
158144 results = fmap (\ search -> T. isInfixOf (" type " <> search) source) typeNames
159145
160146 pure $ Prelude. all ((==) True ) results
161-
162-
163-
164- defaultImplementations :: [(FilePath , Text )]
165- defaultImplementations =
166- [ (" src/Frontend.elm" , [text |
167- module Frontend exposing (..)
168-
169- import Browser exposing (UrlRequest(..))
170- import Browser.Navigation as Nav
171- import Html
172- import Html.Attributes as Attr
173- import Lamdera
174- import Types exposing (..)
175- import Url
176-
177-
178- type alias Model =
179- FrontendModel
180-
181-
182- app =
183- Lamdera.frontend
184- { init = init
185- , onUrlRequest = UrlClicked
186- , onUrlChange = UrlChanged
187- , update = update
188- , updateFromBackend = updateFromBackend
189- , subscriptions = \m -> Sub.none
190- , view = view
191- }
192-
193-
194- init : Url.Url -> Nav.Key -> ( Model, Cmd FrontendMsg )
195- init url key =
196- ( { key = key
197- , message = "Welcome to Lamdera! You're looking at the auto-generated base implementation. Check out src/Frontend.elm to start coding!"
198- }
199- , Cmd.none
200- )
201-
202-
203- update : FrontendMsg -> Model -> ( Model, Cmd FrontendMsg )
204- update msg model =
205- case msg of
206- UrlClicked urlRequest ->
207- case urlRequest of
208- Internal url ->
209- ( model
210- , Nav.pushUrl model.key (Url.toString url)
211- )
212-
213- External url ->
214- ( model
215- , Nav.load url
216- )
217-
218- UrlChanged url ->
219- ( model, Cmd.none )
220-
221- NoOpFrontendMsg ->
222- ( model, Cmd.none )
223-
224-
225- updateFromBackend : ToFrontend -> Model -> ( Model, Cmd FrontendMsg )
226- updateFromBackend msg model =
227- case msg of
228- NoOpToFrontend ->
229- ( model, Cmd.none )
230-
231-
232- view : Model -> Browser.Document FrontendMsg
233- view model =
234- { title = ""
235- , body =
236- [ Html.div [ Attr.style "text-align" "center", Attr.style "padding-top" "40px" ]
237- [ Html.img [ Attr.src "https://lamdera.app/lamdera-logo-black.png", Attr.width 150 ] []
238- , Html.div
239- [ Attr.style "font-family" "sans-serif"
240- , Attr.style "padding-top" "40px"
241- ]
242- [ Html.text model.message ]
243- ]
244- ]
245- }
246- |])
247- , (" src/Backend.elm" , [text |
248- module Backend exposing (..)
249-
250- import Html
251- import Lamdera exposing (ClientId, SessionId)
252- import Types exposing (..)
253-
254-
255- type alias Model =
256- BackendModel
257-
258-
259- app =
260- Lamdera.backend
261- { init = init
262- , update = update
263- , updateFromFrontend = updateFromFrontend
264- , subscriptions = \m -> Sub.none
265- }
266-
267-
268- init : ( Model, Cmd BackendMsg )
269- init =
270- ( { message = "Hello!" }
271- , Cmd.none
272- )
273-
274-
275- update : BackendMsg -> Model -> ( Model, Cmd BackendMsg )
276- update msg model =
277- case msg of
278- NoOpBackendMsg ->
279- ( model, Cmd.none )
280-
281-
282- updateFromFrontend : SessionId -> ClientId -> ToBackend -> Model -> ( Model, Cmd BackendMsg )
283- updateFromFrontend sessionId clientId msg model =
284- case msg of
285- NoOpToBackend ->
286- ( model, Cmd.none )
287-
288- |])
289- , (" src/Types.elm" , [text |
290- module Types exposing (..)
291-
292- import Browser exposing (UrlRequest)
293- import Browser.Navigation exposing (Key)
294- import Url exposing (Url)
295-
296-
297- type alias FrontendModel =
298- { key : Key
299- , message : String
300- }
301-
302-
303- type alias BackendModel =
304- { message : String
305- }
306-
307-
308- type FrontendMsg
309- = UrlClicked UrlRequest
310- | UrlChanged Url
311- | NoOpFrontendMsg
312-
313-
314- type ToBackend
315- = NoOpToBackend
316-
317-
318- type BackendMsg
319- = NoOpBackendMsg
320-
321-
322- type ToFrontend
323- = NoOpToFrontend
324-
325- |])
326- , (" src/Env.elm" , emptyEnv)
327- ]
328-
329-
330- emptyEnv =
331- [text |
332- module Env exposing (..)
333-
334- -- The Env.elm file is for per-environment configuration.
335- -- See https://dashboard.lamdera.app/docs/environment for more info.
336-
337-
338- dummyConfigItem =
339- ""
340- |]
0 commit comments