govau / design-system-components

🛠 Component code and tests for the Australian Government design system
https://auds.service.gov.au
MIT License
739 stars 111 forks source link

Intermittent npm audit fix errors #956

Closed mrrossmullen closed 3 years ago

mrrossmullen commented 3 years ago

Bug Report

What happened

Running npm audit fix within packages/callout displays:

✗ Some package.json files contain inconsistencies: The module callout has the pancake config saved though we don’t want that…

Additionally different Mac/PC and Node/npm versions don't display the error universally.

What I expected to happen

npm audit fix to complete successfully and update dependencies.

Reproducing

Steps to reproduce:

  1. cd packages/callout
  2. npm audit fix

Attachments

> node ../../scripts/helper.js test

✔︎  All pancakes without dependency conflicts
✗  Some package.json files contain inconsistencies:
   The module callout has the pancake config saved though we don’t want that…

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @gov.au/callout@3.0.2 test:helper: `node ../../scripts/helper.js test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @gov.au/callout@3.0.2 test:helper script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\IEUser\AppData\Roaming\npm-cache\_logs\2021-02-15T00_07_04_423Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @gov.au/callout@3.0.2 prepublish: `npm run test:helper && npm run build:pre`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @gov.au/callout@3.0.2 prepublish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
mrrossmullen commented 3 years ago

Error isolated to testing for pancake conditional logic in helper.js where the auto-save key existence is checked in package.json

// testing for pancake config
if( packagesPKG.pancake['auto-save'] !== undefined ) {
error += `The module ${ module } has the pancake config saved though we don’t want that…\n`;
}

Removal of this conditional check causes npm audit fix to complete successfully. However, a more permanent solution needs to be identified.

mrrossmullen commented 3 years ago

Incorrect understanding of the build process results in this error. As a component producer (DTA) npm audit fix shouldn't be run within the packages, update package.json and package-lock.json using ncu https://www.npmjs.com/package/npm-check-updates