@unitedstatespowersquadrons/components 1.3.0 → 1.3.2
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/Badges/Branch.tsx +3 -12
- package/Badges/Commit.tsx +2 -11
- package/Badges/Date.tsx +5 -5
- package/Badges/PhpLibrary.tsx +5 -2
- package/Badges/Reachable.tsx +8 -11
- package/Badges/Suite.tsx +20 -29
- package/Badges/helpers.ts +2 -4
- package/package.json +1 -1
package/Badges/Branch.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { badgeify } from "./helpers";
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
branch: string;
|
|
7
|
-
primaryBranch?: "main" | "master";
|
|
7
|
+
primaryBranch?: "main" | "master" | undefined;
|
|
8
8
|
repo?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -15,19 +15,10 @@ const BranchBadge = (props: Props) => {
|
|
|
15
15
|
const color = branch === primaryBranch ? "blue" : "orange";
|
|
16
16
|
const name = badgeify(branch)!;
|
|
17
17
|
|
|
18
|
-
const img =
|
|
19
|
-
<img src={`${shields}/badge/${name}-${color}?logo=git&logoColor=white`} />
|
|
20
|
-
);
|
|
18
|
+
const img = <img src={`${shields}/badge/${name}-${color}?logo=git&logoColor=white`} />;
|
|
21
19
|
if (!effectiveRepo) return img;
|
|
22
20
|
|
|
23
|
-
return
|
|
24
|
-
<a
|
|
25
|
-
href={`${github}/${effectiveRepo}/compare/${branch}?expand=1`}
|
|
26
|
-
rel="noreferrer" target="_blank"
|
|
27
|
-
>
|
|
28
|
-
{img}
|
|
29
|
-
</a>
|
|
30
|
-
);
|
|
21
|
+
return <a href={`${github}/${effectiveRepo}/compare/${branch}?expand=1`} rel="noreferrer" target="_blank">{img}</a>;
|
|
31
22
|
};
|
|
32
23
|
|
|
33
24
|
export default BranchBadge;
|
package/Badges/Commit.tsx
CHANGED
|
@@ -9,19 +9,10 @@ interface Props {
|
|
|
9
9
|
const CommitBadge = (props: Props) => {
|
|
10
10
|
const { commit, repo } = props;
|
|
11
11
|
|
|
12
|
-
const img = (
|
|
13
|
-
<img src={`${shields}/badge/sha-${commit.slice(0, 12)}-purple`} />
|
|
14
|
-
);
|
|
12
|
+
const img = <img src={`${shields}/badge/sha-${commit.slice(0, 12)}-purple`} />;
|
|
15
13
|
if (!repo) return img;
|
|
16
14
|
|
|
17
|
-
return
|
|
18
|
-
<a
|
|
19
|
-
href={`${github}/${repo}/commit/${commit}`}
|
|
20
|
-
rel="noreferrer" target="_blank"
|
|
21
|
-
>
|
|
22
|
-
{img}
|
|
23
|
-
</a>
|
|
24
|
-
);
|
|
15
|
+
return <a href={`${github}/${repo}/commit/${commit}`} rel="noreferrer" target="_blank">{img}</a>;
|
|
25
16
|
};
|
|
26
17
|
|
|
27
18
|
export default CommitBadge;
|
package/Badges/Date.tsx
CHANGED
|
@@ -16,15 +16,15 @@ const DateBadge = (props: Props) => {
|
|
|
16
16
|
const color = () => {
|
|
17
17
|
// Age
|
|
18
18
|
if (diff <= -60 * 60 * 24 * 14) return "63a2c7";
|
|
19
|
-
else if (diff <= -60 * 60 * 24)
|
|
20
|
-
else if (diff <= -60 * 60)
|
|
21
|
-
else if (diff <= -60)
|
|
19
|
+
else if (diff <= -60 * 60 * 24) return "blue";
|
|
20
|
+
else if (diff <= -60 * 60) return "green";
|
|
21
|
+
else if (diff <= -60) return "yellowgreen";
|
|
22
22
|
|
|
23
23
|
// Expiration Time
|
|
24
|
-
else if (diff <= 60)
|
|
24
|
+
else if (diff <= 60) return "orange";
|
|
25
25
|
else if (diff <= 60 * 10) return "yellowgreen";
|
|
26
26
|
else if (diff <= 60 * 60) return "green";
|
|
27
|
-
else
|
|
27
|
+
else return "brightgreen";
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const params = new URLSearchParams();
|
package/Badges/PhpLibrary.tsx
CHANGED
|
@@ -14,8 +14,11 @@ const PhpLibraryBadge = (props: Props) => {
|
|
|
14
14
|
return(
|
|
15
15
|
<a href={`${github}/${php}`} rel="noreferrer" target="_blank">
|
|
16
16
|
<Badge
|
|
17
|
-
color={versionColor(version)}
|
|
18
|
-
|
|
17
|
+
color={versionColor(version)}
|
|
18
|
+
content={version}
|
|
19
|
+
label="library"
|
|
20
|
+
logo="php"
|
|
21
|
+
logoColor="white"
|
|
19
22
|
/>
|
|
20
23
|
</a>
|
|
21
24
|
);
|
package/Badges/Reachable.tsx
CHANGED
|
@@ -13,18 +13,15 @@ const ReachableBadge = (props: Props) => {
|
|
|
13
13
|
const status = reachable?.status;
|
|
14
14
|
const reason = reachable?.reason || "Error";
|
|
15
15
|
|
|
16
|
-
const badge =
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const badge = () => {
|
|
17
|
+
if (status) {
|
|
18
|
+
return <Badge color="brightgreen" content="Reachable" label={host} />;
|
|
19
|
+
} else {
|
|
20
|
+
return <Badge color="red" content={reason} label={host} />;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
19
23
|
|
|
20
|
-
return(
|
|
21
|
-
<a
|
|
22
|
-
href={`https://${host}.aws.usps.org`}
|
|
23
|
-
rel="noreferrer" target="_blank"
|
|
24
|
-
>
|
|
25
|
-
{badge}
|
|
26
|
-
</a>
|
|
27
|
-
);
|
|
24
|
+
return <a href={`https://${host}.aws.usps.org`} rel="noreferrer" target="_blank">{badge()}</a>;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
export default ReachableBadge;
|
package/Badges/Suite.tsx
CHANGED
|
@@ -13,10 +13,12 @@ const SuiteBadge = (props: Props) => {
|
|
|
13
13
|
|
|
14
14
|
if (!suite || !suite.status) return null;
|
|
15
15
|
|
|
16
|
+
const { headBranch, conclusion, skipCi, status } = suite;
|
|
17
|
+
|
|
16
18
|
const suiteBadgeColor = () => {
|
|
17
|
-
if (
|
|
19
|
+
if (skipCi) return "lightgray";
|
|
18
20
|
|
|
19
|
-
switch (
|
|
21
|
+
switch (status) {
|
|
20
22
|
case "queued":
|
|
21
23
|
case "in_progress":
|
|
22
24
|
case "requested":
|
|
@@ -25,7 +27,7 @@ const SuiteBadge = (props: Props) => {
|
|
|
25
27
|
return "yellow";
|
|
26
28
|
|
|
27
29
|
case "completed":
|
|
28
|
-
switch (
|
|
30
|
+
switch (conclusion) {
|
|
29
31
|
case "success": return "brightgreen";
|
|
30
32
|
case "failure":
|
|
31
33
|
case "timed_out":
|
|
@@ -39,36 +41,25 @@ const SuiteBadge = (props: Props) => {
|
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
|
|
42
|
-
const titleize = (text: string) =>
|
|
43
|
-
|
|
44
|
+
const titleize = (text: string) => text.replace("_", " ").replace(/(^|\s)\S/g, t => t.toUpperCase());
|
|
45
|
+
|
|
46
|
+
const description = () => {
|
|
47
|
+
if (skipCi) return "Skipped";
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (status === "completed") {
|
|
50
|
+
return badgeify(titleize(conclusion || ""));
|
|
51
|
+
} else {
|
|
52
|
+
return badgeify(titleize(status));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
51
55
|
const color = suiteBadgeColor();
|
|
52
56
|
|
|
53
|
-
const img =
|
|
54
|
-
<img
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
+ `${branch}-${description || "Unknown"}-${color}`
|
|
58
|
-
+ "?logo=github"
|
|
59
|
-
}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
if (!repo || suite.conclusion === "success") return img;
|
|
57
|
+
const img =
|
|
58
|
+
<img src={`${shields}/badge/${badgeify(headBranch)}-${description() || "Unknown"}-${color}?logo=github`} />;
|
|
59
|
+
|
|
60
|
+
if (!repo || conclusion === "success") return img;
|
|
63
61
|
|
|
64
|
-
return
|
|
65
|
-
<a
|
|
66
|
-
href={`${github}/${repo}/actions/workflows/main.yml`}
|
|
67
|
-
rel="noreferrer" target="_blank"
|
|
68
|
-
>
|
|
69
|
-
{img}
|
|
70
|
-
</a>
|
|
71
|
-
);
|
|
62
|
+
return <a href={`${github}/${repo}/actions/workflows/main.yml`} rel="noreferrer" target="_blank">{img}</a>;
|
|
72
63
|
};
|
|
73
64
|
|
|
74
65
|
export default SuiteBadge;
|
package/Badges/helpers.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export const badgeify = (text?: string) =>
|
|
2
|
-
text?.replaceAll("-", "--")?.replaceAll("_", "__")?.replaceAll(" ", "_");
|
|
1
|
+
export const badgeify = (text?: string) => text?.replaceAll("-", "--")?.replaceAll("_", "__")?.replaceAll(" ", "_");
|
|
3
2
|
|
|
4
|
-
export const versionColor = (version: string) =>
|
|
5
|
-
version.slice(0, 2) === "v0" ? "orange" : "blue";
|
|
3
|
+
export const versionColor = (version: string) => version.slice(0, 2) === "v0" ? "orange" : "blue";
|