Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishMadan2882 committed Aug 28, 2024
1 parent 130eb56 commit a83a56e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions extensions/react-widget/publish.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
#!/bin/bash
## chmod +x publish.sh - to upgrade ownership
# Exit immediately if a command exits with a non-zero status.
## chmod +x publish.sh - to upgrade ownership
set -e

# Define the function to update package.json and publish the package
cat package.json >> package_copy.json
publish_package() {
PACKAGE_NAME=$1
BUILD_COMMAND=$2
# Update package name in package.json
jq --arg name "$PACKAGE_NAME" '.name=$name' package.json > temp.json && mv temp.json package.json

# Remove 'target' key if the package name is 'widget-react'
# Remove 'target' key if the package name is 'docsgpt-react'
if [ "$PACKAGE_NAME" = "docsgpt-react" ]; then
jq 'del(.targets)' package.json > temp.json && mv temp.json package.json
fi

if [ -d "dist" ]; then
echo "Deleting existing dist directory..."
rm -rf dist
fi
# Increment version (patch by default)
#npm version patch

# Run the build command
npm version patch

npm run "$BUILD_COMMAND"

# Publish to npm
npm pack
npm publish
echo "Published ${PACKAGE_NAME}"
}

# Publish widget package
# Publish docsgpt package
publish_package "docsgpt" "build"

# Publish widget-react package
# Publish docsgpt-react package
publish_package "docsgpt-react" "build:react"

# Clean up
Expand Down

0 comments on commit a83a56e

Please sign in to comment.