@@ -26,6 +26,25 @@ function getResolvedCoreVersion() {
2626 throw new Error ( 'Could not determine resolved @jbrowse/core version (no lockfile entry and no node_modules).' ) ;
2727}
2828
29+ function semverLt ( a , b ) {
30+ const pa = String ( a ) . match ( / ( \d + ) \. ( \d + ) \. ( \d + ) / ) ;
31+ const pb = String ( b ) . match ( / ( \d + ) \. ( \d + ) \. ( \d + ) / ) ;
32+ if ( ! pa || ! pb ) return false ;
33+ for ( let i = 1 ; i <= 3 ; i ++ ) {
34+ const da = Number ( pa [ i ] ) ;
35+ const db = Number ( pb [ i ] ) ;
36+ if ( da !== db ) return da < db ;
37+ }
38+ return false ;
39+ }
40+
41+ function floorVersion ( spec , min ) {
42+ const m = String ( spec ) . match ( / ^ ( \^ | ~ | > = ) ? \s * ( \d + \. \d + \. \d + ) ( .* ) $ / ) ;
43+ if ( ! m ) return spec ;
44+ const [ , op = '' , v , rest = '' ] = m ;
45+ return semverLt ( v , min ) ? `${ op } ${ min } ${ rest } ` : spec ;
46+ }
47+
2948async function extractTgz ( tgzPath , cwd ) {
3049 try {
3150 const mod = await import ( 'tar' ) . catch ( ( ) => null ) ;
@@ -61,7 +80,7 @@ async function main() {
6180 mkdirSync ( OUTDIR , { recursive : true } ) ;
6281
6382 const coreVersion = getResolvedCoreVersion ( ) ;
64- const cliSpec = process . env . JBROWSE_CLI_VERSION || coreVersion ;
83+ const cliSpec = floorVersion ( process . env . JBROWSE_CLI_VERSION || coreVersion , '3.6.0' ) ;
6584
6685 console . log ( `Packing @jbrowse/cli@${ cliSpec } (core resolved: ${ coreVersion } )…` ) ;
6786 const out = execSync ( `npm pack @jbrowse/cli@${ cliSpec } ` , {
0 commit comments