From 4eb3d7c44849ef2ac72d1208aa74f6b488b773ab Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Mon, 12 Feb 2024 21:10:09 +0100 Subject: [PATCH] add a simple script to validate the package.json exports with the build output --- .../devops/package/validate-exports.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/devops/package/validate-exports.js diff --git a/src/Umbraco.Web.UI.Client/devops/package/validate-exports.js b/src/Umbraco.Web.UI.Client/devops/package/validate-exports.js new file mode 100644 index 0000000000..6745ca0778 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/devops/package/validate-exports.js @@ -0,0 +1,18 @@ +import { readFileSync } from 'fs'; +import { globSync } from 'glob'; + +const packageJsonPath = 'package.json'; +const packageJsonData = JSON.parse(readFileSync(packageJsonPath).toString()); +const packageJsonExports = packageJsonData.exports; + +// Iterate over the exports in package.json +for (const [key, value] of Object.entries(packageJsonExports || {})) { + if (value) { + const jsFiles = await globSync(value); + + // Log an error if the export from the package.json does not exist in the build output + if (jsFiles.length === 0) { + console.error(`Could not find export: ${key} -> ${value} in the build output.`); + } + } +}