tailwind 0.1.0.0 → 0.2.0.0
raw patch · 5 files changed
+31/−6 lines, 5 files
Files
- CHANGELOG.md +7/−0
- README.md +1/−1
- exe/Main.hs +3/−0
- src/Web/Tailwind.hs +18/−2
- tailwind.cabal +2/−3
CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for tailwind (Haskell) +## 0.2.0.0 -- 2022-02-03++- Add `--output`+- Fix quoted source paths breaking tailwind.config.js syntax+- Workaround Tailwind not crashing with non-zero exitcode+- [Nix] Switch to nixpkgs' tailwindcss.+ ## 0.1.0.0 -- 2022-01-08 * First version.
README.md view
@@ -3,7 +3,7 @@ Run TailwindCSS CLI [without needing](https://www.srid.ca/nojs) to touch anything JavaScript. No `input.css` or `tailwind.config.js` necessary. ```-cabal run tailwind-run -- 'src/**/.hs'+nix run github:srid/tailwind-haskell -- 'src/**/.hs' -o output.css ``` Compiles CSS classes in those file paths or patterns, and writes `./tailwind.css`. Pass `-w` to run in JIT watcher mode.
exe/Main.hs view
@@ -15,6 +15,7 @@ data Cli = Cli { content :: NonEmpty FilePattern,+ output :: FilePath, mode :: Mode } deriving (Eq, Show)@@ -22,6 +23,7 @@ cliParser :: Parser Cli cliParser = do content <- NE.some (argument str (metavar "SOURCES..."))+ output <- strOption (long "output" <> short 'o' <> metavar "OUTPUT" <> value "tailwind.css") mode <- modeParser pure Cli {..} @@ -38,6 +40,7 @@ runTailwind $ def & tailwindConfig . tailwindConfigContent .~ toList (content cli)+ & tailwindOutput .~ output cli & tailwindMode .~ mode cli where opts =
src/Web/Tailwind.hs view
@@ -108,7 +108,7 @@ [text| module.exports = Object.assign(- JSON.parse('${config}'),+ ${config}, { theme: { extend: {},@@ -134,7 +134,8 @@ runTailwind Tailwind {..} = do withTmpFile (show _tailwindConfig) $ \configFile -> withTmpFile (unCss _tailwindInput) $ \inputFile ->- callTailwind $ ["-c", configFile, "-i", inputFile, "-o", _tailwindOutput] <> modeArgs _tailwindMode+ let f = bool id (failIfFileNotCreated _tailwindOutput) (_tailwindMode == Production)+ in f $ callTailwind $ ["-c", configFile, "-i", inputFile, "-o", _tailwindOutput] <> modeArgs _tailwindMode when (_tailwindMode == JIT) $ error "Tailwind exited unexpectedly!" @@ -147,6 +148,21 @@ hPut h (encodeUtf8 s) >> hClose h f fp `finally` removeFile fp++-- Workaround for https://github.com/srid/emanote/issues/232+--+-- If the given IO action doesnot create this file (we remove the file before+-- running the IO action), then fail with `error`.+failIfFileNotCreated :: (MonadUnliftIO m, HasCallStack) => FilePath -> m a -> m a+failIfFileNotCreated fp m = do+ liftIO (doesFileExist fp) >>= \case+ True -> removeFile fp+ _ -> pure ()+ x <- m+ exists <- liftIO $ doesFileExist fp+ if exists+ then pure x+ else error $ "File not created: " <> toText fp callTailwind :: (MonadIO m, MonadLogger m) => [String] -> m () callTailwind args = do
tailwind.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: tailwind-version: 0.1.0.0+version: 0.2.0.0 license: MIT copyright: 2022 Sridhar Ratnakumar maintainer: srid@srid.ca@@ -15,8 +15,7 @@ description: Run Tailwind from Haskell without touching JavaScript -- A URL where users can report bugs.--- bug-reports:-+bug-reports: https://github.com/srid/tailwind-haskell extra-source-files: CHANGELOG.md LICENSE