Socket
Socket
Sign inDemoInstall

@metamask/auto-changelog

Package Overview
Dependencies
Maintainers
10
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/auto-changelog - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

8

dist/changelog.d.ts
import { ChangeCategory, Version } from './constants';
/**
* Formatter function that formats a Markdown changelog string.
*/
export declare type Formatter = (changelog: string) => string;
declare type ReleaseMetadata = {

@@ -46,6 +50,8 @@ /**

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A function that formats the changelog string.
*/
constructor({ repoUrl, tagPrefix, }: {
constructor({ repoUrl, tagPrefix, formatter, }: {
repoUrl: string;
tagPrefix?: string;
formatter?: Formatter;
});

@@ -52,0 +58,0 @@ /**

12

dist/changelog.js

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

};
var _Changelog_releases, _Changelog_changes, _Changelog_repoUrl, _Changelog_tagPrefix;
var _Changelog_releases, _Changelog_changes, _Changelog_repoUrl, _Changelog_tagPrefix, _Changelog_formatter;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -190,4 +190,5 @@ const semver_1 = __importDefault(require("semver"));

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A function that formats the changelog string.
*/
constructor({ repoUrl, tagPrefix = 'v', }) {
constructor({ repoUrl, tagPrefix = 'v', formatter = (changelog) => changelog, }) {
_Changelog_releases.set(this, void 0);

@@ -197,2 +198,3 @@ _Changelog_changes.set(this, void 0);

_Changelog_tagPrefix.set(this, void 0);
_Changelog_formatter.set(this, void 0);
__classPrivateFieldSet(this, _Changelog_releases, [], "f");

@@ -202,2 +204,3 @@ __classPrivateFieldSet(this, _Changelog_changes, { [constants_1.unreleased]: {} }, "f");

__classPrivateFieldSet(this, _Changelog_tagPrefix, tagPrefix, "f");
__classPrivateFieldSet(this, _Changelog_formatter, formatter, "f");
}

@@ -361,3 +364,3 @@ /**

toString() {
return `${changelogTitle}
const changelog = `${changelogTitle}
${changelogDescription}

@@ -368,6 +371,7 @@

${stringifyLinkReferenceDefinitions(__classPrivateFieldGet(this, _Changelog_repoUrl, "f"), __classPrivateFieldGet(this, _Changelog_tagPrefix, "f"), __classPrivateFieldGet(this, _Changelog_releases, "f"))}`;
return __classPrivateFieldGet(this, _Changelog_formatter, "f").call(this, changelog);
}
}
exports.default = Changelog;
_Changelog_releases = new WeakMap(), _Changelog_changes = new WeakMap(), _Changelog_repoUrl = new WeakMap(), _Changelog_tagPrefix = new WeakMap();
_Changelog_releases = new WeakMap(), _Changelog_changes = new WeakMap(), _Changelog_repoUrl = new WeakMap(), _Changelog_tagPrefix = new WeakMap(), _Changelog_formatter = new WeakMap();
//# sourceMappingURL=changelog.js.map

@@ -9,2 +9,3 @@ #!/usr/bin/env node

const path_1 = __importDefault(require("path"));
const prettier_1 = __importDefault(require("prettier"));
const semver_1 = __importDefault(require("semver"));

@@ -84,4 +85,5 @@ const helpers_1 = require("yargs/helpers");

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A custom Markdown formatter to use.
*/
async function update({ changelogPath, currentVersion, isReleaseCandidate, repoUrl, projectRootDirectory, tagPrefix, }) {
async function update({ changelogPath, currentVersion, isReleaseCandidate, repoUrl, projectRootDirectory, tagPrefix, formatter, }) {
const changelogContent = await readChangelog(changelogPath);

@@ -95,2 +97,3 @@ const newChangelogContent = await (0, update_changelog_1.updateChangelog)({

tagPrefixes: [tagPrefix],
formatter,
});

@@ -115,4 +118,5 @@ if (newChangelogContent) {

* @param options.fix - Whether to attempt to fix the changelog or not.
* @param options.formatter - A custom Markdown formatter to use.
*/
async function validate({ changelogPath, currentVersion, isReleaseCandidate, repoUrl, tagPrefix, fix, }) {
async function validate({ changelogPath, currentVersion, isReleaseCandidate, repoUrl, tagPrefix, fix, formatter, }) {
const changelogContent = await readChangelog(changelogPath);

@@ -126,2 +130,3 @@ try {

tagPrefix,
formatter,
});

@@ -215,2 +220,7 @@ return undefined;

})
.option('prettier', {
default: false,
description: `Expect the changelog to be formatted with Prettier.`,
type: 'boolean',
})
.epilog(updateEpilog))

@@ -232,2 +242,7 @@ .command('validate', 'Validate the changelog, ensuring that it is well-formatted.\nUsage: $0 validate [options]', (_yargs) => configureCommonCommandOptions(_yargs)

})
.option('prettier', {
default: false,
description: `Expect the changelog to be formatted with Prettier.`,
type: 'boolean',
})
.epilog(validateEpilog))

@@ -241,3 +256,3 @@ .command('init', 'Initialize a new empty changelog', (_yargs) => {

.usage(`Utilities for validating and updating "Keep a Changelog" formatted changelogs.\nUsage: $0 [command] [options]`);
const { file: changelogFilename, rc: isReleaseCandidate, repo: repoUrl, root: projectRootDirectory, tagPrefix, fix, } = argv;
const { file: changelogFilename, rc: isReleaseCandidate, repo: repoUrl, root: projectRootDirectory, tagPrefix, fix, prettier: usePrettier, } = argv;
let { currentVersion } = argv;

@@ -321,2 +336,7 @@ if (projectRootDirectory) {

}
const formatter = (changelog) => {
return usePrettier
? prettier_1.default.format(changelog, { parser: 'markdown' })
: changelog;
};
if (command === 'update') {

@@ -330,2 +350,3 @@ await update({

tagPrefix,
formatter,
});

@@ -341,2 +362,3 @@ }

fix,
formatter,
});

@@ -343,0 +365,0 @@ }

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

import Changelog from './changelog';
import Changelog, { Formatter } from './changelog';
/**

@@ -10,8 +10,10 @@ * Constructs a Changelog instance that represents the given changelog, which

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A custom Markdown formatter to use.
* @returns A changelog instance that reflects the changelog text provided.
*/
export declare function parseChangelog({ changelogContent, repoUrl, tagPrefix, }: {
export declare function parseChangelog({ changelogContent, repoUrl, tagPrefix, formatter, }: {
changelogContent: string;
repoUrl: string;
tagPrefix?: string;
formatter?: Formatter;
}): Changelog;

@@ -36,7 +36,8 @@ "use strict";

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A custom Markdown formatter to use.
* @returns A changelog instance that reflects the changelog text provided.
*/
function parseChangelog({ changelogContent, repoUrl, tagPrefix = 'v', }) {
function parseChangelog({ changelogContent, repoUrl, tagPrefix = 'v', formatter = undefined, }) {
const changelogLines = changelogContent.split('\n');
const changelog = new changelog_1.default({ repoUrl, tagPrefix });
const changelog = new changelog_1.default({ repoUrl, tagPrefix, formatter });
const unreleasedHeaderIndex = changelogLines.indexOf(`## [${constants_1.unreleased}]`);

@@ -43,0 +44,0 @@ if (unreleasedHeaderIndex === -1) {

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

import { Formatter } from './changelog';
import { Version } from './constants';

@@ -9,2 +10,3 @@ export declare type UpdateChangelogOptions = {

tagPrefixes?: [string, ...string[]];
formatter?: Formatter;
};

@@ -30,4 +32,5 @@ /**

* prefix and each subsequent prefix is a fallback in case the previous tag prefixes are not found.
* @param options.formatter - A custom Markdown formatter to use.
* @returns The updated changelog text.
*/
export declare function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, tagPrefixes, }: UpdateChangelogOptions): Promise<string | undefined>;
export declare function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, tagPrefixes, formatter, }: UpdateChangelogOptions): Promise<string | undefined>;

@@ -157,5 +157,6 @@ "use strict";

* prefix and each subsequent prefix is a fallback in case the previous tag prefixes are not found.
* @param options.formatter - A custom Markdown formatter to use.
* @returns The updated changelog text.
*/
async function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, tagPrefixes = ['v'], }) {
async function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, tagPrefixes = ['v'], formatter = undefined, }) {
if (isReleaseCandidate && !currentVersion) {

@@ -168,2 +169,3 @@ throw new Error(`A version must be specified if 'isReleaseCandidate' is set.`);

tagPrefix: tagPrefixes[0],
formatter,
});

