keep-a-changelog 2.1.0 → 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 (128) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/README.md +23 -6
  3. package/esm/_dnt.test_shims.d.ts +5 -0
  4. package/esm/bin.js +11 -2
  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/semver/mod.d.ts +398 -0
  9. package/esm/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +227 -334
  10. package/esm/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
  11. package/esm/deps/deno.land/std@0.189.0/_util/asserts.js +21 -0
  12. package/esm/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
  13. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +3 -2
  14. package/esm/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
  15. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +146 -36
  16. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
  17. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +1 -1
  18. package/esm/deps/deno.land/std@0.189.0/path/_interface.js +3 -0
  19. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
  20. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +47 -0
  21. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
  22. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +10 -5
  23. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
  24. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
  25. package/esm/deps/deno.land/std@0.189.0/path/mod.js +35 -0
  26. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +15 -9
  27. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +58 -112
  28. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
  29. package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +13 -9
  30. package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
  31. package/esm/src/Change.js +15 -15
  32. package/{types → esm}/src/Changelog.d.ts +1 -0
  33. package/esm/src/Changelog.js +9 -1
  34. package/{types → esm}/src/Release.d.ts +1 -0
  35. package/esm/src/Release.js +10 -0
  36. package/esm/src/deps.d.ts +1 -0
  37. package/esm/src/deps.js +1 -1
  38. package/esm/src/parser.js +19 -3
  39. package/esm/test/Change.test.d.ts +1 -0
  40. package/esm/test/changelog.custom.type.md +0 -1
  41. package/esm/test/changelog.expected.linted.md +208 -0
  42. package/esm/test/changelog.expected.md +3 -1
  43. package/esm/test/changelog.md +4 -0
  44. package/esm/test/deps.d.ts +1 -0
  45. package/esm/test/empty.expected.md +0 -1
  46. package/esm/test/fixture/CustomRelease.d.ts +8 -0
  47. package/esm/test/parser.test.d.ts +1 -0
  48. package/esm/test/test.d.ts +1 -0
  49. package/package.json +6 -8
  50. package/script/_dnt.polyfills.d.ts +11 -0
  51. package/script/_dnt.shims.d.ts +5 -0
  52. package/script/_dnt.test_shims.d.ts +5 -0
  53. package/script/bin.d.ts +2 -0
  54. package/script/bin.js +11 -2
  55. package/script/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
  56. package/script/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
  57. package/script/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
  58. package/script/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
  59. package/script/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +232 -342
  60. package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
  61. package/script/deps/deno.land/std@0.189.0/_util/asserts.js +27 -0
  62. package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
  63. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +4 -3
  64. package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
  65. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +150 -40
  66. package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
  67. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
  68. package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
  69. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_interface.js +1 -1
  70. package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
  71. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +51 -1
  72. package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
  73. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
  74. package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
  75. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
  76. package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
  77. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/mod.js +23 -2
  78. package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
  79. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +56 -110
  80. package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
  81. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
  82. package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
  83. package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
  84. package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
  85. package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
  86. package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
  87. package/script/mod.d.ts +6 -0
  88. package/script/src/Change.d.ts +8 -0
  89. package/script/src/Change.js +15 -15
  90. package/script/src/Changelog.d.ts +19 -0
  91. package/script/src/Changelog.js +9 -1
  92. package/script/src/Release.d.ts +27 -0
  93. package/script/src/Release.js +10 -0
  94. package/script/src/deps.d.ts +1 -0
  95. package/script/src/deps.js +1 -1
  96. package/script/src/parser.d.ts +11 -0
  97. package/script/src/parser.js +19 -3
  98. package/script/test/Change.test.d.ts +1 -0
  99. package/script/test/changelog.custom.type.md +0 -1
  100. package/script/test/changelog.expected.linted.md +208 -0
  101. package/script/test/changelog.expected.md +3 -1
  102. package/script/test/changelog.md +4 -0
  103. package/script/test/deps.d.ts +1 -0
  104. package/script/test/empty.expected.md +0 -1
  105. package/script/test/fixture/CustomRelease.d.ts +8 -0
  106. package/script/test/parser.test.d.ts +1 -0
  107. package/script/test/test.d.ts +1 -0
  108. package/esm/deps/deno.land/std@0.120.0/_util/assert.js +0 -13
  109. package/esm/deps/deno.land/std@0.120.0/path/_interface.js +0 -3
  110. package/esm/deps/deno.land/std@0.120.0/path/mod.js +0 -14
  111. package/script/deps/deno.land/std@0.120.0/_util/assert.js +0 -18
  112. package/types/deps/deno.land/std@0.120.0/_util/assert.d.ts +0 -5
  113. package/types/deps/deno.land/std@0.120.0/_util/os.d.ts +0 -3
  114. package/types/deps/deno.land/std@0.120.0/flags/mod.d.ts +0 -50
  115. package/types/deps/deno.land/x/semver@v1.4.0/mod.d.ts +0 -116
  116. package/types/src/deps.d.ts +0 -1
  117. /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
  118. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  119. /package/{types → esm}/bin.d.ts +0 -0
  120. /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
  121. /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
  122. /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
  123. /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
  124. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
  125. /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
  126. /package/{types → esm}/mod.d.ts +0 -0
  127. /package/{types → esm}/src/Change.d.ts +0 -0
  128. /package/{types → esm}/src/parser.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
