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: support select template from templates dir #1370

Merged
merged 8 commits into from
Jul 9, 2024

Conversation

kiner-tang
Copy link
Contributor

@kiner-tang kiner-tang commented Jul 3, 2024

  • Support select template from templates dir
    • yarn create mako demo --template=vue3
    • yarn create mako
      image

Summary by CodeRabbit

  • 新功能
    • 引入了一个新选项类型 InitOptionsinit 函数现在接受包含 projectNametemplate 属性的对象。
    • 使用 inquirer 提示用户输入项目名称和模板选择。
    • 根据用户输入动态确定模板路径。

Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Warning

Rate limit exceeded

@kiner-tang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 36 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 7362e1f and 2aa64bb.

Walkthrough

这次更改主要集中在create-mako包中,改进了CLI初始化函数。通过引入InitOptions类型以对象方式传递参数,增强了用户交互功能。更新的主函数包含了使用inquirer提示用户输入项目名称和模板选择的逻辑,从而提高了用户体验。

Changes

文件路径 更改摘要
packages/create-mako/.../index.ts index.ts中新增用于记录创建Angular项目的日志逻辑。
packages/create-mako/src/cli.ts 引入InitOptions类型,重构init函数参数,增强用户交互功能。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Inquirer
    participant FileSystem

    User->>CLI: 启动CLI
    CLI->>Inquirer: 提示用户输入项目名称和模板类型
    Inquirer-->>User: 显示提示
    User-->>Inquirer: 提供项目名称和模板类型
    Inquirer-->>CLI: 返回用户输入的项目名称和模板类型
    CLI->>FileSystem: 根据模板创建项目
    FileSystem-->>CLI: 返回创建结果
    CLI-->>User: 显示创建成功信息
Loading

Poem

新的代码显光辉,

用户输入变清晰。

模板选择便利多,

项目生成如水流。

CodeRabbit问世时,

平步青云远航行。 🐇✨


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
Contributor

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f89abe8 and 04b3b4f.

Files selected for processing (2)
  • packages/create-mako/mako-project/index.ts (1 hunks)
  • packages/create-mako/src/cli.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/create-mako/mako-project/index.ts
Additional comments not posted (5)
packages/create-mako/src/cli.ts (5)

4-4: 导入 QuestionCollection 类型

导入 QuestionCollection 类型是为了支持新的模板选择功能。


8-8: 添加 baseTemplatesPath 常量

添加 baseTemplatesPath 常量使代码更灵活,可以动态确定模板目录的路径。


10-10: 添加 InitOptions 类型

InitOptions 类型用于结构化 init 函数的参数。


51-51: 添加 InitQuestion 类型

InitQuestion 类型用于用户提示。


57-57: 改进用户交互,但需要验证用户提示逻辑

main 函数的更改改进了用户交互,允许动态输入项目名称和模板选择。确保提示逻辑正确实现。

建议验证用户提示逻辑以确保功能正常工作。

Verification successful

用户提示逻辑已正确实现

main 函数中的更改改进了用户交互,允许动态输入项目名称和模板选择。questions 数组和 inquirer.prompt 的使用确保了当未提供参数时,脚本会提示用户输入必要的信息。

  • questions 数组定义在 main 函数中,包含项目名称和模板选择的提示。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify user prompt logic for project name and template selection.

# Test: Run the script and check if it prompts for project name and template correctly.
node packages/create-mako/src/cli.ts

Length of output: 110


Script:

#!/bin/bash
# Search for the usage of `inquirer` in the `cli.ts` file to verify the prompt logic.
ast-grep --lang typescript --pattern 'import $_ from "inquirer"' && rg 'inquirer.prompt' packages/create-mako/src/cli.ts

Length of output: 280


Script:

#!/bin/bash
# Search for the definition and contents of the `questions` array in `packages/create-mako/src/cli.ts`.
rg 'const questions' -A 10 packages/create-mako/src/cli.ts

Length of output: 60


Script:

#!/bin/bash
# Search for the keyword `questions` throughout the `cli.ts` file to find the prompt definitions.
rg 'questions' packages/create-mako/src/cli.ts -A 20 -B 5

Length of output: 1023

packages/create-mako/src/cli.ts Show resolved Hide resolved
Copy link
Contributor

@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 04b3b4f and 81e07df.

Files selected for processing (1)
  • packages/create-mako/src/cli.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/create-mako/src/cli.ts

@kiner-tang
Copy link
Contributor Author

@sorrycc 大佬,有空帮忙看看这个 PR

Copy link
Member

@sorrycc sorrycc left a comment

Choose a reason for hiding this comment

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

it conflicts, please merge master first.

packages/create-mako/mako-project/index.ts Outdated Show resolved Hide resolved
@kiner-tang
Copy link
Contributor Author

it conflicts, please merge master first.

ok

Copy link
Contributor

@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 81e07df and 7362e1f.

Files selected for processing (1)
  • packages/create-mako/src/cli.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/create-mako/src/cli.ts

@kiner-tang kiner-tang requested a review from sorrycc July 8, 2024 23:05
@sorrycc sorrycc merged commit cc673d3 into umijs:master Jul 9, 2024
8 checks passed
@sorrycc
Copy link
Member

sorrycc commented Jul 9, 2024

@kiner-tang https://makojs.dev/docs/feedback#contributing
Thanks for PR! If you want to join the Developer Dingtalk Group, please add my dingtalk as friend.

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