Skip to content

Commit 4e8b611

Browse files
committed
fix: fixed codify edit desktop installation. Fixed apply message
1 parent 1527a48 commit 4e8b611

5 files changed

Lines changed: 108 additions & 29 deletions

File tree

package-lock.json

Lines changed: 10 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dependencies": {
77
"@codifycli/ink-form": "0.0.12",
88
"@codifycli/schemas": "1.1.0-beta8",
9-
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
9+
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
1010
"@mischnic/json-sourcemap": "^0.1.1",
1111
"@oclif/core": "^4.0.8",
1212
"@oclif/plugin-autocomplete": "^3.2.24",
@@ -145,7 +145,7 @@
145145
"deploy": "npm run pkg && npm run notarize && npm run upload",
146146
"prepublishOnly": "npm run build"
147147
},
148-
"version": "1.1.0",
148+
"version": "1.1.1-beta.6",
149149
"bugs": "https://github.com/codifycli/codify/issues",
150150
"keywords": [
151151
"oclif",

src/ui/components/widgets/ApplyComplete.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { ResourceOperation } from '@codifycli/schemas';
22
import { Box, Text } from 'ink';
3+
import path from 'node:path';
34
import React from 'react';
45

56
import { ApplyResult } from '../../../entities/apply-result.js';
67
import { ResourcePlan } from '../../../entities/plan.js';
78
import { applyEntryInkColor, applyEntryLabel } from '../../apply-result-formatter.js';
89
import { prettyFormatResourcePlan } from '../../plan-pretty-printer.js';
10+
import { ShellUtils } from '../../../utils/shell.js';
911

1012
export function ApplyComplete({ result }: { result: ApplyResult }) {
1113
const isPartial = result.isPartialFailure();
@@ -93,7 +95,7 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
9395

9496
{!isPartial && (
9597
<Box marginTop={1}>
96-
<Text dimColor>Open a new terminal or source &apos;.zshrc&apos; for the new changes to be reflected</Text>
98+
<Text dimColor>Open a new terminal or source &apos;{path.basename(ShellUtils.getPrimaryShellRc())}&apos; for the new changes to be reflected</Text>
9799
</Box>
98100
)}
99101

src/utils/desktop-installer.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { spawn } from './spawn.js';
99

1010
const DESKTOP_APP_PATHS = {
1111
darwin: '/Applications/Codify.app',
12-
linux: '/usr/bin/codify',
12+
linux: '/usr/bin/codify-desktop',
1313
};
1414

1515
const DOWNLOAD_URLS: Record<string, Record<string, string>> = {
@@ -86,7 +86,7 @@ export async function installDesktopApp(reporter: Reporter, url: string, platfor
8686
}
8787
} else {
8888
const password = await reporter.promptSudo('codify-installer', {
89-
command: platform === 'linux_deb' ? `dpkg -i ${tmpFile}` : `rpm -i ${tmpFile}`,
89+
command: platform === 'linux_deb' ? `apt install -y ${tmpFile}` : `rpm -i ${tmpFile}`,
9090
options: { requiresRoot: true },
9191
});
9292

@@ -97,12 +97,22 @@ export async function installDesktopApp(reporter: Reporter, url: string, platfor
9797

9898
try {
9999
console.log('Installing Codify desktop app...');
100-
const cmd = platform === 'linux_deb' ? `dpkg -i ${tmpFile}` : `rpm -i ${tmpFile}`;
101-
await spawn(cmd, { requiresRoot: true }, undefined, password);
100+
const cmd = platform === 'linux_deb' ? `apt install -y ${tmpFile}` : `rpm -i ${tmpFile}`;
101+
try {
102+
await spawn(cmd, { requiresRoot: true }, undefined, password);
103+
} catch (e) {
104+
if (platform === 'linux_deb') {
105+
console.log('Fixing broken dependencies...');
106+
await spawn('apt-get install -f -y', { requiresRoot: true }, undefined, password);
107+
await spawn(cmd, { requiresRoot: true }, undefined, password);
108+
} else {
109+
throw e;
110+
}
111+
}
102112
} finally {
103113
await fs.unlink(tmpFile).catch(() => {});
104114
}
105115
}
106116

107117
console.log('Codify desktop app installed successfully.');
108-
}
118+
}

src/utils/shell.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { LinuxDistro } from '@codifycli/schemas';
22
import cp from 'node:child_process';
33
import * as fs from 'node:fs/promises';
44
import util from 'node:util';
5+
import os from 'node:os';
6+
import path from 'node:path';
57

68
const exec = util.promisify(cp.exec);
79

@@ -50,6 +52,82 @@ export const ShellUtils = {
5052
return process.env.SHELL!;
5153
},
5254

55+
getPrimaryShellRc(): string {
56+
return this.getShellRcFiles()[0];
57+
},
58+
59+
getShellRcFiles(): string[] {
60+
const shell = process.env.SHELL || os.userInfo().shell || '';
61+
const homeDir = os.homedir();
62+
63+
if (shell.endsWith('bash')) {
64+
// Linux typically uses .bashrc, macOS uses .bash_profile
65+
if (ShellUtils.isLinux()) {
66+
return [
67+
path.join(homeDir, '.bashrc'),
68+
path.join(homeDir, '.bash_profile'),
69+
path.join(homeDir, '.profile'),
70+
];
71+
}
72+
73+
return [
74+
path.join(homeDir, '.bash_profile'),
75+
path.join(homeDir, '.bashrc'),
76+
path.join(homeDir, '.profile'),
77+
];
78+
}
79+
80+
if (shell.endsWith('zsh')) {
81+
return [
82+
path.join(homeDir, '.zshrc'),
83+
path.join(homeDir, '.zprofile'),
84+
path.join(homeDir, '.zshenv'),
85+
];
86+
}
87+
88+
if (shell.endsWith('sh')) {
89+
return [
90+
path.join(homeDir, '.profile'),
91+
]
92+
}
93+
94+
if (shell.endsWith('ksh')) {
95+
return [
96+
path.join(homeDir, '.profile'),
97+
path.join(homeDir, '.kshrc'),
98+
]
99+
}
100+
101+
if (shell.endsWith('csh')) {
102+
return [
103+
path.join(homeDir, '.cshrc'),
104+
path.join(homeDir, '.login'),
105+
path.join(homeDir, '.logout'),
106+
]
107+
}
108+
109+
if (shell.endsWith('fish')) {
110+
return [
111+
path.join(homeDir, '.config/fish/config.fish'),
112+
]
113+
}
114+
115+
// Default to bash-style files
116+
return [
117+
path.join(homeDir, '.bashrc'),
118+
path.join(homeDir, '.bash_profile'),
119+
path.join(homeDir, '.profile'),
120+
];
121+
},
122+
123+
isMacOS(): boolean {
124+
return os.platform() === 'darwin';
125+
},
126+
127+
isLinux(): boolean {
128+
return os.platform() === 'linux';
129+
},
130+
53131
async getLinuxDistro(): Promise<LinuxDistro | undefined> {
54132
for (const candidate of ['/etc/os-release', '/usr/lib/os-release']) {
55133
let osRelease: string;

0 commit comments

Comments
 (0)