chore: use standard-version directly instead of sync-version.hs
This commit is contained in:
parent
a0ff498fc9
commit
14166933c5
18
.versionrc.js
Normal file
18
.versionrc.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const standardVersionUpdaterYaml = require.resolve('standard-version-updater-yaml');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
scripts: {
|
||||||
|
// postbump: './sync-versions.hs && git add -- package.yaml', // moved to bumpFiles
|
||||||
|
postchangelog: 'sed \'s/^### \\[/## [/g\' -i CHANGELOG.md'
|
||||||
|
},
|
||||||
|
bumpFiles: [
|
||||||
|
{
|
||||||
|
filename: 'package.yaml',
|
||||||
|
updater: standardVersionUpdaterYaml
|
||||||
|
}
|
||||||
|
],
|
||||||
|
commitUrlFormat: 'https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/commit/{{hash}}',
|
||||||
|
compareUrlFormat: 'https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/{{previousTag}}...{{currentTag}}',
|
||||||
|
issueUrlFormat: 'https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/issues/{{id}}',
|
||||||
|
userUrlFormat: 'https://gitlab2.rz.ifi.lmu.de/{{user}}'
|
||||||
|
};
|
||||||
9
package-lock.json
generated
9
package-lock.json
generated
@ -19531,6 +19531,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"standard-version-updater-yaml": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/standard-version-updater-yaml/-/standard-version-updater-yaml-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-hTaNAnsQ7HznYbt489qVPYs4lvZ5q6pVwZJ7kmPMhYmvNzq7hZnQoImTYvEB9hgkx/moBJkqF38Dp82xy+dqvw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"yaml": "^1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"static-extend": {
|
"static-extend": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
|
||||||
|
|||||||
11
package.json
11
package.json
@ -41,16 +41,6 @@
|
|||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"standard-version": {
|
|
||||||
"scripts": {
|
|
||||||
"postbump": "./sync-versions.hs && git add -- package.yaml",
|
|
||||||
"postchangelog": "sed 's/^### \\[/## [/g' -i CHANGELOG.md"
|
|
||||||
},
|
|
||||||
"commitUrlFormat": "https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/commit/{{hash}}",
|
|
||||||
"compareUrlFormat": "https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/{{previousTag}}...{{currentTag}}",
|
|
||||||
"issueUrlFormat": "https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/issues/{{id}}",
|
|
||||||
"userUrlFormat": "https://gitlab2.rz.ifi.lmu.de/{{user}}"
|
|
||||||
},
|
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"defaults"
|
"defaults"
|
||||||
],
|
],
|
||||||
@ -108,6 +98,7 @@
|
|||||||
"sass-loader": "^7.3.1",
|
"sass-loader": "^7.3.1",
|
||||||
"semver": "^6.3.0",
|
"semver": "^6.3.0",
|
||||||
"standard-version": "^9.1.0",
|
"standard-version": "^9.1.0",
|
||||||
|
"standard-version-updater-yaml": "^1.0.2",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"terser-webpack-plugin": "^2.3.8",
|
"terser-webpack-plugin": "^2.3.8",
|
||||||
"tmp": "^0.1.0",
|
"tmp": "^0.1.0",
|
||||||
|
|||||||
@ -1,81 +0,0 @@
|
|||||||
#!/usr/bin/env stack
|
|
||||||
-- stack runghc --package libyaml --package aeson --package unordered-containers --package text
|
|
||||||
|
|
||||||
{-# LANGUAGE OverloadedStrings
|
|
||||||
, LambdaCase
|
|
||||||
, PackageImports
|
|
||||||
, NamedFieldPuns
|
|
||||||
, RecordWildCards
|
|
||||||
#-}
|
|
||||||
|
|
||||||
import "libyaml" Text.Libyaml
|
|
||||||
import Control.Monad.Trans.Resource
|
|
||||||
import Data.Conduit
|
|
||||||
import qualified Data.Conduit.List as C
|
|
||||||
|
|
||||||
import qualified Data.Aeson as JSON
|
|
||||||
|
|
||||||
import qualified Data.ByteString as BS
|
|
||||||
import qualified Data.ByteString.Char8 as CBS
|
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
|
||||||
|
|
||||||
import qualified Data.HashMap.Lazy as HashMap
|
|
||||||
|
|
||||||
import Data.Text (Text)
|
|
||||||
import qualified Data.Text as Text
|
|
||||||
import qualified Data.Text.IO as Text
|
|
||||||
import qualified Data.Text.Encoding as Text
|
|
||||||
|
|
||||||
import Text.Printf
|
|
||||||
import System.IO (stderr)
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = do
|
|
||||||
Just packageJSON <- JSON.decode <$> LBS.readFile "package.json"
|
|
||||||
let
|
|
||||||
newVersion :: Text
|
|
||||||
Just (JSON.String newVersion) = HashMap.lookup ("version" :: Text) packageJSON
|
|
||||||
|
|
||||||
updatePackageYaml newVersion
|
|
||||||
|
|
||||||
|
|
||||||
updatePackageYaml :: Text -> IO ()
|
|
||||||
updatePackageYaml newVersion = do
|
|
||||||
(oldVersion, start, end) <- runResourceT . runConduit . (.|) (decodeFileMarked "package.yaml") $ do
|
|
||||||
awaitUntil $ \case
|
|
||||||
MarkedEvent{ yamlEvent = EventMappingStart _ _ _ } -> True
|
|
||||||
_ -> False
|
|
||||||
awaitUntil $ \case
|
|
||||||
MarkedEvent{ yamlEvent = EventScalar s _ _ _ }
|
|
||||||
| s == "version" -> True
|
|
||||||
_ -> False
|
|
||||||
_ <- await -- Throw away "version: "
|
|
||||||
Just MarkedEvent{ yamlEvent = EventScalar oldVersion' _ _ _, .. } <- await
|
|
||||||
let oldVersion = Text.decodeUtf8 oldVersion'
|
|
||||||
return (oldVersion, yamlStartMark, yamlEndMark)
|
|
||||||
|
|
||||||
encNewVersion <- runResourceT . runConduit . (.| encode) $ C.sourceList
|
|
||||||
[ EventStreamStart
|
|
||||||
, EventDocumentStart
|
|
||||||
, EventScalar (Text.encodeUtf8 newVersion) NoTag Any Nothing
|
|
||||||
, EventDocumentEnd
|
|
||||||
, EventStreamEnd
|
|
||||||
]
|
|
||||||
|
|
||||||
hPrintf stderr "package.yaml: %s -> %s\n" oldVersion newVersion
|
|
||||||
|
|
||||||
packageYaml <- BS.readFile "package.yaml"
|
|
||||||
BS.writeFile "package.yaml" . mconcat $
|
|
||||||
[ BS.take (fromIntegral $ yamlIndex start) packageYaml
|
|
||||||
, Text.encodeUtf8 . Text.strip $ Text.decodeUtf8 encNewVersion
|
|
||||||
, BS.drop (fromIntegral $ yamlIndex end) packageYaml
|
|
||||||
]
|
|
||||||
where
|
|
||||||
awaitUntil :: Monad m => (i -> Bool) -> ConduitM i o m ()
|
|
||||||
awaitUntil pred = do
|
|
||||||
nextIn <- await
|
|
||||||
case nextIn of
|
|
||||||
Nothing -> error "Ran out of input in awaitUntil"
|
|
||||||
Just inp
|
|
||||||
| pred inp -> leftover inp
|
|
||||||
Just _ -> awaitUntil pred
|
|
||||||
Reference in New Issue
Block a user