Skip to content

Commit

Permalink
chore: dev dependencies removed (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonneal authored Jan 27, 2025
1 parent c4504bc commit 8ab64d5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker/rpc-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ COPY ./package.json ./package.json
COPY ./turbo.json ./turbo.json
COPY ./yarn.lock ./yarn.lock
COPY ./tsconfig.json ./tsconfig.json
COPY ./docker/rpc-proxy/adjust-packages.sh ./adjust-packages.sh

# Install all the dependencies and build the app
RUN yarn install && yarn build

# Clean the package.json files ready for production
RUN apk add --no-cache jq
RUN chmod +x ./adjust-packages.sh
RUN /bin/sh ./adjust-packages.sh ./

# Stage 2: Serve the app using node
FROM node:20.17.0-alpine3.20 AS runner

Expand Down
48 changes: 48 additions & 0 deletions docker/rpc-proxy/adjust-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# -----------------------------------------------------------------------------
# Info:
# - input: directory to search for package.json files
# - output:
# package.json without devDependencies section
# package.json without version selectors in dependencies
# -----------------------------------------------------------------------------

# Check if the search directory is provided
if [ -z "$1" ]; then
echo "Usage: $0 <path-to-directory>"
exit 1
fi
SEARCH_DIR="$1"

# Check if the search directory exists
if [ ! -d "$SEARCH_DIR" ]; then
echo "Error: Directory '$SEARCH_DIR' not found."
exit 1
fi


# Find all package.json files in the specified directory (excluding node_modules)
find "$SEARCH_DIR" -type f -name "package.json" ! -path "*/node_modules/*" | while read PACKAGE_JSON; do
echo "Processing: $PACKAGE_JSON"


# Remove the "devDependencies" section and overwrite the file
if jq -e '.devDependencies' "$PACKAGE_JSON" > /dev/null; then
jq 'del(.devDependencies)' "$PACKAGE_JSON" > temp.json && mv temp.json "$PACKAGE_JSON"
echo "devDependencies removed from $PACKAGE_JSON"
else
echo "No devDependencies section found in $PACKAGE_JSON. No changes made."
fi

# Remove version selectors from dependencies
# Check if the dependencies section exists in the package.json file
if jq -e '.dependencies' "$PACKAGE_JSON" > /dev/null; then
# Remove version selectors from dependencies
jq '(.dependencies |= with_entries(.value |= ltrimstr("^") | ltrimstr("~")))' "$PACKAGE_JSON" > temp.json && mv temp.json "$PACKAGE_JSON"
echo "Version selectors (caret/tilde) removed from dependencies in $PACKAGE_JSON"
else
echo "No dependencies section found in $PACKAGE_JSON. No changes made."
fi

done

1 comment on commit 8ab64d5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 98%
98.93% (4378/4425) 96.95% (1400/1444) 98.9% (906/916)
Title Tests Skipped Failures Errors Time
core 836 0 πŸ’€ 0 ❌ 0 πŸ”₯ 2m 30s ⏱️
network 731 0 πŸ’€ 0 ❌ 0 πŸ”₯ 5m 6s ⏱️
errors 40 0 πŸ’€ 0 ❌ 0 πŸ”₯ 18.324s ⏱️
logging 3 0 πŸ’€ 0 ❌ 0 πŸ”₯ 19.446s ⏱️
hardhat-plugin 19 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 10s ⏱️
aws-kms-adapter 23 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 31s ⏱️
ethers-adapter 5 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 20s ⏱️
rpc-proxy 37 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 7s ⏱️

Please sign in to comment.