Skip to content

Update office-converter extension #19471

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

XInTheDark
Copy link
Contributor

@XInTheDark XInTheDark commented May 28, 2025

Description

Add office-converter extension: Convert office files to various formats using LibreOffice.

LibreOffice must be installed for the commands to function.

Screencast

no screenshots available; all commands are no-view

Previous PR: #17573

Checklist

- .gitignore
- Almost ready for publish
- Initial commit
- Fix double execution with StrictMode
- Fix convert failing if file exists
@raycastbot
Copy link
Collaborator

Congratulations on your new Raycast extension! 🚀

You can expect an initial review within five business days.

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

@raycastbot raycastbot added the new extension Label for PRs with new extensions label May 28, 2025
@XInTheDark
Copy link
Contributor Author

hi @pernielsentikaer! following up from your review in the previous PR:

I can't reproduce the issue - the dropdown is shown if no Finder windows are open, or if no file is selected.

CleanShot 2025-05-28 at 21 43 57@2x

Could you try again with the latest build?

@XInTheDark XInTheDark marked this pull request as ready for review May 29, 2025 16:49
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

New Office Converter extension that enables converting office files to various formats using LibreOffice, featuring both general format conversion and PDF-specific conversion commands.

  • Missing metadata folder with screenshots for view commands - please add as per Raycast Documentation
  • Error handling in convert-file.ts should use showFailureToast from @raycast/utils instead of manual error handling
  • launchCommand in convert-file.ts and convert-to-pdf.ts should be wrapped in try-catch blocks
  • Remove console.log statements from convert-file.ts before production
  • Add subtitle to commands in package.json with the service name (Office Converter)

💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

14 file(s) reviewed, 18 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +33 to +35
} catch (e) {
console.error(e);
failed++;
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 showFailureToast(error, { title: "Could not convert file" }) from @raycast/utils for better error handling

Suggested change
} catch (e) {
console.error(e);
failed++;
} catch (e) {
showFailureToast(e, { title: "Could not convert file" });
failed++;

Comment on lines +36 to +39
} catch (e) {
console.error(e);
failed++;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Use showFailureToast from @raycast/utils instead of manual error handling. See https://developers.raycast.com/utilities/functions/showfailuretoast

Suggested change
} catch (e) {
console.error(e);
failed++;
}
} catch (e) {
await showFailureToast(e, { title: "Failed to convert file" });
failed++;
}

Comment on lines +60 to +61
if (selectedFiles && selectedFiles.length > 0 && format) {
await handleConversion({ inputPaths: selectedFiles, format: format || "" });
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential bug: format || "" will allow empty string formats through validation

Suggested change
if (selectedFiles && selectedFiles.length > 0 && format) {
await handleConversion({ inputPaths: selectedFiles, format: format || "" });
if (selectedFiles && selectedFiles.length > 0 && format) {
await handleConversion({ inputPaths: selectedFiles, format });

"commands": [
{
"name": "convert-file",
"title": "Convert Files",
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 subtitle with the service name (Office Converter) since there are multiple commands

return;
}

console.log("Input files: ", files);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove console.log before publishing

Comment on lines +3 to +4
export default function convertToPDF() {
return convertFiles({ arguments: { format: "pdf" } });
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: launchCommand should be wrapped in try-catch for proper error handling

Suggested change
export default function convertToPDF() {
return convertFiles({ arguments: { format: "pdf" } });
export default async function convertToPDF() {
try {
return await convertFiles({ arguments: { format: "pdf" } });
} catch (error) {
showFailureToast(error, { title: "Failed to convert to PDF" });
}
}

Comment on lines +18 to +19
inputPaths: values.inputPaths as string[],
format: values.format as string,
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Type assertions should be avoided. Use runtime validation to ensure values are of correct type

Comment on lines +26 to +31
<Form.FilePicker
id="inputPaths"
title="Select Files"
allowMultipleSelection
defaultValue={props.arguments.inputFiles || []}
/>
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 allowedTypes prop to FilePicker to restrict to supported office file formats

allowMultipleSelection
defaultValue={props.arguments.inputFiles || []}
/>
<Form.TextField id="format" title="Output Format" defaultValue={format} />
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Add placeholder text to help users understand expected format (e.g. 'pdf, docx, etc')

Comment on lines +15 to +21
title="Convert"
onSubmit={async (values) => {
await props.onSubmit({
inputPaths: values.inputPaths as string[],
format: values.format as string,
});
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Missing validation before submission - format field could be empty

@pernielsentikaer pernielsentikaer self-assigned this May 30, 2025
Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

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

Is there a reason why you have duplicates of the command files (ts, tsx)? Can you remove the incorrect ones here?

CleanShot 2025-05-30 at 09 56 23@2x

Request a new review when you are ready. Feel free to contact me here or at Slack if you have any questions.

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.

3 participants