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:
@@ -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}]"
|
||||
|
||||
local packageJsonVersion=$(jq -r '.version' package.json)
|
||||
|
||||
sed -i "s/\"version\": \"${packageJsonVersion}\"/\"version\": \"${versionToUpdate}\"/" dist/package.json
|
||||
if [ "${isBeta}" == "true" ]; then
|
||||
echo "Updating package.json version to [${versionToUpdate}] (beta)"
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user