Skip to content

Commit

Permalink
suggestion from ai
Browse files Browse the repository at this point in the history
  • Loading branch information
PurnenduMIshra129th committed Jan 13, 2025
1 parent f58b8f5 commit 33ab4d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ These scripts help analyze the difference between production and development dep
- Identifies dev-only dependencies used in the production code.
- Moves required dependencies from `devDependencies` to `dependencies` in `package.json`.
2. **Validation**
2. **Backup of `package.json`**
- Before making changes, the script creates a backup file `package.json.bak` for safety.
3. **Validation**
- The script checks if a dependency is used in the production code (default: `./src` folder).
- Modify the script if your codebase structure differs.
Expand Down
2 changes: 1 addition & 1 deletion scripts/deps/analyze-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [ "$NODE_ENV" = "production" ]; then
echo "Skipping npm install in production environment"
else
echo "Installing dependencies (if necessary) to ensure npm ls commands run accurately..."
npm install
npm install --no-save
fi

echo "Generating list of production dependencies (top-level only)..."
Expand Down
9 changes: 8 additions & 1 deletion scripts/deps/move-from-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ echo "$DEV_ONLY_PACKAGES"
# Temporary file to store required production dependencies
REQUIRED_FOR_PRODUCTION_FILE=$(mktemp)

# Allow configuration of source directory
SOURCE_DIR=${SOURCE_DIR:-"./src"}

for PACKAGE in $DEV_ONLY_PACKAGES; do
echo "Checking if $PACKAGE is used in production..."

# Use grep to check if the package name appears in the production code
if grep -qr "$PACKAGE" ./src; then
if grep -qr "$PACKAGE" "$SOURCE_DIR"; then
echo "$PACKAGE is required in production."
echo "$PACKAGE" >> "$REQUIRED_FOR_PRODUCTION_FILE"
else
Expand All @@ -48,6 +51,10 @@ fi
echo "The following dev dependencies are required in production:"
cat "$REQUIRED_FOR_PRODUCTION_FILE"

# Backup package.json
echo "Creating backup of package.json..."
cp package.json package.json.bak

# Move required dependencies to production dependencies
while IFS= read -r PACKAGE; do
echo "Moving $PACKAGE to dependencies..."
Expand Down

0 comments on commit 33ab4d1

Please sign in to comment.