cli icon indicating copy to clipboard operation
cli copied to clipboard

`netlify serve` modifying incorrect .gitignore

Open pcattori opened this issue 11 months ago • 0 comments

Describe the bug

In a pnpm workspace, if a subdirectory is a package acting as a Netlify app, then running netlify serve should:

  • create a .netlify directory within that subdirectory ✅
  • add .netlify to that subdirectory's .gitignore if not already present ❌

Instead of modifying <package>/.gitignore, the root .gitignore gets modified with:

# Local Netlify folder
.netlify

netlify serve is already figuring out where to write .netlify to, so it should start there and look for a .gitignore that contains .netlify. If none is found, then go ahead and modify the root .gitignore or add a .gitignore for that package.

Steps to reproduce

  1. git clone remix-run/react-router-templates
  2. git checkout ff303a5bd4c742104c601dc5eda4f825d10739b8 (known commit that has this issue)
  3. pnpm install
  4. cd netlify
  5. pnpm build
  6. pnpm start (you may need to update netlify.toml with pnpm instead of npm run)
  7. After successful startup, exit netlify serve and run git status

Configuration

[build]
command = "npm run build"
publish = "build/client"

[dev]
command = "npm run dev"
framework = "vite"

# Set immutable caching for static files, because they have fingerprinted filenames

[[headers]]
for = "/assets/*"
[headers.values]
"Cache-Control" = "public, max-age=31560000, immutable"

Environment

  System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 928.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 9.14.4 - ~/.nvm/versions/node/v20.11.0/bin/pnpm
  npmPackages:
    netlify-cli: ^17.38.0 => 17.38.0

pcattori avatar Dec 10 '24 20:12 pcattori