keep-a-changelog 0.10.4 → 2.0.0-beta

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +5 -196
  2. package/LICENSE +1 -1
  3. package/README.md +93 -63
  4. package/esm/bin.js +113 -0
  5. package/esm/deps/deno_land/std_0.113.0/_util/assert.js +13 -0
  6. package/esm/deps/deno_land/std_0.113.0/_util/os.js +15 -0
  7. package/esm/deps/deno_land/std_0.113.0/flags/mod.js +255 -0
  8. package/esm/deps/deno_land/std_0.113.0/path/_constants.js +45 -0
  9. package/esm/deps/deno_land/std_0.113.0/path/_interface.js +3 -0
  10. package/esm/deps/deno_land/std_0.113.0/path/_util.js +114 -0
  11. package/esm/deps/deno_land/std_0.113.0/path/common.js +36 -0
  12. package/esm/deps/deno_land/std_0.113.0/path/glob.js +361 -0
  13. package/esm/deps/deno_land/std_0.113.0/path/mod.js +14 -0
  14. package/esm/deps/deno_land/std_0.113.0/path/posix.js +493 -0
  15. package/esm/deps/deno_land/std_0.113.0/path/separator.js +5 -0
  16. package/esm/deps/deno_land/std_0.113.0/path/win32.js +963 -0
  17. package/esm/deps/deno_land/std_0.51.0/fs/eol.js +29 -0
  18. package/esm/deps/deno_land/x/ini_v2.1.0/ini.js +226 -0
  19. package/esm/deps/deno_land/x/ini_v2.1.0/mod.js +1 -0
  20. package/esm/deps/deno_land/x/semver_v1.4.0/mod.js +1527 -0
  21. package/esm/mod.js +5 -0
  22. package/esm/package.json +3 -0
  23. package/esm/src/Change.js +48 -0
  24. package/esm/src/Changelog.js +137 -0
  25. package/esm/src/Release.js +204 -0
  26. package/esm/src/deps.js +1 -0
  27. package/esm/src/parser.js +149 -0
  28. package/esm/test/changelog.custom.type.md +24 -0
  29. package/esm/test/changelog.expected.md +169 -0
  30. package/esm/test/changelog.md +197 -0
  31. package/esm/test/empty.expected.md +6 -0
  32. package/package.json +26 -24
  33. package/types/bin.d.ts +2 -0
  34. package/types/deps/deno_land/std_0.113.0/_util/assert.d.ts +5 -0
  35. package/types/deps/deno_land/std_0.113.0/_util/os.d.ts +3 -0
  36. package/types/deps/deno_land/std_0.113.0/flags/mod.d.ts +50 -0
  37. package/types/deps/deno_land/std_0.113.0/path/_constants.d.ts +39 -0
  38. package/types/deps/deno_land/std_0.113.0/path/_interface.d.ts +26 -0
  39. package/types/deps/deno_land/std_0.113.0/path/_util.d.ts +8 -0
  40. package/types/deps/deno_land/std_0.113.0/path/common.d.ts +13 -0
  41. package/types/deps/deno_land/std_0.113.0/path/glob.d.ts +78 -0
  42. package/types/deps/deno_land/std_0.113.0/path/mod.d.ts +9 -0
  43. package/types/deps/deno_land/std_0.113.0/path/posix.d.ts +80 -0
  44. package/types/deps/deno_land/std_0.113.0/path/separator.d.ts +2 -0
  45. package/types/deps/deno_land/std_0.113.0/path/win32.d.ts +87 -0
  46. package/types/deps/deno_land/std_0.115.1/fmt/colors.d.ts +270 -0
  47. package/types/deps/deno_land/std_0.115.1/testing/_diff.d.ts +23 -0
  48. package/types/deps/deno_land/std_0.115.1/testing/asserts.d.ts +151 -0
  49. package/types/deps/deno_land/std_0.51.0/fs/eol.d.ts +12 -0
  50. package/types/deps/deno_land/x/ini_v2.1.0/ini.d.ts +53 -0
  51. package/types/deps/deno_land/x/ini_v2.1.0/mod.d.ts +1 -0
  52. package/types/deps/deno_land/x/semver_v1.4.0/mod.d.ts +116 -0
  53. package/types/mod.d.ts +5 -0
  54. package/types/src/Change.d.ts +8 -0
  55. package/types/src/Changelog.d.ts +18 -0
  56. package/types/src/Release.d.ts +25 -0
  57. package/types/src/deps.d.ts +1 -0
  58. package/types/src/parser.d.ts +11 -0
  59. package/types/test/Change.test.d.ts +1 -0
  60. package/types/test/fixture/CustomRelease.d.ts +7 -0
  61. package/types/test/parser.test.d.ts +1 -0
  62. package/types/test/test.d.ts +1 -0
  63. package/umd/bin.js +143 -0
  64. package/umd/deps/deno_land/std_0.113.0/_util/assert.js +27 -0
  65. package/umd/deps/deno_land/std_0.113.0/_util/os.js +46 -0
  66. package/umd/deps/deno_land/std_0.113.0/flags/mod.js +268 -0
  67. package/umd/deps/deno_land/std_0.113.0/path/_constants.js +57 -0
  68. package/umd/deps/deno_land/std_0.113.0/path/_interface.js +13 -0
  69. package/umd/deps/deno_land/std_0.113.0/path/_util.js +133 -0
  70. package/umd/deps/deno_land/std_0.113.0/path/common.js +49 -0
  71. package/umd/deps/deno_land/std_0.113.0/path/glob.js +396 -0
  72. package/umd/deps/deno_land/std_0.113.0/path/mod.js +50 -0
  73. package/umd/deps/deno_land/std_0.113.0/path/posix.js +537 -0
  74. package/umd/deps/deno_land/std_0.113.0/path/separator.js +17 -0
  75. package/umd/deps/deno_land/std_0.113.0/path/win32.js +1007 -0
  76. package/umd/deps/deno_land/std_0.51.0/fs/eol.js +43 -0
  77. package/umd/deps/deno_land/x/ini_v2.1.0/ini.js +261 -0
  78. package/umd/deps/deno_land/x/ini_v2.1.0/mod.js +22 -0
  79. package/umd/deps/deno_land/x/semver_v1.4.0/mod.js +1577 -0
  80. package/umd/mod.js +23 -0
  81. package/umd/package.json +3 -0
  82. package/umd/src/Change.js +60 -0
  83. package/umd/src/Changelog.js +149 -0
  84. package/umd/src/Release.js +219 -0
  85. package/umd/src/deps.js +18 -0
  86. package/umd/src/parser.js +164 -0
  87. package/umd/test/changelog.custom.type.md +24 -0
  88. package/umd/test/changelog.expected.md +169 -0
  89. package/umd/test/changelog.md +197 -0
  90. package/umd/test/empty.expected.md +6 -0
  91. package/bin.js +0 -128
  92. package/src/Change.js +0 -40
  93. package/src/Changelog.js +0 -121
  94. package/src/Release.js +0 -220
  95. package/src/index.js +0 -6
  96. package/src/parser.js +0 -182
