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: pull components cmd #139

Merged
merged 22 commits into from
Jan 22, 2025
Merged

feat: pull components cmd #139

merged 22 commits into from
Jan 22, 2025

Conversation

alvarosabu
Copy link
Contributor

@alvarosabu alvarosabu commented Dec 3, 2024

This PR introduces the new implementation of the pull-components command

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

How to test this PR

  1. Clone the repo and pull the branch
  2. Add several components to a Storyblok Space or use the default test one 295017 or 295018
  3. Run pnpm install
  4. Run pnpm run dev components pull --space <SPACE_ID>

Testing checklist

  • pull-components from a space
    • should create a components.json file inside of .storyblok/components/295017 directory containing an array with all the components available
    • it should prompt the user with a successful message ✔ Components downloaded successfully in ./storyblok/components/295017/components.json
  • should prompt an error if flag space is missing Please provide the space as argument --space YOUR_SPACE_ID.
  • should prompt an API error if the space ID is incorrect
  • should prompt an unauthorized error if the user is not logged in before operating this command
  • components pull in --separate-files
    • should create a file per component. Example: component named Space A Component Inside Folder 1 should generate space-a-component-inside-folder-1.json
    • Should prompt a warning The --filename option is ignored when using --separate-files if --filename flag is used along --sf
  • components pull with custom --path
    • should generate a components.295017.json file inside of the path provided.
    • should generate individual files inside the correspondent path if used together with --separate-files
  • components pull with custom --filename
    • should generate a custom-filename.json inside of the .storyblok/components/295017 directory
    • should generate a custom-filename.json inside of the provided path if --path is provided
  • components pull with custom --suffix
    • should generate a components.suffix.json inside of the .storyblok/components/295017 directory
    • should generate a custom-filename.suffix.json inside of the provided path if --path is provided
    • should create a file per component with the same custom suffix if --separate-files is used. Example: component named Space A Component Inside Folder 1 should generate space-a-component-inside-folder-1.suffix.json
  • components pull component-name
    • should pull a single component if the component name is passed storyblok components pull component-name
    • should generate an individual component-name.json file inside .storyblok/components/295017
    • should throw an error if no component-name is passed.

@alvarosabu alvarosabu added p3-significant [Priority] Moderate issues, major enhancements feature [Issue] New feature or request labels Dec 3, 2024
@alvarosabu alvarosabu marked this pull request as draft December 3, 2024 14:38
- Updated actions to use customFetch instead of ofetch
- Modified the `saveComponentsToFiles` function to accept a structured `spaceData` object containing components, groups, and presets, instead of separate parameters.
- Updated the default filename behavior to save as `components.json` instead of including the space ID in the filename.
- Enhanced test cases to reflect changes in the function signature and filename generation logic.
- Removed unused imports and interfaces to streamline the codebase.
- Deleted the entire block command implementation from the codebase.
- Removed unused imports related to the block command in the components test file.
…pport fetching individual components

- Introduced a new `fetchComponent` function to retrieve a specific component by name.
- Updated the `componentsCommand` to allow pulling a single component by name, enhancing the command's functionality.
- Modified tests to cover the new component fetching feature, including scenarios for successful retrieval and handling of non-existent components.
- Adjusted the structure of the command's output to reflect the new functionality, ensuring clarity in success messages.
@alvarosabu alvarosabu marked this pull request as ready for review January 20, 2025 13:38
@alvarosabu alvarosabu self-assigned this Jan 20, 2025
…and with loading spinners

- Changed COMPONENTS color from '#FF5722' to '#a185ff' in src/constants.ts for better visual consistency.
- Added loading spinners to the components command in src/commands/components/index.ts to improve user experience during data fetching operations.
- Each data fetching step now provides visual feedback, enhancing the command's interactivity.
@alvarosabu alvarosabu merged commit 531656d into next Jan 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [Issue] New feature or request p3-significant [Priority] Moderate issues, major enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants