MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getInstallationInfo

Function getInstallationInfo

packages/cli/src/utils/installationInfo.ts:33–196  ·  view source on GitHub ↗
(
  projectRoot: string,
  isAutoUpdateDisabled: boolean,
)

Source from the content-addressed store, hash-verified

31}
32
33export async function getInstallationInfo(
34 projectRoot: string,
35 isAutoUpdateDisabled: boolean,
36): Promise<InstallationInfo> {
37 const cliPath = process.argv[1];
38 if (!cliPath) {
39 return { packageManager: PackageManager.UNKNOWN, isGlobal: false };
40 }
41
42 try {
43 // Normalize path separators to forward slashes for consistent matching.
44 const realPath = fs.realpathSync(cliPath).replace(/\\/g, '/');
45 const normalizedProjectRoot = projectRoot?.replace(/\\/g, '/');
46 const isGit = isGitRepository(process.cwd());
47
48 // Check for local git clone first
49 if (
50 isGit &&
51 normalizedProjectRoot &&
52 realPath.startsWith(normalizedProjectRoot) &&
53 !realPath.includes('/node_modules/')
54 ) {
55 return {
56 packageManager: PackageManager.UNKNOWN, // Not managed by a package manager in this sense
57 isGlobal: false,
58 updateMessage:
59 'Running from a local git clone. Please update with "git pull".',
60 };
61 }
62
63 // Check for npx/pnpx
64 if (realPath.includes('/.npm/_npx') || realPath.includes('/npm/_npx')) {
65 return {
66 packageManager: PackageManager.NPX,
67 isGlobal: false,
68 updateMessage: 'Running via npx, update not applicable.',
69 };
70 }
71 if (realPath.includes('/.pnpm/_pnpx')) {
72 return {
73 packageManager: PackageManager.PNPX,
74 isGlobal: false,
75 updateMessage: 'Running via pnpx, update not applicable.',
76 };
77 }
78
79 // Check for Homebrew - try both old and new package names
80 if (process.platform === 'darwin') {
81 try {
82 // Check for anus package first
83 childProcess.execSync('brew list -1 | grep -q "^anus$"', {
84 stdio: 'ignore',
85 });
86 return {
87 packageManager: PackageManager.HOMEBREW,
88 isGlobal: true,
89 updateMessage:
90 'Installed via Homebrew. Please update with "brew upgrade".',

Callers 2

handleAutoUpdateFunction · 0.85

Calls 2

isGitRepositoryFunction · 0.85
getPackageJsonFunction · 0.85

Tested by

no test coverage detected