bin: switch scripts to "stack ghc" and "env -S" (#1453)
Using stack's script command meant that the scripts needed to be
compatible, and regularly tested, with a hledger release in stackage,
rather than the latest hledger source. This created hassles for
maintainers, contributors and sometimes for users.
To simplify things overall, we now require script users to check out
the hledger source tree and run the scripts (or, bin/compile.sh) from
there once so they compile themselves. Some notes on alternative
setups are included (in one of the scripts, and referenced by the
others). This ensures that users and our CI tests are building scripts
the same way.
Current stack does not allow a stack options line to be used with the
"stack ghc" command, unfortunately, so instead we are using env's -S
flag, which hopefully has sufficiently wide support by now, and
putting all arguments in the shebang line.
This method will probably require complete explicit --package options,
unlike "stack script", so more testing and tweaking is expected.
Probably we're going to end up with some long shebang lines.
This isn't pretty but seems like a possible way to keep things
manageable.
2021-01-12 04:42:13 +03:00
|
|
|
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
|
|
|
|
-- See hledger-check-fancyassertions.hs
|
2020-08-15 19:59:59 +03:00
|
|
|
|
2020-03-28 03:21:23 +03:00
|
|
|
{-
|
2020-11-27 23:29:39 +03:00
|
|
|
hledger-check-tagfiles stack script.
|
2020-03-28 03:21:23 +03:00
|
|
|
Read the default journal and give an error if any tag values
|
|
|
|
containing '/' do not exist as file paths.
|
|
|
|
Usage:
|
2020-03-28 02:43:14 +03:00
|
|
|
|
2020-11-27 23:29:39 +03:00
|
|
|
$ hledger-check-tagfiles.hs # compiles if needed
|
2020-03-28 03:21:23 +03:00
|
|
|
|
|
|
|
or:
|
|
|
|
|
2020-11-27 23:29:39 +03:00
|
|
|
$ hledger check-tagfiles # compiles if there's no compiled version
|
2020-03-28 03:21:23 +03:00
|
|
|
-}
|
2020-03-28 02:43:14 +03:00
|
|
|
|
|
|
|
import Control.Monad
|
|
|
|
import qualified Data.Text as T
|
|
|
|
import Hledger.Cli
|
|
|
|
import System.Directory
|
|
|
|
import System.Exit
|
|
|
|
|
|
|
|
main = withJournalDo defcliopts $ \j -> do
|
|
|
|
let filetags = [ (t,v)
|
|
|
|
| (t',v') <- concatMap transactionAllTags $ jtxns j
|
|
|
|
, let t = T.unpack t'
|
|
|
|
, let v = T.unpack v'
|
|
|
|
, '/' `elem` v
|
|
|
|
]
|
|
|
|
forM_ filetags $ \(t,f) -> do
|
|
|
|
exists <- doesFileExist f
|
|
|
|
when (not exists) $ do
|
|
|
|
putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f
|
|
|
|
exitFailure
|