Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust scripts to use npx #321

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 12 additions & 11 deletions scripts/indexer-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
## Using the Script
### Suggested to run from the current directory being Prowlarr/Indexers local Repo using Git Bash `./scripts/prowlarr-indexers-jackettpull.sh`

# Check if Required NPM Modules are installed and install if needed
package_servarr='ajv-cli-servarr'
package_formats='ajv-formats'
if [ "$(npm list -g | grep -c $package_servarr)" -eq 0 ]; then
echo "$package_servarr npm package missing. installing"
npm -g install $package_servarr
if ! command -v npx &> /dev/null
then
echo "npx could not be found. check your node installation"
exit 1
fi
if [ "$(npm list -g | grep -c $package_formats)" -eq 0 ]; then
echo "$package_formats npm package missing. installing"
npm -g install $package_formats

# Check if Required NPM Modules are installed
if ! npm list --depth=0 ajv-cli-servarr &> /dev/null || ! npm list --depth=0 ajv-formats &> /dev/null
then
echo "required npm packages are missing, you should run \"npm install\""
exit 2
fi

## Enhanced Logging
Expand Down Expand Up @@ -317,7 +318,7 @@ function determine_best_schema_version() {
dir="definitions/v$i"
schema="$dir/schema.json"
echo "checking file [$def_file] against schema [$schema]"
ajv test -d "$def_file" -s "$schema" --valid -c ajv-formats
npx ajv test -d "$def_file" -s "$schema" --valid -c ajv-formats
test_resp=$?
if [ $test_resp -eq 0 ]; then
echo "Definition [$def_file] matches schema [$schema]"
Expand All @@ -341,7 +342,7 @@ function determine_schema_version() {
dir="definitions/$check_version"
schema="$dir/schema.json"
echo "checking file against schema [$schema]"
ajv test -d "$def_file" -s "$schema" --valid -c ajv-formats
npx ajv test -d "$def_file" -s "$schema" --valid -c ajv-formats
test_resp=$?
if [ $test_resp -eq 0 ]; then
echo "Definition [$def_file] matches schema [$schema]"
Expand Down
15 changes: 15 additions & 0 deletions scripts/validate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

set -euo pipefail

if ! command -v npx &> /dev/null
then
echo "npx could not be found. check your node installation"
exit 1
fi

# Check if Required NPM Modules are installed
if ! npm list --depth=0 ajv-cli-servarr &> /dev/null || ! npm list --depth=0 ajv-formats &> /dev/null
then
echo "required npm packages are missing, you should run \"npm install\""
exit 2
fi

# declare empty array to collect failed definitions
failed_defs=()

Expand Down