@@ -350,6 +350,68 @@ describe("Enhanced Validation", () => {
350350 } ) ;
351351 } ) ;
352352
353+ describe ( "version validation" , ( ) => {
354+ it ( "should reject non-semver calver version" , ( ) => {
355+ const dir = join ( fixturesDir , "version-calver" ) ;
356+ fs . mkdirSync ( join ( dir , "server" ) , { recursive : true } ) ;
357+ fs . writeFileSync ( join ( dir , "server" , "index.js" ) , "// fixture" ) ;
358+ createManifest ( dir , { version : "2024.03.31.01" } ) ;
359+
360+ try {
361+ execSync ( `node ${ cliPath } validate ${ dir } ` , { encoding : "utf-8" } ) ;
362+ fail ( "Expected validation to fail" ) ;
363+ } catch ( e ) {
364+ const error = e as ExecSyncError ;
365+ expect ( error . status ) . toBe ( 1 ) ;
366+ expect ( error . stdout . toString ( ) ) . toContain ( "not valid semver" ) ;
367+ }
368+ } ) ;
369+
370+ it ( "should reject non-numeric version string" , ( ) => {
371+ const dir = join ( fixturesDir , "version-string" ) ;
372+ fs . mkdirSync ( join ( dir , "server" ) , { recursive : true } ) ;
373+ fs . writeFileSync ( join ( dir , "server" , "index.js" ) , "// fixture" ) ;
374+ createManifest ( dir , { version : "latest" } ) ;
375+
376+ try {
377+ execSync ( `node ${ cliPath } validate ${ dir } ` , { encoding : "utf-8" } ) ;
378+ fail ( "Expected validation to fail" ) ;
379+ } catch ( e ) {
380+ const error = e as ExecSyncError ;
381+ expect ( error . status ) . toBe ( 1 ) ;
382+ expect ( error . stdout . toString ( ) ) . toContain ( "not valid semver" ) ;
383+ }
384+ } ) ;
385+
386+ it ( "should accept standard semver version" , ( ) => {
387+ const dir = join ( fixturesDir , "version-semver" ) ;
388+ fs . mkdirSync ( join ( dir , "server" ) , { recursive : true } ) ;
389+ fs . writeFileSync ( join ( dir , "server" , "index.js" ) , "// fixture" ) ;
390+ createManifest ( dir , { version : "1.0.0" } ) ;
391+
392+ const result = execSync ( `node ${ cliPath } validate ${ dir } ` , {
393+ encoding : "utf-8" ,
394+ } ) ;
395+
396+ expect ( result ) . toContain ( "Manifest schema validation passes!" ) ;
397+ expect ( result ) . not . toContain ( "not valid semver" ) ;
398+ } ) ;
399+
400+ it ( "should accept semver with prerelease and build metadata" , ( ) => {
401+ const dir = join ( fixturesDir , "version-prerelease" ) ;
402+ fs . mkdirSync ( join ( dir , "server" ) , { recursive : true } ) ;
403+ fs . writeFileSync ( join ( dir , "server" , "index.js" ) , "// fixture" ) ;
404+ createManifest ( dir , { version : "2.1.0-beta.1+build.123" } ) ;
405+
406+ const result = execSync ( `node ${ cliPath } validate ${ dir } ` , {
407+ encoding : "utf-8" ,
408+ } ) ;
409+
410+ expect ( result ) . toContain ( "Manifest schema validation passes!" ) ;
411+ expect ( result ) . not . toContain ( "not valid semver" ) ;
412+ } ) ;
413+ } ) ;
414+
353415 describe ( "happy path" , ( ) => {
354416 it ( "should pass with all files present and correct types" , ( ) => {
355417 const dir = join ( fixturesDir , "happy-path" ) ;
0 commit comments