Skip to content

Conversation

@Boubalou
Copy link
Contributor

@Boubalou Boubalou commented Jun 8, 2021

📖 Description

Fix NpmPublishTask workingDir scope.

⚠️ Problem

When using the generated task publishJsNpmPublicationToNexus for a custom repository, the publication to Sonatype was reporting a success (HTTP PUT 200) but no artifact was ever uploaded to the expected repository.

Custom Repository config:

        repository("nexus") {
            access = RESTRICTED
            registry = uri("https://nexus.xxx.ca/repository/npm-internal")
            authToken = [obfuscated]
        }

Outputs of the command sent to Node failing to publish was as follow:

npm publish /Users/boubalou/dev/xxx/common/build/publications/npm --access restricted --registry https://nexus.xxx.ca/repository/npm-internal/ [authToken obfuscated]

When run manually using a terminal while being in pwd -> /Users/boubalou/dev/xxx/common/build/publications/npm, it was getting published succesfully.

npm publish . --access restricted --registry https://nexus.xxx.ca/repository/npm-internal/ [authToken obfuscated]

🤓 Solution

Turns out that npm publish must be executed at the root of the source package to upload flawlessly. It is still unknown to me if this is an issue with Nexus itself, or because we use a custom registry, but it is what it is.

The fix is quite easy, make sure to use the current package directory as the workingDir when invoking Node commands for publishing.

@Boubalou
Copy link
Contributor Author

Boubalou commented Jun 8, 2021

By the way, what a great plugin! Very well architectured and a breeze to configure. 🎩

@mpetuska
Copy link
Collaborator

mpetuska commented Jun 9, 2021

Oh wow, thanks for the PR! Odd that it requires to be in the package dir as we are passing that in from command line too.

@mpetuska mpetuska merged commit 73c0c8e into Kotlin:master Jun 9, 2021
@Boubalou Boubalou deleted the fix/npm-publish-task--working-dir branch June 9, 2021 12:38
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.

2 participants