Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/post-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const fileExists = require('fs').existsSync;
const pathJoin = require('path').join;

function isNpxInstall() {
try {
const getNpmArgs = require('./utils/get-npm-args');
Expand All @@ -12,12 +11,10 @@ function isNpxInstall() {
return false;
}
}

(function postInstall(currentDir) {
if (isNpxInstall()) {
return;
}

const jsFile = pathJoin(currentDir || __dirname, 'init.js');
if (fileExists(jsFile)) {
const initConfiguration = require(jsFile);
Expand Down
1 change: 0 additions & 1 deletion lib/pre-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const fileExists = require('fs').existsSync;
const pathJoin = require('path').join;

(function preInstall(currentDir) {
const jsFile = pathJoin(
currentDir || __dirname,
Expand Down
2 changes: 0 additions & 2 deletions lib/reporters/ci-icon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const os = require('os');

module.exports.success = function() {
const isTeamcity = require('./env-type').isTeamcity();
const platform = os.platform();
Expand All @@ -13,7 +12,6 @@ module.exports.success = function() {
}
return '✓';
};

module.exports.error = function() {
const isTeamcity = require('./env-type').isTeamcity();
const platform = os.platform();
Expand Down
4 changes: 1 addition & 3 deletions lib/reporters/ci-reporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

/**
* Why there is no import of third-party modules at the root of this file?
* Required modules may not be available at some point
Expand All @@ -11,7 +12,6 @@
* CI reporter.
* @module reporters/ci-reporter
*/

module.exports = {
/**
* name of the reporter. Must be unique among all reporters.
Expand Down Expand Up @@ -41,7 +41,6 @@ module.exports = {
if (npxArgs && npxArgs['--ci']) {
return true;
}

const isCI = require('./env-type').isCI();
return isCI;
},
Expand Down Expand Up @@ -79,7 +78,6 @@ function reportRunningTask(taskname) {
? console.log(`${icon.success()} ${taskname}`)
: console.log(`${icon.error()} ${taskname}`);
}

return done;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/reporters/elegant-status-reporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

/**
* Why there is no import of third-party modules at the root of this file?
* Required modules may not be available at some point
Expand All @@ -11,7 +12,6 @@
* elegant status reporter.
* @module reporters/elegant-status-reporter
*/

module.exports = {
/**
* name of the reporter. Must be unique among all reporters.
Expand Down Expand Up @@ -171,7 +171,7 @@ function formatAsElegantPath(path, sep) {

// prettier-ignore
const result = packages.map(item => item.trim()).map((item, index) => {
return index === lastIndex ? chalk.red.bold(item) : item;
}).join(' -> ');
return index === lastIndex ? chalk.red.bold(item) : item;
}).join(' -> ');
return result;
}
1 change: 0 additions & 1 deletion lib/reporters/env-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module.exports.isCI = function() {
return require('is-ci') === true;
};

module.exports.isTeamcity = function() {
return 'TEAMCITY_VERSION' in process.env;
};
26 changes: 13 additions & 13 deletions src/utils/npm-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,20 @@ function removeIgnoredVulnerabilities(response, options) {

function filterIgnoredVulnerabilities(vulnerabilities, ignoredVulnerabilities) {
const isIgnoredVulnerability = ({ url }) => {
return !ignoredVulnerabilities
.some(ignoredVulnerability => {
return url ? url.indexOf(ignoredVulnerability) > 0 : false;
});
}
return !ignoredVulnerabilities.some((ignoredVulnerability) => {
return url ? url.indexOf(ignoredVulnerability) > 0 : false;
});
};

return Object.keys(vulnerabilities)
.map((vulnerability) => {
vulnerabilities[vulnerability].via = vulnerabilities[vulnerability].via
.filter(isIgnoredVulnerability);
vulnerabilities[vulnerability].via = vulnerabilities[
vulnerability
].via.filter(isIgnoredVulnerability);

return vulnerabilities[vulnerability];
})
.filter(vulnerability => vulnerability.via.length === 0);
.filter((vulnerability) => vulnerability.via.length === 0);
}

/**
Expand Down Expand Up @@ -463,11 +463,11 @@ function removeIgnoredLevels(response, options) {
}

function filterIgnoredLevels(vulnerabilities, filteredLevels) {
return Object.keys(vulnerabilities).filter(
(vulnerability) => {
return filteredLevels.indexOf(vulnerabilities[vulnerability].severity) < 0;
}
);
return Object.keys(vulnerabilities).filter((vulnerability) => {
return (
filteredLevels.indexOf(vulnerabilities[vulnerability].severity) < 0
);
});
}

/**
Expand Down
19 changes: 12 additions & 7 deletions src/validations/vulnerable-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ module.exports = {

Object.keys(result.vulnerabilities).forEach(
(vulnerability) => {
result.vulnerabilities[vulnerability].nodes
.forEach((path) => {
const formattedPath = summaryOf(path.replace(/^node_modules\//g, ''));
result.vulnerabilities[
vulnerability
].nodes.forEach((path) => {
const formattedPath = summaryOf(
path.replace(/^node_modules\//g, '')
);

errs.add(formattedPath);
});
errs.add(formattedPath);
});
}
);
const distinctAndSortedErrors = Array.from(
Expand All @@ -71,9 +74,11 @@ module.exports = {
};

function vulnerabilitiesFoundIn(result) {
return result &&
return (
result &&
result.vulnerabilities &&
Object.keys(result.vulnerabilities).length > 0;
Object.keys(result.vulnerabilities).length > 0
);
}

function auditErrorFoundIn(result) {
Expand Down
6 changes: 2 additions & 4 deletions test/13-integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,7 @@ describe('Integration tests', () => {
? assert(err.message.indexOf('Vulnerability found') > -1)
: assert(err.message.indexOf('Cannot check vulnerable dependencies') > -1)
));
['lodash@4.16.4', 'testcafe@0.19.2'].forEach(function(
dependency
) {
['lodash@4.16.4', 'testcafe@0.19.2'].forEach(function(dependency) {
const name = dependency.split('@')[0];
const version = dependency.split('@')[1];
it(`Should fail on transitive dependency inside ${dependency}`, () =>
Expand Down Expand Up @@ -1182,7 +1180,7 @@ describe('Integration tests', () => {
err.message.indexOf('operation not permitted') > -1 ||
err.message.indexOf('You must be logged in to publish packages') > -1 ||
//https://github.com/npm/cli/issues/1637
err.message.indexOf('npm ERR! 404 Not Found - PUT https://registry.npmjs.org/testing-repo - Not found') > -1 ||
err.message.indexOf('404 Not Found - PUT https://registry.npmjs.org/testing-repo - Not found') > -1 ||
err.message.indexOf('You may not perform that action with these credentials') > -1 ||
err.message.indexOf('This command requires you to be logged in to https://registry.npmjs.org/') > -1
);
Expand Down
37 changes: 12 additions & 25 deletions test/14-npm-integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const packageName = require('./utils/publish-please-version-under-test');
const nodeInfos = require('../lib/utils/get-node-infos').getNodeInfosSync();
const shouldUsePrePublishOnlyScript = nodeInfos.shouldUsePrePublishOnlyScript;
const lineSeparator = '----------------------------------';
const packagePath = `../${packageName.replace('@','-')}.tgz`;
const packagePath = `../${packageName.replace('@', '-')}.tgz`;

const writePublishFile = () => {
writeFile(
Expand Down Expand Up @@ -112,13 +112,9 @@ describe('npm integration tests', () => {

it('Should not install globally', () => {
return Promise.resolve()
.then(() => console.log(`> npm install -g ${packageName}`))
.then(() =>
console.log(`> npm install -g ${packageName}`)
)
.then(() =>
exec(
`npm install -g --foreground-scripts ${packagePath}`
)
exec(`npm install -g --foreground-scripts ${packagePath}`)
)
.then(() => {
throw new Error('Promise rejection expected');
Expand All @@ -130,11 +126,10 @@ describe('npm integration tests', () => {

it.skip('Should install locally', () => {
return Promise.resolve()
.then(() => console.log(`> npm install --save-dev ${packageName}`))
.then(() =>
console.log(`> npm install --save-dev ${packageName}`)
)
.then(() =>
exec(`npm install --foreground-scripts --save-dev ${packagePath}`
exec(
`npm install --foreground-scripts --save-dev ${packagePath}`
)
)
.then(() => {
Expand Down Expand Up @@ -248,11 +243,7 @@ describe('npm integration tests', () => {
console.log(readFile('.auditignore').toString());
console.log('');
})
.then(() =>
console.log(
`> npm install --save-dev ${packageName}`
)
)
.then(() => console.log(`> npm install --save-dev ${packageName}`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down Expand Up @@ -317,11 +308,7 @@ describe('npm integration tests', () => {
console.log(readFile('.auditignore').toString());
console.log('');
})
.then(() =>
console.log(
`> npm install --save-dev ${packageName}`
)
)
.then(() => console.log(`> npm install --save-dev ${packageName}`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down Expand Up @@ -376,9 +363,7 @@ describe('npm integration tests', () => {
it('Should abort the publishing workflow when npm version < 6.1.0 and vulnerability check is enabled in .publishrc config file', () => {
return Promise.resolve()
.then(() =>
console.log(
`> npm install --save-dev ${packageName}`
)
console.log(`> npm install --save-dev ${packageName}`)
)
.then(() =>
exec(
Expand Down Expand Up @@ -433,7 +418,9 @@ describe('npm integration tests', () => {

it('Should abort the dry-mode workflow when npm version < 6.1.0 and vulnerability check is enabled in .publishrc config file', () => {
return Promise.resolve()
.then(() => console.log(`> npm install --save-dev ${packageName}`))
.then(() =>
console.log(`> npm install --save-dev ${packageName}`)
)
.then(() =>
exec(
/* prettier-ignore */
Expand Down
18 changes: 5 additions & 13 deletions test/15-npx-integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const exec = require('cp-sugar').exec;
const packageName = require('./utils/publish-please-version-under-test');
const nodeInfos = require('../lib/utils/get-node-infos').getNodeInfosSync();
const lineSeparator = '----------------------------------';
const packagePath = `../${packageName.replace('@','-')}.tgz`;
const packagePath = `../${packageName.replace('@', '-')}.tgz`;

/* eslint-disable max-nested-callbacks */
describe('npx integration tests', () => {
Expand Down Expand Up @@ -91,9 +91,7 @@ describe('npx integration tests', () => {
pkg.scripts = scripts;
writeFile('package.json', JSON.stringify(pkg, null, 2));
})
.then(() =>
console.log(`> npx ${packageName} --dry-run`)
)
.then(() => console.log(`> npx ${packageName} --dry-run`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down Expand Up @@ -153,9 +151,7 @@ describe('npx integration tests', () => {
})
);
})
.then(() =>
console.log(`> npx ${packageName} --dry-run`)
)
.then(() => console.log(`> npx ${packageName} --dry-run`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down Expand Up @@ -213,9 +209,7 @@ describe('npx integration tests', () => {
})
);
})
.then(() =>
console.log(`> npx ${packageName} --dry-run --ci`)
)
.then(() => console.log(`> npx ${packageName} --dry-run --ci`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down Expand Up @@ -469,9 +463,7 @@ describe('npx integration tests', () => {
})
);
})
.then(() =>
console.log(`> npx ${packageName} --dry-run`)
)
.then(() => console.log(`> npx ${packageName} --dry-run`))
.then(() =>
exec(
/* prettier-ignore */
Expand Down
2 changes: 1 addition & 1 deletion test/16-npx-integration-with-npm-audit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const packageName = require('./utils/publish-please-version-under-test');
const nodeInfos = require('../lib/utils/get-node-infos').getNodeInfosSync();
const EOL = require('os').EOL;
const lineSeparator = '----------------------------------';
const packagePath = `../${packageName.replace('@','-')}.tgz`;
const packagePath = `../${packageName.replace('@', '-')}.tgz`;

/* eslint-disable max-nested-callbacks */
describe('npx integration tests with npm audit', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const EOL = require('os').EOL;
const pathJoin = require('path').join;
const touch = require('./utils/touch-file-sync');
const lineSeparator = '----------------------------------';
const packagePath = `../${packageName.replace('@','-')}.tgz`;
const packagePath = `../${packageName.replace('@', '-')}.tgz`;

/* eslint-disable max-nested-callbacks */
describe('npx integration tests with sensitive-data validation', () => {
Expand Down