Npm package.json has wrong project scope name after merge request for package registry

I am using Gitlab Self hosted with docker, version 13.11.2

Person A has a public Project in his personal namespace (/personA/exampleProject)

Person B (me) has forked the project into my personal namespace (/personB/exampleProject)

I am working on this project via merge request, this is all working as it is supposed to work.

This Project is a npm package.

But the following problem started to arise: I want wo make a ci/cd pipeline to push the npm package to the gitlab pipeline to that I can use it in other projects via the package.json dependencies.

This is my .gitlab-ci.yml (only the relevant part of it):

npm publish:
  stage: publish
  before_script:
  - "uname -a"
  - "npm config set @${CI_PROJECT_ROOT_NAMESPACE}:registry=https://git.domain.tld/api/v4/projects/${CI_PROJECT_ID}/packages/npm/"
  - "npm config set //git.domain.tld/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}"
  - "npm config set //git.domain.tld/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}"
  
  script:
- npm i
- npm run build
- "npm version prerelease --preid commit-$CI_COMMIT_SHORT_SHA"
- "npm publish --tag git-latest-commit"
`

And in the package.json file I changed to project name to the scope (also in package-lock.json):

  "name": "@personB/exampleProject"

The pipeline is working properly and publish the package successfully to personB’s npm package registry.

Now I wanted to make a merge request But I realised that the pipeline would be broken, because in the config files there is the wrong user namespace configured (package.json and package-lock.json the project name’s scope “@personB/exampleProject”)

So my question is:
How can I change this settings (the name of the project in the pacakge.json and package-lock.json) on the fly in the gitlab pipeline or how can this differ for personA’s and personB’s project

My only guess is to make a small script which gets the json of both package*.json files and replace the name of the project to add the correct scope, but I think this is not how it is supposed to be

Thanks :slight_smile:

Has someone any ideas or a link with more information?