Some checks failed
Verify / Install node dependencies (push) Failing after 2s
Verify / Build packages (push) Has been skipped
Verify / Check linting & formatting (push) Has been skipped
Verify / Run unit tests (push) Has been skipped
Verify / Run e2e tests (shard 1/4) (push) Has been skipped
Verify / Run e2e tests (shard 2/4) (push) Has been skipped
Verify / Run e2e tests (shard 3/4) (push) Has been skipped
Verify / Run e2e tests (shard 4/4) (push) Has been skipped
Publish / Resolve publish config (push) Failing after 2s
Publish / Send notification to Slack (push) Has been skipped
Publish / Send failure notification to Slack (push) Failing after 8s
Verify / Merge e2e reports (push) Has been skipped
Publish / Build (push) Has been skipped
Publish / Bump Versions OR Release to Registry (push) Has been skipped
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.`)
|
|
}
|