From 0c1c4b53d2127f370aafe1514002f432115acf4e Mon Sep 17 00:00:00 2001 From: Kevin Longmuir Date: Thu, 5 Mar 2026 16:30:56 -0500 Subject: [PATCH 1/3] feat: detect and prevent hd update commandin npm installation --- src/hooks/prerun/prerun.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/hooks/prerun/prerun.ts b/src/hooks/prerun/prerun.ts index f6d90b2a..b36e2b79 100644 --- a/src/hooks/prerun/prerun.ts +++ b/src/hooks/prerun/prerun.ts @@ -1,11 +1,25 @@ -import type { Hook } from '@oclif/core'; -import debug from 'debug'; +import type { Hook } from "@oclif/core"; +import debug from "debug"; +import * as path from "path"; -const hook: Hook<'prerun'> = async (opts) => { - // If JSON flag is enabled, silence debug logging - if (opts.Command.prototype.jsonEnabled()) { +const hook: Hook<"prerun"> = async function (this: Hook.Context, { Command }) { + if (Command.prototype.jsonEnabled()) { debug.disable(); } + + if (Command.id === "update") { + const isNpm = this.config.root.split(path.sep).includes("node_modules"); + + if (isNpm) { + this.warn("The update command is not supported for npm installations."); + this.log("\nTo update, run:\n"); + this.log(" npm install -g @herodevs/cli@latest\n"); + this.log("\nTo update to a specific version, run:\n"); + this.log(" npm install -g @herodevs/cli@\n"); + + process.exit(0); + } + } }; export default hook; From 6ae3c2a908449a54401948a702f5d8fc1c9c1c60 Mon Sep 17 00:00:00 2001 From: Kevin Longmuir Date: Thu, 5 Mar 2026 16:34:12 -0500 Subject: [PATCH 2/3] fix: linting --- src/hooks/prerun/prerun.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hooks/prerun/prerun.ts b/src/hooks/prerun/prerun.ts index b36e2b79..c431a5e0 100644 --- a/src/hooks/prerun/prerun.ts +++ b/src/hooks/prerun/prerun.ts @@ -1,21 +1,21 @@ -import type { Hook } from "@oclif/core"; -import debug from "debug"; -import * as path from "path"; +import * as path from 'node:path'; +import type { Hook } from '@oclif/core'; +import debug from 'debug'; -const hook: Hook<"prerun"> = async function (this: Hook.Context, { Command }) { +const hook: Hook<'prerun'> = async function (this: Hook.Context, { Command }) { if (Command.prototype.jsonEnabled()) { debug.disable(); } - if (Command.id === "update") { - const isNpm = this.config.root.split(path.sep).includes("node_modules"); + if (Command.id === 'update') { + const isNpm = this.config.root.split(path.sep).includes('node_modules'); if (isNpm) { - this.warn("The update command is not supported for npm installations."); - this.log("\nTo update, run:\n"); - this.log(" npm install -g @herodevs/cli@latest\n"); - this.log("\nTo update to a specific version, run:\n"); - this.log(" npm install -g @herodevs/cli@\n"); + this.warn('The update command is not supported for npm installations.'); + this.log('\nTo update, run:\n'); + this.log(' npm install -g @herodevs/cli@latest\n'); + this.log('\nTo update to a specific version, run:\n'); + this.log(' npm install -g @herodevs/cli@\n'); process.exit(0); } From d53de58b26f1c3db3414d77bb6d3f415e21c39a9 Mon Sep 17 00:00:00 2001 From: Kevin Longmuir Date: Thu, 5 Mar 2026 16:38:13 -0500 Subject: [PATCH 3/3] feat: update verbiage --- src/hooks/prerun/prerun.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/prerun/prerun.ts b/src/hooks/prerun/prerun.ts index c431a5e0..9c949816 100644 --- a/src/hooks/prerun/prerun.ts +++ b/src/hooks/prerun/prerun.ts @@ -12,7 +12,7 @@ const hook: Hook<'prerun'> = async function (this: Hook.Context, { Command }) { if (isNpm) { this.warn('The update command is not supported for npm installations.'); - this.log('\nTo update, run:\n'); + this.log('\nTo update to the latest, run:\n'); this.log(' npm install -g @herodevs/cli@latest\n'); this.log('\nTo update to a specific version, run:\n'); this.log(' npm install -g @herodevs/cli@\n');