diff --git a/scripts/lib/getPackageDetails.ts b/scripts/lib/getPackageDetails.ts index 283161726..5845b0527 100644 --- a/scripts/lib/getPackageDetails.ts +++ b/scripts/lib/getPackageDetails.ts @@ -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 } diff --git a/scripts/lib/getPackageRegistryVersions.ts b/scripts/lib/getPackageRegistryVersions.ts new file mode 100644 index 000000000..5b50a628f --- /dev/null +++ b/scripts/lib/getPackageRegistryVersions.ts @@ -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 => { + 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() +}