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

Release #846

Merged
merged 62 commits into from
Oct 26, 2024
Merged

Release #846

merged 62 commits into from
Oct 26, 2024

Conversation

philipbrembeck
Copy link
Collaborator

@philipbrembeck philipbrembeck commented Oct 26, 2024

Summary by Sourcery

Implement new features for product search and ingredient checking, refactor components for better maintainability, and update the build and CI configurations to use pnpm. Enhance documentation with a detailed developer guide and introduce comprehensive testing with Jest and Playwright.

New Features:

  • Introduce a new product search feature with barcode scanning capability using Quagga for live stream input.
  • Add a new ingredients check feature that allows users to input ingredients and determine their vegan status.
  • Implement a new layout for the application with improved navigation and metadata handling.

Enhancements:

  • Refactor the share button component to use a more flexible and maintainable structure with useMemo for share options.
  • Improve the footer component by introducing a reusable FooterLink component for external links.
  • Enhance the modal components by consolidating logic and improving the user interface.

Build:

  • Update the build configuration to use pnpm instead of npm, including changes to the GitHub Actions workflows.
  • Add a new Jest configuration file for testing setup and coverage reporting.

CI:

  • Modify the CI workflow to use pnpm for dependency management and add type-checking and testing steps.
  • Introduce an end-to-end testing job in the CI pipeline using Playwright.

Documentation:

  • Revise the README to include a comprehensive developer guide with project structure, development commands, and guidelines.

Tests:

  • Add unit tests for the new product fetching logic and ingredient checking functionality.
  • Introduce Playwright tests for end-to-end testing of the application.

Chores:

  • Remove deprecated pages and components, including old scanner and translation components.
  • Delete outdated documentation files and assets.

