Commit 60c5779
Error when scaffold package-readme commands are not loaded (#271)
* Initial plan
* Add error check when commands are not found in cmd_dump
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Improve error message to include specific missing command
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Load command file when generating README during scaffold
When wp scaffold package creates a new package, it now explicitly loads the command file (hello-world-command.php) before calling package-readme. This ensures the command is registered in WP-CLI so it can be properly documented in the generated README.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Use launch=true to load wp-cli.yml when scaffolding README
Changed package-readme call to use launch=true instead of launch=false. This spawns a new WP-CLI process that automatically loads the wp-cli.yml file from the package directory, which in turn loads the command file. This is cleaner than hardcoding the command filename.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* partial revert, add another test
* first install, then readme
* Skip README generation when package installation is skipped
When wp scaffold package is called with --skip-install, the package is not installed, so commands are not loaded. This means package-readme would fail with the error check for missing commands. To avoid this, README generation is now skipped when --skip-install is used, unless explicitly overridden with the combination of --skip-install without --skip-readme.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Use launch=true for package-readme to ensure commands are loaded
When scaffold package installs a package and then calls package-readme, the newly installed package needs to be available. Using launch=true spawns a new WP-CLI process where the package installation is fully effective and commands are properly loaded.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Skip README generation when package installation is skipped
When --skip-install is used, the package is not installed, so commands won't be loaded. This would cause package-readme to fail with the missing commands error. Instead, we now skip README generation with a warning message explaining that commands must be loaded for complete documentation.
Users who want to skip installation but still generate a README can manually run 'wp scaffold package-readme' after ensuring commands are loaded via wp-cli.yml or package installation.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Fix path resolution for launch=true and remove warning message
- Convert relative package paths to absolute paths before passing to subprocess via launch=true
- Remove warning message when --skip-install is used (silently skip README instead)
- Fix PHPStan error with optional 'heading' offset by using null coalescing operator
This ensures package-readme can find directories when spawned in a new process, and tests don't see unexpected warning messages.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Restore original order: generate README before package installation
Reverted to the original order where README generation happens BEFORE package installation. This avoids issues with Composer's autoloader being modified by package installation and then causing problems when spawning new processes.
The flow is now:
1. Scaffold tests
2. Generate README (using wp-cli.yml to load commands)
3. Scaffold GitHub files
4. Install package (if not skipped)
This way README generation works with launch=false and --path flag, and doesn't conflict with package installation.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* fix attempt
* Lint fixes
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Update src/ScaffoldPackageCommand.php
* Update src/ScaffoldPackageCommand.php
* Add --force flag to test to overwrite existing README
The test "Does not error when commands are specified and present" calls scaffold package which generates a README, then calls scaffold package-readme again. Without --force, it prompts for user input causing the test to fail. Adding --force allows the README to be overwritten without prompting.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
* Apply suggestion from @swissspidy
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent f3df83d commit 60c5779
File tree
2 files changed
+120
-51
lines changed- features
- src
2 files changed
+120
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
298 | 297 | | |
299 | 298 | | |
300 | 299 | | |
| |||
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
321 | 331 | | |
322 | 332 | | |
323 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
| |||
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| |||
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 151 | + | |
| 152 | + | |
147 | 153 | | |
148 | | - | |
149 | | - | |
| 154 | + | |
| 155 | + | |
150 | 156 | | |
151 | 157 | | |
152 | 158 | | |
153 | | - | |
| 159 | + | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
157 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
158 | 169 | | |
159 | 170 | | |
160 | 171 | | |
| |||
327 | 338 | | |
328 | 339 | | |
329 | 340 | | |
330 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
331 | 363 | | |
332 | 364 | | |
333 | | - | |
334 | | - | |
335 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
336 | 369 | | |
337 | 370 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | 371 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
360 | 378 | | |
361 | | - | |
| 379 | + | |
362 | 380 | | |
363 | | - | |
364 | | - | |
365 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
366 | 384 | | |
367 | | - | |
368 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
369 | 391 | | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
376 | 409 | | |
377 | | - | |
378 | | - | |
379 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
380 | 439 | | |
381 | 440 | | |
382 | 441 | | |
| |||
460 | 519 | | |
461 | 520 | | |
462 | 521 | | |
463 | | - | |
| 522 | + | |
464 | 523 | | |
465 | 524 | | |
466 | 525 | | |
| |||
0 commit comments