Skip to content

backup#11

Merged
sang765 merged 7 commits intobackupfrom
master
Aug 8, 2025
Merged

backup#11
sang765 merged 7 commits intobackupfrom
master

Conversation

@sang765
Copy link
Copy Markdown
Contributor

@sang765 sang765 commented Aug 8, 2025

No description provided.

sang765 added 7 commits August 8, 2025 12:57
This commit replaces the `tsickert/discord-webhook` GitHub Action with a custom TypeScript script (`send-webhook.ts`) for sending notifications.

The primary motivation for this change is to enable file attachments in Discord notifications, a feature not easily supported by the previous action.

This new implementation allows for:
- Attaching build artifacts (extensions, userscripts) directly to the success notification.
- Attaching the full, raw job log to failure notifications for more comprehensive debugging.

The `get-failed-step-log.ts` script has also been updated to save the full log to a file to facilitate this.
- Add @types/axios@0.9.36
- Update axios to v1.11.0
- Update form-data to v4.0.4
- Update @types/form-data to v2.5.2
This introduces a new step in the build workflow to automatically run the `add-csp.ts` script. This script injects the required Content Security Policy directives for the `fakeProfile` user plugin, ensuring it functions correctly in the built extension.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch master

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@deepsource-io
Copy link
Copy Markdown
Contributor

deepsource-io Bot commented Aug 8, 2025

Here's the code health analysis summary for commits 917b55c..38a01c3. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Shell LogoShell✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@sang765 sang765 merged commit 217d81f into backup Aug 8, 2025
11 of 12 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @sang765, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I am introducing new functionality to enhance the build process and communication for the fP extension. This includes adding a robust Discord webhook utility for sending messages and attaching files, particularly useful for reporting build failures. I've also updated the project's dependencies to support these new features and improved the README with more informative badges. Additionally, a new script is included to automate the modification of Content Security Policy (CSP) rules for specific Discord projects, enabling integration with a "fakeProfile" API.

Highlights

  • Discord Webhook Integration: Added new TypeScript files (api/discord-webhook.ts and src/send-webhook.ts) to facilitate sending rich messages and file attachments to Discord webhooks, enabling automated notifications for build processes.
  • Automated CSP Rule Addition: Introduced src/add-csp.ts, a script designed to programmatically add a Content Security Policy rule for "fakeprofile.is-always.online" to relevant project files, supporting integration with the fakeProfile API.
  • Enhanced Build Log Retrieval: Modified src/get-failed-step-log.ts to save the full job log to a file, which can then be attached to Discord webhook notifications, providing more comprehensive failure details.
  • Dependency Updates: Updated package.json and package-lock.json to include axios and form-data for HTTP requests and multipart form data handling, along with their respective type definitions.
  • README.md Enhancements: Refreshed the README.md with new, more descriptive badges for technologies used (TypeScript, YAML, NodeJS), GitHub stars, workflow status, and Discord community links, improving project visibility and information.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new scripts and utilities for interacting with Discord webhooks and managing build artifacts. The changes include a new API for sending webhook messages, a script to add CSP rules, and updates to the log retrieval script to save full logs.

My review focuses on improving the robustness and maintainability of the new TypeScript code. I've identified a critical issue in how file uploads are handled in src/send-webhook.ts that needs to be addressed. I've also suggested improvements for using asynchronous methods correctly in api/discord-webhook.ts and cleaning up dependencies in package.json. Additionally, I've recommended replacing magic numbers with enums to improve code clarity.

Comment thread src/send-webhook.ts
Comment on lines +30 to +38
for (const filePath of paths) {
if (fs.existsSync(filePath)) {
const fileName = path.basename(filePath);
form.append('file', fs.createReadStream(filePath), fileName);
fileAttached = true;
} else {
console.warn(`File not found at path: ${filePath}.`);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

When sending multiple files to a Discord webhook, the field names for the files must be unique and follow the pattern files[n], where n is the index of the file. Currently, you are using the same field name 'file' for all attachments, which will likely result in only the last file being sent or an error. You should use a loop with an index to generate unique field names.

Suggested change
for (const filePath of paths) {
if (fs.existsSync(filePath)) {
const fileName = path.basename(filePath);
form.append('file', fs.createReadStream(filePath), fileName);
fileAttached = true;
} else {
console.warn(`File not found at path: ${filePath}.`);
}
}
paths.forEach((filePath, index) => {
if (fs.existsSync(filePath)) {
const fileName = path.basename(filePath);
form.append(`files[${index}]`, fs.createReadStream(filePath), fileName);
fileAttached = true;
} else {
console.warn(`File not found at path: ${filePath}.`);
}
});

Comment thread package.json
},
"homepage": "https://github.com/TheLumiDevs/fP-extension-build#readme",
"devDependencies": {
"@types/form-data": "^2.5.2",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The @types/form-data package is deprecated and no longer needed. The form-data package now includes its own type definitions. You should remove this from your devDependencies.

Comment thread api/discord-webhook.ts
Comment on lines +47 to +52
return axios.post(webhookUrl, formData, {
headers: {
...formData.getHeaders(),
'Content-Length': formData.getLengthSync()
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The formData.getLengthSync() method is synchronous and can block the event loop. Since this function is already async, it's better to use the asynchronous formData.getLength() method to keep your code non-blocking and more performant.

You could refactor this part like so:

  formData.append('payload_json', JSON.stringify(payload));

  const contentLength = await new Promise<number>((resolve, reject) => {
    formData.getLength((err, length) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(length);
    });
  });

  return axios.post(webhookUrl, formData, {
    headers: {
      ...formData.getHeaders(),
      'Content-Length': contentLength,
    },
  });

Comment thread api/discord-webhook.ts
Comment on lines +55 to +65
export function createLinkButton(label: string, url: string) {
return {
type: 1,
components: [{
type: 2,
label,
style: 5,
url
}]
} as Component;
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using magic numbers for component types and styles (e.g., type: 1, style: 5) makes the code harder to read and maintain. It's better to define and use enums for these values, which is a common practice when working with Discord's API. This will make the code more self-documenting and less prone to errors.

You could define enums like these at the top of your file:

export enum ComponentType {
  ActionRow = 1,
  Button = 2,
  // ... other component types
}

export enum ButtonStyle {
  Primary = 1,
  Secondary = 2,
  Success = 3,
  Danger = 4,
  Link = 5,
}

Then, you can refactor createLinkButton and your type definitions to use them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant