{"_id":"@cnumr/lighthouse-eco-index-aggregator","_rev":"1-4ae7b823c3d57661054ec3d2331a6c95","name":"@cnumr/lighthouse-eco-index-aggregator","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@cnumr/lighthouse-eco-index-aggregator","version":"1.0.0","description":"Tool for aggregating lighthouse and eco-index results","main":"src/cli.js","private":false,"scripts":{"start":"node src/cli.js --srcLighthouse=./example/lighthouse --srcEcoIndex=./example/ecoindex --reports=html --outputPath=./example/report_final","lint":"eslint","test":"jest --coverage"},"license":"MIT","dependencies":{"command-line-args":"^5.2.1","command-line-usage":"^5.0.0","ejs":"^3.1.8","fs-extra":"^11.1.1","html-minifier":"^4.0.0"},"devDependencies":{"eslint":"^8.36.0","husky":"^8.0.3","jest":"^29.5.0"},"_id":"@cnumr/lighthouse-eco-index-aggregator@1.0.0","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-oqWjus7LqIO0a303iGvYH2NcUNmmI4AODGcKvEpnVT+BODsy0jAdtXvVRe5crz3f5CiTJD9fLUZrtmgnHOJSbA==","shasum":"5e44173a89055d27904dcdec15973c9d7ddbb447","tarball":"https://registry.npmjs.org/@cnumr/lighthouse-eco-index-aggregator/-/lighthouse-eco-index-aggregator-1.0.0.tgz","fileCount":40,"unpackedSize":528614,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCnuWkgmggfEWHavoieZTdaU9sLPqmUB0thFWFKrvKhPwIgWcWR0+zJlnBnkPaWiflL66P3/jkZi20qoMvDp07zZKQ="}]},"_npmUser":{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"},"directories":{},"maintainers":[{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lighthouse-eco-index-aggregator_1.0.0_1685988470346_0.04984430968739173"},"_hasShrinkwrap":false},"1.1.0":{"name":"@cnumr/lighthouse-eco-index-aggregator","version":"1.1.0","description":"Tool for aggregating lighthouse and eco-index results","main":"src/cli.js","private":false,"scripts":{"start":"node src/cli.js --srcLighthouse=./example/lighthouse --srcEcoIndex=./example/ecoindex --reports=html --outputPath=./example/report_final","lint":"eslint","test":"jest --coverage"},"license":"MIT","dependencies":{"command-line-args":"^5.2.1","command-line-usage":"^5.0.0","ejs":"^3.1.8","fs-extra":"^11.1.1","html-minifier":"^4.0.0"},"devDependencies":{"eslint":"^8.36.0","husky":"^8.0.3","jest":"^29.5.0"},"gitHead":"5c21a8cbf0fe90b8889dbe792f02461756bc4cea","_id":"@cnumr/lighthouse-eco-index-aggregator@1.1.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-/cdbP37wmOyUzjhRuOKDIf6n8YiIFvReJRE7i0DvV1dNzSHk4ceJs222LquGBhQFYWMSf1dmRZE/6bHoc8/IuQ==","shasum":"fa282586358c79b0fe9439ca5b463c305987f0e4","tarball":"https://registry.npmjs.org/@cnumr/lighthouse-eco-index-aggregator/-/lighthouse-eco-index-aggregator-1.1.0.tgz","fileCount":38,"unpackedSize":343748,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBDb58bxcQqUQjCJYREJJ+/ev6vKakF9yKdU4pBxjzMIAiEAmxtlCiaHTfz/1j15Dzasn1hERbUqIw/qaswVau/mrls="}]},"_npmUser":{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"},"directories":{},"maintainers":[{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lighthouse-eco-index-aggregator_1.1.0_1686301018299_0.6560074037314447"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-05T18:07:50.293Z","1.0.0":"2023-06-05T18:07:50.512Z","modified":"2023-06-09T08:56:58.572Z","1.1.0":"2023-06-09T08:56:58.465Z"},"maintainers":[{"name":"emmanueldemey","email":"demey.emmanuel@gmail.com"}],"description":"Tool for aggregating lighthouse and eco-index results","license":"MIT","readme":"# Lighthouse EcoIndex Aggregator\n\nThis generator tool can be used if you need to generate a global reports for all pages audited by **lighthouse** and **ecoindex** tools. After the generation, we will have access to a global HTML report. As an example, you can use this tool at the end of a Cypress test suite in order to generate\nthe final report of your tests.\n\n![image](https://user-images.githubusercontent.com/6480596/213727763-d8cdf611-2b35-4c60-aa94-bd85d5de006c.png)\n\nAt the end of the readme, we will explain how to generate lighthouse and ecoindex reports, used by this aggregator.\n\n## Package\n\n- lighthouse-eco-index-aggregator [![npm version](https://badge.fury.io/js/lighthouse-eco-index-aggregator.svg)](https://badge.fury.io/js/lighthouse-eco-index-aggregator)\n\n```shell\nnpm install -D @cnumr/lighthouse-eco-index-aggregator\n```\n\n## Options\n\n| Nom           | Type     | Description                                                                                                  |\n| ------------- | -------- | ------------------------------------------------------------------------------------------------------------ |\n| config        | string   | Option is used for define configuration file (JSON or JavaScript)                                            |\n| fail          | number   | Option is used for define limit fail                                                                         |\n| h             | boolean  | Option is used for see informations cli                                                                      |\n| lang          | string   | Option is used for translated report values possible used is \"fr-FR\" or \"en-GB\" default is \"en-GB\"           |\n| m             | boolean  | Option is used for minify file output it's true by default                                                   |\n| outputPath    | string   | Option is used in order to define the target folder when the report will be generated                        |\n| pass          | number   | Option is used for define limit pass                                                                         |\n| reports       | string[] | Option is used for defined the format of the generated report. Possible values \"html\", \"sonar\" or a funciton |\n| sonarFilePath | string   | Option is used when generating the sonar report, in order to make the issue visible on SonarCloud            |\n| srcEcoIndex   | string   | Option is used for defined ecoIndex reports path                                                             |\n| srcLighthouse | string   | Option is used for defined lighthouse reports path                                                           |\n| v             | boolean  | Option is used for verbose task                                                                              |\n\n## Example usage\n\n```shell\nnpx @cnumr/lighthouse-eco-index-aggregator --srcLighthouse=\"./reports/lighthouse\" --srcEcoIndex=\"./reports/ecoindex\" --reports=\"html\" --outputPath=\"report_final\"\n```\n\nYou can also used this module programmatically\n\n```js\nconst aggregate = require(\"@cnumr/lighthouse-eco-index-aggregator/src/main\");\n\nconsole.log(\n  aggregate({\n    srcLighthouse: \"./reports/lighthouse\",\n    srcEcoIndex: \"./reports/ecoindex\",\n    outputPath: \"report_final\",\n  })\n);\n```\n\n## How to generate Lighthouse and EcoIndex reports\n\nThis aggregator tool can also be used directly inside a cypress test. For example, we can generate the global report once the Cypress tests suite has finished.\n\n```javascript\n// cypress.config.js\nconst aggregate = require(\"@cnumr/lighthouse-eco-index-aggregator/src/main\");\nconst path = require(\"path\");\n\nconst lighthouseOutputPathDir = path.join(__dirname, \"reports/lighthouse\");\nconst ecoIndexOutputPathDir = path.join(__dirname, \"reports/ecoindex\");\nconst globalOutputPathDir = path.join(__dirname, \"report_final\");\n\nmodule.exports = defineConfig({\n  e2e: {\n    setupNodeEvents(on, config) {\n      on(\"after:run\", async () => {\n        await aggregate({\n          reports: [\"html\"],\n          verbose: true,\n          srcLighthouse: lighthouseOutputPathDir,\n          srcEcoIndex: ecoIndexOutputPathDir,\n          outputPath: globalOutputPathDir,\n        });\n      });\n    },\n  },\n});\n```\n\nBut in order to generate this global report, we need the lighthouse and ecoindex reports available in the `lighthouse` and `ecoindex` subfolders. In order to do so, we will use two extra NPM packages :\n\n- [Cypress Audit](https://github.com/mfrachet/cypress-audit) in order to run Lighthouse\n- [Eco Index Audit](https://github.com/EmmanuelDemey/eco-index-audit) in order to run EcoIndex.\n\nYou will find a sample Cypress tests suite in the `cypress-demo` folder. Please have a look to the `demo.cy.js` and `cypress.config.js`.\n\nIn order to run the Cypress tests suite, you have to execute the following commands :\n\n```shell\ncd cypress-demo\nnpm i\nnpx cypress run -b chrome\n```\n\n## Sonar report\n\nThis tool can also generate a external sonar report you can add to the Sonar configuration (via the `sonar.externalIssuesReportPaths` option).\n\nYou need to define the path to one of your file managed by Sonar, in order to make the rule visible in Sonar Cloud and use the `sonar` reporter.\n\n```bash\nnode ./src/cli.js  --srcLighthouse=\"./reports/lighthouse\" --srcEcoIndex=\"./reports/ecoindex\" --reports=\"sonar\" --sonarFilePath=\"./package.json\"\n```\n\n## Generate any type of report\n\nIn fact, the `output` option can receive a javaScript function. Thanks to this possibility, you can send the result anywhere (Elastic, DataDog, ...)\n\n```javascript\n// cypress.config.js\nconst aggregate = require(\"@cnumr/lighthouse-eco-index-aggregator/src/main\");\nconst path = require(\"path\");\n\nconst lighthouseOutputPathDir = path.join(__dirname, \"reports/lighthouse\");\nconst ecoIndexOutputPathDir = path.join(__dirname, \"reports/ecoindex\");\nconst globalOutputPathDir = path.join(__dirname, \"report_final\");\n\nmodule.exports = defineConfig({\n  e2e: {\n    setupNodeEvents(on, config) {\n      on(\"after:run\", async () => {\n        await aggregate({\n          reports: [\n            \"html\",\n            (options, results) => {\n              const { Client } = require(\"@elastic/elasticsearch\");\n              const client = new Client();\n              return client.index({\n                index: \"lighthouse-ecoindex\",\n                document: {\n                  ...results,\n                  \"@timestamp\": new Date(),\n                },\n              });\n            },\n          ],\n          verbose: true,\n          srcLighthouse: lighthouseOutputPathDir,\n          srcEcoIndex: ecoIndexOutputPathDir,\n          outputPath: globalOutputPathDir,\n        });\n      });\n    },\n  },\n});\n```\n","readmeFilename":"readme.md"}