Skip to content

Commit

Permalink
improve webflow devlink sync to be more minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
ludvigalden committed Jan 29, 2024
1 parent b8cf5ba commit 8753987
Show file tree
Hide file tree
Showing 75 changed files with 770 additions and 2,148 deletions.
47 changes: 47 additions & 0 deletions front-end/delete_unused_devlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Define the directory to search for .tsx files
searchDirs=("src/pages" "src/renderer" "src/components")

# Define the patterns to ignore
ignorePatterns=("devlink" "devlinkContext" "index" "interactions" "types" "utils" "Navbar" "Notification" "CafeOpeningHours" "PubOpeningHours")

# Find all .js and .d.ts files in ./src/devlink/
find ./src/devlink -maxdepth 1 -type f \( -name "*.js" -o -name "*.d.ts" \) | while read filepath; do
# Extract the basename without extension
basename=$(basename "$filepath" | sed 's/\.[^.]*$//')

# Flag to indicate if the file should be skipped
skipFile=0

# Skip if basename matches ignore patterns
for pattern in "${ignorePatterns[@]}"; do
if [[ "$basename" == *"$pattern"* ]]; then
skipFile=1
break
fi
done

if [[ $skipFile -eq 1 ]]; then
continue
fi

# Flag to indicate if the basename was found
found=0

# Search for the basename in .tsx files within specified directories
for dir in "${searchDirs[@]}"; do
if grep -qr --include="*.tsx" "$basename" "$dir"; then
found=1
break
fi
done

# If basename not found in any .tsx file, delete the original file
if [[ $found -eq 0 ]]; then
echo "Deleting unmatched file: $filepath"
rm "$filepath"
fi
done

echo "Cleanup complete."
3 changes: 2 additions & 1 deletion front-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"========= Only allow pnpm; forbid yarn & npm": "",
"preinstall": "npx only-allow pnpm",
"========= Synchronize and format Webflow component code (formatting multiple times for sorted keys)": "",
"sync-webflow": "webflow devlink sync && pnpm lint-webflow",
"sync-webflow": "webflow devlink sync && pnpm clean-webflow && pnpm lint-webflow",
"clean-webflow": "bash delete_unused_devlink.sh",
"lint-webflow": "eslint --fix \"src/devlink/**\"; eslint --fix \"src/devlink/**\"; eslint --fix \"src/devlink/**\"; eslint --fix \"src/devlink/**\""
},
"dependencies": {
Expand Down
5 changes: 0 additions & 5 deletions front-end/src/devlink/AbbreviatedNameParagraph.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions front-end/src/devlink/AbbreviatedNameParagraph.js

This file was deleted.

5 changes: 0 additions & 5 deletions front-end/src/devlink/BoardMembersImageSlider.d.ts

This file was deleted.

62 changes: 0 additions & 62 deletions front-end/src/devlink/BoardMembersImageSlider.js

This file was deleted.

5 changes: 0 additions & 5 deletions front-end/src/devlink/BoardMembersImageSliderSection.d.ts

This file was deleted.

79 changes: 0 additions & 79 deletions front-end/src/devlink/BoardMembersImageSliderSection.js

This file was deleted.

12 changes: 0 additions & 12 deletions front-end/src/devlink/CommonLinks.d.ts

This file was deleted.

44 changes: 0 additions & 44 deletions front-end/src/devlink/CommonLinks.js

This file was deleted.

14 changes: 0 additions & 14 deletions front-end/src/devlink/ContactCard.d.ts

This file was deleted.

75 changes: 0 additions & 75 deletions front-end/src/devlink/ContactCard.js

This file was deleted.

5 changes: 0 additions & 5 deletions front-end/src/devlink/ContactCardsStudiebevakare.d.ts

This file was deleted.

Loading

0 comments on commit 8753987

Please sign in to comment.