fix: run catalog checks outside Unity containers
This commit is contained in:
@@ -25,20 +25,41 @@ fi
|
||||
published_value() {
|
||||
local package_name="$1"
|
||||
local property_name="$2"
|
||||
node --input-type=module - "$published_catalog" "$package_name" "$property_name" <<'NODE'
|
||||
import { readFileSync } from 'node:fs';
|
||||
local value
|
||||
value="$(awk -v package_name="$package_name" -v property_name="$property_name" '
|
||||
index($0, "\"" package_name "\"") {
|
||||
in_package = 1
|
||||
next
|
||||
}
|
||||
in_package && index($0, "\"" property_name "\"") {
|
||||
value = $0
|
||||
sub(/^[^:]*:[[:space:]]*"/, "", value)
|
||||
sub(/".*$/, "", value)
|
||||
print value
|
||||
found = 1
|
||||
exit
|
||||
}
|
||||
in_package && /^[[:space:]]*}/ {
|
||||
exit
|
||||
}
|
||||
END {
|
||||
if (!found) exit 1
|
||||
}
|
||||
' "$published_catalog")" || {
|
||||
echo "Published catalog value is missing: ${package_name}.${property_name}" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
const [, , catalogPath, packageName, propertyName] = process.argv;
|
||||
const catalog = JSON.parse(readFileSync(catalogPath, 'utf8'));
|
||||
const value = catalog.packages?.[packageName]?.[propertyName];
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
throw new Error(`Published catalog value is missing: ${packageName}.${propertyName}`);
|
||||
}
|
||||
if (propertyName === 'version' && !/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(value)) {
|
||||
throw new Error(`Published catalog version is invalid: ${packageName}=${value}`);
|
||||
}
|
||||
process.stdout.write(value);
|
||||
NODE
|
||||
if [[ -z "$value" ]]; then
|
||||
echo "Published catalog value is empty: ${package_name}.${property_name}" >&2
|
||||
return 1
|
||||
fi
|
||||
if [[ "$property_name" == "version" && ! "$value" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
|
||||
echo "Published catalog version is invalid: ${package_name}=${value}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
export SHRINKSDK_PUBLISHED_STARTER_VERSION="$(published_value com.cneicy.shrink-app-starter-basic version)"
|
||||
|
||||
Reference in New Issue
Block a user