11#!/usr/bin/env bun
22
3- /**
4- * Validation script that runs before publishing
5- * Uses bun's native runtime for fast execution
6- */
7-
83import { readFileSync } from "node:fs" ;
94import { $ } from "bun" ;
105
11- console . log ( "🔍 Validating Metadator plugin...\n" ) ;
6+ const manifest = JSON . parse ( readFileSync ( "manifest.json" , "utf-8" ) ) ;
7+ console . log ( `🔍 Validating ${ manifest . name || "plugin" } ...\n` ) ;
128
139let errors = 0 ;
1410
1511// Check manifest.json
16- try {
17- const manifest = JSON . parse ( readFileSync ( "manifest.json" , "utf-8" ) ) ;
18- console . log ( "✓ manifest.json is valid JSON" ) ;
19-
20- if ( ! manifest . id || ! manifest . name || ! manifest . version ) {
21- console . error ( "✗ manifest.json missing required fields" ) ;
22- errors ++ ;
23- } else {
24- console . log ( ` Plugin: ${ manifest . name } v${ manifest . version } ` ) ;
25- }
26- } catch ( error ) {
27- console . error ( "✗ manifest.json is invalid:" , error ) ;
12+ if ( ! manifest . id || ! manifest . name || ! manifest . version ) {
13+ console . error ( "✗ manifest.json missing required fields" ) ;
2814 errors ++ ;
15+ } else {
16+ console . log ( `✓ manifest.json — ${ manifest . name } v${ manifest . version } ` ) ;
2917}
3018
3119// Check package.json version matches manifest
3220try {
3321 const pkg = JSON . parse ( readFileSync ( "package.json" , "utf-8" ) ) ;
34- const manifest = JSON . parse ( readFileSync ( "manifest.json" , "utf-8" ) ) ;
35-
3622 if ( pkg . version !== manifest . version ) {
3723 console . error (
3824 `✗ Version mismatch: package.json (${ pkg . version } ) != manifest.json (${ manifest . version } )` ,
@@ -56,7 +42,7 @@ if (typecheckResult.exitCode === 0) {
5642 errors ++ ;
5743}
5844
59- // Run linter
45+ // Run checks
6046console . log ( "\n🔧 Checking code quality..." ) ;
6147const checkResult = await $ `bun run check` . nothrow ( ) ;
6248if ( checkResult . exitCode === 0 ) {
@@ -72,7 +58,6 @@ const buildResult = await $`bun run build`.nothrow();
7258if ( buildResult . exitCode === 0 ) {
7359 console . log ( "✓ Build successful" ) ;
7460
75- // Check if main.js exists
7661 const mainFile = Bun . file ( "main.js" ) ;
7762 if ( await mainFile . exists ( ) ) {
7863 const size = mainFile . size / 1024 ;
0 commit comments