tiny-engine icon indicating copy to clipboard operation
tiny-engine copied to clipboard

feat: 追加 npmrc 文件的生成

Open Ljhhhhhh opened this issue 9 months ago • 3 comments

根据组件schema 的 npm.npmrc 配置信息生成内容到 npmrc 文件,以满足私有组件库的自动镜像配置生成

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

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

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [x] 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?

给组件 schema 增加 npmrc 配置信息后,可以自动生成 .npmrc 配置文件,解决出码后私有组件库无法安装的问题

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

Summary by CodeRabbit

  • New Features
    • Introduced an automated npm configuration generator that creates a configuration file based on project dependencies and settings.
    • Enhanced the app's configuration generator with a new plugin, expanding customization options for npm settings.

Ljhhhhhh avatar Mar 22 '25 05:03 Ljhhhhhh

Walkthrough

The changes introduce a new plugin, genNpmrcPlugin, into the Vue generator. The generateApp function now integrates the npmrc plugin into its default and custom plugins handling. A new file implements the plugin’s logic for generating .npmrc files based on schema analysis, while the plugins index is updated to export this new module.

Changes

File(s) Change Summary
packages/vue-generator/src/generator/generateApp.js Updated to integrate the new npmrc plugin into default and custom plugin merging logic.
packages/vue-generator/src/plugins/genNpmrcPlugin.js, packages/vue-generator/src/plugins/index.js Introduced genNpmrcPlugin to generate .npmrc files based on schema analysis and updated exports to include the new plugin.

Sequence Diagram(s)

sequenceDiagram
    participant GA as generateApp
    participant DP as DefaultPlugins
    participant GN as genNpmrcPlugin
    participant FS as FileSystem

    GA->>DP: Merge default and custom plugins (includes npmrc)
    alt npmrc plugin is configured
        GA->>GN: Invoke run method with schema
        GN->>FS: Write .npmrc file with generated content
    end

Suggested labels

enhancement

Suggested reviewers

  • hexqi
  • chilingling

Poem

I’m a little rabbit, hopping with delight,
In code burrows deep, new plugins take flight.
With genNpmrc magic, our files sing,
Dependencies and mirrors now perfectly cling.
Cheers to the changes that brighten our night!

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

coderabbitai[bot] avatar Mar 22 '25 05:03 coderabbitai[bot]

需要 .npmrc 的场景可能不多?而且还可以通过 npm config set registry xxx 的方式直接在环境上设置。

可以考虑抽取出来作为独立的出码插件,用户按需配置。

chilingling avatar Mar 25 '25 08:03 chilingling

Bot detected the issue body's language is not English, translate it automatically.


There may not be many scenarios that require .npmrc? It can also be set directly on the environment through npm config set registry xxx.

It can be considered to extract it as an independent code output plug-in and configure it on demand by users.

Issues-translate-bot avatar Mar 25 '25 08:03 Issues-translate-bot