chore(scripts): add getPackageRegistryVersions script

This commit is contained in:
Elliot DeNolf
2024-04-10 21:26:50 -04:00
parent 14d683fb9a
commit 2fc9885abc
2 changed files with 50 additions and 0 deletions

View File

@@ -8,9 +8,13 @@ const __dirname = path.dirname(__filename)
const packagesDir = path.resolve(__dirname, '../../packages')
export type PackageDetails = {
/** Name in package.json / npm registry */
name: string
/** Full path to package */
packagePath: string
/** Short name is the directory name */
shortName: string
/** Version in package.json */
version: string
}

View File

@@ -0,0 +1,46 @@
import chalk from 'chalk'
import { getPackageDetails } from './getPackageDetails.js'
const packages = [
'payload',
'translations',
'ui',
'next',
'graphql',
'db-mongodb',
'db-postgres',
'richtext-slate',
'richtext-lexical',
'create-payload-app',
// Plugins
'plugin-cloud',
'plugin-cloud-storage',
'plugin-form-builder',
'plugin-nested-docs',
'plugin-redirects',
'plugin-search',
'plugin-seo',
// 'plugin-stripe',
// 'plugin-sentry',
]
export const getPackageRegistryVersions = async (): Promise<void> => {
const packageDetails = await getPackageDetails(packages)
await Promise.all(
packageDetails.map(async (pkg) => {
// Get published version from npm
const json = await fetch(`https://registry.npmjs.org/${pkg.name}`).then((res) => res.json())
const { latest, beta } = json['dist-tags']
const msg = `${chalk.bold(pkg.name.padEnd(32))} latest: ${latest?.padEnd(16)} beta: ${beta?.padEnd(16)}`
console.log(msg)
}),
)
}
if (import.meta.url === new URL(import.meta.url).href) {
await getPackageRegistryVersions()
}