1
  <!-- deno-fmt-ignore-file -->
2
2
 
3
3
  # Changelog
4
-
5
4
  All notable changes to this project will be documented in this file.
6
5
 
7
6
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
8
7
  and this project adheres to [Semantic Versioning](http://semver.org/).
9
8
 
9
+ ## [2.3.0] - 2023-05-25
10
+ ### Added
11
+ - New option `--create`, to create unreleased versions [#31].
12
+
13
+ ### Fixed
14
+ - Allow empty values for `--release` option
15
+
16
+ ## [2.2.1] - 2023-01-25
17
+ ### Fixed
18
+ - Allow list elements in the descriptions of releases and changelogs [#30].
19
+
20
+ ## [2.2.0] - 2023-01-18
21
+ ### Added
22
+ - New option `format` to configure the output option [#28].
23
+ - `Release.setYanked` function [#26].
24
+
25
+ ### Fixed
26
+ - Removed unnecessary new line after the title [#27].
27
+
10
28
  ## [2.1.0] - 2022-04-03
11
29
  ### Added
12
30
  - Support for `[YANKED]` releases [#25]
@@ -29,7 +47,15 @@ New version merging Deno and Node code using Deno's `dnt` package.
29
47
  [#21]: https://github.com/oscarotero/keep-a-changelog/issues/21
30
48
  [#23]: https://github.com/oscarotero/keep-a-changelog/issues/23
31
49
  [#25]: https://github.com/oscarotero/keep-a-changelog/issues/25
32
-
50
+ [#26]: https://github.com/oscarotero/keep-a-changelog/issues/26
51
+ [#27]: https://github.com/oscarotero/keep-a-changelog/issues/27
52
+ [#28]: https://github.com/oscarotero/keep-a-changelog/issues/28
53
+ [#30]: https://github.com/oscarotero/keep-a-changelog/issues/30
54
+ [#31]: https://github.com/oscarotero/keep-a-changelog/issues/31
55
+
56
+ [2.3.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.2.1...v2.3.0
57
+ [2.2.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.2.0...v2.2.1
58
+ [2.2.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.1.0...v2.2.0
33
59
  [2.1.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.1...v2.1.0
34
60
  [2.0.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.0...v2.0.1
35
61
  [2.0.0]: https://github.com/oscarotero/keep-a-changelog/releases/tag/v2.0.0
package/README.md CHANGED
@@ -22,7 +22,7 @@ console.log(changelog.toString());
22
22
  ## Usage in Deno
23
23
 
24
24
  ```js
25
- import { parser } from "https://deno.land/x/changelog@v2.0.0/mod.ts";
25
+ import { parser } from "https://deno.land/x/changelog@v2.2.1/mod.ts";
26
26
 
27
27
  //Parse a changelog file
28
28
  const changelog = parser(await Deno.readTextFile("CHANGELOG.md"));
@@ -37,7 +37,7 @@ console.log(changelog.toString());
37
37
  import {
38
38
  Changelog,
39
39
  Release,
40
- } from "https://deno.land/x/changelog@v2.0.0/mod.ts";
40
+ } from "https://deno.land/x/changelog@v2.2.1/mod.ts";
41
41
 
42
42
  const changelog = new Changelog("My project")
43
43
  .addRelease(
@@ -56,6 +56,17 @@ const changelog = new Changelog("My project")
56
56
  console.log(changelog.toString());
57
57
  ```
58
58
 
59
+ ### Custom output format
60
+
61
+ By default, the output format of the markdown is "compact", that removes the
62
+ space after the headings. You can change it to follow the
63
+ [`markdownlint`](https://github.com/DavidAnson/markdownlint) rules:
64
+
65
+ ```js
66
+ const changelog = new Changelog();
67
+ changelog.format = "markdownlint";
68
+ ```
69
+
59
70
  ### Custom tag names
60
71
 
61
72
  By default, the tag names are `v` + version number. For example, the tag for the
@@ -73,10 +84,10 @@ By default and according to the
73
84
  [keepachangelog](http://keepachangelog.com/en/1.0.0/) format, the change types
74
85
  are `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, and `Security`.
75
86
 
76
- In case you'd like add another type in order to use is in your changelog, you
77
- basically need to extend the `Release` class to support new types. Additionally,
78
- you have to tell the `parser` that it should create instances of your new
79
- extended `Release` in order to parse your changelog correctly.
87
+ In case you'd like add another type, you need to extend the `Release` class to
88
+ support new types. Additionally, you have to tell the `parser` that it should
89
+ create instances of your new extended `Release` in order to parse your changelog
90
+ correctly.
80
91
 
81
92
  For example, we would like to add a type `Maintenance`. Extend the provided
82
93
  `Release` class:
@@ -149,6 +160,11 @@ You can release automatically the latest "Unreleased" version:
149
160
  changelog --release
150
161
  ```
151
162
 
163
+ If your "Unreleased" section has no version, you can specify it as an argument:
164
+ ```sh
165
+ changelog --release 2.0.0
166
+ ```
167
+
152
168
  And return the latest released version:
153
169
 
154
170
  ```sh
@@ -160,6 +176,7 @@ Available options:
160
176
 
161
177
  | Option | Description |
162
178
  | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
179
+ | `--format` | The output format for the generated markdown. It can be `markdownlint` or `compact`. The default value is `compact`. |
163
180
  | `--file` | The markdown file of the changelog. The default value is `CHANGELOG.md`. |
164
181
  | `--url` | The base url used to build the diff urls of the different releases. It is taken from the existing diff urls in the markdown. If no urls are found, try to catch it using the url of the git remote repository. |
165
182
  | `--https` | Set to false to use `http` instead `https` in the url (`--https=false`). |
@@ -0,0 +1,5 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
+ Deno: typeof Deno;
5
+ };
package/esm/bin.js CHANGED
@@ -1,28 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  import "./_dnt.polyfills.js";
3
3
  import * as dntShim from "./_dnt.shims.js";
4
- import { join } from "./deps/deno.land/std@0.120.0/path/mod.js";
4
+ import { join } from "./deps/deno.land/std@0.189.0/path/mod.js";
5
5
  import { Changelog, parser, Release } from "./mod.js";
6
- import { parse as parseFlag } from "./deps/deno.land/std@0.120.0/flags/mod.js";
6
+ import { parse as parseFlag } from "./deps/deno.land/std@0.189.0/flags/mod.js";
7
7
  import { parse as parseIni } from "./deps/deno.land/x/ini@v2.1.0/mod.js";
8
8
  const argv = parseFlag(dntShim.Deno.args, {
9
9
  default: {
10
10
  file: "CHANGELOG.md",
11
+ format: "compact",
11
12
  release: null,
13
+ create: null,
12
14
  url: null,
13
15
  https: true,
14
16
  quiet: false,
15
17
  },
18
+ string: ["file", "format", "url"],
16
19
  boolean: ["https", "init", "latest-release", "quiet"],
17
20
  });
18
21
  const file = join(dntShim.Deno.cwd(), argv.file);
19
22
  try {
20
23
  if (argv.init) {
21
24
  const changelog = new Changelog("Changelog").addRelease(new Release("0.1.0", new Date(), "First version"));
25
+ changelog.format = argv.format;
22
26
  save(file, changelog, true);
23
27
  dntShim.Deno.exit(0);
24
28
  }
25
29
  const changelog = parser(dntShim.Deno.readTextFileSync(file));
30
+ changelog.format = argv.format;
26
31
  if (argv["latest-release"]) {
27
32
  const release = changelog.releases.find((release) => release.date && release.version);
28
33
  if (release) {
@@ -51,6 +56,10 @@ try {
51
56
  dntShim.Deno.exit(1);
52
57
  }
53
58
  }
59
+ if (argv.create) {
60
+ const version = typeof argv.create === "string" ? argv.create : undefined;
61
+ changelog.addRelease(new Release(version));
62
+ }
54
63
  if (!changelog.url) {
55
64
  if (argv.url) {
56
65
  changelog.url = argv.url;
@@ -0,0 +1,270 @@
1
+ /** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
2
+ interface Rgb {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ }
7
+ /**
8
+ * Set changing text color to enabled or disabled
9
+ * @param value
10
+ */
11
+ export declare function setColorEnabled(value: boolean): void;
12
+ /** Get whether text color change is enabled or disabled. */
13
+ export declare function getColorEnabled(): boolean;
14
+ /**
15
+ * Reset the text modified
16
+ * @param str text to reset
17
+ */
18
+ export declare function reset(str: string): string;
19
+ /**
20
+ * Make the text bold.
21
+ * @param str text to make bold
22
+ */
23
+ export declare function bold(str: string): string;
24
+ /**
25
+ * The text emits only a small amount of light.
26
+ * @param str text to dim
27
+ */
28
+ export declare function dim(str: string): string;
29
+ /**
30
+ * Make the text italic.
31
+ * @param str text to make italic
32
+ */
33
+ export declare function italic(str: string): string;
34
+ /**
35
+ * Make the text underline.
36
+ * @param str text to underline
37
+ */
38
+ export declare function underline(str: string): string;
39
+ /**
40
+ * Invert background color and text color.
41
+ * @param str text to invert its color
42
+ */
43
+ export declare function inverse(str: string): string;
44
+ /**
45
+ * Make the text hidden.
46
+ * @param str text to hide
47
+ */
48
+ export declare function hidden(str: string): string;
49
+ /**
50
+ * Put horizontal line through the center of the text.
51
+ * @param str text to strike through
52
+ */
53
+ export declare function strikethrough(str: string): string;
54
+ /**
55
+ * Set text color to black.
56
+ * @param str text to make black
57
+ */
58
+ export declare function black(str: string): string;
59
+ /**
60
+ * Set text color to red.
61
+ * @param str text to make red
62
+ */
63
+ export declare function red(str: string): string;
64
+ /**
65
+ * Set text color to green.
66
+ * @param str text to make green
67
+ */
68
+ export declare function green(str: string): string;
69
+ /**
70
+ * Set text color to yellow.
71
+ * @param str text to make yellow
72
+ */
73
+ export declare function yellow(str: string): string;
74
+ /**
75
+ * Set text color to blue.
76
+ * @param str text to make blue
77
+ */
78
+ export declare function blue(str: string): string;
79
+ /**
80
+ * Set text color to magenta.
81
+ * @param str text to make magenta
82
+ */
83
+ export declare function magenta(str: string): string;
84
+ /**
85
+ * Set text color to cyan.
86
+ * @param str text to make cyan
87
+ */
88
+ export declare function cyan(str: string): string;
89
+ /**
90
+ * Set text color to white.
91
+ * @param str text to make white
92
+ */
93
+ export declare function white(str: string): string;
94
+ /**
95
+ * Set text color to gray.
96
+ * @param str text to make gray
97
+ */
98
+ export declare function gray(str: string): string;
99
+ /**
100
+ * Set text color to bright black.
101
+ * @param str text to make bright-black
102
+ */
103
+ export declare function brightBlack(str: string): string;
104
+ /**
105
+ * Set text color to bright red.
106
+ * @param str text to make bright-red
107
+ */
108
+ export declare function brightRed(str: string): string;
109
+ /**
110
+ * Set text color to bright green.
111
+ * @param str text to make bright-green
112
+ */
113
+ export declare function brightGreen(str: string): string;
114
+ /**
115
+ * Set text color to bright yellow.
116
+ * @param str text to make bright-yellow
117
+ */
118
+ export declare function brightYellow(str: string): string;
119
+ /**
120
+ * Set text color to bright blue.
121
+ * @param str text to make bright-blue
122
+ */
123
+ export declare function brightBlue(str: string): string;
124
+ /**
125
+ * Set text color to bright magenta.
126
+ * @param str text to make bright-magenta
127
+ */
128
+ export declare function brightMagenta(str: string): string;
129
+ /**
130
+ * Set text color to bright cyan.
131
+ * @param str text to make bright-cyan
132
+ */
133
+ export declare function brightCyan(str: string): string;
134
+ /**
135
+ * Set text color to bright white.
136
+ * @param str text to make bright-white
137
+ */
138
+ export declare function brightWhite(str: string): string;
139
+ /**
140
+ * Set background color to black.
141
+ * @param str text to make its background black
142
+ */
143
+ export declare function bgBlack(str: string): string;
144
+ /**
145
+ * Set background color to red.
146
+ * @param str text to make its background red
147
+ */
148
+ export declare function bgRed(str: string): string;
149
+ /**
150
+ * Set background color to green.
151
+ * @param str text to make its background green
152
+ */
153
+ export declare function bgGreen(str: string): string;
154
+ /**
155
+ * Set background color to yellow.
156
+ * @param str text to make its background yellow
157
+ */
158
+ export declare function bgYellow(str: string): string;
159
+ /**
160
+ * Set background color to blue.
161
+ * @param str text to make its background blue
162
+ */
163
+ export declare function bgBlue(str: string): string;
164
+ /**
165
+ * Set background color to magenta.
166
+ * @param str text to make its background magenta
167
+ */
168
+ export declare function bgMagenta(str: string): string;
169
+ /**
170
+ * Set background color to cyan.
171
+ * @param str text to make its background cyan
172
+ */
173
+ export declare function bgCyan(str: string): string;
174
+ /**
175
+ * Set background color to white.
176
+ * @param str text to make its background white
177
+ */
178
+ export declare function bgWhite(str: string): string;
179
+ /**
180
+ * Set background color to bright black.
181
+ * @param str text to make its background bright-black
182
+ */
183
+ export declare function bgBrightBlack(str: string): string;
184
+ /**
185
+ * Set background color to bright red.
186
+ * @param str text to make its background bright-red
187
+ */
188
+ export declare function bgBrightRed(str: string): string;
189
+ /**
190
+ * Set background color to bright green.
191
+ * @param str text to make its background bright-green
192
+ */
193
+ export declare function bgBrightGreen(str: string): string;
194
+ /**
195
+ * Set background color to bright yellow.
196
+ * @param str text to make its background bright-yellow
197
+ */
198
+ export declare function bgBrightYellow(str: string): string;
199
+ /**
200
+ * Set background color to bright blue.
201
+ * @param str text to make its background bright-blue
202
+ */
203
+ export declare function bgBrightBlue(str: string): string;
204
+ /**
205
+ * Set background color to bright magenta.
206
+ * @param str text to make its background bright-magenta
207
+ */
208
+ export declare function bgBrightMagenta(str: string): string;
209
+ /**
210
+ * Set background color to bright cyan.
211
+ * @param str text to make its background bright-cyan
212
+ */
213
+ export declare function bgBrightCyan(str: string): string;
214
+ /**
215
+ * Set background color to bright white.
216
+ * @param str text to make its background bright-white
217
+ */
218
+ export declare function bgBrightWhite(str: string): string;
219
+ /**
220
+ * Set text color using paletted 8bit colors.
221
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
222
+ * @param str text color to apply paletted 8bit colors to
223
+ * @param color code
224
+ */
225
+ export declare function rgb8(str: string, color: number): string;
226
+ /**
227
+ * Set background color using paletted 8bit colors.
228
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
229
+ * @param str text color to apply paletted 8bit background colors to
230
+ * @param color code
231
+ */
232
+ export declare function bgRgb8(str: string, color: number): string;
233
+ /**
234
+ * Set text color using 24bit rgb.
235
+ * `color` can be a number in range `0x000000` to `0xffffff` or
236
+ * an `Rgb`.
237
+ *
238
+ * To produce the color magenta:
239
+ *
240
+ * ```ts
241
+ * import { rgb24 } from "./colors.ts";
242
+ * rgb24("foo", 0xff00ff);
243
+ * rgb24("foo", {r: 255, g: 0, b: 255});
244
+ * ```
245
+ * @param str text color to apply 24bit rgb to
246
+ * @param color code
247
+ */
248
+ export declare function rgb24(str: string, color: number | Rgb): string;
249
+ /**
250
+ * Set background color using 24bit rgb.
251
+ * `color` can be a number in range `0x000000` to `0xffffff` or
252
+ * an `Rgb`.
253
+ *
254
+ * To produce the color magenta:
255
+ *
256
+ * ```ts
257
+ * import { bgRgb24 } from "./colors.ts";
258
+ * bgRgb24("foo", 0xff00ff);
259
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
260
+ * ```
261
+ * @param str text color to apply 24bit rgb to
262
+ * @param color code
263
+ */
264
+ export declare function bgRgb24(str: string, color: number | Rgb): string;
265
+ /**
266
+ * Remove ANSI escape codes from the string.
267
+ * @param string to remove ANSI escape codes from
268
+ */
269
+ export declare function stripColor(string: string): string;
270
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare enum DiffType {
2
+ removed = "removed",
3
+ common = "common",
4
+ added = "added"
5
+ }
6
+ export interface DiffResult<T> {
7
+ type: DiffType;
8
+ value: T;
9
+ details?: Array<DiffResult<T>>;
10
+ }
11
+ /**
12
+ * Renders the differences between the actual and expected values
13
+ * @param A Actual value
14
+ * @param B Expected value
15
+ */
16
+ export declare function diff<T>(A: T[], B: T[]): Array<DiffResult<T>>;
17
+ /**
18
+ * Renders the differences between the actual and expected strings
19
+ * Partially inspired from https://github.com/kpdecker/jsdiff
20
+ * @param A Actual string
21
+ * @param B Expected string
22
+ */
23
+ export declare function diffstr(A: string, B: string): DiffResult<string>[];
@@ -0,0 +1,167 @@
1
+ export declare class AssertionError extends Error {
2
+ name: string;
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * Converts the input into a string. Objects, Sets and Maps are sorted so as to
7
+ * make tests less flaky
8
+ * @param v Value to be formatted
9
+ */
10
+ export declare function _format(v: unknown): string;
11
+ /**
12
+ * Deep equality comparison used in assertions
13
+ * @param c actual value
14
+ * @param d expected value
15
+ */
16
+ export declare function equal(c: unknown, d: unknown): boolean;
17
+ /** Make an assertion, error will be thrown if `expr` does not have truthy value. */
18
+ export declare function assert(expr: unknown, msg?: string): asserts expr;
19
+ /**
20
+ * Make an assertion that `actual` and `expected` are equal, deeply. If not
21
+ * deeply equal, then throw.
22
+ *
23
+ * Type parameter can be specified to ensure values under comparison have the same type.
24
+ * For example:
25
+ * ```ts
26
+ * import { assertEquals } from "./asserts.ts";
27
+ *
28
+ * assertEquals<number>(1, 2)
29
+ * ```
30
+ */
31
+ export declare function assertEquals(actual: unknown, expected: unknown, msg?: string): void;
32
+ export declare function assertEquals<T>(actual: T, expected: T, msg?: string): void;
33
+ /**
34
+ * Make an assertion that `actual` and `expected` are not equal, deeply.
35
+ * If not then throw.
36
+ *
37
+ * Type parameter can be specified to ensure values under comparison have the same type.
38
+ * For example:
39
+ * ```ts
40
+ * import { assertNotEquals } from "./asserts.ts";
41
+ *
42
+ * assertNotEquals<number>(1, 2)
43
+ * ```
44
+ */
45
+ export declare function assertNotEquals(actual: unknown, expected: unknown, msg?: string): void;
46
+ export declare function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
47
+ /**
48
+ * Make an assertion that `actual` and `expected` are strictly equal. If
49
+ * not then throw.
50
+ *
51
+ * ```ts
52
+ * import { assertStrictEquals } from "./asserts.ts";
53
+ *
54
+ * assertStrictEquals(1, 2)
55
+ * ```
56
+ */
57
+ export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
58
+ /**
59
+ * Make an assertion that `actual` and `expected` are not strictly equal.
60
+ * If the values are strictly equal then throw.
61
+ *
62
+ * ```ts
63
+ * import { assertNotStrictEquals } from "./asserts.ts";
64
+ *
65
+ * assertNotStrictEquals(1, 1)
66
+ * ```
67
+ */
68
+ export declare function assertNotStrictEquals(actual: unknown, expected: unknown, msg?: string): void;
69
+ export declare function assertNotStrictEquals<T>(actual: T, expected: T, msg?: string): void;
70
+ /**
71
+ * Make an assertion that `actual` and `expected` are almost equal numbers through
72
+ * a given tolerance. It can be used to take into account IEEE-754 double-precision
73
+ * floating-point representation limitations.
74
+ * If the values are not almost equal then throw.
75
+ *
76
+ * ```ts
77
+ * import { assertAlmostEquals, assertThrows } from "./asserts.ts";
78
+ *
79
+ * assertAlmostEquals(0.1, 0.2);
80
+ *
81
+ * // Using a custom tolerance value
82
+ * assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16);
83
+ * assertThrows(() => assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17));
84
+ * ```
85
+ */
86
+ export declare function assertAlmostEquals(actual: number, expected: number, tolerance?: number, msg?: string): void;
87
+ type AnyConstructor = new (...args: any[]) => any;
88
+ type GetConstructorType<T extends AnyConstructor> = T extends new (...args: any) => infer C ? C : never;
89
+ /**
90
+ * Make an assertion that `obj` is an instance of `type`.
91
+ * If not then throw.
92
+ */
93
+ export declare function assertInstanceOf<T extends AnyConstructor>(actual: unknown, expectedType: T, msg?: string): asserts actual is GetConstructorType<T>;
94
+ /**
95
+ * Make an assertion that actual is not null or undefined.
96
+ * If not then throw.
97
+ */
98
+ export declare function assertExists<T>(actual: T, msg?: string): asserts actual is NonNullable<T>;
99
+ /**
100
+ * Make an assertion that actual includes expected. If not
101
+ * then throw.
102
+ */
103
+ export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
104
+ /**
105
+ * Make an assertion that `actual` includes the `expected` values.
106
+ * If not then an error will be thrown.
107
+ *
108
+ * Type parameter can be specified to ensure values under comparison have the same type.
109
+ * For example:
110
+ *
111
+ * ```ts
112
+ * import { assertArrayIncludes } from "./asserts.ts";
113
+ *
114
+ * assertArrayIncludes<number>([1, 2], [2])
115
+ * ```
116
+ */
117
+ export declare function assertArrayIncludes(actual: ArrayLike<unknown>, expected: ArrayLike<unknown>, msg?: string): void;
118
+ export declare function assertArrayIncludes<T>(actual: ArrayLike<T>, expected: ArrayLike<T>, msg?: string): void;
119
+ /**
120
+ * Make an assertion that `actual` match RegExp `expected`. If not
121
+ * then throw.
122
+ */
123
+ export declare function assertMatch(actual: string, expected: RegExp, msg?: string): void;
124
+ /**
125
+ * Make an assertion that `actual` not match RegExp `expected`. If match
126
+ * then throw.
127
+ */
128
+ export declare function assertNotMatch(actual: string, expected: RegExp, msg?: string): void;
129
+ /**
130
+ * Make an assertion that `actual` object is a subset of `expected` object, deeply.
131
+ * If not, then throw.
132
+ */
133
+ export declare function assertObjectMatch(actual: Record<PropertyKey, any>, expected: Record<PropertyKey, unknown>): void;
134
+ /**
135
+ * Forcefully throws a failed assertion
136
+ */
137
+ export declare function fail(msg?: string): never;
138
+ /**
139
+ * Make an assertion that `error` is an `Error`.
140
+ * If not then an error will be thrown.
141
+ * An error class and a string that should be included in the
142
+ * error message can also be asserted.
143
+ */
144
+ export declare function assertIsError<E extends Error = Error>(error: unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): asserts error is E;
145
+ /**
146
+ * Executes a function, expecting it to throw. If it does not, then it
147
+ * throws. An error class and a string that should be included in the
148
+ * error message can also be asserted. Or you can pass a
149
+ * callback which will be passed the error, usually to apply some custom
150
+ * assertions on it.
151
+ */
152
+ export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): void;
153
+ export declare function assertThrows(fn: () => unknown, errorCallback: (e: Error) => unknown, msg?: string): void;
154
+ /**
155
+ * Executes a function which returns a promise, expecting it to throw or reject.
156
+ * If it does not, then it throws. An error class and a string that should be
157
+ * included in the error message can also be asserted. Or you can pass a
158
+ * callback which will be passed the error, usually to apply some custom
159
+ * assertions on it.
160
+ */
161
+ export declare function assertRejects<E extends Error = Error>(fn: () => Promise<unknown>, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<void>;
162
+ export declare function assertRejects(fn: () => Promise<unknown>, errorCallback: (e: Error) => unknown, msg?: string): Promise<void>;
163
+ /** Use this to stub out methods that will throw when invoked. */
164
+ export declare function unimplemented(msg?: string): never;
165
+ /** Use this to assert unreachable code. */
166
+ export declare function unreachable(): never;
167
+ export {};