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

feat: types-generate-cmd WIP #169

Open
wants to merge 9 commits into
base: next
Choose a base branch
from
Open

Conversation

alvarosabu
Copy link
Contributor

Pull request type

Jira Link: INT-

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Other (please describe):

How to test this PR

What is the new behavior?

Other information

…tion

- Introduced new utility functions in `format.ts` for converting strings to PascalCase, CamelCase, and SnakeCase.
- Added functions for masking tokens, slugifying text, and recursively removing properties from objects.
- Implemented a method to convert objects to string parameters for URLSearchParams.
- Created a function to generate regex patterns from glob patterns.
- Updated `index.ts` to export the new formatting utilities.
- Refactored the type generation logic to improve handling of component types, including sanitization of component names.
- Introduced a new `ComponentPropertySchema` interface and related types in `schemas.ts` for better type safety and organization.
- Updated the `generateStoryblokTypes` function to read type definitions from an external file, ensuring a more robust extraction process.
- Removed redundant type definitions from `storyblok.ts` to streamline the codebase and avoid duplication.
- Added support for component restrictions based on groups and individual whitelists in `getComponentPropertiesTypeAnnotations`.
- Introduced a new parameter `componentsMaps` to facilitate the mapping of component groups and names.
- Updated the `generateTypes` function to pass the new `componentsMaps` parameter, improving type safety and flexibility in handling component properties.
- Updated `generateTypes` and `getComponentPropertiesTypeAnnotations` functions to utilize `spaceData` instead of `componentsMaps`, improving type safety and flexibility.
- Added null checks for `spaceData.components` to prevent runtime errors.
- Removed the redundant `generateComponentGroupsAndComponentNames` function to streamline the codebase.
- Improved error handling in the `generateTypes` function by implementing a try/catch block to manage asynchronous errors effectively.
- Refactored `GenerateTypesOptions` to replace `typeNamesPrefix` and `typeNamesSuffix` with a single `typePrefix` option for improved clarity and usability.
- Enhanced `getComponentType` function to utilize the new `typePrefix` option, simplifying the type name generation process.
- Updated command options in `index.ts` to include `--type-prefix` for better user experience when generating component types.
- Adjusted handling of Storyblok property types to ensure consistent type generation without unnecessary prefixes.
- Introduced a new launch configuration in `.vscode/launch.json` for debugging the type generation process with separate files.
- This configuration allows for easier debugging of the type generation command, enhancing the development experience.
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