dependabot bot and others added 30 commits October 7, 2024 02:50
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.3.3 to 18.3.11.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [eslint-config-next](https://github.com/vercel/next.js/tree/HEAD/packages/eslint-config-next) from 14.2.5 to 14.2.14.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/commits/v14.2.14/packages/eslint-config-next)

---
updated-dependencies:
- dependency-name: eslint-config-next
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [next-intl](https://github.com/amannn/next-intl) from 3.17.2 to 3.20.0.
- [Release notes](https://github.com/amannn/next-intl/releases)
- [Changelog](https://github.com/amannn/next-intl/blob/main/CHANGELOG.md)
- [Commits](amannn/next-intl@v3.17.2...v3.20.0)

---
updated-dependencies:
- dependency-name: next-intl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…next-intl-3.20.0

build(deps): bump next-intl from 3.17.2 to 3.20.0
…eslint-config-next-14.2.14

build(deps-dev): bump eslint-config-next from 14.2.5 to 14.2.14
…types/react-18.3.11

build(deps-dev): bump @types/react from 18.3.3 to 18.3.11
Bumps [@playwright/test](https://github.com/microsoft/playwright) from 1.46.1 to 1.47.2.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](microsoft/playwright@v1.46.1...v1.47.2)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…playwright/test-1.47.2

build(deps-dev): bump @playwright/test from 1.46.1 to 1.47.2
Bumps [eslint-config-next](https://github.com/vercel/next.js/tree/HEAD/packages/eslint-config-next) from 14.2.14 to 14.2.15.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/commits/v14.2.15/packages/eslint-config-next)

---
updated-dependencies:
- dependency-name: eslint-config-next
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.5.4 to 5.6.3.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](microsoft/TypeScript@v5.5.4...v5.6.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [next](https://github.com/vercel/next.js) from 14.2.14 to 14.2.15.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](vercel/next.js@v14.2.14...v14.2.15)

---
updated-dependencies:
- dependency-name: next
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
…next-14.2.15

build(deps): bump next from 14.2.14 to 14.2.15
…typescript-5.6.3

build(deps): bump typescript from 5.5.4 to 5.6.3
Bumps [@playwright/test](https://github.com/microsoft/playwright) from 1.47.2 to 1.48.0.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](microsoft/playwright@v1.47.2...v1.48.0)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…playwright/test-1.48.0

build(deps-dev): bump @playwright/test from 1.47.2 to 1.48.0
…eslint-config-next-14.2.15

build(deps-dev): bump eslint-config-next from 14.2.14 to 14.2.15
feat: Change Package manager to pnpm
Bumps [next-intl](https://github.com/amannn/next-intl) from 3.20.0 to 3.21.1.
- [Release notes](https://github.com/amannn/next-intl/releases)
- [Changelog](https://github.com/amannn/next-intl/blob/main/CHANGELOG.md)
- [Commits](amannn/next-intl@v3.20.0...v3.21.1)

---
updated-dependencies:
- dependency-name: next-intl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [pnpm/action-setup](https://github.com/pnpm/action-setup) from 2 to 4.
- [Release notes](https://github.com/pnpm/action-setup/releases)
- [Commits](pnpm/action-setup@v2...v4)

---
updated-dependencies:
- dependency-name: pnpm/action-setup
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
…s/pnpm/action-setup-4

build(deps): bump pnpm/action-setup from 2 to 4
…next-intl-3.21.1

build(deps): bump next-intl from 3.20.0 to 3.21.1
philipbrembeck and others added 25 commits October 26, 2024 17:03
feat: Code Refactor & Upgrade to Next.js 15 / React 19-RC
Bumps [sass](https://github.com/sass/dart-sass) from 1.79.4 to 1.80.4.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md)
- [Commits](sass/dart-sass@1.79.4...1.80.4)

---
updated-dependencies:
- dependency-name: sass
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.5.4 to 22.8.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…types/node-22.8.1

build(deps): bump @types/node from 22.5.4 to 22.8.1
Bumps [@frontendnetwork/veganify](https://github.com/JokeNetwork/veganify-api-wrapper) from 1.2.5 to 1.2.9.
- [Commits](https://github.com/JokeNetwork/veganify-api-wrapper/commits)

---
updated-dependencies:
- dependency-name: "@frontendnetwork/veganify"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
…frontendnetwork/veganify-1.2.9

build(deps): bump @frontendnetwork/veganify from 1.2.5 to 1.2.9
…sass-1.80.4

build(deps): bump sass from 1.79.4 to 1.80.4
Copy link

stackblitz bot commented Oct 26, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

sourcery-ai bot commented Oct 26, 2024

Reviewer's Guide by Sourcery

This pull request implements a major refactoring and modernization of the codebase, migrating to Next.js App Router, improving type safety, and enhancing code organization. The changes include better component structure, improved error handling, and the adoption of modern React patterns.

Architecture diagram for CI/CD pipeline changes

graph TD;
    A[Pull Request] -->|Trigger| B[Build and Lint PRs]
    B --> C[Regular Build]
    C -->|Success| D[Deploy to Staging]
    C -->|Failure| E[Legacy Peer Deps Build]
    E -->|Success| D
    D --> F[E2E Tests]
    F -->|Run on| G[Staging Environment]
Loading

Class diagram for ShareButton component refactor

classDiagram
    class ShareButton {
        +string productName
        +string barcode
        +boolean showButton
        +useEffect()
        +handleShareClick(shareUrl: string)
        +shareOptions: ShareOption[]
    }
    class ShareOption {
        +string id
        +string text
        +string icon
        +string url
        +handler(): Promise<void>
    }
Loading

Class diagram for ModalWrapper component refactor

classDiagram
    class ModalWrapper {
        +string id
        +"sup" | "span" | "div" buttonType
        +string buttonClass
        +string buttonText
        +ReactNode children
        +boolean isOpen
        +boolean mounted
        +useEffect()
        +closeModal()
    }
Loading

Class diagram for ProductSearch component

classDiagram
    class ProductSearch {
        +ProductResult result
        +Sources sources
        +string barcode
        +boolean showFound
        +boolean showNotFound
        +boolean showInvalid
        +boolean showTimeout
        +boolean showTimeoutFinal
        +boolean loading
        +useEffect()
        +handleSubmit(barcode: string, event?: FormEvent)
    }
    class ProductResult {
        +string productname
        +boolean | "n/a" vegan
        +boolean | "n/a" vegetarian
        +boolean | "n/a" animaltestfree
        +boolean | "n/a" palmoil
        +string nutriscore
        +string grade
    }
    class Sources {
        +string api
        +string baseuri
    }
Loading

Class diagram for ViewportScanner component

classDiagram
    class ViewportScanner {
        +string facingMode
        +boolean isHidden
        +boolean isMirrored
        +initializeScanner(newFacingMode: string)
        +handleCameraSwitch()
        +handleClose()
    }
Loading

File-Level Changes

Change Details Files
Migration to Next.js App Router and improved internationalization
  • Replaced page-based routing with App Router directory structure
  • Implemented new Next.js metadata API
  • Enhanced internationalization setup with next-intl
  • Added proper locale handling and middleware
src/app/[locale]/layout.tsx
src/app/[locale]/page.tsx
src/middleware.ts
src/i18n/routing.ts
src/i18n/request.ts
Component refactoring and code organization improvements
  • Split large components into smaller, more focused components
  • Implemented proper TypeScript interfaces and types
  • Added proper error boundaries and loading states
  • Improved component reusability with better props typing
src/components/Check/index.tsx
src/components/Check/ProductResult.tsx
src/components/Check/SearchForm.tsx
src/components/IngredientsCheck/IngredientsForm.tsx
src/components/Scanner/ViewportScanner.tsx
Enhanced build and development setup
  • Added Jest configuration for unit testing
  • Configured Playwright for end-to-end testing
  • Updated ESLint configuration for stricter type checking
  • Added Million.js for performance optimization
jest.config.ts
playwright.config.ts
.eslintrc.json
next.config.ts
Improved share functionality and modal components
  • Refactored share button component with better type safety
  • Improved modal wrapper with proper accessibility
  • Added proper event handling for share actions
  • Enhanced share options management with TypeScript
src/components/elements/share.tsx
src/components/elements/modalwrapper.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

sonarcloud bot commented Oct 26, 2024

@philipbrembeck philipbrembeck merged commit eb75ccc into main Oct 26, 2024
8 of 9 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @philipbrembeck - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Potential hard-coded PayPal donation link found. (link)
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🔴 Security: 1 blocking issue, 1 other issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

},
(err: Error | null) => {
if (err) {
console.error("Error initializing Quagga:", err);
Copy link

Choose a reason for hiding this comment

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

suggestion: Add user-facing error handling for scanner initialization failures

Consider adding a proper error state and user feedback mechanism instead of just logging to console. This would improve the user experience when camera access fails or initialization errors occur.

          setError(`Scanner initialization failed: ${err.message}`);
          showErrorToast('Unable to start barcode scanner. Please check camera permissions.');


const data = await checkIngredients(ingredientsString);
setResult(data);
} catch (error) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Extract error handling logic into a separate function

Consider extracting the error handling logic into a separate function to reduce code duplication and improve maintainability.

    } catch (error) {
      handleFormError(error);

excludeLinksFromLockfile: false

overrides:
'@types/react': npm:[email protected]
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider using stable versions of React and its type definitions instead of pre-release versions

Pre-release versions can introduce breaking changes and instability. Unless you specifically need features from React 19, consider using the latest stable version (React 18) and its corresponding type definitions.

  '@types/react': npm:[email protected]

'@typescript-eslint/eslint-plugin': ^8.11.0
'@typescript-eslint/parser': ^8.11.0
'@typescript-eslint/typescript-estree': ^8.11.0
uuid: 3.4.0
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): The uuid package version is significantly outdated

Version 3.4.0 is quite old - consider upgrading to the latest version (v9+) to get performance improvements and security updates.

Suggested change
uuid: 3.4.0
uuid: 9.0.1

icon: "icon-paypal",
vendor: "PayPal",
text: "Donate with PayPal",
link: "https://www.paypal.com/donate/?hosted_button_id=J7TEA8GBPN536",
Copy link

Choose a reason for hiding this comment

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

🚨 issue (security): Potential hard-coded PayPal donation link found.

This line contains a hard-coded PayPal donation link. Ensure that this is intended and does not expose any sensitive information or credentials.

Comment on lines +13 to +14
if (!score || score === "n/a")
return { score: "unknown icon-help", className: "" };
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!score || score === "n/a")
return { score: "unknown icon-help", className: "" };
if (!score || score === "n/a") {
return { score: "unknown icon-help", className: "" };
}


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

@@ -0,0 +1,27 @@
export function preprocessIngredients(input: string): string[] {
if (!input || typeof input !== "string") return [];
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!input || typeof input !== "string") return [];
if (!input || typeof input !== "string") {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (isHidden) return null;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (isHidden) return null;
if (isHidden) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).


useEffect(() => {
if (!isOpen) return;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!isOpen) return;
if (!isOpen) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

}, 500);
}
};
if (!mounted) return null;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!mounted) return null;
if (!mounted) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

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