nodejs-packaging-bundler: sanitize package name
The NPM package name might contain invalid characters, e.g. `@bitwarden/cli`. Normalize the generated bundles by converting `/` to `-`. ``` specs/nodejs on master ❯ ~/src/fedora/pkgs-others/nodejs-packaging/nodejs-packaging-bundler @bitwarden/cli ... Successful dev dependences download '@bitwarden-cli-1.13.3-bundled-licenses.txt' -> '/home/michel/rpmbuild/SOURCES/@bitwarden-cli-1.13.3-bundled-licenses.txt' '@bitwarden-cli-1.13.3-nm-dev.tgz' -> '/home/michel/rpmbuild/SOURCES/@bitwarden-cli-1.13.3-nm-dev.tgz' '@bitwarden-cli-1.13.3-nm-prod.tgz' -> '/home/michel/rpmbuild/SOURCES/@bitwarden-cli-1.13.3-nm-prod.tgz' ``` Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
This commit is contained in:
parent
05a9e58997
commit
7d1699cedc
@ -41,7 +41,8 @@ if [ $# -ge 2 ]; then
|
|||||||
else
|
else
|
||||||
VERSION="$(npm view ${PACKAGE} version)"
|
VERSION="$(npm view ${PACKAGE} version)"
|
||||||
fi
|
fi
|
||||||
|
# the package name might contain invalid characters, sanitize first
|
||||||
|
PACKAGE_SAFE=$(echo $PACKAGE | sed -e 's|/|-|g')
|
||||||
TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
|
TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
|
||||||
mkdir -p ${OUTPUT_DIR}
|
mkdir -p ${OUTPUT_DIR}
|
||||||
mkdir -p ${TMP_DIR}
|
mkdir -p ${TMP_DIR}
|
||||||
@ -59,10 +60,10 @@ else
|
|||||||
mv node_modules/ node_modules_prod
|
mv node_modules/ node_modules_prod
|
||||||
fi
|
fi
|
||||||
echo "LICENSES IN BUNDLE:"
|
echo "LICENSES IN BUNDLE:"
|
||||||
find . -name "package.json" -exec jq .license {} \; >> ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt
|
find . -name "package.json" -exec jq .license {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt
|
||||||
find . -name "package.json" -exec jq '.licenses[] .type' {} \; >> ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt 2>/dev/null
|
find . -name "package.json" -exec jq '.licenses[] .type' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt 2>/dev/null
|
||||||
sed -i "/^null$/d" ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt
|
sed -i "/^null$/d" ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt
|
||||||
sort -u -o ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt
|
sort -u -o ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt
|
||||||
echo " Downloading dev dependencies"
|
echo " Downloading dev dependencies"
|
||||||
npm install --no-optional --only=dev
|
npm install --no-optional --only=dev
|
||||||
if [ $? -ge 1 ] ; then
|
if [ $? -ge 1 ] ; then
|
||||||
@ -72,12 +73,12 @@ else
|
|||||||
mv node_modules/ node_modules_dev
|
mv node_modules/ node_modules_dev
|
||||||
fi
|
fi
|
||||||
if [ -d node_modules_prod ] ; then
|
if [ -d node_modules_prod ] ; then
|
||||||
tar cfz ../${PACKAGE}-${VERSION}-nm-prod.tgz node_modules_prod
|
tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-prod.tgz node_modules_prod
|
||||||
fi
|
fi
|
||||||
if [ -d node_modules_dev ] ; then
|
if [ -d node_modules_dev ] ; then
|
||||||
tar cfz ../${PACKAGE}-${VERSION}-nm-dev.tgz node_modules_dev
|
tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-dev.tgz node_modules_dev
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
cp -v ${PACKAGE}-${VERSION}* $HOME/rpmbuild/SOURCES
|
cp -v ${PACKAGE_SAFE}-${VERSION}* $HOME/rpmbuild/SOURCES
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
rm -rf ${TMP_DIR}
|
rm -rf ${TMP_DIR}
|
||||||
|
Loading…
Reference in New Issue
Block a user