keep-a-changelog 2.2.1 → 2.3.0

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 (97) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +7 -2
  3. package/esm/_dnt.test_shims.d.ts +5 -0
  4. package/esm/bin.js +8 -3
  5. package/esm/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
  6. package/esm/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
  7. package/esm/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
  8. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +3 -2
  9. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
  10. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +46 -0
  11. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
  12. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +4 -1
  13. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +7 -5
  14. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +50 -108
  15. package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +7 -5
  16. package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +23 -82
  17. package/esm/test/Change.test.d.ts +1 -0
  18. package/esm/test/deps.d.ts +1 -0
  19. package/esm/test/fixture/CustomRelease.d.ts +8 -0
  20. package/esm/test/parser.test.d.ts +1 -0
  21. package/esm/test/test.d.ts +1 -0
  22. package/package.json +5 -12
  23. package/script/_dnt.polyfills.d.ts +11 -0
  24. package/script/_dnt.shims.d.ts +5 -0
  25. package/script/_dnt.test_shims.d.ts +5 -0
  26. package/script/bin.d.ts +2 -0
  27. package/script/bin.js +8 -3
  28. package/script/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
  29. package/script/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
  30. package/script/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
  31. package/script/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
  32. package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
  33. package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
  34. package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
  35. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/flags/mod.js +4 -3
  36. package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
  37. package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
  38. package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
  39. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_util.js +50 -1
  40. package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
  41. package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
  42. package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
  43. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/mod.js +5 -2
  44. package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
  45. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/posix.js +48 -106
  46. package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
  47. package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
  48. package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/win32.js +22 -81
  49. package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
  50. package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
  51. package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
  52. package/script/mod.d.ts +6 -0
  53. package/script/src/Change.d.ts +8 -0
  54. package/script/src/Changelog.d.ts +19 -0
  55. package/script/src/Release.d.ts +27 -0
  56. package/script/src/deps.d.ts +1 -0
  57. package/script/src/parser.d.ts +11 -0
  58. package/script/test/Change.test.d.ts +1 -0
  59. package/script/test/deps.d.ts +1 -0
  60. package/script/test/fixture/CustomRelease.d.ts +8 -0
  61. package/script/test/parser.test.d.ts +1 -0
  62. package/script/test/test.d.ts +1 -0
  63. /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
  64. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  65. /package/{types → esm}/bin.d.ts +0 -0
  66. /package/{types → esm}/deps/deno.land/std@0.173.0/semver/mod.d.ts +0 -0
  67. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/asserts.d.ts +0 -0
  68. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  69. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/_util/os.d.ts +0 -0
  70. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  71. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/flags/mod.d.ts +0 -0
  72. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
  73. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  74. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +0 -0
  75. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  76. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
  77. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  78. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +0 -0
  79. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  80. /package/{types/deps/deno.land/std@0.173.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
  81. /package/esm/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
  82. /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
  83. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
  84. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
  85. /package/{types → esm}/mod.d.ts +0 -0
  86. /package/{types → esm}/src/Change.d.ts +0 -0
  87. /package/{types → esm}/src/Changelog.d.ts +0 -0
  88. /package/{types → esm}/src/Release.d.ts +0 -0
  89. /package/{types → esm}/src/deps.d.ts +0 -0
  90. /package/{types → esm}/src/parser.d.ts +0 -0
  91. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/asserts.js +0 -0
  92. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/_util/os.js +0 -0
  93. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_constants.js +0 -0
  94. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/_interface.js +0 -0
  95. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/common.js +0 -0
  96. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/glob.js +0 -0
  97. /package/script/deps/deno.land/{std@0.173.0 → std@0.189.0}/path/separator.js +0 -0
@@ -0,0 +1,398 @@
1
+ /**
2
+ * The semantic version parser.
3
+ *
4
+ * Adapted directly from [semver](https://github.com/npm/node-semver).
5
+ *
6
+ * ## Versions
7
+ *
8
+ * A "version" is described by the `v2.0.0` specification found at
9
+ * <https://semver.org>.
10
+ *
11
+ * A leading `"="` or `"v"` character is stripped off and ignored.
12
+ *
13
+ * ## Ranges
14
+ *
15
+ * A `version range` is a set of `comparators` which specify versions that satisfy
16
+ * the range.
17
+ *
18
+ * A `comparator` is composed of an `operator` and a `version`. The set of
19
+ * primitive `operators` is:
20
+ *
21
+ * - `<` Less than
22
+ * - `<=` Less than or equal to
23
+ * - `>` Greater than
24
+ * - `>=` Greater than or equal to
25
+ * - `=` Equal. If no operator is specified, then equality is assumed, so this
26
+ * operator is optional, but MAY be included.
27
+ *
28
+ * For example, the comparator `>=1.2.7` would match the versions `1.2.7`, `1.2.8`,
29
+ * `2.5.3`, and `1.3.9`, but not the versions `1.2.6` or `1.1.0`.
30
+ *
31
+ * Comparators can be joined by whitespace to form a `comparator set`, which is
32
+ * satisfied by the **intersection** of all of the comparators it includes.
33
+ *
34
+ * A range is composed of one or more comparator sets, joined by `||`. A version
35
+ * matches a range if and only if every comparator in at least one of the
36
+ * `||`-separated comparator sets is satisfied by the version.
37
+ *
38
+ * For example, the range `>=1.2.7 <1.3.0` would match the versions `1.2.7`,
39
+ * `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`, or `1.1.0`.
40
+ *
41
+ * The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`, `1.2.9`,
42
+ * and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
43
+ *
44
+ * ### Prerelease Tags
45
+ *
46
+ * If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then it will
47
+ * only be allowed to satisfy comparator sets if at least one comparator with the
48
+ * same `[major, minor, patch]` tuple also has a prerelease tag.
49
+ *
50
+ * For example, the range `>1.2.3-alpha.3` would be allowed to match the version
51
+ * `1.2.3-alpha.7`, but it would _not_ be satisfied by `3.4.5-alpha.9`, even though
52
+ * `3.4.5-alpha.9` is technically "greater than" `1.2.3-alpha.3` according to the
53
+ * SemVer sort rules. The version range only accepts prerelease tags on the `1.2.3`
54
+ * version. The version `3.4.5` _would_ satisfy the range, because it does not have
55
+ * a prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
56
+ *
57
+ * The purpose for this behavior is twofold. First, prerelease versions frequently
58
+ * are updated very quickly, and contain many breaking changes that are (by the
59
+ * author"s design) not yet fit for public consumption. Therefore, by default, they
60
+ * are excluded from range matching semantics.
61
+ *
62
+ * Second, a user who has opted into using a prerelease version has clearly
63
+ * indicated the intent to use _that specific_ set of alpha/beta/rc versions. By
64
+ * including a prerelease tag in the range, the user is indicating that they are
65
+ * aware of the risk. However, it is still not appropriate to assume that they have
66
+ * opted into taking a similar risk on the _next_ set of prerelease versions.
67
+ *
68
+ * Note that this behavior can be suppressed (treating all prerelease versions as
69
+ * if they were normal versions, for the purpose of range matching) by setting the
70
+ * `includePrerelease` flag on the options object to any [functions](#functions)
71
+ * that do range matching.
72
+ *
73
+ * #### Prerelease Identifiers
74
+ *
75
+ * The method `.increment` takes an additional `identifier` string argument that
76
+ * will append the value of the string as a prerelease identifier:
77
+ *
78
+ * ```javascript
79
+ * semver.increment("1.2.3", "prerelease", "beta");
80
+ * // "1.2.4-beta.0"
81
+ * ```
82
+ *
83
+ * ### Advanced Range Syntax
84
+ *
85
+ * Advanced range syntax desugars to primitive comparators in deterministic ways.
86
+ *
87
+ * Advanced ranges may be combined in the same way as primitive comparators using
88
+ * white space or `||`.
89
+ *
90
+ * #### Hyphen Ranges `X.Y.Z - A.B.C`
91
+ *
92
+ * Specifies an inclusive set.
93
+ *
94
+ * - `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
95
+ *
96
+ * If a partial version is provided as the first version in the inclusive range,
97
+ * then the missing pieces are replaced with zeroes.
98
+ *
99
+ * - `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
100
+ *
101
+ * If a partial version is provided as the second version in the inclusive range,
102
+ * then all versions that start with the supplied parts of the tuple are accepted,
103
+ * but nothing that would be greater than the provided tuple parts.
104
+ *
105
+ * - `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
106
+ * - `1.2.3 - 2` := `>=1.2.3 <3.0.0`
107
+ *
108
+ * #### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
109
+ *
110
+ * Any of `X`, `x`, or `*` may be used to "stand in" for one of the numeric values
111
+ * in the `[major, minor, patch]` tuple.
112
+ *
113
+ * - `*` := `>=0.0.0` (Any version satisfies)
114
+ * - `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
115
+ * - `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
116
+ *
117
+ * A partial version range is treated as an X-Range, so the special character is in
118
+ * fact optional.
119
+ *
120
+ * - `""` (empty string) := `*` := `>=0.0.0`
121
+ * - `1` := `1.x.x` := `>=1.0.0 <2.0.0`
122
+ * - `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
123
+ *
124
+ * #### Tilde Ranges `~1.2.3` `~1.2` `~1`
125
+ *
126
+ * Allows patch-level changes if a minor version is specified on the comparator.
127
+ * Allows minor-level changes if not.
128
+ *
129
+ * - `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
130
+ * - `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
131
+ * - `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
132
+ * - `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
133
+ * - `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
134
+ * - `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
135
+ * - `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in the
136
+ * `1.2.3` version will be allowed, if they are greater than or equal to
137
+ * `beta.2`. So, `1.2.3-beta.4` would be allowed, but `1.2.4-beta.2` would not,
138
+ * because it is a prerelease of a different `[major, minor, patch]` tuple.
139
+ *
140
+ * #### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
141
+ *
142
+ * Allows changes that do not modify the left-most non-zero element in the
143
+ * `[major, minor, patch]` tuple. In other words, this allows patch and minor
144
+ * updates for versions `1.0.0` and above, patch updates for versions
145
+ * `0.X >=0.1.0`, and _no_ updates for versions `0.0.X`.
146
+ *
147
+ * Many authors treat a `0.x` version as if the `x` were the major
148
+ * "breaking-change" indicator.
149
+ *
150
+ * Caret ranges are ideal when an author may make breaking changes between `0.2.4`
151
+ * and `0.3.0` releases, which is a common practice. However, it presumes that
152
+ * there will _not_ be breaking changes between `0.2.4` and `0.2.5`. It allows for
153
+ * changes that are presumed to be additive (but non-breaking), according to
154
+ * commonly observed practices.
155
+ *
156
+ * - `^1.2.3` := `>=1.2.3 <2.0.0`
157
+ * - `^0.2.3` := `>=0.2.3 <0.3.0`
158
+ * - `^0.0.3` := `>=0.0.3 <0.0.4`
159
+ * - `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in the
160
+ * `1.2.3` version will be allowed, if they are greater than or equal to
161
+ * `beta.2`. So, `1.2.3-beta.4` would be allowed, but `1.2.4-beta.2` would not,
162
+ * because it is a prerelease of a different `[major, minor, patch]` tuple.
163
+ * - `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the `0.0.3`
164
+ * version _only_ will be allowed, if they are greater than or equal to `beta`.
165
+ * So, `0.0.3-pr.2` would be allowed.
166
+ *
167
+ * When parsing caret ranges, a missing `patch` value desugars to the number `0`,
168
+ * but will allow flexibility within that value, even if the major and minor
169
+ * versions are both `0`.
170
+ *
171
+ * - `^1.2.x` := `>=1.2.0 <2.0.0`
172
+ * - `^0.0.x` := `>=0.0.0 <0.1.0`
173
+ * - `^0.0` := `>=0.0.0 <0.1.0`
174
+ *
175
+ * A missing `minor` and `patch` values will desugar to zero, but also allow
176
+ * flexibility within those values, even if the major version is zero.
177
+ *
178
+ * - `^1.x` := `>=1.0.0 <2.0.0`
179
+ * - `^0.x` := `>=0.0.0 <1.0.0`
180
+ *
181
+ * ### Range Grammar
182
+ *
183
+ * Putting all this together, here is a Backus-Naur grammar for ranges, for the
184
+ * benefit of parser authors:
185
+ *
186
+ * ```bnf
187
+ * range-set ::= range ( logical-or range ) *
188
+ * logical-or ::= ( " " ) * "||" ( " " ) *
189
+ * range ::= hyphen | simple ( " " simple ) * | ""
190
+ * hyphen ::= partial " - " partial
191
+ * simple ::= primitive | partial | tilde | caret
192
+ * primitive ::= ( "<" | ">" | ">=" | "<=" | "=" ) partial
193
+ * partial ::= xr ( "." xr ( "." xr qualifier ? )? )?
194
+ * xr ::= "x" | "X" | "*" | nr
195
+ * nr ::= "0" | ["1"-"9"] ( ["0"-"9"] ) *
196
+ * tilde ::= "~" partial
197
+ * caret ::= "^" partial
198
+ * qualifier ::= ( "-" pre )? ( "+" build )?
199
+ * pre ::= parts
200
+ * build ::= parts
201
+ * parts ::= part ( "." part ) *
202
+ * part ::= nr | [-0-9A-Za-z]+
203
+ * ```
204
+ *
205
+ * Note that, since ranges may be non-contiguous, a version might not be greater
206
+ * than a range, less than a range, _or_ satisfy a range! For example, the range
207
+ * `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9` until `2.0.0`, so the
208
+ * version `1.2.10` would not be greater than the range (because `2.0.1` satisfies,
209
+ * which is higher), nor less than the range (since `1.2.8` satisfies, which is
210
+ * lower), and it also does not satisfy the range.
211
+ *
212
+ * If you want to know if a version satisfies or does not satisfy a range, use the
213
+ * {@linkcode satisfies} function.
214
+ *
215
+ * This module is browser compatible.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * import * as semver from "https://deno.land/std@$STD_VERSION/semver/mod.ts";
220
+ *
221
+ * semver.valid("1.2.3"); // "1.2.3"
222
+ * semver.valid("a.b.c"); // null
223
+ * semver.satisfies("1.2.3", "1.x || >=2.5.0 || 5.0.0 - 7.2.3"); // true
224
+ * semver.gt("1.2.3", "9.8.7"); // false
225
+ * semver.lt("1.2.3", "9.8.7"); // true
226
+ * semver.minVersion(">=1.0.0"); // "1.0.0"
227
+ * ```
228
+ *
229
+ * @module
230
+ */
231
+ export type ReleaseType = "pre" | "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease";
232
+ export type Operator = "===" | "!==" | "" | "=" | "==" | "!=" | ">" | ">=" | "<" | "<=";
233
+ export interface Options {
234
+ /**
235
+ * Set to suppress the default behavior of excluding prerelease tagged
236
+ * versions from ranges unless they are explicitly opted into.
237
+ */
238
+ includePrerelease?: boolean;
239
+ }
240
+ export declare const SEMVER_SPEC_VERSION = "2.0.0";
241
+ /**
242
+ * Attempt to parse a string as a semantic version, returning either a `SemVer`
243
+ * object or `null`.
244
+ */
245
+ export declare function parse(version: string | SemVer | null, options?: Options): SemVer | null;
246
+ /** Returns the parsed version, or null if it's not valid. */
247
+ export declare function valid(version: string | SemVer | null, options?: Options): string | null;
248
+ export declare class SemVer {
249
+ raw: string;
250
+ options: Options;
251
+ major: number;
252
+ minor: number;
253
+ patch: number;
254
+ version: string;
255
+ build: ReadonlyArray<string>;
256
+ prerelease: Array<string | number>;
257
+ constructor(version: string | SemVer, options?: Options);
258
+ format(): string;
259
+ compare(other: string | SemVer): 1 | 0 | -1;
260
+ compareMain(other: string | SemVer): 1 | 0 | -1;
261
+ comparePre(other: string | SemVer): 1 | 0 | -1;
262
+ compareBuild(other: string | SemVer): 1 | 0 | -1;
263
+ increment(release: ReleaseType, identifier?: string): SemVer;
264
+ toString(): string;
265
+ }
266
+ /**
267
+ * Returns the version incremented by the release type
268
+ * (major, minor, patch, or prerelease), or null if it's not valid.
269
+ *
270
+ * `premajor` in one call will bump the version up to the next major version and
271
+ * down to a prerelease of that major version. `preminor`, and `prepatch` work
272
+ * the same way.
273
+ *
274
+ * If called from a non-prerelease version, the `prerelease` will work the same
275
+ * as `prepatch`. It increments the patch version, then makes a prerelease. If
276
+ * the input version is already a prerelease it simply increments it.
277
+ */
278
+ export declare function increment(version: string | SemVer, release: ReleaseType, options?: Options, identifier?: string): string | null;
279
+ /**
280
+ * Returns difference between two versions by the release type (`major`,
281
+ * `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`), or
282
+ * null if the versions are the same.
283
+ */
284
+ export declare function difference(version1: string | SemVer, version2: string | SemVer, options?: Options): ReleaseType | null;
285
+ export declare function compareIdentifiers(a: string | number | null, b: string | number | null): 1 | 0 | -1;
286
+ export declare function rcompareIdentifiers(a: string | null, b: string | null): 1 | 0 | -1;
287
+ /** Returns the major version number. */
288
+ export declare function major(v: string | SemVer, options?: Options): number;
289
+ /** Returns the minor version number. */
290
+ export declare function minor(v: string | SemVer, options?: Options): number;
291
+ /** Returns the patch version number. */
292
+ export declare function patch(v: string | SemVer, options?: Options): number;
293
+ /**
294
+ * Returns `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if `v2` is
295
+ * greater. Sorts in ascending order if passed to `Array.sort()`,
296
+ */
297
+ export declare function compare(v1: string | SemVer, v2: string | SemVer, options?: Options): 1 | 0 | -1;
298
+ /**
299
+ * The same as {@linkcode compare} but considers `build` when two versions are
300
+ * equal. Sorts in ascending order if passed to `Array.sort()`.
301
+ */
302
+ export declare function compareBuild(a: string | SemVer, b: string | SemVer, options?: Options): 1 | 0 | -1;
303
+ /**
304
+ * Returns `0` if `v1 == v2`, or `-1` if `v1` is greater, or `1` if `v2` is
305
+ * greater. Sorts in descending order if passed to `Array.sort()`,
306
+ */
307
+ export declare function rcompare(v1: string | SemVer, v2: string | SemVer, options?: Options): 1 | 0 | -1;
308
+ export declare function sort<T extends string | SemVer>(list: T[], options?: Options): T[];
309
+ export declare function rsort<T extends string | SemVer>(list: T[], options?: Options): T[];
310
+ /** Greater than comparison */
311
+ export declare function gt(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
312
+ /** Less than comparison */
313
+ export declare function lt(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
314
+ /**
315
+ * This is true if they're logically equivalent, even if they're not the exact
316
+ * same string.
317
+ */
318
+ export declare function eq(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
319
+ /**
320
+ * This is true if they're not logically equivalent, even if they're the exact
321
+ * same string.
322
+ */
323
+ export declare function neq(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
324
+ /** Greater than or equal comparison */
325
+ export declare function gte(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
326
+ /** Less than or equal comparison */
327
+ export declare function lte(v1: string | SemVer, v2: string | SemVer, options?: Options): boolean;
328
+ /**
329
+ * Pass in a comparison string, and it'll call the corresponding comparison
330
+ * function. `"==="` and `"!=="` do simple string comparison, but are included
331
+ * for completeness. Throws if an invalid comparison string is provided.
332
+ */
333
+ export declare function cmp(v1: string | SemVer, operator: Operator, v2: string | SemVer, options?: Options): boolean;
334
+ export declare class Comparator {
335
+ semver: SemVer;
336
+ operator: "" | "=" | "<" | ">" | "<=" | ">=";
337
+ value: string;
338
+ options: Options;
339
+ constructor(comp: string | Comparator, options?: Options);
340
+ parse(comp: string): void;
341
+ test(version: string | SemVer): boolean;
342
+ intersects(comp: Comparator, options?: Options): boolean;
343
+ toString(): string;
344
+ }
345
+ export declare class Range {
346
+ range: string;
347
+ raw: string;
348
+ options: Options;
349
+ includePrerelease: boolean;
350
+ set: ReadonlyArray<ReadonlyArray<Comparator>>;
351
+ constructor(range: string | Range | Comparator, options?: Options);
352
+ format(): string;
353
+ parseRange(range: string): ReadonlyArray<Comparator>;
354
+ test(version: string | SemVer): boolean;
355
+ intersects(range?: Range, options?: Options): boolean;
356
+ toString(): string;
357
+ }
358
+ export declare function toComparators(range: string | Range, options?: Options): string[][];
359
+ /** Returns true if the version satisfies the range. */
360
+ export declare function satisfies(version: string | SemVer, range: string | Range, options?: Options): boolean;
361
+ /**
362
+ * Returns the highest version in the list that satisfies the range, or `null`
363
+ * if none of them do.
364
+ */
365
+ export declare function maxSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, options?: Options): T | null;
366
+ /**
367
+ * Returns the lowest version in the list that satisfies the range, or `null` if
368
+ * none of them do.
369
+ */
370
+ export declare function minSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, options?: Options): T | null;
371
+ /** Returns the lowest version that can possibly match the given range. */
372
+ export declare function minVersion(range: string | Range, options?: Options): SemVer | null;
373
+ /** Returns the valid range or null if it's not valid. */
374
+ export declare function validRange(range: string | Range | null, options?: Options): string | null;
375
+ /**
376
+ * Returns true if version is less than all the versions possible in the range.
377
+ */
378
+ export declare function ltr(version: string | SemVer, range: string | Range, options?: Options): boolean;
379
+ /**
380
+ * Returns true if version is greater than all the versions possible in the range.
381
+ */
382
+ export declare function gtr(version: string | SemVer, range: string | Range, options?: Options): boolean;
383
+ /**
384
+ * Returns true if the version is outside the bounds of the range in either the
385
+ * high or low direction. The hilo argument must be either the string '>' or
386
+ * '<'. (This is the function called by {@linkcode gtr} and {@linkcode ltr}.)
387
+ */
388
+ export declare function outside(version: string | SemVer, range: string | Range, hilo: ">" | "<", options?: Options): boolean;
389
+ /**
390
+ * Returns an array of prerelease components, or null if none exist.
391
+ *
392
+ * @example
393
+ * `prerelease("1.2.3-alpha.1") -> ["alpha", 1]`
394
+ */
395
+ export declare function prerelease(version: string | SemVer, options?: Options): ReadonlyArray<string | number> | null;
396
+ /** Returns true if the two supplied ranges or comparators intersect. */
397
+ export declare function intersects(range1: string | Range | Comparator, range2: string | Range | Comparator, options?: Options): boolean;
398
+ export default SemVer;
@@ -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 {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.parse = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  /**
6
7
  * Command line arguments parser based on
7
8
  * [minimist](https://github.com/minimistjs/minimist).
@@ -333,10 +334,10 @@ function parse(args, { "--": doubleDash = false, alias = {}, boolean = false, de
333
334
  }
334
335
  for (const [key, value] of Object.entries(defaults)) {
335
336
  if (!hasKey(argv, key.split("."))) {
336
- setKey(argv, key, value);
337
+ setKey(argv, key, value, false);
337
338
  if (aliases[key]) {
338
339
  for (const x of aliases[key]) {
339
- setKey(argv, x, value);
340
+ setKey(argv, x, value, false);
340
341
  }
341
342
  }
342
343
  }
@@ -0,0 +1,39 @@
1
+ export declare const CHAR_UPPERCASE_A = 65;
2
+ export declare const CHAR_LOWERCASE_A = 97;
3
+ export declare const CHAR_UPPERCASE_Z = 90;
4
+ export declare const CHAR_LOWERCASE_Z = 122;
5
+ export declare const CHAR_DOT = 46;
6
+ export declare const CHAR_FORWARD_SLASH = 47;
7
+ export declare const CHAR_BACKWARD_SLASH = 92;
8
+ export declare const CHAR_VERTICAL_LINE = 124;
9
+ export declare const CHAR_COLON = 58;
10
+ export declare const CHAR_QUESTION_MARK = 63;
11
+ export declare const CHAR_UNDERSCORE = 95;
12
+ export declare const CHAR_LINE_FEED = 10;
13
+ export declare const CHAR_CARRIAGE_RETURN = 13;
14
+ export declare const CHAR_TAB = 9;
15
+ export declare const CHAR_FORM_FEED = 12;
16
+ export declare const CHAR_EXCLAMATION_MARK = 33;
17
+ export declare const CHAR_HASH = 35;
18
+ export declare const CHAR_SPACE = 32;
19
+ export declare const CHAR_NO_BREAK_SPACE = 160;
20
+ export declare const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279;
21
+ export declare const CHAR_LEFT_SQUARE_BRACKET = 91;
22
+ export declare const CHAR_RIGHT_SQUARE_BRACKET = 93;
23
+ export declare const CHAR_LEFT_ANGLE_BRACKET = 60;
24
+ export declare const CHAR_RIGHT_ANGLE_BRACKET = 62;
25
+ export declare const CHAR_LEFT_CURLY_BRACKET = 123;
26
+ export declare const CHAR_RIGHT_CURLY_BRACKET = 125;
27
+ export declare const CHAR_HYPHEN_MINUS = 45;
28
+ export declare const CHAR_PLUS = 43;
29
+ export declare const CHAR_DOUBLE_QUOTE = 34;
30
+ export declare const CHAR_SINGLE_QUOTE = 39;
31
+ export declare const CHAR_PERCENT = 37;
32
+ export declare const CHAR_SEMICOLON = 59;
33
+ export declare const CHAR_CIRCUMFLEX_ACCENT = 94;
34
+ export declare const CHAR_GRAVE_ACCENT = 96;
35
+ export declare const CHAR_AT = 64;
36
+ export declare const CHAR_AMPERSAND = 38;
37
+ export declare const CHAR_EQUAL = 61;
38
+ export declare const CHAR_0 = 48;
39
+ export declare const CHAR_9 = 57;