add a simple script to validate the package.json exports with the build output
This commit is contained in:
18
src/Umbraco.Web.UI.Client/devops/package/validate-exports.js
Normal file
18
src/Umbraco.Web.UI.Client/devops/package/validate-exports.js
Normal file
@@ -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.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user