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: cli support customize project name #1340

Merged
merged 14 commits into from
Jul 3, 2024
Merged

Conversation

kiner-tang
Copy link
Contributor

@kiner-tang kiner-tang commented Jun 30, 2024

Cli support customize project name:

  • yarn create mako test-demo will create new project in 'test-demo'
  • yarn create mako . will create new project in current directory

Summary by CodeRabbit

  • 新功能
    • 添加了项目初始化功能,用户可以通过命令行参数或提示输入项目名称来初始化项目。

Copy link
Contributor

coderabbitai bot commented Jun 30, 2024

Walkthrough

此次更新在 packages/create-mako 包中增加了 inquirer 及其类型定义包,用于项目初始化时进行用户交互。此外,cli.ts 文件增加了一个新的 init(projectName: string) 函数用于根据提供的项目名称初始化项目,main() 函数也进行了修改,以便处理通过命令行参数或者提示获取项目名称。

Changes

文件路径 更改摘要
packages/create-mako/package.json 增加了对 "inquirer": "^9.3.1" 的依赖,并在开发依赖中包含 "@types/inquirer": "^9.0.7"
packages/create-mako/src/cli.ts 增加了 init(projectName: string) 函数,并更新 main() 函数以采用 yargs-parserinquirer 处理项目名称的获取。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as CLI Application
    participant Inquirer as Inquirer
    participant Filesystem

    User->>CLI: Run CLI without project name
    CLI->>Inquirer: Prompt for project name
    Inquirer->>User: Ask for project name
    User->>Inquirer: Provide project name
    Inquirer->>CLI: Return project name
    CLI->>Filesystem: Initialize project with given name

    Note over CLI,Filesystem: CLI initializes the project in the given directory.
Loading

Poem

代码如诗,变化如歌,
小兔儿忙碌,不辞辛劳。
新增问询,名称问答,
项目初始化,快捷高效。
依赖更新,无缝衔接,
愿你编程路,欢乐无穷。

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


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

Outside diff range and nitpick comments (1)
packages/create-mako/src/cli.ts (1)

Line range hint 7-41: 建议添加文件操作的错误处理

目前的实现缺少对文件操作(如fs.mkdirSyncfs.copyFileSync)的错误处理。如果在创建目录或复制文件时发生错误,程序将崩溃。建议在这些操作中添加错误处理逻辑。

-    fs.mkdirSync(destDir, { recursive: true });
+    try {
+      fs.mkdirSync(destDir, { recursive: true });
+    } catch (err) {
+      console.error(`Error creating directory ${destDir}:`, err);
+      process.exit(1);
+    }

-    fs.copyFileSync(source, dest);
+    try {
+      fs.copyFileSync(source, dest);
+    } catch (err) {
+      console.error(`Error copying file from ${source} to ${dest}:`, err);
+      process.exit(1);
+    }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 25fa59f and e4e1a99.

Files ignored due to path filters (1)
  • packages/create-mako/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (3)
  • packages/create-mako/package.json (1 hunks)
  • packages/create-mako/src/cli.ts (2 hunks)
  • packages/create-mako/tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/create-mako/package.json
  • packages/create-mako/tsconfig.json
Additional comments not posted (2)
packages/create-mako/src/cli.ts (2)

Line range hint 7-41: LGTM!

代码实现看起来很好,但请确保在文件操作中添加适当的错误处理逻辑。


43-55: LGTM!

代码实现看起来很好,但请考虑添加注释以提高可读性。

packages/create-mako/src/cli.ts Outdated 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 e4e1a99 and d3eaa18.

Files selected for processing (1)
  • packages/create-mako/.gitignore (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/create-mako/.gitignore

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 d3eaa18 and d4c816e.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (2)
  • packages/create-mako/package.json (1 hunks)
  • packages/create-mako/src/cli.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/create-mako/package.json
  • packages/create-mako/src/cli.ts

packages/create-mako/src/cli.ts Outdated Show resolved Hide resolved
packages/create-mako/src/cli.ts Outdated Show resolved Hide resolved
packages/create-mako/.gitignore Outdated 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 d4c816e and e0bb7e5.

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

@kiner-tang kiner-tang requested a review from sorrycc July 1, 2024 14:47
@kiner-tang
Copy link
Contributor Author

@sorrycc 云谦老师,帮忙再 CR 一下

@sorrycc sorrycc merged commit 3b2512a into umijs:master Jul 3, 2024
8 checks passed
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 e0bb7e5 and 0439013.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (2)
  • packages/create-mako/package.json (1 hunks)
  • packages/create-mako/src/cli.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/create-mako/package.json
  • packages/create-mako/src/cli.ts

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