forked from cerc-io/stack-orchestrator
Working builds
This commit is contained in:
parent
1b0407ae3c
commit
c059745af9
@ -26,7 +26,7 @@ echo "Fixing up dependencies"
|
|||||||
for package in "${dependencies_from_scope[@]}"
|
for package in "${dependencies_from_scope[@]}"
|
||||||
do
|
do
|
||||||
echo "Fixing up package ${package}"
|
echo "Fixing up package ${package}"
|
||||||
yarn-local-registry-fixup.sh $package
|
yarn-local-registry-fixup.sh $package ${local_npm_registry_url}
|
||||||
done
|
done
|
||||||
echo "Running build"
|
echo "Running build"
|
||||||
build-npm-package.sh ${local_npm_registry_url} ${package_publish_version}
|
build-npm-package.sh ${local_npm_registry_url} ${package_publish_version}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Usage: yarn-local-registry-fixup.sh <package-to-fix>
|
# Usage: yarn-local-registry-fixup.sh <package-to-fix> <registry-url>
|
||||||
# Assumes package.json and yarn.lock are in the cwd
|
# Assumes package.json and yarn.lock are in the cwd
|
||||||
# The purpose of this script is to take a project cloned from git
|
# The purpose of this script is to take a project cloned from git
|
||||||
# and "fixup" its yarn.lock file such that specified dependency
|
# and "fixup" its yarn.lock file such that specified dependency
|
||||||
@ -10,16 +10,24 @@
|
|||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
if [[ $# -ne 1 ]]; then
|
if [[ $# -ne 2 ]]; then
|
||||||
echo "Illegal number of parameters" >&2
|
echo "Illegal number of parameters" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
target_package=$1
|
target_package=$1
|
||||||
|
local_npm_registry_url=$2
|
||||||
|
# TODO: use jq rather than sed here:
|
||||||
versioned_target_package=$(grep ${target_package} package.json | sed -e 's#[[:space:]]\{1,\}\"\('${target_package}'\)\":[[:space:]]\{1,\}\"\(.*\)\",#\1@\2#' )
|
versioned_target_package=$(grep ${target_package} package.json | sed -e 's#[[:space:]]\{1,\}\"\('${target_package}'\)\":[[:space:]]\{1,\}\"\(.*\)\",#\1@\2#' )
|
||||||
# Use yarn info to get URL checksums etc from the new registry
|
# Use yarn info to get URL checksums etc from the new registry
|
||||||
yarn_info_output=$(yarn info --json $versioned_target_package 2>/dev/null)
|
yarn_info_output=$(yarn info --json $versioned_target_package 2>/dev/null)
|
||||||
# Code below parses out the values we need
|
# Code below parses out the values we need
|
||||||
package_tarball=$(echo $yarn_info_output | jq -r .data.dist.tarball)
|
package_tarball=$(echo $yarn_info_output | jq -r .data.dist.tarball)
|
||||||
|
# When running inside a container, the registry can return a URL with the wrong host name due to proxying
|
||||||
|
# so we need to check if that has happened and fix the URL if so.
|
||||||
|
if ! [[ "${package_tarball}" =~ ^${local_npm_registry_url}.* ]]; then
|
||||||
|
# HACK: I've hard-wired the host names below. Replace with proper implementation
|
||||||
|
package_tarball=$( echo ${package_tarball} | sed -e 's/localhost/host.docker.internal/g' )
|
||||||
|
fi
|
||||||
package_integrity=$(echo $yarn_info_output | jq -r .data.dist.integrity)
|
package_integrity=$(echo $yarn_info_output | jq -r .data.dist.integrity)
|
||||||
package_shasum=$(echo $yarn_info_output | jq -r .data.dist.shasum)
|
package_shasum=$(echo $yarn_info_output | jq -r .data.dist.shasum)
|
||||||
package_resolved=${package_tarball}#${package_shasum}
|
package_resolved=${package_tarball}#${package_shasum}
|
||||||
@ -33,5 +41,6 @@ if [ -n "$CERC_SCRIPT_VERBOSE" ]; then
|
|||||||
echo "Resolved: ${package_resolved}"
|
echo "Resolved: ${package_resolved}"
|
||||||
fi
|
fi
|
||||||
# Use magic sed regex to replace the values in yarn.lock
|
# Use magic sed regex to replace the values in yarn.lock
|
||||||
|
# Note: yarn.lock is not json so we can not use jq for this
|
||||||
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}resolved \).*$/\1'\"${escaped_package_resolved}\"'/' yarn.lock
|
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}resolved \).*$/\1'\"${escaped_package_resolved}\"'/' yarn.lock
|
||||||
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}integrity \).*$/\1'${package_integrity}'/' yarn.lock
|
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}integrity \).*$/\1'${package_integrity}'/' yarn.lock
|
||||||
|
Loading…
Reference in New Issue
Block a user