Skip to content

Commit f139c1e

Browse files
authored
Merge pull request #6037 from wp-cli/try/6004-update-logic
Check PHP version requirement in update check
2 parents 90c9a75 + 9e1f660 commit f139c1e

File tree

4 files changed

+318
-28
lines changed

4 files changed

+318
-28
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"wp-cli/entity-command": "^1.2 || ^2",
2222
"wp-cli/extension-command": "^1.1 || ^2",
2323
"wp-cli/package-command": "^1 || ^2",
24-
"wp-cli/wp-cli-tests": "^4.0.1"
24+
"wp-cli/wp-cli-tests": "^4.3.7"
2525
},
2626
"suggest": {
2727
"ext-readline": "Include for a better --prompt implementation",

features/cli-check-update.feature

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
Feature: Check for updates
2+
3+
Scenario: Ignores updates with a higher PHP version requirement
4+
Given that HTTP requests to https://api.github.com/repos/wp-cli/wp-cli/releases?per_page=100 will respond with:
5+
"""
6+
HTTP/1.1 200
7+
Content-Type: application/json
8+
9+
[
10+
{
11+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978",
12+
"assets_url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/assets",
13+
"upload_url": "https://uploads.github.com/repos/wp-cli/wp-cli/releases/169243978/assets{?name,label}",
14+
"html_url": "https://github.com/wp-cli/wp-cli/releases/tag/v999.9.9",
15+
"id": 169243978,
16+
"node_id": "RE_kwDOACQFs84KFnVK",
17+
"tag_name": "v999.9.9",
18+
"target_commitish": "main",
19+
"name": "Version 999.9.9",
20+
"draft": false,
21+
"prerelease": false,
22+
"created_at": "2024-08-08T03:04:55Z",
23+
"published_at": "2024-08-08T03:51:13Z",
24+
"assets": [
25+
{
26+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
27+
"id": 184590231,
28+
"node_id": "RA_kwDOACQFs84LAJ-X",
29+
"name": "wp-cli-999.9.9.phar",
30+
"label": null,
31+
"content_type": "application/octet-stream",
32+
"state": "uploaded",
33+
"size": 7048108,
34+
"download_count": 722639,
35+
"created_at": "2024-08-08T03:51:05Z",
36+
"updated_at": "2024-08-08T03:51:08Z",
37+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.phar"
38+
},
39+
{
40+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
41+
"id": 184590231,
42+
"node_id": "RA_kwDOACQFs84LAJ-X",
43+
"name": "wp-cli-999.9.9.phar",
44+
"label": null,
45+
"content_type": "application/octet-stream",
46+
"state": "uploaded",
47+
"size": 7048108,
48+
"download_count": 722639,
49+
"created_at": "2024-08-08T03:51:05Z",
50+
"updated_at": "2024-08-08T03:51:08Z",
51+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.manifest.json"
52+
}
53+
],
54+
"tarball_url": "https://api.github.com/repos/wp-cli/wp-cli/tarball/v999.9.9",
55+
"zipball_url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/v999.9.9",
56+
"body": "- Allow manually dispatching tests workflow [[#5965](https://github.com/wp-cli/wp-cli/pull/5965)]\r\n- Add fish shell completion [[#5954](https://github.com/wp-cli/wp-cli/pull/5954)]\r\n- Add defaults and accepted values for runcommand() options in doc [[#5953](https://github.com/wp-cli/wp-cli/pull/5953)]\r\n- Address warnings with filenames ending in fullstop on Windows [[#5951](https://github.com/wp-cli/wp-cli/pull/5951)]\r\n- Fix unit tests [[#5950](https://github.com/wp-cli/wp-cli/pull/5950)]\r\n- Update copyright year in license [[#5942](https://github.com/wp-cli/wp-cli/pull/5942)]\r\n- Fix breaking multi-line CSV values on reading [[#5939](https://github.com/wp-cli/wp-cli/pull/5939)]\r\n- Fix broken Gutenberg test [[#5938](https://github.com/wp-cli/wp-cli/pull/5938)]\r\n- Update docker runner to resolve docker path using `/usr/bin/env` [[#5936](https://github.com/wp-cli/wp-cli/pull/5936)]\r\n- Fix `inherit` path in nested directory [[#5930](https://github.com/wp-cli/wp-cli/pull/5930)]\r\n- Minor docblock improvements [[#5929](https://github.com/wp-cli/wp-cli/pull/5929)]\r\n- Add Signup fetcher [[#5926](https://github.com/wp-cli/wp-cli/pull/5926)]\r\n- Ensure the alias has the leading `@` symbol when added [[#5924](https://github.com/wp-cli/wp-cli/pull/5924)]\r\n- Include any non default hook information in CompositeCommand [[#5921](https://github.com/wp-cli/wp-cli/pull/5921)]\r\n- Correct completion case when ends in = [[#5913](https://github.com/wp-cli/wp-cli/pull/5913)]\r\n- Docs: Fixes for inline comments [[#5912](https://github.com/wp-cli/wp-cli/pull/5912)]\r\n- Update Inline comments [[#5910](https://github.com/wp-cli/wp-cli/pull/5910)]\r\n- Add a real-world example for `wp cli has-command` [[#5908](https://github.com/wp-cli/wp-cli/pull/5908)]\r\n- Fix typos [[#5901](https://github.com/wp-cli/wp-cli/pull/5901)]\r\n- Avoid PHP deprecation notices in PHP 8.1.x [[#5899](https://github.com/wp-cli/wp-cli/pull/5899)]",
57+
"reactions": {
58+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/reactions",
59+
"total_count": 9,
60+
"+1": 4,
61+
"-1": 0,
62+
"laugh": 0,
63+
"hooray": 1,
64+
"confused": 0,
65+
"heart": 0,
66+
"rocket": 4,
67+
"eyes": 0
68+
}
69+
},
70+
{
71+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978",
72+
"assets_url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/assets",
73+
"upload_url": "https://uploads.github.com/repos/wp-cli/wp-cli/releases/169243978/assets{?name,label}",
74+
"html_url": "https://github.com/wp-cli/wp-cli/releases/tag/v777.7.7",
75+
"id": 169243978,
76+
"node_id": "RE_kwDOACQFs84KFnVK",
77+
"tag_name": "v777.7.7",
78+
"target_commitish": "main",
79+
"name": "Version 777.7.7",
80+
"draft": false,
81+
"prerelease": false,
82+
"created_at": "2024-08-08T03:04:55Z",
83+
"published_at": "2024-08-08T03:51:13Z",
84+
"assets": [
85+
{
86+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
87+
"id": 184590231,
88+
"node_id": "RA_kwDOACQFs84LAJ-X",
89+
"name": "wp-cli-777.7.7.phar",
90+
"label": null,
91+
"content_type": "application/octet-stream",
92+
"state": "uploaded",
93+
"size": 7048108,
94+
"download_count": 722639,
95+
"created_at": "2024-08-08T03:51:05Z",
96+
"updated_at": "2024-08-08T03:51:08Z",
97+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.phar"
98+
},
99+
{
100+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
101+
"id": 184590231,
102+
"node_id": "RA_kwDOACQFs84LAJ-X",
103+
"name": "wp-cli-777.7.7.phar",
104+
"label": null,
105+
"content_type": "application/octet-stream",
106+
"state": "uploaded",
107+
"size": 7048108,
108+
"download_count": 722639,
109+
"created_at": "2024-08-08T03:51:05Z",
110+
"updated_at": "2024-08-08T03:51:08Z",
111+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.manifest.json"
112+
}
113+
],
114+
"tarball_url": "https://api.github.com/repos/wp-cli/wp-cli/tarball/v777.7.7",
115+
"zipball_url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/v777.7.7",
116+
"body": "- Allow manually dispatching tests workflow [[#5965](https://github.com/wp-cli/wp-cli/pull/5965)]\r\n- Add fish shell completion [[#5954](https://github.com/wp-cli/wp-cli/pull/5954)]\r\n- Add defaults and accepted values for runcommand() options in doc [[#5953](https://github.com/wp-cli/wp-cli/pull/5953)]\r\n- Address warnings with filenames ending in fullstop on Windows [[#5951](https://github.com/wp-cli/wp-cli/pull/5951)]\r\n- Fix unit tests [[#5950](https://github.com/wp-cli/wp-cli/pull/5950)]\r\n- Update copyright year in license [[#5942](https://github.com/wp-cli/wp-cli/pull/5942)]\r\n- Fix breaking multi-line CSV values on reading [[#5939](https://github.com/wp-cli/wp-cli/pull/5939)]\r\n- Fix broken Gutenberg test [[#5938](https://github.com/wp-cli/wp-cli/pull/5938)]\r\n- Update docker runner to resolve docker path using `/usr/bin/env` [[#5936](https://github.com/wp-cli/wp-cli/pull/5936)]\r\n- Fix `inherit` path in nested directory [[#5930](https://github.com/wp-cli/wp-cli/pull/5930)]\r\n- Minor docblock improvements [[#5929](https://github.com/wp-cli/wp-cli/pull/5929)]\r\n- Add Signup fetcher [[#5926](https://github.com/wp-cli/wp-cli/pull/5926)]\r\n- Ensure the alias has the leading `@` symbol when added [[#5924](https://github.com/wp-cli/wp-cli/pull/5924)]\r\n- Include any non default hook information in CompositeCommand [[#5921](https://github.com/wp-cli/wp-cli/pull/5921)]\r\n- Correct completion case when ends in = [[#5913](https://github.com/wp-cli/wp-cli/pull/5913)]\r\n- Docs: Fixes for inline comments [[#5912](https://github.com/wp-cli/wp-cli/pull/5912)]\r\n- Update Inline comments [[#5910](https://github.com/wp-cli/wp-cli/pull/5910)]\r\n- Add a real-world example for `wp cli has-command` [[#5908](https://github.com/wp-cli/wp-cli/pull/5908)]\r\n- Fix typos [[#5901](https://github.com/wp-cli/wp-cli/pull/5901)]\r\n- Avoid PHP deprecation notices in PHP 8.1.x [[#5899](https://github.com/wp-cli/wp-cli/pull/5899)]",
117+
"reactions": {
118+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/reactions",
119+
"total_count": 9,
120+
"+1": 4,
121+
"-1": 0,
122+
"laugh": 0,
123+
"hooray": 1,
124+
"confused": 0,
125+
"heart": 0,
126+
"rocket": 4,
127+
"eyes": 0
128+
}
129+
}
130+
]
131+
"""
132+
133+
And that HTTP requests to wp-cli-999.9.9.manifest.json will respond with:
134+
"""
135+
HTTP/1.1 200
136+
Content-Type: application/json
137+
138+
{
139+
"requires_php": "123.4.5"
140+
}
141+
"""
142+
143+
And that HTTP requests to wp-cli-777.7.7.manifest.json will respond with:
144+
"""
145+
HTTP/1.1 200
146+
Content-Type: application/json
147+
148+
{
149+
"requires_php": "5.6.0"
150+
}
151+
"""
152+
153+
When I run `wp cli check-update`
154+
Then STDOUT should be a table containing rows:
155+
| version | update_type | package_url | status | requires_php |
156+
| 999.9.9 | major | https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.phar | unavailable | 123.4.5 |
157+
| 777.7.7 | major | https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.phar | available | 5.6.0 |

manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"requires_php": "5.6.0"
3+
}

0 commit comments

Comments
 (0)