@stoked-ui/github 0.0.0-a.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/CHANGELOG.md +15014 -0
- package/GithubCalendar/GithubCalendar.d.ts +7 -0
- package/GithubCalendar/GithubCalendar.js +330 -0
- package/GithubCalendar/index.d.ts +2 -0
- package/GithubCalendar/index.js +2 -0
- package/GithubCalendar/package.json +6 -0
- package/GithubEvents/EventTypes/CreateEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/CreateEvent.js +72 -0
- package/GithubEvents/EventTypes/DeleteEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/DeleteEvent.js +65 -0
- package/GithubEvents/EventTypes/ForkEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ForkEvent.js +77 -0
- package/GithubEvents/EventTypes/IssueCommentEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
- package/GithubEvents/EventTypes/IssuesEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/IssuesEvent.js +97 -0
- package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
- package/GithubEvents/EventTypes/ProjectsV2Event.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
- package/GithubEvents/EventTypes/ProjectsV2FieldEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
- package/GithubEvents/EventTypes/ProjectsV2ItemEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
- package/GithubEvents/EventTypes/PullRequest/CommitsList.d.ts +17 -0
- package/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
- package/GithubEvents/EventTypes/PullRequest/FileChanges.d.ts +17 -0
- package/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.d.ts +8 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestView.d.ts +29 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
- package/GithubEvents/EventTypes/PushEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/PushEvent.js +106 -0
- package/GithubEvents/GithubEvents.d.ts +49 -0
- package/GithubEvents/GithubEvents.js +1454 -0
- package/GithubEvents/index.d.ts +2 -0
- package/GithubEvents/index.js +2 -0
- package/GithubEvents/package.json +6 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/apiHandlers/getPullRequestDetails.d.ts +7 -0
- package/apiHandlers/getPullRequestDetails.js +120 -0
- package/apiHandlers/index.d.ts +1 -0
- package/apiHandlers/index.js +1 -0
- package/apiHandlers/package.json +6 -0
- package/index.d.ts +3 -0
- package/index.js +10 -0
- package/modern/GithubCalendar/GithubCalendar.js +330 -0
- package/modern/GithubCalendar/index.js +2 -0
- package/modern/GithubEvents/EventTypes/CreateEvent.js +72 -0
- package/modern/GithubEvents/EventTypes/DeleteEvent.js +65 -0
- package/modern/GithubEvents/EventTypes/ForkEvent.js +77 -0
- package/modern/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
- package/modern/GithubEvents/EventTypes/IssuesEvent.js +97 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
- package/modern/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
- package/modern/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
- package/modern/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
- package/modern/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
- package/modern/GithubEvents/EventTypes/PushEvent.js +106 -0
- package/modern/GithubEvents/GithubEvents.js +1454 -0
- package/modern/GithubEvents/index.js +2 -0
- package/modern/apiHandlers/getPullRequestDetails.js +120 -0
- package/modern/apiHandlers/index.js +1 -0
- package/modern/index.js +10 -0
- package/modern/types/github.js +1 -0
- package/node/GithubCalendar/GithubCalendar.js +337 -0
- package/node/GithubCalendar/index.js +9 -0
- package/node/GithubEvents/EventTypes/CreateEvent.js +80 -0
- package/node/GithubEvents/EventTypes/DeleteEvent.js +73 -0
- package/node/GithubEvents/EventTypes/ForkEvent.js +85 -0
- package/node/GithubEvents/EventTypes/IssueCommentEvent.js +218 -0
- package/node/GithubEvents/EventTypes/IssuesEvent.js +105 -0
- package/node/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +77 -0
- package/node/GithubEvents/EventTypes/ProjectsV2Event.js +82 -0
- package/node/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +85 -0
- package/node/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +87 -0
- package/node/GithubEvents/EventTypes/PullRequest/CommitsList.js +107 -0
- package/node/GithubEvents/EventTypes/PullRequest/FileChanges.js +188 -0
- package/node/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +381 -0
- package/node/GithubEvents/EventTypes/PullRequest/PullRequestView.js +138 -0
- package/node/GithubEvents/EventTypes/PushEvent.js +114 -0
- package/node/GithubEvents/GithubEvents.js +1463 -0
- package/node/GithubEvents/index.js +9 -0
- package/node/apiHandlers/getPullRequestDetails.js +127 -0
- package/node/apiHandlers/index.js +13 -0
- package/node/index.js +27 -0
- package/node/types/github.js +5 -0
- package/package.json +71 -0
- package/types/github.d.ts +107 -0
- package/types/github.js +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface PullRequestViewProps {
|
|
3
|
+
title: string;
|
|
4
|
+
number: number;
|
|
5
|
+
commits: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
message: string;
|
|
8
|
+
author: {
|
|
9
|
+
name: string;
|
|
10
|
+
avatar: string;
|
|
11
|
+
};
|
|
12
|
+
date: string;
|
|
13
|
+
hash: string;
|
|
14
|
+
}>;
|
|
15
|
+
files: Array<{
|
|
16
|
+
path: string;
|
|
17
|
+
type: 'added' | 'modified' | 'deleted';
|
|
18
|
+
additions: number;
|
|
19
|
+
deletions: number;
|
|
20
|
+
diff: Array<{
|
|
21
|
+
type: 'addition' | 'deletion' | 'context';
|
|
22
|
+
content: string;
|
|
23
|
+
lineNumber: number;
|
|
24
|
+
}>;
|
|
25
|
+
}>;
|
|
26
|
+
onCheckout?: (hash?: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export default function PullRequestView({ title, number, commits, files, onCheckout, }: PullRequestViewProps): React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["children", "value", "index"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import Box from '@mui/material/Box';
|
|
6
|
+
import Tabs from '@mui/material/Tabs';
|
|
7
|
+
import Tab from '@mui/material/Tab';
|
|
8
|
+
import Typography from '@mui/material/Typography';
|
|
9
|
+
import { styled } from '@mui/material/styles';
|
|
10
|
+
import CommitsList from './CommitsList';
|
|
11
|
+
import FileChanges from './FileChanges';
|
|
12
|
+
|
|
13
|
+
// Custom styled components to match GitHub's UI
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const StyledTabs = styled(Tabs)(({
|
|
16
|
+
theme
|
|
17
|
+
}) => ({
|
|
18
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
19
|
+
'& .MuiTab-root': {
|
|
20
|
+
textTransform: 'none',
|
|
21
|
+
minHeight: 48,
|
|
22
|
+
padding: '0 16px',
|
|
23
|
+
color: theme.palette.text.secondary,
|
|
24
|
+
'&.Mui-selected': {
|
|
25
|
+
color: theme.palette.text.primary
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
const StatsBox = styled(Box)(({
|
|
30
|
+
theme
|
|
31
|
+
}) => ({
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
gap: theme.spacing(1),
|
|
35
|
+
padding: theme.spacing(1, 2),
|
|
36
|
+
backgroundColor: theme.palette.background.paper,
|
|
37
|
+
borderRadius: theme.shape.borderRadius,
|
|
38
|
+
border: `1px solid ${theme.palette.divider}`
|
|
39
|
+
}));
|
|
40
|
+
function TabPanel(props) {
|
|
41
|
+
const {
|
|
42
|
+
children,
|
|
43
|
+
value,
|
|
44
|
+
index
|
|
45
|
+
} = props,
|
|
46
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
47
|
+
return /*#__PURE__*/_jsx("div", _extends({
|
|
48
|
+
role: "tabpanel",
|
|
49
|
+
hidden: value !== index,
|
|
50
|
+
id: `pr-tabpanel-${index}`,
|
|
51
|
+
"aria-labelledby": `pr-tab-${index}`
|
|
52
|
+
}, other, {
|
|
53
|
+
children: value === index && /*#__PURE__*/_jsx(Box, {
|
|
54
|
+
sx: {
|
|
55
|
+
p: 3
|
|
56
|
+
},
|
|
57
|
+
children: children
|
|
58
|
+
})
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
export default function PullRequestView({
|
|
62
|
+
title,
|
|
63
|
+
number,
|
|
64
|
+
commits,
|
|
65
|
+
files,
|
|
66
|
+
onCheckout
|
|
67
|
+
}) {
|
|
68
|
+
const [tabValue, setTabValue] = React.useState(0);
|
|
69
|
+
const handleTabChange = (event, newValue) => {
|
|
70
|
+
setTabValue(newValue);
|
|
71
|
+
};
|
|
72
|
+
const totalAdditions = files.reduce((sum, file) => sum + file.additions, 0);
|
|
73
|
+
const totalDeletions = files.reduce((sum, file) => sum + file.deletions, 0);
|
|
74
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
75
|
+
sx: {
|
|
76
|
+
width: '100%'
|
|
77
|
+
},
|
|
78
|
+
children: [title && /*#__PURE__*/_jsx(Box, {
|
|
79
|
+
sx: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
justifyContent: 'space-between',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
mb: 2
|
|
84
|
+
},
|
|
85
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
|
86
|
+
variant: "h5",
|
|
87
|
+
component: "h1",
|
|
88
|
+
children: [title, " #", number]
|
|
89
|
+
})
|
|
90
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
91
|
+
sx: {
|
|
92
|
+
borderBottom: 1,
|
|
93
|
+
borderColor: 'divider'
|
|
94
|
+
},
|
|
95
|
+
children: /*#__PURE__*/_jsxs(StyledTabs, {
|
|
96
|
+
value: tabValue,
|
|
97
|
+
onChange: handleTabChange,
|
|
98
|
+
children: [/*#__PURE__*/_jsx(Tab, {
|
|
99
|
+
label: `Commits (${commits.length})`,
|
|
100
|
+
id: "pr-tab-0"
|
|
101
|
+
}), /*#__PURE__*/_jsx(Tab, {
|
|
102
|
+
label: `Files changed (${files.length})`,
|
|
103
|
+
id: "pr-tab-1"
|
|
104
|
+
})]
|
|
105
|
+
})
|
|
106
|
+
}), /*#__PURE__*/_jsx(TabPanel, {
|
|
107
|
+
value: tabValue,
|
|
108
|
+
index: 0,
|
|
109
|
+
children: /*#__PURE__*/_jsx(CommitsList, {
|
|
110
|
+
commits: commits,
|
|
111
|
+
onCheckout: onCheckout
|
|
112
|
+
})
|
|
113
|
+
}), /*#__PURE__*/_jsxs(TabPanel, {
|
|
114
|
+
value: tabValue,
|
|
115
|
+
index: 1,
|
|
116
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
117
|
+
sx: {
|
|
118
|
+
mb: 2
|
|
119
|
+
},
|
|
120
|
+
children: /*#__PURE__*/_jsx(StatsBox, {
|
|
121
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
|
122
|
+
variant: "body2",
|
|
123
|
+
component: "span",
|
|
124
|
+
children: ["Showing ", files.length, " changed files with ", totalAdditions, " additions and ", totalDeletions, " deletions"]
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
}), /*#__PURE__*/_jsx(FileChanges, {
|
|
128
|
+
files: files
|
|
129
|
+
})]
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import Typography from '@mui/material/Typography';
|
|
4
|
+
import Link from '@mui/material/Link';
|
|
5
|
+
import Chip from '@mui/material/Chip';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
export default function PushEvent({
|
|
8
|
+
event
|
|
9
|
+
}) {
|
|
10
|
+
var _event$ref, _event$payload;
|
|
11
|
+
if (!(event != null && event.date)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const commitMessage = event.description || 'No commit message available';
|
|
15
|
+
const commitUrl = event.url || `https://github.com/${event.repo}`;
|
|
16
|
+
const branchName = ((_event$ref = event.ref) == null ? void 0 : _event$ref.replace('refs/heads/', '')) || 'main';
|
|
17
|
+
const commits = ((_event$payload = event.payload) == null ? void 0 : _event$payload.commits) || [];
|
|
18
|
+
const commitCount = commits.length;
|
|
19
|
+
// const firstCommit = commits[0];
|
|
20
|
+
|
|
21
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
22
|
+
sx: {
|
|
23
|
+
p: '16px'
|
|
24
|
+
},
|
|
25
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
26
|
+
sx: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
gap: 1,
|
|
30
|
+
mb: 2
|
|
31
|
+
},
|
|
32
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
33
|
+
variant: "caption",
|
|
34
|
+
color: "text.secondary",
|
|
35
|
+
children: event.date
|
|
36
|
+
}), /*#__PURE__*/_jsx(Chip, {
|
|
37
|
+
label: branchName,
|
|
38
|
+
size: "small",
|
|
39
|
+
color: "default"
|
|
40
|
+
}), /*#__PURE__*/_jsx(Chip, {
|
|
41
|
+
label: `${commitCount} commit${commitCount !== 1 ? 's' : ''}`,
|
|
42
|
+
size: "small",
|
|
43
|
+
color: "primary"
|
|
44
|
+
})]
|
|
45
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
46
|
+
variant: "h6",
|
|
47
|
+
component: "h3",
|
|
48
|
+
sx: {
|
|
49
|
+
mb: 1
|
|
50
|
+
},
|
|
51
|
+
children: /*#__PURE__*/_jsx(Link, {
|
|
52
|
+
href: commitUrl,
|
|
53
|
+
target: "_blank",
|
|
54
|
+
rel: "noopener noreferrer",
|
|
55
|
+
sx: {
|
|
56
|
+
textDecoration: 'none'
|
|
57
|
+
},
|
|
58
|
+
children: commitMessage
|
|
59
|
+
})
|
|
60
|
+
}), commits.length > 0 && /*#__PURE__*/_jsxs(Box, {
|
|
61
|
+
sx: {
|
|
62
|
+
mt: 2
|
|
63
|
+
},
|
|
64
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
65
|
+
variant: "subtitle2",
|
|
66
|
+
sx: {
|
|
67
|
+
mb: 1
|
|
68
|
+
},
|
|
69
|
+
children: "Commits:"
|
|
70
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
71
|
+
component: "ul",
|
|
72
|
+
sx: {
|
|
73
|
+
listStyle: 'none',
|
|
74
|
+
p: 0,
|
|
75
|
+
m: 0,
|
|
76
|
+
'& li': {
|
|
77
|
+
mb: 1,
|
|
78
|
+
'&:last-child': {
|
|
79
|
+
mb: 0
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
children: commits.map((commit, index) => /*#__PURE__*/_jsxs(Box, {
|
|
84
|
+
component: "li",
|
|
85
|
+
sx: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
alignItems: 'flex-start',
|
|
88
|
+
gap: 1
|
|
89
|
+
},
|
|
90
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
91
|
+
variant: "body2",
|
|
92
|
+
component: "span",
|
|
93
|
+
sx: {
|
|
94
|
+
color: 'text.secondary',
|
|
95
|
+
minWidth: '7ch'
|
|
96
|
+
},
|
|
97
|
+
children: commit.sha.substring(0, 7)
|
|
98
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
99
|
+
variant: "body2",
|
|
100
|
+
children: commit.message
|
|
101
|
+
})]
|
|
102
|
+
}, index))
|
|
103
|
+
})]
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RequestError } from '@octokit/request-error';
|
|
3
|
+
import { GitHubEvent } from '../types/github';
|
|
4
|
+
export type EventsQuery = {
|
|
5
|
+
page?: number;
|
|
6
|
+
per_page?: number;
|
|
7
|
+
repo?: string;
|
|
8
|
+
action?: string;
|
|
9
|
+
date?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function githubEventsQuery({ query, githubUser, githubToken }: {
|
|
13
|
+
query: EventsQuery;
|
|
14
|
+
githubUser: string;
|
|
15
|
+
githubToken?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
events: GitHubEvent[];
|
|
18
|
+
total: number;
|
|
19
|
+
repositories: string[];
|
|
20
|
+
actionTypes: string[];
|
|
21
|
+
page: number;
|
|
22
|
+
per_page: number;
|
|
23
|
+
total_pages: number;
|
|
24
|
+
total_fetched_events: number;
|
|
25
|
+
max_pages_fetched: number;
|
|
26
|
+
}>;
|
|
27
|
+
export interface GetEventsParams {
|
|
28
|
+
githubUser: string;
|
|
29
|
+
githubToken?: string;
|
|
30
|
+
apiUrl?: string;
|
|
31
|
+
query: {
|
|
32
|
+
page: number;
|
|
33
|
+
perPage: number;
|
|
34
|
+
repo?: string;
|
|
35
|
+
action?: string;
|
|
36
|
+
date?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export declare function ErrorDetails({ error }: {
|
|
41
|
+
error: string | RequestError;
|
|
42
|
+
}): React.JSX.Element | null;
|
|
43
|
+
export default function GithubEvents({ apiUrl, eventsPerPage, hideMetadata, githubUser, githubToken }: {
|
|
44
|
+
apiUrl?: string;
|
|
45
|
+
eventsPerPage?: number;
|
|
46
|
+
hideMetadata?: boolean;
|
|
47
|
+
githubUser: string;
|
|
48
|
+
githubToken?: string;
|
|
49
|
+
}): import("react/jsx-runtime").JSX.Element;
|