mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Fix wp-cli support
This commit is contained in:
parent
d95ca49e8d
commit
68c827cfcf
@ -278,10 +278,10 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking getWpCliUri', async () => {
|
it('checking getWpCliUri', async () => {
|
||||||
expect(await tools.getWpCliUrl('latest')).toBe(
|
expect(await tools.getWpCliUrl('latest')).toBe(
|
||||||
'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'
|
||||||
);
|
);
|
||||||
expect(await tools.getWpCliUrl('2.4.0')).toBe(
|
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'
|
'wp-cli/wp-cli/releases/download/v2.4.0/wp-cli-2.4.0.phar'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ describe('Tools tests', () => {
|
|||||||
'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(
|
expect(script).toContain(
|
||||||
'add_tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true 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/');
|
||||||
@ -443,7 +443,7 @@ describe('Tools tests', () => {
|
|||||||
'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(
|
expect(script).toContain(
|
||||||
'add_tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true 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"');
|
||||||
@ -477,7 +477,7 @@ describe('Tools tests', () => {
|
|||||||
'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(
|
expect(script).toContain(
|
||||||
'Add-Tool https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar wp-cli'
|
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true 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');
|
||||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1872,13 +1872,9 @@ function getWpCliUrl(version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar';
|
return 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
|
||||||
default:
|
default:
|
||||||
return ('https://github.com/wp-cli/wp-cli/releases/download/v' +
|
return yield getUri('wp-cli', '-' + version + '.phar', version, 'wp-cli/wp-cli/releases', 'v', 'download');
|
||||||
version +
|
|
||||||
'/wp-cli-' +
|
|
||||||
version +
|
|
||||||
'.phar');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2069,7 +2065,7 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
script += yield addArchive('symfony', version, url, os_version);
|
script += yield addArchive('symfony', version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'wp-cli':
|
case 'wp-cli':
|
||||||
url = yield getWpCliUrl(version);
|
url = github + (yield getWpCliUrl(version));
|
||||||
script += yield addArchive(tool, version, url, os_version);
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -93,7 +93,8 @@ add_tool() {
|
|||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
tool_path=/usr/local/bin/"$tool"
|
tool_path_dir=/usr/local/bin
|
||||||
|
tool_path="$tool_path_dir/$tool"
|
||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
@ -110,7 +111,7 @@ add_tool() {
|
|||||||
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
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
sudo cp "$tool_path" /usr/local/bin/wp
|
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
|
@ -150,7 +150,8 @@ update_extension() {
|
|||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
tool_path=/usr/local/bin/"$tool"
|
tool_path_dir=/usr/local/bin
|
||||||
|
tool_path="$tool_path_dir/$tool"
|
||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
@ -166,7 +167,7 @@ add_tool() {
|
|||||||
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
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
sudo cp "$tool_path" /usr/local/bin/wp
|
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
|
@ -124,6 +124,8 @@ Function Add-Tool() {
|
|||||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||||
} elseif($tool -eq "composer") {
|
} elseif($tool -eq "composer") {
|
||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
|
} elseif($tool -eq "wp-cli") {
|
||||||
|
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
||||||
}
|
}
|
||||||
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||||
Add-Log $tick $tool "Added"
|
Add-Log $tick $tool "Added"
|
||||||
|
17
src/tools.ts
17
src/tools.ts
@ -316,14 +316,15 @@ export async function getSymfonyUri(
|
|||||||
export async function getWpCliUrl(version: string): Promise<string> {
|
export async function getWpCliUrl(version: string): Promise<string> {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar';
|
return 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
|
||||||
default:
|
default:
|
||||||
return (
|
return await getUri(
|
||||||
'https://github.com/wp-cli/wp-cli/releases/download/v' +
|
'wp-cli',
|
||||||
version +
|
'-' + version + '.phar',
|
||||||
'/wp-cli-' +
|
version,
|
||||||
version +
|
'wp-cli/wp-cli/releases',
|
||||||
'.phar'
|
'v',
|
||||||
|
'download'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,7 +545,7 @@ export async function addTools(
|
|||||||
script += await addArchive('symfony', version, url, os_version);
|
script += await addArchive('symfony', version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'wp-cli':
|
case 'wp-cli':
|
||||||
url = await getWpCliUrl(version);
|
url = github + (await getWpCliUrl(version));
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user