Skip to content

Commit 63632fd

Browse files
committed
Merge branch 'main' into copilot/fix-default-branch-install
2 parents be5aaa4 + d662e02 commit 63632fd

19 files changed

Lines changed: 950 additions & 192 deletions

.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: 119 additions & 26 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.
@@ -184,6 +248,30 @@ for future authorization requests.
184248

185249

186250

251+
### wp package is-installed
252+
253+
Checks if a given package is installed.
254+
255+
~~~
256+
wp package is-installed <name>
257+
~~~
258+
259+
Returns exit code 0 when installed, 1 when uninstalled.
260+
261+
**OPTIONS**
262+
263+
<name>
264+
The package to check.
265+
266+
**EXAMPLES**
267+
268+
# Check whether "foo/bar" is installed; exit status 0 if installed, otherwise 1
269+
$ wp package is-installed foo/bar
270+
$ echo $?
271+
1
272+
273+
274+
187275
### wp package list
188276

189277
Lists installed WP-CLI packages.
@@ -246,6 +334,37 @@ These fields are optionally available:
246334

247335

248336

337+
### wp package path
338+
339+
Gets the path to an installed WP-CLI package, or the package directory.
340+
341+
~~~
342+
wp package path [<name>]
343+
~~~
344+
345+
If you want to contribute to a package, this is a great way to jump to it.
346+
347+
**OPTIONS**
348+
349+
[<name>]
350+
Name of the package to get the directory for.
351+
352+
**EXAMPLES**
353+
354+
# Get package path.
355+
$ wp package path
356+
/home/person/.wp-cli/packages/
357+
358+
# Get path to an installed package.
359+
$ wp package path wp-cli/server-command
360+
/home/person/.wp-cli/packages/vendor/wp-cli/server-command
361+
362+
# Change directory to package path.
363+
$ cd $(wp package path) && pwd
364+
/home/vagrant/.wp-cli/packages
365+
366+
367+
249368
### wp package update
250369

251370
Updates installed WP-CLI packages to their latest version.
@@ -254,8 +373,6 @@ Updates installed WP-CLI packages to their latest version.
254373
wp package update [<package-name>...]
255374
~~~
256375

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

@@ -314,30 +431,6 @@ wp package uninstall <name> [--insecure]
314431
Removing package directories and regenerating autoloader...
315432
Success: Uninstalled package.
316433

317-
318-
319-
### wp package is-installed
320-
321-
Checks if a given package is installed.
322-
323-
~~~
324-
wp package is-installed <name>
325-
~~~
326-
327-
Returns exit code 0 when installed, 1 when uninstalled.
328-
329-
**OPTIONS**
330-
331-
<name>
332-
The package to check.
333-
334-
**EXAMPLES**
335-
336-
# Check whether "foo/bar" is installed; exit status 0 if installed, otherwise 1
337-
$ wp package is-installed foo/bar
338-
$ echo $?
339-
1
340-
341434
## Installing
342435

343436
This package is included with WP-CLI itself, no additional installation necessary.

composer.json

