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

Version 16.3.3: netlify deploy in monorepo with --dir flag deploys entire project root #6000

Closed
South-Paw opened this issue Sep 18, 2023 · 5 comments · Fixed by #6001 or #6003
Closed
Assignees
Labels
area: monorepo type: bug code to address defects in shipped code

Comments

@South-Paw
Copy link

South-Paw commented Sep 18, 2023

Describe the bug

With a --filter flag set, the root of the project is being deployed (src and all) instead of the specified --dir

And adjacent to that, the deploy command requires a --filter flag despite a --dir flag being provided?

Steps to reproduce

We have a monorepo project (using npm workspaces) with the following structure

/apps
  /app-1
    /dist (after build)
    /src
    /package.json
  /app-2
    /dist (after build)
    /src
    /package.json
/package.json

To deploy we were using the following in a GitHub workflow (from the project root):

npx netlify-cli deploy --prod --dir ./apps/app-1/dist

However, this broke in CI with 16.x introducing the --filter arg. The command started failing as it prompts for the "the site you want to work with" despite us having set an explicit --dir 🤔

So we added:

npx netlify-cli deploy --prod --dir ./apps/app-1/dist --filter @example/app-1

As was suggested by the deploy commands output without the --filter arg

But now we've now realized after setting --filter @example/apps-1 flag to resolve the failed command, the Netlify CLI is deploying our entire project to the Netlify site (src directories, .json files, md files) instead of the specified --dir.

We confirmed this by downloading a zip from the site only to find our repo in there.

I've reproduced on my local machine with a similar setup and specifying v16.3.3

npx netlify-cli@16.3.3 deploy --prod --dir ./apps/app-1/dist --filter @example/app-1

Possibly related is #5966

Configuration

No response

Environment

the issue exists on a GitHub action workflow

@South-Paw South-Paw added the type: bug code to address defects in shipped code label Sep 18, 2023
@South-Paw South-Paw changed the title Version 16.3.3: netlify deploy in monorepo with --dir flag deploys root Version 16.3.3: netlify deploy in monorepo with --dir flag deploys entire project root Sep 18, 2023
@South-Paw
Copy link
Author

South-Paw commented Sep 18, 2023

The issue does not occur when using netlify-cli@15.11.0

Tbh, I'm more than a little annoyed that our private monorepo and src directories have been published to our Netlify site. I've been going through and removing those specific deployments, which hopefully will keep them private.

@lukasholzer
Copy link
Collaborator

Thanks for creating this detailed issue I'm so sorry you accidentally published your whole repo. If there is anything we can assist you here please feel free to send me a mail to lukas.holzer@netlify.com

I'm currently trying to replicate it with a simple example and be back in some minutes to you hopefully with an answer

@lukasholzer
Copy link
Collaborator

A quick way in the meanwhile, until I'm able to push a fix out today, is to use the internal --cwd flag. This should bypass the --filter and everything and is a backdoor to old behavior:

ntl deploy --cwd ./apps/app-1 --dir ./dist

This basically treats the site as if it would be a non monorepo simple netlify located in this directory

@lukasholzer
Copy link
Collaborator

The fix is released in 16.3.4 @South-Paw please let us know if something is not working as expected

@South-Paw
Copy link
Author

Thanks, will sing out if problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: monorepo type: bug code to address defects in shipped code
Projects
None yet
2 participants