Skip to content

Commit 3159b5a

Browse files
committed
Guide user when trying to use check on non-main branch
1 parent 95de174 commit 3159b5a

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

extra/Lamdera/CLI/Check.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ run :: () -> Lamdera.CLI.Check.Flags -> IO ()
6868
run () flags@(Lamdera.CLI.Check.Flags destructiveMigration) = do
6969
debug_ "Starting check..."
7070

71+
branch <- Lamdera.getGitBranch
72+
case branch of
73+
"main" -> runHelp () flags
74+
"master" -> runHelp () flags
75+
_ -> do
76+
atomicPutStrLn "`lamdera check` is only for main/master branches when preparing for a production deploy."
77+
atomicPutStrLn "If you're trying to deploy a preview app, use `lamdera deploy` instead."
78+
pure ()
79+
80+
81+
runHelp :: () -> Lamdera.CLI.Check.Flags -> IO ()
82+
runHelp () flags@(Lamdera.CLI.Check.Flags destructiveMigration) = do
7183
Lamdera.setCheckMode True
7284

7385
-- appNameEnvM <- Env.lookupEnv "LAMDERA_APP_NAME"

test/Test.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ For more information on how to use the GHCi debugger, see the GHC User's Guide.
9898
-- Current target for ghci :rr command. See ~/.ghci config file, which should contain
9999
-- something like `:def rr const $ return $ unlines [":r","Test.target"]`
100100

101-
target = Test.all
101+
-- target = Test.all
102102
-- target = checkProject
103103

104104

@@ -122,8 +122,8 @@ previewProject = do
122122
Dir.withCurrentDirectory p $ Lamdera.CLI.Deploy.run () ()
123123

124124

125-
-- target =
126-
-- Test.Check.checkWithParams "/Users/mario/lamdera/test/v1" "always-v0"
125+
target =
126+
Test.Check.checkWithParams "/Users/mario/dev/projects/lamdera-dashboard"
127127
-- Test.Check.checkWithParams "/Users/mario/lamdera/test/sheep-game" "sheep-game"
128128

129129
-- target = buildTestHarnessToProductionJs

test/Test/Check.hs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ suite = tests $
4747
] $ do
4848

4949
scope "lamdera check should succeed, ignoring the Debug.log usages" $ do
50-
actual <- catchOutput $ checkWithParams project "always-v0"
50+
actual <- catchOutput $ checkWithParamsProduction project "always-v0"
5151
expectTextContains actual
5252
"It appears you're all set to deploy the first version of 'always-v0'!"
5353

@@ -64,7 +64,7 @@ suite = tests $
6464
io $ Ext.Common.bash $ "cd " <> project <> " && git init"
6565
io $ Ext.Common.bash $ "cd " <> project <> " && git remote add lamdera git@apps.lamdera.com:always-v0.git"
6666

67-
_ <- io $ checkWithParams project "always-v0"
67+
_ <- io $ checkWithParamsProduction project "always-v0"
6868

