mirror of
https://github.com/ueberdosis/tiptap.git
synced 2026-09-14 16:14:40 +08:00
1d205165bd
* 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
55 lines
1.6 KiB
JavaScript
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.`)
|
|
}
|