@sudoplatform/sudo-common 5.10.1 → 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.
- package/bin/outdated-with-suppression.sh +97 -0
- package/bin/suppress-outdated.sh +33 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/docs/interfaces/SudoCryptoProvider.html +33 -25
- package/docs/interfaces/SudoKeyManager.html +33 -25
- package/github/bin/outdated-with-suppression.sh +97 -0
- package/github/bin/suppress-outdated.sh +33 -0
- package/github/docs/assets/search.js +1 -1
- package/github/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/github/docs/interfaces/SudoCryptoProvider.html +33 -25
- package/github/docs/interfaces/SudoKeyManager.html +33 -25
- package/github/package.json +5 -2
- package/github/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/github/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/github/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
- package/lib/errors/error.js +14 -16
- package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +12 -0
- package/lib/sudoKeyManager/sudoKeyManager.d.ts +14 -0
- package/lib/sudoKeyManager/sudoKeyManager.js +8 -0
- package/package.json +5 -2
- package/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
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]"
|
|
86
|
+
new=1
|
|
87
|
+
elif [ $(date '+%s') -gt "${suppression}" ]; then
|
|
88
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppression expired]"
|
|
89
|
+
new=1
|
|
90
|
+
else
|
|
91
|
+
echo "${package_name}: current: ${current} wanted: ${wanted} latest: ${latest} [${outdated_diff_type} suppressed]"
|
|
92
|
+
fi
|
|
93
|
+
done
|
|
94
|
+
if [ -n "${new}" ]; then
|
|
95
|
+
exit 1
|
|
96
|
+
fi
|
|
97
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# Insert a package name to suppress in outdated checks.
|
|
4
|
+
#
|
|
5
|
+
|
|
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"
|
|
24
|
+
PACKAGE_JSON="package.json"
|
|
25
|
+
|
|
26
|
+
if [ -z "$package_name" ]; then
|
|
27
|
+
echo "Usage: yarn suppress-outdated {--major|--minor|--patch} <package name>"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
cp $PACKAGE_JSON $PACKAGE_JSON.old
|
|
32
|
+
cat $PACKAGE_JSON | jq "${root}.\"${package_name}\" = (now | floor | . + 1209600)" > $PACKAGE_JSON.staging
|
|
33
|
+
mv $PACKAGE_JSON.staging $PACKAGE_JSON
|