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

contents flag does not get respected in latest version #551

Open
cambiph opened this issue Jul 7, 2020 · 6 comments
Open

contents flag does not get respected in latest version #551

cambiph opened this issue Jul 7, 2020 · 6 comments

Comments

@cambiph
Copy link

cambiph commented Jul 7, 2020

Description

When specifying the contents flag like np --contents=./../../ --preview" it seems to be ignored.
This may be caused by my setup but I am not sure because using npm publish ./../../ --dry-run does what I expect.

My project has a dependency called vl-ui-util that has a package.json
containing an npm run script that calls np. When calling np in the parent project, np will try and publish vl-ui-util instead of the parent project. According to the documentation, this can be fixed using the --contents flag, however, this seems to fail.

Steps to reproduce

  1. Create an empty project via npm init (project A)
  2. Create an empty project via npm init (project B)
  3. Install np as dependency in project B
  4. Create an npm run script in project B which runs np --contents=./../../ --preview" (Script X)
  5. Create an npm run script in project A (Script Y) which runs script X
  6. Call script A

Expected behavior

Np wizard starts and tries to release project A.

Environment

np - 6.3.0
Node.js - 13.12.0
npm - 6.14.5
Git - 2.15.0
OS - OSX Catalina 10.15.5

@dopecodez
Copy link
Collaborator

On further investigation, it looks like np does publish the right file. However, the root of the project is still the package.json which started the call. You should not think that contents means that np will use the folder specified as root, it only publishes from this folder, much like npm publish does. The rest of the operations will still be working on your current root directory.
Look through the comments in #276 and #264 to see the reason why the --contents flag should be used and see whether it makes sense.

@dopecodez
Copy link
Collaborator

@sindresorhus , i suggest we change the readme sligthly to stress this is the use case. I can see where the confusion could arise, I had the same doubt when i first started looking into the issue.

@cambiph
Copy link
Author

cambiph commented Jul 16, 2020

Thanks for the feedback.
So there will be no feature to mimick the npm publish ./../../ behaviour?

@dopecodez
Copy link
Collaborator

np publish contents=./../.. should do exactly the same thing as npm publish ./../../ does. The contents folder will only be taken into consideration while publishing only ie when np internally runs npm publish ./../../, all the other options np performs will be on the package that called np, and not on the contents path.

@twelve17
Copy link

I'm not sure how to make np work properly with a separate folder. As one of the steps in np is to bump the version, the updated package.json is in the package folder, not in the contents folder, so when it comes time to do the actual publish, the task fails because it is trying to update a version that is already published.

I suppose the alternative is to use publish: false, then delegate the bundling to the contents folder and publish that with npm publish ./contents?

@STLMikey
Copy link

@twelve17 I am also experiencing this case, I'm almost certain it's an oversight on my end. Did you manage to find a solution?

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

No branches or pull requests

4 participants