-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: cli tool to setup the sdk and circle console #58
base: main
Are you sure you want to change the base?
Conversation
bef2667
to
b67bf5d
Compare
9f04775
to
cb3cab0
Compare
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.
Just a couple of questions, but otherwise looks great - great documentation!
return false; | ||
} catch (error) { | ||
console.error('Error checking existing configuration:', error); | ||
return false; |
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.
Shouldn't this throw and propagate the 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.
This is simply a check to verify if the file exists and contains the expected environment variables. It throws an error if the file doesn’t exist, which is fine for detecting the file’s presence. While reviewing this, I discovered another issue: the environment variable name was incorrect (CIRCLE_APP_ID instead of CIRCLE_API_KEY). I’ve fixed that.
In summary, this error doesn’t need to be propagated since its sole purpose is to check for the file’s existence.
packages/circle-sdk-setup/src/cli.ts
Outdated
async initializeSdk(apiKey: string, secret: string): Promise<CircleSdk> { | ||
console.log('Initializing Circle SDK...'); | ||
return new CircleSdk(apiKey, secret); | ||
} |
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 this need to be async and return a Promise
? Is this method even really needed?
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.
for context, that was my late night experiment with using AI agent to build something useful and I thought simple CLI tool is a good task for that 😄 . So I wasn't very strict with the results. I'm cleaning this up now, thanks for the review!
packages/circle-sdk-setup/src/cli.ts
Outdated
let envContent = ''; | ||
if (fs.existsSync(this.options.envPath)) { | ||
envContent = fs.readFileSync(this.options.envPath, 'utf-8'); | ||
// Remove existing Circle config if 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.
Is that what we'd want to do in this situation? I guess this goes along with the comment I left regarding the checkExistingConfig
function.
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.
We should avoid removing anything from local user settings. Instead, notify the user that the configuration failed and suggest checking the Circle console. I spent a significant amount of time investigating whether Circle configuration can be removed, but found no option to do so. The only available actions are rotating keys or resetting the cipher, both of which are not possible via the API.
@@ -2,8 +2,15 @@ | |||
"name": "web3-circle-sdk", | |||
"version": "0.1.0", | |||
"description": "Web3 Circle SDK", | |||
"type": "module", |
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.
@avkos can we have the sdk build and export setup for esm and cjs done asap (in main branch) as that impacts consuming it by other packages? I'm using only esm and I think we should aim to make ESM the default and commonjs as a fallback for legacy use. what do you think? cc @Muhammad-Altabba @jdevcs
08d4c76
to
e1eec90
Compare
@danforbes Alright, I think this PR is ready. I’ve tested detecting the .env file and writing a new one. The only step I couldn’t test is registerCiphertext and storing the recovery file (with the recovery content), as my Circle account is already set up. |
e1eec90
to
2c9f694
Compare
2c9f694
to
2d765db
Compare
If somebody hasn't configured their circle console yet, please try this cli tool with