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:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@techniker-me/hash-map",
|
"name": "@techniker-me/hash-map",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "A robust HashMap implementation following OOP SOLID principles",
|
"description": "A robust HashMap implementation following OOP SOLID principles",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ set -o errexit
|
|||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
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://npm.techniker.me"
|
||||||
# registryUrl="https://registry-node.techniker.me"
|
|
||||||
packageVersionToDeploy=""
|
packageVersionToDeploy=""
|
||||||
isBeta="false"
|
isBeta="false"
|
||||||
|
|
||||||
@@ -32,34 +36,19 @@ function cleanDirectory {
|
|||||||
|
|
||||||
if [ -d "${directory}" ]; then
|
if [ -d "${directory}" ]; then
|
||||||
echo "Deleting [${directory}]..."
|
echo "Deleting [${directory}]..."
|
||||||
|
|
||||||
rm -rf "${directory}"
|
rm -rf "${directory}"
|
||||||
fi
|
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 {
|
function updatePackageJsonVersion {
|
||||||
local versionToUpdate="${1}"
|
local versionToUpdate="${1}"
|
||||||
|
local packageJsonPath="dist/package.json"
|
||||||
|
|
||||||
if [ isBeta == "true" ]; then
|
if [ "${isBeta}" == "true" ]; then
|
||||||
echo "Version to update [${versionToUpdate}] Contains beta"
|
echo "Updating package.json version to [${versionToUpdate}] (beta)"
|
||||||
echo "Updating package.json version to [${versionToUpdate}]"
|
|
||||||
|
|
||||||
local packageJsonVersion=$(jq -r '.version' package.json)
|
# Use jq for cross-platform compatibility
|
||||||
|
jq ".version = \"${versionToUpdate}\"" "${packageJsonPath}" > tmp.$$.json && mv tmp.$$.json "${packageJsonPath}"
|
||||||
sed -i "s/\"version\": \"${packageJsonVersion}\"/\"version\": \"${versionToUpdate}\"/" dist/package.json
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,14 +59,16 @@ cleanDirectory "dist"
|
|||||||
|
|
||||||
bun run ci-build
|
bun run ci-build
|
||||||
|
|
||||||
removePackageJsonMember "devDependencies"
|
# Update version if beta and version provided
|
||||||
removePackageJsonMember "scripts"
|
if [ "${isBeta}" == "true" ] && [ -n "${packageVersionToDeploy}" ]; then
|
||||||
|
|
||||||
echo "publishing to ${registryUrl}"
|
|
||||||
if [ "${isBeta}" == "true" ]; then
|
|
||||||
updatePackageJsonVersion "${packageVersionToDeploy}"
|
updatePackageJsonVersion "${packageVersionToDeploy}"
|
||||||
npm publish --registry "${registryUrl}" --tag beta
|
|
||||||
else
|
|
||||||
npm publish --registry "${registryUrl}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Publishing to ${registryUrl}"
|
||||||
|
cd dist
|
||||||
|
|
||||||
|
if [ "${isBeta}" == "true" ]; then
|
||||||
|
bun publish --registry "${registryUrl}" --tag beta
|
||||||
|
else
|
||||||
|
bun publish --registry "${registryUrl}"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user