-
Notifications
You must be signed in to change notification settings - Fork 1
β‘ Replace synchronous I/O in Async Context in setup command #19
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -75,12 +75,10 @@ program | |||||
| await JulesClient.validateKey(apiKey); | ||||||
|
|
||||||
| const configDir = path.join(os.homedir(), '.config', 'jules'); | ||||||
| if (!fs.existsSync(configDir)) { | ||||||
| fs.mkdirSync(configDir, { recursive: true }); | ||||||
| } | ||||||
| await fs.promises.mkdir(configDir, { recursive: true }); | ||||||
|
|
||||||
| const configPath = path.join(configDir, 'config.json'); | ||||||
| fs.writeFileSync(configPath, JSON.stringify({ apiKey }, null, 2)); | ||||||
| await fs.promises.writeFile(configPath, JSON.stringify({ apiKey }, null, 2)); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration file contains a sensitive API key and should have restricted permissions. Setting
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've also updated the configuration file writing to use |
||||||
|
|
||||||
| console.log('Setup complete. API key saved to ~/.config/jules/config.json'); | ||||||
| } catch (error: any) { | ||||||
|
|
||||||
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.
To protect the sensitive API key, the directory permissions should be restricted. Setting
mode: 0o700ensures that only the owner can access this directory, which is a crucial security measure for storing credentials.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.
@jules
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've replaced the synchronous
fs.mkdirSynccall withawait fs.promises.mkdir(configDir, { recursive: true }). This is an asynchronous operation that doesn't block the event loop and it's idempotent, meaning it won't throw an error if the directory already exists, effectively replacing the previousfs.existsSynccheck as well.