Skip to content
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 config-converter extension #17923

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

erfgypO
Copy link

@erfgypO erfgypO commented Mar 17, 2025

Description

Screencast

Checklist

@raycastbot raycastbot added the new extension Label for PRs with new extensions label Mar 17, 2025
@raycastbot
Copy link
Collaborator

Congratulations on your new Raycast extension! 🚀

Due to our current reduced availability, the initial review may take up to 10-15 business days

Once the PR is approved and merged, the extension will be available on our Store.

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 adds a new Config Converter extension that converts JSON objects to shell environment variables, with options for regular and base64-encoded output.

  • README.md is too minimal and needs significant expansion to include usage instructions, examples, and proper documentation of the functionality
  • Consider wrapping launchCommand in try-catch blocks in both json2environment.ts and json2environmentB64.ts for better error handling
  • Could simplify error handling in processJson.ts by using showFailureToast from @raycast/utils instead of manual showToast with failure style
  • Add subtitle to both commands in package.json with "Config Converter" to match extension title
  • Consider adding screenshots in a metadata folder since this is a new extension, showing example input/output

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

12 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -0,0 +1 @@
# Config Converter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: README needs more content: description of what the extension does, installation/usage instructions, and examples of JSON to environment variable conversion. See https://developers.raycast.com/basics/prepare-an-extension-for-store#readme

"commands": [
{
"name": "json2environment",
"title": "Json2Environment",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding a subtitle to distinguish between the two commands, e.g. 'Convert JSON to environment variables'

},
{
"name": "json2environmentB64",
"title": "Json2Environment - Base64",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding a subtitle to distinguish between the two commands, e.g. 'Convert JSON to base64-encoded environment variables'

Comment on lines +3 to +4
export default async function main() {
await processJson(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider wrapping processJson call in try/catch for better error handling

Suggested change
export default async function main() {
await processJson(false);
export default async function main() {
try {
await processJson(false);
} catch (error) {
console.error(error);
throw error;
}

export function descendJsonObject(obj: any, path?: string) {
const keyValuePairs: KeyValuePair[] = [];

if (typeof obj !== "object" && path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This condition will return undefined if path is not provided for primitive values. Should be if (typeof obj !== 'object') {

return keyValuePairs;
}

for (const key in obj) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: for...in loop on objects should check hasOwnProperty to avoid prototype chain properties

Suggested change
for (const key in obj) {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {

export interface KeyValuePair {
key: string;
//eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more specific type than any to better type-check JSON values, e.g. string | number | boolean | null | object | Array<unknown>

erfgypO and others added 2 commits March 17, 2025 10:01
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@erfgypO erfgypO marked this pull request as draft March 17, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new extension Label for PRs with new extensions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants