Skip to content

feat: validate configuration with arktype #806

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

Merged
merged 1 commit into from
Apr 4, 2025
Merged

Conversation

satya164
Copy link
Member

No description provided.

@satya164 satya164 requested review from atlj and Copilot March 29, 2025 17:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces configuration validation using arktype to improve the robustness of the configuration input. Key changes include:

  • Moving and refining the definition of configuration types from types.ts to a new schema.ts.
  • Integrating arktype validation in the build process with appropriate error handling.
  • Adjusting target option parsing and related imports to align with the new schema.

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react-native-builder-bob/src/utils/workerize.ts Updated Target type import for consistency with the new schema.
packages/react-native-builder-bob/src/utils/loadConfig.ts Refactored loadConfig function signature for clarity.
packages/react-native-builder-bob/src/types.ts Removed obsolete Target and Options types moved to the schema.
packages/react-native-builder-bob/src/targets/codegen/index.ts Updated Options type to exclude output for codegen targets.
packages/react-native-builder-bob/src/schema.ts Introduced configuration schema using arktype.
packages/react-native-builder-bob/src/index.ts Adjusted Target type import to use the new schema.
packages/react-native-builder-bob/src/build.ts Integrated arktype validation and refined target option parsing.
Files not reviewed (1)
  • packages/react-native-builder-bob/package.json: Language not supported
Comments suppressed due to low confidence (2)

packages/react-native-builder-bob/src/schema.ts:1

  • [nitpick] Consider renaming the imported identifier 'type' (e.g. to 'arktype') to avoid potential confusion with TypeScript's 'type' keyword and improve code clarity.
import { type } from 'arktype';

packages/react-native-builder-bob/src/build.ts:110

  • [nitpick] Consider explicitly handling the case where no target-specific options are found rather than relying solely on a type cast, which may lead to unexpected behavior at runtime.
const options = config.targets.map((t) => (Array.isArray(t) ? t : ([t, undefined] as const))).find((t) => t[0] === target)?.[1];

@satya164 satya164 force-pushed the @satya164/arktype branch from f42468f to b43ff30 Compare March 29, 2025 17:52
@atlj atlj force-pushed the @satya164/arktype branch from b43ff30 to f3ff47f Compare April 4, 2025 10:17
Copy link
Collaborator

@atlj atlj left a comment

Choose a reason for hiding this comment

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

Tested and works well

@satya164 satya164 force-pushed the @satya164/arktype branch from f3ff47f to ee1d7e8 Compare April 4, 2025 18:24
@satya164 satya164 force-pushed the @satya164/arktype branch from ee1d7e8 to fe258be Compare April 4, 2025 18:25
@satya164 satya164 added this pull request to the merge queue Apr 4, 2025
Merged via the queue into main with commit a8fd434 Apr 4, 2025
21 checks passed
@satya164 satya164 deleted the @satya164/arktype branch April 4, 2025 19:29
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.

2 participants