keep-a-changelog 2.1.0 → 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.
Files changed (75) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/README.md +16 -4
  3. package/esm/bin.js +6 -2
  4. package/esm/deps/deno.land/std@0.173.0/_util/asserts.js +21 -0
  5. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/_util/os.js +3 -2
  6. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/flags/mod.js +145 -36
  7. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_constants.js +1 -0
  8. package/esm/deps/deno.land/std@0.173.0/path/_interface.js +3 -0
  9. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_util.js +1 -0
  10. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/common.js +1 -1
  11. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/glob.js +1 -1
  12. package/esm/deps/deno.land/std@0.173.0/path/mod.js +32 -0
  13. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/posix.js +20 -16
  14. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/separator.js +1 -1
  15. package/esm/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/win32.js +17 -15
  16. package/esm/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +227 -334
  17. package/esm/src/Change.js +15 -15
  18. package/esm/src/Changelog.js +9 -1
  19. package/esm/src/Release.js +10 -0
  20. package/esm/src/deps.js +1 -1
  21. package/esm/src/parser.js +19 -3
  22. package/esm/test/changelog.custom.type.md +0 -1
  23. package/esm/test/changelog.expected.linted.md +208 -0
  24. package/esm/test/changelog.expected.md +3 -1
  25. package/esm/test/changelog.md +4 -0
  26. package/esm/test/empty.expected.md +0 -1
  27. package/package.json +13 -8
  28. package/script/bin.js +6 -2
  29. package/script/deps/deno.land/std@0.173.0/_util/asserts.js +27 -0
  30. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/_util/os.js +4 -3
  31. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/flags/mod.js +149 -40
  32. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_constants.js +1 -0
  33. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_interface.js +1 -1
  34. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_util.js +1 -0
  35. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/common.js +1 -1
  36. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/glob.js +1 -1
  37. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/mod.js +19 -1
  38. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/posix.js +20 -16
  39. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/separator.js +1 -1
  40. package/script/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/win32.js +18 -16
  41. package/script/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +232 -342
  42. package/script/src/Change.js +15 -15
  43. package/script/src/Changelog.js +9 -1
  44. package/script/src/Release.js +10 -0
  45. package/script/src/deps.js +1 -1
  46. package/script/src/parser.js +19 -3
  47. package/script/test/changelog.custom.type.md +0 -1
  48. package/script/test/changelog.expected.linted.md +208 -0
  49. package/script/test/changelog.expected.md +3 -1
  50. package/script/test/changelog.md +4 -0
  51. package/script/test/empty.expected.md +0 -1
  52. package/types/deps/deno.land/std@0.173.0/_util/asserts.d.ts +10 -0
  53. package/types/deps/deno.land/std@0.173.0/_util/os.d.ts +4 -0
  54. package/types/deps/deno.land/std@0.173.0/flags/mod.d.ts +166 -0
  55. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_constants.d.ts +0 -0
  56. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_interface.d.ts +1 -1
  57. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/_util.d.ts +0 -0
  58. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/common.d.ts +0 -0
  59. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/glob.d.ts +10 -5
  60. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/mod.d.ts +0 -0
  61. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/posix.d.ts +9 -5
  62. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/separator.d.ts +0 -0
  63. package/types/deps/deno.land/{std@0.120.0 → std@0.173.0}/path/win32.d.ts +7 -5
  64. package/types/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
  65. package/types/src/Changelog.d.ts +1 -0
  66. package/types/src/Release.d.ts +1 -0
  67. package/types/src/deps.d.ts +1 -1
  68. package/esm/deps/deno.land/std@0.120.0/_util/assert.js +0 -13
  69. package/esm/deps/deno.land/std@0.120.0/path/_interface.js +0 -3
  70. package/esm/deps/deno.land/std@0.120.0/path/mod.js +0 -14
  71. package/script/deps/deno.land/std@0.120.0/_util/assert.js +0 -18
  72. package/types/deps/deno.land/std@0.120.0/_util/assert.d.ts +0 -5
  73. package/types/deps/deno.land/std@0.120.0/_util/os.d.ts +0 -3
  74. package/types/deps/deno.land/std@0.120.0/flags/mod.d.ts +0 -50
  75. package/types/deps/deno.land/x/semver@v1.4.0/mod.d.ts +0 -116
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class Change {
4
+ static extractIssues(text, issues) {
5
+ return text
6
+ .replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
7
+ if (!issues.includes(index)) {
8
+ issues.push(index);
9
+ }
10
+ return `${start}[#${index}]`;
11
+ })
12
+ .replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
13
+ if (!issues.includes(index)) {
14
+ issues.push(index);
15
+ }
16
+ return `${start}[#${index}]`;
17
+ });
18
+ }
4
19
  constructor(title, description = "") {
5
20
  Object.defineProperty(this, "title", {
6
21
  enumerable: true,
@@ -23,21 +38,6 @@ class Change {
23
38
  this.title = Change.extractIssues(title, this.issues);
24
39
  this.description = Change.extractIssues(description, this.issues);
25
40
  }
26
- static extractIssues(text, issues) {
27
- return text
28
- .replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
29
- if (!issues.includes(index)) {
30
- issues.push(index);
31
- }
32
- return `${start}[#${index}]`;
33
- })
34
- .replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
35
- if (!issues.includes(index)) {
36
- issues.push(index);
37
- }
38
- return `${start}[#${index}]`;
39
- });
40
- }
41
41
  toString() {
42
42
  let t = this.title.split("\n").map((line) => ` ${line}`.trimEnd());
43
43
  t[0] = "-" + t[0].substr(1);
@@ -51,6 +51,12 @@ class Changelog {
51
51
  writable: true,
52
52
  value: void 0
53
53
  });
