mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-31 07:16:22 +07:00 
			
		
		
		
	Refactor coverage and extension code
This commit is contained in:
		| @ -2,20 +2,15 @@ import * as coverage from '../src/coverage'; | |||||||
|  |  | ||||||
| jest.mock('../src/extensions', () => ({ | jest.mock('../src/extensions', () => ({ | ||||||
|   addExtension: jest.fn().mockImplementation(extension => { |   addExtension: jest.fn().mockImplementation(extension => { | ||||||
|     return 'addExtension ' + extension + '\n'; |     return 'add_extension ' + extension + '\n'; | ||||||
|   }) |   }) | ||||||
| })); | })); | ||||||
|  |  | ||||||
| describe('Config tests', () => { | describe('Config tests', () => { | ||||||
|   it('checking addCoverage with PCOV on windows', async () => { |   it('checking addCoverage with PCOV on windows', async () => { | ||||||
|     let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32'); |     let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32'); | ||||||
|     expect(win32).toContain('addExtension pcov'); |     expect(win32).toContain('add_extension pcov'); | ||||||
|     expect(win32).toContain( |     expect(win32).toContain('Remove-Extension xdebug'); | ||||||
|       'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir' |  | ||||||
|     ); |  | ||||||
|     expect(win32).toContain( |  | ||||||
|       'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' |  | ||||||
|     ); |  | ||||||
|  |  | ||||||
|     win32 = await coverage.addCoverage('pcov', '7.0', 'win32'); |     win32 = await coverage.addCoverage('pcov', '7.0', 'win32'); | ||||||
|     expect(win32).toContain('PHP 7.1 or newer is required'); |     expect(win32).toContain('PHP 7.1 or newer is required'); | ||||||
| @ -26,24 +21,19 @@ describe('Config tests', () => { | |||||||
|  |  | ||||||
|   it('checking addCoverage with PCOV on linux', async () => { |   it('checking addCoverage with PCOV on linux', async () => { | ||||||
|     const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux'); |     const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux'); | ||||||
|     expect(linux).toContain('addExtension pcov'); |     expect(linux).toContain('add_extension pcov'); | ||||||
|     expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"'); |     expect(linux).toContain('remove_extension xdebug'); | ||||||
|     expect(linux).toContain('sudo phpdismod -v 7.4 xdebug'); |  | ||||||
|     expect(linux).toContain( |  | ||||||
|       'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug' |  | ||||||
|     ); |  | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking addCoverage with PCOV on darwin', async () => { |   it('checking addCoverage with PCOV on darwin', async () => { | ||||||
|     const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin'); |     const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin'); | ||||||
|     expect(darwin).toContain('addExtension pcov'); |     expect(darwin).toContain('add_extension pcov'); | ||||||
|     expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); |     expect(darwin).toContain('remove_extension xdebug'); | ||||||
|     expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so'); |  | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking addCoverage with Xdebug on windows', async () => { |   it('checking addCoverage with Xdebug on windows', async () => { | ||||||
|     const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); |     const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); | ||||||
|     expect(win32).toContain('addExtension xdebug'); |     expect(win32).toContain('add_extension xdebug'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking addCoverage with Xdebug on windows', async () => { |   it('checking addCoverage with Xdebug on windows', async () => { | ||||||
| @ -53,7 +43,7 @@ describe('Config tests', () => { | |||||||
|  |  | ||||||
|   it('checking addCoverage with Xdebug on linux', async () => { |   it('checking addCoverage with Xdebug on linux', async () => { | ||||||
|     const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux'); |     const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux'); | ||||||
|     expect(linux).toContain('addExtension xdebug'); |     expect(linux).toContain('add_extension xdebug'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking addCoverage with Xdebug on linux', async () => { |   it('checking addCoverage with Xdebug on linux', async () => { | ||||||
| @ -67,7 +57,7 @@ describe('Config tests', () => { | |||||||
|       '7.4', |       '7.4', | ||||||
|       'darwin' |       'darwin' | ||||||
|     ); |     ); | ||||||
|     expect(darwin).toContain('addExtension xdebug'); |     expect(darwin).toContain('add_extension xdebug'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking addCoverage with Xdebug on darwin', async () => { |   it('checking addCoverage with Xdebug on darwin', async () => { | ||||||
| @ -81,33 +71,20 @@ describe('Config tests', () => { | |||||||
|  |  | ||||||
|   it('checking disableCoverage windows', async () => { |   it('checking disableCoverage windows', async () => { | ||||||
|     const win32 = await coverage.addCoverage('none', '7.4', 'win32'); |     const win32 = await coverage.addCoverage('none', '7.4', 'win32'); | ||||||
|     expect(win32).toContain('Disable-PhpExtension xdebug'); |     expect(win32).toContain('Remove-Extension xdebug'); | ||||||
|     expect(win32).toContain('Disable-PhpExtension pcov'); |     expect(win32).toContain('Remove-Extension pcov'); | ||||||
|     expect(win32).toContain( |  | ||||||
|       'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' |  | ||||||
|     ); |  | ||||||
|     expect(win32).toContain( |  | ||||||
|       'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' |  | ||||||
|     ); |  | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking disableCoverage on linux', async () => { |   it('checking disableCoverage on linux', async () => { | ||||||
|     const linux: string = await coverage.addCoverage('none', '7.4', 'linux'); |     const linux: string = await coverage.addCoverage('none', '7.4', 'linux'); | ||||||
|     expect(linux).toContain('sudo phpdismod -v 7.4 xdebug'); |     expect(linux).toContain('remove_extension xdebug'); | ||||||
|     expect(linux).toContain('sudo phpdismod -v 7.4 pcov'); |     expect(linux).toContain('remove_extension pcov'); | ||||||
|     expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"'); |  | ||||||
|     expect(linux).toContain('sudo sed -i "/pcov/d" "$ini_file"'); |  | ||||||
|     expect(linux).toContain( |  | ||||||
|       'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov' |  | ||||||
|     ); |  | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking disableCoverage on darwin', async () => { |   it('checking disableCoverage on darwin', async () => { | ||||||
|     const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin'); |     const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin'); | ||||||
|     expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); |     expect(darwin).toContain('remove_extension xdebug'); | ||||||
|     expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" "$ini_file"'); |     expect(darwin).toContain('remove_extension pcov'); | ||||||
|     expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so'); |  | ||||||
|     expect(darwin).toContain('sudo rm -rf "$ext_dir"/pcov.so'); |  | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('checking no or invalid coverage driver', async () => { |   it('checking no or invalid coverage driver', async () => { | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ describe('Extension tests', () => { | |||||||
|     ); |     ); | ||||||
|     expect(win32).toContain('Add-Extension xdebug'); |     expect(win32).toContain('Add-Extension xdebug'); | ||||||
|     expect(win32).toContain('Add-Extension pcov'); |     expect(win32).toContain('Add-Extension pcov'); | ||||||
|     expect(win32).toContain('Add-Phalcon phalcon4'); |     expect(win32).toContain('phalcon.ps1 phalcon4'); | ||||||
|  |  | ||||||
|     win32 = await extensions.addExtension( |     win32 = await extensions.addExtension( | ||||||
|       'phalcon3, does_not_exist', |       'phalcon3, does_not_exist', | ||||||
| @ -17,7 +17,7 @@ describe('Extension tests', () => { | |||||||
|       'win32', |       'win32', | ||||||
|       true |       true | ||||||
|     ); |     ); | ||||||
|     expect(win32).toContain('Add-Phalcon phalcon3'); |     expect(win32).toContain('phalcon.ps1 phalcon3'); | ||||||
|     expect(win32).toContain('Add-Extension does_not_exist'); |     expect(win32).toContain('Add-Extension does_not_exist'); | ||||||
|  |  | ||||||
|     win32 = await extensions.addExtension('xdebug', '7.2', 'fedora'); |     win32 = await extensions.addExtension('xdebug', '7.2', 'fedora'); | ||||||
| @ -80,10 +80,10 @@ describe('Extension tests', () => { | |||||||
|     expect(darwin).toContain('sudo pecl install pcov'); |     expect(darwin).toContain('sudo pecl install pcov'); | ||||||
|  |  | ||||||
|     darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); |     darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); | ||||||
|     expect(darwin).toContain('add_phalcon phalcon3'); |     expect(darwin).toContain('phalcon_darwin.sh phalcon3'); | ||||||
|  |  | ||||||
|     darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); |     darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); | ||||||
|     expect(darwin).toContain('add_phalcon phalcon4'); |     expect(darwin).toContain('phalcon_darwin.sh phalcon4'); | ||||||
|  |  | ||||||
|     darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); |     darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); | ||||||
|     expect(darwin).toContain('sudo pecl install pcov'); |     expect(darwin).toContain('sudo pecl install pcov'); | ||||||
|  | |||||||
| @ -47,8 +47,7 @@ jest.mock('../src/install', () => ({ | |||||||
|         } |         } | ||||||
|         case 'win32': |         case 'win32': | ||||||
|           script = await install.build(os_version + '.sh', version, os_version); |           script = await install.build(os_version + '.sh', version, os_version); | ||||||
|           script += |           script += 'pwsh script.ps1 ' + version + ' ' + __dirname; | ||||||
|             'pwsh script.ps1 -version ' + version + ' -dir ' + __dirname; |  | ||||||
|           break; |           break; | ||||||
|         default: |         default: | ||||||
|           script += os_version + ' is not supported'; |           script += os_version + ' is not supported'; | ||||||
| @ -90,13 +89,13 @@ describe('Install', () => { | |||||||
|     // @ts-ignore |     // @ts-ignore | ||||||
|     let script: string = await install.run(); |     let script: string = await install.run(); | ||||||
|     expect(script).toContain('initial script'); |     expect(script).toContain('initial script'); | ||||||
|     expect(script).toContain('pwsh script.ps1 -version 7.0 -dir ' + __dirname); |     expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname); | ||||||
|  |  | ||||||
|     setEnv('7.3', 'win32', '', '', '', ''); |     setEnv('7.3', 'win32', '', '', '', ''); | ||||||
|     // @ts-ignore |     // @ts-ignore | ||||||
|     script = await install.run(); |     script = await install.run(); | ||||||
|     expect(script).toContain('initial script'); |     expect(script).toContain('initial script'); | ||||||
|     expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname); |     expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); | ||||||
|  |  | ||||||
|     setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); |     setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); | ||||||
|     // @ts-ignore |     // @ts-ignore | ||||||
| @ -105,7 +104,7 @@ describe('Install', () => { | |||||||
|     expect(script).toContain('install extensions'); |     expect(script).toContain('install extensions'); | ||||||
|     expect(script).toContain('edit php.ini'); |     expect(script).toContain('edit php.ini'); | ||||||
|     expect(script).toContain('set coverage driver'); |     expect(script).toContain('set coverage driver'); | ||||||
|     expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname); |     expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('Test install on linux', async () => { |   it('Test install on linux', async () => { | ||||||
|  | |||||||
							
								
								
									
										164
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										164
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -1570,8 +1570,9 @@ const config = __importStar(__webpack_require__(641)); | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function addCoverageXdebug(version, os_version) { | function addCoverageXdebug(version, os_version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         switch (version) { |         switch (version) { | ||||||
|             case '8.0': |             case '8.0': | ||||||
| @ -1580,7 +1581,7 @@ function addCoverageXdebug(version, os_version) { | |||||||
|             case '7.4': |             case '7.4': | ||||||
|             default: |             default: | ||||||
|                 return ((yield extensions.addExtension('xdebug', version, os_version, true)) + |                 return ((yield extensions.addExtension('xdebug', version, os_version, true)) + | ||||||
|                     (yield utils.suppressOutput(os_version)) + |                     pipe + | ||||||
|                     '\n' + |                     '\n' + | ||||||
|                     (yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version))); |                     (yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version))); | ||||||
|         } |         } | ||||||
| @ -1592,47 +1593,27 @@ exports.addCoverageXdebug = addCoverageXdebug; | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function addCoveragePCOV(version, os_version) { | function addCoveragePCOV(version, os_version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
|         switch (version) { |         switch (version) { | ||||||
|             default: |             default: | ||||||
|                 script += |                 script += | ||||||
|                     (yield extensions.addExtension('pcov', version, os_version, true)) + |                     (yield extensions.addExtension('pcov', version, os_version, true)) + | ||||||
|                         (yield utils.suppressOutput(os_version)) + |                         pipe + | ||||||
|                         '\n'; |                         '\n'; | ||||||
|                 script += |                 script += | ||||||
|                     (yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; |                     (yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; | ||||||
|                 // add command to disable xdebug and enable pcov |                 // add command to disable xdebug and enable pcov | ||||||
|                 switch (os_version) { |                 switch (os_version) { | ||||||
|                     case 'linux': |                     case 'linux': | ||||||
|                         script += |  | ||||||
|                             'if [ -e /etc/php/' + |  | ||||||
|                                 version + |  | ||||||
|                                 '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + |  | ||||||
|                                 version + |  | ||||||
|                                 ' xdebug; fi\n'; |  | ||||||
|                         script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; |  | ||||||
|                         script += |  | ||||||
|                             'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' + |  | ||||||
|                                 (yield utils.suppressOutput('linux')) + |  | ||||||
|                                 '\n'; |  | ||||||
|                         break; |  | ||||||
|                     case 'darwin': |                     case 'darwin': | ||||||
|                         script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; |                         script += 'remove_extension xdebug' + pipe + '\n'; | ||||||
|                         script += |  | ||||||
|                             'sudo rm -rf "$ext_dir"/xdebug.so ' + |  | ||||||
|                                 (yield utils.suppressOutput('darwin')) + |  | ||||||
|                                 '\n'; |  | ||||||
|                         break; |                         break; | ||||||
|                     case 'win32': |                     case 'win32': | ||||||
|                         script += |                         script += 'Remove-Extension xdebug' + pipe + '\n'; | ||||||
|                             'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; |  | ||||||
|                         script += |  | ||||||
|                             'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + |  | ||||||
|                                 (yield utils.suppressOutput('win32')) + |  | ||||||
|                                 '\n'; |  | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|                 // success |                 // success | ||||||
| @ -1653,56 +1634,20 @@ exports.addCoveragePCOV = addCoveragePCOV; | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function disableCoverage(version, os_version) { | function disableCoverage(version, os_version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
|         switch (os_version) { |         switch (os_version) { | ||||||
|             case 'linux': |             case 'linux': | ||||||
|                 script += |  | ||||||
|                     'if [ -e /etc/php/' + |  | ||||||
|                         version + |  | ||||||
|                         '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + |  | ||||||
|                         version + |  | ||||||
|                         ' xdebug; fi\n'; |  | ||||||
|                 script += |  | ||||||
|                     'if [ -e /etc/php/' + |  | ||||||
|                         version + |  | ||||||
|                         '/mods-available/pcov.ini ]; then sudo phpdismod -v ' + |  | ||||||
|                         version + |  | ||||||
|                         ' pcov; fi\n'; |  | ||||||
|                 script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; |  | ||||||
|                 script += 'sudo sed -i "/pcov/d" "$ini_file"\n'; |  | ||||||
|                 script += |  | ||||||
|                     'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' + |  | ||||||
|                         (yield utils.suppressOutput('linux')) + |  | ||||||
|                         '\n'; |  | ||||||
|                 break; |  | ||||||
|             case 'darwin': |             case 'darwin': | ||||||
|                 script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; |                 script += 'remove_extension xdebug' + pipe + '\n'; | ||||||
|                 script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; |                 script += 'remove_extension pcov' + pipe + '\n'; | ||||||
|                 script += |  | ||||||
|                     'sudo rm -rf "$ext_dir"/xdebug.so ' + |  | ||||||
|                         (yield utils.suppressOutput('darwin')) + |  | ||||||
|                         '\n'; |  | ||||||
|                 script += |  | ||||||
|                     'sudo rm -rf "$ext_dir"/pcov.so ' + |  | ||||||
|                         (yield utils.suppressOutput('darwin')) + |  | ||||||
|                         '\n'; |  | ||||||
|                 break; |                 break; | ||||||
|             case 'win32': |             case 'win32': | ||||||
|                 script += |                 script += 'Remove-Extension xdebug' + pipe + '\n'; | ||||||
|                     'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; |                 script += 'Remove-Extension pcov' + pipe + '\n'; | ||||||
|                 script += |  | ||||||
|                     'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n'; |  | ||||||
|                 script += |  | ||||||
|                     'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + |  | ||||||
|                         (yield utils.suppressOutput('win32')) + |  | ||||||
|                         '\n'; |  | ||||||
|                 script += |  | ||||||
|                     'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' + |  | ||||||
|                         (yield utils.suppressOutput('win32')) + |  | ||||||
|                         '\n'; |  | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|         script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); |         script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); | ||||||
| @ -1721,13 +1666,14 @@ function addCoverage(coverage_driver, version, os_version) { | |||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         coverage_driver.toLowerCase(); |         coverage_driver.toLowerCase(); | ||||||
|         const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version)); |         const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version)); | ||||||
|  |         const pipe = yield utils.suppressOutput(os_version); | ||||||
|         switch (coverage_driver) { |         switch (coverage_driver) { | ||||||
|             case 'pcov': |             case 'pcov': | ||||||
|                 return script + (yield addCoveragePCOV(version, os_version)); |                 return script + (yield addCoveragePCOV(version, os_version, pipe)); | ||||||
|             case 'xdebug': |             case 'xdebug': | ||||||
|                 return script + (yield addCoverageXdebug(version, os_version)); |                 return script + (yield addCoverageXdebug(version, os_version, pipe)); | ||||||
|             case 'none': |             case 'none': | ||||||
|                 return script + (yield disableCoverage(version, os_version)); |                 return script + (yield disableCoverage(version, os_version, pipe)); | ||||||
|             default: |             default: | ||||||
|                 return ''; |                 return ''; | ||||||
|         } |         } | ||||||
| @ -1922,7 +1868,7 @@ function run() { | |||||||
|                 } |                 } | ||||||
|                 case 'win32': |                 case 'win32': | ||||||
|                     script_path = yield build('win32.ps1', version, os_version); |                     script_path = yield build('win32.ps1', version, os_version); | ||||||
|                     yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname); |                     yield exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname); | ||||||
|                     break; |                     break; | ||||||
|             } |             } | ||||||
|             yield matchers.addMatchers(); |             yield matchers.addMatchers(); | ||||||
| @ -2184,28 +2130,35 @@ const utils = __importStar(__webpack_require__(163)); | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function addExtensionDarwin(extension_csv, version) { | function addExtensionDarwin(extension_csv, version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         const extensions = yield utils.extensionArray(extension_csv); |         const extensions = yield utils.extensionArray(extension_csv); | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
|         yield utils.asyncForEach(extensions, function (extension) { |         yield utils.asyncForEach(extensions, function (extension) { | ||||||
|             return __awaiter(this, void 0, void 0, function* () { |             return __awaiter(this, void 0, void 0, function* () { | ||||||
|                 extension = extension.toLowerCase(); |                 extension = extension.toLowerCase(); | ||||||
|  |                 const version_extension = version + extension; | ||||||
|                 // add script to enable extension is already installed along with php |                 // add script to enable extension is already installed along with php | ||||||
|                 let install_command = ''; |                 let install_command = ''; | ||||||
|                 switch (true) { |                 switch (true) { | ||||||
|                     case /5\.6xdebug/.test(version + extension): |                     case /5\.6xdebug/.test(version_extension): | ||||||
|                         install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1'; |                         install_command = 'sudo pecl install xdebug-2.5.5' + pipe; | ||||||
|                         break; |                         break; | ||||||
|                     case /5\.6redis/.test(version + extension): |                     case /5\.6redis/.test(version_extension): | ||||||
|                         install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1'; |                         install_command = 'sudo pecl install redis-2.2.8' + pipe; | ||||||
|  |                         break; | ||||||
|  |                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|  |                         install_command = | ||||||
|  |                             'sh ' + | ||||||
|  |                                 path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + | ||||||
|  |                                 ' ' + | ||||||
|  |                                 extension + | ||||||
|  |                                 pipe; | ||||||
|                         break; |                         break; | ||||||
|                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |  | ||||||
|                         script += '\nadd_phalcon ' + extension; |  | ||||||
|                         return; |  | ||||||
|                     default: |                     default: | ||||||
|                         install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1'; |                         install_command = 'sudo pecl install ' + extension + pipe; | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|                 script += |                 script += | ||||||
| @ -2226,18 +2179,27 @@ exports.addExtensionDarwin = addExtensionDarwin; | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function addExtensionWindows(extension_csv, version) { | function addExtensionWindows(extension_csv, version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         const extensions = yield utils.extensionArray(extension_csv); |         const extensions = yield utils.extensionArray(extension_csv); | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
|         yield utils.asyncForEach(extensions, function (extension) { |         yield utils.asyncForEach(extensions, function (extension) { | ||||||
|             return __awaiter(this, void 0, void 0, function* () { |             return __awaiter(this, void 0, void 0, function* () { | ||||||
|                 // add script to enable extension is already installed along with php |                 // add script to enable extension is already installed along with php | ||||||
|  |                 const version_extension = version + extension; | ||||||
|                 switch (true) { |                 switch (true) { | ||||||
|                     // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 |                     // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 | ||||||
|                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|                         script += '\nAdd-Phalcon ' + extension; |                         script += | ||||||
|  |                             '\n& ' + | ||||||
|  |                                 path.join(__dirname, '../src/scripts/ext/phalcon.ps1') + | ||||||
|  |                                 ' ' + | ||||||
|  |                                 extension + | ||||||
|  |                                 ' ' + | ||||||
|  |                                 version + | ||||||
|  |                                 '\n'; | ||||||
|                         break; |                         break; | ||||||
|                     default: |                     default: | ||||||
|                         script += '\nAdd-Extension ' + extension; |                         script += '\nAdd-Extension ' + extension; | ||||||
| @ -2254,8 +2216,9 @@ exports.addExtensionWindows = addExtensionWindows; | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| function addExtensionLinux(extension_csv, version) { | function addExtensionLinux(extension_csv, version, pipe) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         const extensions = yield utils.extensionArray(extension_csv); |         const extensions = yield utils.extensionArray(extension_csv); | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
| @ -2263,27 +2226,28 @@ function addExtensionLinux(extension_csv, version) { | |||||||
|             return __awaiter(this, void 0, void 0, function* () { |             return __awaiter(this, void 0, void 0, function* () { | ||||||
|                 extension = extension.toLowerCase(); |                 extension = extension.toLowerCase(); | ||||||
|                 // add script to enable extension is already installed along with php |                 // add script to enable extension is already installed along with php | ||||||
|  |                 const version_extension = version + extension; | ||||||
|                 let install_command = ''; |                 let install_command = ''; | ||||||
|                 switch (true) { |                 switch (true) { | ||||||
|                     // match 5.6gearman..7.4gearman |                     // match 5.6gearman..7.4gearman | ||||||
|                     case /^((5\.6)|(7\.[0-4]))gearman$/.test(version + extension): |                     case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): | ||||||
|                         install_command = |                         install_command = | ||||||
|                             'sh ' + |                             'sh ' + | ||||||
|                                 path.join(__dirname, '../src/scripts/gearman.sh') + |                                 path.join(__dirname, '../src/scripts/ext/gearman.sh') + | ||||||
|                                 ' ' + |                                 ' ' + | ||||||
|                                 version + |                                 version + | ||||||
|                                 ' >/dev/null 2>&1'; |                                 pipe; | ||||||
|                         break; |                         break; | ||||||
|                     // match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 |                     // match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 | ||||||
|                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |                     case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|                         install_command = |                         install_command = | ||||||
|                             'sh ' + |                             'sh ' + | ||||||
|                                 path.join(__dirname, '../src/scripts/phalcon.sh') + |                                 path.join(__dirname, '../src/scripts/ext/phalcon.sh') + | ||||||
|                                 ' ' + |                                 ' ' + | ||||||
|                                 extension + |                                 extension + | ||||||
|                                 ' ' + |                                 ' ' + | ||||||
|                                 version + |                                 version + | ||||||
|                                 ' >/dev/null 2>&1'; |                                 pipe; | ||||||
|                         break; |                         break; | ||||||
|                     default: |                     default: | ||||||
|                         install_command = |                         install_command = | ||||||
| @ -2291,9 +2255,10 @@ function addExtensionLinux(extension_csv, version) { | |||||||
|                                 version + |                                 version + | ||||||
|                                 '-' + |                                 '-' + | ||||||
|                                 extension.replace('pdo_', '').replace('pdo-', '') + |                                 extension.replace('pdo_', '').replace('pdo-', '') + | ||||||
|                                 ' >/dev/null 2>&1 || sudo pecl install ' + |                                 pipe + | ||||||
|  |                                 ' || sudo pecl install ' + | ||||||
|                                 extension + |                                 extension + | ||||||
|                                 ' >/dev/null 2>&1'; |                                 pipe; | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|                 script += |                 script += | ||||||
| @ -2319,12 +2284,11 @@ exports.addExtensionLinux = addExtensionLinux; | |||||||
|  */ |  */ | ||||||
| function addExtension(extension_csv, version, os_version, no_step = false) { | function addExtension(extension_csv, version, os_version, no_step = false) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |         const pipe = yield utils.suppressOutput(os_version); | ||||||
|         let script = '\n'; |         let script = '\n'; | ||||||
|         switch (no_step) { |         switch (no_step) { | ||||||
|             case true: |             case true: | ||||||
|                 script += |                 script += (yield utils.stepLog('Setup Extensions', os_version)) + pipe; | ||||||
|                     (yield utils.stepLog('Setup Extensions', os_version)) + |  | ||||||
|                         (yield utils.suppressOutput(os_version)); |  | ||||||
|                 break; |                 break; | ||||||
|             case false: |             case false: | ||||||
|             default: |             default: | ||||||
| @ -2333,11 +2297,11 @@ function addExtension(extension_csv, version, os_version, no_step = false) { | |||||||
|         } |         } | ||||||
|         switch (os_version) { |         switch (os_version) { | ||||||
|             case 'win32': |             case 'win32': | ||||||
|                 return script + (yield addExtensionWindows(extension_csv, version)); |                 return script + (yield addExtensionWindows(extension_csv, version, pipe)); | ||||||
|             case 'darwin': |             case 'darwin': | ||||||
|                 return script + (yield addExtensionDarwin(extension_csv, version)); |                 return script + (yield addExtensionDarwin(extension_csv, version, pipe)); | ||||||
|             case 'linux': |             case 'linux': | ||||||
|                 return script + (yield addExtensionLinux(extension_csv, version)); |                 return script + (yield addExtensionLinux(extension_csv, version, pipe)); | ||||||
|             default: |             default: | ||||||
|                 return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); |                 return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -7,10 +7,12 @@ import * as config from './config'; | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function addCoverageXdebug( | export async function addCoverageXdebug( | ||||||
|   version: string, |   version: string, | ||||||
|   os_version: string |   os_version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   switch (version) { |   switch (version) { | ||||||
|     case '8.0': |     case '8.0': | ||||||
| @ -27,7 +29,7 @@ export async function addCoverageXdebug( | |||||||
|     default: |     default: | ||||||
|       return ( |       return ( | ||||||
|         (await extensions.addExtension('xdebug', version, os_version, true)) + |         (await extensions.addExtension('xdebug', version, os_version, true)) + | ||||||
|         (await utils.suppressOutput(os_version)) + |         pipe + | ||||||
|         '\n' + |         '\n' + | ||||||
|         (await utils.addLog( |         (await utils.addLog( | ||||||
|           '$tick', |           '$tick', | ||||||
| @ -44,17 +46,19 @@ export async function addCoverageXdebug( | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function addCoveragePCOV( | export async function addCoveragePCOV( | ||||||
|   version: string, |   version: string, | ||||||
|   os_version: string |   os_version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   switch (version) { |   switch (version) { | ||||||
|     default: |     default: | ||||||
|       script += |       script += | ||||||
|         (await extensions.addExtension('pcov', version, os_version, true)) + |         (await extensions.addExtension('pcov', version, os_version, true)) + | ||||||
|         (await utils.suppressOutput(os_version)) + |         pipe + | ||||||
|         '\n'; |         '\n'; | ||||||
|       script += |       script += | ||||||
|         (await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; |         (await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; | ||||||
| @ -62,32 +66,11 @@ export async function addCoveragePCOV( | |||||||
|       // add command to disable xdebug and enable pcov |       // add command to disable xdebug and enable pcov | ||||||
|       switch (os_version) { |       switch (os_version) { | ||||||
|         case 'linux': |         case 'linux': | ||||||
|           script += |  | ||||||
|             'if [ -e /etc/php/' + |  | ||||||
|             version + |  | ||||||
|             '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + |  | ||||||
|             version + |  | ||||||
|             ' xdebug; fi\n'; |  | ||||||
|           script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; |  | ||||||
|           script += |  | ||||||
|             'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' + |  | ||||||
|             (await utils.suppressOutput('linux')) + |  | ||||||
|             '\n'; |  | ||||||
|           break; |  | ||||||
|         case 'darwin': |         case 'darwin': | ||||||
|           script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; |           script += 'remove_extension xdebug' + pipe + '\n'; | ||||||
|           script += |  | ||||||
|             'sudo rm -rf "$ext_dir"/xdebug.so ' + |  | ||||||
|             (await utils.suppressOutput('darwin')) + |  | ||||||
|             '\n'; |  | ||||||
|           break; |           break; | ||||||
|         case 'win32': |         case 'win32': | ||||||
|           script += |           script += 'Remove-Extension xdebug' + pipe + '\n'; | ||||||
|             'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; |  | ||||||
|           script += |  | ||||||
|             'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + |  | ||||||
|             (await utils.suppressOutput('win32')) + |  | ||||||
|             '\n'; |  | ||||||
|           break; |           break; | ||||||
|       } |       } | ||||||
|  |  | ||||||
| @ -119,58 +102,23 @@ export async function addCoveragePCOV( | |||||||
|  * |  * | ||||||
|  * @param version |  * @param version | ||||||
|  * @param os_version |  * @param os_version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function disableCoverage( | export async function disableCoverage( | ||||||
|   version: string, |   version: string, | ||||||
|   os_version: string |   os_version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   switch (os_version) { |   switch (os_version) { | ||||||
|     case 'linux': |     case 'linux': | ||||||
|       script += |  | ||||||
|         'if [ -e /etc/php/' + |  | ||||||
|         version + |  | ||||||
|         '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + |  | ||||||
|         version + |  | ||||||
|         ' xdebug; fi\n'; |  | ||||||
|       script += |  | ||||||
|         'if [ -e /etc/php/' + |  | ||||||
|         version + |  | ||||||
|         '/mods-available/pcov.ini ]; then sudo phpdismod -v ' + |  | ||||||
|         version + |  | ||||||
|         ' pcov; fi\n'; |  | ||||||
|       script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; |  | ||||||
|       script += 'sudo sed -i "/pcov/d" "$ini_file"\n'; |  | ||||||
|       script += |  | ||||||
|         'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' + |  | ||||||
|         (await utils.suppressOutput('linux')) + |  | ||||||
|         '\n'; |  | ||||||
|       break; |  | ||||||
|     case 'darwin': |     case 'darwin': | ||||||
|       script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; |       script += 'remove_extension xdebug' + pipe + '\n'; | ||||||
|       script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; |       script += 'remove_extension pcov' + pipe + '\n'; | ||||||
|       script += |  | ||||||
|         'sudo rm -rf "$ext_dir"/xdebug.so ' + |  | ||||||
|         (await utils.suppressOutput('darwin')) + |  | ||||||
|         '\n'; |  | ||||||
|       script += |  | ||||||
|         'sudo rm -rf "$ext_dir"/pcov.so ' + |  | ||||||
|         (await utils.suppressOutput('darwin')) + |  | ||||||
|         '\n'; |  | ||||||
|       break; |       break; | ||||||
|     case 'win32': |     case 'win32': | ||||||
|       script += |       script += 'Remove-Extension xdebug' + pipe + '\n'; | ||||||
|         'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; |       script += 'Remove-Extension pcov' + pipe + '\n'; | ||||||
|       script += |  | ||||||
|         'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n'; |  | ||||||
|       script += |  | ||||||
|         'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + |  | ||||||
|         (await utils.suppressOutput('win32')) + |  | ||||||
|         '\n'; |  | ||||||
|       script += |  | ||||||
|         'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' + |  | ||||||
|         (await utils.suppressOutput('win32')) + |  | ||||||
|         '\n'; |  | ||||||
|       break; |       break; | ||||||
|   } |   } | ||||||
|   script += await utils.addLog( |   script += await utils.addLog( | ||||||
| @ -198,13 +146,14 @@ export async function addCoverage( | |||||||
|   coverage_driver.toLowerCase(); |   coverage_driver.toLowerCase(); | ||||||
|   const script: string = |   const script: string = | ||||||
|     '\n' + (await utils.stepLog('Setup Coverage', os_version)); |     '\n' + (await utils.stepLog('Setup Coverage', os_version)); | ||||||
|  |   const pipe: string = await utils.suppressOutput(os_version); | ||||||
|   switch (coverage_driver) { |   switch (coverage_driver) { | ||||||
|     case 'pcov': |     case 'pcov': | ||||||
|       return script + (await addCoveragePCOV(version, os_version)); |       return script + (await addCoveragePCOV(version, os_version, pipe)); | ||||||
|     case 'xdebug': |     case 'xdebug': | ||||||
|       return script + (await addCoverageXdebug(version, os_version)); |       return script + (await addCoverageXdebug(version, os_version, pipe)); | ||||||
|     case 'none': |     case 'none': | ||||||
|       return script + (await disableCoverage(version, os_version)); |       return script + (await disableCoverage(version, os_version, pipe)); | ||||||
|     default: |     default: | ||||||
|       return ''; |       return ''; | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -6,29 +6,37 @@ import * as utils from './utils'; | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function addExtensionDarwin( | export async function addExtensionDarwin( | ||||||
|   extension_csv: string, |   extension_csv: string, | ||||||
|   version: string |   version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   const extensions: Array<string> = await utils.extensionArray(extension_csv); |   const extensions: Array<string> = await utils.extensionArray(extension_csv); | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   await utils.asyncForEach(extensions, async function(extension: string) { |   await utils.asyncForEach(extensions, async function(extension: string) { | ||||||
|     extension = extension.toLowerCase(); |     extension = extension.toLowerCase(); | ||||||
|  |     const version_extension: string = version + extension; | ||||||
|     // add script to enable extension is already installed along with php |     // add script to enable extension is already installed along with php | ||||||
|     let install_command = ''; |     let install_command = ''; | ||||||
|     switch (true) { |     switch (true) { | ||||||
|       case /5\.6xdebug/.test(version + extension): |       case /5\.6xdebug/.test(version_extension): | ||||||
|         install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1'; |         install_command = 'sudo pecl install xdebug-2.5.5' + pipe; | ||||||
|         break; |         break; | ||||||
|       case /5\.6redis/.test(version + extension): |       case /5\.6redis/.test(version_extension): | ||||||
|         install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1'; |         install_command = 'sudo pecl install redis-2.2.8' + pipe; | ||||||
|  |         break; | ||||||
|  |       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|  |         install_command = | ||||||
|  |           'sh ' + | ||||||
|  |           path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + | ||||||
|  |           ' ' + | ||||||
|  |           extension + | ||||||
|  |           pipe; | ||||||
|         break; |         break; | ||||||
|       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |  | ||||||
|         script += '\nadd_phalcon ' + extension; |  | ||||||
|         return; |  | ||||||
|       default: |       default: | ||||||
|         install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1'; |         install_command = 'sudo pecl install ' + extension + pipe; | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     script += |     script += | ||||||
| @ -47,19 +55,29 @@ export async function addExtensionDarwin( | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function addExtensionWindows( | export async function addExtensionWindows( | ||||||
|   extension_csv: string, |   extension_csv: string, | ||||||
|   version: string |   version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   const extensions: Array<string> = await utils.extensionArray(extension_csv); |   const extensions: Array<string> = await utils.extensionArray(extension_csv); | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   await utils.asyncForEach(extensions, async function(extension: string) { |   await utils.asyncForEach(extensions, async function(extension: string) { | ||||||
|     // add script to enable extension is already installed along with php |     // add script to enable extension is already installed along with php | ||||||
|  |     const version_extension: string = version + extension; | ||||||
|     switch (true) { |     switch (true) { | ||||||
|       // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 |       // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 | ||||||
|       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|         script += '\nAdd-Phalcon ' + extension; |         script += | ||||||
|  |           '\n& ' + | ||||||
|  |           path.join(__dirname, '../src/scripts/ext/phalcon.ps1') + | ||||||
|  |           ' ' + | ||||||
|  |           extension + | ||||||
|  |           ' ' + | ||||||
|  |           version + | ||||||
|  |           '\n'; | ||||||
|         break; |         break; | ||||||
|       default: |       default: | ||||||
|         script += '\nAdd-Extension ' + extension; |         script += '\nAdd-Extension ' + extension; | ||||||
| @ -74,38 +92,40 @@ export async function addExtensionWindows( | |||||||
|  * |  * | ||||||
|  * @param extension_csv |  * @param extension_csv | ||||||
|  * @param version |  * @param version | ||||||
|  |  * @param pipe | ||||||
|  */ |  */ | ||||||
| export async function addExtensionLinux( | export async function addExtensionLinux( | ||||||
|   extension_csv: string, |   extension_csv: string, | ||||||
|   version: string |   version: string, | ||||||
|  |   pipe: string | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|   const extensions: Array<string> = await utils.extensionArray(extension_csv); |   const extensions: Array<string> = await utils.extensionArray(extension_csv); | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   await utils.asyncForEach(extensions, async function(extension: string) { |   await utils.asyncForEach(extensions, async function(extension: string) { | ||||||
|     extension = extension.toLowerCase(); |     extension = extension.toLowerCase(); | ||||||
|     // add script to enable extension is already installed along with php |     // add script to enable extension is already installed along with php | ||||||
|  |     const version_extension: string = version + extension; | ||||||
|     let install_command = ''; |     let install_command = ''; | ||||||
|     switch (true) { |     switch (true) { | ||||||
|       // match 5.6gearman..7.4gearman |       // match 5.6gearman..7.4gearman | ||||||
|       case /^((5\.6)|(7\.[0-4]))gearman$/.test(version + extension): |       case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): | ||||||
|         install_command = |         install_command = | ||||||
|           'sh ' + |           'sh ' + | ||||||
|           path.join(__dirname, '../src/scripts/gearman.sh') + |           path.join(__dirname, '../src/scripts/ext/gearman.sh') + | ||||||
|           ' ' + |           ' ' + | ||||||
|           version + |           version + | ||||||
|           ' >/dev/null 2>&1'; |           pipe; | ||||||
|         break; |         break; | ||||||
|       // match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 |       // match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 | ||||||
|       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version + extension): |       case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): | ||||||
|         install_command = |         install_command = | ||||||
|           'sh ' + |           'sh ' + | ||||||
|           path.join(__dirname, '../src/scripts/phalcon.sh') + |           path.join(__dirname, '../src/scripts/ext/phalcon.sh') + | ||||||
|           ' ' + |           ' ' + | ||||||
|           extension + |           extension + | ||||||
|           ' ' + |           ' ' + | ||||||
|           version + |           version + | ||||||
|           ' >/dev/null 2>&1'; |           pipe; | ||||||
|         break; |         break; | ||||||
|       default: |       default: | ||||||
|         install_command = |         install_command = | ||||||
| @ -113,9 +133,10 @@ export async function addExtensionLinux( | |||||||
|           version + |           version + | ||||||
|           '-' + |           '-' + | ||||||
|           extension.replace('pdo_', '').replace('pdo-', '') + |           extension.replace('pdo_', '').replace('pdo-', '') + | ||||||
|           ' >/dev/null 2>&1 || sudo pecl install ' + |           pipe + | ||||||
|  |           ' || sudo pecl install ' + | ||||||
|           extension + |           extension + | ||||||
|           ' >/dev/null 2>&1'; |           pipe; | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     script += |     script += | ||||||
| @ -143,12 +164,11 @@ export async function addExtension( | |||||||
|   os_version: string, |   os_version: string, | ||||||
|   no_step = false |   no_step = false | ||||||
| ): Promise<string> { | ): Promise<string> { | ||||||
|  |   const pipe: string = await utils.suppressOutput(os_version); | ||||||
|   let script = '\n'; |   let script = '\n'; | ||||||
|   switch (no_step) { |   switch (no_step) { | ||||||
|     case true: |     case true: | ||||||
|       script += |       script += (await utils.stepLog('Setup Extensions', os_version)) + pipe; | ||||||
|         (await utils.stepLog('Setup Extensions', os_version)) + |  | ||||||
|         (await utils.suppressOutput(os_version)); |  | ||||||
|       break; |       break; | ||||||
|     case false: |     case false: | ||||||
|     default: |     default: | ||||||
| @ -158,11 +178,11 @@ export async function addExtension( | |||||||
|  |  | ||||||
|   switch (os_version) { |   switch (os_version) { | ||||||
|     case 'win32': |     case 'win32': | ||||||
|       return script + (await addExtensionWindows(extension_csv, version)); |       return script + (await addExtensionWindows(extension_csv, version, pipe)); | ||||||
|     case 'darwin': |     case 'darwin': | ||||||
|       return script + (await addExtensionDarwin(extension_csv, version)); |       return script + (await addExtensionDarwin(extension_csv, version, pipe)); | ||||||
|     case 'linux': |     case 'linux': | ||||||
|       return script + (await addExtensionLinux(extension_csv, version)); |       return script + (await addExtensionLinux(extension_csv, version, pipe)); | ||||||
|     default: |     default: | ||||||
|       return await utils.log( |       return await utils.log( | ||||||
|         'Platform ' + os_version + ' is not supported', |         'Platform ' + os_version + ' is not supported', | ||||||
|  | |||||||
| @ -65,9 +65,7 @@ export async function run(): Promise<void> { | |||||||
|       } |       } | ||||||
|       case 'win32': |       case 'win32': | ||||||
|         script_path = await build('win32.ps1', version, os_version); |         script_path = await build('win32.ps1', version, os_version); | ||||||
|         await exec( |         await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname); | ||||||
|           'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname |  | ||||||
|         ); |  | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     await matchers.addMatchers(); |     await matchers.addMatchers(); | ||||||
|  | |||||||
| @ -1,116 +0,0 @@ | |||||||
| tick="✓" |  | ||||||
| cross="✗" |  | ||||||
|  |  | ||||||
| step_log() { |  | ||||||
|   message=$1 |  | ||||||
|   printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| add_log() { |  | ||||||
|   mark=$1 |  | ||||||
|   subject=$2 |  | ||||||
|   message=$3 |  | ||||||
|   if [ "$mark" = "$tick" ]; then |  | ||||||
|     printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" |  | ||||||
|   else |  | ||||||
|     printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
| version='7.4.0' |  | ||||||
| step_log "Setup dependencies" |  | ||||||
| for package in pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl; |  | ||||||
| do |  | ||||||
|   brew install "$package" >/dev/null 2>&1 |  | ||||||
|   add_log "$tick" "$package" "Installed" |  | ||||||
| done |  | ||||||
| brew link icu4c gettext --force >/dev/null 2>&1 |  | ||||||
|  |  | ||||||
| for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype; |  | ||||||
| do |  | ||||||
|   caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]') |  | ||||||
|   { |  | ||||||
|   echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"' |  | ||||||
|   echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"' |  | ||||||
|   echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"' |  | ||||||
|   echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"' |  | ||||||
|   } >> ~/.bash_profile; |  | ||||||
| done |  | ||||||
| { |  | ||||||
| echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"' |  | ||||||
| echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"' |  | ||||||
| echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"' |  | ||||||
| echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"' |  | ||||||
| echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"' |  | ||||||
| echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"' |  | ||||||
| echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"' |  | ||||||
| echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"' |  | ||||||
| echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"' |  | ||||||
| echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"' |  | ||||||
| echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"' |  | ||||||
| echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"' |  | ||||||
| echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib |  | ||||||
| /usr/local/opt/readline/lib/libreadline.dylib |  | ||||||
| /usr/local/opt/openssl@1.1/lib/libssl.dylib |  | ||||||
| /usr/local/opt/openssl@1.1/lib/libcrypto.dylib |  | ||||||
| /usr/local/opt/icu4c/lib/libicudata.dylib |  | ||||||
| /usr/local/opt/icu4c/lib/libicui18n.dylib |  | ||||||
| /usr/local/opt/icu4c/lib/libicuio.dylib |  | ||||||
| /usr/local/opt/icu4c/lib/libicutu.dylib |  | ||||||
| /usr/local/opt/icu4c/lib/libicuuc.dylib"' |  | ||||||
| } >> ~/.bash_profile |  | ||||||
| config_file=$2/../src/configs/config.yaml |  | ||||||
|  |  | ||||||
| step_log "Setup PHPBrew" |  | ||||||
| curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1 |  | ||||||
| chmod +x ./phpbrew |  | ||||||
| sudo mv phpbrew /usr/local/bin/phpbrew |  | ||||||
| sudo mkdir -p /opt/phpbrew |  | ||||||
| sudo mkdir -p /usr/local/lib |  | ||||||
| sudo mkdir -p /usr/local/bin |  | ||||||
| sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1 |  | ||||||
| sudo chmod -R 777 /opt/phpbrew |  | ||||||
| export PHPBREW_ROOT=/opt/phpbrew |  | ||||||
| export PHPBREW_HOME=/opt/phpbrew |  | ||||||
| echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc |  | ||||||
| add_log "$tick" "PHPBrew" "Installed" |  | ||||||
|  |  | ||||||
| source ~/.bash_profile >/dev/null 2>&1 |  | ||||||
| source ~/.bashrc >/dev/null 2>&1 |  | ||||||
|  |  | ||||||
| step_log "Setup PHP and Composer" |  | ||||||
| phpbrew install -j 6 github:php/php-src@PHP-$version as php-$version +dev >/dev/null 2>&1 |  | ||||||
| phpbrew switch $version |  | ||||||
| sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/ |  | ||||||
| sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini |  | ||||||
| ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") |  | ||||||
| ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||") |  | ||||||
| pecl config-set php_ini "$ini_file" >/dev/null 2>&1 |  | ||||||
| pear config-set php_ini "$ini_file" >/dev/null 2>&1 |  | ||||||
| sudo chmod 777 "$ini_file" |  | ||||||
| brew install composer >/dev/null 2>&1 |  | ||||||
|  |  | ||||||
| add_log "$tick" "PHP" "Installed PHP$version" |  | ||||||
| add_log "$tick" "Composer" "Installed" |  | ||||||
|  |  | ||||||
| add_extension() { |  | ||||||
|   extension=$1 |  | ||||||
|   install_command=$2 |  | ||||||
|   prefix=$3 |  | ||||||
|   if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then |  | ||||||
|     echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" |  | ||||||
|   elif php -m | grep -i -q "$extension"; then |  | ||||||
|     add_log "$tick" "$extension" "Enabled" |  | ||||||
|   elif ! php -m | grep -i -q "$extension"; then |  | ||||||
|     exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) |  | ||||||
|     if [ "$exists" = "200" ]; then |  | ||||||
|       ( |  | ||||||
|         eval "$install_command" && \ |  | ||||||
|         add_log "$tick" "$extension" "Installed and enabled" |  | ||||||
|       ) || add_log "$cross" "$extension" "Could not install $extension on PHP$version" |  | ||||||
|     else |  | ||||||
|       if ! php -m | grep -i -q "$extension"; then |  | ||||||
|         add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL" |  | ||||||
|       fi |  | ||||||
|     fi |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
| @ -27,7 +27,7 @@ add_extension() { | |||||||
|     add_log "$tick" "$extension" "Enabled" |     add_log "$tick" "$extension" "Enabled" | ||||||
|   elif ! php -m | grep -i -q -w "$extension"; then |   elif ! php -m | grep -i -q -w "$extension"; then | ||||||
|     exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) |     exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) | ||||||
|     if [ "$exists" = "200" ]; then |     if [ "$exists" = "200" ] || [[ "$extension" == "phalcon"* ]]; then | ||||||
|       ( |       ( | ||||||
|         eval "$install_command" && \ |         eval "$install_command" && \ | ||||||
|         add_log "$tick" "$extension" "Installed and enabled" |         add_log "$tick" "$extension" "Installed and enabled" | ||||||
| @ -40,20 +40,11 @@ add_extension() { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| add_phalcon() { | # Function to remove extensions | ||||||
|  | remove_extension() { | ||||||
|   extension=$1 |   extension=$1 | ||||||
|   sudo pecl install psr >/dev/null 2>&1 |   sudo sed -i '' "/$1/d" "$ini_file" | ||||||
|   brew install autoconf automake libtool >/dev/null 2>&1 |   sudo rm -rf "$ext_dir"/"$1".so >/dev/null 2>&1 | ||||||
|   git clone https://github.com/phalcon/cphalcon.git >/dev/null 2>&1 |  | ||||||
|   cd cphalcon || echo "could not cd" |  | ||||||
|   git checkout "$(git branch -r | grep -E "origin/${extension: -1}\.\d\.x" | sort -r | head -n 1 | sed "s/ //g")" >/dev/null 2>&1 |  | ||||||
|   sed -i '' 's/zend_ulong/ulong/' build/php7/64bits/phalcon.zep.c |  | ||||||
|   sed -i '' 's/ulong/zend_ulong/' build/php7/64bits/phalcon.zep.c |  | ||||||
|   cd build/php7/64bits && sudo phpize >/dev/null 2>&1 |  | ||||||
|   sudo ./configure --with-php-config=/usr/local/bin/php-config --enable-phalcon >/dev/null 2>&1 |  | ||||||
|   sudo glibtoolize --force >/dev/null 2>&1 && sudo autoreconf >/dev/null 2>&1 |  | ||||||
|   sudo make -i -j2 >/dev/null 2>&1 && sudo make install >/dev/null 2>&1 |  | ||||||
|   echo "extension=phalcon.so" >>"$ini_file" && add_log "$tick" "$extension" "Installed and enabled" |  | ||||||
| } | } | ||||||
|  |  | ||||||
| # Function to setup PHP and composer | # Function to setup PHP and composer | ||||||
|  | |||||||
							
								
								
									
										27
									
								
								src/scripts/ext/phalcon.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/scripts/ext/phalcon.ps1
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | Param ( | ||||||
|  |     [Parameter(Position = 0, Mandatory = $true)] | ||||||
|  |     [ValidateNotNull()] | ||||||
|  |     [ValidateSet('phalcon3', 'phalcon4')] | ||||||
|  |     [string] | ||||||
|  |     $extension, | ||||||
|  |     [Parameter(Position = 1, Mandatory = $true)] | ||||||
|  |     [ValidateNotNull()] | ||||||
|  |     [ValidateLength(1, [int]::MaxValue)] | ||||||
|  |     [string] | ||||||
|  |     $version | ||||||
|  | ) | ||||||
|  | $tick = ([char]8730) | ||||||
|  | $domain = 'https://github.com' | ||||||
|  | $php_dir = 'C:\tools\php' | ||||||
|  | $ext_dir = $php_dir + '\ext' | ||||||
|  | $installed = Get-Php -Path $php_dir | ||||||
|  | $extension_version = $extension.substring($extension.Length - 1) | ||||||
|  | $nts = if(! $installed.ThreadSafe ) { "_nts" } else { "" } | ||||||
|  | $match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`"" | ||||||
|  | $zip_file = $match.Matches[0].Groups[1].Value | ||||||
|  | Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip >$null 2>&1 | ||||||
|  | Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force >$null 2>&1 | ||||||
|  | New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll >$null 2>&1 | ||||||
|  | Install-Phpextension psr -MinimumStability stable -Path $php_dir | ||||||
|  | Enable-PhpExtension -Extension phalcon -Path $php_dir | ||||||
|  | printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled" | ||||||
							
								
								
									
										16
									
								
								src/scripts/ext/phalcon_darwin.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/scripts/ext/phalcon_darwin.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | extension=$1 | ||||||
|  | ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") | ||||||
|  | sudo pecl install psr | ||||||
|  | brew install autoconf automake libtool | ||||||
|  | git clone https://github.com/phalcon/cphalcon.git | ||||||
|  | cd cphalcon || echo "could not cd" | ||||||
|  | git checkout "$(git branch -r | grep -E "origin/${extension: -1}\.\d\.x" | sort -r | head -n 1 | sed "s/ //g")" | ||||||
|  | sed -i '' 's/zend_ulong/ulong/' build/php7/64bits/phalcon.zep.c | ||||||
|  | sed -i '' 's/ulong/zend_ulong/' build/php7/64bits/phalcon.zep.c | ||||||
|  | cd build/php7/64bits && sudo phpize | ||||||
|  | sudo ./configure --with-php-config=/usr/local/bin/php-config --enable-phalcon | ||||||
|  | sudo glibtoolize --force | ||||||
|  | sudo autoreconf | ||||||
|  | sudo make -i -j6 | ||||||
|  | sudo make install | ||||||
|  | echo "extension=phalcon.so" >>"$ini_file" | ||||||
| @ -24,7 +24,7 @@ update_ppa() { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| # Function to setup extension | # Function to setup extensions | ||||||
| add_extension() { | add_extension() { | ||||||
|   extension=$1 |   extension=$1 | ||||||
|   install_command=$2 |   install_command=$2 | ||||||
| @ -40,6 +40,16 @@ add_extension() { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # Function to remove extensions | ||||||
|  | remove_extension() { | ||||||
|  |   extension=$1 | ||||||
|  |   if [ -e /etc/php/"$version"/mods-available/$1.ini ]; then | ||||||
|  |     sudo phpdismod -v "$version" $1 | ||||||
|  |   fi | ||||||
|  |   sudo sed -i "/$1/d" "$ini_file" | ||||||
|  |   sudo DEBIAN_FRONTEND=noninteractive apt-get remove php-$1 -y >/dev/null 2>&1 | ||||||
|  | } | ||||||
|  |  | ||||||
| # Function to setup the nightly build from master branch | # Function to setup the nightly build from master branch | ||||||
| setup_master() { | setup_master() { | ||||||
|   tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz |   tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz | ||||||
|  | |||||||
| @ -1,16 +1,16 @@ | |||||||
| param ( | param ( | ||||||
|   [Parameter(Mandatory = $true)][string]$version = "7.4", |   [Parameter(Position = 0, Mandatory = $true)] | ||||||
|   [Parameter(Mandatory=$true)][string]$dir |   [ValidateNotNull()] | ||||||
|  |   [ValidateLength(1, [int]::MaxValue)] | ||||||
|  |   [string] | ||||||
|  |   $version = '7.4', | ||||||
|  |   [Parameter(Position = 1, Mandatory = $true)] | ||||||
|  |   [ValidateNotNull()] | ||||||
|  |   [ValidateLength(1, [int]::MaxValue)] | ||||||
|  |   [string] | ||||||
|  |   $dir | ||||||
| ) | ) | ||||||
|  |  | ||||||
| $tick = ([char]8730) |  | ||||||
| $cross = ([char]10007) |  | ||||||
| $php_dir = 'C:\tools\php' |  | ||||||
| $ext_dir = $php_dir + '\ext' |  | ||||||
| $ProgressPreference = 'SilentlyContinue' |  | ||||||
| $master_version = '8.0' |  | ||||||
| $arch='x64' |  | ||||||
|  |  | ||||||
| Function Step-Log($message) { | Function Step-Log($message) { | ||||||
|   printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message |   printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message | ||||||
| } | } | ||||||
| @ -20,49 +20,6 @@ Function Add-Log($mark, $subject, $message) { | |||||||
|   printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message |   printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message | ||||||
| } | } | ||||||
|  |  | ||||||
| Step-Log "Setup PhpManager" |  | ||||||
| Install-Module -Name PhpManager -Force -Scope CurrentUser |  | ||||||
| Add-Log $tick "PhpManager" "Installed" |  | ||||||
|  |  | ||||||
| $installed = $null |  | ||||||
| if (Test-Path -LiteralPath $php_dir -PathType Container) { |  | ||||||
|   try { |  | ||||||
|     $installed = Get-Php -Path $php_dir |  | ||||||
|   } |  | ||||||
|   catch { |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| Step-Log "Setup PHP and Composer" |  | ||||||
| if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) { |  | ||||||
|   if ($version -lt '7.0') { |  | ||||||
|     Install-Module -Name VcRedist -Force |  | ||||||
|     $arch='x86' |  | ||||||
|   } |  | ||||||
|   if ($version -eq $master_version) { |  | ||||||
|     $version = 'master' |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 |  | ||||||
|   $installed = Get-Php -Path $php_dir |  | ||||||
|   $status = "Installed PHP $($installed.FullVersion)" |  | ||||||
| } |  | ||||||
| else { |  | ||||||
|   $status = "PHP $($installed.FullVersion) Found" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir |  | ||||||
| Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir |  | ||||||
| Update-PhpCAInfo -Path $php_dir -Source CurrentUser |  | ||||||
| Add-Log $tick "PHP" $status |  | ||||||
|  |  | ||||||
| Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir |  | ||||||
| Add-Log $tick "Composer" "Installed" |  | ||||||
| if ($version -eq 'master') { |  | ||||||
|   Copy-Item $dir"\..\src\ext\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" |  | ||||||
|   Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir |  | ||||||
|   Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Function Add-Extension { | Function Add-Extension { | ||||||
|   Param ( |   Param ( | ||||||
|     [Parameter(Position = 0, Mandatory = $true)] |     [Parameter(Position = 0, Mandatory = $true)] | ||||||
| @ -102,28 +59,70 @@ Function Add-Extension { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| Function Add-Phalcon { | Function Remove-Extension() { | ||||||
|   Param ( |   Param ( | ||||||
|     [Parameter(Position = 0, Mandatory = $true)] |     [Parameter(Position = 0, Mandatory = $true)] | ||||||
|     [ValidateNotNull()] |     [ValidateNotNull()] | ||||||
|     [ValidateSet('phalcon3', 'phalcon4')] |     [ValidateLength(1, [int]::MaxValue)] | ||||||
|     [string] |     [string] | ||||||
|     $extension |     $extension | ||||||
|   ) |   ) | ||||||
|   $extension_version = $extension.substring($extension.Length - 1) |   if(php -m | findstr -i $extension) { | ||||||
|   $nts = if(! $installed.ThreadSafe ) { "_nts" } else { "" } |     Disable-PhpExtension $extension $php_dir | ||||||
|   $domain = "https://github.com" |   } | ||||||
|   Install-Phpextension psr |   if (Test-Path $ext_dir\php_$extension.dll) { | ||||||
|   try |     Remove-Item $ext_dir\php_$extension.dll | ||||||
|   { |  | ||||||
|     $match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`"" |  | ||||||
|     $zip_file = $match.Matches[0].Groups[1].Value |  | ||||||
|     Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $PSScriptRoot\phalcon.zip |  | ||||||
|     Expand-Archive -Path $PSScriptRoot\phalcon.zip -DestinationPath $PSScriptRoot\phalcon -Force > $null 2>&1 |  | ||||||
|     New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $PSScriptRoot\phalcon\php_phalcon.dll > $null 2>&1 |  | ||||||
|     Enable-PhpExtension -Extension phalcon -Path $php_dir |  | ||||||
|     Add-Log $tick $extension "Installed and enabled" |  | ||||||
|   } catch { |  | ||||||
|     Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)" |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # Variables | ||||||
|  | $tick = ([char]8730) | ||||||
|  | $cross = ([char]10007) | ||||||
|  | $php_dir = 'C:\tools\php' | ||||||
|  | $ext_dir = $php_dir + '\ext' | ||||||
|  | $ProgressPreference = 'SilentlyContinue' | ||||||
|  | $master_version = '8.0' | ||||||
|  | $arch='x64' | ||||||
|  |  | ||||||
|  | Step-Log "Setup PhpManager" | ||||||
|  | Install-Module -Name PhpManager -Force -Scope CurrentUser | ||||||
|  | Add-Log $tick "PhpManager" "Installed" | ||||||
|  |  | ||||||
|  | $installed = $null | ||||||
|  | if (Test-Path -LiteralPath $php_dir -PathType Container) { | ||||||
|  |   try { | ||||||
|  |     $installed = Get-Php -Path $php_dir | ||||||
|  |   } | ||||||
|  |   catch { | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | Step-Log "Setup PHP and Composer" | ||||||
|  | if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) { | ||||||
|  |   if ($version -lt '7.0') { | ||||||
|  |     Install-Module -Name VcRedist -Force | ||||||
|  |     $arch='x86' | ||||||
|  |   } | ||||||
|  |   if ($version -eq $master_version) { | ||||||
|  |     $version = 'master' | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 | ||||||
|  |   $installed = Get-Php -Path $php_dir | ||||||
|  |   $status = "Installed PHP $($installed.FullVersion)" | ||||||
|  | } | ||||||
|  | else { | ||||||
|  |   $status = "PHP $($installed.FullVersion) Found" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir | ||||||
|  | Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir | ||||||
|  | Update-PhpCAInfo -Path $php_dir -Source CurrentUser | ||||||
|  | if ($version -eq 'master') { | ||||||
|  |   Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" | ||||||
|  |   Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir | ||||||
|  |   Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir | ||||||
|  | } | ||||||
|  | Add-Log $tick "PHP" $status | ||||||
|  |  | ||||||
|  | Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir | ||||||
|  | Add-Log $tick "Composer" "Installed" | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur