keep-a-changelog 2.0.1 → 2.2.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 +28 -2
- package/README.md +21 -6
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/bin.js +9 -4
- package/esm/deps/deno.land/std@0.173.0/_util/asserts.js +21 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/_util/os.js +4 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/flags/mod.js +145 -36
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_constants.js +1 -0
- package/esm/deps/deno.land/std@0.173.0/path/_interface.js +3 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_util.js +1 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/common.js +1 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/glob.js +1 -1
- package/esm/deps/deno.land/std@0.173.0/path/mod.js +32 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/posix.js +23 -16
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/separator.js +1 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/win32.js +20 -15
- package/esm/deps/{deno_land/x/semver_v1.4.0 → deno.land/std@0.173.0/semver}/mod.js +227 -334
- package/esm/deps/{deno_land/std_0.51.0 → deno.land/std@0.51.0}/fs/eol.js +0 -0
- package/esm/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/ini.js +1 -1
- package/esm/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/mod.js +0 -0
- package/esm/mod.js +1 -0
- package/esm/src/Change.js +15 -15
- package/esm/src/Changelog.js +9 -1
- package/esm/src/Release.js +21 -4
- package/esm/src/deps.js +1 -1
- package/esm/src/parser.js +24 -5
- package/esm/test/changelog.custom.type.md +0 -1
- package/esm/test/changelog.expected.linted.md +208 -0
- package/esm/test/changelog.expected.md +6 -4
- package/esm/test/changelog.md +7 -3
- package/esm/test/empty.expected.md +0 -1
- package/package.json +13 -8
- package/script/_dnt.polyfills.js +16 -0
- package/script/_dnt.shims.js +66 -0
- package/script/bin.js +144 -0
- package/script/deps/deno.land/std@0.173.0/_util/asserts.js +27 -0
- package/script/deps/deno.land/std@0.173.0/_util/os.js +44 -0
- package/script/deps/deno.land/std@0.173.0/flags/mod.js +368 -0
- package/script/deps/deno.land/std@0.173.0/path/_constants.js +49 -0
- package/script/deps/deno.land/std@0.173.0/path/_interface.js +4 -0
- package/script/deps/deno.land/std@0.173.0/path/_util.js +125 -0
- package/script/deps/deno.land/std@0.173.0/path/common.js +40 -0
- package/script/deps/deno.land/std@0.173.0/path/glob.js +391 -0
- package/script/deps/deno.land/std@0.173.0/path/mod.js +63 -0
- package/script/deps/deno.land/std@0.173.0/path/posix.js +539 -0
- package/script/deps/deno.land/std@0.173.0/path/separator.js +8 -0
- package/script/deps/deno.land/std@0.173.0/path/win32.js +1007 -0
- package/script/deps/deno.land/std@0.173.0/semver/mod.js +1458 -0
- package/script/deps/deno.land/std@0.51.0/fs/eol.js +34 -0
- package/script/deps/deno.land/x/ini@v2.1.0/ini.js +256 -0
- package/script/deps/deno.land/x/ini@v2.1.0/mod.js +17 -0
- package/script/mod.js +15 -0
- package/{umd → script}/package.json +0 -0
- package/script/src/Change.js +51 -0
- package/script/src/Changelog.js +148 -0
- package/script/src/Release.js +227 -0
- package/script/src/deps.js +9 -0
- package/script/src/parser.js +184 -0
- package/{umd → script}/test/changelog.custom.type.md +0 -1
- package/script/test/changelog.expected.linted.md +208 -0
- package/{umd → script}/test/changelog.expected.md +6 -4
- package/{umd → script}/test/changelog.md +7 -3
- package/{umd → script}/test/empty.expected.md +0 -1
- package/types/_dnt.polyfills.d.ts +11 -0
- package/types/_dnt.shims.d.ts +0 -4
- package/types/bin.d.ts +1 -1
- package/types/deps/deno.land/std@0.173.0/_util/asserts.d.ts +10 -0
- package/types/deps/deno.land/std@0.173.0/_util/os.d.ts +4 -0
- package/types/deps/deno.land/std@0.173.0/flags/mod.d.ts +166 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_constants.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_interface.d.ts +1 -1
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_util.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/common.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/glob.d.ts +10 -5
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/mod.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/posix.d.ts +9 -5
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/separator.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/win32.d.ts +7 -5
- package/types/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/types/deps/{deno_land/std_0.51.0 → deno.land/std@0.51.0}/fs/eol.d.ts +0 -0
- package/types/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/ini.d.ts +0 -0
- package/types/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/mod.d.ts +0 -0
- package/types/mod.d.ts +1 -0
- package/types/src/Changelog.d.ts +1 -0
- package/types/src/Release.d.ts +2 -0
- package/types/src/deps.d.ts +1 -1
- package/esm/deps/deno_land/std_0.120.0/_util/assert.js +0 -13
- package/esm/deps/deno_land/std_0.120.0/path/_interface.js +0 -3
- package/esm/deps/deno_land/std_0.120.0/path/mod.js +0 -14
- package/types/deps/deno_land/std_0.120.0/_util/assert.d.ts +0 -5
- package/types/deps/deno_land/std_0.120.0/_util/os.d.ts +0 -3
- package/types/deps/deno_land/std_0.120.0/flags/mod.d.ts +0 -50
- package/types/deps/deno_land/x/semver_v1.4.0/mod.d.ts +0 -116
- package/umd/_dnt.shims.js +0 -76
- package/umd/bin.js +0 -145
- package/umd/deps/deno_land/std_0.120.0/_util/assert.js +0 -28
- package/umd/deps/deno_land/std_0.120.0/_util/os.js +0 -47
- package/umd/deps/deno_land/std_0.120.0/flags/mod.js +0 -269
- package/umd/deps/deno_land/std_0.120.0/path/_constants.js +0 -58
- package/umd/deps/deno_land/std_0.120.0/path/_interface.js +0 -14
- package/umd/deps/deno_land/std_0.120.0/path/_util.js +0 -134
- package/umd/deps/deno_land/std_0.120.0/path/common.js +0 -50
- package/umd/deps/deno_land/std_0.120.0/path/glob.js +0 -397
- package/umd/deps/deno_land/std_0.120.0/path/mod.js +0 -51
- package/umd/deps/deno_land/std_0.120.0/path/posix.js +0 -538
- package/umd/deps/deno_land/std_0.120.0/path/separator.js +0 -18
- package/umd/deps/deno_land/std_0.120.0/path/win32.js +0 -1008
- package/umd/deps/deno_land/std_0.51.0/fs/eol.js +0 -44
- package/umd/deps/deno_land/x/ini_v2.1.0/ini.js +0 -262
- package/umd/deps/deno_land/x/ini_v2.1.0/mod.js +0 -23
- package/umd/deps/deno_land/x/semver_v1.4.0/mod.js +0 -1578
- package/umd/mod.js +0 -24
- package/umd/src/Change.js +0 -61
- package/umd/src/Changelog.js +0 -150
- package/umd/src/Release.js +0 -220
- package/umd/src/deps.js +0 -19
- package/umd/src/parser.js +0 -175
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const deps_js_1 = require("./deps.js");
|
|
7
|
+
const Change_js_1 = __importDefault(require("./Change.js"));
|
|
8
|
+
class Release {
|
|
9
|
+
constructor(version, date, description = "") {
|
|
10
|
+
Object.defineProperty(this, "changelog", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "version", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "date", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "yanked", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: false
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "description", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "changes", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: void 0
|
|
45
|
+
});
|
|
46
|
+
this.setVersion(version);
|
|
47
|
+
this.setDate(date);
|
|
48
|
+
this.description = description;
|
|
49
|
+
this.changes = new Map([
|
|
50
|
+
["added", []],
|
|
51
|
+
["changed", []],
|
|
52
|
+
["deprecated", []],
|
|
53
|
+
["removed", []],
|
|
54
|
+
["fixed", []],
|
|
55
|
+
["security", []],
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
compare(release) {
|
|
59
|
+
if (!this.version && release.version) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
if (!release.version) {
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
if (!this.date && release.date) {
|
|
66
|
+
return -1;
|
|
67
|
+
}
|
|
68
|
+
if (!release.date) {
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
if (this.version && release.version) {
|
|
72
|
+
return -this.version.compare(release.version);
|
|
73
|
+
}
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
isEmpty() {
|
|
77
|
+
if (this.description.trim()) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return Array.from(this.changes.values()).every((change) => !change.length);
|
|
81
|
+
}
|
|
82
|
+
setVersion(version) {
|
|
83
|
+
if (typeof version === "string") {
|
|
84
|
+
version = new deps_js_1.Semver(version);
|
|
85
|
+
}
|
|
86
|
+
this.version = version;
|
|
87
|
+
//Re-sort the releases of the parent changelog
|
|
88
|
+
if (this.changelog) {
|
|
89
|
+
this.changelog.sortReleases();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
setDate(date) {
|
|
93
|
+
if (typeof date === "string") {
|
|
94
|
+
date = new Date(date);
|
|
95
|
+
}
|
|
96
|
+
this.date = date;
|
|
97
|
+
}
|
|
98
|
+
setYanked(yanked = true) {
|
|
99
|
+
this.yanked = yanked;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
addChange(type, change) {
|
|
103
|
+
if (!(change instanceof Change_js_1.default)) {
|
|
104
|
+
change = new Change_js_1.default(change);
|
|
105
|
+
}
|
|
106
|
+
if (!this.changes.has(type)) {
|
|
107
|
+
throw new Error("Invalid change type");
|
|
108
|
+
}
|
|
109
|
+
this.changes.get(type).push(change);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
added(change) {
|
|
113
|
+
return this.addChange("added", change);
|
|
114
|
+
}
|
|
115
|
+
changed(change) {
|
|
116
|
+
return this.addChange("changed", change);
|
|
117
|
+
}
|
|
118
|
+
deprecated(change) {
|
|
119
|
+
return this.addChange("deprecated", change);
|
|
120
|
+
}
|
|
121
|
+
removed(change) {
|
|
122
|
+
return this.addChange("removed", change);
|
|
123
|
+
}
|
|
124
|
+
fixed(change) {
|
|
125
|
+
return this.addChange("fixed", change);
|
|
126
|
+
}
|
|
127
|
+
security(change) {
|
|
128
|
+
return this.addChange("security", change);
|
|
129
|
+
}
|
|
130
|
+
toString(changelog) {
|
|
131
|
+
let t = [];
|
|
132
|
+
const hasCompareLink = this.getCompareLink(changelog) !== undefined;
|
|
133
|
+
const yanked = this.yanked ? " [YANKED]" : "";
|
|
134
|
+
if (this.version) {
|
|
135
|
+
if (hasCompareLink) {
|
|
136
|
+
t.push(`## [${this.version}] - ${formatDate(this.date)}${yanked}`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
t.push(`## ${this.version} - ${formatDate(this.date)}${yanked}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
if (hasCompareLink) {
|
|
144
|
+
t.push(`## [Unreleased]${yanked}`);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
t.push(`## Unreleased${yanked}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (changelog?.format === "markdownlint") {
|
|
151
|
+
t.push("");
|
|
152
|
+
}
|
|
153
|
+
if (this.description.trim()) {
|
|
154
|
+
t.push(this.description.trim());
|
|
155
|
+
t.push("");
|
|
156
|
+
}
|
|
157
|
+
this.changes.forEach((changes, type) => {
|
|
158
|
+
if (changes.length) {
|
|
159
|
+
t.push(`### ${type[0].toUpperCase()}${type.substring(1)}`);
|
|
160
|
+
if (changelog?.format === "markdownlint") {
|
|
161
|
+
t.push("");
|
|
162
|
+
}
|
|
163
|
+
t = t.concat(changes.map((change) => change.toString()));
|
|
164
|
+
t.push("");
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return t.join("\n").trim();
|
|
168
|
+
}
|
|
169
|
+
getCompareLink(changelog) {
|
|
170
|
+
if (!changelog?.url) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const index = changelog.releases.indexOf(this);
|
|
174
|
+
if (index === -1) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
let offset = 1;
|
|
178
|
+
let previous = changelog.releases[index + offset];
|
|
179
|
+
while (previous && !previous.date) {
|
|
180
|
+
++offset;
|
|
181
|
+
previous = changelog.releases[index + offset];
|
|
182
|
+
}
|
|
183
|
+
if (!previous) {
|
|
184
|
+
if (!this.version || !this.date) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
return `[${this.version}]: ${changelog.url}/releases/tag/${changelog.tagName(this)}`;
|
|
188
|
+
}
|
|
189
|
+
if (!this.version) {
|
|
190
|
+
return `[Unreleased]: ${changelog.url}/compare/${changelog.tagName(previous)}...${changelog.head}`;
|
|
191
|
+
}
|
|
192
|
+
if (!this.date) {
|
|
193
|
+
return `[${this.version}]: ${changelog.url}/compare/${changelog.tagName(previous)}...${changelog.head}`;
|
|
194
|
+
}
|
|
195
|
+
return `[${this.version}]: ${changelog.url}/compare/${changelog.tagName(previous)}...${changelog.tagName(this)}`;
|
|
196
|
+
}
|
|
197
|
+
getLinks(changelog) {
|
|
198
|
+
const links = [];
|
|
199
|
+
if (!changelog.url) {
|
|
200
|
+
return links;
|
|
201
|
+
}
|
|
202
|
+
this.changes.forEach((changes) => changes.forEach((change) => {
|
|
203
|
+
change.issues.forEach((issue) => {
|
|
204
|
+
if (!links.includes(issue)) {
|
|
205
|
+
links.push(`[#${issue}]: ${changelog.url}/issues/${issue}`);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}));
|
|
209
|
+
return links;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
exports.default = Release;
|
|
213
|
+
function formatDate(date) {
|
|
214
|
+
if (!date) {
|
|
215
|
+
return "Unreleased";
|
|
216
|
+
}
|
|
217
|
+
const year = date.getUTCFullYear();
|
|
218
|
+
let month = date.getUTCMonth() + 1;
|
|
219
|
+
let day = date.getUTCDate();
|
|
220
|
+
if (month < 10) {
|
|
221
|
+
month = "0" + month;
|
|
222
|
+
}
|
|
223
|
+
if (day < 10) {
|
|
224
|
+
day = "0" + day;
|
|
225
|
+
}
|
|
226
|
+
return `${year}-${month}-${day}`;
|
|
227
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.eq = exports.Semver = void 0;
|
|
7
|
+
var mod_js_1 = require("../deps/deno.land/std@0.173.0/semver/mod.js");
|
|
8
|
+
Object.defineProperty(exports, "Semver", { enumerable: true, get: function () { return __importDefault(mod_js_1).default; } });
|
|
9
|
+
Object.defineProperty(exports, "eq", { enumerable: true, get: function () { return mod_js_1.eq; } });
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Changelog_js_1 = __importDefault(require("./Changelog.js"));
|
|
7
|
+
const Release_js_1 = __importDefault(require("./Release.js"));
|
|
8
|
+
const defaultOptions = {
|
|
9
|
+
releaseCreator: (version, date, description) => new Release_js_1.default(version, date, description),
|
|
10
|
+
};
|
|
11
|
+
/** Parse a markdown string */
|
|
12
|
+
function parser(markdown, options) {
|
|
13
|
+
const opts = Object.assign({}, defaultOptions, options);
|
|
14
|
+
const tokens = tokenize(markdown);
|
|
15
|
+
try {
|
|
16
|
+
return processTokens(tokens, opts);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(`Parse error in the line ${tokens[0][0]}: ${error.message}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = parser;
|
|
23
|
+
/** Process an array of tokens to build the Changelog */
|
|
24
|
+
function processTokens(tokens, opts) {
|
|
25
|
+
const changelog = new Changelog_js_1.default("");
|
|
26
|
+
changelog.flag = getContent(tokens, "flag");
|
|
27
|
+
changelog.title = getContent(tokens, "h1", true);
|
|
28
|
+
changelog.description = getTextContent(tokens);
|
|
29
|
+
//Releases
|
|
30
|
+
let release;
|
|
31
|
+
while ((release = getContent(tokens, "h2").toLowerCase())) {
|
|
32
|
+
const matches = release.match(/\[?([^\]]+)\]?\s*-\s*([\d]{4}-[\d]{1,2}-[\d]{1,2})(\s+\[yanked\])?$/);
|
|
33
|
+
if (matches) {
|
|
34
|
+
release = opts.releaseCreator(matches[1], matches[2]);
|
|
35
|
+
release.yanked = !!matches[3];
|
|
36
|
+
}
|
|
37
|
+
else if (release.includes("unreleased")) {
|
|
38
|
+
const matches = release.match(/\[?([^\]]+)\]?\s*-\s*unreleased(\s+\[yanked\])?$/);
|
|
39
|
+
const yanked = release.includes("[yanked]");
|
|
40
|
+
release = matches
|
|
41
|
+
? opts.releaseCreator(matches[1])
|
|
42
|
+
: opts.releaseCreator();
|
|
43
|
+
release.yanked = yanked;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(`Syntax error in the release title`);
|
|
47
|
+
}
|
|
48
|
+
changelog.addRelease(release);
|
|
49
|
+
release.description = getTextContent(tokens);
|
|
50
|
+
let type;
|
|
51
|
+
while ((type = getContent(tokens, "h3").toLowerCase())) {
|
|
52
|
+
let change;
|
|
53
|
+
while ((change = getContent(tokens, "li"))) {
|
|
54
|
+
release.addChange(type, change);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//Skip release links
|
|
59
|
+
let link = getContent(tokens, "link");
|
|
60
|
+
while (link) {
|
|
61
|
+
if (!changelog.url) {
|
|
62
|
+
const matches = link.match(/^\[.*\]\:\s*(http.*)\/compare\/.*$/);
|
|
63
|
+
if (matches) {
|
|
64
|
+
changelog.url = matches[1];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
link = getContent(tokens, "link");
|
|
68
|
+
}
|
|
69
|
+
//Footer
|
|
70
|
+
if (getContent(tokens, "hr")) {
|
|
71
|
+
changelog.footer = getContent(tokens, "p");
|
|
72
|
+
}
|
|
73
|
+
if (tokens.length) {
|
|
74
|
+
throw new Error(`Unexpected content ${JSON.stringify(tokens)}`);
|
|
75
|
+
}
|
|
76
|
+
return changelog;
|
|
77
|
+
}
|
|
78
|
+
/** Returns the content of a token */
|
|
79
|
+
function getContent(tokens, type, required = false) {
|
|
80
|
+
const types = Array.isArray(type) ? type : [type];
|
|
81
|
+
if (!tokens[0] || types.indexOf(tokens[0][1]) === -1) {
|
|
82
|
+
if (required) {
|
|
83
|
+
throw new Error(`Required token missing in: "${tokens[0][0]}"`);
|
|
84
|
+
}
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
return tokens.shift()[2].join("\n");
|
|
88
|
+
}
|
|
89
|
+
/** Return the next text content */
|
|
90
|
+
function getTextContent(tokens) {
|
|
91
|
+
const lines = [];
|
|
92
|
+
const types = ["p", "li"];
|
|
93
|
+
while (tokens[0] && types.indexOf(tokens[0][1]) !== -1) {
|
|
94
|
+
const token = tokens.shift();
|
|
95
|
+
if (token[1] === "li") {
|
|
96
|
+
lines.push("- " + token[2].join("\n"));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
lines.push(token[2].join("\n"));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return lines.join("\n");
|
|
103
|
+
}
|
|
104
|
+
/** Tokenize a markdown string */
|
|
105
|
+
function tokenize(markdown) {
|
|
106
|
+
const tokens = [];
|
|
107
|
+
markdown
|
|
108
|
+
.trim()
|
|
109
|
+
.split("\n")
|
|
110
|
+
.map((line, index, allLines) => {
|
|
111
|
+
const lineNumber = index + 1;
|
|
112
|
+
if (line.startsWith("---")) {
|
|
113
|
+
return [lineNumber, "hr", ["-"]];
|
|
114
|
+
}
|
|
115
|
+
if (line.startsWith("# ")) {
|
|
116
|
+
return [lineNumber, "h1", [line.substr(1).trim()]];
|
|
117
|
+
}
|
|
118
|
+
if (line.startsWith("## ")) {
|
|
119
|
+
return [lineNumber, "h2", [line.substr(2).trim()]];
|
|
120
|
+
}
|
|
121
|
+
if (line.startsWith("### ")) {
|
|
122
|
+
return [lineNumber, "h3", [line.substr(3).trim()]];
|
|
123
|
+
}
|
|
124
|
+
if (line.startsWith("-")) {
|
|
125
|
+
return [lineNumber, "li", [line.substr(1).trim()]];
|
|
126
|
+
}
|
|
127
|
+
if (line.startsWith("*")) {
|
|
128
|
+
return [lineNumber, "li", [line.substr(1).trim()]];
|
|
129
|
+
}
|
|
130
|
+
if (line.match(/^\[.*\]\:\s*http.*$/)) {
|
|
131
|
+
return [lineNumber, "link", [line.trim()]];
|
|
132
|
+
}
|
|
133
|
+
if (line.match(/^\[.*\]\:$/)) {
|
|
134
|
+
const nextLine = allLines[index + 1];
|
|
135
|
+
if (nextLine && nextLine.match(/\s+http.*$/)) {
|
|
136
|
+
// We found a multi-line link: treat it like a single line
|
|
137
|
+
allLines[index + 1] = "";
|
|
138
|
+
return [lineNumber, "link", [
|
|
139
|
+
line.trim() + "\n" + nextLine.trimEnd(),
|
|
140
|
+
]];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const result = line.match(/^<!--(.*)-->$/);
|
|
144
|
+
if (result) {
|
|
145
|
+
return [lineNumber, "flag", [result[1].trim()]];
|
|
146
|
+
}
|
|
147
|
+
return [lineNumber, "p", [line.trimEnd()]];
|
|
148
|
+
})
|
|
149
|
+
.forEach((line, index) => {
|
|
150
|
+
const [lineNumber, type, [content]] = line;
|
|
151
|
+
if (index > 0) {
|
|
152
|
+
const prevType = tokens[0][1];
|
|
153
|
+
if (type === "p") {
|
|
154
|
+
if (prevType === "p") {
|
|
155
|
+
return tokens[0][2].push(content);
|
|
156
|
+
}
|
|
157
|
+
if (prevType === "li") {
|
|
158
|
+
return tokens[0][2].push(content.replace(/^\s\s/, ""));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
tokens.unshift([lineNumber, type, [content]]);
|
|
163
|
+
});
|
|
164
|
+
return tokens
|
|
165
|
+
.filter((token) => !isEmpty(token[2]))
|
|
166
|
+
.map((token) => {
|
|
167
|
+
const content = token[2];
|
|
168
|
+
while (isEmpty(content[content.length - 1])) {
|
|
169
|
+
content.pop();
|
|
170
|
+
}
|
|
171
|
+
while (isEmpty(content[0])) {
|
|
172
|
+
content.shift();
|
|
173
|
+
}
|
|
174
|
+
return token;
|
|
175
|
+
})
|
|
176
|
+
.reverse();
|
|
177
|
+
}
|
|
178
|
+
/** Check if a string or array is empty */
|
|
179
|
+
function isEmpty(val) {
|
|
180
|
+
if (Array.isArray(val)) {
|
|
181
|
+
val = val.join("");
|
|
182
|
+
}
|
|
183
|
+
return !val || val.trim() === "";
|
|
184
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
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] [YANKED]
|
|
10
|
+
|
|
11
|
+
This is a brand new releases with:
|
|
12
|
+
- Configuration is now done within the Web client, for authorized users.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Test
|
|
17
|
+
|
|
18
|
+
## [2.0.0] - Unreleased [YANKED]
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- None
|
|
23
|
+
- Test with issue link [#1]
|
|
24
|
+
- Test with issue link [#4] in the middle of the text
|
|
25
|
+
- [#3] Test with issue link in the beginning of the text
|
|
26
|
+
- Test with issue dot [#2], [#10].
|
|
27
|
+
- Test with no issue link #123b
|
|
28
|
+
- Test with `package#2.0`
|
|
29
|
+
|
|
30
|
+
## [1.0.0] - 2017-06-20
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- New visual identity by @tylerfortune8.
|
|
35
|
+
- Version navigation.
|
|
36
|
+
- Links to latest released version in previous versions.
|
|
37
|
+
- "Why keep a changelog?" section.
|
|
38
|
+
- "Who needs a changelog?" section.
|
|
39
|
+
- "How do I make a changelog?" section.
|
|
40
|
+
- "Frequently Asked Questions" section.
|
|
41
|
+
- New "Guiding Principles" sub-section to "How do I make a changelog?".
|
|
42
|
+
- Simplified and Traditional Chinese translations from @tianshuo.
|
|
43
|
+
- German translation from @mpbzh & @Art4.
|
|
44
|
+
- Italian translation from @azkidenz.
|
|
45
|
+
- Swedish translation from @magol.
|
|
46
|
+
- Turkish translation from @karalamalar.
|
|
47
|
+
- French translation from @zapashcanon.
|
|
48
|
+
- Brazilian Portugese translation from @aisamu.
|
|
49
|
+
- Polish translation from @amielucha.
|
|
50
|
+
- Russian translation from @aishek.
|
|
51
|
+
- Czech translation from @h4vry.
|
|
52
|
+
- Slovak translation from @jkostolansky.
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- Start using "changelog" over "change log" since it's the common usage.
|
|
57
|
+
- Start versioning based on the current English version at 0.3.0 to help
|
|
58
|
+
translation authors keep things up-to-date.
|
|
59
|
+
- Rewrite "What makes unicorns cry?" section.
|
|
60
|
+
- Rewrite "Ignoring Deprecations" sub-section to clarify the ideal scenario.
|
|
61
|
+
- Improve "Commit log diffs" sub-section to further argument against them.
|
|
62
|
+
- Merge "Why can’t people just use a git log diff?" with "Commit log diffs"
|
|
63
|
+
- Fix typos in Simplified Chinese and Traditional Chinese translations.
|
|
64
|
+
- Fix typos in Brazilian Portugese translation.
|
|
65
|
+
- Fix typos in Turkish translation.
|
|
66
|
+
- Fix typos in Czech translation.
|
|
67
|
+
- Fix typos in Swedish translation.
|
|
68
|
+
- Improve phrasing in French translation.
|
|
69
|
+
- Fix phrasing and spelling in German translation.
|
|
70
|
+
|
|
71
|
+
### Removed
|
|
72
|
+
|
|
73
|
+
- Section about "changelog" vs "CHANGELOG".
|
|
74
|
+
|
|
75
|
+
## [0.3.0] - 2015-12-03
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- RU translation from @aishek.
|
|
80
|
+
- pt-BR translation from @tallesl.
|
|
81
|
+
- es-ES translation from @ZeliosAriex.
|
|
82
|
+
|
|
83
|
+
## [0.2.0] - 2015-10-06
|
|
84
|
+
|
|
85
|
+
### Changed
|
|
86
|
+
|
|
87
|
+
- Remove exclusionary mentions of "open source" since this project can benefit
|
|
88
|
+
both "open" and "closed" source projects equally.
|
|
89
|
+
|
|
90
|
+
## [0.1.0] - 2015-10-06
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
|
|
94
|
+
- Answer "Should you ever rewrite a change log?".
|
|
95
|
+
|
|
96
|
+
### Changed
|
|
97
|
+
|
|
98
|
+
- Improve argument against commit logs.
|
|
99
|
+
- Start following [SemVer](http://semver.org) properly.
|
|
100
|
+
|
|
101
|
+
## [0.0.8] - 2015-02-17
|
|
102
|
+
|
|
103
|
+
### Changed
|
|
104
|
+
|
|
105
|
+
- Update year to match in every README example.
|
|
106
|
+
- Reluctantly stop making fun of Brits only, since most of the world writes
|
|
107
|
+
dates in a strange way.
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- Fix typos in recent README changes.
|
|
112
|
+
- Update outdated unreleased diff link.
|
|
113
|
+
|
|
114
|
+
## [0.0.7] - 2015-02-16
|
|
115
|
+
|
|
116
|
+
### Added
|
|
117
|
+
|
|
118
|
+
- Link, and make it obvious that date format is ISO 8601.
|
|
119
|
+
|
|
120
|
+
### Changed
|
|
121
|
+
|
|
122
|
+
- Clarified the section on "Is there a standard change log format?".
|
|
123
|
+
|
|
124
|
+
### Fixed
|
|
125
|
+
|
|
126
|
+
- Fix Markdown links to tag comparison URL with footnote-style links.
|
|
127
|
+
|
|
128
|
+
## [0.0.6] - 2014-12-12 [YANKED]
|
|
129
|
+
|
|
130
|
+
### Added
|
|
131
|
+
|
|
132
|
+
- README section on "yanked" releases.
|
|
133
|
+
|
|
134
|
+
## [0.0.5] - 2014-08-09
|
|
135
|
+
|
|
136
|
+
### Added
|
|
137
|
+
|
|
138
|
+
- Markdown links to version tags on release headings.
|
|
139
|
+
- Unreleased section to gather unreleased changes and encourage note keeping
|
|
140
|
+
prior to releases.
|
|
141
|
+
|
|
142
|
+
## [0.0.4] - 2014-08-09
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
|
|
146
|
+
- Better explanation of the difference between the file ("CHANGELOG") and its
|
|
147
|
+
function "the change log".
|
|
148
|
+
|
|
149
|
+
### Changed
|
|
150
|
+
|
|
151
|
+
- Refer to a "change log" instead of a "CHANGELOG" throughout the site to
|
|
152
|
+
differentiate between the file and the purpose of the file — the logging of
|
|
153
|
+
changes.
|
|
154
|
+
|
|
155
|
+
### Removed
|
|
156
|
+
|
|
157
|
+
- Remove empty sections from CHANGELOG, they occupy too much space and create
|
|
158
|
+
too much noise in the file. People will have to assume that the missing
|
|
159
|
+
sections were intentionally left out because they contained no notable
|
|
160
|
+
changes.
|
|
161
|
+
|
|
162
|
+
## [0.0.3] - 2014-08-09
|
|
163
|
+
|
|
164
|
+
### Added
|
|
165
|
+
|
|
166
|
+
- "Why should I care?" section mentioning The Changelog podcast.
|
|
167
|
+
|
|
168
|
+
## [0.0.2] - 2014-07-10
|
|
169
|
+
|
|
170
|
+
### Added
|
|
171
|
+
|
|
172
|
+
- Explanation of the recommended reverse chronological release ordering.
|
|
173
|
+
|
|
174
|
+
## [0.0.1] - 2014-05-31
|
|
175
|
+
|
|
176
|
+
### Added
|
|
177
|
+
|
|
178
|
+
- This CHANGELOG file to hopefully serve as an evolving example of a
|
|
179
|
+
standardized open source project CHANGELOG.
|
|
180
|
+
- CNAME file to enable GitHub Pages custom domain
|
|
181
|
+
- README now contains answers to common questions about CHANGELOGs
|
|
182
|
+
- Good examples and basic guidelines, including proper date formatting.
|
|
183
|
+
- Counter-examples: "What makes unicorns cry?"
|
|
184
|
+
|
|
185
|
+
[#1]: https://github.com/olivierlacan/keep-a-changelog/issues/1
|
|
186
|
+
[#2]: https://github.com/olivierlacan/keep-a-changelog/issues/2
|
|
187
|
+
[#3]: https://github.com/olivierlacan/keep-a-changelog/issues/3
|
|
188
|
+
[#4]: https://github.com/olivierlacan/keep-a-changelog/issues/4
|
|
189
|
+
[#10]: https://github.com/olivierlacan/keep-a-changelog/issues/10
|
|
190
|
+
|
|
191
|
+
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
|
|
192
|
+
[2.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
|
|
193
|
+
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
|
|
194
|
+
[0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0
|
|
195
|
+
[0.2.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...v0.2.0
|
|
196
|
+
[0.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.8...v0.1.0
|
|
197
|
+
[0.0.8]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.7...v0.0.8
|
|
198
|
+
[0.0.7]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.6...v0.0.7
|
|
199
|
+
[0.0.6]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.5...v0.0.6
|
|
200
|
+
[0.0.5]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.4...v0.0.5
|
|
201
|
+
[0.0.4]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.3...v0.0.4
|
|
202
|
+
[0.0.3]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.2...v0.0.3
|
|
203
|
+
[0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2
|
|
204
|
+
[0.0.1]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v0.0.1
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
This is a footer
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Changelog - demo
|
|
2
|
-
|
|
3
2
|
All notable changes to this project will be documented in this file.
|
|
4
3
|
|
|
5
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
6
5
|
and this project adheres to
|
|
7
6
|
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
8
7
|
|
|
9
|
-
## [Unreleased]
|
|
8
|
+
## [Unreleased] [YANKED]
|
|
9
|
+
This is a brand new releases with:
|
|
10
|
+
- Configuration is now done within the Web client, for authorized users.
|
|
11
|
+
|
|
10
12
|
### Added
|
|
11
13
|
- Test
|
|
12
14
|
|
|
13
|
-
## [2.0.0] - Unreleased
|
|
15
|
+
## [2.0.0] - Unreleased [YANKED]
|
|
14
16
|
### Added
|
|
15
17
|
- None
|
|
16
18
|
- Test with issue link [#1]
|
|
@@ -100,7 +102,7 @@ and this project adheres to
|
|
|
100
102
|
### Fixed
|
|
101
103
|
- Fix Markdown links to tag comparison URL with footnote-style links.
|
|
102
104
|
|
|
103
|
-
## [0.0.6] - 2014-12-12
|
|
105
|
+
## [0.0.6] - 2014-12-12 [YANKED]
|
|
104
106
|
### Added
|
|
105
107
|
- README section on "yanked" releases.
|
|
106
108
|
|
|
@@ -6,13 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
-
## [Unreleased]
|
|
9
|
+
## [Unreleased] [Yanked]
|
|
10
|
+
This is a brand new releases with:
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
- Configuration is now done within the Web client, for authorized users.
|
|
10
14
|
|
|
11
15
|
### Added
|
|
12
16
|
|
|
13
17
|
- Test
|
|
14
18
|
|
|
15
|
-
## [2.0.0] - unreleased
|
|
19
|
+
## [2.0.0] - unreleased [Yanked]
|
|
16
20
|
|
|
17
21
|
### Added
|
|
18
22
|
|
|
@@ -122,7 +126,7 @@ and this project adheres to
|
|
|
122
126
|
|
|
123
127
|
- Fix Markdown links to tag comparison URL with footnote-style links.
|
|
124
128
|
|
|
125
|
-
## [0.0.6] - 2014-12-12
|
|
129
|
+
## [0.0.6] - 2014-12-12 [YANKED]
|
|
126
130
|
|
|
127
131
|
### Added
|
|
128
132
|
|