Skip to content

Commit 8147461

Browse files
zackkatzclaude
andcommitted
refactor: use local wp-hooks-documentor instead of global install
- Add wp-hooks-documentor as dev dependency in package.json - Remove global installation step from GitHub Actions workflow - Use npx to run the locally installed package - Update help messages and documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 59bee79 commit 8147461

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ jobs:
3636
- name: Install dependencies
3737
run: npm ci
3838

39-
- name: Install wp-hooks-documentor
40-
run: |
41-
npm install -g github:GravityKit/wp-hooks-documentor
42-
# Add npm global bin to PATH for subsequent steps
43-
echo "$(npm config get prefix)/bin" >> $GITHUB_PATH
44-
45-
- name: Verify wp-hooks-documentor installation
46-
run: wp-hooks-documentor --version || wp-hooks-documentor --help || echo "Tool installed but may not support --version flag"
47-
4839
- name: Clone GravityKit repositories
4940
run: npm run repos:clone
5041
env:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"devDependencies": {
3232
"@docusaurus/module-type-aliases": "^3.5.2",
3333
"@docusaurus/tsconfig": "^3.5.2",
34-
"@docusaurus/types": "^3.5.2"
34+
"@docusaurus/types": "^3.5.2",
35+
"wp-hooks-documentor": "github:GravityKit/wp-hooks-documentor"
3536
},
3637
"browserslist": {
3738
"production": [

scripts/generate-hooks.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* npm run hooks:generate -- --list # List available product IDs
1414
*
1515
* Prerequisites:
16-
* - wp-hooks-documentor installed globally: npm i -g github:GravityKit/wp-hooks-documentor
16+
* - Dependencies installed: npm install
1717
* - Repos cloned via: npm run repos:clone
1818
*/
1919

@@ -109,17 +109,17 @@ function loadConfig() {
109109
}
110110

111111
/**
112-
* Check if wp-hooks-documentor is available
112+
* Check if wp-hooks-documentor is available (via npx for local install)
113113
*/
114114
function checkWpHooksDocumentor() {
115-
// Try --help first as it's more universally supported than --version
116-
const result = spawnSync('wp-hooks-documentor', ['--help'], {
115+
// Try running via npx which finds locally installed packages
116+
const result = spawnSync('npx', ['wp-hooks-documentor', '--help'], {
117117
encoding: 'utf8',
118118
stdio: 'pipe',
119119
});
120120

121121
// If no error running the command, the tool is available
122-
if (!result.error) {
122+
if (!result.error && result.status === 0) {
123123
return true;
124124
}
125125
return false;
@@ -269,8 +269,8 @@ function generateHooksDocs(product, config, options) {
269269
const configPath = path.join(tempWorkDir, 'wp-hooks-doc.json');
270270
fs.writeFileSync(configPath, JSON.stringify(hooksConfig, null, 2));
271271

272-
// Run wp-hooks-documentor from the temp directory
273-
const result = spawnSync('wp-hooks-documentor', ['generate', '--skip-build'], {
272+
// Run wp-hooks-documentor via npx from the temp directory
273+
const result = spawnSync('npx', ['wp-hooks-documentor', 'generate', '--skip-build'], {
274274
cwd: tempWorkDir,
275275
stdio: 'inherit',
276276
shell: false,
@@ -281,7 +281,7 @@ function generateHooksDocs(product, config, options) {
281281
return {
282282
ok: false,
283283
id: product.id,
284-
reason: 'wp-hooks-documentor not found. Install: npm i -g github:GravityKit/wp-hooks-documentor',
284+
reason: 'wp-hooks-documentor not found. Run: npm install',
285285
};
286286
}
287287
return {
@@ -591,7 +591,7 @@ ${colors.cyan}Examples:${colors.reset}
591591
npm run hooks:generate -- --dry-run # Preview mode
592592
593593
${colors.cyan}Prerequisites:${colors.reset}
594-
1. Install wp-hooks-documentor: npm i -g github:GravityKit/wp-hooks-documentor
594+
1. Install dependencies: npm install
595595
2. Clone repositories: npm run repos:clone
596596
597597
${colors.cyan}Output:${colors.reset}
@@ -643,8 +643,8 @@ async function main() {
643643
logStep('Checking prerequisites');
644644

645645
if (!checkWpHooksDocumentor()) {
646-
logError('wp-hooks-documentor is not installed or not in PATH');
647-
logInfo('Install it with: npm i -g github:GravityKit/wp-hooks-documentor');
646+
logError('wp-hooks-documentor is not installed');
647+
logInfo('Run: npm install');
648648
return 1;
649649
}
650650
logSuccess('wp-hooks-documentor is available');

0 commit comments

Comments
 (0)