Skip to content

Commit 2be7e74

Browse files
committed
Add lamdera check --force support for intentional migration generation outside main/master to support alternative dev workflows
1 parent d140776 commit 2be7e74

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

extra/Lamdera/CLI.hs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ check =
8686
checkFlags =
8787
flags Lamdera.CLI.Check.Flags
8888
|-- onOff "destructive-migration" "Generate a migration that will drop all production data when deployed, instead of the usual automatic migration generation."
89+
|-- onOff "force" "Force a production check for Evergreen, even if we're on a non main/master branch (i.e. a preview). You shouldn't be using this unless you know what you're doing."
8990
in
9091
Terminal.Command "check" (Common summary) details example noArgs checkFlags Lamdera.CLI.Check.run
9192

extra/Lamdera/CLI/Check.hs

+14-10
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ import qualified Lamdera.Evergreen.Snapshot
5757
data Flags =
5858
Flags
5959
{ _destructiveMigration :: Bool
60+
, _force :: Bool
6061
}
6162

6263

6364
run_ :: IO ()
64-
run_ = run () (Lamdera.CLI.Check.Flags { _destructiveMigration = False })
65+
run_ = run () (Lamdera.CLI.Check.Flags { _destructiveMigration = False, _force = False })
6566

6667

6768
run :: () -> Lamdera.CLI.Check.Flags -> IO ()
68-
run () flags@(Lamdera.CLI.Check.Flags destructiveMigration) = do
69+
run () flags@(Lamdera.CLI.Check.Flags destructiveMigration force) = do
6970
debug_ "Starting check..."
7071

7172
inProduction_ <- Lamdera.inProduction
@@ -78,17 +79,20 @@ run () flags@(Lamdera.CLI.Check.Flags destructiveMigration) = do
7879
runHelp () flags
7980
else do
8081
branch <- Lamdera.getGitBranch
81-
case branch of
82-
"main" -> runHelp () flags
83-
"master" -> runHelp () flags
84-
_ -> do
85-
atomicPutStrLn "`lamdera check` is only for main/master branches when preparing for a production deploy."
86-
atomicPutStrLn "If you're trying to deploy a preview app, use `lamdera deploy` instead."
87-
pure ()
82+
if force
83+
then runHelp () flags
84+
else
85+
case branch of
86+
"main" -> runHelp () flags
87+
"master" -> runHelp () flags
88+
_ -> do
89+
atomicPutStrLn "`lamdera check` is only for main/master branches when preparing for a production deploy."
90+
atomicPutStrLn "If you're trying to deploy a preview app, use `lamdera deploy` instead."
91+
pure ()
8892

8993

9094
runHelp :: () -> Lamdera.CLI.Check.Flags -> IO ()
91-
runHelp () flags@(Lamdera.CLI.Check.Flags destructiveMigration) = do
95+
runHelp () flags@(Lamdera.CLI.Check.Flags destructiveMigration force) = do
9296
Lamdera.setCheckMode True
9397

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

0 commit comments

Comments
 (0)