Skip to content

Commit 6776563

Browse files
committed
Merge branch 'main' into copilot/add-non-interactive-option
2 parents 559907d + c28f0e4 commit 6776563

16 files changed

Lines changed: 406 additions & 164 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

.typos.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ extend-ignore-re = [
77

88
[files]
99
extend-exclude = [
10-
"tests/JsonManipulatorTest.php"
10+
"tests/phpunit/JsonManipulatorTest.php"
1111
]

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,70 @@ There are no optionally available fields.
125125

126126

127127

128+
### wp package get
129+
130+
Gets information about an installed WP-CLI package.
131+
132+
~~~
133+
wp package get <name> [--fields=<fields>] [--format=<format>] [--skip-update-check]
134+
~~~
135+
136+
**OPTIONS**
137+
138+
<name>
139+
Name of the package to get information for.
140+
141+
[--fields=<fields>]
142+
Limit the output to specific fields. Defaults to all fields.
143+
144+
[--format=<format>]
145+
Render output in a particular format.
146+
---
147+
default: table
148+
options:
149+
- table
150+
- csv
151+
- json
152+
- yaml
153+
---
154+
155+
[--skip-update-check]
156+
Skip checking for updates. This is faster and avoids authentication issues with GitHub or Composer repositories.
157+
158+
**AVAILABLE FIELDS**
159+
160+
These fields will be displayed by default for each package:
161+
162+
* name
163+
* authors
164+
* version
165+
* update
166+
* update_version
167+
168+
These fields are optionally available:
169+
170+
* description
171+
172+
**EXAMPLES**
173+
174+
# Get information about an installed package.
175+
$ wp package get wp-cli/scaffold-package-command
176+
+----------------+---------------------------------+
177+
| Field | Value |
178+
+----------------+---------------------------------+
179+
| name | wp-cli/scaffold-package-command |
180+
| authors | Daniel Bachhuber |
181+
| version | dev-main |
182+
| update | available |
183+
| update_version | 2.x-dev |
184+
+----------------+---------------------------------+
185+
186+
# Get the version of a package.
187+
$ wp package get wp-cli/server-command --fields=version --format=json
188+
{"version":"dev-main"}
189+
190+
191+
128192
### wp package install
129193

130194
Installs a WP-CLI package.
@@ -254,8 +318,6 @@ Updates installed WP-CLI packages to their latest version.
254318
wp package update [<package-name>...]
255319
~~~
256320

257-
**OPTIONS**
258-
259321
[<package-name>...]
260322
One or more package names to update. If not specified, all packages will be updated.
261323

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
],
1414
"require": {
1515
"ext-json": "*",
16-
"composer/composer": "^2.2.25",
17-
"wp-cli/wp-cli": "^2.12"
16+
"composer/composer": "^2.9.5",
17+
"wp-cli/wp-cli": "^2.13"
1818
},
1919
"require-dev": {
2020
"wp-cli/scaffold-command": "^1 || ^2",
@@ -38,6 +38,7 @@
3838
"commands": [
3939
"package",
4040
"package browse",
41+
"package get",
4142
"package install",
4243
"package list",
4344
"package update",

features/package.feature

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,69 @@ Feature: Manage WP-CLI packages
250250

251251
When I run `wp package uninstall runcommand/hook`
252252
Then STDERR should be empty
253+
254+
Scenario: Get information about a single package
255+
Given an empty directory
256+
257+
When I try `wp package get runcommand/hook`
258+
Then STDERR should contain:
259+
"""
260+
Error: Package 'runcommand/hook' is not installed.
261+
"""
262+
And the return code should be 1
263+
264+
When I run `wp package install runcommand/hook`
265+
Then STDERR should be empty
266+
267+
When I run `wp package get runcommand/hook`
268+
Then STDOUT should contain:
269+
"""
270+
runcommand/hook
271+
"""
272+
And STDOUT should contain:
273+
"""
274+
version
275+
"""
276+
277+
When I run `wp package get runcommand/hook --fields=name,version`
278+
Then STDOUT should contain:
279+
"""
280+
runcommand/hook
281+
"""
282+
And STDOUT should contain:
283+
"""
284+
version
285+
"""
286+
287+
When I run `wp package get runcommand/hook --fields=version --format=json`
288+
Then STDOUT should contain:
289+
"""
290+
"version"
291+
"""
292+
293+
When I run `wp package get runcommand/hook --format=json`
294+
Then STDOUT should contain:
295+
"""
296+
"name":"runcommand\/hook"
297+
"""
298+
And STDOUT should contain:
299+
"""
300+
"version"
301+
"""
302+
303+
When I run `wp package get runcommand/hook --skip-update-check --fields=name,update,update_version`
304+
Then STDOUT should contain:
305+
"""
306+
runcommand/hook
307+
"""
308+
And STDOUT should contain:
309+
"""
310+
none
311+
"""
312+
And STDOUT should not contain:
313+
"""
314+
available
315+
"""
316+
317+
When I run `wp package uninstall runcommand/hook`
318+
Then STDERR should be empty

phpcs.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<exclude-pattern>*/src/WP_CLI/JsonManipulator\.php$</exclude-pattern>
1919
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_1_10/NullIOMethodsTrait\.php$</exclude-pattern>
2020
<exclude-pattern>*/src/WP_CLI/Package/Compat/Min_Composer_2_3/NullIOMethodsTrait\.php$</exclude-pattern>
21-
<exclude-pattern>*/tests/JsonManipulatorTest\.php$</exclude-pattern>
21+
<exclude-pattern>*/tests/phpunit/JsonManipulatorTest\.php$</exclude-pattern>
2222

2323
<!-- Show progress. -->
2424
<arg value="p"/>
@@ -63,4 +63,5 @@
6363
<exclude-pattern>*/src/Package_Command\.php$</exclude-pattern>
6464
</rule>
6565

66+
<exclude-pattern>*/tests/phpstan/scan-files\.php$</exclude-pattern>
6667
</ruleset>

phpstan.neon.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
parameters:
2-
level: 1
2+
level: 5
33
paths:
44
- src
55
- package-command.php
66
scanDirectories:
77
- vendor/wp-cli/wp-cli/php
88
scanFiles:
99
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
10+
- tests/phpstan/scan-files.php
1011
treatPhpDocTypesAsCertain: false
1112
ignoreErrors:
1213
# WP_CLI_VERSION is defined in wp-cli core at runtime

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
colors="true"
1414
verbose="true">
1515
<testsuite name="wp-cli/package-command tests">
16-
<directory suffix="Test.php">tests</directory>
16+
<directory suffix="Test.php">tests/phpunit</directory>
1717
</testsuite>
1818

1919
<filter>

0 commit comments

Comments
 (0)