microsoft / Oryx

Build your repo automatically.
Other
731 stars 169 forks source link

PHP detected on node project because node_modules directory is scanned #2400

Open dr-BEat opened 3 months ago

dr-BEat commented 3 months ago

I recently noticed that my Azure Static Web App project which uses node and typescript gets detected as node and PHP.

---Oryx build logs---
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version: 0.2.20231128.3, Commit: 0b76566110f0db32097b869761e056fd9b01848d, ReleaseTagName: 20231128.3
Build Operation ID: 2c7aaad437699c9d
Repository Commit : ...
OS Type           : bullseye
Image Type        : jamstack
Detecting platforms...
Detected following platforms:
  nodejs: 18.19.1
  php: 8.0.30
Version '8.0.30' of platform 'php' is not installed. Generating script to install it...

After some investigation I found that the npm package flatted ships some php (and other languages) files. Which trigger the PhpPlatformDetector to report the whole project as being PHP. While it can be discussed if PHP files should be part of a node package the much much larger issue is that Oryx is scanning the usually quite large node_modules folder in projects. And not once, but for every single IPlatformDetector implementation at least once. That is a colossal waste of time.

There is no way to exclude the node_modules folder from these searches either.

Am I missing something? This seems like a huge oversight.

dr-BEat commented 3 months ago

I worked around this issue by adding a postinstall script to my package.json to delete the offending php file from the node_modules folder after install.

{
  "scripts": {
    ...
    "postinstall": "rimraf node_modules/flatted/php"
    ...
  }
}

Maybe this helps somebody.

surenderssm commented 3 months ago

We appreciate your insight, @dr-BEat. Your analysis is accurate and we’re currently exploring this area. Anticipate improvements in the near future.