-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ibmtelemetry not run in prod (#1593)
* fix: ibmtelemetry not run in prod * fix: remove prepare
- Loading branch information
1 parent
a02a189
commit 3ae3f22
Showing
30 changed files
with
353 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.32 KB
.yarn/cache/@npmcli-promise-spawn-npm-7.0.1-4ff7da854a-a2b25d66d4.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.54 KB
.yarn/cache/json-parse-even-better-errors-npm-3.0.1-0bac4a1c62-bf74fa3f71.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+11.4 KB
.yarn/cache/normalize-package-data-npm-6.0.0-eb6fb03d4d-741211a435.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.83 KB
.yarn/cache/npm-normalize-package-bin-npm-3.0.1-6c120b50f7-de416d720a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.26 KB
.yarn/cache/validate-npm-package-name-npm-5.0.0-fc061c1b84-5342a99498.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const PackageJson = require('@npmcli/package-json'); | ||
|
||
async function prepack() { | ||
const pkgJson = await PackageJson.load('./'); | ||
pkgJson.content.scripts['dev_postinstall'] = | ||
pkgJson.content.scripts['postinstall']; | ||
pkgJson.content.scripts['postinstall'] = | ||
pkgJson.content.scripts['pack_postinstall']; | ||
pkgJson.content.scripts['pack_postinstall'] = 'echo removed by packrat.js'; | ||
await pkgJson.save(); | ||
// eslint-disable-next-line no-console | ||
console.log('scripts:', { | ||
postinstall: pkgJson.content.scripts['postinstall'], | ||
dev_postinstall: pkgJson.content.scripts['dev_postinstall'], | ||
}); | ||
} | ||
async function postpack() { | ||
const pkgJson = await PackageJson.load('./'); | ||
pkgJson.content.scripts['pack_postinstall'] = | ||
pkgJson.content.scripts['postinstall']; | ||
pkgJson.content.scripts['postinstall'] = | ||
pkgJson.content.scripts['dev_postinstall']; | ||
delete pkgJson.content.scripts['dev_postinstall']; | ||
await pkgJson.save(); | ||
// eslint-disable-next-line no-console | ||
console.log('scripts:', { | ||
postinstall: pkgJson.content.scripts['postinstall'], | ||
pack_postinstall: pkgJson.content.scripts['pack_postinstall'], | ||
}); | ||
} | ||
|
||
if (process.argv.length !== 3) { | ||
console.error( | ||
'The pinst package not working for us anymore. We need two different postinstall hooks.' | ||
); | ||
console.error( | ||
'1. postinstall that runs git pre-commit hooks - this is dev only' | ||
); | ||
console.error('2. postinstall that runs production hooks like ibmtelemetry'); | ||
console.error('This script toggles between the 2'); | ||
console.error('usage: node packrat.js'); | ||
console.error('Options'); | ||
console.error('\t--enable Enable pack (production) postinstall hook'); | ||
console.error('\t\trename postinstall to dev_postinstall'); | ||
console.error('\t\trename pack_postinstall to postinstall'); | ||
console.error('\t--disable Disable pack (production) postinstall hook'); | ||
console.error('\t\trename postinstall to pack_postinstall'); | ||
console.error('\t\trename dev_postinstall to postinstall'); | ||
process.exit(1); | ||
} | ||
|
||
if (process.argv[2] === '--disable') { | ||
// eslint-disable-next-line no-console | ||
prepack().then(() => console.log('updated package.json')); | ||
} else if (process.argv[2] === '--enable') { | ||
// eslint-disable-next-line no-console | ||
postpack().then(() => console.log('updated package.json')); | ||
} else console.error('unknown argument', process.argv[2]); |
Oops, something went wrong.