如何select特定的预发布版本?
How to select specific prerelease versions?
我正在使用 npm info
获取位于 nexus 3 npm 存储库中的我们自己的私有工件的现有版本列表。对于新功能,我们使用预发布版本。
下面是我的完整数据集,列出了当前存在的所有版本:
[
'1.7.0',
'1.7.1',
'1.7.2',
'1.7.3',
'1.7.4',
'1.7.5',
'1.7.6',
'1.7.7',
'1.7.8',
'1.7.9',
'1.7.10',
'1.7.11',
'1.7.12',
'1.7.13',
'1.7.14',
'1.7.15',
'1.7.16',
'1.7.17',
'1.7.18',
'1.7.19',
'1.7.20',
'1.7.21',
'1.7.22',
'1.7.23',
'1.7.24',
'1.7.25',
'1.7.26',
'1.7.27',
'1.7.28',
'1.7.29',
'1.7.30',
'1.7.31',
'1.7.32',
'1.7.33',
'1.7.34',
'1.7.35',
'1.7.36',
'1.7.37',
'1.7.38',
'1.7.39',
'1.7.40',
'1.7.41',
'1.7.42',
'1.7.43',
'1.7.44',
'1.7.45',
'1.7.46',
'1.7.47',
'1.7.48',
'1.7.49',
'1.7.50',
'1.7.51',
'1.7.52',
'1.7.53',
'1.7.54',
'1.7.55',
'1.7.56',
'1.7.57',
'1.7.58',
'1.7.59',
'1.7.60',
'1.7.61',
'1.7.62',
'1.7.63',
'1.7.64',
'1.7.65',
'1.7.66',
'1.7.67',
'1.7.68',
'1.7.69',
'1.7.70',
'1.7.71',
'1.7.72',
'1.7.73',
'1.7.74',
'1.7.75',
'1.7.76',
'1.7.77',
'1.7.78',
'1.7.79',
'1.7.80',
'1.7.81',
'1.7.82',
'1.7.83',
'1.7.84',
'1.7.85',
'1.7.86',
'1.7.87',
'1.7.88',
'1.7.89',
'1.7.90',
'1.7.91',
'1.7.92',
'1.7.93',
'1.7.94',
'1.7.95',
'1.7.96',
'1.7.97',
'1.7.98',
'1.7.99',
'1.7.100',
'1.7.101',
'1.7.102',
'1.7.103',
'1.7.104',
'1.7.105',
'1.7.106',
'1.7.107',
'1.7.108',
'1.7.109',
'1.7.110',
'1.7.111',
'1.7.112',
'1.7.113',
'1.7.114',
'1.7.115',
'1.7.116',
'1.7.117',
'1.7.118',
'1.7.119',
'1.7.120',
'1.7.121',
'1.7.122',
'1.7.123',
'1.7.124',
'1.7.125',
'1.7.126',
'1.7.127',
'1.7.128',
'1.7.129',
'1.7.130',
'1.7.131',
'1.7.132',
'1.7.133',
'1.7.134',
'1.7.135',
'1.7.136',
'1.7.137',
'1.7.138',
'1.7.139',
'1.7.140',
'1.7.141',
'1.7.142',
'1.7.143',
'1.7.144',
'1.7.145',
'1.7.146',
'1.7.147',
'1.7.148',
'1.7.149',
'1.7.150',
'1.7.151',
'1.7.152',
'1.7.153',
'1.7.154',
'1.7.155',
'1.7.156',
'1.7.157',
'1.7.158',
'1.7.159',
'1.11.0',
'1.12.0',
'1.12.1',
'1.12.2',
'1.12.3',
'1.12.4',
'1.12.5',
'1.12.6',
'1.12.7',
'1.12.8',
'1.12.9',
'1.12.10',
'1.12.11',
'1.12.12',
'1.12.13',
'1.12.14',
'1.12.15',
'1.12.16',
'1.12.17',
'1.12.18',
'1.12.19',
'1.12.20',
'1.12.21',
'1.12.22',
'1.12.23',
'1.12.24',
'1.12.25',
'1.12.26',
'1.12.27',
'1.12.28',
'1.12.29',
'1.12.30',
'1.12.31',
'1.12.32',
'1.12.33',
'1.12.34',
'1.12.35',
'1.12.36',
'1.13.0-4161.0',
'1.13.0-4161.1',
'1.13.0-4161.2',
'1.13.0-ft.0',
'1.13.0-ft.1',
'1.13.0-ft.2',
'1.13.0-ft.3',
'1.13.0-ft.4',
'1.13.0-ft.5',
'1.13.0-ft.6',
'1.13.0-ft.7',
'1.13.0-ft.8',
'1.13.0-ft.9',
'1.13.0-ft.10',
'1.13.0-ft.11',
'1.13.0-ft.12',
'1.13.0-ft.13',
'1.13.0-ft.14',
'1.13.0-ft.15',
'1.13.0-ft.16',
'1.13.0-ft.17',
'1.13.0-ft.18',
'1.13.0-ft.19',
'1.13.0-ft.20',
'1.13.0-ft.21',
'1.13.0-ft.22',
'1.13.0-ft.23',
'1.13.0-ft.24',
'1.13.0-ft.25',
'1.13.0-ft.26',
'1.13.0-ft.27',
'1.13.0-ft.28',
'1.13.0-ft.29',
'1.13.0-ft.30',
'1.13.0-ft.31',
'1.13.0-ft.32',
'1.13.0-ft.33',
'1.13.0-ft.34',
'1.13.0-ft.35',
'1.13.0-ft.36',
'1.13.0-ft.37',
'1.13.0-ft.38',
'1.13.0-ft.39',
'1.13.0-ft.40',
'1.13.0-ft.41',
'1.13.0-ft-on-angular.0',
'1.13.0-ft-on-angular.1',
'1.13.0-ft-on-angular.2',
'1.13.0-ft-on-angular.3',
'1.13.0-ft-on-angular.4',
'1.13.0-ft-on-angular.5',
'1.13.0-ft-on-angular.6',
'1.13.0-ft-on-angular.7',
'1.13.0-ft-on-angular.8',
'1.13.0-ft-on-angular.9',
'1.13.0-ft-on-angular.10',
'1.13.0-perf.0',
'1.13.0-perf.1',
'1.13.0-perf.2',
'1.13.0-perf.3',
'1.13.0-perf.4',
'1.13.0-perf.5',
'1.13.0-perf.6',
'1.13.0-perf.7',
'1.13.0-revival.0',
'1.13.0-revival.1',
'1.13.0-revival.2',
'1.13.0-revival.3',
'1.13.0-revival.4',
'1.13.0-revival.5',
'1.13.0-revival.6',
'1.13.0-revival.7',
'1.13.0-revival.8',
'1.13.0-revival.9',
'1.13.0-revival.10',
'1.13.0-revival.11',
'1.13.0-revival.12',
'1.13.0-revival.13',
'1.13.0-revival.14',
'1.13.0-revival.15',
'1.13.0-revival2.0',
'1.13.0-revival2.1',
'1.13.0-user-pdf.0',
'1.13.0-user-pdf.1',
'1.13.0-user-pdf.2',
'1.13.0-user-pdf.3',
'1.13.0-user-pdf.4',
'1.13.0-user-pdf.5',
'1.13.0-user-pdf.6',
'1.13.0-user-pdf.7',
'1.13.0-user-pdf.8',
'1.13.0-user-pdf.9',
'1.13.0-user-pdf.10',
'1.13.0-user-pdf.11',
'1.13.0-user-pdf.12',
'1.13.0-user-pdf.13',
'1.13.0-user-pdf.14',
'1.13.0-user-pdf.15',
'1.13.0-user-pdf.16',
'1.13.0-user-pdf.17',
'1.13.0-user-pdf.18',
'1.13.0',
'1.13.1',
'1.13.2',
'1.13.3',
'1.13.4',
'1.13.5',
'1.13.6',
'1.13.7',
'1.13.8',
'1.13.9',
'1.13.10',
'1.13.11',
'1.13.12',
'1.13.13',
'1.13.14',
'1.13.15',
'1.13.16',
'1.13.17',
'1.13.18',
'1.13.19',
'1.13.20',
'1.13.21',
'1.13.22',
'1.13.23',
'1.13.24',
'1.13.25',
'1.13.26',
'1.13.27',
'1.13.28',
'1.13.29',
'1.13.30',
'1.13.31',
'1.13.32',
'1.13.33',
'1.13.34',
'1.13.35',
'1.13.36',
'1.13.37',
'1.13.38',
'1.13.39',
'1.13.40',
'1.13.41',
'1.13.42',
'1.13.43',
'1.13.44',
'1.13.45',
'1.13.46',
'1.13.47',
'1.13.48',
'1.13.49',
'1.13.50',
'1.13.51',
'1.13.52',
'1.13.53',
'1.13.54',
'1.13.55',
'1.13.56',
'1.13.57',
'1.13.58',
'1.13.59',
'1.13.60',
'1.13.61',
'1.13.62',
'1.13.63',
'1.13.64',
'1.13.65',
'1.13.66',
'1.13.67',
'1.13.68',
'1.13.69',
'1.13.70',
'1.13.71',
'1.13.72',
'1.13.73',
'1.13.74',
'1.13.75',
'1.13.76',
'1.13.77',
'1.13.78',
'1.13.79',
'1.13.80',
'1.13.81',
'1.13.82',
'1.13.83',
'1.13.84',
'1.13.85',
'1.13.86',
'1.13.87',
'1.13.88',
'1.13.89',
'1.13.90',
'1.13.91',
'1.13.92',
'1.13.93',
'1.13.94',
'1.13.95',
'1.13.96',
'1.13.97',
'1.13.98',
'1.13.99',
'1.13.100',
'1.13.101',
'1.13.102',
'1.13.103',
'1.13.104',
'1.13.105',
'1.13.106',
'1.13.107',
'1.13.108',
'1.13.109',
'1.13.110',
'1.13.111',
'1.13.112',
'1.13.113',
'1.13.114',
'1.13.115',
'1.13.116',
'1.13.117',
'1.13.118',
'1.13.119',
'1.13.120',
'1.13.121',
'1.13.122',
'1.13.123',
'1.13.124',
'1.13.125',
'1.13.126',
'1.13.127',
'1.13.128',
'1.13.129',
'1.13.130',
'1.13.131',
'1.13.132',
'1.13.133',
'1.13.134',
'1.13.135',
'1.13.136',
'1.13.137',
'1.13.138',
'1.13.139',
'1.13.140',
'1.13.141',
'1.13.142',
'1.13.143',
'1.13.144',
'1.13.145',
'1.13.146',
'1.13.147',
'1.13.148',
'1.13.149',
'1.13.150',
'1.13.151',
'1.13.152',
'1.13.153',
'1.13.154',
'1.13.155',
'1.13.156',
'1.13.157',
'1.13.158',
'1.13.159',
'1.13.160',
'1.13.161',
'1.13.162',
'1.13.163',
'1.13.164',
'1.13.165',
'1.13.166',
'1.13.167',
'1.13.168',
'1.13.169',
'1.13.170',
'1.13.171',
'1.13.172',
'1.13.173',
'1.13.174',
'1.13.175',
'1.13.176',
'1.13.177',
'1.14.0-1263aaaa.0',
'1.14.0-1294trackingwithreferrer.0',
'1.14.0-7076reminder.0',
'1.14.0-7076reminder.1',
'1.14.0-7076reminder.2',
'1.14.0-7076reminder.3',
'1.14.0-7521id.0',
'1.14.0-7521id.1',
'1.14.0-7521id.2',
'1.14.0-7521id.3',
'1.14.0-7540quit.0',
'1.14.0-7540quit.1',
'1.14.0-7540quit.2',
'1.14.0-7540quit.3',
'1.14.0-7540quit.4',
'1.14.0-7676update-mail-tests.0',
'1.14.0-7676update-mail-tests.1',
'1.14.0-7676update-mail-tests.2',
'1.14.0-7807html-title.0',
'1.14.0-7807html-title.1',
'1.14.0-7807html-title.2',
'1.14.0-7807html-title.3',
'1.14.0-7807html-title.4',
'1.14.0-7807html-title.5',
'1.14.0-7852.0',
'1.14.0-7852.1',
'1.14.0-7852.2',
'1.14.0-7852.3',
'1.14.0-7874logout.0',
'1.14.0-7874logout.1',
'1.14.0-7874logout.2',
'1.14.0-7874logout.3',
'1.14.0-7874logout.4',
'1.14.0-7874logout.5',
'1.14.0-8002price.0',
'1.14.0-8002price.1',
'1.14.0-8079tipp.0',
'1.14.0-8079tipp.1',
'1.14.0-8079tipp.2',
'1.14.0-ft.0',
'1.14.0-ft.1',
'1.14.0-ft.2',
'1.14.0-ft.3',
'1.14.0-ft.4',
'1.14.0-ft.5',
'1.14.0-ft.6',
'1.14.0-ft.7',
'1.14.0-ft.8',
'1.14.0-ft.9',
'1.14.0-ft.10',
'1.14.0-ft.11',
'1.14.0-ft.12',
'1.14.0-ft.13',
'1.14.0-ft.14',
'1.14.0-ft.15',
'1.14.0-ft.16',
'1.14.0-ft.17',
'1.14.0-ft.18',
'1.14.0-ft.19',
'1.14.0-ft.20',
'1.14.0-ft.21',
'1.14.0-ft.22',
'1.14.0-ft.23',
'1.14.0-ft.24',
'1.14.0-ft.25',
'1.14.0-ft.26',
'1.14.0-ft.27',
'1.14.0-ft.28',
'1.14.0-ft.29',
'1.14.0-ft.30',
'1.14.0-ft.31',
'1.14.0-ft.32',
'1.14.0-ft.33',
'1.14.0-ft.34',
'1.14.0-ft.35',
'1.14.0-ft.36',
'1.14.0-ft.37',
'1.14.0-ft.38',
'1.14.0-ft.39',
'1.14.0-ft.40',
'1.14.0-ft.41',
'1.14.0-ft.42',
'1.14.0-ft.43',
'1.14.0-ft.44',
'1.14.0-ft.45',
'1.14.0-ft.46',
'1.14.0-ft.47',
'1.14.0-ft.48',
'1.14.0-ft.49',
'1.14.0-ft.50',
'1.14.0-ft.51',
'1.14.0-ft.52',
'1.14.0-ft.53',
'1.14.0-ft.54',
'1.14.0-ft.55',
'1.14.0-ft.56',
'1.14.0-ft.57',
'1.14.0-ft.58',
'1.14.0-ft.59',
'1.14.0-ft.60',
'1.14.0-ft.61',
'1.14.0-ft.62',
'1.14.0-ft.63',
'1.14.0-ft.64',
'1.14.0-ft.65',
'1.14.0-ft.66',
'1.14.0-ft.67',
'1.14.0-ft.68',
'1.14.0-ft.69',
'1.14.0-ft.70',
'1.14.0-ft.71',
'1.14.0-ft.72',
'1.14.0-ft.73',
'1.14.0-ft.74',
'1.14.0-ft.75',
'1.14.0-ft.76',
'1.14.0-ft.77',
'1.14.0-ft.78',
'1.14.0-ft.79',
'1.14.0-ft.80',
'1.14.0-ft.81',
'1.14.0-ft.82',
'1.14.0-ft.83',
'1.14.0-ft.84',
'1.14.0-ft.85',
'1.14.0-ft-on-angular.0',
'1.14.0-ft-on-angular.1',
'1.14.0-ft-on-angular.2',
'1.14.0-ft-on-angular.3',
'1.14.0-ft-on-angular.4',
'1.14.0-ft-on-angular.5',
'1.14.0-ft-tracking.0',
'1.14.0-ft-tracking.1',
'1.14.0-ft-tracking.2',
'1.14.0-report-failed-deployments.0',
'1.14.0-report-failed-deployments.1',
'1.14.0-report-failed-deployments.2',
'1.14.0-report-failed-deployments.3',
'1.14.0-report-failed-deployments.4',
'1.14.0-report-failed-deployments.5',
'1.14.0-report-failed-deployments.6',
'1.14.0-tr-commons.0',
'1.14.0-tr-commons.1',
'1.14.0-tr-commons.2',
'1.14.0-tr-commons.3',
'1.14.0-tr-commons.4',
'1.14.0-tr-commons.5',
'1.14.0-tr-commons.6',
'1.14.0-tr-commons.7',
'1.14.0-tr-commons.8',
'1.14.0-tr-commons.9',
'1.14.0-tr-commons.10',
'1.14.0-tr-commons.11',
'1.14.0-tr-commons.12',
'1.14.0',
'1.14.1',
'1.14.2',
'1.14.3',
'1.14.4',
'1.14.5',
'1.14.6',
'1.14.7',
'1.14.8',
'1.14.9',
'1.14.10',
'1.14.11',
'1.14.12',
'1.14.13',
'1.14.14',
'1.14.15',
'1.14.16',
'1.14.17',
'1.14.18',
'1.14.19',
'1.14.20',
'1.14.21',
'1.14.22',
'1.14.23',
'1.14.24',
'1.14.25',
'1.14.26',
'1.14.27',
'1.14.28',
'1.14.29',
'1.14.30',
'1.14.31',
'1.14.32',
'1.14.33',
'1.14.34',
'1.14.35',
'1.14.36',
'1.14.37',
'1.14.38',
'1.14.39',
'1.14.40',
'1.14.41',
'1.14.42',
'1.14.43',
'1.14.44',
'1.14.45',
'1.14.46',
'1.14.47',
'1.14.48',
'1.14.49',
'1.14.50',
'1.14.51',
'1.14.52',
'1.14.53',
'1.14.54',
'1.14.55',
'1.14.56',
'1.14.57',
'1.14.58',
'1.14.59',
'1.14.60',
'1.14.61',
'1.14.62',
'1.14.63',
'1.14.64',
'1.14.65',
'1.14.66',
'1.14.67',
'1.14.68',
'1.14.69',
'1.14.70',
'1.14.71',
'1.14.72',
'1.14.73',
'1.14.74',
'1.14.75',
'1.14.76',
'1.14.77',
'1.14.78',
'1.14.79',
'1.14.80',
'1.14.81',
'1.14.82',
'1.14.83',
'1.14.84',
'1.14.85',
'1.14.86',
'1.14.87',
'2.2.0',
'2.2.1',
'2.2.2',
'2.2.3',
'2.2.4',
'2.2.5',
'2.2.6',
'2.2.7',
'2.2.8',
'2.2.9',
'2.2.10',
'2.2.11',
'2.2.12',
'2.2.13',
'2.2.14',
'2.2.15',
'2.2.16',
'2.2.17',
'2.2.18',
'2.2.19',
'2.2.20',
'2.2.21',
'2.2.22',
'2.2.23',
'2.2.24',
'2.2.25',
'2.2.26',
'2.2.27',
'2.2.28',
'2.2.29',
'2.2.30',
'2.2.31',
'2.2.32',
'2.2.33',
'2.2.34',
'2.2.35',
'2.2.36',
'2.2.37',
'2.2.38',
'2.2.39',
'2.2.40',
'2.2.41',
'2.2.42',
'2.2.43',
'2.2.44',
'2.2.45',
'2.2.46',
'2.2.47',
'2.2.48',
'2.2.49',
'2.2.50',
'2.2.51',
'2.2.52',
'2.2.53',
'2.2.54',
'2.2.55',
'2.2.56',
'2.2.57',
'2.2.58',
'2.2.59',
'2.2.60',
'2.2.61',
'2.2.62',
'2.2.63',
'2.2.64',
'2.2.65',
'2.2.66',
'2.2.67',
'2.2.68',
'2.2.69',
'2.2.70',
'2.2.71',
'2.2.72',
'2.2.73',
'2.3.0',
'2.3.1',
'2.3.2',
'2.3.3',
'2.3.4',
'2.3.5',
'2.3.6',
'2.3.7',
'2.3.8',
'2.3.9',
'2.3.10',
'2.3.11',
'2.3.12',
'2.3.13',
'2.3.14',
'2.3.15',
'2.3.16',
'2.3.17',
'2.3.18',
'2.3.19',
'2.3.20',
'2.3.21',
'2.3.22',
'2.3.23',
'2.3.24',
'2.3.25',
'2.3.26',
'2.3.27',
'2.3.28',
'2.3.29',
'2.3.30',
'2.3.31',
'2.3.32',
'2.3.33',
'2.3.34',
'2.3.35',
'2.3.36',
'2.3.37',
'2.3.38',
'2.3.39',
'2.3.40',
'2.3.41',
'2.3.42',
'2.3.43',
'2.3.44',
'2.3.45',
'2.3.46',
'2.3.47',
'2.3.48'
]
但 npm 似乎不能在不同的预发布版本之间有所不同:
> npm info artifact@">=1.14.0-ft.0 <1.14.0-ft0" version
[
artifact@1.14.0-ft.23 '1.14.0-ft.23'
artifact@1.14.0-ft.24 '1.14.0-ft.24'
artifact@1.14.0-ft.21 '1.14.0-ft.21'
artifact@1.14.0-ft.22 '1.14.0-ft.22'
artifact@1.14.0-ft.20 '1.14.0-ft.20'
artifact@1.14.0-ft.29 '1.14.0-ft.29'
artifact@1.14.0-ft.27 '1.14.0-ft.27'
artifact@1.14.0-ft.28 '1.14.0-ft.28'
artifact@1.14.0-ft.25 '1.14.0-ft.25'
artifact@1.14.0-ft.26 '1.14.0-ft.26'
artifact@1.14.0-ft.12 '1.14.0-ft.12'
artifact@1.14.0-ft.13 '1.14.0-ft.13'
artifact@1.14.0-ft.10 '1.14.0-ft.10'
artifact@1.14.0-ft.11 '1.14.0-ft.11'
artifact@1.14.0-ft.18 '1.14.0-ft.18'
artifact@1.14.0-ft.19 '1.14.0-ft.19'
artifact@1.14.0-ft.16 '1.14.0-ft.16'
artifact@1.14.0-ft.17 '1.14.0-ft.17'
artifact@1.14.0-ft.14 '1.14.0-ft.14'
artifact@1.14.0-ft.15 '1.14.0-ft.15'
artifact@1.14.0-ft-on-angular.4 '1.14.0-ft-on-angular.4'
artifact@1.14.0-ft.45 '1.14.0-ft.45'
artifact@1.14.0-ft-on-angular.5 '1.14.0-ft-on-angular.5'
artifact@1.14.0-ft.46 '1.14.0-ft.46'
artifact@1.14.0-ft-on-angular.2 '1.14.0-ft-on-angular.2'
artifact@1.14.0-ft.43 '1.14.0-ft.43'
artifact@1.14.0-ft-on-angular.3 '1.14.0-ft-on-angular.3'
artifact@1.14.0-ft.44 '1.14.0-ft.44'
artifact@1.14.0-ft-on-angular.0 '1.14.0-ft-on-angular.0'
artifact@1.14.0-ft.41 '1.14.0-ft.41'
artifact@1.14.0-ft-on-angular.1 '1.14.0-ft-on-angular.1'
artifact@1.14.0-ft.42 '1.14.0-ft.42'
artifact@1.14.0-ft.40 '1.14.0-ft.40'
artifact@1.14.0-ft.49 '1.14.0-ft.49'
artifact@1.14.0-ft.47 '1.14.0-ft.47'
artifact@1.14.0-ft.48 '1.14.0-ft.48'
artifact@1.14.0-ft.34 '1.14.0-ft.34'
artifact@1.14.0-ft.35 '1.14.0-ft.35'
artifact@1.14.0-ft.32 '1.14.0-ft.32'
artifact@1.14.0-ft.33 '1.14.0-ft.33'
artifact@1.14.0-ft.30 '1.14.0-ft.30'
artifact@1.14.0-ft.31 '1.14.0-ft.31'
artifact@1.14.0-ft.38 '1.14.0-ft.38'
artifact@1.14.0-ft.39 '1.14.0-ft.39'
artifact@1.14.0-ft.36 '1.14.0-ft.36'
artifact@1.14.0-ft.37 '1.14.0-ft.37'
artifact@1.14.0-ft.67 '1.14.0-ft.67'
artifact@1.14.0-ft.68 '1.14.0-ft.68'
artifact@1.14.0-ft.65 '1.14.0-ft.65'
artifact@1.14.0-ft.66 '1.14.0-ft.66'
artifact@1.14.0-ft.63 '1.14.0-ft.63'
artifact@1.14.0-ft.64 '1.14.0-ft.64'
artifact@1.14.0-ft.61 '1.14.0-ft.61'
artifact@1.14.0-ft.62 '1.14.0-ft.62'
artifact@1.14.0-ft.69 '1.14.0-ft.69'
artifact@1.14.0-ft.60 '1.14.0-ft.60'
artifact@1.14.0-ft.56 '1.14.0-ft.56'
artifact@1.14.0-ft.57 '1.14.0-ft.57'
artifact@1.14.0-ft.54 '1.14.0-ft.54'
artifact@1.14.0-ft.55 '1.14.0-ft.55'
artifact@1.14.0-ft.52 '1.14.0-ft.52'
artifact@1.14.0-ft.53 '1.14.0-ft.53'
artifact@1.14.0-ft.50 '1.14.0-ft.50'
artifact@1.14.0-ft.51 '1.14.0-ft.51'
artifact@1.14.0-ft.58 '1.14.0-ft.58'
artifact@1.14.0-ft.59 '1.14.0-ft.59'
artifact@1.14.0-ft.83 '1.14.0-ft.83'
artifact@1.14.0-ft.81 '1.14.0-ft.81'
artifact@1.14.0-ft.82 '1.14.0-ft.82'
artifact@1.14.0-ft.80 '1.14.0-ft.80'
artifact@1.14.0-ft.78 '1.14.0-ft.78'
artifact@1.14.0-ft.79 '1.14.0-ft.79'
artifact@1.14.0-ft.76 '1.14.0-ft.76'
artifact@1.14.0-ft.77 '1.14.0-ft.77'
artifact@1.14.0-ft.74 '1.14.0-ft.74'
artifact@1.14.0-ft.75 '1.14.0-ft.75'
artifact@1.14.0-ft.72 '1.14.0-ft.72'
artifact@1.14.0-ft.73 '1.14.0-ft.73'
artifact@1.14.0-ft.70 '1.14.0-ft.70'
artifact@1.14.0-ft.71 '1.14.0-ft.71'
artifact@1.14.0-ft.4 '1.14.0-ft.4'
artifact@1.14.0-ft.3 '1.14.0-ft.3'
artifact@1.14.0-ft.2 '1.14.0-ft.2'
artifact@1.14.0-ft.1 '1.14.0-ft.1'
artifact@1.14.0-ft.0 '1.14.0-ft.0'
artifact@1.14.0-ft.9 '1.14.0-ft.9'
artifact@1.14.0-ft.8 '1.14.0-ft.8'
artifact@1.14.0-ft.7 '1.14.0-ft.7'
artifact@1.14.0-ft.6 '1.14.0-ft.6'
artifact@1.14.0-ft.5 '1.14.0-ft.5'
artifact@1.14.0-ft-tracking.0 '1.14.0-ft-tracking.0'
artifact@1.14.0-ft-tracking.1 '1.14.0-ft-tracking.1'
artifact@1.14.0-ft-tracking.2 '1.14.0-ft-tracking.2'
]
想要的结果:
> npm info artifact@">=1.14.0-ft.0 <1.14.0-ft0" version
[
artifact@1.14.0-ft.23 '1.14.0-ft.23'
artifact@1.14.0-ft.24 '1.14.0-ft.24'
artifact@1.14.0-ft.21 '1.14.0-ft.21'
artifact@1.14.0-ft.22 '1.14.0-ft.22'
artifact@1.14.0-ft.20 '1.14.0-ft.20'
artifact@1.14.0-ft.29 '1.14.0-ft.29'
artifact@1.14.0-ft.27 '1.14.0-ft.27'
artifact@1.14.0-ft.28 '1.14.0-ft.28'
artifact@1.14.0-ft.25 '1.14.0-ft.25'
artifact@1.14.0-ft.26 '1.14.0-ft.26'
artifact@1.14.0-ft.12 '1.14.0-ft.12'
artifact@1.14.0-ft.13 '1.14.0-ft.13'
artifact@1.14.0-ft.10 '1.14.0-ft.10'
artifact@1.14.0-ft.11 '1.14.0-ft.11'
artifact@1.14.0-ft.18 '1.14.0-ft.18'
artifact@1.14.0-ft.19 '1.14.0-ft.19'
artifact@1.14.0-ft.16 '1.14.0-ft.16'
artifact@1.14.0-ft.17 '1.14.0-ft.17'
artifact@1.14.0-ft.14 '1.14.0-ft.14'
artifact@1.14.0-ft.15 '1.14.0-ft.15'
...
]
我预计不会有结果,因为 ft
不等于 ft-on-angular
或 ft-tracking
。
如何才能达到 select 至少只有 ft
作为预发布版本?
我试过 semver calculator 和类似的 select 或 (>=1.0.0-rc.0 <1.0.0-rc0
) 但它 select 只有 1.0.0-rcX。如果我更新 selector 到 >=1.0.0-r.0 <1.0.0-r0
它不匹配任何东西。
简答:
"How can I achieve to select at least only ft as prerelease version?"
通过 npm info
命令,您需要:
提供此比较器集以匹配 1.14.0
版本的所有 -ft
预发行版:
npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
或者,提供此比较器集以匹配 1.13.0
版本的所有 -ft
预发行版:
npm info artifact@">=1.13.0-ft.0 <1.13.0-ft-on-angular.0" version
或者,提供由两个比较器集组成的范围,以匹配 1.13.0
和 1.14.0
版本的所有 -ft
预发布:
npm info artifact@">=1.13.0-ft.0 <1.13.0-ft-on-angular.0 || >=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
注意:在确定用于匹配特定预发布版本的正确比较器时,确实需要事先了解完整的数据集及其排序顺序SemVer 优先级。使用以下 npm info
命令将为给定 artifact/package:
的所有可用版本提供 return 列表(按 SemVer 优先级升序排序)
npm info <package_name> versions
为什么您的 OP 中的比较器会产生不需要的语义版本?
"I would expect no results, because ft
is not equal to ft-on-angular
or ft-tracking
." 1
为了进一步理解为什么 npm info
命令和你给定的 >=1.14.0-ft.0 <1.14.0-ft0
比较器集没有产生你想要的 semvers 列表,我们需要首先理解 Semver 规范在 关于优先规则的第 11 点。为方便起见,下面提供了 第 11 点 的副本:
注:编号列表格式是我加的
Precedence MUST be calculated by separating the version into major, minor,
patch and pre-release identifiers in that order (Build metadata does not
figure into precedence).
Precedence is determined by the first difference when comparing each of
these identifiers from left to right as follows:
When major, minor, and patch are equal, a pre-release version has lower
precedence than a normal version. Example: 1.0.0-alpha < 1.0.0.
Precedence for two pre-release versions with the same major, minor, and
patch version MUST be determined by comparing each dot separated identifier
from left to right until a difference is found as follows:
2.1. identifiers consisting of only digits are compared numerically and
2.2. identifiers with letters or hyphens are compared lexically in ASCII sort order.
Numeric identifiers always have lower precedence than non-numeric identifiers.
A larger set of pre-release fields has a higher precedence than a smaller
set, if all of the preceding identifiers are equal. Example:
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2
< 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
第 1、2、3 和 4 点与您的 OP 特别相关,因为它们专门解决了关于 semver 中的 pre-release field/identifier 的优先级规则。
您使用的比较器组有什么不正确的地方?
>=1.14.0-ft.0 <1.14.0-ft0
首先要注意这个比较器; <1.14.0-ft0
,要求范围小于版本 1.14.0-ft0
,并且您的数据集不包含 -ft0
预发布版。
但是,如果 -ft0
预发布标识符确实存在于您的数据集中,它将大于现有的 1.14.0-ft-tracking.2
和 1.14.0-ft-on-angular.0
semvers - 因此这就是为什么您得到的结果包括所有 -ft-on-angular
和 ft-tracking
预发布。
为了进一步说明这一点,请考虑下面的排序语义版本列表(按升序排列)。特别注意 -ft0
预发布标识符的优先级 - 它明显高于其他标识符。
...
'1.14.0-ft.83',
'1.14.0-ft.84',
'1.14.0-ft.85',
'1.14.0-ft-on-angular.0',
'1.14.0-ft-on-angular.1',
'1.14.0-ft-on-angular.2',
'1.14.0-ft-on-angular.3',
'1.14.0-ft-on-angular.4',
'1.14.0-ft-on-angular.5',
'1.14.0-ft-tracking.0',
'1.14.0-ft-tracking.1',
'1.14.0-ft-tracking.2',
'1.14.0-ft0', <-------
...
现在,如果您考虑上面的第 2、3 和 4 点(即我在 Semver 规范第 11 点的摘录中指出的那些),关于优先规则,很明显为什么数据中的预发布标识符set 以这种方式排序:
特别地,考虑第 2.2 点的内容;
"[pre-release] identifiers with letters or hyphens are compared lexically in ASCII sort order".
注意 1.14.0-ft0
语义化末尾的零 (0
) 以及零在 ASCII 排序表中的位置(如下)。将其与 1.14.0-ft-tracking.2
语义版本中的第二个连字符 (-
) 以及 ASCII 排序图中的连字符位置进行比较。如您所见,零 (0
) 的排序位置位于连字符 (-
) 之后。这解释了为什么 1.14.0-ft0
在 1.14.0-ft-tracking.2
之后排序。
ASCII 排序顺序表:
为方便起见,下图显示了 ASCII 字符的排序顺序:
┌─────────┬──────────────┬─────┬─────┬─────┬─────┬─────┬───────┐
│ space │ - (hyphen) │ : │ G │ T │ a │ n │ } │
│ ! │ . │ ; │ H │ U │ b │ o │ | │
│ " │ / │ < │ I │ V │ c │ p │ { │
│ # │ 0 (zero) │ = │ J │ W │ d │ q │ ~ │
│ $ │ 1 │ > │ K │ X │ e │ r │ DEL │
│ % │ 2 │ ? │ L │ Y │ f │ s │ │
│ & │ 3 │ @ │ M │ Z │ g │ t │ │
│ ' │ 4 │ A │ N │ [ │ h │ u │ │
│ ( │ 5 │ B │ O │ \ │ i │ v │ │
│ ) │ 6 │ C │ P │ ] │ j │ w │ │
│ * │ 7 │ D │ Q │ ^ │ k │ x │ │
│ + │ 8 │ E │ R │ _ │ l │ y │ │
│ , │ 9 │ F │ S │ ` │ m │ z │ │
└─────────┴──────────────┴─────┴─────┴─────┴─────┴─────┴───────┘
补充说明
您会注意到,在使用以下正确的 npm info
命令时:
npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
它将结果打印到您的控制台,格式如下:
artifact@1.14.0-ft.1 '1.14.0-ft.1'
artifact@1.14.0-ft.2 '1.14.0-ft.2'
artifact@1.14.0-ft.3 '1.14.0-ft.3'
...
但是,如果您想重新格式化结果以形成 JSON 数组,请考虑将输出通过管道传输到 AWK,然后再传输到 node.js。例如使用以下复合命令:
npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version | awk -F "'" '{print }' | node -e "process.stdin.on('data', function(d) {console.log( JSON.stringify(d.toString().split('\n').filter(Boolean), null, 2) )});"
将生成以下重新格式化的结果:
[
"1.14.0-ft.1",
"1.14.0-ft.2",
"1.14.0-ft.3",
...
]
脚注:
1 这个期望有点类似于 NOT 期望数字7
和 8
从这组八个数字中 return 编辑; 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 当定义要捕获的范围的边界为 >=0 <10
.
对于此问答的任何新读者,您可能有兴趣阅读评论中的讨论 here which took place prior to providing this answer. Props to @jwdonahue,以获得他的宝贵意见。
我正在使用 npm info
获取位于 nexus 3 npm 存储库中的我们自己的私有工件的现有版本列表。对于新功能,我们使用预发布版本。
下面是我的完整数据集,列出了当前存在的所有版本:
[
'1.7.0',
'1.7.1',
'1.7.2',
'1.7.3',
'1.7.4',
'1.7.5',
'1.7.6',
'1.7.7',
'1.7.8',
'1.7.9',
'1.7.10',
'1.7.11',
'1.7.12',
'1.7.13',
'1.7.14',
'1.7.15',
'1.7.16',
'1.7.17',
'1.7.18',
'1.7.19',
'1.7.20',
'1.7.21',
'1.7.22',
'1.7.23',
'1.7.24',
'1.7.25',
'1.7.26',
'1.7.27',
'1.7.28',
'1.7.29',
'1.7.30',
'1.7.31',
'1.7.32',
'1.7.33',
'1.7.34',
'1.7.35',
'1.7.36',
'1.7.37',
'1.7.38',
'1.7.39',
'1.7.40',
'1.7.41',
'1.7.42',
'1.7.43',
'1.7.44',
'1.7.45',
'1.7.46',
'1.7.47',
'1.7.48',
'1.7.49',
'1.7.50',
'1.7.51',
'1.7.52',
'1.7.53',
'1.7.54',
'1.7.55',
'1.7.56',
'1.7.57',
'1.7.58',
'1.7.59',
'1.7.60',
'1.7.61',
'1.7.62',
'1.7.63',
'1.7.64',
'1.7.65',
'1.7.66',
'1.7.67',
'1.7.68',
'1.7.69',
'1.7.70',
'1.7.71',
'1.7.72',
'1.7.73',
'1.7.74',
'1.7.75',
'1.7.76',
'1.7.77',
'1.7.78',
'1.7.79',
'1.7.80',
'1.7.81',
'1.7.82',
'1.7.83',
'1.7.84',
'1.7.85',
'1.7.86',
'1.7.87',
'1.7.88',
'1.7.89',
'1.7.90',
'1.7.91',
'1.7.92',
'1.7.93',
'1.7.94',
'1.7.95',
'1.7.96',
'1.7.97',
'1.7.98',
'1.7.99',
'1.7.100',
'1.7.101',
'1.7.102',
'1.7.103',
'1.7.104',
'1.7.105',
'1.7.106',
'1.7.107',
'1.7.108',
'1.7.109',
'1.7.110',
'1.7.111',
'1.7.112',
'1.7.113',
'1.7.114',
'1.7.115',
'1.7.116',
'1.7.117',
'1.7.118',
'1.7.119',
'1.7.120',
'1.7.121',
'1.7.122',
'1.7.123',
'1.7.124',
'1.7.125',
'1.7.126',
'1.7.127',
'1.7.128',
'1.7.129',
'1.7.130',
'1.7.131',
'1.7.132',
'1.7.133',
'1.7.134',
'1.7.135',
'1.7.136',
'1.7.137',
'1.7.138',
'1.7.139',
'1.7.140',
'1.7.141',
'1.7.142',
'1.7.143',
'1.7.144',
'1.7.145',
'1.7.146',
'1.7.147',
'1.7.148',
'1.7.149',
'1.7.150',
'1.7.151',
'1.7.152',
'1.7.153',
'1.7.154',
'1.7.155',
'1.7.156',
'1.7.157',
'1.7.158',
'1.7.159',
'1.11.0',
'1.12.0',
'1.12.1',
'1.12.2',
'1.12.3',
'1.12.4',
'1.12.5',
'1.12.6',
'1.12.7',
'1.12.8',
'1.12.9',
'1.12.10',
'1.12.11',
'1.12.12',
'1.12.13',
'1.12.14',
'1.12.15',
'1.12.16',
'1.12.17',
'1.12.18',
'1.12.19',
'1.12.20',
'1.12.21',
'1.12.22',
'1.12.23',
'1.12.24',
'1.12.25',
'1.12.26',
'1.12.27',
'1.12.28',
'1.12.29',
'1.12.30',
'1.12.31',
'1.12.32',
'1.12.33',
'1.12.34',
'1.12.35',
'1.12.36',
'1.13.0-4161.0',
'1.13.0-4161.1',
'1.13.0-4161.2',
'1.13.0-ft.0',
'1.13.0-ft.1',
'1.13.0-ft.2',
'1.13.0-ft.3',
'1.13.0-ft.4',
'1.13.0-ft.5',
'1.13.0-ft.6',
'1.13.0-ft.7',
'1.13.0-ft.8',
'1.13.0-ft.9',
'1.13.0-ft.10',
'1.13.0-ft.11',
'1.13.0-ft.12',
'1.13.0-ft.13',
'1.13.0-ft.14',
'1.13.0-ft.15',
'1.13.0-ft.16',
'1.13.0-ft.17',
'1.13.0-ft.18',
'1.13.0-ft.19',
'1.13.0-ft.20',
'1.13.0-ft.21',
'1.13.0-ft.22',
'1.13.0-ft.23',
'1.13.0-ft.24',
'1.13.0-ft.25',
'1.13.0-ft.26',
'1.13.0-ft.27',
'1.13.0-ft.28',
'1.13.0-ft.29',
'1.13.0-ft.30',
'1.13.0-ft.31',
'1.13.0-ft.32',
'1.13.0-ft.33',
'1.13.0-ft.34',
'1.13.0-ft.35',
'1.13.0-ft.36',
'1.13.0-ft.37',
'1.13.0-ft.38',
'1.13.0-ft.39',
'1.13.0-ft.40',
'1.13.0-ft.41',
'1.13.0-ft-on-angular.0',
'1.13.0-ft-on-angular.1',
'1.13.0-ft-on-angular.2',
'1.13.0-ft-on-angular.3',
'1.13.0-ft-on-angular.4',
'1.13.0-ft-on-angular.5',
'1.13.0-ft-on-angular.6',
'1.13.0-ft-on-angular.7',
'1.13.0-ft-on-angular.8',
'1.13.0-ft-on-angular.9',
'1.13.0-ft-on-angular.10',
'1.13.0-perf.0',
'1.13.0-perf.1',
'1.13.0-perf.2',
'1.13.0-perf.3',
'1.13.0-perf.4',
'1.13.0-perf.5',
'1.13.0-perf.6',
'1.13.0-perf.7',
'1.13.0-revival.0',
'1.13.0-revival.1',
'1.13.0-revival.2',
'1.13.0-revival.3',
'1.13.0-revival.4',
'1.13.0-revival.5',
'1.13.0-revival.6',
'1.13.0-revival.7',
'1.13.0-revival.8',
'1.13.0-revival.9',
'1.13.0-revival.10',
'1.13.0-revival.11',
'1.13.0-revival.12',
'1.13.0-revival.13',
'1.13.0-revival.14',
'1.13.0-revival.15',
'1.13.0-revival2.0',
'1.13.0-revival2.1',
'1.13.0-user-pdf.0',
'1.13.0-user-pdf.1',
'1.13.0-user-pdf.2',
'1.13.0-user-pdf.3',
'1.13.0-user-pdf.4',
'1.13.0-user-pdf.5',
'1.13.0-user-pdf.6',
'1.13.0-user-pdf.7',
'1.13.0-user-pdf.8',
'1.13.0-user-pdf.9',
'1.13.0-user-pdf.10',
'1.13.0-user-pdf.11',
'1.13.0-user-pdf.12',
'1.13.0-user-pdf.13',
'1.13.0-user-pdf.14',
'1.13.0-user-pdf.15',
'1.13.0-user-pdf.16',
'1.13.0-user-pdf.17',
'1.13.0-user-pdf.18',
'1.13.0',
'1.13.1',
'1.13.2',
'1.13.3',
'1.13.4',
'1.13.5',
'1.13.6',
'1.13.7',
'1.13.8',
'1.13.9',
'1.13.10',
'1.13.11',
'1.13.12',
'1.13.13',
'1.13.14',
'1.13.15',
'1.13.16',
'1.13.17',
'1.13.18',
'1.13.19',
'1.13.20',
'1.13.21',
'1.13.22',
'1.13.23',
'1.13.24',
'1.13.25',
'1.13.26',
'1.13.27',
'1.13.28',
'1.13.29',
'1.13.30',
'1.13.31',
'1.13.32',
'1.13.33',
'1.13.34',
'1.13.35',
'1.13.36',
'1.13.37',
'1.13.38',
'1.13.39',
'1.13.40',
'1.13.41',
'1.13.42',
'1.13.43',
'1.13.44',
'1.13.45',
'1.13.46',
'1.13.47',
'1.13.48',
'1.13.49',
'1.13.50',
'1.13.51',
'1.13.52',
'1.13.53',
'1.13.54',
'1.13.55',
'1.13.56',
'1.13.57',
'1.13.58',
'1.13.59',
'1.13.60',
'1.13.61',
'1.13.62',
'1.13.63',
'1.13.64',
'1.13.65',
'1.13.66',
'1.13.67',
'1.13.68',
'1.13.69',
'1.13.70',
'1.13.71',
'1.13.72',
'1.13.73',
'1.13.74',
'1.13.75',
'1.13.76',
'1.13.77',
'1.13.78',
'1.13.79',
'1.13.80',
'1.13.81',
'1.13.82',
'1.13.83',
'1.13.84',
'1.13.85',
'1.13.86',
'1.13.87',
'1.13.88',
'1.13.89',
'1.13.90',
'1.13.91',
'1.13.92',
'1.13.93',
'1.13.94',
'1.13.95',
'1.13.96',
'1.13.97',
'1.13.98',
'1.13.99',
'1.13.100',
'1.13.101',
'1.13.102',
'1.13.103',
'1.13.104',
'1.13.105',
'1.13.106',
'1.13.107',
'1.13.108',
'1.13.109',
'1.13.110',
'1.13.111',
'1.13.112',
'1.13.113',
'1.13.114',
'1.13.115',
'1.13.116',
'1.13.117',
'1.13.118',
'1.13.119',
'1.13.120',
'1.13.121',
'1.13.122',
'1.13.123',
'1.13.124',
'1.13.125',
'1.13.126',
'1.13.127',
'1.13.128',
'1.13.129',
'1.13.130',
'1.13.131',
'1.13.132',
'1.13.133',
'1.13.134',
'1.13.135',
'1.13.136',
'1.13.137',
'1.13.138',
'1.13.139',
'1.13.140',
'1.13.141',
'1.13.142',
'1.13.143',
'1.13.144',
'1.13.145',
'1.13.146',
'1.13.147',
'1.13.148',
'1.13.149',
'1.13.150',
'1.13.151',
'1.13.152',
'1.13.153',
'1.13.154',
'1.13.155',
'1.13.156',
'1.13.157',
'1.13.158',
'1.13.159',
'1.13.160',
'1.13.161',
'1.13.162',
'1.13.163',
'1.13.164',
'1.13.165',
'1.13.166',
'1.13.167',
'1.13.168',
'1.13.169',
'1.13.170',
'1.13.171',
'1.13.172',
'1.13.173',
'1.13.174',
'1.13.175',
'1.13.176',
'1.13.177',
'1.14.0-1263aaaa.0',
'1.14.0-1294trackingwithreferrer.0',
'1.14.0-7076reminder.0',
'1.14.0-7076reminder.1',
'1.14.0-7076reminder.2',
'1.14.0-7076reminder.3',
'1.14.0-7521id.0',
'1.14.0-7521id.1',
'1.14.0-7521id.2',
'1.14.0-7521id.3',
'1.14.0-7540quit.0',
'1.14.0-7540quit.1',
'1.14.0-7540quit.2',
'1.14.0-7540quit.3',
'1.14.0-7540quit.4',
'1.14.0-7676update-mail-tests.0',
'1.14.0-7676update-mail-tests.1',
'1.14.0-7676update-mail-tests.2',
'1.14.0-7807html-title.0',
'1.14.0-7807html-title.1',
'1.14.0-7807html-title.2',
'1.14.0-7807html-title.3',
'1.14.0-7807html-title.4',
'1.14.0-7807html-title.5',
'1.14.0-7852.0',
'1.14.0-7852.1',
'1.14.0-7852.2',
'1.14.0-7852.3',
'1.14.0-7874logout.0',
'1.14.0-7874logout.1',
'1.14.0-7874logout.2',
'1.14.0-7874logout.3',
'1.14.0-7874logout.4',
'1.14.0-7874logout.5',
'1.14.0-8002price.0',
'1.14.0-8002price.1',
'1.14.0-8079tipp.0',
'1.14.0-8079tipp.1',
'1.14.0-8079tipp.2',
'1.14.0-ft.0',
'1.14.0-ft.1',
'1.14.0-ft.2',
'1.14.0-ft.3',
'1.14.0-ft.4',
'1.14.0-ft.5',
'1.14.0-ft.6',
'1.14.0-ft.7',
'1.14.0-ft.8',
'1.14.0-ft.9',
'1.14.0-ft.10',
'1.14.0-ft.11',
'1.14.0-ft.12',
'1.14.0-ft.13',
'1.14.0-ft.14',
'1.14.0-ft.15',
'1.14.0-ft.16',
'1.14.0-ft.17',
'1.14.0-ft.18',
'1.14.0-ft.19',
'1.14.0-ft.20',
'1.14.0-ft.21',
'1.14.0-ft.22',
'1.14.0-ft.23',
'1.14.0-ft.24',
'1.14.0-ft.25',
'1.14.0-ft.26',
'1.14.0-ft.27',
'1.14.0-ft.28',
'1.14.0-ft.29',
'1.14.0-ft.30',
'1.14.0-ft.31',
'1.14.0-ft.32',
'1.14.0-ft.33',
'1.14.0-ft.34',
'1.14.0-ft.35',
'1.14.0-ft.36',
'1.14.0-ft.37',
'1.14.0-ft.38',
'1.14.0-ft.39',
'1.14.0-ft.40',
'1.14.0-ft.41',
'1.14.0-ft.42',
'1.14.0-ft.43',
'1.14.0-ft.44',
'1.14.0-ft.45',
'1.14.0-ft.46',
'1.14.0-ft.47',
'1.14.0-ft.48',
'1.14.0-ft.49',
'1.14.0-ft.50',
'1.14.0-ft.51',
'1.14.0-ft.52',
'1.14.0-ft.53',
'1.14.0-ft.54',
'1.14.0-ft.55',
'1.14.0-ft.56',
'1.14.0-ft.57',
'1.14.0-ft.58',
'1.14.0-ft.59',
'1.14.0-ft.60',
'1.14.0-ft.61',
'1.14.0-ft.62',
'1.14.0-ft.63',
'1.14.0-ft.64',
'1.14.0-ft.65',
'1.14.0-ft.66',
'1.14.0-ft.67',
'1.14.0-ft.68',
'1.14.0-ft.69',
'1.14.0-ft.70',
'1.14.0-ft.71',
'1.14.0-ft.72',
'1.14.0-ft.73',
'1.14.0-ft.74',
'1.14.0-ft.75',
'1.14.0-ft.76',
'1.14.0-ft.77',
'1.14.0-ft.78',
'1.14.0-ft.79',
'1.14.0-ft.80',
'1.14.0-ft.81',
'1.14.0-ft.82',
'1.14.0-ft.83',
'1.14.0-ft.84',
'1.14.0-ft.85',
'1.14.0-ft-on-angular.0',
'1.14.0-ft-on-angular.1',
'1.14.0-ft-on-angular.2',
'1.14.0-ft-on-angular.3',
'1.14.0-ft-on-angular.4',
'1.14.0-ft-on-angular.5',
'1.14.0-ft-tracking.0',
'1.14.0-ft-tracking.1',
'1.14.0-ft-tracking.2',
'1.14.0-report-failed-deployments.0',
'1.14.0-report-failed-deployments.1',
'1.14.0-report-failed-deployments.2',
'1.14.0-report-failed-deployments.3',
'1.14.0-report-failed-deployments.4',
'1.14.0-report-failed-deployments.5',
'1.14.0-report-failed-deployments.6',
'1.14.0-tr-commons.0',
'1.14.0-tr-commons.1',
'1.14.0-tr-commons.2',
'1.14.0-tr-commons.3',
'1.14.0-tr-commons.4',
'1.14.0-tr-commons.5',
'1.14.0-tr-commons.6',
'1.14.0-tr-commons.7',
'1.14.0-tr-commons.8',
'1.14.0-tr-commons.9',
'1.14.0-tr-commons.10',
'1.14.0-tr-commons.11',
'1.14.0-tr-commons.12',
'1.14.0',
'1.14.1',
'1.14.2',
'1.14.3',
'1.14.4',
'1.14.5',
'1.14.6',
'1.14.7',
'1.14.8',
'1.14.9',
'1.14.10',
'1.14.11',
'1.14.12',
'1.14.13',
'1.14.14',
'1.14.15',
'1.14.16',
'1.14.17',
'1.14.18',
'1.14.19',
'1.14.20',
'1.14.21',
'1.14.22',
'1.14.23',
'1.14.24',
'1.14.25',
'1.14.26',
'1.14.27',
'1.14.28',
'1.14.29',
'1.14.30',
'1.14.31',
'1.14.32',
'1.14.33',
'1.14.34',
'1.14.35',
'1.14.36',
'1.14.37',
'1.14.38',
'1.14.39',
'1.14.40',
'1.14.41',
'1.14.42',
'1.14.43',
'1.14.44',
'1.14.45',
'1.14.46',
'1.14.47',
'1.14.48',
'1.14.49',
'1.14.50',
'1.14.51',
'1.14.52',
'1.14.53',
'1.14.54',
'1.14.55',
'1.14.56',
'1.14.57',
'1.14.58',
'1.14.59',
'1.14.60',
'1.14.61',
'1.14.62',
'1.14.63',
'1.14.64',
'1.14.65',
'1.14.66',
'1.14.67',
'1.14.68',
'1.14.69',
'1.14.70',
'1.14.71',
'1.14.72',
'1.14.73',
'1.14.74',
'1.14.75',
'1.14.76',
'1.14.77',
'1.14.78',
'1.14.79',
'1.14.80',
'1.14.81',
'1.14.82',
'1.14.83',
'1.14.84',
'1.14.85',
'1.14.86',
'1.14.87',
'2.2.0',
'2.2.1',
'2.2.2',
'2.2.3',
'2.2.4',
'2.2.5',
'2.2.6',
'2.2.7',
'2.2.8',
'2.2.9',
'2.2.10',
'2.2.11',
'2.2.12',
'2.2.13',
'2.2.14',
'2.2.15',
'2.2.16',
'2.2.17',
'2.2.18',
'2.2.19',
'2.2.20',
'2.2.21',
'2.2.22',
'2.2.23',
'2.2.24',
'2.2.25',
'2.2.26',
'2.2.27',
'2.2.28',
'2.2.29',
'2.2.30',
'2.2.31',
'2.2.32',
'2.2.33',
'2.2.34',
'2.2.35',
'2.2.36',
'2.2.37',
'2.2.38',
'2.2.39',
'2.2.40',
'2.2.41',
'2.2.42',
'2.2.43',
'2.2.44',
'2.2.45',
'2.2.46',
'2.2.47',
'2.2.48',
'2.2.49',
'2.2.50',
'2.2.51',
'2.2.52',
'2.2.53',
'2.2.54',
'2.2.55',
'2.2.56',
'2.2.57',
'2.2.58',
'2.2.59',
'2.2.60',
'2.2.61',
'2.2.62',
'2.2.63',
'2.2.64',
'2.2.65',
'2.2.66',
'2.2.67',
'2.2.68',
'2.2.69',
'2.2.70',
'2.2.71',
'2.2.72',
'2.2.73',
'2.3.0',
'2.3.1',
'2.3.2',
'2.3.3',
'2.3.4',
'2.3.5',
'2.3.6',
'2.3.7',
'2.3.8',
'2.3.9',
'2.3.10',
'2.3.11',
'2.3.12',
'2.3.13',
'2.3.14',
'2.3.15',
'2.3.16',
'2.3.17',
'2.3.18',
'2.3.19',
'2.3.20',
'2.3.21',
'2.3.22',
'2.3.23',
'2.3.24',
'2.3.25',
'2.3.26',
'2.3.27',
'2.3.28',
'2.3.29',
'2.3.30',
'2.3.31',
'2.3.32',
'2.3.33',
'2.3.34',
'2.3.35',
'2.3.36',
'2.3.37',
'2.3.38',
'2.3.39',
'2.3.40',
'2.3.41',
'2.3.42',
'2.3.43',
'2.3.44',
'2.3.45',
'2.3.46',
'2.3.47',
'2.3.48'
]
但 npm 似乎不能在不同的预发布版本之间有所不同:
> npm info artifact@">=1.14.0-ft.0 <1.14.0-ft0" version
[
artifact@1.14.0-ft.23 '1.14.0-ft.23'
artifact@1.14.0-ft.24 '1.14.0-ft.24'
artifact@1.14.0-ft.21 '1.14.0-ft.21'
artifact@1.14.0-ft.22 '1.14.0-ft.22'
artifact@1.14.0-ft.20 '1.14.0-ft.20'
artifact@1.14.0-ft.29 '1.14.0-ft.29'
artifact@1.14.0-ft.27 '1.14.0-ft.27'
artifact@1.14.0-ft.28 '1.14.0-ft.28'
artifact@1.14.0-ft.25 '1.14.0-ft.25'
artifact@1.14.0-ft.26 '1.14.0-ft.26'
artifact@1.14.0-ft.12 '1.14.0-ft.12'
artifact@1.14.0-ft.13 '1.14.0-ft.13'
artifact@1.14.0-ft.10 '1.14.0-ft.10'
artifact@1.14.0-ft.11 '1.14.0-ft.11'
artifact@1.14.0-ft.18 '1.14.0-ft.18'
artifact@1.14.0-ft.19 '1.14.0-ft.19'
artifact@1.14.0-ft.16 '1.14.0-ft.16'
artifact@1.14.0-ft.17 '1.14.0-ft.17'
artifact@1.14.0-ft.14 '1.14.0-ft.14'
artifact@1.14.0-ft.15 '1.14.0-ft.15'
artifact@1.14.0-ft-on-angular.4 '1.14.0-ft-on-angular.4'
artifact@1.14.0-ft.45 '1.14.0-ft.45'
artifact@1.14.0-ft-on-angular.5 '1.14.0-ft-on-angular.5'
artifact@1.14.0-ft.46 '1.14.0-ft.46'
artifact@1.14.0-ft-on-angular.2 '1.14.0-ft-on-angular.2'
artifact@1.14.0-ft.43 '1.14.0-ft.43'
artifact@1.14.0-ft-on-angular.3 '1.14.0-ft-on-angular.3'
artifact@1.14.0-ft.44 '1.14.0-ft.44'
artifact@1.14.0-ft-on-angular.0 '1.14.0-ft-on-angular.0'
artifact@1.14.0-ft.41 '1.14.0-ft.41'
artifact@1.14.0-ft-on-angular.1 '1.14.0-ft-on-angular.1'
artifact@1.14.0-ft.42 '1.14.0-ft.42'
artifact@1.14.0-ft.40 '1.14.0-ft.40'
artifact@1.14.0-ft.49 '1.14.0-ft.49'
artifact@1.14.0-ft.47 '1.14.0-ft.47'
artifact@1.14.0-ft.48 '1.14.0-ft.48'
artifact@1.14.0-ft.34 '1.14.0-ft.34'
artifact@1.14.0-ft.35 '1.14.0-ft.35'
artifact@1.14.0-ft.32 '1.14.0-ft.32'
artifact@1.14.0-ft.33 '1.14.0-ft.33'
artifact@1.14.0-ft.30 '1.14.0-ft.30'
artifact@1.14.0-ft.31 '1.14.0-ft.31'
artifact@1.14.0-ft.38 '1.14.0-ft.38'
artifact@1.14.0-ft.39 '1.14.0-ft.39'
artifact@1.14.0-ft.36 '1.14.0-ft.36'
artifact@1.14.0-ft.37 '1.14.0-ft.37'
artifact@1.14.0-ft.67 '1.14.0-ft.67'
artifact@1.14.0-ft.68 '1.14.0-ft.68'
artifact@1.14.0-ft.65 '1.14.0-ft.65'
artifact@1.14.0-ft.66 '1.14.0-ft.66'
artifact@1.14.0-ft.63 '1.14.0-ft.63'
artifact@1.14.0-ft.64 '1.14.0-ft.64'
artifact@1.14.0-ft.61 '1.14.0-ft.61'
artifact@1.14.0-ft.62 '1.14.0-ft.62'
artifact@1.14.0-ft.69 '1.14.0-ft.69'
artifact@1.14.0-ft.60 '1.14.0-ft.60'
artifact@1.14.0-ft.56 '1.14.0-ft.56'
artifact@1.14.0-ft.57 '1.14.0-ft.57'
artifact@1.14.0-ft.54 '1.14.0-ft.54'
artifact@1.14.0-ft.55 '1.14.0-ft.55'
artifact@1.14.0-ft.52 '1.14.0-ft.52'
artifact@1.14.0-ft.53 '1.14.0-ft.53'
artifact@1.14.0-ft.50 '1.14.0-ft.50'
artifact@1.14.0-ft.51 '1.14.0-ft.51'
artifact@1.14.0-ft.58 '1.14.0-ft.58'
artifact@1.14.0-ft.59 '1.14.0-ft.59'
artifact@1.14.0-ft.83 '1.14.0-ft.83'
artifact@1.14.0-ft.81 '1.14.0-ft.81'
artifact@1.14.0-ft.82 '1.14.0-ft.82'
artifact@1.14.0-ft.80 '1.14.0-ft.80'
artifact@1.14.0-ft.78 '1.14.0-ft.78'
artifact@1.14.0-ft.79 '1.14.0-ft.79'
artifact@1.14.0-ft.76 '1.14.0-ft.76'
artifact@1.14.0-ft.77 '1.14.0-ft.77'
artifact@1.14.0-ft.74 '1.14.0-ft.74'
artifact@1.14.0-ft.75 '1.14.0-ft.75'
artifact@1.14.0-ft.72 '1.14.0-ft.72'
artifact@1.14.0-ft.73 '1.14.0-ft.73'
artifact@1.14.0-ft.70 '1.14.0-ft.70'
artifact@1.14.0-ft.71 '1.14.0-ft.71'
artifact@1.14.0-ft.4 '1.14.0-ft.4'
artifact@1.14.0-ft.3 '1.14.0-ft.3'
artifact@1.14.0-ft.2 '1.14.0-ft.2'
artifact@1.14.0-ft.1 '1.14.0-ft.1'
artifact@1.14.0-ft.0 '1.14.0-ft.0'
artifact@1.14.0-ft.9 '1.14.0-ft.9'
artifact@1.14.0-ft.8 '1.14.0-ft.8'
artifact@1.14.0-ft.7 '1.14.0-ft.7'
artifact@1.14.0-ft.6 '1.14.0-ft.6'
artifact@1.14.0-ft.5 '1.14.0-ft.5'
artifact@1.14.0-ft-tracking.0 '1.14.0-ft-tracking.0'
artifact@1.14.0-ft-tracking.1 '1.14.0-ft-tracking.1'
artifact@1.14.0-ft-tracking.2 '1.14.0-ft-tracking.2'
]
想要的结果:
> npm info artifact@">=1.14.0-ft.0 <1.14.0-ft0" version
[
artifact@1.14.0-ft.23 '1.14.0-ft.23'
artifact@1.14.0-ft.24 '1.14.0-ft.24'
artifact@1.14.0-ft.21 '1.14.0-ft.21'
artifact@1.14.0-ft.22 '1.14.0-ft.22'
artifact@1.14.0-ft.20 '1.14.0-ft.20'
artifact@1.14.0-ft.29 '1.14.0-ft.29'
artifact@1.14.0-ft.27 '1.14.0-ft.27'
artifact@1.14.0-ft.28 '1.14.0-ft.28'
artifact@1.14.0-ft.25 '1.14.0-ft.25'
artifact@1.14.0-ft.26 '1.14.0-ft.26'
artifact@1.14.0-ft.12 '1.14.0-ft.12'
artifact@1.14.0-ft.13 '1.14.0-ft.13'
artifact@1.14.0-ft.10 '1.14.0-ft.10'
artifact@1.14.0-ft.11 '1.14.0-ft.11'
artifact@1.14.0-ft.18 '1.14.0-ft.18'
artifact@1.14.0-ft.19 '1.14.0-ft.19'
artifact@1.14.0-ft.16 '1.14.0-ft.16'
artifact@1.14.0-ft.17 '1.14.0-ft.17'
artifact@1.14.0-ft.14 '1.14.0-ft.14'
artifact@1.14.0-ft.15 '1.14.0-ft.15'
...
]
我预计不会有结果,因为 ft
不等于 ft-on-angular
或 ft-tracking
。
如何才能达到 select 至少只有 ft
作为预发布版本?
我试过 semver calculator 和类似的 select 或 (>=1.0.0-rc.0 <1.0.0-rc0
) 但它 select 只有 1.0.0-rcX。如果我更新 selector 到 >=1.0.0-r.0 <1.0.0-r0
它不匹配任何东西。
简答:
"How can I achieve to select at least only ft as prerelease version?"
通过 npm info
命令,您需要:
提供此比较器集以匹配
1.14.0
版本的所有-ft
预发行版:npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
或者,提供此比较器集以匹配
1.13.0
版本的所有-ft
预发行版:npm info artifact@">=1.13.0-ft.0 <1.13.0-ft-on-angular.0" version
或者,提供由两个比较器集组成的范围,以匹配
1.13.0
和1.14.0
版本的所有-ft
预发布:npm info artifact@">=1.13.0-ft.0 <1.13.0-ft-on-angular.0 || >=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
注意:在确定用于匹配特定预发布版本的正确比较器时,确实需要事先了解完整的数据集及其排序顺序SemVer 优先级。使用以下 npm info
命令将为给定 artifact/package:
npm info <package_name> versions
为什么您的 OP 中的比较器会产生不需要的语义版本?
"I would expect no results, because
ft
is not equal toft-on-angular
orft-tracking
." 1
为了进一步理解为什么 npm info
命令和你给定的 >=1.14.0-ft.0 <1.14.0-ft0
比较器集没有产生你想要的 semvers 列表,我们需要首先理解 Semver 规范在 关于优先规则的第 11 点。为方便起见,下面提供了 第 11 点 的副本:
注:编号列表格式是我加的
Precedence MUST be calculated by separating the version into major, minor, patch and pre-release identifiers in that order (Build metadata does not figure into precedence).
Precedence is determined by the first difference when comparing each of these identifiers from left to right as follows:
When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version. Example: 1.0.0-alpha < 1.0.0.
Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows:
2.1. identifiers consisting of only digits are compared numerically and
2.2. identifiers with letters or hyphens are compared lexically in ASCII sort order.
Numeric identifiers always have lower precedence than non-numeric identifiers.
A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal. Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
第 1、2、3 和 4 点与您的 OP 特别相关,因为它们专门解决了关于 semver 中的 pre-release field/identifier 的优先级规则。
您使用的比较器组有什么不正确的地方?
>=1.14.0-ft.0 <1.14.0-ft0
首先要注意这个比较器;
<1.14.0-ft0
,要求范围小于版本1.14.0-ft0
,并且您的数据集不包含-ft0
预发布版。但是,如果
-ft0
预发布标识符确实存在于您的数据集中,它将大于现有的1.14.0-ft-tracking.2
和1.14.0-ft-on-angular.0
semvers - 因此这就是为什么您得到的结果包括所有-ft-on-angular
和ft-tracking
预发布。为了进一步说明这一点,请考虑下面的排序语义版本列表(按升序排列)。特别注意
-ft0
预发布标识符的优先级 - 它明显高于其他标识符。... '1.14.0-ft.83', '1.14.0-ft.84', '1.14.0-ft.85', '1.14.0-ft-on-angular.0', '1.14.0-ft-on-angular.1', '1.14.0-ft-on-angular.2', '1.14.0-ft-on-angular.3', '1.14.0-ft-on-angular.4', '1.14.0-ft-on-angular.5', '1.14.0-ft-tracking.0', '1.14.0-ft-tracking.1', '1.14.0-ft-tracking.2', '1.14.0-ft0', <------- ...
现在,如果您考虑上面的第 2、3 和 4 点(即我在 Semver 规范第 11 点的摘录中指出的那些),关于优先规则,很明显为什么数据中的预发布标识符set 以这种方式排序:
特别地,考虑第 2.2 点的内容;
"[pre-release] identifiers with letters or hyphens are compared lexically in ASCII sort order".
注意
1.14.0-ft0
语义化末尾的零 (0
) 以及零在 ASCII 排序表中的位置(如下)。将其与1.14.0-ft-tracking.2
语义版本中的第二个连字符 (-
) 以及 ASCII 排序图中的连字符位置进行比较。如您所见,零 (0
) 的排序位置位于连字符 (-
) 之后。这解释了为什么1.14.0-ft0
在1.14.0-ft-tracking.2
之后排序。
ASCII 排序顺序表:
为方便起见,下图显示了 ASCII 字符的排序顺序:
┌─────────┬──────────────┬─────┬─────┬─────┬─────┬─────┬───────┐ │ space │ - (hyphen) │ : │ G │ T │ a │ n │ } │ │ ! │ . │ ; │ H │ U │ b │ o │ | │ │ " │ / │ < │ I │ V │ c │ p │ { │ │ # │ 0 (zero) │ = │ J │ W │ d │ q │ ~ │ │ $ │ 1 │ > │ K │ X │ e │ r │ DEL │ │ % │ 2 │ ? │ L │ Y │ f │ s │ │ │ & │ 3 │ @ │ M │ Z │ g │ t │ │ │ ' │ 4 │ A │ N │ [ │ h │ u │ │ │ ( │ 5 │ B │ O │ \ │ i │ v │ │ │ ) │ 6 │ C │ P │ ] │ j │ w │ │ │ * │ 7 │ D │ Q │ ^ │ k │ x │ │ │ + │ 8 │ E │ R │ _ │ l │ y │ │ │ , │ 9 │ F │ S │ ` │ m │ z │ │ └─────────┴──────────────┴─────┴─────┴─────┴─────┴─────┴───────┘
补充说明
您会注意到,在使用以下正确的 npm info
命令时:
npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version
它将结果打印到您的控制台,格式如下:
artifact@1.14.0-ft.1 '1.14.0-ft.1' artifact@1.14.0-ft.2 '1.14.0-ft.2' artifact@1.14.0-ft.3 '1.14.0-ft.3' ...
但是,如果您想重新格式化结果以形成 JSON 数组,请考虑将输出通过管道传输到 AWK,然后再传输到 node.js。例如使用以下复合命令:
npm info artifact@">=1.14.0-ft.0 <1.14.0-ft-on-angular.0" version | awk -F "'" '{print }' | node -e "process.stdin.on('data', function(d) {console.log( JSON.stringify(d.toString().split('\n').filter(Boolean), null, 2) )});"
将生成以下重新格式化的结果:
[
"1.14.0-ft.1",
"1.14.0-ft.2",
"1.14.0-ft.3",
...
]
脚注:
1 这个期望有点类似于 NOT 期望数字7
和 8
从这组八个数字中 return 编辑; 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 当定义要捕获的范围的边界为 >=0 <10
.
对于此问答的任何新读者,您可能有兴趣阅读评论中的讨论 here which took place prior to providing this answer. Props to @jwdonahue,以获得他的宝贵意见。