Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Postinstall message about repo owner #619

Closed
Closed
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
12 changes: 6 additions & 6 deletions lib/npm-check-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ function analyzeProjectDependencies(options, pkgData, pkgFile) {
options.enginesNode = _.get(pkg, 'engines.node');
}

print(options, '\nOptions (partial):', 'verbose')
print(options, '\nOptions (partial):', 'verbose');
print(options, {
registry: options.registry ? options.registry : null,
pre: options.pre,
packageManager: options.packageManager,
json: options.json,
enginesNode: options.enginesNode
}, 'verbose')
}, 'verbose');

return vm.upgradePackageDefinitions(current, options).then(async ([upgraded, latest]) => {

print(options, '\nFetched:', 'verbose')
print(options, latest, 'verbose')
print(options, '\nFetched:', 'verbose');
print(options, latest, 'verbose');

print(options, '\nUpgraded:', 'verbose')
print(options, upgraded, 'verbose')
print(options, '\nUpgraded:', 'verbose');
print(options, upgraded, 'verbose');

const {newPkgData, selectedNewDependencies} = await vm.upgradePackageData(pkgData, current, upgraded, latest, options);

Expand Down
31 changes: 31 additions & 0 deletions lib/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const chalk = require('chalk');
const util = require('util');
const exec = util.promisify(require('child_process').exec);

const stdOutCols = process.stdout.columns || 80;
const warnWord = ' WARNING ';
const padCols = (stdOutCols - warnWord.length) / 2;

const warningHeader = ''.padStart(padCols, '*') + warnWord + ''.padEnd(padCols, '*');
const warningMessage = "This repository's owner has changed. You are advised to check on the new owner.\nPlease type the new owner's mail address to continue: ...";
const warningFooter = ''.padStart(stdOutCols, '*');

const output = `${chalk.red(warningHeader + '\n' + warningMessage + '\n' + warningFooter)}`;

async function getOwners() {
const {stdout} = await exec('npm owner ls npm-check-updates');
if (stdout) {
return stdout.trim().split('\n');
}
return null;
}

getOwners().then(val => {
if (val) {
console.log(JSON.stringify(val, null, 2));
console.log(output);
}
});

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-check-updates",
"version": "4.0.1",
"version": "4.0.2",
"author": "Tomas Junnonen <[email protected]>",
"license": "Apache-2.0",
"contributors": [
Expand Down Expand Up @@ -31,7 +31,8 @@
"scripts": {
"lint": "eslint bin/* lib test",
"watch": "chokidar \"lib/**/*.js\" -c \"npm run test\"",
"test": "npm run lint && mocha && mocha test/individual && if [ ! \"$TRAVIS\" ]; then snyk test; fi"
"test": "npm run lint && mocha && mocha test/individual && if [ ! \"$TRAVIS\" ]; then snyk test; fi",
"postinstall": "node lib/postinstall.js"
},
"bin": {
"npm-check-updates": "./bin/npm-check-updates",
Expand Down