@@ -0,0 +1,169 @@
1
+ # Changelog - demo
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to
7
+ [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
+
9
+ ## [Unreleased]
10
+ ### Added
11
+ - Test
12
+
13
+ ## [2.0.0] - Unreleased
14
+ ### Added
15
+ - None
16
+ - Test with issue link [#1]
17
+ - Test with issue link [#4] in the middle of the text
18
+ - [#3] Test with issue link in the beginning of the text
19
+ - Test with issue dot [#2], [#10].
20
+ - Test with no issue link #123b
21
+ - Test with `package#2.0`
22
+
23
+ ## [1.0.0] - 2017-06-20
24
+ ### Added
25
+ - New visual identity by @tylerfortune8.
26
+ - Version navigation.
27
+ - Links to latest released version in previous versions.
28
+ - "Why keep a changelog?" section.
29
+ - "Who needs a changelog?" section.
30
+ - "How do I make a changelog?" section.
31
+ - "Frequently Asked Questions" section.
32
+ - New "Guiding Principles" sub-section to "How do I make a changelog?".
33
+ - Simplified and Traditional Chinese translations from @tianshuo.
34
+ - German translation from @mpbzh & @Art4.
35
+ - Italian translation from @azkidenz.
36
+ - Swedish translation from @magol.
37
+ - Turkish translation from @karalamalar.
38
+ - French translation from @zapashcanon.
39
+ - Brazilian Portugese translation from @aisamu.
40
+ - Polish translation from @amielucha.
41
+ - Russian translation from @aishek.
42
+ - Czech translation from @h4vry.
43
+ - Slovak translation from @jkostolansky.
44
+
45
+ ### Changed
46
+ - Start using "changelog" over "change log" since it's the common usage.
47
+ - Start versioning based on the current English version at 0.3.0 to help
48
+ translation authors keep things up-to-date.
49
+ - Rewrite "What makes unicorns cry?" section.
50
+ - Rewrite "Ignoring Deprecations" sub-section to clarify the ideal scenario.
51
+ - Improve "Commit log diffs" sub-section to further argument against them.
52
+ - Merge "Why can’t people just use a git log diff?" with "Commit log diffs"
53
+ - Fix typos in Simplified Chinese and Traditional Chinese translations.
54
+ - Fix typos in Brazilian Portugese translation.
55
+ - Fix typos in Turkish translation.
56
+ - Fix typos in Czech translation.
57
+ - Fix typos in Swedish translation.
58
+ - Improve phrasing in French translation.
59
+ - Fix phrasing and spelling in German translation.
60
+
61
+ ### Removed
62
+ - Section about "changelog" vs "CHANGELOG".
63
+
64
+ ## [0.3.0] - 2015-12-03
65
+ ### Added
66
+ - RU translation from @aishek.
67
+ - pt-BR translation from @tallesl.
68
+ - es-ES translation from @ZeliosAriex.
69
+
70
+ ## [0.2.0] - 2015-10-06
71
+ ### Changed
72
+ - Remove exclusionary mentions of "open source" since this project can benefit
73
+ both "open" and "closed" source projects equally.
74
+
75
+ ## [0.1.0] - 2015-10-06
76
+ ### Added
77
+ - Answer "Should you ever rewrite a change log?".
78
+
79
+ ### Changed
80
+ - Improve argument against commit logs.
81
+ - Start following [SemVer](http://semver.org) properly.
82
+
83
+ ## [0.0.8] - 2015-02-17
84
+ ### Changed
85
+ - Update year to match in every README example.
86
+ - Reluctantly stop making fun of Brits only, since most of the world writes
87
+ dates in a strange way.
88
+
89
+ ### Fixed
90
+ - Fix typos in recent README changes.
91
+ - Update outdated unreleased diff link.
92
+
93
+ ## [0.0.7] - 2015-02-16
94
+ ### Added
95
+ - Link, and make it obvious that date format is ISO 8601.
96
+
97
+ ### Changed
98
+ - Clarified the section on "Is there a standard change log format?".
99
+
100
+ ### Fixed
101
+ - Fix Markdown links to tag comparison URL with footnote-style links.
102
+
103
+ ## [0.0.6] - 2014-12-12
104
+ ### Added
105
+ - README section on "yanked" releases.
106
+
107
+ ## [0.0.5] - 2014-08-09
108
+ ### Added
109
+ - Markdown links to version tags on release headings.
110
+ - Unreleased section to gather unreleased changes and encourage note keeping
111
+ prior to releases.
112
+
113
+ ## [0.0.4] - 2014-08-09
114
+ ### Added
115
+ - Better explanation of the difference between the file ("CHANGELOG") and its
116
+ function "the change log".
117
+
118
+ ### Changed
119
+ - Refer to a "change log" instead of a "CHANGELOG" throughout the site to
120
+ differentiate between the file and the purpose of the file — the logging of
121
+ changes.
122
+
123
+ ### Removed
124
+ - Remove empty sections from CHANGELOG, they occupy too much space and create
125
+ too much noise in the file. People will have to assume that the missing
126
+ sections were intentionally left out because they contained no notable
127
+ changes.
128
+
129
+ ## [0.0.3] - 2014-08-09
130
+ ### Added
131
+ - "Why should I care?" section mentioning The Changelog podcast.
132
+
133
+ ## [0.0.2] - 2014-07-10
134
+ ### Added
135
+ - Explanation of the recommended reverse chronological release ordering.
136
+
137
+ ## [0.0.1] - 2014-05-31
138
+ ### Added
139
+ - This CHANGELOG file to hopefully serve as an evolving example of a
140
+ standardized open source project CHANGELOG.
141
+ - CNAME file to enable GitHub Pages custom domain
142
+ - README now contains answers to common questions about CHANGELOGs
143
+ - Good examples and basic guidelines, including proper date formatting.
144
+ - Counter-examples: "What makes unicorns cry?"
145
+
146
+ [#1]: https://github.com/olivierlacan/keep-a-changelog/issues/1
147
+ [#2]: https://github.com/olivierlacan/keep-a-changelog/issues/2
148
+ [#3]: https://github.com/olivierlacan/keep-a-changelog/issues/3
149
+ [#4]: https://github.com/olivierlacan/keep-a-changelog/issues/4
150
+ [#10]: https://github.com/olivierlacan/keep-a-changelog/issues/10
151
+
152
+ [Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
153
+ [2.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
154
+ [1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
155
+ [0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0
156
+ [0.2.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...v0.2.0
157
+ [0.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.8...v0.1.0
158
+ [0.0.8]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.7...v0.0.8
159
+ [0.0.7]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.6...v0.0.7
160
+ [0.0.6]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.5...v0.0.6
161
+ [0.0.5]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.4...v0.0.5
162
+ [0.0.4]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.3...v0.0.4
163
+ [0.0.3]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.2...v0.0.3
164
+ [0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2
165
+ [0.0.1]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v0.0.1
166
+
167
+ ---
168
+
169
+ This is a footer
@@ -0,0 +1,197 @@
1
+ # Changelog - demo
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to
7
+ [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
+
9
+ ## [Unreleased]
10
+
11
+ ### Added
12
+
13
+ - Test
14
+
15
+ ## [2.0.0] - unreleased
16
+
17
+ ### Added
18
+
19
+ - None
20
+ - Test with issue link [#1]
21
+ - Test with issue link #4 in the middle of the text
22
+ - #3 Test with issue link in the beginning of the text
23
+ - Test with issue dot #2, #10.
24
+ - Test with no issue link #123b
25
+ - Test with `package#2.0`
26
+
27
+ ## [1.0.0] - 2017-06-20
28
+
29
+ ### Added
30
+
31
+ - New visual identity by @tylerfortune8.
32
+ - Version navigation.
33
+ - Links to latest released version in previous versions.
34
+ - "Why keep a changelog?" section.
35
+ - "Who needs a changelog?" section.
36
+ - "How do I make a changelog?" section.
37
+ - "Frequently Asked Questions" section.
38
+ - New "Guiding Principles" sub-section to "How do I make a changelog?".
39
+ - Simplified and Traditional Chinese translations from @tianshuo.
40
+ - German translation from @mpbzh & @Art4.
41
+ - Italian translation from @azkidenz.
42
+ - Swedish translation from @magol.
43
+ - Turkish translation from @karalamalar.
44
+ - French translation from @zapashcanon.
45
+ - Brazilian Portugese translation from @aisamu.
46
+ - Polish translation from @amielucha.
47
+ - Russian translation from @aishek.
48
+ - Czech translation from @h4vry.
49
+ - Slovak translation from @jkostolansky.
50
+
51
+ ### Changed
52
+
53
+ - Start using "changelog" over "change log" since it's the common usage.
54
+ - Start versioning based on the current English version at 0.3.0 to help
55
+ translation authors keep things up-to-date.
56
+ - Rewrite "What makes unicorns cry?" section.
57
+ - Rewrite "Ignoring Deprecations" sub-section to clarify the ideal scenario.
58
+ - Improve "Commit log diffs" sub-section to further argument against them.
59
+ - Merge "Why can’t people just use a git log diff?" with "Commit log diffs"
60
+ - Fix typos in Simplified Chinese and Traditional Chinese translations.
61
+ - Fix typos in Brazilian Portugese translation.
62
+ - Fix typos in Turkish translation.
63
+ - Fix typos in Czech translation.
64
+ - Fix typos in Swedish translation.
65
+ - Improve phrasing in French translation.
66
+ - Fix phrasing and spelling in German translation.
67
+
68
+ ### Removed
69
+
70
+ - Section about "changelog" vs "CHANGELOG".
71
+
72
+ ## [0.3.0] - 2015-12-03
73
+
74
+ ### Added
75
+
76
+ - RU translation from @aishek.
77
+ - pt-BR translation from @tallesl.
78
+ - es-ES translation from @ZeliosAriex.
79
+
80
+ ## [0.2.0] - 2015-10-06
81
+
82
+ ### Changed
83
+
84
+ - Remove exclusionary mentions of "open source" since this project can benefit
85
+ both "open" and "closed" source projects equally.
86
+
87
+ ## [0.1.0] - 2015-10-06
88
+
89
+ ### Added
90
+
91
+ - Answer "Should you ever rewrite a change log?".
92
+
93
+ ### Changed
94
+
95
+ - Improve argument against commit logs.
96
+ - Start following [SemVer](http://semver.org) properly.
97
+
98
+ ## [0.0.8] - 2015-02-17
99
+
100
+ ### Changed
101
+
102
+ - Update year to match in every README example.
103
+ - Reluctantly stop making fun of Brits only, since most of the world writes
104
+ dates in a strange way.
105
+
106
+ ### Fixed
107
+
108
+ - Fix typos in recent README changes.
109
+ - Update outdated unreleased diff link.
110
+
111
+ ## [0.0.7] - 2015-02-16
112
+
113
+ ### Added
114
+
115
+ - Link, and make it obvious that date format is ISO 8601.
116
+
117
+ ### Changed
118
+
119
+ - Clarified the section on "Is there a standard change log format?".
120
+
121
+ ### Fixed
122
+
123
+ - Fix Markdown links to tag comparison URL with footnote-style links.
124
+
125
+ ## [0.0.6] - 2014-12-12
126
+
127
+ ### Added
128
+
129
+ - README section on "yanked" releases.
130
+
131
+ ## [0.0.5] - 2014-08-09
132
+
133
+ ### Added
134
+
135
+ - Markdown links to version tags on release headings.
136
+ - Unreleased section to gather unreleased changes and encourage note keeping
137
+ prior to releases.
138
+
139
+ ## [0.0.4] - 2014-08-09
140
+
141
+ ### Added
142
+
143
+ - Better explanation of the difference between the file ("CHANGELOG") and its
144
+ function "the change log".
145
+
146
+ ### Changed
147
+
148
+ - Refer to a "change log" instead of a "CHANGELOG" throughout the site to
149
+ differentiate between the file and the purpose of the file — the logging of
150
+ changes.
151
+
152
+ ### Removed
153
+
154
+ - Remove empty sections from CHANGELOG, they occupy too much space and create
155
+ too much noise in the file. People will have to assume that the missing
156
+ sections were intentionally left out because they contained no notable
157
+ changes.
158
+
159
+ ## [0.0.3] - 2014-08-09
160
+
161
+ ### Added
162
+
163
+ - "Why should I care?" section mentioning The Changelog podcast.
164
+
165
+ ## [0.0.2] - 2014-07-10
166
+
167
+ ### Added
168
+
169
+ - Explanation of the recommended reverse chronological release ordering.
170
+
171
+ ## 0.0.1 - 2014-05-31
172
+
173
+ ### Added
174
+
175
+ - This CHANGELOG file to hopefully serve as an evolving example of a
176
+ standardized open source project CHANGELOG.
177
+ - CNAME file to enable GitHub Pages custom domain
178
+ - README now contains answers to common questions about CHANGELOGs
179
+ - Good examples and basic guidelines, including proper date formatting.
180
+ - Counter-examples: "What makes unicorns cry?"
181
+
182
+ [Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
183
+ [1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
184
+ [0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0
185
+ [0.2.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...v0.2.0
186
+ [0.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.8...v0.1.0
187
+ [0.0.8]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.7...v0.0.8
188
+ [0.0.7]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.6...v0.0.7
189
+ [0.0.6]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.5...v0.0.6
190
+ [0.0.5]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.4...v0.0.5
191
+ [0.0.4]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.3...v0.0.4
192
+ [0.0.3]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.2...v0.0.3
193
+ [0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2
194
+
195
+ ---
196
+
197
+ This is a footer
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
+ and this project adheres to [Semantic Versioning](http://semver.org/).
package/bin.js DELETED
@@ -1,128 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const url = require('url');
6
- const { parser, Changelog, Release } = require('./src');
7
- const argv = require('yargs-parser')(process.argv.slice(2), {
8
- default: {
9
- file: 'CHANGELOG.md',
10
- url: null,
11
- https: true,
12
- quiet: false,
13
- },
14
- boolean: ['https', 'init', 'latest-release', 'quiet'],
15
- });
16
-
17
- const file = path.join(process.cwd(), argv.file);
18
-
19
- try {
20
- if (argv.init) {
21
- const changelog = new Changelog('Changelog').addRelease(
22
- new Release('0.1.0', new Date(), 'First version')
23
- );
24
-
25
- save(file, changelog, true);
26
- process.exit(0);
27
- }
28
-
29
- const changelog = parser(fs.readFileSync(file, 'UTF-8'));
30
-
31
- if (argv.latestRelease) {
32
- const release = changelog.releases.find((release) => release.date && release.version);
33
-
34
- if (release) {
35
- console.log(release.version.toString());
36
- }
37
-
38
- process.exit(0);
39
- }
40
-
41
- if (argv.release) {
42
- const release = changelog.releases.find((release) => {
43
- if (release.date) {
44
- return false;
45
- }
46
-
47
- if (typeof argv.release === "string") {
48
- return !release.version || argv.release === release.version.toString();
49
- }
50
-
51
- return !!release.version;
52
- });
53
-
54
- if (release) {
55
- release.date = new Date();
56
- if (typeof argv.release === "string") {
57
- release.setVersion(argv.release);
58
- }
59
- } else {
60
- console.error("Not found any valid unreleased version");
61
- process.exit(1);
62
- }
63
- }
64
-
65
- if (!changelog.url && !argv.url) {
66
- const gitconfig = require('gitconfiglocal');
67
-
68
- gitconfig(process.cwd(), (err, config) => {
69
- if (err) {
70
- console.error(red(err));
71
- return;
72
- }
73
-
74
- changelog.url = getHttpUrl(
75
- config.remote && config.remote.origin && config.remote.origin.url
76
- );
77
- save(file, changelog);
78
- });
79
- } else {
80
- changelog.url = getHttpUrl(argv.url || changelog.url);
81
- save(file, changelog);
82
- }
83
- } catch (err) {
84
- console.error(red(err.message));
85
- if (!argv.quiet) {
86
- process.exit(1);
87
- }
88
- }
89
-
90
- function getHttpUrl(remoteUrl) {
91
- if (!remoteUrl) {
92
- return;
93
- }
94
-
95
- const parsed = url.parse(remoteUrl.replace('git@', `https://`));
96
-
97
- if (!argv.https) {
98
- parsed.protocol = 'http';
99
- }
100
-
101
- parsed.pathname = parsed.pathname.replace(/\.git$/, '').replace(/^\/\:/, '/');
102
-
103
- return url.format(parsed);
104
- }
105
-
106
- function save(file, changelog, isNew) {
107
- const url = changelog.url;
108
-
109
- if (url && url.includes('gitlab.com')) {
110
- changelog.head = 'master';
111
- }
112
-
113
- fs.writeFileSync(file, changelog.toString());
114
-
115
- if (isNew) {
116
- console.log(green('Generated new file'), file);
117
- } else {
118
- console.log(green('Updated file'), file);
119
- }
120
- }
121
-
122
- function red(message) {
123
- return '\u001b[' + 31 + 'm' + message + '\u001b[' + 39 + 'm';
124
- }
125
-
126
- function green(message) {
127
- return '\u001b[' + 32 + 'm' + message + '\u001b[' + 39 + 'm';
128
- }
package/src/Change.js DELETED
@@ -1,40 +0,0 @@
1
- class Change {
2
- constructor(title, description = '') {
3
- this.issues = [];
4
- this.title = Change.extractIssues(title, this.issues);
5
- this.description = Change.extractIssues(description, this.issues);
6
- }
7
-
8
- toString() {
9
- let t = this.title.split('\n').map((line) => ` ${line}`);
10
- t[0] = '-' + t[0].substr(1);
11
-
12
- if (this.description) {
13
- t.push('');
14
-
15
- t = t.concat(this.description.split('\n').map((line) => ` ${line}`));
16
- }
17
-
18
- return t.join('\n').trim();
19
- }
20
- }
21
-
22
- module.exports = Change;
23
-
24
- Change.extractIssues = function (text, issues) {
25
- return text
26
- .replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (matches, start, index) => {
27
- if (!issues.includes(index)) {
28
- issues.push(index);
29
- }
30
-
31
- return `${start}[#${index}]`;
32
- })
33
- .replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (matches, start, index) => {
34
- if (!issues.includes(index)) {
35
- issues.push(index);
36
- }
37
-
38
- return `${start}[#${index}]`;
39
- });
40
- };
package/src/Changelog.js DELETED
@@ -1,121 +0,0 @@
1
- const Release = require('./Release');
2
- const eq = require('semver/functions/eq');
3
-
4
- class Changelog {
5
- constructor(title, description = '') {
6
- this.title = title;
7
- this.description = description;
8
- this.head = 'HEAD';
9
- this.footer = null;
10
- this.url = null;
11
- this.releases = [];
12
- this.tagNameBuilder = null;
13
- }
14
-
15
- addRelease(release) {
16
- if (!(release instanceof Release)) {
17
- throw new Error('Invalid release. Must be an instance of Release');
18
- }
19
-
20
- this.releases.push(release);
21
- this.sortReleases();
22
- release.changelog = this;
23
-
24
- return this;
25
- }
26
-
27
- findRelease(version) {
28
- if (!version) {
29
- return this.releases.find((release) => !release.version);
30
- }
31
- return this.releases.find((release) => release.version && eq(release.version, version));
32
- }
33
-
34
- sortReleases() {
35
- this.releases.sort((a, b) => a.compare(b));
36
- }
37
-
38
- tagName(release) {
39
- if (this.tagNameBuilder) {
40
- return this.tagNameBuilder(release);
41
- }
42
-
43
- return `v${release.version}`;
44
- }
45
-
46
- toString() {
47
- const t = [`# ${this.title}`];
48
-
49
- const links = [];
50
- const compareLinks = [];
51
-
52
- const description =
53
- this.description.trim() ||
54
- `All notable changes to this project will be documented in this file.
55
-
56
- The format is based on [Keep a Changelog](http://keepachangelog.com/)
57
- and this project adheres to [Semantic Versioning](http://semver.org/).`;
58
-
59
- if (description) {
60
- t.push('');
61
- t.push(description);
62
- }
63
-
64
- this.releases.forEach((release) => {
65
- t.push('');
66
- t.push(release.toString(this));
67
-
68
- release.getLinks(this).forEach((link) => {
69
- if (!links.includes(link)) {
70
- links.push(link);
71
- }
72
- });
73
-
74
- const link = release.getCompareLink(this);
75
-
76
- if (link) {
77
- compareLinks.push(link);
78
- }
79
- });
80
-
81
- if (links.length) {
82
- t.push('');
83
- links.sort(compare);
84
- links.forEach((link) => t.push(link));
85
- }
86
-
87
- if (compareLinks.length) {
88
- t.push('');
89
-
90
- compareLinks.forEach((link) => t.push(link));
91
- }
92
-
93
- t.push('');
94
-
95
- if (this.footer) {
96
- t.push('---');
97
- t.push('');
98
- t.push(this.footer);
99
- t.push('');
100
- }
101
-
102
- return t.join('\n');
103
- }
104
- }
105
-
106
- module.exports = Changelog;
107
-
108
- function compare(a, b) {
109
- if (a === b) {
110
- return 0;
111
- }
112
- const reg = /^\[#(\d+)\]:/;
113
- const aNumber = a.match(reg);
114
- const bNumber = b.match(reg);
115
-
116
- if (aNumber && bNumber) {
117
- return parseInt(aNumber[1]) - parseInt(bNumber[1]);
118
- }
119
-
120
- return a < b ? -1 : 1;
121
- }