-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: rpc docs * chore: rpc dockerfile * chore: node env * chore: ignore cve * chore: production packages * chore: update comment * chore: code review * chore: code review * chore: fix * chore: fix * Revert "chore: fix" This reverts commit b20a93c. * chore: fix * chore: add back trivy ignore
- Loading branch information
1 parent
9999f37
commit 75fb28d
Showing
3 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75fb28d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test Coverage
Summary