Skip to content

fix(cli): add missing .npmrc#175

Merged
fengmk2 merged 1 commit intomainfrom
09-21-fix_cli_add_missing_.npmrc
Sep 22, 2025
Merged

fix(cli): add missing .npmrc#175
fengmk2 merged 1 commit intomainfrom
09-21-fix_cli_add_missing_.npmrc

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Sep 21, 2025

TL;DR

Fixed monorepo initialization by properly handling dotfiles during template creation.

What changed?

  • Moved renameFiles() call before package manager setup to ensure dotfiles are renamed early in the initialization process
  • Added .npmrc and .yarnrc.yml to the list of files that need to be renamed
  • Renamed template files to use underscore prefix (_npmrc, _yarnrc.yml) to avoid git ignoring them
  • Added existence check before attempting to rename files to prevent errors
  • Updated file renaming logic to handle cases where source files might not exist

How to test?

  1. Create a new monorepo using the CLI
  2. Verify that .gitignore, .npmrc, and .yarnrc.yml files are correctly created
  3. Test with different package managers (npm, yarn, pnpm) to ensure proper initialization

Why make this change?

Dotfiles like .npmrc and .yarnrc.yml are essential for proper package manager configuration in monorepos. The previous implementation didn't properly handle these files during template creation, which could lead to missing configuration files. This change ensures all necessary dotfiles are correctly created during monorepo initialization.

@fengmk2 fengmk2 self-assigned this Sep 21, 2025
@fengmk2 fengmk2 marked this pull request as ready for review September 21, 2025 14:48
Copilot AI review requested due to automatic review settings September 21, 2025 14:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes a missing .npmrc configuration file in the CLI monorepo initialization process. The main issue was that the renameFiles function was being called after package manager setup, preventing the .npmrc file from being properly renamed and available during the initialization process.

  • Move renameFiles call to occur immediately after template copying
  • Add .npmrc and .yarnrc.yml to the rename files mapping
  • Add existence check before attempting file renames to prevent errors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@fengmk2 fengmk2 force-pushed the 09-21-fix_cli_add_missing_.npmrc branch from 1d6e4b2 to 400129a Compare September 22, 2025 01:13
Copilot AI review requested due to automatic review settings September 22, 2025 01:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

packages/global/src/new.ts:800

  • The renameFiles function will throw an error if the source file doesn't exist. Based on the PR description mentioning 'Added existence check before attempting to rename files to prevent errors', this function should check if the source file exists before attempting to rename it using fs.existsSync().
function renameFiles(projectDir: string) {
  for (const [from, to] of Object.entries(RENAME_FILES)) {
    fs.renameSync(path.join(projectDir, from), path.join(projectDir, to));
  }
}

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@fengmk2 fengmk2 merged commit 0db0d37 into main Sep 22, 2025
9 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Sep 22, 2025

Merge activity

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.

3 participants