@@ -170,0 +172,0 @@ // Ensure we have all tags on remote

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

import { Formatter } from './changelog';
import { Version } from './constants';

@@ -52,2 +53,3 @@ /**

tagPrefix?: string;
formatter?: Formatter;
};

@@ -68,2 +70,3 @@ /**

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A custom Markdown formatter to use.
* @throws `InvalidChangelogError` - Will throw if the changelog is invalid

@@ -79,3 +82,3 @@ * @throws `MissingCurrentVersionError` - Will throw if `isReleaseCandidate` is

*/
export declare function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, tagPrefix, }: ValidateChangelogOptions): void;
export declare function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, tagPrefix, formatter, }: ValidateChangelogOptions): void;
export {};

@@ -77,2 +77,3 @@ "use strict";

* @param options.tagPrefix - The prefix used in tags before the version number.
* @param options.formatter - A custom Markdown formatter to use.
* @throws `InvalidChangelogError` - Will throw if the changelog is invalid

@@ -88,5 +89,10 @@ * @throws `MissingCurrentVersionError` - Will throw if `isReleaseCandidate` is

*/
function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, tagPrefix = 'v', }) {
function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, tagPrefix = 'v', formatter = undefined, }) {
var _a, _b;
const changelog = (0, parse_changelog_1.parseChangelog)({ changelogContent, repoUrl, tagPrefix });
const changelog = (0, parse_changelog_1.parseChangelog)({
changelogContent,
repoUrl,
tagPrefix,
formatter,
});
const hasUnreleasedChanges = Object.keys(changelog.getUnreleasedChanges()).length !== 0;

@@ -93,0 +99,0 @@ const releaseChanges = currentVersion

{
"name": "@metamask/auto-changelog",
"version": "3.2.0",
"version": "3.3.0",
"description": "Utilities for validating and updating \"Keep a Changelog\" formatted changelogs",

@@ -36,2 +36,3 @@ "publishConfig": {

"execa": "^5.1.1",
"prettier": "^2.8.8",
"semver": "^7.3.5",

@@ -62,3 +63,2 @@ "yargs": "^17.0.1"

"outdent": "^0.8.0",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",

@@ -65,0 +65,0 @@ "ts-jest": "^26.5.6",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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