import * as utils from './utils' ; param extension_csv param version export async function addExtensionDarwin ( extension_csv , version ) { const extensions = await utils . extensionArray ( extension_csv ) ; let add_script = '\n' ; let remove_script = '' ; await utils . asyncForEach ( extensions , async function ( extension ) { const version_extension = version + extension ; const [ ext_name , ext_version ] = extension . split ( '-' ) ; const ext_prefix = await utils . getExtensionPrefix ( ext_name ) ; switch ( true ) { case /^:/ . test ( ext_name ) : remove_script += '\ndisable_extension' + ext_name . replace ( /:/g , ' ' ) ; return ; case /^none$/ . test ( ext_name ) : add_script += '\ndisable_all_shared' ; return ; case /.+-.+\/.+@.+/ . test ( extension ) : add_script += await utils . parseExtensionSource ( extension , ext_prefix ) ; return ; case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/ . test ( version_extension ) : case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/ . test ( extension ) : case /^(5\.[3-6]|7\.[0-4])ioncube$/ . test ( version_extension ) : case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/ . test ( version_extension ) : add_script += await utils . customPackage ( ext_name , 'ext' , extension , 'darwin' ) ; return ; case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/ . test ( extension ) : add_script += await utils . joins ( '\nadd_unstable_extension' , ext_name , ext_version , ext_prefix ) ; return ; case /.+-\d+\.\d+\.\d+.*/ . test ( extension ) : add_script += await utils . joins ( '\nadd_pecl_extension' , ext_name , ext_version , ext_prefix ) ; return ; case /(5\.[3-6]|7\.0)pcov/ . test ( version_extension ) : add_script += await utils . getUnsupportedLog ( 'pcov' , version , 'darwin' ) ; return ; case /(?<!5\.[3-5])(amqp|apcu|expect|grpc|igbinary|imagick|imap|mailparse|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/ . test ( version_extension ) : case /(5\.6|7\.[0-4])propro/ . test ( version_extension ) : case /(?<!5\.[3-6]|7\.0)pcov/ . test ( version_extension ) : case /(?<!5\.[3-6])(vips|xlswriter)/ . test ( version_extension ) : add_script += await utils . joins ( '\nadd_brew_extension' , ext_name , ext_prefix ) ; return ; case /^sqlite$/ . test ( extension ) : extension = 'sqlite3' ; break ; default : break ; } add_script += await utils . joins ( '\nadd_extension' , extension , ext_prefix ) ; } ) ; return add_script + remove_script ; } param extension_csv param version export async function addExtensionWindows ( extension_csv , version ) { const extensions = await utils . extensionArray ( extension_csv ) ; let add_script = '\n' ; let remove_script = '' ; await utils . asyncForEach ( extensions , async function ( extension ) { const [ ext_name , ext_version ] = extension . split ( '-' ) ; const version_extension = version + extension ; let matches ; switch ( true ) { case /^:/ . test ( ext_name ) : remove_script += '\nDisable-Extension' + ext_name . replace ( /:/g , ' ' ) ; break ; case /^none$/ . test ( ext_name ) : add_script += '\nDisable-AllShared' ; break ; case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/ . test ( version_extension ) : case /^pdo_oci$|^oci8$|^pdo_firebird$/ . test ( extension ) : case /^(5\.[3-6]|7\.[0-4])ioncube$/ . test ( version_extension ) : case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/ . test ( version_extension ) : case /^(7\.[1-4]|8\.0)(pecl_)?http/ . test ( version_extension ) : add_script += await utils . customPackage ( ext_name , 'ext' , extension , 'win32' ) ; return ; case /.+-(stable|beta|alpha|devel|snapshot)/ . test ( extension ) : add_script += await utils . joins ( '\nAdd-Extension' , ext_name , ext_version . replace ( 'stable' , '' ) ) ; break ; case /.+-.+\/.+@.+/ . test ( extension ) : add_script += await utils . getUnsupportedLog ( extension , version , 'win32' ) ; break ; case /.+-\d+\.\d+\.\d+$/ . test ( extension ) : add_script += await utils . joins ( '\nAdd-Extension' , ext_name , 'stable' , ext_version ) ; break ; case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/ . test ( 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 ] . replace ( 'preview' , 'devel' ) , matches [ 1 ] ) ; break ; case /7\.[2-4]xdebug2/ . test ( version_extension ) : add_script += '\nAdd-Extension xdebug stable 2.9.8' ; break ; case /(5\.[3-6]|7\.0)pcov/ . test ( version_extension ) : add_script += await utils . getUnsupportedLog ( 'pcov' , version , 'win32' ) ; break ; case /^5\.[3-6](?<!pdo_)(mysql|mysqli|mysqlnd)$/ . test ( version_extension ) : add_script += '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd' ; break ; case /(?<!5\.[3-6])(?<!pdo_)(mysql|mysqli|mysqlnd)$/ . test ( version_extension ) : add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd' ; break ; case /^sqlite$/ . test ( extension ) : extension = 'sqlite3' ; add_script += await utils . joins ( '\nAdd-Extension' , extension ) ; break ; default : add_script += '\nAdd-Extension ' + extension ; break ; } } ) ; return add_script + remove_script ; } param extension_csv param version export async function addExtensionLinux ( extension_csv , version ) { const extensions = await utils . extensionArray ( extension_csv ) ; let add_script = '\n' ; let remove_script = '' ; await utils . asyncForEach ( extensions , async function ( extension ) { const version_extension = version + extension ; const [ ext_name , ext_version ] = extension . split ( /-(.+)/ ) . filter ( Boolean ) ; const ext_prefix = await utils . getExtensionPrefix ( ext_name ) ; switch ( true ) { case /^:/ . test ( ext_name ) : remove_script += '\ndisable_extension' + ext_name . replace ( /:/g , ' ' ) ; return ; case /^none$/ . test ( ext_name ) : add_script += '\ndisable_all_shared' ; return ; case /.+-.+\/.+@.+/ . test ( extension ) : add_script += await utils . parseExtensionSource ( extension , ext_prefix ) ; return ; case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/ . test ( version_extension ) : case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/ . test ( version_extension ) : case /^couchbase$|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/ . test ( extension ) : case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/ . test ( version_extension ) : case /^(5\.[3-6]|7\.[0-4])ioncube$/ . test ( version_extension ) : case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/ . test ( version_extension ) : add_script += await utils . customPackage ( ext_name , 'ext' , extension , 'linux' ) ; return ; case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/ . test ( extension ) : add_script += await utils . joins ( '\nadd_unstable_extension' , ext_name , ext_version , ext_prefix ) ; return ; case /.+-\d+\.\d+\.\d+.*/ . test ( extension ) : add_script += await utils . joins ( '\nadd_pecl_extension' , ext_name , ext_version , ext_prefix ) ; return ; case /(5\.[3-6]|7\.0)pcov/ . test ( version_extension ) : add_script += await utils . getUnsupportedLog ( 'pcov' , version , 'linux' ) ; return ; case /^7\.[2-4]xdebug2$/ . test ( version_extension ) : add_script += await utils . joins ( '\nadd_pecl_extension' , 'xdebug' , '2.9.8' , ext_prefix ) ; return ; case /^pdo[_-].+/ . test ( extension ) : extension = extension . replace ( /pdo[_-]|3/ , '' ) ; add_script += '\nadd_pdo_extension ' + extension ; return ; case /^sqlite$/ . test ( extension ) : extension = 'sqlite3' ; break ; default : break ; } add_script += await utils . joins ( '\nadd_extension' , extension , ext_prefix ) ; } ) ; return add_script + remove_script ; } param extension_csv param version param os_version param no_step export async function addExtension ( extension_csv , version , os_version , no_step = false ) { const log = await utils . stepLog ( 'Setup Extensions' , os_version ) ; let script = '\n' ; switch ( no_step ) { case true : script += log + ( await utils . suppressOutput ( os_version ) ) ; break ; case false : default : script += log ; break ; } switch ( os_version ) { case 'win32' : return script + ( await addExtensionWindows ( extension_csv , version ) ) ; case 'darwin' : return script + ( await addExtensionDarwin ( extension_csv , version ) ) ; case 'linux' : return script + ( await addExtensionLinux ( extension_csv , version ) ) ; default : return await utils . log ( 'Platform ' + os_version + ' is not supported' , os_version , 'error' ) ; } }