-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vm beta #69
base: main
Are you sure you want to change the base?
Add vm beta #69
Conversation
Changed Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR introduces VM management functionality to the CLI with feature flag support, including commands for listing VMs, managing startup scripts, and viewing logs.
- Added
src/lib/vm.ts
with three core commands:vm list
,vm script
, andvm logs
for VM management - Implemented feature flag caching system in
src/helpers/feature-flags.ts
with 24-hour expiration - Added
isFeatureEnabled
function insrc/lib/posthog.ts
to gate VM features behind 'vms' flag - Potential architecture concern: Mixed usage of Node.js and Deno APIs in
feature-flags.ts
could cause compatibility issues - Security enhancement: All VM commands properly handle unauthorized access with session token expiration checks
5 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
if (!exchangeAccountId) { | ||
const response = await fetch(await getApiUrl("me"), { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${config.auth_token}`, | ||
}, | ||
}); | ||
|
||
const data = await response.json(); | ||
if (data.id) { | ||
exchangeAccountId = data.id; | ||
saveConfig({ ...config, account_id: data.id }); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: no error handling for failed API requests - could silently fail if network error or invalid response
if (!exchangeAccountId) { | |
const response = await fetch(await getApiUrl("me"), { | |
method: "GET", | |
headers: { | |
"Content-Type": "application/json", | |
Authorization: `Bearer ${config.auth_token}`, | |
}, | |
}); | |
const data = await response.json(); | |
if (data.id) { | |
exchangeAccountId = data.id; | |
saveConfig({ ...config, account_id: data.id }); | |
} | |
} | |
if (!exchangeAccountId) { | |
try { | |
const response = await fetch(await getApiUrl("me"), { | |
method: "GET", | |
headers: { | |
"Content-Type": "application/json", | |
Authorization: `Bearer ${config.auth_token}`, | |
}, | |
}); | |
if (!response.ok) { | |
throw new Error(`API request failed with status ${response.status}`); | |
} | |
const data = await response.json(); | |
if (data.id) { | |
exchangeAccountId = data.id; | |
saveConfig({ ...config, account_id: data.id }); | |
} | |
} catch (error) { | |
console.error('Failed to fetch account ID:', error); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one might be a real concern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some code quality nits. In a perfect world I would prefer these get fixed, but we do not live in a perfect world, so send it if you need to
} catch (error) { | ||
console.error("boba error saving feature flags:", error); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnPhamous @Flaque one of you should rebase this branch on main, I believe this change is outdated.
const response = await fetch(await getApiUrl("me"), { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${config.auth_token}`, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the OpenAPI client fail to properly generate types here? all good if so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const client = await apiClient();
this one
let script: string; | ||
try { | ||
script = readFileSync(options.file, "utf-8"); | ||
} catch (err) { | ||
logAndQuit(`Failed to read script file: ${err.message}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact JS used to have a with
keyword
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
Not supported in strict JS/TS though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT DO THIS.
for (const log of data.data) { | ||
console.log(`[${log.timestamp}] ${log.message}`); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have this be a streaming window like fly log
that you can quit out of, but prob out of scope for this PR
declare namespace Deno { | ||
function writeTextFile(path: string, data: string): Promise<void>; | ||
function readTextFile(path: string): Promise<string>; | ||
function mkdir( | ||
path: string, | ||
options?: { recursive?: boolean } | ||
): Promise<void>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to declare a type file like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try adding deno.ns
to the tsconfig in the relevant fields
https://docs.deno.com/runtime/reference/ts_config_migration/#using-the-%22lib%22-property
{
"compilerOptions": {
"lib": ["deno.ns"]
}
}
Use the Deno target with the smallest possible scope
Also @JohnPhamous I think you probably reformatted some files using |
No description provided.