Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/auto-changelog

Package Overview
Dependencies
Maintainers
7
Versions
20
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 2.1.0 to 2.2.0

dist/init.d.ts

15

CHANGELOG.md

@@ -9,2 +9,14 @@ # Changelog

## [2.2.0]
### Added
- Add `init` command ([#77](https://github.com/MetaMask/auto-changelog/pull/77))
### Changed
- Add `@lavamoat/allow-scripts` and `setup` command ([#78](https://github.com/MetaMask/auto-changelog/pull/78))
- Detect all PRs referenced in each change description, rather than just the first ([#84](https://github.com/MetaMask/auto-changelog/pull/84))
### Fixed
- Fix broken validation and updating when the lowest SemVer release isn't the first chronological release ([#76](https://github.com/MetaMask/auto-changelog/pull/76))
- Fix PR number detection in existing change entries ([#83](https://github.com/MetaMask/auto-changelog/pull/83))
## [2.1.0]

@@ -46,3 +58,4 @@ ### Added

[Unreleased]: https://github.com/MetaMask/auto-changelog/compare/v2.1.0...HEAD
[Unreleased]: https://github.com/MetaMask/auto-changelog/compare/v2.2.0...HEAD
[2.2.0]: https://github.com/MetaMask/auto-changelog/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/MetaMask/auto-changelog/compare/v2.0.1...v2.1.0

@@ -49,0 +62,0 @@ [2.0.1]: https://github.com/MetaMask/auto-changelog/compare/v2.0.0...v2.0.1

35

dist/changelog.js

@@ -56,3 +56,4 @@ "use strict";

function stringifyLinkReferenceDefinitions(repoUrl, releases) {
const releasesOrderedByVersion = releases
// A list of release versions in descending SemVer order
const descendingSemverVersions = releases
.map(({ version }) => version)

@@ -62,4 +63,6 @@ .sort((a, b) => {

});
const orderedReleases = releases.map(({ version }) => version);
const hasReleases = orderedReleases.length > 0;
const latestSemverVersion = descendingSemverVersions[0];
// A list of release versions in chronological order
const chronologicalVersions = releases.map(({ version }) => version);
const hasReleases = chronologicalVersions.length > 0;
// The "Unreleased" section represents all changes made since the *highest*

@@ -76,3 +79,3 @@ // release, not the most recent release. This is to accomodate patch releases

const unreleasedLinkReferenceDefinition = `[${constants_1.unreleased}]: ${hasReleases
? getCompareUrl(repoUrl, `v${releasesOrderedByVersion[0]}`, 'HEAD')
? getCompareUrl(repoUrl, `v${latestSemverVersion}`, 'HEAD')
: withTrailingSlash(repoUrl)}`;

@@ -85,12 +88,18 @@ // The "previous" release that should be used for comparison is not always

.map(({ version }) => {
if (version === orderedReleases[orderedReleases.length - 1]) {
return `[${version}]: ${getTagUrl(repoUrl, `v${version}`)}`;
let diffUrl;
if (version === chronologicalVersions[chronologicalVersions.length - 1]) {
diffUrl = getTagUrl(repoUrl, `v${version}`);
}
const versionIndex = orderedReleases.indexOf(version);
const previousVersion = orderedReleases
.slice(versionIndex)
.find((releaseVersion) => {
return semver_1.default.gt(version, releaseVersion);
});
return `[${version}]: ${getCompareUrl(repoUrl, `v${previousVersion}`, `v${version}`)}`;
else {
const versionIndex = chronologicalVersions.indexOf(version);
const previousVersion = chronologicalVersions
.slice(versionIndex)
.find((releaseVersion) => {
return semver_1.default.gt(version, releaseVersion);
});
diffUrl = previousVersion
? getCompareUrl(repoUrl, `v${previousVersion}`, `v${version}`)
: getTagUrl(repoUrl, `v${version}`);
}
return `[${version}]: ${diffUrl}`;
})

@@ -97,0 +106,0 @@ .join('\n');

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

const generate_diff_1 = require("./generate-diff");
const init_1 = require("./init");
const constants_1 = require("./constants");

@@ -98,2 +99,6 @@ const validate_changelog_1 = require("./validate-changelog");

}
async function init({ changelogPath, repoUrl }) {
const changelogContent = await init_1.createEmptyChangelog({ repoUrl });
await saveChangelog(changelogPath, changelogContent);
}
const rootDescription = `The root project directory. This determines where we \

@@ -110,7 +115,2 @@ look for changes since the last release (defaults to the entire repository at \

})
.option('currentVersion', {
default: npmPackageVersion,
description: 'The current version of the project that the changelog belongs to.',
type: 'string',
})
.option('repo', {

@@ -134,2 +134,7 @@ default: githubRepositoryUrl,

})
.option('currentVersion', {
default: npmPackageVersion,
description: 'The current version of the project that the changelog belongs to.',
type: 'string',
})
.epilog(updateEpilog))

@@ -142,3 +147,11 @@ .command('validate', 'Validate the changelog, ensuring that it is well-formatted.\nUsage: $0 validate [options]', (_yargs) => configureCommonCommandOptions(_yargs)

})
.option('currentVersion', {
default: npmPackageVersion,
description: 'The current version of the project that the changelog belongs to.',
type: 'string',
})
.epilog(validateEpilog))
.command('init', 'Initialize a new empty changelog', (_yargs) => {
configureCommonCommandOptions(_yargs);
})
.strict()

@@ -189,16 +202,22 @@ .demandCommand()

}
try {
// eslint-disable-next-line no-bitwise
await fs_1.promises.access(changelogPath, fs_1.constants.F_OK | fs_1.constants.W_OK);
if (!argv._) {
throw new Error('No command provided');
}
catch (error) {
if (error.code === 'ENOENT') {
exitWithError(`File does not exist: '${changelogPath}'`);
const command = argv._[0];
if (command !== 'init') {
try {
// eslint-disable-next-line no-bitwise
await fs_1.promises.access(changelogPath, fs_1.constants.F_OK | fs_1.constants.W_OK);
}
else {
exitWithError(`File is not writable: '${changelogPath}'`);
catch (error) {
if (error.code === 'ENOENT') {
exitWithError(`File does not exist: '${changelogPath}'`);
}
else {
exitWithError(`File is not writable: '${changelogPath}'`);
}
return;
}
return;
}
if (argv._ && argv._[0] === 'update') {
if (command === 'update') {
await update({

@@ -212,3 +231,3 @@ changelogPath,

}
else if (argv._ && argv._[0] === 'validate') {
else if (command === 'validate') {
await validate({

@@ -221,2 +240,8 @@ changelogPath,

}
else if (command === 'init') {
await init({
changelogPath,
repoUrl,
});
}
}

@@ -223,0 +248,0 @@ main().catch((error) => {

@@ -82,8 +82,5 @@ "use strict";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const matchResults = description.match(/^\[#(\d+)\]/u);
if (matchResults === null) {
continue;
}
const prNumber = matchResults[1];
prNumbersWithChangelogEntries.push(prNumber);
const matchResults = description.matchAll(/\[#(\d+)\]/gu);
const prNumbers = Array.from(matchResults, (result) => result[1]);
prNumbersWithChangelogEntries.push(...prNumbers);
}

@@ -90,0 +87,0 @@ return prNumbersWithChangelogEntries;

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

@@ -22,2 +22,4 @@ "publishConfig": {

"scripts": {
"setup": "yarn install && yarn setup:postinstall",
"setup:postinstall": "yarn allow-scripts",
"test": "jest",

@@ -41,2 +43,3 @@ "test:watch": "jest --watch",

"devDependencies": {
"@lavamoat/allow-scripts": "^1.0.6",
"@metamask/eslint-config": "^6.0.0",

@@ -65,3 +68,8 @@ "@metamask/eslint-config-jest": "^6.0.0",

"typescript": "^4.2.4"
},
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false
}
}
}

@@ -86,10 +86,20 @@ # @metamask/auto-changelog

## Testing
## Contributing
Run `yarn test` to run the tests once.
### Setup
To run tests on file changes, run `yarn test:watch`.
- Install [Node.js](https://nodejs.org) version 12
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.
- Install [Yarn v1](https://yarnpkg.com/en/docs/install)
- Run `yarn setup` to install dependencies and run any requried post-install scripts
- **Warning**: Do not use the `yarn` / `yarn install` command directly. Use `yarn setup` instead. The normal install command will skip required post-install scripts, leaving your development environment in an invalid state.
## Release & Publishing
### Testing and Linting
Run `yarn test` to run the tests once. To run tests on file changes, run `yarn test:watch`.
Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and fix any automatically fixable issues.
### Release & Publishing
The project follows the same release process as the other libraries in the MetaMask organization:

@@ -96,0 +106,0 @@

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