mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 07:19:52 +00:00
refactor(cli): address review findings in telemetry code
- Extract shared isDevMode() to utils/env.ts (was duplicated in dev.ts and client.ts) - Use ui/colors.ts instead of raw ANSI escapes in telemetry notice (respects NO_COLOR) - Derive known commands from subCommands object instead of maintaining duplicate set - Skip telemetry on --help/--version and unknown commands - Gate incrementCommandCount() behind shouldTrack() (no disk writes in CI) - Add flushSync() for process.exit() paths (beforeExit doesn't fire on explicit exit) - Remove dead trackBrowserInstall(success) param (failure path never called it) - Remove redundant isEnabled/anonymousId caching in client.ts (config.ts cache suffices) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,7 @@ async function runEnsure(): Promise<void> {
|
||||
});
|
||||
|
||||
downloadSpinner.stop(c.success("Download complete"));
|
||||
trackBrowserInstall(true);
|
||||
trackBrowserInstall();
|
||||
|
||||
console.log();
|
||||
console.log(` ${c.dim("Source:")} ${c.bold(result.source)}`);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { resolve, dirname, basename, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as clack from "@clack/prompts";
|
||||
import { c } from "../ui/colors.js";
|
||||
import { isDevMode } from "../utils/env.js";
|
||||
|
||||
/**
|
||||
* Check if a port is available by trying to listen on it briefly.
|
||||
@@ -31,19 +32,6 @@ async function findAvailablePort(startPort: number): Promise<number> {
|
||||
return startPort; // fallback — let the server fail with a clear error
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether we're running from source (monorepo dev) or from the built bundle.
|
||||
* When running via tsx from source, the file is at cli/src/commands/dev.ts.
|
||||
* When running from the built bundle, the file is at cli/dist/cli.js.
|
||||
* We check the filename portion of the URL to avoid false positives from
|
||||
* directory names (e.g., /Users/someone/src/...).
|
||||
*/
|
||||
function isDevMode(): boolean {
|
||||
const url = new URL(import.meta.url);
|
||||
// In dev mode the file is a .ts source file; in production it's a bundled .js
|
||||
return url.pathname.endsWith(".ts");
|
||||
}
|
||||
|
||||
export default defineCommand({
|
||||
meta: { name: "dev", description: "Start the studio for local development" },
|
||||
args: {
|
||||
|
||||
Reference in New Issue
Block a user