Files
ueberdosis__tiptap/scripts/check-package-exports.mjs
Dominik Biedebach 1d205165bd chore!: remove deprecated package aliases (#8256)
* chore!: remove deprecated package aliases

Remove the legacy package workspace and all build, alias, release, and test references before v4.

BREAKING CHANGE: v4 no longer publishes the deprecated package aliases from packages-deprecated.

* update changeset

* chore: change changeset bump type

* fix: fix README link

* chore: update changeset
2026-08-26 14:09:19 +02:00

55 lines
1.6 KiB
JavaScript

import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { join, resolve } from 'node:path'
const root = resolve('.')
const fields = ['main', 'module', 'types']
const errors = []
let total = 0
function collectTargets(value, targets = []) {
if (typeof value === 'string') {
targets.push(value)
return targets
}
if (!value || typeof value !== 'object') return targets
for (const nestedValue of Object.values(value)) collectTargets(nestedValue, targets)
return targets
}
const packagesRoot = join(root, 'packages')
for (const entry of readdirSync(packagesRoot, { withFileTypes: true })) {
if (!entry.isDirectory()) continue
const packageRoot = join(packagesRoot, entry.name)
const manifestPath = join(packageRoot, 'package.json')
if (!existsSync(manifestPath)) continue
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
total += 1
const targets = fields.flatMap(field =>
typeof manifest[field] === 'string' ? [manifest[field]] : [],
)
targets.push(...collectTargets(manifest.exports))
for (const target of new Set(targets)) {
if (target === './package.json') continue
// Remove leading './' from target path and join with package root
const targetPath = join(packageRoot, target.replace(/^\.\//, ''))
if (!existsSync(targetPath)) errors.push(`${manifest.name}: ${target}`)
}
}
if (errors.length > 0) {
console.error(`Missing package export targets in ${total} packages:`)
for (const error of errors) console.error(`- ${error}`)
process.exitCode = 1
} else {
console.log(`All package export targets exist in ${total} packages.`)
}