Scope npm registry in drone template to @aetoskia

The registry was set globally (
egistry=...), which forced all public
transitive deps through the private Verdaccio. Verdaccio has no uplink,
so
pm install 404'd on public packages. Scope the registry to
@aetoskia:registry=... so public deps resolve from npmjs and only
@aetoskia/* go to the private registry.
This commit is contained in:
2026-10-21 01:29:00 +05:30
parent 08a9983984
commit da1e46a921
2 changed files with 16 additions and 8 deletions

View File

@@ -30,7 +30,8 @@ steps:
exit 1
fi
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > /tmp/.npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > /tmp/.npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> /tmp/.npmrc
echo "Checking if $PACKAGE_NAME@$VERSION exists on $NPM_REPO_URL ..."
if npm view "$PACKAGE_NAME@$VERSION" version --userconfig /tmp/.npmrc >/dev/null 2>&1; then
@@ -56,7 +57,8 @@ steps:
exit 1
fi
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > .npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > .npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> .npmrc
- npm install
- echo "Running quality gate..."
@@ -82,7 +84,8 @@ steps:
commands:
- |
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > .npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > .npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> .npmrc
- echo "Publishing to private npm at $NPM_REPO_URL ..."
- npm publish --access restricted
@@ -122,7 +125,8 @@ steps:
- apk add --no-cache git
- |
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > /tmp/.npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > /tmp/.npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> /tmp/.npmrc
- |
set -e

View File

@@ -30,7 +30,8 @@ steps:
exit 1
fi
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > /tmp/.npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > /tmp/.npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> /tmp/.npmrc
echo "Checking if $PACKAGE_NAME@$VERSION exists on $NPM_REPO_URL ..."
if npm view "$PACKAGE_NAME@$VERSION" version --userconfig /tmp/.npmrc >/dev/null 2>&1; then
@@ -56,7 +57,8 @@ steps:
exit 1
fi
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > .npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > .npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> .npmrc
- npm install
- echo "Running quality gate..."
@@ -82,7 +84,8 @@ steps:
commands:
- |
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > .npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > .npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> .npmrc
- echo "Publishing to private npm at $NPM_REPO_URL ..."
- npm publish --access restricted
@@ -122,7 +125,8 @@ steps:
- apk add --no-cache git
- |
NPM_HOST=$(echo "$NPM_REPO_URL" | sed -E 's|^[a-z]+://||; s|/*$||')
echo "registry=$NPM_REPO_URL" > /tmp/.npmrc
NPM_SCOPE="@$(node -p "require('./package.json').name.split('/')[0].replace(/^@/,'')")"
echo "$NPM_SCOPE:registry=$NPM_REPO_URL" > /tmp/.npmrc
echo "//$NPM_HOST/:_auth=$(echo -n "$NPM_USERNAME:$NPM_PASSWORD" | base64 | tr -d '\n')" >> /tmp/.npmrc
- |
set -e