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
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,200 +7,7 @@ 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.10.4] - 2021-03-04
9
- ### Fixed
10
- - Allow to pass a version number to `--release` command [#18]
11
-
12
- ## [0.10.3] - 2021-01-09
13
- ### Fixed
14
- - Support for multiline links [#16]
15
-
16
- ## [0.10.2] - 2020-10-11
17
- ### Added
18
- - New command option --quiet added to cli [#14] [#15]
19
-
20
- ### Changed
21
- - `changelong` command will exit with code 1 if it fails to parse the changelog file
22
-
23
- ## [0.10.1] - 2020-05-04
24
- ### Added
25
- - New command --latest-release added to cli
26
- - New command --release added to cli
27
-
28
- ### Fixed
29
- - Removed trailing space in the default description generated with --init
30
- - Updated dependencies
31
-
32
- ## [0.10.0] - 2020-02-08
33
- ### Added
34
- - Documentation to extend `Release` class + test coverage [#12] [#13]
35
- - Ability to use extended `Release` within `parser` [#12] [#13]
36
-
37
- ### Fixed
38
- - Upgrade semver and mocha to the latest version
39
-
40
- ## [0.9.1] - 2019-11-26
41
- ### Fixed
42
- - Undefined function bug in CLI
43
-
44
- ## [0.9.0] - 2019-11-26
45
- ### Removed
46
- - Support for node < 10
47
-
48
- ## [0.8.2] - 2019-11-26
49
- ### Added
50
- - Allow to customize the HEAD branch to compare the unreleased versions
51
-
52
- ### Fixed
53
- - Compare with master branch in gitlab
54
- - Nested lists were flatten
55
- - Updated yargs-parser
56
-
57
- ## [0.8.1] - 2019-05-27
58
- ### Fixed
59
- - Support for more than one unreleased version
60
- - Updated semver to the latest version
61
-
62
- ## [0.8.0] - 2019-03-02
63
- ### Added
64
- - New property `Changelog.tagNameBuilder` to customize how the tag names are generated - [#10]
65
- - New `Release.setDate()` function - [#9]
66
-
67
- ### Fixed
68
- - Update `yargs-parser` dependency to v13.0.0
69
-
70
- ## [0.7.0] - 2018-11-29
71
- ### Changed
72
- - Removed some spaces before and after some titles to inline with the changelog format
73
-
74
- ## [0.6.7] - 2018-11-29
75
- ### Fixed
76
- - Fixed the links sorting to compare issues numerically instead alphabetically
77
-
78
- ## [0.6.6] - 2018-11-29
79
- ### Changed
80
- - Order the links alphabetically
81
-
82
- ## [0.6.5] - 2018-11-01
83
- ### Fixed
84
- - Updated issue autodetection to prevent unwanted extractions - [#7]
85
-
86
- ## [0.6.4] - 2018-09-03
87
- ### Added
88
- - Added `findRelease` function to `Changelog` for finding a release by version number - [#6]
89
- - Added `setVersion` function to `Release` for changing the version of a release - [#6]
90
-
91
- ## [0.6.3] - 2018-08-22
92
- ### Fixed
93
- - Fixed trailing newlines when no links are present - [#5]
94
- - Fixed case of unreleased version to match http://keepachangelog.com/ - [#4]
95
- - Fixed Release isEmpty and add tests - [#3]
96
-
97
- ## [0.6.2] - 2018-07-24
98
- ### Added
99
- - Support for unreleased versions (releases with version but without date)
100
-
101
- ## [0.6.1] - 2018-06-30
102
- ### Fixed
103
- - Prevent inserting duplicated links
104
-
105
- ## [0.6.0] - 2018-06-12
106
- ### Added
107
- - CLI Api: New option `--init`, to generate an empty CHANGELOG.md file
108
-
109
- ## [0.5.2] - 2018-05-12
110
- ### Fixed
111
- - Issues autodetection links
112
-
113
- ## [0.5.1] - 2018-05-12
114
- ### Fixed
115
- - Issues autodetection problems with texts like `#3.4`
116
- - Test execution was commented
117
-
118
- ## [0.5.0] - 2018-05-09
119
- ### Added
120
- - Allow to insert a footer at the end of the changelog
121
-
122
- ### Changed
123
- - Placed the urls of the issues at bottom
124
- - Indent automatically the extra lines of the changes
125
-
126
- ### Fixed
127
- - Parser refactoring
128
-
129
- ## [0.4.0] - 2018-03-22
130
- ### Added
131
- - Create links automatically to the issues
132
-
133
- ### Fixed
134
- - Use UTC date functions to fix decrement issue - [#1]
135
-
136
- ## [0.3.1] - 2017-12-11
137
- ### Added
138
- - CLI Api: New option `--file`, to change the filename used
139
- - CLI Api: New option `--url`, to set or change the project url
140
- - CLI Api: New option `--https`, to change the use of https in the url scheme
141
-
142
- ## [0.3.0] - 2017-12-08
143
- ### Added
144
- - Added colors in CLI
145
- - Parser errors contains the line number in the CHANGELOG file
146
-
147
- ### Fixed
148
- - Fixed parsing bug when the changelog is using incorrect title levels
149
-
150
- ## [0.2.0] - 2017-12-07
151
- ### Changed
152
- - Parser improvements
153
- - Changed the constructor arguments of Changelog, Change and Release classes
154
-
155
- ### Removed
156
- - Removed static factories. Use `new` instead.
157
-
158
- ### Fixed
159
- - The last version should't have diff link
160
-
161
- ## 0.1.0 - 2017-12-07
162
- First version
163
-
164
- [#1]: https://github.com/oscarotero/keep-a-changelog/issues/1
165
- [#3]: https://github.com/oscarotero/keep-a-changelog/issues/3
166
- [#4]: https://github.com/oscarotero/keep-a-changelog/issues/4
167
- [#5]: https://github.com/oscarotero/keep-a-changelog/issues/5
168
- [#6]: https://github.com/oscarotero/keep-a-changelog/issues/6
169
- [#7]: https://github.com/oscarotero/keep-a-changelog/issues/7
170
- [#9]: https://github.com/oscarotero/keep-a-changelog/issues/9
171
- [#10]: https://github.com/oscarotero/keep-a-changelog/issues/10
172
- [#12]: https://github.com/oscarotero/keep-a-changelog/issues/12
173
- [#13]: https://github.com/oscarotero/keep-a-changelog/issues/13
174
- [#14]: https://github.com/oscarotero/keep-a-changelog/issues/14
175
- [#15]: https://github.com/oscarotero/keep-a-changelog/issues/15
176
- [#16]: https://github.com/oscarotero/keep-a-changelog/issues/16
177
- [#18]: https://github.com/oscarotero/keep-a-changelog/issues/18
10
+ ## [2.0.0] - 2021-12-08
11
+ New version merging Deno and Node code. There are no changes.
178
12
 
179
- [0.10.4]: https://github.com/oscarotero/keep-a-changelog/compare/v0.10.3...v0.10.4
180
- [0.10.3]: https://github.com/oscarotero/keep-a-changelog/compare/v0.10.2...v0.10.3
181
- [0.10.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.10.1...v0.10.2
182
- [0.10.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.10.0...v0.10.1
183
- [0.10.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.9.1...v0.10.0
184
- [0.9.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.9.0...v0.9.1
185
- [0.9.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.2...v0.9.0
186
- [0.8.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.1...v0.8.2
187
- [0.8.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.8.0...v0.8.1
188
- [0.8.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.7.0...v0.8.0
189
- [0.7.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.7...v0.7.0
190
- [0.6.7]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.6...v0.6.7
191
- [0.6.6]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.5...v0.6.6
192
- [0.6.5]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.4...v0.6.5
193
- [0.6.4]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.3...v0.6.4
194
- [0.6.3]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.2...v0.6.3
195
- [0.6.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.1...v0.6.2
196
- [0.6.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.0...v0.6.1
197
- [0.6.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.2...v0.6.0
198
- [0.5.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.1...v0.5.2
199
- [0.5.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.5.0...v0.5.1
200
- [0.5.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.4.0...v0.5.0
201
- [0.4.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.3.1...v0.4.0
202
- [0.3.1]: https://github.com/oscarotero/keep-a-changelog/compare/v0.3.0...v0.3.1
203
- [0.3.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.2.0...v0.3.0
204
- [0.2.0]: https://github.com/oscarotero/keep-a-changelog/compare/v0.1.0...v0.2.0
13
+ [2.0.0]: https://github.com/oscarotero/keep-a-changelog/releases/tag/v2.0.0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 Oscar Otero
3
+ Copyright (c) 2020 Oscar Otero
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,25 +1,31 @@
1
- # keep-a-changelog
1
+ # Changelog
2
2
 
3
- [![Build Status](https://travis-ci.org/oscarotero/keep-a-changelog.svg?branch=master)](https://travis-ci.org/oscarotero/keep-a-changelog)
3
+ [Keep a Changelog](https://github.com/oscarotero/keep-a-changelog) library for
4
+ Node & Deno
4
5
 
5
- Node package to parse and generate changelogs following the [keepachangelog](http://keepachangelog.com/en/1.0.0/) format.
6
+ Deno package to parse and generate changelogs following the
7
+ [keepachangelog](http://keepachangelog.com/en/1.0.0/) format.
6
8
 
7
- ## Install
9
+ ## Usage in Node
8
10
 
9
- You can install it from the [npm repository](https://www.npmjs.com/package/keep-a-changelog) using npm/yarn:
11
+ ```js
12
+ import { parser } from "keep-a-changelog";
13
+ import fs from "fs";
10
14
 
11
- ```sh
12
- npm install keep-a-changelog
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
- const { parser } = require('keep-a-changelog');
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(fs.readFileSync('CHANGELOG.md', 'UTF-8'));
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
- const { Changelog, Release } = require('keep-a-changelog');
32
-
33
- const changelog = new Changelog('My project')
34
- .addRelease(
35
- new Release('0.1.0', '2017-12-06')
36
- .added('New awesome feature')
37
- .added('New other awesome feature')
38
- .fixed('Bug #3')
39
- .removed('Drop support for X')
40
- )
41
- .addRelease(
42
- new Release('0.2.0', '2017-12-09')
43
- .security('Fixed security vulnerability')
44
- .deprecated('Feature X is deprecated')
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 version `2.4.9` is `v2.4.9`. To change this behavior, set a new `tagNameBuilder`:
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 [keepachangelog](http://keepachangelog.com/en/1.0.0/) format, the change types are
61
- `Added`,
62
- `Changed`,
63
- `Deprecated`,
64
- `Removed`,
65
- `Fixed`,
66
- and `Security`.
67
- In case you'd like add another type in order to use is in your changelog, you basically need to extend the `Release` class to support new types. Additionally, you have to tell the `parser` that it should create instances of your new extended `Release` in order to parse your changelog correctly.
68
-
69
- For example, we would like to add a type `Maintenance`.
70
- Extend the provided `Release` class:
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
- constructor(version, date, description) {
74
- super(version, date, description);
75
- // add whatever types you want - in lowercase
76
- const newChangeTypes = [
77
- ['maintenance', []]
78
- ];
79
-
80
- this.changes = new Map([...this.changes, ...newChangeTypes]);
81
- }
82
- // for convenience, add a new method to add change of type 'maintanance'
83
- maintenance(change) {
84
- return this.addChange('maintenance', change);
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. It reads the CHANGELOG.md file and override it with the new 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 | Description
130
- -------|-------------
131
- `--file` | The markdown file of the changelog. The default value is `CHANGELOG.md`.
132
- `--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.
133
- `--https` | Set to false to use `http` instead `https` in the url (`--https=false`).
134
- `--init` | Init a new empty changelog file.
135
- `--latest-release` | Print the latest release version.
136
- `--release` | Updated the latest unreleased version with the current date.
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 |
package/esm/bin.js ADDED
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ import * as denoShim from "deno.ns";
3
+ import { join } from "./deps/deno_land/std_0.113.0/path/mod.js";
4
+ import { Changelog, parser, Release } from "./mod.js";
5
+ import { parse as parseFlag } from "./deps/deno_land/std_0.113.0/flags/mod.js";
6
+ import { parse as parseIni } from "./deps/deno_land/x/ini_v2.1.0/mod.js";
7
+ const argv = parseFlag(denoShim.Deno.args, {
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
+ const file = join(denoShim.Deno.cwd(), argv.file);
17
+ try {
18
+ if (argv.init) {
19
+ const changelog = new Changelog("Changelog").addRelease(new Release("0.1.0", new Date(), "First version"));
20
+ save(file, changelog, true);
21
+ denoShim.Deno.exit(0);
22
+ }
23
+ const changelog = parser(denoShim.Deno.readTextFileSync(file));
24
+ if (argv.latestRelease) {
25
+ const release = changelog.releases.find((release) => release.date && release.version);
26
+ if (release) {
27
+ console.log(release.version?.toString());
28
+ }
29
+ denoShim.Deno.exit(0);
30
+ }
31
+ if (argv.release) {
32
+ const release = changelog.releases.find((release) => {
33
+ if (release.date) {
34
+ return false;
35
+ }
36
+ if (typeof argv.release === "string") {
37
+ return !release.version || argv.release === release.version.toString();
38
+ }
39
+ return !!release.version;
40
+ });
41
+ if (release) {
42
+ release.date = new Date();
43
+ if (typeof argv.release === "string") {
44
+ release.setVersion(argv.release);
45
+ }
46
+ }
47
+ else {
48
+ console.error("Not found any valid unreleased version");
49
+ denoShim.Deno.exit(1);
50
+ }
51
+ }
52
+ if (!changelog.url) {
53
+ if (argv.url) {
54
+ changelog.url = argv.url;
55
+ }
56
+ else {
57
+ const url = getRemoteUrl(argv.https);
58
+ if (url) {
59
+ changelog.url = url;
60
+ }
61
+ else {
62
+ console.error(red('Please, set the repository url with --url="https://github.com/username/repository"'));
63
+ denoShim.Deno.exit(1);
64
+ }
65
+ }
66
+ }
67
+ save(file, changelog);
68
+ }
69
+ catch (err) {
70
+ console.error(red(err.message));
71
+ if (!argv.quiet) {
72
+ denoShim.Deno.exit(1);
73
+ }
74
+ }
75
+ function save(file, changelog, isNew = false) {
76
+ const url = changelog.url;
77
+ if (url && url.includes("gitlab.com")) {
78
+ changelog.head = "master";
79
+ }
80
+ denoShim.Deno.writeTextFileSync(file, changelog.toString());
81
+ if (isNew) {
82
+ console.log(green("Generated new file"), file);
83
+ }
84
+ else {
85
+ console.log(green("Updated file"), file);
86
+ }
87
+ }
88
+ function red(message) {
89
+ return "\u001b[" + 31 + "m" + message + "\u001b[" + 39 + "m";
90
+ }
91
+ function green(message) {
92
+ return "\u001b[" + 32 + "m" + message + "\u001b[" + 39 + "m";
93
+ }
94
+ function getRemoteUrl(https = true) {
95
+ try {
96
+ const file = join(denoShim.Deno.cwd(), ".git", "config");
97
+ const content = denoShim.Deno.readTextFileSync(file);
98
+ const data = parseIni(content);
99
+ const url = data?.['remote "origin"']?.url;
100
+ if (!url) {
101
+ return;
102
+ }
103
+ const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2"));
104
+ if (https) {
105
+ remoteUrl.protocol = "https:";
106
+ }
107
+ return remoteUrl.href;
108
+ }
109
+ catch (err) {
110
+ console.error(red(err.message));
111
+ // Ignore
112
+ }
113
+ }
@@ -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 denoShim from "deno.ns";
2
+ export const osType = (() => {
3
+ // deno-lint-ignore no-explicit-any
4
+ const { Deno } = ({ ...denoShim, ...globalThis });
5
+ if (typeof Deno?.build?.os === "string") {
6
+ return Deno.build.os;
7
+ }
8
+ // deno-lint-ignore no-explicit-any
9
+ const { navigator } = ({ ...denoShim, ...globalThis });
10
+ if (navigator?.appVersion?.includes?.("Win") ?? false) {
11
+ return "windows";
12
+ }
13
+ return "linux";
14
+ })();
15
+ export const isWindows = osType === "windows";