The ibmtelemetry should be part of postinstall but it was not. This PR, hopefully, fixes that.
How have you tested it?
yarn build
yarn pack
tar -xvf package.tgz
jq .scripts.postinstall package/package.json
extract package/package.json from generated package.tgz
"postinstall": "ibmtelemetry --config=telemetry.yml",
Also verified that package.json is unchanged after running these commands.
The root cause of this issue is pinst npm package.
Originally the postinstall script was meant only for developers of this repo. It installed some git pre-commit hooks. Obviously that should not happen for users of this package and pinst did a nice job of preventing the postinstall from running for package users.
Now, however, we need two different postinstall scripts.
postinstall that runs git pre-commit hooks - this is dev only
postinstall that runs production hooks like ibmtelemetry
The pinst package does not handle this use case. So I added the packrat.js that toggles between these 2 versions of postinstall.
Another possible solution is to stop using yarn. :-( The npm package manager has a preparelifecycle hook that could accommodate this use case. Also, pnpm has a very nice devPreinstall hook which would work.
What did you do?
The
ibmtelemetry
should be part of postinstall but it was not. This PR, hopefully, fixes that.How have you tested it?
extract
package/package.json
from generated package.tgz"postinstall": "ibmtelemetry --config=telemetry.yml",
Also verified that package.json is unchanged after running these commands.
The root cause of this issue is pinst npm package. Originally the
postinstall
script was meant only for developers of this repo. It installed some git pre-commit hooks. Obviously that should not happen for users of this package andpinst
did a nice job of preventing thepostinstall
from running for package users.Now, however, we need two different
postinstall
scripts.pinst
package does not handle this use case. So I added thepackrat.js
that toggles between these 2 versions ofpostinstall
.Another possible solution is to stop using yarn. :-( The npm package manager has a
prepare
lifecycle hook that could accommodate this use case. Also, pnpm has a very nice devPreinstall hook which would work.Please ignore the noisy .yarn/cache updates