pionxzh / wakaru

🔪📦 Javascript decompiler for modern frontend
https://wakaru.vercel.app/
MIT License
313 stars 18 forks source link

add easy-to-use CLI features #72

Open StringKe opened 11 months ago

StringKe commented 11 months ago
  1. Automatically catch exceptions and create URLs where issues can be submitted
  2. Provide some non-privacy related data collection for refining parsing rules
  3. cli support i18n and configuring memory
pionxzh commented 11 months ago

For 2, you mean like collecting what rules users tend to enable?

For 3, I don't have any plan to do i18n on CLI tbh 🤔

StringKe commented 11 months ago

For 2, you mean like collecting what rules users tend to enable?

yes, or collect some minimal chunks of code that have not been hit by any rule for updating new rules.

It can also be used, for example, for packaged code that is not known but can be identified as a jsx (known component).

pionxzh commented 11 months ago

For the memory part, I would like to implement a size checker before running. If the file size exceeds a limit, the tool will ask you to confirm, with a hint that guides users on how to configure the memory limit to prevent OOM.

0xdevalias commented 11 months ago

or collect some minimal chunks of code that have not been hit by any rule for updating new rules

This part sounds like it could be rather hard to automate; it seems like the kind of thing that would be better suited to being done manually; but perhaps a special issue template could be added to help guide users with the right info to provide for it:

pionxzh commented 11 months ago

I think the simple solution is to add a contribution guide and an issue template like what @0xdevalias said. Collecting code snippets anonymously seems impossible.

0xdevalias commented 11 months ago

There are a few basic CLI type patterns that could potentially be done to 'guide' the user towards creating an issue; and prefilling some of the information as well. I haven't deeply explored it, but here is a quick high level ChatGPT query/response for it:

Details ## My Prompt > For a CLI written in node, I want to be able to make it easy for end users to open relevant GitHub issues for bugs/etc. > > - How could I go about implementing this? > - Are there any standard patterns for how other tools do it? > - Are there any libraries that can help me? ## ChatGPT's Response > To implement a feature in your Node.js CLI application that allows end users to easily open relevant GitHub issues for bugs or other concerns, you can follow these steps: > > ### Steps to Implement the Feature > > 1. **Capture Error Information**: When an error or issue occurs in your application, capture relevant details such as the error message, stack trace, and any specific application context. > > 2. **Prompt the User**: When an error is detected, prompt the user with an option to report the issue. You can use libraries like `inquirer.js` for interactive CLI prompts. > > 3. **Format Issue Details**: Format the captured error information into a readable and useful format for the issue report. > > 4. **Generate GitHub Issue URL**: Create a URL to open a new issue on your GitHub repository, prefilling details using query parameters. The URL format is: > ``` > https://github.com/[username]/[repository]/issues/new?title=[issue_title]&body=[issue_body] > ``` > > 5. **Open the URL in User’s Browser**: Use a Node.js library like `open` to open the generated URL in the user's default web browser. > > ### Example Code Snippet > > ```javascript > const open = require('open'); > const inquirer = require('inquirer'); > > function reportIssue(error) { > const issueTitle = encodeURIComponent("Bug Report: " + error.message); > const issueBody = encodeURIComponent("Error Details:\n" + error.stack + "\n\nContext:\n..."); > > const githubUrl = `https://github.com/yourusername/yourrepo/issues/new?title=${issueTitle}&body=${issueBody}`; > > inquirer.prompt([{ > type: 'confirm', > name: 'openIssue', > message: 'Would you like to report this issue to GitHub?', > }]).then(answers => { > if (answers.openIssue) { > open(githubUrl); > } > }); > } > > // Example usage > try { > // Your code logic > } catch (error) { > reportIssue(error); > } > ``` > > ### Standard Patterns and Libraries > > - **Libraries**: `inquirer.js` for CLI interactions, `open` to open URLs in a browser. > - **Standard Pattern**: Many CLI tools prompt the user to report the issue with pre-filled details on encountering an error. The approach of formatting the error and opening a GitHub issue URL is fairly standard. > > ### Additional Considerations > > - **User Consent**: Always get user consent before opening the browser, as it can be intrusive. > - **Sensitive Information**: Be cautious about including sensitive information in automated error reports. > - **Customization**: Allow users to add additional comments or details before submitting the issue. > > This approach aligns with standard practices and uses popular Node.js libraries for implementation. Remember to replace `yourusername` and `yourrepo` with your actual GitHub username and repository name in the URL. >
pionxzh commented 9 months ago

Let me finalize what we can do in this issue: