opencollective-postinstall
Advanced tools
Comparing version 1.0.10 to 1.0.11
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
const { debug, padding } = require('../lib/utils'); | ||
const { fetchStats, fetchLogo } = require('../lib/fetchData'); | ||
const { printLogo, printFooter, printStats } = require('../lib/print'); | ||
const utils = require('../lib/utils'); | ||
const fetchData = require('../lib/fetchData'); | ||
const print = require('../lib/print'); | ||
const { | ||
npm_package_collective_url, | ||
npm_package_collective_logo, | ||
npm_lifecycle_event | ||
} = process.env; | ||
const debug = utils.debug; | ||
const padding = utils.padding; | ||
const fetchStats = fetchData.fetchStats; | ||
const fetchLogo = fetchData.fetchLogo; | ||
const printLogo = print.printLogo; | ||
const printFooter = print.printFooter; | ||
const printStats = print.printStats; | ||
const collective_url = process.env.npm_package_collective_url; | ||
const collective_logo = process.env.npm_package_collective_logo; | ||
const lifecycle_event = process.env.npm_lifecycle_event; | ||
function init() { | ||
const promises = []; | ||
promises.push(fetchStats(npm_package_collective_url)); | ||
if (npm_package_collective_logo) { | ||
promises.push(fetchLogo(npm_package_collective_logo)); | ||
promises.push(fetchStats(collective_url)); | ||
if (collective_logo) { | ||
promises.push(fetchLogo(collective_logo)); | ||
} | ||
@@ -38,3 +44,3 @@ | ||
if (npm_lifecycle_event !== 'postinstall') { | ||
if (lifecycle_event !== 'postinstall') { | ||
console.error(`This script should be run as a postinstall script. Please add it to your package.json.`); | ||
@@ -48,4 +54,4 @@ console.log(`e.g.:`); | ||
return process.exit(0); | ||
} else if (npm_package_collective_url) { | ||
} else if (collective_url) { | ||
init(); | ||
} |
@@ -10,6 +10,10 @@ #!/usr/bin/env node | ||
const inquirer = require('inquirer'); | ||
const { fetchLogo } = require('../lib/fetchData'); | ||
const { printLogo } = require('../lib/print'); | ||
const { debug } = require('../lib/utils'); | ||
const fetchData = require('../lib/fetchData'); | ||
const print = require('../lib/print'); | ||
const utils = require('../lib/utils'); | ||
const fetchLogo = fetchData.fetchLogo; | ||
const printLogo = print.printLogo; | ||
const debug = utils.debug; | ||
const parentDir = process.cwd().split('/').slice(-2, -1)[0]; | ||
@@ -93,3 +97,3 @@ if (parentDir !== 'node_modules') { | ||
} | ||
let postinstall = "./node_modules/.bin/opencollective-postinstall || exit 0"; | ||
var postinstall = "./node_modules/.bin/opencollective-postinstall || exit 0"; | ||
if (package.scripts.postinstall && package.scripts.postinstall.indexOf(postinstall) === -1) { | ||
@@ -96,0 +100,0 @@ package.scripts.postinstall = `${package.scripts.postinstall} && ${postinstall}`; |
@@ -8,16 +8,8 @@ | ||
.then((json) => { | ||
const { | ||
currency, | ||
balance, | ||
yearlyIncome, | ||
backersCount, | ||
contributorsCount | ||
} = json; | ||
return { | ||
currency, | ||
balance, | ||
yearlyIncome, | ||
backersCount, | ||
contributorsCount | ||
currency: json.currency, | ||
balance: json.balance, | ||
yearlyIncome: json.yearlyIncome, | ||
backersCount: json.backersCount, | ||
contributorsCount: json.contributorsCount | ||
}; | ||
@@ -24,0 +16,0 @@ }) |
const execSync = require('child_process').execSync; | ||
const chalk = require('chalk'); | ||
const { padding, formatCurrency } = require('../lib/utils'); | ||
const utils = require('../lib/utils'); | ||
const { | ||
npm_package_name, | ||
npm_package_collective_url, | ||
npm_package_collective_suggested_donation_amount, | ||
npm_package_collective_suggested_donation_interval, | ||
npm_config_user_agent | ||
} = process.env; | ||
const padding = utils.padding; | ||
const formatCurrency = utils.formatCurrency; | ||
const package_name = process.env.npm_package_name; | ||
const collective_url = process.env.npm_package_collective_url; | ||
const collective_suggested_donation_amount = process.env.npm_package_collective_suggested_donation_amount; | ||
const collective_suggested_donation_interval = process.env.npm_package_collective_suggested_donation_interval; | ||
const user_agent = process.env.npm_config_user_agent; | ||
function getDonateURL() { | ||
let donate_url = npm_package_collective_url; | ||
if (npm_package_collective_suggested_donation_amount) { | ||
donate_url += `/donate/${npm_package_collective_suggested_donation_amount}`; | ||
if (npm_package_collective_suggested_donation_interval) { | ||
donate_url += `/${npm_package_collective_suggested_donation_interval}`; | ||
var donate_url = collective_url; | ||
if (collective_suggested_donation_amount) { | ||
donate_url += `/donate/${collective_suggested_donation_amount}`; | ||
if (collective_suggested_donation_interval) { | ||
donate_url += `/${collective_suggested_donation_interval}`; | ||
} | ||
@@ -25,3 +26,4 @@ donate_url += (npm_config_user_agent.match(/yarn/)) ? '/yarn' : '/npm'; | ||
const print = function(str, opts = { color: null, align: 'center'}) { | ||
const print = function(str, opts) { | ||
opts = opts || { color: null, align: 'center'}; | ||
opts.align = opts.align || 'center'; | ||
@@ -54,3 +56,3 @@ const terminalCols = parseInt(execSync(`tput cols`).toString()); | ||
print(`Thanks for installing ${process.env.npm_package_name} 🙏.`, { color: 'yellow' }); | ||
print(`Thanks for installing ${package_name} 🙏.`, { color: 'yellow' }); | ||
print(`Please consider donating to our open collective`, { color: 'dim' }); | ||
@@ -57,0 +59,0 @@ print(`to help us maintain this package.`, { color: 'dim' }); |
@@ -10,3 +10,3 @@ const chalk = require('chalk'); | ||
const padding = function(length) { | ||
let padding = ''; | ||
var padding = ''; | ||
for (var i=0; i<length; i++) { | ||
@@ -18,3 +18,4 @@ padding += ' '; | ||
const formatCurrency = function(amount, currency, precision = 0) { | ||
const formatCurrency = function(amount, currency, precision) { | ||
precision = precision || 0; | ||
amount = amount/100; // converting cents | ||
@@ -21,0 +22,0 @@ |
{ | ||
"name": "opencollective-postinstall", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Prompt users to donate after they install your node module with npm install", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16646
270
16