keep-a-changelog 0.10.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -185
- package/LICENSE +1 -1
- package/README.md +93 -63
- package/esm/_dnt.shims.js +62 -0
- package/esm/bin.js +114 -0
- package/esm/deps/deno_land/std_0.120.0/_util/assert.js +13 -0
- package/esm/deps/deno_land/std_0.120.0/_util/os.js +15 -0
- package/esm/deps/deno_land/std_0.120.0/flags/mod.js +255 -0
- package/esm/deps/deno_land/std_0.120.0/path/_constants.js +45 -0
- package/esm/deps/deno_land/std_0.120.0/path/_interface.js +3 -0
- package/esm/deps/deno_land/std_0.120.0/path/_util.js +114 -0
- package/esm/deps/deno_land/std_0.120.0/path/common.js +36 -0
- package/esm/deps/deno_land/std_0.120.0/path/glob.js +361 -0
- package/esm/deps/deno_land/std_0.120.0/path/mod.js +14 -0
- package/esm/deps/deno_land/std_0.120.0/path/posix.js +493 -0
- package/esm/deps/deno_land/std_0.120.0/path/separator.js +5 -0
- package/esm/deps/deno_land/std_0.120.0/path/win32.js +963 -0
- package/esm/deps/deno_land/std_0.51.0/fs/eol.js +29 -0
- package/esm/deps/deno_land/x/ini_v2.1.0/ini.js +226 -0
- package/esm/deps/deno_land/x/ini_v2.1.0/mod.js +1 -0
- package/esm/deps/deno_land/x/semver_v1.4.0/mod.js +1527 -0
- package/esm/mod.js +5 -0
- package/esm/package.json +3 -0
- package/esm/src/Change.js +48 -0
- package/esm/src/Changelog.js +137 -0
- package/esm/src/Release.js +204 -0
- package/esm/src/deps.js +1 -0
- package/esm/src/parser.js +159 -0
- package/esm/test/changelog.custom.type.md +24 -0
- package/esm/test/changelog.expected.md +169 -0
- package/esm/test/changelog.md +200 -0
- package/esm/test/empty.expected.md +6 -0
- package/package.json +26 -24
- package/types/_dnt.shims.d.ts +9 -0
- package/types/bin.d.ts +2 -0
- package/types/deps/deno_land/std_0.120.0/_util/assert.d.ts +5 -0
- package/types/deps/deno_land/std_0.120.0/_util/os.d.ts +3 -0
- package/types/deps/deno_land/std_0.120.0/flags/mod.d.ts +50 -0
- package/types/deps/deno_land/std_0.120.0/path/_constants.d.ts +39 -0
- package/types/deps/deno_land/std_0.120.0/path/_interface.d.ts +26 -0
- package/types/deps/deno_land/std_0.120.0/path/_util.d.ts +8 -0
- package/types/deps/deno_land/std_0.120.0/path/common.d.ts +13 -0
- package/types/deps/deno_land/std_0.120.0/path/glob.d.ts +78 -0
- package/types/deps/deno_land/std_0.120.0/path/mod.d.ts +9 -0
- package/types/deps/deno_land/std_0.120.0/path/posix.d.ts +80 -0
- package/types/deps/deno_land/std_0.120.0/path/separator.d.ts +2 -0
- package/types/deps/deno_land/std_0.120.0/path/win32.d.ts +87 -0
- package/types/deps/deno_land/std_0.51.0/fs/eol.d.ts +12 -0
- package/types/deps/deno_land/x/ini_v2.1.0/ini.d.ts +53 -0
- package/types/deps/deno_land/x/ini_v2.1.0/mod.d.ts +1 -0
- package/types/deps/deno_land/x/semver_v1.4.0/mod.d.ts +116 -0
- package/types/mod.d.ts +5 -0
- package/types/src/Change.d.ts +8 -0
- package/types/src/Changelog.d.ts +18 -0
- package/types/src/Release.d.ts +25 -0
- package/types/src/deps.d.ts +1 -0
- package/types/src/parser.d.ts +11 -0
- package/umd/_dnt.shims.js +76 -0
- package/umd/bin.js +145 -0
- package/umd/deps/deno_land/std_0.120.0/_util/assert.js +28 -0
- package/umd/deps/deno_land/std_0.120.0/_util/os.js +47 -0
- package/umd/deps/deno_land/std_0.120.0/flags/mod.js +269 -0
- package/umd/deps/deno_land/std_0.120.0/path/_constants.js +58 -0
- package/umd/deps/deno_land/std_0.120.0/path/_interface.js +14 -0
- package/umd/deps/deno_land/std_0.120.0/path/_util.js +134 -0
- package/umd/deps/deno_land/std_0.120.0/path/common.js +50 -0
- package/umd/deps/deno_land/std_0.120.0/path/glob.js +397 -0
- package/umd/deps/deno_land/std_0.120.0/path/mod.js +51 -0
- package/umd/deps/deno_land/std_0.120.0/path/posix.js +538 -0
- package/umd/deps/deno_land/std_0.120.0/path/separator.js +18 -0
- package/umd/deps/deno_land/std_0.120.0/path/win32.js +1008 -0
- package/umd/deps/deno_land/std_0.51.0/fs/eol.js +44 -0
- package/umd/deps/deno_land/x/ini_v2.1.0/ini.js +262 -0
- package/umd/deps/deno_land/x/ini_v2.1.0/mod.js +23 -0
- package/umd/deps/deno_land/x/semver_v1.4.0/mod.js +1578 -0
- package/umd/mod.js +24 -0
- package/umd/package.json +3 -0
- package/umd/src/Change.js +61 -0
- package/umd/src/Changelog.js +150 -0
- package/umd/src/Release.js +220 -0
- package/umd/src/deps.js +19 -0
- package/umd/src/parser.js +175 -0
- package/umd/test/changelog.custom.type.md +24 -0
- package/umd/test/changelog.expected.md +169 -0
- package/umd/test/changelog.md +200 -0
- package/umd/test/empty.expected.md +6 -0
- package/bin.js +0 -114
- package/src/Change.js +0 -40
- package/src/Changelog.js +0 -121
- package/src/Release.js +0 -220
- package/src/index.js +0 -6
- package/src/parser.js +0 -182
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
2
|
+
|
|
1
3
|
# Changelog
|
|
2
4
|
|
|
3
5
|
All notable changes to this project will be documented in this file.
|
|
@@ -5,194 +7,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
7
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
8
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
9
|
|
|
8
|
-
## [0.
|
|
9
|
-
### Fixed
|
|
10
|
-
- Support for multiline links [#16]
|
|
11
|
-
|
|
12
|
-
## [0.10.2] - 2020-10-11
|
|
13
|
-
### Added
|
|
14
|
-
- New command option --quiet added to cli [#14] [#15]
|
|
15
|
-
|
|
16
|
-
### Changed
|
|
17
|
-
- `changelong` command will exit with code 1 if it fails to parse the changelog file
|
|
18
|
-
|
|
19
|
-
## [0.10.1] - 2020-05-04
|
|
20
|
-
### Added
|
|
21
|
-
- New command --latest-release added to cli
|
|
22
|
-
- New command --release added to cli
|
|
23
|
-
|
|
24
|
-
### Fixed
|
|
25
|
-
- Removed trailing space in the default description generated with --init
|
|
26
|
-
- Updated dependencies
|
|
27
|
-
|
|
28
|
-
## [0.10.0] - 2020-02-08
|
|
29
|
-
### Added
|
|
30
|
-
- Documentation to extend `Release` class + test coverage [#12] [#13]
|
|
31
|
-
- Ability to use extended `Release` within `parser` [#12] [#13]
|
|
32
|
-
|
|
33
|
-
### Fixed
|
|
34
|
-
- Upgrade semver and mocha to the latest version
|
|
35
|
-
|
|
36
|
-
## [0.9.1] - 2019-11-26
|
|
37
|
-
### Fixed
|
|
38
|
-
- Undefined function bug in CLI
|
|
39
|
-
|
|
40
|
-
## [0.9.0] - 2019-11-26
|
|
41
|
-
### Removed
|
|
42
|
-
- Support for node < 10
|
|
43
|
-
|
|
44
|
-
## [0.8.2] - 2019-11-26
|
|
45
|
-
### Added
|
|
46
|
-
- Allow to customize the HEAD branch to compare the unreleased versions
|
|
47
|
-
|
|
48
|
-
### Fixed
|
|
49
|
-
- Compare with master branch in gitlab
|
|
50
|
-
- Nested lists were flatten
|
|
51
|
-
- Updated yargs-parser
|
|
52
|
-
|
|
53
|
-
## [0.8.1] - 2019-05-27
|
|
54
|
-
### Fixed
|
|
55
|
-
- Support for more than one unreleased version
|
|
56
|
-
- Updated semver to the latest version
|
|
57
|
-
|
|
58
|
-
## [0.8.0] - 2019-03-02
|
|
59
|
-
### Added
|
|
60
|
-
- New property `Changelog.tagNameBuilder` to customize how the tag names are generated - [#10]
|
|
61
|
-
- New `Release.setDate()` function - [#9]
|
|
62
|
-
|
|
10
|
+
## [2.0.1] - 2022-01-09
|
|
63
11
|
### Fixed
|
|
64
|
-
-
|
|
12
|
+
- Updated deps.
|
|
13
|
+
- `release` and `latest-release` args [#23].
|
|
65
14
|
|
|
66
|
-
## [0.
|
|
67
|
-
|
|
68
|
-
- Removed some spaces before and after some titles to inline with the changelog format
|
|
69
|
-
|
|
70
|
-
## [0.6.7] - 2018-11-29
|
|
71
|
-
### Fixed
|
|
72
|
-
- Fixed the links sorting to compare issues numerically instead alphabetically
|
|
15
|
+
## [2.0.0] - 2021-12-08
|
|
16
|
+
New version merging Deno and Node code using Deno's `dnt` package.
|
|
73
17
|
|
|
74
|
-
## [0.6.6] - 2018-11-29
|
|
75
18
|
### Changed
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
## [0.6.5] - 2018-11-01
|
|
79
|
-
### Fixed
|
|
80
|
-
- Updated issue autodetection to prevent unwanted extractions - [#7]
|
|
81
|
-
|
|
82
|
-
## [0.6.4] - 2018-09-03
|
|
83
|
-
### Added
|
|
84
|
-
- Added `findRelease` function to `Changelog` for finding a release by version number - [#6]
|
|
85
|
-
- Added `setVersion` function to `Release` for changing the version of a release - [#6]
|
|
86
|
-
|
|
87
|
-
## [0.6.3] - 2018-08-22
|
|
88
|
-
### Fixed
|
|
89
|
-
- Fixed trailing newlines when no links are present - [#5]
|
|
90
|
-
- Fixed case of unreleased version to match http://keepachangelog.com/ - [#4]
|
|
91
|
-
- Fixed Release isEmpty and add tests - [#3]
|
|
92
|
-
|
|
93
|
-
## [0.6.2] - 2018-07-24
|
|
94
|
-
### Added
|
|
95
|
-
- Support for unreleased versions (releases with version but without date)
|
|
96
|
-
|
|
97
|
-
## [0.6.1] - 2018-06-30
|
|
98
|
-
### Fixed
|
|
99
|
-
- Prevent inserting duplicated links
|
|
100
|
-
|
|
101
|
-
## [0.6.0] - 2018-06-12
|
|
102
|
-
### Added
|
|
103
|
-
- CLI Api: New option `--init`, to generate an empty CHANGELOG.md file
|
|
104
|
-
|
|
105
|
-
## [0.5.2] - 2018-05-12
|
|
106
|
-
### Fixed
|
|
107
|
-
- Issues autodetection links
|
|
108
|
-
|
|
109
|
-
## [0.5.1] - 2018-05-12
|
|
110
|
-
### Fixed
|
|
111
|
-
- Issues autodetection problems with texts like `#3.4`
|
|
112
|
-
- Test execution was commented
|
|
113
|
-
|
|
114
|
-
## [0.5.0] - 2018-05-09
|
|
115
|
-
### Added
|
|
116
|
-
- Allow to insert a footer at the end of the changelog
|
|
117
|
-
|
|
118
|
-
### Changed
|
|
119
|
-
- Placed the urls of the issues at bottom
|
|
120
|
-
- Indent automatically the extra lines of the changes
|
|
121
|
-
|
|
122
|
-
### Fixed
|
|
123
|
-
- Parser refactoring
|
|
124
|
-
|
|
125
|
-
## [0.4.0] - 2018-03-22
|
|
126
|
-
### Added
|
|
127
|
-
- Create links automatically to the issues
|
|
128
|
-
|
|
129
|
-
### Fixed
|
|
130
|
-
- Use UTC date functions to fix decrement issue - [#1]
|
|
131
|
-
|
|
132
|
-
## [0.3.1] - 2017-12-11
|
|
133
|
-
### Added
|
|
134
|
-
- CLI Api: New option `--file`, to change the filename used
|
|
135
|
-
- CLI Api: New option `--url`, to set or change the project url
|
|
136
|
-
- CLI Api: New option `--https`, to change the use of https in the url scheme
|
|
137
|
-
|
|
138
|
-
## [0.3.0] - 2017-12-08
|
|
139
|
-
### Added
|
|
140
|
-
- Added colors in CLI
|
|
141
|
-
- Parser errors contains the line number in the CHANGELOG file
|
|
142
|
-
|
|
143
|
-
### Fixed
|
|
144
|
-
- Fixed parsing bug when the changelog is using incorrect title levels
|
|
145
|
-
|
|
146
|
-
## [0.2.0] - 2017-12-07
|
|
147
|
-
### Changed
|
|
148
|
-
- Parser improvements
|
|
149
|
-
- Changed the constructor arguments of Changelog, Change and Release classes
|
|
150
|
-
|
|
151
|
-
### Removed
|
|
152
|
-
- Removed static factories. Use `new` instead.
|
|
153
|
-
|
|
154
|
-
### Fixed
|
|
155
|
-
- The last version should't have diff link
|
|
156
|
-
|
|
157
|
-
## 0.1.0 - 2017-12-07
|
|
158
|
-
First version
|
|
19
|
+
- Code converted to TypeScript.
|
|
20
|
+
- Added the link of the first version [#21].
|
|
159
21
|
|
|
160
|
-
[#
|
|
161
|
-
[#
|
|
162
|
-
[#4]: https://github.com/oscarotero/keep-a-changelog/issues/4
|
|
163
|
-
[#5]: https://github.com/oscarotero/keep-a-changelog/issues/5
|
|
164
|
-
[#6]: https://github.com/oscarotero/keep-a-changelog/issues/6
|
|
165
|
-
[#7]: https://github.com/oscarotero/keep-a-changelog/issues/7
|
|
166
|
-
[#9]: https://github.com/oscarotero/keep-a-changelog/issues/9
|
|
167
|
-
[#10]: https://github.com/oscarotero/keep-a-changelog/issues/10
|
|
168
|
-
[#12]: https://github.com/oscarotero/keep-a-changelog/issues/12
|
|
169
|
-
[#13]: https://github.com/oscarotero/keep-a-changelog/issues/13
|
|
170
|
-
[#14]: https://github.com/oscarotero/keep-a-changelog/issues/14
|
|
171
|
-
[#15]: https://github.com/oscarotero/keep-a-changelog/issues/15
|
|
172
|
-
[#16]: https://github.com/oscarotero/keep-a-changelog/issues/16
|
|
22
|
+
[#21]: https://github.com/oscarotero/keep-a-changelog/issues/21
|
|
23
|
+
[#23]: https://github.com/oscarotero/keep-a-changelog/issues/23
|
|
173
24
|
|
|
174
|
-
[0.
|
|
175
|
-
[0.
|
|
176
|
-
[0.10.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.10.0...v0.10.1
|
|
177
|
-
[0.10.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.9.1...v0.10.0
|
|
178
|
-
[0.9.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.9.0...v0.9.1
|
|
179
|
-
[0.9.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.2...v0.9.0
|
|
180
|
-
[0.8.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.1...v0.8.2
|
|
181
|
-
[0.8.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.0...v0.8.1
|
|
182
|
-
[0.8.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.7.0...v0.8.0
|
|
183
|
-
[0.7.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.7...v0.7.0
|
|
184
|
-
[0.6.7]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.6...v0.6.7
|
|
185
|
-
[0.6.6]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.5...v0.6.6
|
|
186
|
-
[0.6.5]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.4...v0.6.5
|
|
187
|
-
[0.6.4]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.3...v0.6.4
|
|
188
|
-
[0.6.3]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.2...v0.6.3
|
|
189
|
-
[0.6.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.1...v0.6.2
|
|
190
|
-
[0.6.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.0...v0.6.1
|
|
191
|
-
[0.6.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.2...v0.6.0
|
|
192
|
-
[0.5.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.1...v0.5.2
|
|
193
|
-
[0.5.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.0...v0.5.1
|
|
194
|
-
[0.5.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.4.0...v0.5.0
|
|
195
|
-
[0.4.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.3.1...v0.4.0
|
|
196
|
-
[0.3.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.3.0...v0.3.1
|
|
197
|
-
[0.3.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.2.0...v0.3.0
|
|
198
|
-
[0.2.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.1.0...v0.2.0
|
|
25
|
+
[2.0.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.0...v2.0.1
|
|
26
|
+
[2.0.0]: https://github.com/oscarotero/keep-a-changelog/releases/tag/v2.0.0
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[Keep a Changelog](https://github.com/oscarotero/keep-a-changelog) library for
|
|
4
|
+
Node & Deno
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Deno package to parse and generate changelogs following the
|
|
7
|
+
[keepachangelog](http://keepachangelog.com/en/1.0.0/) format.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Usage in Node
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
```js
|
|
12
|
+
import { parser } from "keep-a-changelog";
|
|
13
|
+
import fs from "fs";
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
//Parse a changelog file
|
|
16
|
+
const changelog = parser(fs.readFileSync("CHANGELOG.md", "UTF-8"));
|
|
17
|
+
|
|
18
|
+
//Generate the new changelog string
|
|
19
|
+
console.log(changelog.toString());
|
|
13
20
|
```
|
|
14
21
|
|
|
15
|
-
## Usage
|
|
22
|
+
## Usage in Deno
|
|
16
23
|
|
|
17
24
|
```js
|
|
18
|
-
|
|
19
|
-
const fs = require('fs');
|
|
25
|
+
import { parser } from "https://deno.land/x/changelog@2.0.0/mod.ts";
|
|
20
26
|
|
|
21
27
|
//Parse a changelog file
|
|
22
|
-
const changelog = parser(
|
|
28
|
+
const changelog = parser(await Deno.readTextFile("CHANGELOG.md"));
|
|
23
29
|
|
|
24
30
|
//Generate the new changelog string
|
|
25
31
|
console.log(changelog.toString());
|
|
@@ -28,72 +34,95 @@ console.log(changelog.toString());
|
|
|
28
34
|
### Create a new changelog
|
|
29
35
|
|
|
30
36
|
```js
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const changelog = new Changelog(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
import { Changelog, Release } from "https://deno.land/x/changelog@2.0.0/mod.ts";
|
|
38
|
+
|
|
39
|
+
const changelog = new Changelog("My project")
|
|
40
|
+
.addRelease(
|
|
41
|
+
new Release("0.1.0", "2017-12-06")
|
|
42
|
+
.added("New awesome feature")
|
|
43
|
+
.added("New other awesome feature")
|
|
44
|
+
.fixed("Bug #3")
|
|
45
|
+
.removed("Drop support for X"),
|
|
46
|
+
)
|
|
47
|
+
.addRelease(
|
|
48
|
+
new Release("0.2.0", "2017-12-09")
|
|
49
|
+
.security("Fixed security vulnerability")
|
|
50
|
+
.deprecated("Feature X is deprecated"),
|
|
51
|
+
);
|
|
46
52
|
|
|
47
53
|
console.log(changelog.toString());
|
|
48
54
|
```
|
|
49
55
|
|
|
50
56
|
### Custom tag names
|
|
51
57
|
|
|
52
|
-
By default, the tag names are `v` + version number. For example, the tag for the
|
|
58
|
+
By default, the tag names are `v` + version number. For example, the tag for the
|
|
59
|
+
version `2.4.9` is `v2.4.9`. To change this behavior, set a new
|
|
60
|
+
`tagNameBuilder`:
|
|
53
61
|
|
|
54
62
|
```js
|
|
55
63
|
const changelog = new Changelog();
|
|
56
|
-
changelog.tagNameBuilder = release => `version-${release.version}`;
|
|
64
|
+
changelog.tagNameBuilder = (release) => `version-${release.version}`;
|
|
57
65
|
```
|
|
66
|
+
|
|
58
67
|
### Custom Change Types
|
|
59
68
|
|
|
60
|
-
By default and according to the
|
|
61
|
-
|
|
62
|
-
`Changed`,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
For example, we would like to add a type `Maintenance`.
|
|
70
|
-
|
|
69
|
+
By default and according to the
|
|
70
|
+
[keepachangelog](http://keepachangelog.com/en/1.0.0/) format, the change types
|
|
71
|
+
are `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, and `Security`.
|
|
72
|
+
|
|
73
|
+
In case you'd like add another type in order to use is in your changelog, you
|
|
74
|
+
basically need to extend the `Release` class to support new types. Additionally,
|
|
75
|
+
you have to tell the `parser` that it should create instances of your new
|
|
76
|
+
extended `Release` in order to parse your changelog correctly.
|
|
77
|
+
|
|
78
|
+
For example, we would like to add a type `Maintenance`. Extend the provided
|
|
79
|
+
`Release` class:
|
|
80
|
+
|
|
71
81
|
```js
|
|
72
82
|
class CustomRelease extends Release {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
constructor(version, date, description) {
|
|
84
|
+
super(version, date, description);
|
|
85
|
+
// add whatever types you want - in lowercase
|
|
86
|
+
const newChangeTypes = [
|
|
87
|
+
["maintenance", []],
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
this.changes = new Map([...this.changes, ...newChangeTypes]);
|
|
91
|
+
}
|
|
92
|
+
// for convenience, add a new method to add change of type 'maintanance'
|
|
93
|
+
maintenance(change) {
|
|
94
|
+
return this.addChange("maintenance", change);
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
```
|
|
98
|
+
|
|
88
99
|
And once you want to use the parser:
|
|
100
|
+
|
|
89
101
|
```js
|
|
90
|
-
const releaseCreator = (ver, date, desc) => new CustomRelease(ver, date, desc)
|
|
91
|
-
const changelog = parser(changelogTextContent, {releaseCreator})
|
|
102
|
+
const releaseCreator = (ver, date, desc) => new CustomRelease(ver, date, desc);
|
|
103
|
+
const changelog = parser(changelogTextContent, { releaseCreator });
|
|
92
104
|
```
|
|
93
105
|
|
|
94
106
|
## Cli
|
|
95
107
|
|
|
96
|
-
This library provides the `changelog` command to normalize the changelog format.
|
|
108
|
+
This library provides the `changelog` command to normalize the changelog format.
|
|
109
|
+
It reads the CHANGELOG.md file and override it with the new format:
|
|
110
|
+
|
|
111
|
+
### Install the library as script
|
|
112
|
+
|
|
113
|
+
Deno:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
deno install --allow-read --allow-write --name changelog https://deno.land/x/changelog/bin.ts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Node:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npm install keep-a-changelog -g
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Run the script:
|
|
97
126
|
|
|
98
127
|
```sh
|
|
99
128
|
changelog
|
|
@@ -126,11 +155,12 @@ changelog --latest-release
|
|
|
126
155
|
|
|
127
156
|
Available options:
|
|
128
157
|
|
|
129
|
-
Option
|
|
130
|
-
|
|
131
|
-
`--file`
|
|
132
|
-
`--url`
|
|
133
|
-
`--https`
|
|
134
|
-
`--init`
|
|
135
|
-
`--latest-release` | Print the latest release version.
|
|
136
|
-
`--release`
|
|
158
|
+
| Option | Description |
|
|
159
|
+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
160
|
+
| `--file` | The markdown file of the changelog. The default value is `CHANGELOG.md`. |
|
|
161
|
+
| `--url` | The base url used to build the diff urls of the different releases. It is taken from the existing diff urls in the markdown. If no urls are found, try to catch it using the url of the git remote repository. |
|
|
162
|
+
| `--https` | Set to false to use `http` instead `https` in the url (`--https=false`). |
|
|
163
|
+
| `--init` | Init a new empty changelog file. |
|
|
164
|
+
| `--latest-release` | Print the latest release version. |
|
|
165
|
+
| `--release` | Updated the latest unreleased version with the current date. |
|
|
166
|
+
| `--quiet` | Do not output error messages |
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
const dntGlobals = {
|
|
4
|
+
Deno,
|
|
5
|
+
};
|
|
6
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
|
+
// deno-lint-ignore ban-types
|
|
8
|
+
function createMergeProxy(baseObj, extObj) {
|
|
9
|
+
return new Proxy(baseObj, {
|
|
10
|
+
get(_target, prop, _receiver) {
|
|
11
|
+
if (prop in extObj) {
|
|
12
|
+
return extObj[prop];
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return baseObj[prop];
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
set(_target, prop, value) {
|
|
19
|
+
if (prop in extObj) {
|
|
20
|
+
delete extObj[prop];
|
|
21
|
+
}
|
|
22
|
+
baseObj[prop] = value;
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
deleteProperty(_target, prop) {
|
|
26
|
+
let success = false;
|
|
27
|
+
if (prop in extObj) {
|
|
28
|
+
delete extObj[prop];
|
|
29
|
+
success = true;
|
|
30
|
+
}
|
|
31
|
+
if (prop in baseObj) {
|
|
32
|
+
delete baseObj[prop];
|
|
33
|
+
success = true;
|
|
34
|
+
}
|
|
35
|
+
return success;
|
|
36
|
+
},
|
|
37
|
+
ownKeys(_target) {
|
|
38
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
39
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
40
|
+
const extKeysSet = new Set(extKeys);
|
|
41
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
42
|
+
},
|
|
43
|
+
defineProperty(_target, prop, desc) {
|
|
44
|
+
if (prop in extObj) {
|
|
45
|
+
delete extObj[prop];
|
|
46
|
+
}
|
|
47
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
48
|
+
return true;
|
|
49
|
+
},
|
|
50
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
51
|
+
if (prop in extObj) {
|
|
52
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
has(_target, prop) {
|
|
59
|
+
return prop in extObj || prop in baseObj;
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
package/esm/bin.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as dntShim from "./_dnt.shims.js";
|
|
3
|
+
import { join } from "./deps/deno_land/std_0.120.0/path/mod.js";
|
|
4
|
+
import { Changelog, parser, Release } from "./mod.js";
|
|
5
|
+
import { parse as parseFlag } from "./deps/deno_land/std_0.120.0/flags/mod.js";
|
|
6
|
+
import { parse as parseIni } from "./deps/deno_land/x/ini_v2.1.0/mod.js";
|
|
7
|
+
const argv = parseFlag(dntShim.Deno.args, {
|
|
8
|
+
default: {
|
|
9
|
+
file: "CHANGELOG.md",
|
|
10
|
+
release: null,
|
|
11
|
+
url: null,
|
|
12
|
+
https: true,
|
|
13
|
+
quiet: false,
|
|
14
|
+
},
|
|
15
|
+
boolean: ["https", "init", "latest-release", "quiet"],
|
|
16
|
+
});
|
|
17
|
+
const file = join(dntShim.Deno.cwd(), argv.file);
|
|
18
|
+
try {
|
|
19
|
+
if (argv.init) {
|
|
20
|
+
const changelog = new Changelog("Changelog").addRelease(new Release("0.1.0", new Date(), "First version"));
|
|
21
|
+
save(file, changelog, true);
|
|
22
|
+
dntShim.Deno.exit(0);
|
|
23
|
+
}
|
|
24
|
+
const changelog = parser(dntShim.Deno.readTextFileSync(file));
|
|
25
|
+
if (argv['latest-release']) {
|
|
26
|
+
const release = changelog.releases.find((release) => release.date && release.version);
|
|
27
|
+
if (release) {
|
|
28
|
+
console.log(release.version?.toString());
|
|
29
|
+
}
|
|
30
|
+
dntShim.Deno.exit(0);
|
|
31
|
+
}
|
|
32
|
+
if (argv.release) {
|
|
33
|
+
const release = changelog.releases.find((release) => {
|
|
34
|
+
if (release.date) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (typeof argv.release === "string") {
|
|
38
|
+
return !release.version || argv.release === release.version.toString();
|
|
39
|
+
}
|
|
40
|
+
return !!release.version;
|
|
41
|
+
});
|
|
42
|
+
if (release) {
|
|
43
|
+
release.date = new Date();
|
|
44
|
+
if (typeof argv.release === "string") {
|
|
45
|
+
release.setVersion(argv.release);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.error("Not found any valid unreleased version");
|
|
50
|
+
dntShim.Deno.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!changelog.url) {
|
|
54
|
+
if (argv.url) {
|
|
55
|
+
changelog.url = argv.url;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const url = getRemoteUrl(argv.https);
|
|
59
|
+
if (url) {
|
|
60
|
+
changelog.url = url;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.error(red('Please, set the repository url with --url="https://github.com/username/repository"'));
|
|
64
|
+
dntShim.Deno.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
save(file, changelog);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
console.error(red(err.message));
|
|
72
|
+
if (!argv.quiet) {
|
|
73
|
+
dntShim.Deno.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function save(file, changelog, isNew = false) {
|
|
77
|
+
const url = changelog.url;
|
|
78
|
+
if (url && url.includes("gitlab.com")) {
|
|
79
|
+
changelog.head = "master";
|
|
80
|
+
}
|
|
81
|
+
dntShim.Deno.writeTextFileSync(file, changelog.toString());
|
|
82
|
+
if (isNew) {
|
|
83
|
+
console.log(green("Generated new file"), file);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.log(green("Updated file"), file);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function red(message) {
|
|
90
|
+
return "\u001b[" + 31 + "m" + message + "\u001b[" + 39 + "m";
|
|
91
|
+
}
|
|
92
|
+
function green(message) {
|
|
93
|
+
return "\u001b[" + 32 + "m" + message + "\u001b[" + 39 + "m";
|
|
94
|
+
}
|
|
95
|
+
function getRemoteUrl(https = true) {
|
|
96
|
+
try {
|
|
97
|
+
const file = join(dntShim.Deno.cwd(), ".git", "config");
|
|
98
|
+
const content = dntShim.Deno.readTextFileSync(file);
|
|
99
|
+
const data = parseIni(content);
|
|
100
|
+
const url = data?.['remote "origin"']?.url;
|
|
101
|
+
if (!url) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2"));
|
|
105
|
+
if (https) {
|
|
106
|
+
remoteUrl.protocol = "https:";
|
|
107
|
+
}
|
|
108
|
+
return remoteUrl.href;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
console.error(red(err.message));
|
|
112
|
+
// Ignore
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
export class DenoStdInternalError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DenoStdInternalError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Make an assertion, if not `true`, then throw. */
|
|
9
|
+
export function assert(expr, msg = "") {
|
|
10
|
+
if (!expr) {
|
|
11
|
+
throw new DenoStdInternalError(msg);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
|
+
export const osType = (() => {
|
|
3
|
+
// deno-lint-ignore no-explicit-any
|
|
4
|
+
const { Deno } = dntShim.dntGlobalThis;
|
|
5
|
+
if (typeof Deno?.build?.os === "string") {
|
|
6
|
+
return Deno.build.os;
|
|
7
|
+
}
|
|
8
|
+
// deno-lint-ignore no-explicit-any
|
|
9
|
+
const { navigator } = dntShim.dntGlobalThis;
|
|
10
|
+
if (navigator?.appVersion?.includes?.("Win") ?? false) {
|
|
11
|
+
return "windows";
|
|
12
|
+
}
|
|
13
|
+
return "linux";
|
|
14
|
+
})();
|
|
15
|
+
export const isWindows = osType === "windows";
|