Update version to 1.0.4 in package.json and enhance ci-deploy script with dependency check and improved version update logic.

This commit is contained in:
2025-11-22 22:15:46 -05:00
parent 4ee358c0df
commit dd39fd6fcb
2 changed files with 23 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@techniker-me/hash-map",
"version": "1.0.3",
"version": "1.0.4",
"description": "A robust HashMap implementation following OOP SOLID principles",
"module": "src/index.ts",
"type": "module",

View File

@@ -4,9 +4,13 @@ set -o errexit
set -o nounset
set -o pipefail
# Check dependencies
if ! command -v jq &> /dev/null; then
echo "Error: jq is required but not installed"
exit 1
fi
registryUrl="http://localhost:4873"
# registryUrl="https://registry-node.techniker.me"
registryUrl="https://npm.techniker.me"
packageVersionToDeploy=""
isBeta="false"
@@ -32,34 +36,19 @@ function cleanDirectory {
if [ -d "${directory}" ]; then
echo "Deleting [${directory}]..."
rm -rf "${directory}"
fi
}
function removePackageJsonMember {
local packageJsonPath="dist/package.json"
local memberToRemove="${1}"
if [ -f "${packageJsonPath}" ]; then
echo "Removing [${memberToRemove}] from the dist/package.json"
jq "del(.${memberToRemove})" "${packageJsonPath}" >tmp.$$.json && mv tmp.$$.json "$packageJsonPath"
else
echo "Error: [${packageJsonPath}] not found."
fi
}
function updatePackageJsonVersion {
local versionToUpdate="${1}"
local packageJsonPath="dist/package.json"
if [ isBeta == "true" ]; then
echo "Version to update [${versionToUpdate}] Contains beta"
echo "Updating package.json version to [${versionToUpdate}]"
if [ "${isBeta}" == "true" ]; then
echo "Updating package.json version to [${versionToUpdate}] (beta)"
local packageJsonVersion=$(jq -r '.version' package.json)
sed -i "s/\"version\": \"${packageJsonVersion}\"/\"version\": \"${versionToUpdate}\"/" dist/package.json
# Use jq for cross-platform compatibility
jq ".version = \"${versionToUpdate}\"" "${packageJsonPath}" > tmp.$$.json && mv tmp.$$.json "${packageJsonPath}"
fi
}
@@ -70,14 +59,16 @@ cleanDirectory "dist"
bun run ci-build
removePackageJsonMember "devDependencies"
removePackageJsonMember "scripts"
echo "publishing to ${registryUrl}"
if [ "${isBeta}" == "true" ]; then
# Update version if beta and version provided
if [ "${isBeta}" == "true" ] && [ -n "${packageVersionToDeploy}" ]; then
updatePackageJsonVersion "${packageVersionToDeploy}"
npm publish --registry "${registryUrl}" --tag beta
else
npm publish --registry "${registryUrl}"
fi
echo "Publishing to ${registryUrl}"
cd dist
if [ "${isBeta}" == "true" ]; then
bun publish --registry "${registryUrl}" --tag beta
else
bun publish --registry "${registryUrl}"
fi