33const { getUnityChangeset, scrapeArchivedChangesets, scrapeBetaChangesets } = require ( "../dist/index" ) ;
44const cli = require ( 'cac' ) ( ) ;
55
6+ toNumber = function ( version ) {
7+ const match = version . toString ( ) . match ( / ^ ( \d + ) \. * ( \d * ) \. * ( \d * ) ( \w * ) ( \d * ) $ / ) ;
8+ if ( match === null ) return 0 ;
9+
10+ return parseInt ( match [ 1 ] || '0' ) * 100 * 100 * 100 * 100
11+ + parseInt ( match [ 2 ] || '0' ) * 100 * 100 * 100
12+ + parseInt ( match [ 3 ] || '0' ) * 100 * 100
13+ + ( ( match [ 4 ] || 'a' ) . toUpperCase ( ) . charCodeAt ( 0 ) - 65 ) * 100
14+ + parseInt ( match [ 5 ] || '0' ) ;
15+ } ;
16+
617cli . command ( '<version>' , 'Get a changeset for specific version' )
718 . action ( ( version , options ) => ( async ( ) => {
819 try {
@@ -15,6 +26,8 @@ cli.command('<version>', 'Get a changeset for specific version')
1526 } ) ( ) ) ;
1627
1728cli . command ( 'list' , 'List changesets' )
29+ . option ( '--min <version>' , 'Minimum version (included)' )
30+ . option ( '--max <version>' , 'Maximum version (included)' )
1831 . option ( '--json' , 'Output in json format' )
1932 . option ( '--all' , 'List all changesets (alpha/beta included)' )
2033 . option ( '--beta' , 'List alpha/beta changesets' )
@@ -26,6 +39,14 @@ cli.command('list', 'List changesets')
2639 ? await scrapeBetaChangesets ( )
2740 : await scrapeArchivedChangesets ( ) ;
2841
42+ // Filter by min/max.
43+ var min = options . min ? toNumber ( options . min ) : Number . MIN_VALUE ;
44+ var max = options . max ? toNumber ( options . max ) : Number . MAX_VALUE ;
45+ results = results . filter ( r => {
46+ const n = toNumber ( r . version ) ;
47+ return min <= n && n <= max ;
48+ } ) ;
49+
2950 if ( options . json ) {
3051 if ( options . versions )
3152 console . log ( JSON . stringify ( results . map ( r => r . version ) ) ) ;
0 commit comments