Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
opencollective-postinstall
Advanced tools
Prompt users to donate after they install your node module with npm install
The opencollective-postinstall npm package is designed to display a message after the installation of an npm package. This is typically used by open source projects to encourage users to support their work via Open Collective. It helps maintainers to promote their funding needs directly in the terminal after a user installs their package.
Display a custom message post-installation
This feature allows package maintainers to display a custom message in the terminal after their package is installed. The message is usually a call to support the project on Open Collective. The code snippet shows how to set up the postinstall script in the package.json file to trigger the opencollective-postinstall command.
{
"scripts": {
"postinstall": "opencollective-postinstall"
}
}
Similar to opencollective-postinstall, the 'funding' package is used to display a message about funding options for the package. However, 'funding' allows for more customization in terms of the message content and the funding platforms it supports, making it a more flexible option compared to opencollective-postinstall.
This package serves a similar purpose by allowing messages or scripts to be run after npm install. While opencollective-postinstall focuses specifically on Open Collective funding messages, postinstall-postinstall can be used for a variety of post-install scripts, not limited to funding appeals.
Prompt your users to donate to your collective after npm install
npm install opencollective-postinstall --save-dev
This will run an interactive cli to configure your package.json
Note: because you are adding this in your devDependencies
, it will only be installed in development enviromnent.
In your package.json
, it will add a new "collective"
attribute and update the postinstall script.
{
...
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/yourcollective_slug", // e.g. https://opencollective.com/webpack
"logo": "https://opencollective.com/webpack/logo.txt?variant=wide&width=26"
},
"scripts": {
"postinstall": "./node_modules/.bin/opencollective-postinstall || exit 0"
},
...
}
Why || exit 0
in scripts.postinstall
?
Since we are adding the dependency in devDependencies
, the script ./node_modules/.bin/opencollective-postinstall
won't be installed in production. Therefore, the postinstall
script will return an error and will interrupt the npm install
process. Adding || exit 0
makes sure that this postinstall
script always returns true.
You can play with different sizes and variants to get the perfect ASCII art for your collective:
https://opencollective.com/:slug/logo.txt?variant=:string&width=:integer&reverse=:boolean
e.g. https://opencollective.com/webpack/logo.txt?variant=wide&width=26&reverse=false
Possible values for variant
: wide
, ultra-wide
, variant1
, variant2
, variant3
, variant4
, blocks
, bits
, binary
, greyscale
, solid
You can also change reverse
to true
.
You can specify a suggested donation amount or a different URL to use for your logo in ascii.
In the "collective" section of your package.json
, add:
{
...
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/yourcollective_slug", // e.g. https://opencollective.com/webpack
"logo": "https://opencollective.com/yourcollective_slug/logo.txt" // e.g. https://opencollective.com/webpack/logo.txt
"suggested_donation": {
"amount": 2,
"currency": "USD", // must be same currency than your collective's default currency
"interval": "monthly" // or "one-time" or "yearly"
}
}
}
Join the #opensource channel on our slack: https://slack.opencollective.org
FAQs
Lightweight npm postinstall message to invite people to donate to your collective
The npm package opencollective-postinstall receives a total of 2,759,247 weekly downloads. As such, opencollective-postinstall popularity was classified as popular.
We found that opencollective-postinstall demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.