6969
"elm-stuff/lamdera/.lamdera-fe-config" & expectContains "frontendOnly"
7070
"elm-stuff/lamdera/.lamdera-be-config" & expectContains "backendOnly"
@@ -115,15 +115,15 @@ expectFileContains needle file =
115115
check = do
116116
-- touch "/Users/mario/lamdera/test/v1/src/WireTypes.elm"
117117
-- touch "/Users/mario/lamdera/test/v1/src/Env.elm"
118-
-- checkWithParams "/Users/mario/lamdera/test/v1" "always-v0"
119-
-- checkWithParams "/Users/mario/dev/test/ascii-art" "ascii-art-local"
120-
-- checkWithParams "/Users/mario/dev/test/lamdera-minilatex-app" "minilatex"
121-
-- checkWithParams "/Users/mario/dev/lamdera-user-projects/beat-the-big-two" "beat-the-big-two"
122-
-- checkWithParams "/Users/mario/dev/projects/lamdera-dashboard" "dashboard"
123-
-- checkWithParams "/Users/mario/dev/projects/lamdera-test" "testapp"
124-
-- checkWithParams "/Users/mario/lamdera/tmp/elm-audio-test0" "elm-audio-test0"
125-
-- checkWithParams "/Users/mario/lamdera-builds/build-test-local/staging" "test-local"
126-
checkWithParams "/Users/mario/dev/projects/bento-life" "life"
118+
-- checkWithParamsProduction "/Users/mario/lamdera/test/v1" "always-v0"
119+
-- checkWithParamsProduction "/Users/mario/dev/test/ascii-art" "ascii-art-local"
120+
-- checkWithParamsProduction "/Users/mario/dev/test/lamdera-minilatex-app" "minilatex"
121+
-- checkWithParamsProduction "/Users/mario/dev/lamdera-user-projects/beat-the-big-two" "beat-the-big-two"
122+
-- checkWithParamsProduction "/Users/mario/dev/projects/lamdera-dashboard" "dashboard"
123+
-- checkWithParamsProduction "/Users/mario/dev/projects/lamdera-test" "testapp"
124+
-- checkWithParamsProduction "/Users/mario/lamdera/tmp/elm-audio-test0" "elm-audio-test0"
125+
-- checkWithParamsProduction "/Users/mario/lamdera-builds/build-test-local/staging" "test-local"
126+
checkWithParamsProduction "/Users/mario/dev/projects/bento-life" "life"
127127

128128

129129
mockBuildSh projectPath appName = do
@@ -181,16 +181,26 @@ installElmHttpForRPC projectPath = do
181181

182182

183183
{-| Run the `lamdera check` pipeline with specific params -}
184-
checkWithParams projectPath appName = do
185-
setEnv "LAMDERA_APP_NAME" appName
184+
checkWithParams projectPath = do
186185
setEnv "LOVR" "/Users/mario/dev/projects/lamdera/overrides"
187186
setEnv "LDEBUG" "1"
188187
setEnv "ELM_HOME" "/Users/mario/elm-home-elmx-test"
188+
189+
Ext.Common.withProjectRoot projectPath $ Lamdera.CLI.Check.run_
190+
191+
unsetEnv "LOVR"
192+
unsetEnv "LDEBUG"
193+
unsetEnv "ELM_HOME"
194+
195+
196+
{-| Run the `lamdera check` pipeline as if it were run in production to invoke prod behaviour -}
197+
checkWithParamsProduction projectPath appName = do
198+
setEnv "LAMDERA_APP_NAME" appName
189199
-- setEnv "NOTPROD" "1"
190-
requireEnv "TOKEN"
191200
-- setEnv "HOIST_REBUILD" "1"
192201
-- setEnv "VERSION" "1"
193202

203+
requireEnv "TOKEN"
194204
cp "/Users/mario/lamdera/runtime/src/LBR.elm" (projectPath ++ "/src/LBR.elm")
195205
cp "/Users/mario/lamdera/runtime/src/LFR.elm" (projectPath ++ "/src/LFR.elm")
196206
cp "/Users/mario/lamdera/runtime/src/LamderaRPC.elm" (projectPath ++ "/src/LamderaRPC.elm")
@@ -200,17 +210,12 @@ checkWithParams projectPath appName = do
200210
cp "/Users/mario/lamdera/runtime/src/RPC_Empty.elm" (projectPath ++ "/src/RPC.elm")
201211
cp "/Users/mario/lamdera/runtime/src/LamderaHelpers.elm" (projectPath ++ "/src/LamderaHelpers.elm")
202212

203-
Ext.Common.withProjectRoot projectPath $ Lamdera.CLI.Check.run_
204-
213+
checkWithParams projectPath
205214
unsetEnv "LAMDERA_APP_NAME"
206-
unsetEnv "LOVR"
207-
unsetEnv "LDEBUG"
208-
unsetEnv "ELM_HOME"
209215
unsetEnv "NOTPROD"
210216
unsetEnv "VERSION"
211217

212218

213-
214219
{-| Run the `lamdera check` pipeline with specific params -}
215220
checkWithParamsNoDebug version projectPath appName = do
216221
unsetEnv "LDEBUG"

0 commit comments

Comments
 (0)