Skip to content
Snippets Groups Projects
Commit fd0f04d7 authored by Thomas Caillier's avatar Thomas Caillier Committed by Pierre Smeyers
Browse files

fix: set node-publish default registry

parent 673e5cac
No related branches found
No related tags found
No related merge requests found
...@@ -420,7 +420,9 @@ It uses the following variables: ...@@ -420,7 +420,9 @@ It uses the following variables:
#### Configure the target registry #### Configure the target registry
The target registry url for publication shall be configured in the `publishConfig` of your `package.json` file. Examples: The target registry url for publication shall be configured in the `publishConfig` of your `package.json` file. \
If no registry is configured in `publishConfig`, it will publish to default target registry 'https://registry.npmjs.org/' only if `access` is set to 'public' in the `publishConfig` of your `package.json` file. \
Examples:
- for an unscoped package: - for an unscoped package:
......
...@@ -554,12 +554,14 @@ stages: ...@@ -554,12 +554,14 @@ stages:
pkg_fullname=$(node -pe "require('./package.json').name") pkg_fullname=$(node -pe "require('./package.json').name")
publish_registry_key=$(node -pe "parts='$pkg_fullname'.split('/');parts.length>1?parts[0]+':registry':'registry'") publish_registry_key=$(node -pe "parts='$pkg_fullname'.split('/');parts.length>1?parts[0]+':registry':'registry'")
publish_registry_url=$(node -pe "require('./package.json').publishConfig?.['$publish_registry_key'] || ''") publish_registry_url=$(node -pe "require('./package.json').publishConfig?.['$publish_registry_key'] || ''")
if [[ -z "$publish_registry_url" ]] publish_access=$(node -pe "require('./package.json').publishConfig?.access || ''")
if [[ -z "$publish_registry_url" ]] && [[ "$publish_access" != "public" ]]
then then
log_info "No publish registry url found in your package.json file" log_info "No publish registry url found in your package.json file, and publish access is not set to public"
log_info "Publish will only work if you're using GitLab project-level registry (use scope \\e[33;1m@${CI_PROJECT_ROOT_NAMESPACE}\\e[0m)" log_info "Publish will only work if you're using GitLab project-level registry (use scope \\e[33;1m@${CI_PROJECT_ROOT_NAMESPACE}\\e[0m)"
log_info "Otherwise, declare the target registry url under \\e[33;1m'publishConfig' > '$publish_registry_key'\\e[0m key in your package.json file..." log_info "Otherwise, declare the target registry url under \\e[33;1m'publishConfig' > '$publish_registry_key'\\e[0m key in your package.json file, or set 'public' access under \\e[33;1m'publishConfig' > 'access'\\e[0m to publish on default registry https://registry.npmjs.org/..."
else else
publish_registry_url="${publish_registry_url:-https://registry.npmjs.org/}"
log_info "Publish to \\e[33;1m$publish_registry_url\\e[0m..." log_info "Publish to \\e[33;1m$publish_registry_url\\e[0m..."
# maybe configure token # maybe configure token
if [[ "$NODE_PUBLISH_TOKEN" ]] if [[ "$NODE_PUBLISH_TOKEN" ]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment