@sudoplatform/sudo-common 6.0.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,17 +1,94 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function version_diff_type() {
|
|
4
|
+
v1="$1"
|
|
5
|
+
v2="$2"
|
|
6
|
+
v1_major=$(echo $v1 | sed -E -e 's/^([^.]+)\..*/\1/')
|
|
7
|
+
v2_major=$(echo $v2 | sed -E -e 's/^([^.]+)\..*/\1/')
|
|
8
|
+
v1_minor=$(echo $v1 | sed -E -e 's/^([^.]+)\.([^.]+)\..*/\2/')
|
|
9
|
+
v2_minor=$(echo $v2 | sed -E -e 's/^([^.]+)\.([^.]+)\..*/\2/')
|
|
10
|
+
if [ "${v1_major}" != "${v2_major}" ]; then echo 'major'; return 0; fi
|
|
11
|
+
if [ "${v1_minor}" != "${v2_minor}" ]; then echo 'minor'; return 0; fi
|
|
12
|
+
if [ "${v1}" != "${v2}" ]; then echo 'patch'; return 0; fi
|
|
13
|
+
echo 'equal'
|
|
14
|
+
return 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function suppression_from_diff_type() {
|
|
18
|
+
diff_type="$1"
|
|
19
|
+
majorSuppression="$2"
|
|
20
|
+
minorSuppression="$3"
|
|
21
|
+
patchSuppression="$4"
|
|
22
|
+
|
|
23
|
+
case "${diff_type}" in
|
|
24
|
+
major)
|
|
25
|
+
if [ -n "${majorSuppression}" ]; then
|
|
26
|
+
echo "major ${majorSuppression}"
|
|
27
|
+
elif [ -n "${minorSuppression}" ]; then
|
|
28
|
+
echo "minor ${minorSuppression}"
|
|
29
|
+
elif [ -n "${patchSuppression}" ]; then
|
|
30
|
+
echo "patch ${patchSuppression}"
|
|
31
|
+
fi
|
|
32
|
+
;;
|
|
33
|
+
minor)
|
|
34
|
+
if [ -n "${minorSuppression}" ]; then
|
|
35
|
+
echo "minor ${minorSuppression}"
|
|
36
|
+
elif [ -n "${patchSuppression}" ]; then
|
|
37
|
+
echo "patch ${patchSuppression}"
|
|
38
|
+
fi
|
|
39
|
+
;;
|
|
40
|
+
patch)
|
|
41
|
+
if [ -n "${patchSuppression}" ]; then
|
|
42
|
+
echo "patch ${patchSuppression}"
|
|
43
|
+
fi
|
|
44
|
+
;;
|
|
45
|
+
esac
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
yarn outdated --json | jq -r -s -c 'map(select(.type == "table").data.body) | .[] | unique_by(.[0]) | .[] | .[0] + " " + .[1] + " " + .[2] + " " + .[3]' | (new=""; while read package_name current wanted latest; do
|
|
49
|
+
majorSuppression=$(jq ".outdatedSuppressions.major[\"${package_name}\"] | select (. != null)" package.json)
|
|
50
|
+
minorSuppression=$(jq ".outdatedSuppressions.minor[\"${package_name}\"] | select (. != null)" package.json)
|
|
51
|
+
patchSuppression=$(jq ".outdatedSuppressions[\"${package_name}\"] | select (. != null)" package.json)
|
|
52
|
+
latest_diff_type=$(version_diff_type "${current}" "${latest}")
|
|
53
|
+
wanted_diff_type=$(version_diff_type "${current}" "${wanted}")
|
|
54
|
+
|
|
55
|
+
set -- $(suppression_from_diff_type "${latest_diff_type}" "${majorSuppression}" "${minorSuppression}" "${patchSuppression}")
|
|
56
|
+
latest_suppression_type="$1"
|
|
57
|
+
latest_suppression="$2"
|
|
58
|
+
|
|
59
|
+
set -- $(suppression_from_diff_type "${wanted_diff_type}" "${majorSuppression}" "${minorSuppression}" "${patchSuppression}")
|
|
60
|
+
wanted_suppression_type="$1"
|
|
61
|
+
wanted_suppression="$2"
|
|
62
|
+
|
|
63
|
+
# If package has major update but isn't suppre
|
|
64
|
+
suppression=""
|
|
65
|
+
suppression_type=""
|
|
66
|
+
outdated_diff_type="${latest_diff_type}"
|
|
67
|
+
if [ -n "${latest_suppression_type}" ]; then
|
|
68
|
+
if [ "${wanted_diff_type}" != "equal" ]; then
|
|
69
|
+
outdated_diff_type="${wanted_diff_type}"
|
|
70
|
+
if [ -n "${wanted_suppression_type}" ]; then
|
|
71
|
+
suppression_type="${wanted_suppression_type}"
|
|
72
|
+
suppression="${wanted_suppression}"
|
|
73
|
+
else
|
|
74
|
+
# Only suppressed at major level and we have minor or patch
|
|
75
|
+
# updates available - do not suppress
|
|
76
|
+
:
|
|
77
|
+
fi
|
|
78
|
+
else
|
|
79
|
+
suppression_type="${latest_suppression_type}"
|
|
80
|
+
suppression="${latest_suppression}"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
if [ -z "${suppression}" ]; then
|
|
85
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} outdated]"
|
|
8
86
|
new=1
|
|
9
|
-
elif [ $(date '+%s') -gt "$suppression" ]; then
|
|
10
|
-
echo "
|
|
11
|
-
echo "${package_name}" | jq .
|
|
87
|
+
elif [ $(date '+%s') -gt "${suppression}" ]; then
|
|
88
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppression expired]"
|
|
12
89
|
new=1
|
|
13
90
|
else
|
|
14
|
-
echo "
|
|
91
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppressed]"
|
|
15
92
|
fi
|
|
16
93
|
done
|
|
17
94
|
if [ -n "${new}" ]; then
|
package/bin/suppress-outdated.sh
CHANGED
|
@@ -3,13 +3,31 @@
|
|
|
3
3
|
# Insert a package name to suppress in outdated checks.
|
|
4
4
|
#
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
case "$1" in
|
|
7
|
+
--major)
|
|
8
|
+
root=".outdatedSuppressions.major"
|
|
9
|
+
;;
|
|
10
|
+
--minor)
|
|
11
|
+
root=".outdatedSuppressions.minor"
|
|
12
|
+
;;
|
|
13
|
+
--patch)
|
|
14
|
+
root=".outdatedSuppressions"
|
|
15
|
+
;;
|
|
16
|
+
*)
|
|
17
|
+
echo "suppress-outdated.sh: Unrecognized option: '$1'" 1>&2
|
|
18
|
+
echo "Usage: suppress-outdated.sh {--major|--minor|--patch} <package name>" 1>&2
|
|
19
|
+
exit 1
|
|
20
|
+
;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
package_name="$2"
|
|
7
24
|
PACKAGE_JSON="package.json"
|
|
8
25
|
|
|
9
26
|
if [ -z "$package_name" ]; then
|
|
10
|
-
echo "Usage: yarn suppress-outdated <package name>"
|
|
27
|
+
echo "Usage: yarn suppress-outdated {--major|--minor|--patch} <package name>"
|
|
11
28
|
exit 1
|
|
12
29
|
fi
|
|
30
|
+
|
|
13
31
|
cp $PACKAGE_JSON $PACKAGE_JSON.old
|
|
14
|
-
cat $PACKAGE_JSON | jq "
|
|
32
|
+
cat $PACKAGE_JSON | jq "${root}.\"${package_name}\" = (now | floor | . + 1209600)" > $PACKAGE_JSON.staging
|
|
15
33
|
mv $PACKAGE_JSON.staging $PACKAGE_JSON
|
|
@@ -1,17 +1,94 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function version_diff_type() {
|
|
4
|
+
v1="$1"
|
|
5
|
+
v2="$2"
|
|
6
|
+
v1_major=$(echo $v1 | sed -E -e 's/^([^.]+)\..*/\1/')
|
|
7
|
+
v2_major=$(echo $v2 | sed -E -e 's/^([^.]+)\..*/\1/')
|
|
8
|
+
v1_minor=$(echo $v1 | sed -E -e 's/^([^.]+)\.([^.]+)\..*/\2/')
|
|
9
|
+
v2_minor=$(echo $v2 | sed -E -e 's/^([^.]+)\.([^.]+)\..*/\2/')
|
|
10
|
+
if [ "${v1_major}" != "${v2_major}" ]; then echo 'major'; return 0; fi
|
|
11
|
+
if [ "${v1_minor}" != "${v2_minor}" ]; then echo 'minor'; return 0; fi
|
|
12
|
+
if [ "${v1}" != "${v2}" ]; then echo 'patch'; return 0; fi
|
|
13
|
+
echo 'equal'
|
|
14
|
+
return 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function suppression_from_diff_type() {
|
|
18
|
+
diff_type="$1"
|
|
19
|
+
majorSuppression="$2"
|
|
20
|
+
minorSuppression="$3"
|
|
21
|
+
patchSuppression="$4"
|
|
22
|
+
|
|
23
|
+
case "${diff_type}" in
|
|
24
|
+
major)
|
|
25
|
+
if [ -n "${majorSuppression}" ]; then
|
|
26
|
+
echo "major ${majorSuppression}"
|
|
27
|
+
elif [ -n "${minorSuppression}" ]; then
|
|
28
|
+
echo "minor ${minorSuppression}"
|
|
29
|
+
elif [ -n "${patchSuppression}" ]; then
|
|
30
|
+
echo "patch ${patchSuppression}"
|
|
31
|
+
fi
|
|
32
|
+
;;
|
|
33
|
+
minor)
|
|
34
|
+
if [ -n "${minorSuppression}" ]; then
|
|
35
|
+
echo "minor ${minorSuppression}"
|
|
36
|
+
elif [ -n "${patchSuppression}" ]; then
|
|
37
|
+
echo "patch ${patchSuppression}"
|
|
38
|
+
fi
|
|
39
|
+
;;
|
|
40
|
+
patch)
|
|
41
|
+
if [ -n "${patchSuppression}" ]; then
|
|
42
|
+
echo "patch ${patchSuppression}"
|
|
43
|
+
fi
|
|
44
|
+
;;
|
|
45
|
+
esac
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
yarn outdated --json | jq -r -s -c 'map(select(.type == "table").data.body) | .[] | unique_by(.[0]) | .[] | .[0] + " " + .[1] + " " + .[2] + " " + .[3]' | (new=""; while read package_name current wanted latest; do
|
|
49
|
+
majorSuppression=$(jq ".outdatedSuppressions.major[\"${package_name}\"] | select (. != null)" package.json)
|
|
50
|
+
minorSuppression=$(jq ".outdatedSuppressions.minor[\"${package_name}\"] | select (. != null)" package.json)
|
|
51
|
+
patchSuppression=$(jq ".outdatedSuppressions[\"${package_name}\"] | select (. != null)" package.json)
|
|
52
|
+
latest_diff_type=$(version_diff_type "${current}" "${latest}")
|
|
53
|
+
wanted_diff_type=$(version_diff_type "${current}" "${wanted}")
|
|
54
|
+
|
|
55
|
+
set -- $(suppression_from_diff_type "${latest_diff_type}" "${majorSuppression}" "${minorSuppression}" "${patchSuppression}")
|
|
56
|
+
latest_suppression_type="$1"
|
|
57
|
+
latest_suppression="$2"
|
|
58
|
+
|
|
59
|
+
set -- $(suppression_from_diff_type "${wanted_diff_type}" "${majorSuppression}" "${minorSuppression}" "${patchSuppression}")
|
|
60
|
+
wanted_suppression_type="$1"
|
|
61
|
+
wanted_suppression="$2"
|
|
62
|
+
|
|
63
|
+
# If package has major update but isn't suppre
|
|
64
|
+
suppression=""
|
|
65
|
+
suppression_type=""
|
|
66
|
+
outdated_diff_type="${latest_diff_type}"
|
|
67
|
+
if [ -n "${latest_suppression_type}" ]; then
|
|
68
|
+
if [ "${wanted_diff_type}" != "equal" ]; then
|
|
69
|
+
outdated_diff_type="${wanted_diff_type}"
|
|
70
|
+
if [ -n "${wanted_suppression_type}" ]; then
|
|
71
|
+
suppression_type="${wanted_suppression_type}"
|
|
72
|
+
suppression="${wanted_suppression}"
|
|
73
|
+
else
|
|
74
|
+
# Only suppressed at major level and we have minor or patch
|
|
75
|
+
# updates available - do not suppress
|
|
76
|
+
:
|
|
77
|
+
fi
|
|
78
|
+
else
|
|
79
|
+
suppression_type="${latest_suppression_type}"
|
|
80
|
+
suppression="${latest_suppression}"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
if [ -z "${suppression}" ]; then
|
|
85
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} outdated]"
|
|
8
86
|
new=1
|
|
9
|
-
elif [ $(date '+%s') -gt "$suppression" ]; then
|
|
10
|
-
echo "
|
|
11
|
-
echo "${package_name}" | jq .
|
|
87
|
+
elif [ $(date '+%s') -gt "${suppression}" ]; then
|
|
88
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppression expired]"
|
|
12
89
|
new=1
|
|
13
90
|
else
|
|
14
|
-
echo "
|
|
91
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppressed]"
|
|
15
92
|
fi
|
|
16
93
|
done
|
|
17
94
|
if [ -n "${new}" ]; then
|
|
@@ -3,13 +3,31 @@
|
|
|
3
3
|
# Insert a package name to suppress in outdated checks.
|
|
4
4
|
#
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
case "$1" in
|
|
7
|
+
--major)
|
|
8
|
+
root=".outdatedSuppressions.major"
|
|
9
|
+
;;
|
|
10
|
+
--minor)
|
|
11
|
+
root=".outdatedSuppressions.minor"
|
|
12
|
+
;;
|
|
13
|
+
--patch)
|
|
14
|
+
root=".outdatedSuppressions"
|
|
15
|
+
;;
|
|
16
|
+
*)
|
|
17
|
+
echo "suppress-outdated.sh: Unrecognized option: '$1'" 1>&2
|
|
18
|
+
echo "Usage: suppress-outdated.sh {--major|--minor|--patch} <package name>" 1>&2
|
|
19
|
+
exit 1
|
|
20
|
+
;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
package_name="$2"
|
|
7
24
|
PACKAGE_JSON="package.json"
|
|
8
25
|
|
|
9
26
|
if [ -z "$package_name" ]; then
|
|
10
|
-
echo "Usage: yarn suppress-outdated <package name>"
|
|
27
|
+
echo "Usage: yarn suppress-outdated {--major|--minor|--patch} <package name>"
|
|
11
28
|
exit 1
|
|
12
29
|
fi
|
|
30
|
+
|
|
13
31
|
cp $PACKAGE_JSON $PACKAGE_JSON.old
|
|
14
|
-
cat $PACKAGE_JSON | jq "
|
|
32
|
+
cat $PACKAGE_JSON | jq "${root}.\"${package_name}\" = (now | floor | . + 1209600)" > $PACKAGE_JSON.staging
|
|
15
33
|
mv $PACKAGE_JSON.staging $PACKAGE_JSON
|