Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/laravel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3,041 changes: 1,496 additions & 1,545 deletions examples/nuxtjs/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/vite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions examples/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/wasm-benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"prepare": "husky",
"e2e-tests": "./scripts/e2e-tests.sh",
"lint-staged": "lint-staged",
"test": "playwright test"
"test": "playwright test",
"audit-fix": "./scripts/audit-dependencies.sh"
},
"lint-staged": {
"*": ["biome check --write --no-errors-on-unmatched"]
Expand Down
54 changes: 54 additions & 0 deletions scripts/audit-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Runs npm/pnpm audit fix on all examples and outputs the result

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo -e "\033[37;1mAuditing npm vulnerabilities in examples\033[0m\r"

for dir in examples/*; do
if [ -d "$dir" ]; then

echo -e "\n\033[34;1m* $dir:\033[0m"

pushd "${SCRIPT_DIR}/../${dir}/" > /dev/null

result=0
initialresult=0

if [ -f "pnpm-lock.yaml" ]; then
# Check if the 'total' field exists and extract it if present
initialresult=$(pnpm audit --json | jq -r '.metadata.vulnerabilities.total // 0')

pnpm audit fix > /dev/null

# Capture vulnerabilities metadata using pnpm
result=$(pnpm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
elif [ -f "package-lock.json" ]; then
# Capture vulnerabilities metadata using npm
initialresult=$(npm audit --json | jq -r '.metadata.vulnerabilities.total // 0')

npm audit fix > /dev/null

# Capture vulnerabilities metadata using npm
result=$(npm audit --json | jq -r '.metadata.vulnerabilities.total // 0')
fi

# If vulnerabilities were found, output the result

if (( initialresult > 0 )); then
((fixed = initialresult - result))
echo -e " \033[93mFound: ${initialresult}\033[0m"
echo -e " \033[92mFixed: $fixed\033[0m"

if (( result > 0 )); then
echo -e " \033[31mRemaining: ${result}\033[0m"
else
echo -e " \033[92;1mAll fixed!\033[0m"
fi
else
echo -e " \033[34mNo npm vulnerabilities found\033[0m"
fi

popd > /dev/null
fi
done
Loading