54
+ Object.defineProperty(this, "format", {
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true,
58
+ value: "compact"
59
+ });
54
60
  this.title = title;
55
61
  this.description = description;
56
62
  }
@@ -82,6 +88,9 @@ class Changelog {
82
88
  t.push("");
83
89
  }
84
90
  t.push(`# ${this.title}`);
91
+ if (this.format === "markdownlint") {
92
+ t.push("");
93
+ }
85
94
  const links = [];
86
95
  const compareLinks = [];
87
96
  const description = this.description.trim() ||
@@ -90,7 +99,6 @@ class Changelog {
90
99
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
91
100
  and this project adheres to [Semantic Versioning](http://semver.org/).`;
92
101
  if (description) {
93
- t.push("");
94
102
  t.push(description);
95
103
  }
96
104
  this.releases.forEach((release) => {
@@ -95,6 +95,10 @@ class Release {
95
95
  }
96
96
  this.date = date;
97
97
  }
98
+ setYanked(yanked = true) {
99
+ this.yanked = yanked;
100
+ return this;
101
+ }
98
102
  addChange(type, change) {
99
103
  if (!(change instanceof Change_js_1.default)) {
100
104
  change = new Change_js_1.default(change);
@@ -143,6 +147,9 @@ class Release {
143
147
  t.push(`## Unreleased${yanked}`);
144
148
  }
145
149
  }
150
+ if (changelog?.format === "markdownlint") {
151
+ t.push("");
152
+ }
146
153
  if (this.description.trim()) {
147
154
  t.push(this.description.trim());
148
155
  t.push("");
@@ -150,6 +157,9 @@ class Release {
150
157
  this.changes.forEach((changes, type) => {
151
158
  if (changes.length) {
152
159
  t.push(`### ${type[0].toUpperCase()}${type.substring(1)}`);
160
+ if (changelog?.format === "markdownlint") {
161
+ t.push("");
162
+ }
153
163
  t = t.concat(changes.map((change) => change.toString()));
154
164
  t.push("");
155
165
  }
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.eq = exports.Semver = void 0;
7
- var mod_js_1 = require("../deps/deno.land/x/semver@v1.4.0/mod.js");
7
+ var mod_js_1 = require("../deps/deno.land/std@0.173.0/semver/mod.js");
8
8
  Object.defineProperty(exports, "Semver", { enumerable: true, get: function () { return __importDefault(mod_js_1).default; } });
9
9
  Object.defineProperty(exports, "eq", { enumerable: true, get: function () { return mod_js_1.eq; } });
@@ -25,7 +25,7 @@ function processTokens(tokens, opts) {
25
25
  const changelog = new Changelog_js_1.default("");
26
26
  changelog.flag = getContent(tokens, "flag");
27
27
  changelog.title = getContent(tokens, "h1", true);
28
- changelog.description = getContent(tokens, "p");
28
+ changelog.description = getTextContent(tokens);
29
29
  //Releases
30
30
  let release;
31
31
  while ((release = getContent(tokens, "h2").toLowerCase())) {
@@ -46,7 +46,7 @@ function processTokens(tokens, opts) {
46
46
  throw new Error(`Syntax error in the release title`);
47
47
  }
48
48
  changelog.addRelease(release);
49
- release.description = getContent(tokens, "p");
49
+ release.description = getTextContent(tokens);
50
50
  let type;
51
51
  while ((type = getContent(tokens, "h3").toLowerCase())) {
52
52
  let change;
@@ -77,7 +77,8 @@ function processTokens(tokens, opts) {
77
77
  }
78
78
  /** Returns the content of a token */
79
79
  function getContent(tokens, type, required = false) {
80
- if (!tokens[0] || tokens[0][1] !== type) {
80
+ const types = Array.isArray(type) ? type : [type];
81
+ if (!tokens[0] || types.indexOf(tokens[0][1]) === -1) {
81
82
  if (required) {
82
83
  throw new Error(`Required token missing in: "${tokens[0][0]}"`);
83
84
  }
@@ -85,6 +86,21 @@ function getContent(tokens, type, required = false) {
85
86
  }
86
87
  return tokens.shift()[2].join("\n");
87
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
+ }
88
104
  /** Tokenize a markdown string */
89
105
  function tokenize(markdown) {
90
106
  const tokens = [];
@@ -1,5 +1,4 @@
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/)
@@ -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,5 +1,4 @@
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/)
@@ -7,6 +6,9 @@ and this project adheres to
7
6
  [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
7
 
9
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
 
@@ -7,6 +7,10 @@ and this project adheres to
7
7
  [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
8
 
9
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
 
@@ -1,5 +1,4 @@
1
1
  # Changelog
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/)
@@ -0,0 +1,10 @@
1
+ /**
2
+ * All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions.
3
+ */
4
+ export declare class DenoStdInternalError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /** Make an assertion, if not `true`, then throw. */
8
+ export declare function assert(expr: unknown, msg?: string): asserts expr;
9
+ /** Use this to assert unreachable code. */
10
+ export declare function unreachable(): never;
@@ -0,0 +1,4 @@
1
+ export type OSType = "windows" | "linux" | "darwin" | "freebsd";
2
+ export declare const osType: OSType;
3
+ export declare const isWindows: boolean;
4
+ export declare const isLinux: boolean;
@@ -0,0 +1,166 @@
1
+ /** Combines recursively all intersection types and returns a new single type. */
2
+ type Id<TRecord> = TRecord extends Record<string, unknown> ? TRecord extends infer InferredRecord ? {
3
+ [Key in keyof InferredRecord]: Id<InferredRecord[Key]>;
4
+ } : never : TRecord;
5
+ /** Converts a union type `A | B | C` into an intersection type `A & B & C`. */
6
+ type UnionToIntersection<TValue> = (TValue extends unknown ? (args: TValue) => unknown : never) extends (args: infer R) => unknown ? R extends Record<string, unknown> ? R : never : never;
7
+ type BooleanType = boolean | string | undefined;
8
+ type StringType = string | undefined;
9
+ type ArgType = StringType | BooleanType;
10
+ type Collectable = string | undefined;
11
+ type Negatable = string | undefined;
12
+ type UseTypes<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable> = undefined extends ((false extends TBooleans ? undefined : TBooleans) & TCollectable & TStrings) ? false : true;
13
+ /**
14
+ * Creates a record with all available flags with the corresponding type and
15
+ * default type.
16
+ */
17
+ type Values<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable, TNegatable extends Negatable, TDefault extends Record<string, unknown> | undefined, TAliases extends Aliases | undefined> = UseTypes<TBooleans, TStrings, TCollectable> extends true ? Record<string, unknown> & AddAliases<SpreadDefaults<CollectValues<TStrings, string, TCollectable, TNegatable> & RecursiveRequired<CollectValues<TBooleans, boolean, TCollectable>> & CollectUnknownValues<TBooleans, TStrings, TCollectable, TNegatable>, DedotRecord<TDefault>>, TAliases> : Record<string, any>;
18
+ type Aliases<TArgNames = string, TAliasNames extends string = string> = Partial<Record<Extract<TArgNames, string>, TAliasNames | ReadonlyArray<TAliasNames>>>;
19
+ type AddAliases<TArgs, TAliases extends Aliases | undefined> = {
20
+ [TArgName in keyof TArgs as AliasNames<TArgName, TAliases>]: TArgs[TArgName];
21
+ };
22
+ type AliasNames<TArgName, TAliases extends Aliases | undefined> = TArgName extends keyof TAliases ? string extends TAliases[TArgName] ? TArgName : TAliases[TArgName] extends string ? TArgName | TAliases[TArgName] : TAliases[TArgName] extends Array<string> ? TArgName | TAliases[TArgName][number] : TArgName : TArgName;
23
+ /**
24
+ * Spreads all default values of Record `TDefaults` into Record `TArgs`
25
+ * and makes default values required.
26
+ *
27
+ * **Example:**
28
+ * `SpreadValues<{ foo?: boolean, bar?: number }, { foo: number }>`
29
+ *
30
+ * **Result:** `{ foo: boolean | number, bar?: number }`
31
+ */
32
+ type SpreadDefaults<TArgs, TDefaults> = TDefaults extends undefined ? TArgs : TArgs extends Record<string, unknown> ? Omit<TArgs, keyof TDefaults> & {
33
+ [Default in keyof TDefaults]: Default extends keyof TArgs ? (TArgs[Default] & TDefaults[Default] | TDefaults[Default]) extends Record<string, unknown> ? NonNullable<SpreadDefaults<TArgs[Default], TDefaults[Default]>> : TDefaults[Default] | NonNullable<TArgs[Default]> : unknown;
34
+ } : never;
35
+ /**
36
+ * Defines the Record for the `default` option to add
37
+ * auto-suggestion support for IDE's.
38
+ */
39
+ type Defaults<TBooleans extends BooleanType, TStrings extends StringType> = Id<UnionToIntersection<Record<string, unknown> & MapTypes<TStrings, unknown> & MapTypes<TBooleans, unknown> & MapDefaults<TBooleans> & MapDefaults<TStrings>>>;
40
+ type MapDefaults<TArgNames extends ArgType> = Partial<Record<TArgNames extends string ? TArgNames : string, unknown>>;
41
+ type RecursiveRequired<TRecord> = TRecord extends Record<string, unknown> ? {
42
+ [Key in keyof TRecord]-?: RecursiveRequired<TRecord[Key]>;
43
+ } : TRecord;
44
+ /** Same as `MapTypes` but also supports collectable options. */
45
+ type CollectValues<TArgNames extends ArgType, TType, TCollectable extends Collectable, TNegatable extends Negatable = undefined> = UnionToIntersection<Extract<TArgNames, TCollectable> extends string ? (Exclude<TArgNames, TCollectable> extends never ? Record<never, never> : MapTypes<Exclude<TArgNames, TCollectable>, TType, TNegatable>) & (Extract<TArgNames, TCollectable> extends never ? Record<never, never> : RecursiveRequired<MapTypes<Extract<TArgNames, TCollectable>, Array<TType>, TNegatable>>) : MapTypes<TArgNames, TType, TNegatable>>;
46
+ /** Same as `Record` but also supports dotted and negatable options. */
47
+ type MapTypes<TArgNames extends ArgType, TType, TNegatable extends Negatable = undefined> = undefined extends TArgNames ? Record<never, never> : TArgNames extends `${infer Name}.${infer Rest}` ? {
48
+ [Key in Name]?: MapTypes<Rest, TType, TNegatable extends `${Name}.${infer Negate}` ? Negate : undefined>;
49
+ } : TArgNames extends string ? Partial<Record<TArgNames, TNegatable extends TArgNames ? TType | false : TType>> : Record<never, never>;
50
+ type CollectUnknownValues<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable, TNegatable extends Negatable> = UnionToIntersection<TCollectable extends TBooleans & TStrings ? Record<never, never> : DedotRecord<Record<Exclude<Extract<Exclude<TCollectable, TNegatable>, string>, Extract<TStrings | TBooleans, string>>, Array<unknown>> & Record<Exclude<Extract<Extract<TCollectable, TNegatable>, string>, Extract<TStrings | TBooleans, string>>, Array<unknown> | false>>>;
51
+ /** Converts `{ "foo.bar.baz": unknown }` into `{ foo: { bar: { baz: unknown } } }`. */
52
+ type DedotRecord<TRecord> = Record<string, unknown> extends TRecord ? TRecord : TRecord extends Record<string, unknown> ? UnionToIntersection<ValueOf<{
53
+ [Key in keyof TRecord]: Key extends string ? Dedot<Key, TRecord[Key]> : never;
54
+ }>> : TRecord;
55
+ type Dedot<TKey extends string, TValue> = TKey extends `${infer Name}.${infer Rest}` ? {
56
+ [Key in Name]: Dedot<Rest, TValue>;
57
+ } : {
58
+ [Key in TKey]: TValue;
59
+ };
60
+ type ValueOf<TValue> = TValue[keyof TValue];
61
+ /** The value returned from `parse`. */
62
+ export type Args<TArgs extends Record<string, unknown> = Record<string, any>, TDoubleDash extends boolean | undefined = undefined> = Id<TArgs & {
63
+ /** Contains all the arguments that didn't have an option associated with
64
+ * them. */
65
+ _: Array<string | number>;
66
+ } & (boolean extends TDoubleDash ? DoubleDash : true extends TDoubleDash ? Required<DoubleDash> : Record<never, never>)>;
67
+ type DoubleDash = {
68
+ /** Contains all the arguments that appear after the double dash: "--". */
69
+ "--"?: Array<string>;
70
+ };
71
+ /** The options for the `parse` call. */
72
+ export interface ParseOptions<TBooleans extends BooleanType = BooleanType, TStrings extends StringType = StringType, TCollectable extends Collectable = Collectable, TNegatable extends Negatable = Negatable, TDefault extends Record<string, unknown> | undefined = Record<string, unknown> | undefined, TAliases extends Aliases | undefined = Aliases | undefined, TDoubleDash extends boolean | undefined = boolean | undefined> {
73
+ /**
74
+ * When `true`, populate the result `_` with everything before the `--` and
75
+ * the result `['--']` with everything after the `--`.
76
+ *
77
+ * @default {false}
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * // $ deno run example.ts -- a arg1
82
+ * import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";
83
+ * console.dir(parse(Deno.args, { "--": false }));
84
+ * // output: { _: [ "a", "arg1" ] }
85
+ * console.dir(parse(Deno.args, { "--": true }));
86
+ * // output: { _: [], --: [ "a", "arg1" ] }
87
+ * ```
88
+ */
89
+ "--"?: TDoubleDash;
90
+ /**
91
+ * An object mapping string names to strings or arrays of string argument
92
+ * names to use as aliases.
93
+ */
94
+ alias?: TAliases;
95
+ /**
96
+ * A boolean, string or array of strings to always treat as booleans. If
97
+ * `true` will treat all double hyphenated arguments without equal signs as
98
+ * `boolean` (e.g. affects `--foo`, not `-f` or `--foo=bar`).
99
+ * All `boolean` arguments will be set to `false` by default.
100
+ */
101
+ boolean?: TBooleans | ReadonlyArray<Extract<TBooleans, string>>;
102
+ /** An object mapping string argument names to default values. */
103
+ default?: TDefault & Defaults<TBooleans, TStrings>;
104
+ /**
105
+ * When `true`, populate the result `_` with everything after the first
106
+ * non-option.
107
+ */
108
+ stopEarly?: boolean;
109
+ /** A string or array of strings argument names to always treat as strings. */
110
+ string?: TStrings | ReadonlyArray<Extract<TStrings, string>>;
111
+ /**
112
+ * A string or array of strings argument names to always treat as arrays.
113
+ * Collectable options can be used multiple times. All values will be
114
+ * collected into one array. If a non-collectable option is used multiple
115
+ * times, the last value is used.
116
+ * All Collectable arguments will be set to `[]` by default.
117
+ */
118
+ collect?: TCollectable | ReadonlyArray<Extract<TCollectable, string>>;
119
+ /**
120
+ * A string or array of strings argument names which can be negated
121
+ * by prefixing them with `--no-`, like `--no-config`.
122
+ */
123
+ negatable?: TNegatable | ReadonlyArray<Extract<TNegatable, string>>;
124
+ /**
125
+ * A function which is invoked with a command line parameter not defined in
126
+ * the `options` configuration object. If the function returns `false`, the
127
+ * unknown option is not added to `parsedArgs`.
128
+ */
129
+ unknown?: (arg: string, key?: string, value?: unknown) => unknown;
130
+ }
131
+ /** Take a set of command line arguments, optionally with a set of options, and
132
+ * return an object representing the flags found in the passed arguments.
133
+ *
134
+ * By default, any arguments starting with `-` or `--` are considered boolean
135
+ * flags. If the argument name is followed by an equal sign (`=`) it is
136
+ * considered a key-value pair. Any arguments which could not be parsed are
137
+ * available in the `_` property of the returned object.
138
+ *
139
+ * By default, the flags module tries to determine the type of all arguments
140
+ * automatically and the return type of the `parse` method will have an index
141
+ * signature with `any` as value (`{ [x: string]: any }`).
142
+ *
143
+ * If the `string`, `boolean` or `collect` option is set, the return value of
144
+ * the `parse` method will be fully typed and the index signature of the return
145
+ * type will change to `{ [x: string]: unknown }`.
146
+ *
147
+ * Any arguments after `'--'` will not be parsed and will end up in `parsedArgs._`.
148
+ *
149
+ * Numeric-looking arguments will be returned as numbers unless `options.string`
150
+ * or `options.boolean` is set for that argument name.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";
155
+ * const parsedArgs = parse(Deno.args);
156
+ * ```
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";
161
+ * const parsedArgs = parse(["--foo", "--bar=baz", "./quux.txt"]);
162
+ * // parsedArgs: { foo: true, bar: "baz", _: ["./quux.txt"] }
163
+ * ```
164
+ */
165
+ export declare function parse<TArgs extends Values<TBooleans, TStrings, TCollectable, TNegatable, TDefaults, TAliases>, TDoubleDash extends boolean | undefined = undefined, TBooleans extends BooleanType = undefined, TStrings extends StringType = undefined, TCollectable extends Collectable = undefined, TNegatable extends Negatable = undefined, TDefaults extends Record<string, unknown> | undefined = undefined, TAliases extends Aliases<TAliasArgNames, TAliasNames> | undefined = undefined, TAliasArgNames extends string = string, TAliasNames extends string = string>(args: string[], { "--": doubleDash, alias, boolean, default: defaults, stopEarly, string, collect, negatable, unknown, }?: ParseOptions<TBooleans, TStrings, TCollectable, TNegatable, TDefaults, TAliases, TDoubleDash>): Args<TArgs, TDoubleDash>;
166
+ export {};
@@ -23,4 +23,4 @@ export interface ParsedPath {
23
23
  */
24
24
  name: string;
25
25
  }
26
- export declare type FormatInputPathObject = Partial<ParsedPath>;
26
+ export type FormatInputPathObject = Partial<ParsedPath>;
@@ -1,19 +1,24 @@
1
1
  import type { OSType } from "../_util/os.js";
2
2
  export interface GlobOptions {
3
3
  /** Extended glob syntax.
4
- * See https://www.linuxjournal.com/content/bash-extended-globbing. Defaults
5
- * to true. */
4
+ * See https://www.linuxjournal.com/content/bash-extended-globbing.
5
+ *
6
+ * @default {true}
7
+ */
6
8
  extended?: boolean;
7
9
  /** Globstar syntax.
8
10
  * See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
9
- * If false, `**` is treated like `*`. Defaults to true. */
11
+ * If false, `**` is treated like `*`.
12
+ *
13
+ * @default {true}
14
+ */
10
15
  globstar?: boolean;
11
- /** Whether globstar should be case insensitive. */
16
+ /** Whether globstar should be case-insensitive. */
12
17
  caseInsensitive?: boolean;
13
18
  /** Operating system. Defaults to the native OS. */
14
19
  os?: OSType;
15
20
  }
16
- export declare type GlobToRegExpOptions = GlobOptions;
21
+ export type GlobToRegExpOptions = GlobOptions;
17
22
  /** Convert a glob string to a regular expression.
18
23
  *
19
24
  * Tries to match bash glob expansion as closely as possible.