mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-30 23:07:56 +07:00 
			
		
		
		
	Improve regexes for pre-release extensions
This commit is contained in:
		| @ -3,7 +3,7 @@ import * as extensions from '../src/extensions'; | ||||
| describe('Extension tests', () => { | ||||
|   it('checking addExtensionOnWindows', async () => { | ||||
|     let win32: string = await extensions.addExtension( | ||||
|       'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', | ||||
|       'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1', | ||||
|       '7.4', | ||||
|       'win32' | ||||
|     ); | ||||
| @ -18,6 +18,7 @@ describe('Extension tests', () => { | ||||
|     expect(win32).toContain('Add-Extension ast beta'); | ||||
|     expect(win32).toContain('Add-Extension grpc stable 1.2.3'); | ||||
|     expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); | ||||
|     expect(win32).toContain('Add-Extension sqlsrv devel 1.2.3'); | ||||
|  | ||||
|     win32 = await extensions.addExtension('pcov', '5.6', 'win32'); | ||||
|     expect(win32).toContain( | ||||
|  | ||||
							
								
								
									
										6
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -2974,9 +2974,9 @@ async function addExtensionWindows(extension_csv, version) { | ||||
|                 add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version); | ||||
|                 break; | ||||
|             // match semver with state | ||||
|             case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension): | ||||
|                 matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension); | ||||
|                 add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2], matches[1]); | ||||
|             case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension): | ||||
|                 matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec(version_extension); | ||||
|                 add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]); | ||||
|                 break; | ||||
|             // match 5.3pcov to 7.0pcov | ||||
|             case /(5\.[3-6]|7\.0)pcov/.test(version_extension): | ||||
|  | ||||
| @ -164,16 +164,14 @@ export async function addExtensionWindows( | ||||
|         ); | ||||
|         break; | ||||
|       // match semver with state | ||||
|       case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test( | ||||
|         version_extension | ||||
|       ): | ||||
|         matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec( | ||||
|       case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension): | ||||
|         matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec( | ||||
|           version_extension | ||||
|         ) as RegExpExecArray; | ||||
|         add_script += await utils.joins( | ||||
|           '\nAdd-Extension', | ||||
|           ext_name, | ||||
|           matches[2], | ||||
|           matches[2].replace('preview', 'devel'), | ||||
|           matches[1] | ||||
|         ); | ||||
|         break; | ||||
|  | ||||
| @ -71,7 +71,7 @@ check_extension() { | ||||
| # Function to get the PECL version. | ||||
| get_pecl_version() { | ||||
|   extension=$1 | ||||
|   stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" | ||||
|   stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")" | ||||
|   pecl_rest='https://pecl.php.net/rest/r/' | ||||
|   response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) | ||||
|   pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)") | ||||
| @ -92,7 +92,7 @@ add_pecl_extension() { | ||||
|   extension=$1 | ||||
|   pecl_version=$2 | ||||
|   prefix=$3 | ||||
|   if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then | ||||
|   if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then | ||||
|     pecl_version=$(get_pecl_version "$extension" "$pecl_version") | ||||
|   fi | ||||
|   if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then | ||||
|  | ||||
| @ -92,7 +92,7 @@ configure_pecl() { | ||||
| # Function to get the PECL version of an extension. | ||||
| get_pecl_version() { | ||||
|   extension=$1 | ||||
|   stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" | ||||
|   stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")" | ||||
|   pecl_rest='https://pecl.php.net/rest/r/' | ||||
|   response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) | ||||
|   pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)") | ||||
| @ -202,7 +202,7 @@ add_pecl_extension() { | ||||
|   extension=$1 | ||||
|   pecl_version=$2 | ||||
|   prefix=$3 | ||||
|   if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then | ||||
|   if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then | ||||
|     pecl_version=$(get_pecl_version "$extension" "$pecl_version") | ||||
|   fi | ||||
|   if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur