Skip to content

Publish in custom artifactory #424

Description

@gethari

After spending lot of time, I looked into the code & found that, the regex pattern is always matching for only registries pointing to npm. In my case we have a custom artifactory the URL that looks like //art01.spotifycloud.io

action/src/index.ts

Lines 62 to 64 in 31ff97e

const authLine = userNpmrcContent.split("\n").find((line) => {
// check based on https://github.com/npm/cli/blob/8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed/test/lib/adduser.js#L103-L105
return /^\s*\/\/registry\.npmjs\.org\/:[_-]authToken=/i.test(line);

Suggested solution

we can generalized the Regex and avoid hardcoding

const authLine = userNpmrcContent.split("\n").find((line) => {
  // Dynamically adapt to any registry by looking for :_authToken= pattern
  return /^\s*\/\/.*\/:[_-]authToken=/i.test(line);
});

Activity

  1. added 2 commits that reference this issue on Nov 19, 2024
    8669687
    958ee58
  2. Andarist commented on Nov 21, 2024

    @Andarist
    Member

    Shouldn't it just work if you create .npmrc with a content like this?

    //art01.spotifycloud.io/:_authToken=YOUR_TOKEN
    

    I don't understand when the logic falls apart right now.

  3. gethari commented on Nov 21, 2024

    @gethari
    Author

    @Andarist , I already had created my .npmrc as you suggested, but the catch here I forgot to highlight is, I am using a Auth _auth variable & not _authToken & I think that is also one of the reason's the code is going into the else.. condition

    I have updated my PR for this fix as well, thanks for the input 👍

  4. added a commit that references this issue on Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions