mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
WP-CLI tool support added
This commit is contained in:
parent
03fd0b8719
commit
d95ca49e8d
@ -276,6 +276,15 @@ describe('Tools tests', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking getWpCliUri', async () => {
|
||||||
|
expect(await tools.getWpCliUrl('latest')).toBe(
|
||||||
|
'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getWpCliUrl('2.4.0')).toBe(
|
||||||
|
'https://github.com/wp-cli/wp-cli/releases/download/v2.4.0/wp-cli-2.4.0.phar'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('checking addArchive', async () => {
|
it('checking addArchive', async () => {
|
||||||
let script: string = await tools.addArchive(
|
let script: string = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
@ -358,7 +367,7 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking addTools on linux', async () => {
|
it('checking addTools on linux', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'cs2pr, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
|
'cs2pr, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony, wp-cli',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
@ -383,6 +392,9 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
|
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
|
||||||
);
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
||||||
|
);
|
||||||
expect(script).toContain('add_pecl');
|
expect(script).toContain('add_pecl');
|
||||||
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
|
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
|
||||||
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
|
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
|
||||||
@ -392,7 +404,7 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
it('checking addTools on darwin', async () => {
|
it('checking addTools on darwin', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3',
|
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli',
|
||||||
'7.4',
|
'7.4',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
@ -430,12 +442,15 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
|
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
|
||||||
);
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
||||||
|
);
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
});
|
});
|
||||||
it('checking addTools on windows', async () => {
|
it('checking addTools on windows', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'codeception, cs2pr, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exit',
|
'codeception, cs2pr, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, wp-cli, does_not_exit',
|
||||||
'7.4',
|
'7.4',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
@ -461,6 +476,9 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
|
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
|
||||||
);
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
||||||
|
);
|
||||||
expect(script).toContain('phpize is not a windows tool');
|
expect(script).toContain('phpize is not a windows tool');
|
||||||
expect(script).toContain('php-config is not a windows tool');
|
expect(script).toContain('php-config is not a windows tool');
|
||||||
expect(script).toContain('Tool does_not_exit is not supported');
|
expect(script).toContain('Tool does_not_exit is not supported');
|
||||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@ -1863,6 +1863,26 @@ function getSymfonyUri(version, os_version) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getSymfonyUri = getSymfonyUri;
|
exports.getSymfonyUri = getSymfonyUri;
|
||||||
|
/**
|
||||||
|
* Function to get the WP-CLI url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
function getWpCliUrl(version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar';
|
||||||
|
default:
|
||||||
|
return ('https://github.com/wp-cli/wp-cli/releases/download/v' +
|
||||||
|
version +
|
||||||
|
'/wp-cli-' +
|
||||||
|
version +
|
||||||
|
'.phar');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getWpCliUrl = getWpCliUrl;
|
||||||
/**
|
/**
|
||||||
* Function to add/move composer in the tools list
|
* Function to add/move composer in the tools list
|
||||||
*
|
*
|
||||||
@ -2048,6 +2068,10 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
url = github + 'symfony/cli/' + uri;
|
url = github + 'symfony/cli/' + uri;
|
||||||
script += yield addArchive('symfony', version, url, os_version);
|
script += yield addArchive('symfony', version, url, os_version);
|
||||||
break;
|
break;
|
||||||
|
case 'wp-cli':
|
||||||
|
url = yield getWpCliUrl(version);
|
||||||
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
|
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
|
||||||
break;
|
break;
|
||||||
|
@ -109,6 +109,8 @@ add_tool() {
|
|||||||
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
||||||
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
||||||
sudo chmod a+x "$tool_path"
|
sudo chmod a+x "$tool_path"
|
||||||
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
|
sudo cp "$tool_path" /usr/local/bin/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
|
@ -165,6 +165,8 @@ add_tool() {
|
|||||||
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
||||||
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
||||||
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
||||||
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
|
sudo cp "$tool_path" /usr/local/bin/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
|
24
src/tools.ts
24
src/tools.ts
@ -308,6 +308,26 @@ export async function getSymfonyUri(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the WP-CLI url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function getWpCliUrl(version: string): Promise<string> {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar';
|
||||||
|
default:
|
||||||
|
return (
|
||||||
|
'https://github.com/wp-cli/wp-cli/releases/download/v' +
|
||||||
|
version +
|
||||||
|
'/wp-cli-' +
|
||||||
|
version +
|
||||||
|
'.phar'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to add/move composer in the tools list
|
* Function to add/move composer in the tools list
|
||||||
*
|
*
|
||||||
@ -523,6 +543,10 @@ export async function addTools(
|
|||||||
url = github + 'symfony/cli/' + uri;
|
url = github + 'symfony/cli/' + uri;
|
||||||
script += await addArchive('symfony', version, url, os_version);
|
script += await addArchive('symfony', version, url, os_version);
|
||||||
break;
|
break;
|
||||||
|
case 'wp-cli':
|
||||||
|
url = await getWpCliUrl(version);
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
'$cross',
|
'$cross',
|
||||||
|
Loading…
Reference in New Issue
Block a user