-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathscaffold-package-readme.feature
354 lines (321 loc) · 10.7 KB
/
scaffold-package-readme.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
Feature: Scaffold a README.md file for an existing package
Scenario: Fails when invalid directory provided
Given an empty directory
When I try `wp scaffold package-readme bar`
Then the bar directory should not exist
And STDERR should be:
"""
Error: Directory does not exist.
"""
And the return code should be 1
Scenario: Fails when invalid package provided
Given an empty directory
And a baz/empty file:
"""
"""
When I try `wp scaffold package-readme baz`
Then the baz directory should exist
But the baz/README.md file should not exist
And STDERR should be:
"""
Error: Invalid package directory. composer.json file must be present.
"""
And the return code should be 1
Scenario: Scaffold a README.md based on the defaults
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/default-readme`
Then STDOUT should contain:
"""
Success: Created package readme.
"""
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should exist
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
"""
Installing this package requires WP-CLI v2.5 or greater. Update to the latest stable release with `wp cli update`.
"""
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
"""
[![Build Status](https://travis-ci.org/wp-cli/default-readme.svg?branch=master)
"""
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
"""
*This README.md is generated dynamically from the project's codebase
"""
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
"""
wp package install wp-cli/default-readme:dev-master
"""
When I run `wp package uninstall wp-cli/default-readme`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a README.md based with custom repository branch
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/custom-branch`
Then STDOUT should contain:
"""
Success: Created package readme.
"""
# `wp scaffold package-readme --force` returns a warning
And I try `wp scaffold package-readme {PACKAGE_PATH}/local/wp-cli/custom-branch --branch=custom --force`
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should exist
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should contain:
"""
Installing this package requires WP-CLI v2.5 or greater. Update to the latest stable release with `wp cli update`.
"""
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should contain:
"""
[![Build Status](https://travis-ci.org/wp-cli/custom-branch.svg?branch=custom)
"""
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should contain:
"""
*This README.md is generated dynamically from the project's codebase
"""
Scenario: Scaffold a README.md requiring a nightly build
Given an empty directory
When I run `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='>=0.24.0-alpha'`
Then STDOUT should contain:
"""
Success: Created package readme.
"""
And the foo/composer.json file should contain:
"""
"require": {
"wp-cli/wp-cli": ">=0.24.0-alpha"
},
"""
And the foo/README.md file should exist
And the foo/README.md file should contain:
"""
Installing this package requires WP-CLI v0.24.0-alpha or greater. Update to the latest nightly release with `wp cli update --nightly`.
"""
When I run `wp package uninstall wp-cli/foo`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a README.md requiring the latest stable release
Given an empty directory
When I run `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='*'`
Then STDOUT should contain:
"""
Success: Created package readme.
"""
And the foo/composer.json file should contain:
"""
"require": {
"wp-cli/wp-cli": "*"
},
"""
And the foo/README.md file should exist
And the foo/README.md file should contain:
"""
Installing this package requires WP-CLI's latest stable release. Update to the latest stable release with `wp cli update`.
"""
When I run `wp package uninstall wp-cli/foo`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a readme with custom shields
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"license": "GPL-2.0",
"authors": [],
"minimum-stability": "dev",
"autoload": {
"files": [ "command.php" ]
},
"require": {
"wp-cli/wp-cli": "^2.5"
},
"require-dev": {
"wp-cli/wp-cli-tests": "^3.0.11"
},
"extra": {
"readme": {
"shields": [
"shield 1",
"shield 2",
"shield 3"
]
}
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
shield 1 shield 2 shield 3
"""
Scenario: Scaffold a readme with a remote support body
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"extra": {
"readme": {
"contributing": {
"body": "https://gist.githubusercontent.com/danielbachhuber/bb652b1b744cea541705ee9c13605dad/raw/195c17ebb8cf25e947a9df6e02de1e96a084c287/support.md"
}
}
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
## Contributing
Support isn't free!
"""
Scenario: Scaffold a readme with a pre, post and body for the section
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"extra": {
"readme": {
"contributing": {
"pre": "[Visit Site](https://example.com)",
"body": "https://gist.githubusercontent.com/danielbachhuber/bb652b1b744cea541705ee9c13605dad/raw/195c17ebb8cf25e947a9df6e02de1e96a084c287/support.md",
"post": "I am after body."
}
}
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
## Contributing
[Visit Site](https://example.com)
Support isn't free!
I am after body.
"""
Scenario: Scaffold a readme with custom sections
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"extra": {
"readme": {
"sections": [
"Installing",
"Donating"
],
"donating": {
"body": "Give me money!"
}
}
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
Quick links: [Installing](#installing) | [Donating](#donating)
"""
And the foo/README.md file should contain:
"""
## Donating
Give me money!
"""
Scenario: Scaffold a readme without the powered by
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"extra": {
"readme": {
"show_powered_by": false
}
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should not contain:
"""
*This README.md is generated dynamically from the project's codebase
"""
@broken
Scenario: Error when commands are specified but not present
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"description": "Quickly identify what's slow with WordPress.",
"homepage": "https://runcommand.io/wp/profile/",
"extra": {
"commands": [
"profile"
]
}
}
"""
When I try `wp scaffold package-readme foo`
Then STDERR should be:
"""
Error: Missing one or more commands defined in composer.json -> extra -> commands.
"""
And the return code should be 1
Scenario: README for a bundled command
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"authors": [],
"minimum-stability": "dev",
"autoload": {
"files": [ "command.php" ]
},
"require": {
},
"require-dev": {
"wp-cli/wp-cli": "*",
"wp-cli/wp-cli-tests": "^3.0.11"
},
"extra": {
"bundled": true
}
}
"""
When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
runcommand/profile
==================
"""
And the foo/README.md file should contain:
"""
This package is included with WP-CLI itself
"""