/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ const fs = require('fs'); const path = require('path'); const packageRoot = process.cwd(); const monorepoRoot = path.resolve(__dirname, '..'); const autoInstrumentationNodeDeps = require( `${monorepoRoot}/packages/auto-instrumentations-node/package.json` ).dependencies; const autoInstrumentationWebDeps = require( `${monorepoRoot}/packages/auto-instrumentations-web/package.json` ).dependencies; // extract info from package.json const packageJsonUrl = path.resolve(`${packageRoot}/package.json`); const pjson = require(packageJsonUrl); const instrumentationPackageName = pjson.name; // identify if it's node or web // eslint-disable-next-line no-unused-vars const isNode = instrumentationPackageName in autoInstrumentationNodeDeps; const isWeb = instrumentationPackageName in autoInstrumentationWebDeps; // extract info from README.md const currentReadmeContent = fs.readFileSync( path.resolve(`${packageRoot}/README.md`), 'utf8' ); // make sure the footer is present const footerToVerify = `## Useful links - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License Apache 2.0 - See [LICENSE][license-url] for more information. [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions [license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [npm-url]: https://www.npmjs.com/package/${instrumentationPackageName} [npm-img]: https://badge.fury.io/js/${encodeURIComponent( instrumentationPackageName )}.svg `; if (!currentReadmeContent.includes(footerToVerify)) { throw new Error( `README.md footer is not valid. Please add the following text to the README.md file:\n\n${footerToVerify}` ); } // make sure we have badges at the top const badgesToVerify = `[![NPM Published Version][npm-img]][npm-url] [![Apache License][license-image]][license-image] `; if (!currentReadmeContent.includes(badgesToVerify)) { throw new Error( `README.md badges are not valid. Please add the following text to the README.md file:\n\n${badgesToVerify}` ); }