Socket
Socket
Sign inDemoInstall

keep-a-changelog

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keep-a-changelog - npm Package Compare versions

Comparing version 2.1.0 to 2.2.1

esm/deps/deno.land/std@0.173.0/_util/asserts.js

19

CHANGELOG.md
<!-- deno-fmt-ignore-file -->
# Changelog
All notable changes to this project will be documented in this file.

@@ -10,2 +9,14 @@

## [2.2.1] - 2023-01-25
### Fixed
- Allow list elements in the descriptions of releases and changelogs [#30].
## [2.2.0] - 2023-01-18
### Added
- New option `format` to configure the output option [#28].
- `Release.setYanked` function [#26].
### Fixed
- Removed unnecessary new line after the title [#27].
## [2.1.0] - 2022-04-03

@@ -33,5 +44,11 @@ ### Added

[#25]: https://github.com/oscarotero/keep-a-changelog/issues/25
[#26]: https://github.com/oscarotero/keep-a-changelog/issues/26
[#27]: https://github.com/oscarotero/keep-a-changelog/issues/27
[#28]: https://github.com/oscarotero/keep-a-changelog/issues/28
[#30]: https://github.com/oscarotero/keep-a-changelog/issues/30
[2.2.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.2.0...v2.2.1
[2.2.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/oscarotero/keep-a-changelog/releases/tag/v2.0.0

8

esm/bin.js
#!/usr/bin/env node
import "./_dnt.polyfills.js";
import * as dntShim from "./_dnt.shims.js";
import { join } from "./deps/deno.land/std@0.120.0/path/mod.js";
import { join } from "./deps/deno.land/std@0.173.0/path/mod.js";
import { Changelog, parser, Release } from "./mod.js";
import { parse as parseFlag } from "./deps/deno.land/std@0.120.0/flags/mod.js";
import { parse as parseFlag } from "./deps/deno.land/std@0.173.0/flags/mod.js";
import { parse as parseIni } from "./deps/deno.land/x/ini@v2.1.0/mod.js";

@@ -11,2 +11,3 @@ const argv = parseFlag(dntShim.Deno.args, {

file: "CHANGELOG.md",
format: "compact",
release: null,

@@ -17,2 +18,3 @@ url: null,

},
string: ["file", "format", "release", "url"],
boolean: ["https", "init", "latest-release", "quiet"],

@@ -24,2 +26,3 @@ });

const changelog = new Changelog("Changelog").addRelease(new Release("0.1.0", new Date(), "First version"));
changelog.format = argv.format;
save(file, changelog, true);

@@ -29,2 +32,3 @@ dntShim.Deno.exit(0);

const changelog = parser(dntShim.Deno.readTextFileSync(file));
changelog.format = argv.format;
if (argv["latest-release"]) {

@@ -31,0 +35,0 @@ const release = changelog.releases.find((release) => release.date && release.version);

export default class Change {
static extractIssues(text, issues) {
return text
.replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
})
.replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
});
}
constructor(title, description = "") {

@@ -24,17 +39,2 @@ Object.defineProperty(this, "title", {

}
static extractIssues(text, issues) {
return text
.replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
})
.replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
});
}
toString() {

@@ -41,0 +41,0 @@ let t = this.title.split("\n").map((line) => ` ${line}`.trimEnd());

@@ -52,2 +52,8 @@ import { eq } from "./deps.js";

});
Object.defineProperty(this, "format", {
enumerable: true,
configurable: true,
writable: true,
value: "compact"
});
this.title = title;

@@ -84,2 +90,5 @@ this.description = description;

t.push(`# ${this.title}`);
if (this.format === "markdownlint") {
t.push("");
}
const links = [];

@@ -93,3 +102,2 @@ const compareLinks = [];

if (description) {
t.push("");
t.push(description);

@@ -96,0 +104,0 @@ }

@@ -1,1 +0,1 @@

export { default as Semver, eq, } from "../deps/deno.land/x/semver@v1.4.0/mod.js";
export { default as Semver, eq, } from "../deps/deno.land/std@0.173.0/semver/mod.js";

@@ -22,3 +22,3 @@ import Changelog from "./Changelog.js";

changelog.title = getContent(tokens, "h1", true);
changelog.description = getContent(tokens, "p");
changelog.description = getTextContent(tokens);
//Releases

@@ -44,3 +44,3 @@ let release;

changelog.addRelease(release);
release.description = getContent(tokens, "p");
release.description = getTextContent(tokens);
let type;

@@ -76,3 +76,4 @@ while ((type = getContent(tokens, "h3").toLowerCase())) {

function getContent(tokens, type, required = false) {
if (!tokens[0] || tokens[0][1] !== type) {
const types = Array.isArray(type) ? type : [type];
if (!tokens[0] || types.indexOf(tokens[0][1]) === -1) {
if (required) {

@@ -85,2 +86,17 @@ throw new Error(`Required token missing in: "${tokens[0][0]}"`);

}
/** Return the next text content */
function getTextContent(tokens) {
const lines = [];
const types = ["p", "li"];
while (tokens[0] && types.indexOf(tokens[0][1]) !== -1) {
const token = tokens.shift();
if (token[1] === "li") {
lines.push("- " + token[2].join("\n"));
}
else {
lines.push(token[2].join("\n"));
}
}
return lines.join("\n");
}
/** Tokenize a markdown string */

@@ -87,0 +103,0 @@ function tokenize(markdown) {

@@ -93,2 +93,6 @@ import { Semver } from "./deps.js";

}
setYanked(yanked = true) {
this.yanked = yanked;
return this;
}
addChange(type, change) {

@@ -142,2 +146,5 @@ if (!(change instanceof Change)) {

}
if (changelog?.format === "markdownlint") {
t.push("");
}
if (this.description.trim()) {

@@ -150,2 +157,5 @@ t.push(this.description.trim());

t.push(`### ${type[0].toUpperCase()}${type.substring(1)}`);
if (changelog?.format === "markdownlint") {
t.push("");
}
t = t.concat(changes.map((change) => change.toString()));

@@ -152,0 +162,0 @@ t.push("");

# Changelog - demo
All notable changes to this project will be documented in this file.

@@ -4,0 +3,0 @@

# Changelog - demo
All notable changes to this project will be documented in this file.

@@ -10,2 +9,5 @@

## [Unreleased] [YANKED]
This is a brand new releases with:
- Configuration is now done within the Web client, for authorized users.
### Added

@@ -12,0 +14,0 @@ - Test

@@ -10,3 +10,7 @@ # Changelog - demo

## [Unreleased] [Yanked]
This is a brand new releases with:
- Configuration is now done within the Web client, for authorized users.
### Added

@@ -13,0 +17,0 @@

# Changelog
All notable changes to this project will be documented in this file.

@@ -4,0 +3,0 @@

@@ -9,3 +9,3 @@ {

"name": "keep-a-changelog",
"version": "2.1.0",
"version": "2.2.1",
"description": "Node package to parse and generate changelogs following the [keepachangelog](http://keepachangelog.com/en/1.0.0/) format.",

@@ -29,5 +29,10 @@ "homepage": "https://github.com/oscarotero/keep-a-changelog#readme",

".": {
"import": "./esm/mod.js",
"require": "./script/mod.js",
"types": "./types/mod.d.ts"
"import": {
"types": "./types/mod.d.ts",
"default": "./esm/mod.js"
},
"require": {
"types": "./types/mod.d.ts",
"default": "./script/mod.js"
}
}

@@ -39,8 +44,8 @@ },

"dependencies": {
"@deno/shim-deno": "~0.4.3"
"@deno/shim-deno": "~0.12.0"
},
"devDependencies": {
"@types/node": "16.11.26",
"chalk": "4.1.2"
"@types/node": "^18.11.9",
"chalk": "^4.1.2"
}
}
}

@@ -59,2 +59,13 @@ # Changelog

### Custom output format
By default, the output format of the markdown is "compact", that removes the
space after the headings. You can change it to follow the
[`markdownlint`](https://github.com/DavidAnson/markdownlint) rules:
```js
const changelog = new Changelog();
changelog.format = "markdownlint";
```
### Custom tag names

@@ -77,6 +88,6 @@

In case you'd like add another type in order to use is in your changelog, you
basically need to extend the `Release` class to support new types. Additionally,
you have to tell the `parser` that it should create instances of your new
extended `Release` in order to parse your changelog correctly.
In case you'd like add another type, you need to extend the `Release` class to
support new types. Additionally, you have to tell the `parser` that it should
create instances of your new extended `Release` in order to parse your changelog
correctly.

@@ -165,2 +176,3 @@ For example, we would like to add a type `Maintenance`. Extend the provided

| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--format` | The output format for the generated markdown. It can be `markdownlint` or `compact`. The default value is `compact`. |
| `--file` | The markdown file of the changelog. The default value is `CHANGELOG.md`. |

@@ -167,0 +179,0 @@ | `--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. |

@@ -29,5 +29,5 @@ #!/usr/bin/env node

const dntShim = __importStar(require("./_dnt.shims.js"));
const mod_js_1 = require("./deps/deno.land/std@0.120.0/path/mod.js");
const mod_js_1 = require("./deps/deno.land/std@0.173.0/path/mod.js");
const mod_js_2 = require("./mod.js");
const mod_js_3 = require("./deps/deno.land/std@0.120.0/flags/mod.js");
const mod_js_3 = require("./deps/deno.land/std@0.173.0/flags/mod.js");
const mod_js_4 = require("./deps/deno.land/x/ini@v2.1.0/mod.js");

@@ -37,2 +37,3 @@ const argv = (0, mod_js_3.parse)(dntShim.Deno.args, {

file: "CHANGELOG.md",
format: "compact",
release: null,

@@ -43,2 +44,3 @@ url: null,

},
string: ["file", "format", "release", "url"],
boolean: ["https", "init", "latest-release", "quiet"],

@@ -50,2 +52,3 @@ });

const changelog = new mod_js_2.Changelog("Changelog").addRelease(new mod_js_2.Release("0.1.0", new Date(), "First version"));
changelog.format = argv.format;
save(file, changelog, true);

@@ -55,2 +58,3 @@ dntShim.Deno.exit(0);

const changelog = (0, mod_js_2.parser)(dntShim.Deno.readTextFileSync(file));
changelog.format = argv.format;
if (argv["latest-release"]) {

@@ -57,0 +61,0 @@ const release = changelog.releases.find((release) => release.date && release.version);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Change {
static extractIssues(text, issues) {
return text
.replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
})
.replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
});
}
constructor(title, description = "") {

@@ -26,17 +41,2 @@ Object.defineProperty(this, "title", {

}
static extractIssues(text, issues) {
return text
.replace(/(^|[^\\])\[#(\d+)\](?=[^\(]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
})
.replace(/(^|[\s,])#(\d+)(?=[\s,\.]|$)/g, (_, start, index) => {
if (!issues.includes(index)) {
issues.push(index);
}
return `${start}[#${index}]`;
});
}
toString() {

@@ -43,0 +43,0 @@ let t = this.title.split("\n").map((line) => ` ${line}`.trimEnd());

@@ -54,2 +54,8 @@ "use strict";

});
Object.defineProperty(this, "format", {
enumerable: true,
configurable: true,
writable: true,
value: "compact"
});
this.title = title;

@@ -86,2 +92,5 @@ this.description = description;

t.push(`# ${this.title}`);
if (this.format === "markdownlint") {
t.push("");
}
const links = [];

@@ -95,3 +104,2 @@ const compareLinks = [];

if (description) {
t.push("");
t.push(description);

@@ -98,0 +106,0 @@ }

@@ -7,4 +7,4 @@ "use strict";

exports.eq = exports.Semver = void 0;
var mod_js_1 = require("../deps/deno.land/x/semver@v1.4.0/mod.js");
var mod_js_1 = require("../deps/deno.land/std@0.173.0/semver/mod.js");
Object.defineProperty(exports, "Semver", { enumerable: true, get: function () { return __importDefault(mod_js_1).default; } });
Object.defineProperty(exports, "eq", { enumerable: true, get: function () { return mod_js_1.eq; } });

@@ -28,3 +28,3 @@ "use strict";

changelog.title = getContent(tokens, "h1", true);
changelog.description = getContent(tokens, "p");
changelog.description = getTextContent(tokens);
//Releases

@@ -50,3 +50,3 @@ let release;

changelog.addRelease(release);
release.description = getContent(tokens, "p");
release.description = getTextContent(tokens);
let type;

@@ -82,3 +82,4 @@ while ((type = getContent(tokens, "h3").toLowerCase())) {

function getContent(tokens, type, required = false) {
if (!tokens[0] || tokens[0][1] !== type) {
const types = Array.isArray(type) ? type : [type];
if (!tokens[0] || types.indexOf(tokens[0][1]) === -1) {
if (required) {

@@ -91,2 +92,17 @@ throw new Error(`Required token missing in: "${tokens[0][0]}"`);

}
/** Return the next text content */
function getTextContent(tokens) {
const lines = [];
const types = ["p", "li"];
while (tokens[0] && types.indexOf(tokens[0][1]) !== -1) {
const token = tokens.shift();
if (token[1] === "li") {
lines.push("- " + token[2].join("\n"));
}
else {
lines.push(token[2].join("\n"));
}
}
return lines.join("\n");
}
/** Tokenize a markdown string */

@@ -93,0 +109,0 @@ function tokenize(markdown) {

@@ -98,2 +98,6 @@ "use strict";

}
setYanked(yanked = true) {
this.yanked = yanked;
return this;
}
addChange(type, change) {

@@ -147,2 +151,5 @@ if (!(change instanceof Change_js_1.default)) {

}
if (changelog?.format === "markdownlint") {
t.push("");
}
if (this.description.trim()) {

@@ -155,2 +162,5 @@ t.push(this.description.trim());

t.push(`### ${type[0].toUpperCase()}${type.substring(1)}`);
if (changelog?.format === "markdownlint") {
t.push("");
}
t = t.concat(changes.map((change) => change.toString()));

@@ -157,0 +167,0 @@ t.push("");

# Changelog - demo
All notable changes to this project will be documented in this file.

@@ -4,0 +3,0 @@

# Changelog - demo
All notable changes to this project will be documented in this file.

@@ -10,2 +9,5 @@

## [Unreleased] [YANKED]
This is a brand new releases with:
- Configuration is now done within the Web client, for authorized users.
### Added

@@ -12,0 +14,0 @@ - Test

@@ -10,3 +10,7 @@ # Changelog - demo

## [Unreleased] [Yanked]
This is a brand new releases with:
- Configuration is now done within the Web client, for authorized users.
### Added

@@ -13,0 +17,0 @@

# Changelog
All notable changes to this project will be documented in this file.

@@ -4,0 +3,0 @@

@@ -12,2 +12,3 @@ import Release from "./Release.js";

tagNameBuilder?: (release: Release) => string;
format: "compact" | "markdownlint";
constructor(title: string, description?: string);

@@ -14,0 +15,0 @@ addRelease(release: Release): this;

@@ -1,1 +0,1 @@

export { default as Semver, eq, } from "../deps/deno.land/x/semver@v1.4.0/mod.js";
export { default as Semver, eq, } from "../deps/deno.land/std@0.173.0/semver/mod.js";

@@ -16,2 +16,3 @@ import { Semver } from "./deps.js";

setDate(date?: Date | string): void;
setYanked(yanked?: boolean): this;
addChange(type: string, change: Change | string): this;

@@ -18,0 +19,0 @@ added(change: Change | string): this;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc