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

[Sweep Rules] Refactor DescriptionResult class and generateDescription function #22

Closed

Conversation

sweep-ai[bot]
Copy link
Contributor

@sweep-ai sweep-ai bot commented Nov 8, 2023

PR Feedback: 👎

I created this PR to address this rule:

"Implementations should be simple, straightforward, and clean."

Description

This PR addresses the complexity introduced in the generator.js file by refactoring the DescriptionResult class and the generateDescription function. The errorDescription property has been removed from the DescriptionResult class, and the status property has been simplified to a boolean isGenerated. Additionally, the generateDescription function has been refactored to break down its functionality into smaller, more focused functions for improved readability and maintainability.

Summary

  • Removed the errorDescription property from the DescriptionResult class and simplified the status property to a boolean isGenerated.
  • Refactored the generateDescription function to break down its functionality into smaller functions: getFrontMatter and getDescription.
  • Updated the generateDescription function to use the new smaller functions and return a new DescriptionResult with the page, description, and isGenerated status.

Copy link
Contributor Author

sweep-ai bot commented Nov 8, 2023

Rollback Files For Sweep

  • Rollback changes to src/generator.js

@sweep-ai sweep-ai bot added the sweep Sweep your software chores label Nov 8, 2023
Copy link
Contributor Author

sweep-ai bot commented Nov 8, 2023

Sandbox Executions

Copy link
Contributor Author

sweep-ai bot commented Nov 8, 2023

The command:
Run npm test
yielded the following error:
##[error]Process completed with exit code 1.
Here are the logs:

> jekyl-seo-action@1.0.0 test
> cross-env NODE_OPTIONS=--experimental-vm-modules jest

FAIL test/generator.test.js
● Test suite failed to run

SyntaxError: Unexpected token 'export'

18 | }));
19 |
> 20 | const { generateDescriptions, DescriptionResult, GenerationStatus } = await import("../src/generator");
|                                                                       ^
21 | const { getModelResponse } = await import("../src/openai-client");
22 | const fs = await import("fs/promises");
23 |

at Runtime.loadEsmModule (node_modules/jest-runtime/build/index.js:510:20)
at test/generator.test.js:20:71

(node:1973) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
/home/runner/work/jekyll-seo-ai-action/jekyll-seo-ai-action/src/generator.js:75
export const generateDescriptions = async (pages) => {
^^^^^^

SyntaxError: Unexpected token 'export'
at new Module (node:internal/vm/module:125:21)
at new SourceTextModule (node:internal/vm/module:291:5)
at Runtime.loadEsmModule (/home/runner/work/jekyll-seo-ai-action/jekyll-seo-ai-action/node_modules/jest-runtime/build/index.js:510:20)
at importModuleDynamically (/home/runner/work/jekyll-seo-ai-action/jekyll-seo-ai-action/node_modules/jest-runtime/build/index.js:518:30)
at importModuleDynamicallyWrapper (node:internal/vm/module:429:15)
at /home/runner/work/jekyll-seo-ai-action/jekyll-seo-ai-action/test/generator.test.js:20:71

Node.js v18.18.2

Copy link
Contributor Author

sweep-ai bot commented Nov 8, 2023

🚀 Wrote Changes

Done.

jest.config.mjs Outdated Show resolved Hide resolved
src/generator.js Show resolved Hide resolved
Copy link

github-actions bot commented Nov 8, 2023

No files to generate SEO content were detected in this pull request.
-- Jekyll SEO AI Action
These changes were automatically generated by Jekyll SEO AI Action.

src/generator.js Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Nov 8, 2023

No files to generate SEO content were detected in this pull request.
-- Jekyll SEO AI Action
These changes were automatically generated by Jekyll SEO AI Action.

@AlphaGit AlphaGit closed this Nov 8, 2023
@AlphaGit AlphaGit deleted the sweep/descriptionresult-and-generateDescription branch November 8, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sweep Sweep your software chores
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant