|
48 | 48 |
|
49 | 49 | - name: Configure git user |
50 | 50 | run: | |
51 | | - git config --global user.email "alain.schlesser@gmail.com" |
52 | | - git config --global user.name "Alain Schlesser" |
| 51 | + git config --global user.email "info@wp-cli.org" |
| 52 | + git config --global user.name "wp-make-coffee" |
53 | 53 |
|
54 | 54 | - name: Check if remote branch exists |
55 | 55 | id: check_remote_branch |
|
74 | 74 | sudo mv wp-cli-nightly.phar /usr/local/bin/wp |
75 | 75 | sudo chmod +x /usr/local/bin/wp |
76 | 76 |
|
| 77 | + - name: Check documented commands against registered commands |
| 78 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 79 | + run: | |
| 80 | + TYPE=$(jq -r '.type' composer.json) |
| 81 | + if [ "$TYPE" != "wp-cli-package" ]; then |
| 82 | + echo "Not a wp-cli-package, skipping." |
| 83 | + exit 0 |
| 84 | + fi |
| 85 | +
|
| 86 | + DOCUMENTED=$(jq -r '.extra.commands[]?' composer.json) |
| 87 | + if [ -z "$DOCUMENTED" ]; then |
| 88 | + echo "No extra.commands found in composer.json, skipping." |
| 89 | + exit 0 |
| 90 | + fi |
| 91 | +
|
| 92 | + ROOTS=$(echo "$DOCUMENTED" | awk '{print $1}' | sort -u) |
| 93 | +
|
| 94 | + if ! DUMP=$(wp cli cmd-dump); then |
| 95 | + echo "::error::Failed to dump commands" |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | +
|
| 99 | + REGISTERED=$(echo "$DUMP" | jq -r ' |
| 100 | + def walk_commands(prefix): |
| 101 | + (if prefix == "" then .name else prefix + " " + .name end) as $path | |
| 102 | + (if $path != "wp" and $path != "" then $path else empty end), |
| 103 | + (.subcommands[]? | walk_commands(if $path == "wp" or $path == "" then "" else $path end)); |
| 104 | + walk_commands("") |
| 105 | + ') |
| 106 | +
|
| 107 | + FOUND_ROOT=0 |
| 108 | + while IFS= read -r root; do |
| 109 | + if echo "$REGISTERED" | grep -qE "^${root}( |$)"; then |
| 110 | + FOUND_ROOT=1 |
| 111 | + break |
| 112 | + fi |
| 113 | + done <<< "$ROOTS" |
| 114 | +
|
| 115 | + if [ "$FOUND_ROOT" -eq 0 ]; then |
| 116 | + echo "::error::None of the documented root commands were found in the registered commands. Package commands may have failed to load." |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | +
|
| 120 | + MISSING=0 |
| 121 | + while IFS= read -r cmd; do |
| 122 | + ROOT=$(echo "$cmd" | awk '{print $1}') |
| 123 | + if echo "$ROOTS" | grep -q "^$ROOT$"; then |
| 124 | + if ! echo "$DOCUMENTED" | grep -Fqx "$cmd"; then |
| 125 | + echo "::error::Missing command in composer.json: $cmd" |
| 126 | + MISSING=1 |
| 127 | + fi |
| 128 | + fi |
| 129 | + done <<< "$REGISTERED" |
| 130 | +
|
| 131 | + if [ "$MISSING" -eq 1 ]; then |
| 132 | + echo "::error::Please update extra.commands in composer.json before regenerating README." |
| 133 | + exit 1 |
| 134 | + fi |
| 135 | +
|
| 136 | + echo "All commands correctly documented." |
| 137 | +
|
77 | 138 | - name: Regenerate README.md file |
78 | 139 | run: | |
79 | 140 | wp package install "wp-cli/scaffold-package-command:^2" |
|
0 commit comments