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: engine-cli support create platform with params #626

Open
wants to merge 2 commits into
base: refactor/develop
Choose a base branch
from

Conversation

chilingling
Copy link
Member

@chilingling chilingling commented Jul 3, 2024

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a default configuration object for the engine, specifying an ID, theme, material, scripts, and styles.
    • Enhanced create-platform command to accept options for theme, platform ID, material address, scripts, and styles.
  • Refactor

    • Moved inline configuration settings to external files for better code organization and maintainability.
  • Bug Fixes

    • Corrected destructure assignment in material state dependencies.

Copy link

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes consolidate engine configuration into dedicated files for better modularity and flexibility. Engine configurations like themes, materials, and scripts are now externalized to an engine.config.js file, enhancing maintainability. The CLI tool engine-cli has also been improved to allow more customizable options during platform creation. Additionally, there are modifications to use consistent state references and introduction of new helper functions for generating configurations.

Changes

Files / Paths Change Summaries
designer-demo/engine.config.js Introduced a new default configuration object for the engine with properties like ID, theme, material, scripts, and styles.
designer-demo/registry.js Configurations are now imported from engine.config.js, moving away from inline definitions.
packages/common/js/preview.js Updated to destructure materialState instead of resState for third-party dependencies.
packages/engine-cli/src/commands/create.js Updated the createPlatform function to accept an options object, default values, folder checks, and configuration merges.
packages/engine-cli/src/commands/generateConfig.js Introduced functions generateConfig and generatePackageJson for generating configuration content and modifying package.json with specified options.
packages/engine-cli/src/index.js Enhanced create-platform command with more customizable options such as theme, platform ID, material address, scripts, and styles.
packages/engine-cli/template/designer/engine.config.js Introduced a new default configuration object for the engine with properties like ID, theme, material, scripts, and styles.
packages/engine-cli/template/designer/registry.js Configurations are now imported from engine.config.js, moving away from inline definitions.

Sequence Diagrams

Overall Flow for Platform Creation with Enhanced Options

sequenceDiagram
    User->>CLI: Run create-platform with options
    CLI->>createPlatform: Pass name and options
    createPlatform->>FileSystem: Check for existing folders
    FileSystem-->>createPlatform: Response
    createPlatform->>ConfigGenerator: Merge options and generate configuration
    ConfigGenerator-->>createPlatform: Return config and package.json content
    createPlatform->>FileSystem: Write config and package.json files
    createPlatform->>Template: Copy templates
    createPlatform-->>CLI: Creation completed
    CLI-->>User: Notify creation success
Loading

Poem

In a world of code so swift and rare,
A rabbit hops with utmost care.
Configs aligned, no mess to find,
🎨 Themes and scripts neatly combined.
With tools enhanced, how platforms grow,
CodeRabbit leads, in streams they flow.
🌟 A better future starts today,
With every line we pounce and play! 🐇🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0c6a248 and ed8fb86.

Files selected for processing (8)
  • designer-demo/engine.config.js (1 hunks)
  • designer-demo/registry.js (2 hunks)
  • packages/common/js/preview.js (1 hunks)
  • packages/engine-cli/src/commands/create.js (2 hunks)
  • packages/engine-cli/src/commands/generateConfig.js (1 hunks)
  • packages/engine-cli/src/index.js (1 hunks)
  • packages/engine-cli/template/designer/engine.config.js (1 hunks)
  • packages/engine-cli/template/designer/registry.js (1 hunks)
Files skipped from review due to trivial changes (2)
  • designer-demo/engine.config.js
  • packages/engine-cli/template/designer/engine.config.js
Additional comments not posted (10)
packages/engine-cli/template/designer/registry.js (1)

49-49: LGTM!

The import of engineConfig and its usage in the exported configuration object look good.

designer-demo/registry.js (1)

49-49: LGTM!

The import of engineConfig and its usage in the exported configuration object look good.

packages/common/js/preview.js (1)

29-29: LGTM!

The update from resState to materialState in the destructuring assignment looks good.

packages/engine-cli/src/commands/create.js (1)

58-61: LGTM!

The createPlugin function looks good.

packages/engine-cli/src/index.js (6)

21-21: LGTM! The --theme option is correctly implemented.

The --theme option allows customization of the platform theme with a default value of 'light'.


22-22: LGTM! The --platformId option is correctly implemented.

The --platformId option allows specifying a unique platform ID with a default value of '918'.


23-23: LGTM! The --material option is correctly implemented.

The --material option allows specifying one or more material addresses with a default value of ['/mock/bundle.json'].


24-24: LGTM! The --scripts option is correctly implemented.

The --scripts option allows specifying one or more scripts with a default value of an empty array.


25-25: LGTM! The --styles option is correctly implemented.

The --styles option allows specifying one or more styles with a default value of an empty array.


26-27: LGTM! The createPlatform function call is correctly implemented.

The createPlatform function is called with the provided options, ensuring that the new options are utilized.

However, ensure that all function calls to createPlatform match the new signature.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ed8fb86 and 46e7bed.

Files selected for processing (2)
  • packages/engine-cli/src/index.js (2 hunks)
  • packages/engine-cli/template/designer/registry.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/engine-cli/src/index.js
Additional comments not posted (2)
packages/engine-cli/template/designer/registry.js (2)

47-47: Verify the usage of GenerateCodeService.

The addition of GenerateCodeService looks good.

However, ensure that GenerateCodeService is correctly used within the file and the rest of the codebase.


49-49: Verify the usage of engineConfig.

The addition of engineConfig import looks good.

However, ensure that engineConfig is correctly used within the file and the rest of the codebase.

Verification successful

The engineConfig import and its usage are correctly implemented.

The addition of engineConfig import in packages/engine-cli/template/designer/registry.js is appropriate and it is used consistently within the file and the rest of the codebase.

  • designer-demo/registry.js:
    • import engineConfig from './engine.config'
    • config: engineConfig,
  • packages/engine-cli/template/designer/registry.js:
    • import engineConfig from './engine.config'
    • config: engineConfig,
  • packages/build/vite-config/src/default-config.js:
    • Various functions utilizing engineConfig
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `engineConfig` in the codebase.

# Test: Search for the usage of `engineConfig`. Expect: Relevant usage in the codebase.
rg --type javascript 'engineConfig'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify the usage of `engineConfig` in the codebase.

# Test: Search for the usage of `engineConfig` in JavaScript files. Expect: Relevant usage in the codebase.
rg 'engineConfig' --glob '*.js'

Length of output: 1072

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.

None yet

2 participants