File tree Expand file tree Collapse file tree 5 files changed +928
-41
lines changed
Expand file tree Collapse file tree 5 files changed +928
-41
lines changed Original file line number Diff line number Diff line change 1+ scripts :
2+ beforeStage : yarn update-changelog
3+ git :
4+ tagName : ' v${version}'
5+ tagAnnotation : ' v${version}'
6+ commitMessage : ' v${version}'
7+ npm :
8+ publish : true
Original file line number Diff line number Diff line change 1111 "scripts" : {
1212 "start" : " tsdx watch" ,
1313 "build" : " tsdx build" ,
14- "test" : " tsdx test --env=jsdom"
14+ "test" : " tsdx test --env=jsdom" ,
15+ "update-changelog" : " node ./scripts/update-changelog" ,
16+ "release" : " release-it"
1517 },
1618 "peerDependencies" : {
1719 "react" : " ^16.8.0"
3234 "pretty-quick" : " ^1.10.0" ,
3335 "react" : " ^16.8.6" ,
3436 "react-dom" : " ^16.8.6" ,
37+ "release-it" : " ^12.2.0" ,
3538 "tsdx" : " ^0.5.9" ,
3639 "tslib" : " ^1.9.3" ,
3740 "typescript" : " ^3.4.5"
Original file line number Diff line number Diff line change 1+ {
2+ "parserOptions" : {
3+ "sourceType" : " script"
4+ },
5+ "env" : {
6+ "browser" : false ,
7+ "jest" : false
8+ },
9+ "rules" : {
10+ "@typescript-eslint/no-var-requires" : " off"
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const fs = require ( 'fs' )
4+ const { promisify } = require ( 'util' )
5+
6+ const readFile = promisify ( fs . readFile )
7+ const writeFile = promisify ( fs . writeFile )
8+
9+ const CHANGELOG_FILENAME = 'CHANGELOG.md'
10+ const UNRELEASED_SECTION = '## [Unreleased]'
11+
12+ const getVersion = ( ) => {
13+ const package = require ( '../package.json' )
14+
15+ return package . version
16+ }
17+
18+ const update = async ( ) => {
19+ const changelog = ( await readFile ( CHANGELOG_FILENAME ) ) . toString ( )
20+
21+ const unreleasedSectionIndex = changelog . indexOf ( UNRELEASED_SECTION )
22+ const headerLength = unreleasedSectionIndex + UNRELEASED_SECTION . length + 1
23+
24+ const header = changelog . slice ( 0 , headerLength )
25+
26+ const body = changelog . slice ( headerLength )
27+ const now = new Date ( )
28+
29+ const year = now . getFullYear ( )
30+ const month = ( now . getUTCMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' )
31+ const day = now
32+ . getUTCDate ( )
33+ . toString ( )
34+ . padStart ( 2 , '0' )
35+
36+ const newChangelog = `
37+ ${ header }
38+ ## [${ getVersion ( ) } ] - ${ year } -${ month } -${ day }
39+ ${ body }
40+ ` . trim ( )
41+
42+ await writeFile ( CHANGELOG_FILENAME , newChangelog + '\n' )
43+ }
44+
45+ update ( )
You can’t perform that action at this time.
0 commit comments