apigee / apigeelint

Static code analysis for Apigee proxy bundles to encourage API developers to use best practices and avoid anti-patterns.
Apache License 2.0
91 stars 71 forks source link

BUG: v2.46.0 introduced a postinstall lifecycle script which requires devdependencies for non-development installations #407

Closed michael-kirkegaard-solita closed 7 months ago

michael-kirkegaard-solita commented 8 months ago

In version v2.46.0 the package.json file has introduced the lifecycle script postinstall.

The postinstall script executes cli commands that requires the packages "peggy" and "mkdirp" to be installed. The packages "peggy" and "mkdirp" are not defined in the dependencies, only in the devDependencies.

When apigeelint in installed for non-development usage with npm install -g apigeelint@latest, devDependencies are not installed 1 but the postinstall script is triggered 2, resulting in the postinstall script failing because "peggy" and "mkdirp" are not necessarily installed.

This makes the npm install command fail.

An example of this: image

References:

gislikonrad commented 8 months ago

Yeah, I noticed this too, but I think the actual problem is that the postinstall script is running from the ./node_modules/apigeelint folder and from there it's referencing ./node_modules/peggy/peggy.js. I tried manually adding peggy to my project, but it still failed because the ./node_modules/apigeelint folder didn't have it's own node_modules folder.

Adding an npm i to the post install script should solve this, but I don't know how clean that would be.

gislikonrad commented 8 months ago

Used npx to invoke peggy like was done for mkdirp. Pull request #408 is ready for this issue

ssvaidyanathan commented 8 months ago

Unpublished v2.46.0

ssvaidyanathan commented 7 months ago

Published v2.46.3

I had to comment out the postinstall script from the package.json as the npx command was failing when I was trying to install apigeelint globally. Looks like peggy and mkdirp needs to be installed globally for the postinstall command to work?

Please test and see if the issue still persists