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

shelljs-changelog

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shelljs-changelog - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

57

index.js
#!/usr/bin/env node
var assert = require('assert');
require('shelljs-plugin-sleep');
require('shelljs/global');

@@ -8,2 +10,11 @@

// The maximum number of deletions for updating the changelog should
// be 5 lines. Typically, the "Unreleased" and "Full Changelog" links
// are changed because the version increases.
var MAX_DELETIONS = 5;
// Command line option: --force
// Skips validating the number of deletions in the changelog diff.
var force = (process.argv.indexOf('--force') >= 0);
function parseGitUri(uri) {

@@ -14,5 +25,35 @@ return uri.match(/https:..github.com\/([^./]+)\/([^./]+).*/) ||

function verifyChangelog() {
var diff = exec('git diff HEAD CHANGELOG.md').split('\n');
var changelog = cat('CHANGELOG.md').split('\n');
if (changelog[changelog.length - 1] === '') changelog.pop();
var isOneLine = (changelog.length === 1);
var deletions = diff.filter(function (x) {
return /^-/.test(x);
}).length;
var containsError = false;
diff.forEach(function (line) {
if (line.indexOf('Make a POST first') >= 0) containsError = true;
});
assert(
changelog.length > 1,
'Changelog was reduced to one line, this is an error.'
);
assert(
!containsError,
'Changelog contains an error message.'
);
assert(
deletions < MAX_DELETIONS,
'Too many deletions (-' + deletions + '), this is probably an error.\n' +
'Run with --force to ignore this error.'
);
}
function revertChanges() {
exec('git checkout -- .');
}
function run() {
echo('...generating changelog (be patient)');
config.silent = true;

@@ -34,3 +75,3 @@ var urls = exec('git remote show -n origin')

do {
exec('sleep 1');
sleep(1);
newLog = exec('curl "' + url + '"');

@@ -43,6 +84,16 @@ } while (newLog.match(/^Working, try again.*/));

exec('git ls-files --exclude-standard --modified --others').split('\n').forEach(function (file) {
if ( file === 'CHANGELOG.md') changelog_was_updated = true;
if (file === 'CHANGELOG.md') changelog_was_updated = true;
});
if (changelog_was_updated) {
if (!force) {
try {
echo('...verifying changelog');
verifyChangelog();
} catch (err) {
revertChanges();
console.error(err.message);
process.exit(1);
}
}
echo('...committing updated changelog');

@@ -49,0 +100,0 @@ var current_user = exec('git config user.name').trimRight();

7

package.json
{
"name": "shelljs-changelog",
"version": "0.2.5",
"version": "0.2.6",
"description": "A simple script to create & update a changelog",

@@ -29,7 +29,8 @@ "main": "index.js",

"dependencies": {
"shelljs": "^0.7.0"
"shelljs": "^0.8.5",
"shelljs-plugin-sleep": "^0.2.1"
},
"devDependencies": {
"shelljs-release": "^0.2.0"
"shelljs-release": "^0.5.1"
}
}

@@ -35,1 +35,8 @@ # Changelog.js

For best results, try to run this after every time you publish.
## Command line options
### `--force`
By default, this script verifies that the changelog diff contains no more than
5 deletions. With `--force` enabled, this step is skipped.
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