Lines changed: 6 additions & 4 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,11 +38,13 @@
3838
"commands": [
3939
"package",
4040
"package browse",
41+
"package get",
4142
"package install",
43+
"package is-installed",
4244
"package list",
45+
"package path",
4346
"package update",
44-
"package uninstall",
45-
"package is-installed"
47+
"package uninstall"
4648
]
4749
},
4850
"autoload": {

features/package-auth.feature

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Feature: Composer authentication for various git providers
2+
3+
Scenario: GitHub OAuth token is set in COMPOSER_AUTH
4+
Given an empty directory
5+
When I run `GITHUB_TOKEN=ghp_test123456789 wp package path`
6+
Then STDOUT should not be empty
7+
And the return code should be 0
8+
9+
Scenario: GitLab OAuth token is set in COMPOSER_AUTH
10+
Given an empty directory
11+
When I run `GITLAB_OAUTH_TOKEN=glpat_test123456789 wp package path`
12+
Then STDOUT should not be empty
13+
And the return code should be 0
14+
15+
Scenario: GitLab personal access token is set in COMPOSER_AUTH
16+
Given an empty directory
17+
When I run `GITLAB_TOKEN=glpat_test123456789 wp package path`
18+
Then STDOUT should not be empty
19+
And the return code should be 0
20+
21+
Scenario: Bitbucket OAuth consumer is set in COMPOSER_AUTH
22+
Given an empty directory
23+
When I run `BITBUCKET_CONSUMER_KEY=test_key BITBUCKET_CONSUMER_SECRET=test_secret wp package path`
24+
Then STDOUT should not be empty
25+
And the return code should be 0
26+
27+
Scenario: HTTP Basic Auth is set in COMPOSER_AUTH
28+
Given an empty directory
29+
When I run `HTTP_BASIC_AUTH='{"repo.example.com":{"username":"user","password":"pass"}}' wp package path`
30+
Then STDOUT should not be empty
31+
And the return code should be 0
32+
33+
Scenario: Multiple auth providers can be used together
34+
Given an empty directory
35+
When I run `GITHUB_TOKEN=ghp_test123 GITLAB_TOKEN=glpat_test456 wp package path`
36+
Then STDOUT should not be empty
37+
And the return code should be 0
38+
39+
Scenario: Invalid HTTP_BASIC_AUTH JSON is ignored
40+
Given an empty directory
41+
When I run `HTTP_BASIC_AUTH='not-valid-json' wp package path`
42+
Then STDOUT should not be empty
43+
And the return code should be 0

features/package-install.feature

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,50 @@ Feature: Install WP-CLI packages
4545
"""
4646
"url": "http://wp-cli.org/package-index/"
4747
"""
48+
And the composer.json file should contain:
49+
"""
50+
"canonical": false
51+
"""
4852

4953
When I run `WP_CLI_PACKAGES_DIR=. wp package is-installed wp-cli/restful`
5054
Then the return code should be 0
5155
And STDERR should be empty
5256
And STDOUT should be empty
5357

58+
Scenario: Install a package updates the package index repository to be non-canonical
59+
Given an empty directory
60+
And a composer.json file:
61+
"""
62+
{
63+
"repositories": {
64+
"test" : {
65+
"type": "path",
66+
"url": "./dummy-package/"
67+
},
68+
"wp-cli": {
69+
"type": "composer",
70+
"url": "https://wp-cli.org/package-index/"
71+
}
72+
}
73+
}
74+
"""
75+
And a dummy-package/composer.json file:
76+
"""
77+
{
78+
"name": "wp-cli/restful",
79+
"description": "This is a dummy package we will install instead of actually installing the real package. This prevents the test from hanging indefinitely for some reason, even though it passes. The 'name' must match a real package as it is checked against the package index."
80+
}
81+
"""
82+
When I run `WP_CLI_PACKAGES_DIR=. wp package install wp-cli/restful`
83+
Then STDOUT should contain:
84+
"""
85+
Success: Package installed
86+
"""
87+
And the composer.json file should contain:
88+
"""
89+
"canonical": false
90+
"""
91+
5492
@require-php-5.6
5593
Scenario: Install a package with 'wp-cli/wp-cli' as a dependency
5694
Given a WP install
@@ -236,6 +274,30 @@ Feature: Install WP-CLI packages
236274
wp-cli/google-sitemap-generator-cli
237275
"""
238276

277+
@github-api
278+
Scenario: Install a package from a Git URL with a version suffix
279+
Given an empty directory
280+
281+
When I run `wp package install https://github.com/wp-cli/google-sitemap-generator-cli.git:dev-main`
282+
Then STDOUT should contain:
283+
"""
284+
Installing package wp-cli/google-sitemap-generator-cli (dev-main)
285+
"""
286+
And STDOUT should contain:
287+
"""
288+
Registering https://github.com/wp-cli/google-sitemap-generator-cli.git as a VCS repository...
289+
"""
290+
And STDOUT should contain:
291+
"""
292+
Success: Package installed.
293+
"""
294+
295+
When I run `wp package uninstall wp-cli/google-sitemap-generator-cli`
296+
Then STDOUT should contain:
297+
"""
298+
Success: Uninstalled package.
299+
"""
300+
239301
@github-api
240302
Scenario: Install a package from a Git URL with mixed-case git name but lowercase composer.json name
241303
Given an empty directory

0 commit comments

Comments
 (0)