From 6ace05550c86ffbe2468dfd2a8726f46949acace Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Sat, 28 Sep 2024 18:34:39 +0900 Subject: [PATCH 01/49] =?UTF-8?q?refactor:=20filteredRange=20zustand=20sto?= =?UTF-8?q?re=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/TemporalFilter/LineChart.ts | 2 +- .../TemporalFilter/TemporalFilter.tsx | 5 +++-- .../view/src/context/GlobalDataProvider.tsx | 7 ++----- packages/view/src/hooks/useGlobalData.ts | 9 --------- packages/view/src/store/filteredRange.ts | 18 ++++++++++++++++++ packages/view/src/store/index.ts | 1 + 6 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 packages/view/src/store/filteredRange.ts diff --git a/packages/view/src/components/TemporalFilter/LineChart.ts b/packages/view/src/components/TemporalFilter/LineChart.ts index 728416ce..d976f88f 100644 --- a/packages/view/src/components/TemporalFilter/LineChart.ts +++ b/packages/view/src/components/TemporalFilter/LineChart.ts @@ -1,7 +1,7 @@ import * as d3 from "d3"; import dayjs from "dayjs"; +import { type DateFilterRange } from "store"; -import type { DateFilterRange } from "hooks"; import "./LineChart.scss"; export type LineChartDatum = { diff --git a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx index d0d58a16..8e9f50a2 100644 --- a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx +++ b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx @@ -6,7 +6,7 @@ import BounceLoader from "react-spinners/BounceLoader"; import { Button } from "@mui/material"; import { useGlobalData } from "hooks"; -import { useLoadingStore } from "store"; +import { useLoadingStore, useFilteredRangeStore } from "store"; import { filterDataByDate, getMinMaxDate, lineChartTimeFormatter, sortBasedOnCommitNode } from "./TemporalFilter.util"; import "./TemporalFilter.scss"; @@ -18,8 +18,9 @@ import { createBrush, drawBrush, resetBrush } from "./LineChartBrush"; import { BRUSH_MARGIN, TEMPORAL_FILTER_LINE_CHART_STYLES } from "./LineChart.const"; const TemporalFilter = () => { - const { data, filteredData, setFilteredData, filteredRange, setFilteredRange, setSelectedData } = useGlobalData(); + const { data, filteredData, setFilteredData, setSelectedData } = useGlobalData(); const { loading } = useLoadingStore((state) => state); + const { filteredRange, setFilteredRange } = useFilteredRangeStore(); const brushGroupRef = useRef(null); const brushRef = useRef>(); diff --git a/packages/view/src/context/GlobalDataProvider.tsx b/packages/view/src/context/GlobalDataProvider.tsx index 7e2cc0dd..5982ca28 100644 --- a/packages/view/src/context/GlobalDataProvider.tsx +++ b/packages/view/src/context/GlobalDataProvider.tsx @@ -1,7 +1,7 @@ import type { PropsWithChildren } from "react"; import { useMemo, useState } from "react"; -import { GlobalDataContext, type DateFilterRange } from "hooks"; +import { GlobalDataContext } from "hooks"; import type { ClusterNode } from "types"; import { useLoadingStore } from "store"; @@ -9,7 +9,6 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { const [data, setData] = useState([]); const [filteredData, setFilteredData] = useState(data); const [selectedData, setSelectedData] = useState([]); - const [filteredRange, setFilteredRange] = useState(undefined); const { setLoading } = useLoadingStore((state) => state); const [branchList, setBranchList] = useState([]); const [selectedBranch, setSelectedBranch] = useState(branchList?.[0]); @@ -31,8 +30,6 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { const value = useMemo( () => ({ data, - filteredRange, - setFilteredRange, filteredData, setFilteredData, selectedData, @@ -48,7 +45,7 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { repo, setRepo, }), - [data, filteredRange, filteredData, selectedData, branchList, selectedBranch, owner, repo] + [data, filteredData, selectedData, branchList, selectedBranch, owner, repo] ); return {children}; diff --git a/packages/view/src/hooks/useGlobalData.ts b/packages/view/src/hooks/useGlobalData.ts index 1d2b96a1..f0a4ef93 100644 --- a/packages/view/src/hooks/useGlobalData.ts +++ b/packages/view/src/hooks/useGlobalData.ts @@ -3,21 +3,12 @@ import { createContext, useContext } from "react"; import type { ClusterNode, IDESentEvents } from "types"; -export type DateFilterRange = - | { - fromDate: string; - toDate: string; - } - | undefined; - type GlobalDataState = { data: ClusterNode[]; - filteredRange: DateFilterRange; filteredData: ClusterNode[]; selectedData: ClusterNode[]; setFilteredData: Dispatch>; setSelectedData: Dispatch>; - setFilteredRange: Dispatch>; branchList: string[]; setBranchList: Dispatch>; selectedBranch: string; diff --git a/packages/view/src/store/filteredRange.ts b/packages/view/src/store/filteredRange.ts new file mode 100644 index 00000000..63729726 --- /dev/null +++ b/packages/view/src/store/filteredRange.ts @@ -0,0 +1,18 @@ +import { create } from "zustand"; + +export type DateFilterRange = + | { + fromDate: string; + toDate: string; + } + | undefined; + +type FilteredRangeStore = { + filteredRange: DateFilterRange; + setFilteredRange: (filteredRange: DateFilterRange) => void; +}; + +export const useFilteredRangeStore = create((set) => ({ + filteredRange: undefined, + setFilteredRange: (filteredRange) => set({ filteredRange }), +})); diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index b50fe215..fb2b9871 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -1 +1,2 @@ export * from "./loading"; +export * from "./filteredRange"; From b8ec9a54c9b5ac92d538337bb5e7829c00419196 Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Sat, 28 Sep 2024 22:58:37 +0900 Subject: [PATCH 02/49] =?UTF-8?q?refactor:=20branch=EA=B4=80=EB=A0=A8=20co?= =?UTF-8?q?ntext=EB=A5=BC=20store=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit type 수정하면서 BranchListPayload의 위치 고민됨 현재는 store쪽에 선언하고 IDESentEvents에서 가져와서 쓰는데 괜찮은지 확인 필요 --- packages/view/src/App.tsx | 5 ++-- .../BranchSelector/BranchSelector.tsx | 5 ++-- .../RefreshButton/RefreshButton.tsx | 5 ++-- .../view/src/context/GlobalDataProvider.tsx | 14 +--------- packages/view/src/hooks/useGlobalData.ts | 9 +++---- packages/view/src/store/branch.ts | 26 +++++++++++++++++++ packages/view/src/store/index.ts | 1 + packages/view/src/types/IDESentEvents.ts | 3 ++- 8 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 packages/view/src/store/branch.ts diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 19d8af42..0011a3ac 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -11,12 +11,13 @@ import { useGlobalData } from "hooks"; import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; -import { useLoadingStore } from "store"; +import { useBranchStore, useLoadingStore } from "store"; const App = () => { const initRef = useRef(false); - const { filteredData, handleChangeAnalyzedData, handleChangeBranchList } = useGlobalData(); + const { filteredData, handleChangeAnalyzedData } = useGlobalData(); + const { handleChangeBranchList } = useBranchStore(); const { loading, setLoading } = useLoadingStore((state) => state); const ideAdapter = container.resolve("IDEAdapter"); diff --git a/packages/view/src/components/BranchSelector/BranchSelector.tsx b/packages/view/src/components/BranchSelector/BranchSelector.tsx index 5425f30f..eec0035d 100644 --- a/packages/view/src/components/BranchSelector/BranchSelector.tsx +++ b/packages/view/src/components/BranchSelector/BranchSelector.tsx @@ -3,15 +3,14 @@ import FormControl from "@mui/material/FormControl"; import type { SelectChangeEvent } from "@mui/material/Select"; import Select from "@mui/material/Select"; -import { useGlobalData } from "hooks"; import { sendFetchAnalyzedDataCommand } from "services"; import "./BranchSelector.scss"; -import { useLoadingStore } from "store"; +import { useBranchStore, useLoadingStore } from "store"; import { SLICE_LENGTH } from "./BranchSelector.const"; const BranchSelector = () => { - const { branchList, selectedBranch, setSelectedBranch } = useGlobalData(); + const { branchList, selectedBranch, setSelectedBranch } = useBranchStore(); const { setLoading } = useLoadingStore((state) => state); const handleChangeSelect = (event: SelectChangeEvent) => { diff --git a/packages/view/src/components/RefreshButton/RefreshButton.tsx b/packages/view/src/components/RefreshButton/RefreshButton.tsx index 490bae97..b3845033 100644 --- a/packages/view/src/components/RefreshButton/RefreshButton.tsx +++ b/packages/view/src/components/RefreshButton/RefreshButton.tsx @@ -4,13 +4,12 @@ import ReplayCircleFilledRoundedIcon from "@mui/icons-material/ReplayCircleFille import { IconButton } from "@mui/material"; import { throttle } from "utils"; -import { useGlobalData } from "hooks"; import "./RefreshButton.scss"; import { sendRefreshDataCommand } from "services"; -import { useLoadingStore } from "store"; +import { useBranchStore, useLoadingStore } from "store"; const RefreshButton = () => { - const { selectedBranch } = useGlobalData(); + const { selectedBranch } = useBranchStore(); const { loading, setLoading } = useLoadingStore((state) => state); const refreshHandler = throttle(() => { diff --git a/packages/view/src/context/GlobalDataProvider.tsx b/packages/view/src/context/GlobalDataProvider.tsx index 5982ca28..1210cf84 100644 --- a/packages/view/src/context/GlobalDataProvider.tsx +++ b/packages/view/src/context/GlobalDataProvider.tsx @@ -10,16 +10,9 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { const [filteredData, setFilteredData] = useState(data); const [selectedData, setSelectedData] = useState([]); const { setLoading } = useLoadingStore((state) => state); - const [branchList, setBranchList] = useState([]); - const [selectedBranch, setSelectedBranch] = useState(branchList?.[0]); const [owner, setOwner] = useState(""); const [repo, setRepo] = useState(""); - const handleChangeBranchList = (branches: { branchList: string[]; head: string | null }) => { - setSelectedBranch((prev) => (!prev && branches.head ? branches.head : prev)); - setBranchList(branches.branchList); - }; - const handleChangeAnalyzedData = (analyzedData: ClusterNode[]) => { setData(analyzedData); setFilteredData([...analyzedData.reverse()]); @@ -34,18 +27,13 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { setFilteredData, selectedData, setSelectedData, - branchList, - setBranchList, - selectedBranch, - setSelectedBranch, handleChangeAnalyzedData, - handleChangeBranchList, owner, setOwner, repo, setRepo, }), - [data, filteredData, selectedData, branchList, selectedBranch, owner, repo] + [data, filteredData, selectedData, owner, repo] ); return {children}; diff --git a/packages/view/src/hooks/useGlobalData.ts b/packages/view/src/hooks/useGlobalData.ts index f0a4ef93..16e2793b 100644 --- a/packages/view/src/hooks/useGlobalData.ts +++ b/packages/view/src/hooks/useGlobalData.ts @@ -1,7 +1,7 @@ import type { Dispatch, SetStateAction } from "react"; import { createContext, useContext } from "react"; -import type { ClusterNode, IDESentEvents } from "types"; +import type { ClusterNode } from "types"; type GlobalDataState = { data: ClusterNode[]; @@ -9,15 +9,12 @@ type GlobalDataState = { selectedData: ClusterNode[]; setFilteredData: Dispatch>; setSelectedData: Dispatch>; - branchList: string[]; - setBranchList: Dispatch>; - selectedBranch: string; - setSelectedBranch: Dispatch>; owner: string; setOwner: Dispatch>; repo: string; setRepo: Dispatch>; -} & IDESentEvents; + handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; +}; // handleChangeBranchList를 임시로 제외 -> 추후 GlobalDataContext를 삭제할 예정 export const GlobalDataContext = createContext(undefined); diff --git a/packages/view/src/store/branch.ts b/packages/view/src/store/branch.ts new file mode 100644 index 00000000..996a5386 --- /dev/null +++ b/packages/view/src/store/branch.ts @@ -0,0 +1,26 @@ +import { create } from "zustand"; + +export type BranchListPayload = { + branchList: string[]; + head: string | null; +}; + +type BranchStore = { + branchList: string[]; + selectedBranch: string; + setBranchList: (branches: string[]) => void; + setSelectedBranch: (branch: string) => void; + handleChangeBranchList: (branches: BranchListPayload) => void; +}; + +export const useBranchStore = create((set) => ({ + branchList: [], + selectedBranch: "", + setBranchList: (branches) => set({ branchList: branches }), + setSelectedBranch: (branch) => set({ selectedBranch: branch }), + handleChangeBranchList: (branches) => + set((state) => ({ + branchList: branches.branchList, + selectedBranch: !state.selectedBranch && branches.head ? branches.head : state.selectedBranch, + })), +})); diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index fb2b9871..f1c226fd 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -1,2 +1,3 @@ export * from "./loading"; export * from "./filteredRange"; +export * from "./branch"; diff --git a/packages/view/src/types/IDESentEvents.ts b/packages/view/src/types/IDESentEvents.ts index 65def9df..e1420a41 100644 --- a/packages/view/src/types/IDESentEvents.ts +++ b/packages/view/src/types/IDESentEvents.ts @@ -1,7 +1,8 @@ +import type { BranchListPayload } from "store"; import type { ClusterNode } from "types"; // triggered by ide response export type IDESentEvents = { handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; - handleChangeBranchList: (branches: { branchList: string[]; head: string | null }) => void; + handleChangeBranchList: (branches: BranchListPayload) => void; }; From 7800d9863e868110dd0baed3f910bca1d893207b Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:09:27 +0900 Subject: [PATCH 03/49] =?UTF-8?q?refactor:=20useLoadingStore=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 2 +- packages/view/src/components/BranchSelector/BranchSelector.tsx | 2 +- packages/view/src/components/RefreshButton/RefreshButton.tsx | 2 +- packages/view/src/components/TemporalFilter/TemporalFilter.tsx | 2 +- packages/view/src/context/GlobalDataProvider.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 0011a3ac..dea87f62 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -18,7 +18,7 @@ const App = () => { const { filteredData, handleChangeAnalyzedData } = useGlobalData(); const { handleChangeBranchList } = useBranchStore(); - const { loading, setLoading } = useLoadingStore((state) => state); + const { loading, setLoading } = useLoadingStore(); const ideAdapter = container.resolve("IDEAdapter"); diff --git a/packages/view/src/components/BranchSelector/BranchSelector.tsx b/packages/view/src/components/BranchSelector/BranchSelector.tsx index eec0035d..90ef39bb 100644 --- a/packages/view/src/components/BranchSelector/BranchSelector.tsx +++ b/packages/view/src/components/BranchSelector/BranchSelector.tsx @@ -11,7 +11,7 @@ import { SLICE_LENGTH } from "./BranchSelector.const"; const BranchSelector = () => { const { branchList, selectedBranch, setSelectedBranch } = useBranchStore(); - const { setLoading } = useLoadingStore((state) => state); + const { setLoading } = useLoadingStore(); const handleChangeSelect = (event: SelectChangeEvent) => { setSelectedBranch(event.target.value); diff --git a/packages/view/src/components/RefreshButton/RefreshButton.tsx b/packages/view/src/components/RefreshButton/RefreshButton.tsx index b3845033..ac54eaa3 100644 --- a/packages/view/src/components/RefreshButton/RefreshButton.tsx +++ b/packages/view/src/components/RefreshButton/RefreshButton.tsx @@ -10,7 +10,7 @@ import { useBranchStore, useLoadingStore } from "store"; const RefreshButton = () => { const { selectedBranch } = useBranchStore(); - const { loading, setLoading } = useLoadingStore((state) => state); + const { loading, setLoading } = useLoadingStore(); const refreshHandler = throttle(() => { setLoading(true); diff --git a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx index 8e9f50a2..686e305d 100644 --- a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx +++ b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx @@ -19,7 +19,7 @@ import { BRUSH_MARGIN, TEMPORAL_FILTER_LINE_CHART_STYLES } from "./LineChart.con const TemporalFilter = () => { const { data, filteredData, setFilteredData, setSelectedData } = useGlobalData(); - const { loading } = useLoadingStore((state) => state); + const { loading } = useLoadingStore(); const { filteredRange, setFilteredRange } = useFilteredRangeStore(); const brushGroupRef = useRef(null); const brushRef = useRef>(); diff --git a/packages/view/src/context/GlobalDataProvider.tsx b/packages/view/src/context/GlobalDataProvider.tsx index 1210cf84..e570b240 100644 --- a/packages/view/src/context/GlobalDataProvider.tsx +++ b/packages/view/src/context/GlobalDataProvider.tsx @@ -9,7 +9,7 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { const [data, setData] = useState([]); const [filteredData, setFilteredData] = useState(data); const [selectedData, setSelectedData] = useState([]); - const { setLoading } = useLoadingStore((state) => state); + const { setLoading } = useLoadingStore(); const [owner, setOwner] = useState(""); const [repo, setRepo] = useState(""); From 6cf977b4890e8aba5f379eb7fa241deb2affeb7d Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:17:21 +0900 Subject: [PATCH 04/49] =?UTF-8?q?refactor:=20repo,=20owner=20context?= =?UTF-8?q?=EB=A5=BC=20store=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 6 +++--- packages/view/src/components/Detail/Detail.tsx | 5 +++-- .../VerticalClusterList/Summary/Content/Content.tsx | 5 +++-- packages/view/src/context/GlobalDataProvider.tsx | 8 +------- packages/view/src/hooks/useGlobalData.ts | 4 ---- packages/view/src/store/index.ts | 2 ++ packages/view/src/store/owner.ts | 11 +++++++++++ packages/view/src/store/repo.ts | 11 +++++++++++ 8 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 packages/view/src/store/owner.ts create mode 100644 packages/view/src/store/repo.ts diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index dea87f62..467a6218 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -11,7 +11,7 @@ import { useGlobalData } from "hooks"; import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; -import { useBranchStore, useLoadingStore } from "store"; +import { useBranchStore, useLoadingStore, useOwnerStore, useRepoStore } from "store"; const App = () => { const initRef = useRef(false); @@ -19,7 +19,8 @@ const App = () => { const { filteredData, handleChangeAnalyzedData } = useGlobalData(); const { handleChangeBranchList } = useBranchStore(); const { loading, setLoading } = useLoadingStore(); - + const { setOwner } = useOwnerStore(); + const { setRepo } = useRepoStore(); const ideAdapter = container.resolve("IDEAdapter"); useEffect(() => { @@ -37,7 +38,6 @@ const App = () => { } }, [handleChangeAnalyzedData, handleChangeBranchList, ideAdapter, setLoading]); - const { setOwner, setRepo } = useGlobalData(); useEffect(() => { const handleMessage = (event: MessageEvent) => { const message = event.data; diff --git a/packages/view/src/components/Detail/Detail.tsx b/packages/view/src/components/Detail/Detail.tsx index dde6c560..010787fb 100644 --- a/packages/view/src/components/Detail/Detail.tsx +++ b/packages/view/src/components/Detail/Detail.tsx @@ -11,7 +11,7 @@ import { import { Tooltip } from "@mui/material"; import { Author } from "components/@common/Author"; -import { useGlobalData } from "hooks"; +import { useOwnerStore, useRepoStore } from "store"; import { useCommitListHide } from "./Detail.hook"; import { getCommitListDetail } from "./Detail.util"; @@ -56,7 +56,8 @@ const Detail = ({ selectedData, clusterId, authSrcMap }: DetailProps) => { const commitNodeListInCluster = selectedData?.filter((selected) => selected.commitNodeList[0].clusterId === clusterId)[0].commitNodeList ?? []; const { commitNodeList, toggle, handleToggle } = useCommitListHide(commitNodeListInCluster); - const { repo, owner } = useGlobalData(); + const { owner } = useOwnerStore(); + const { repo } = useRepoStore(); const isShow = commitNodeListInCluster.length > FIRST_SHOW_NUM; const handleCommitIdCopy = (id: string) => async () => { navigator.clipboard.writeText(id); diff --git a/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx b/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx index 95b6f3dc..44291936 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx @@ -1,12 +1,13 @@ import React, { useEffect, useState } from "react"; import ArrowDropDownCircleRoundedIcon from "@mui/icons-material/ArrowDropDownCircleRounded"; -import { useGlobalData } from "hooks"; +import { useOwnerStore, useRepoStore } from "store"; import type { ContentProps } from "../Summary.type"; const Content = ({ content, clusterId, selectedClusterId }: ContentProps) => { - const { owner, repo } = useGlobalData(); + const { owner } = useOwnerStore(); + const { repo } = useRepoStore(); const [linkedStr, setLinkedStr] = useState([]); useEffect(() => { diff --git a/packages/view/src/context/GlobalDataProvider.tsx b/packages/view/src/context/GlobalDataProvider.tsx index e570b240..b1b61811 100644 --- a/packages/view/src/context/GlobalDataProvider.tsx +++ b/packages/view/src/context/GlobalDataProvider.tsx @@ -10,8 +10,6 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { const [filteredData, setFilteredData] = useState(data); const [selectedData, setSelectedData] = useState([]); const { setLoading } = useLoadingStore(); - const [owner, setOwner] = useState(""); - const [repo, setRepo] = useState(""); const handleChangeAnalyzedData = (analyzedData: ClusterNode[]) => { setData(analyzedData); @@ -28,12 +26,8 @@ export const GlobalDataProvider = ({ children }: PropsWithChildren) => { selectedData, setSelectedData, handleChangeAnalyzedData, - owner, - setOwner, - repo, - setRepo, }), - [data, filteredData, selectedData, owner, repo] + [data, filteredData, selectedData] ); return {children}; diff --git a/packages/view/src/hooks/useGlobalData.ts b/packages/view/src/hooks/useGlobalData.ts index 16e2793b..45f70a77 100644 --- a/packages/view/src/hooks/useGlobalData.ts +++ b/packages/view/src/hooks/useGlobalData.ts @@ -9,10 +9,6 @@ type GlobalDataState = { selectedData: ClusterNode[]; setFilteredData: Dispatch>; setSelectedData: Dispatch>; - owner: string; - setOwner: Dispatch>; - repo: string; - setRepo: Dispatch>; handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; }; // handleChangeBranchList를 임시로 제외 -> 추후 GlobalDataContext를 삭제할 예정 diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index f1c226fd..991b1d87 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -1,3 +1,5 @@ export * from "./loading"; export * from "./filteredRange"; export * from "./branch"; +export * from "./repo"; +export * from "./owner"; diff --git a/packages/view/src/store/owner.ts b/packages/view/src/store/owner.ts new file mode 100644 index 00000000..dbeefc29 --- /dev/null +++ b/packages/view/src/store/owner.ts @@ -0,0 +1,11 @@ +import { create } from "zustand"; + +type OwnerStore = { + owner: string; + setOwner: (owner: string) => void; +}; + +export const useOwnerStore = create((set) => ({ + owner: "", + setOwner: (owner) => set({ owner }), +})); diff --git a/packages/view/src/store/repo.ts b/packages/view/src/store/repo.ts new file mode 100644 index 00000000..d2aac79d --- /dev/null +++ b/packages/view/src/store/repo.ts @@ -0,0 +1,11 @@ +import { create } from "zustand"; + +type RepoStore = { + repo: string; + setRepo: (repo: string) => void; +}; + +export const useRepoStore = create((set) => ({ + repo: "", + setRepo: (repo) => set({ repo }), +})); From d93dda6a3d5554b03980fd0383c0a58c1ad6fa53 Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:08:39 +0900 Subject: [PATCH 05/49] =?UTF-8?q?refactor:=20data=20=EA=B4=80=EB=A0=A8=20c?= =?UTF-8?q?ontext=EB=A5=BC=20store=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 8 +++--- .../FilteredAuthors/FilteredAuthors.tsx | 4 +-- .../SelectedClusterGroup.tsx | 5 ++-- .../AuthorBarChart/AuthorBarChart.tsx | 4 +-- .../components/Statistics/Statistics.hook.tsx | 4 +-- .../TemporalFilter/TemporalFilter.tsx | 5 ++-- .../ClusterGraph/ClusterGraph.tsx | 4 +-- .../Summary/Summary.hook.tsx | 4 +-- .../VerticalClusterList/Summary/Summary.tsx | 4 +-- .../VerticalClusterList.tsx | 4 +-- packages/view/src/hooks/index.ts | 2 +- packages/view/src/hooks/useAnalayzedData.ts | 16 ++++++++++++ packages/view/src/index.common.tsx | 6 ++--- packages/view/src/store/data.ts | 25 +++++++++++++++++++ packages/view/src/store/index.ts | 1 + 15 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 packages/view/src/hooks/useAnalayzedData.ts create mode 100644 packages/view/src/store/data.ts diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 467a6218..1e21f10f 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -7,16 +7,16 @@ import MonoLogo from "assets/monoLogo.svg"; import { BranchSelector, Statistics, TemporalFilter, ThemeSelector, VerticalClusterList } from "components"; import "./App.scss"; import type IDEPort from "ide/IDEPort"; -import { useGlobalData } from "hooks"; +import { useAnalayzedData } from "hooks"; import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; -import { useBranchStore, useLoadingStore, useOwnerStore, useRepoStore } from "store"; +import { useBranchStore, useDataStore, useLoadingStore, useOwnerStore, useRepoStore } from "store"; const App = () => { const initRef = useRef(false); - - const { filteredData, handleChangeAnalyzedData } = useGlobalData(); + const { handleChangeAnalyzedData } = useAnalayzedData(); + const { filteredData } = useDataStore(); const { handleChangeBranchList } = useBranchStore(); const { loading, setLoading } = useLoadingStore(); const { setOwner } = useOwnerStore(); diff --git a/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx b/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx index 0f8d5c4a..e7a0ad08 100644 --- a/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx +++ b/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx @@ -1,12 +1,12 @@ import { Author } from "components/@common/Author"; import { usePreLoadAuthorImg } from "components/VerticalClusterList/Summary/Summary.hook"; import { getInitData } from "components/VerticalClusterList/Summary/Summary.util"; -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; import "./FilteredAuthors.scss"; const FilteredAuthors = () => { - const { selectedData } = useGlobalData(); + const { selectedData } = useDataStore(); const authSrcMap = usePreLoadAuthorImg(); const selectedClusters = getInitData(selectedData); diff --git a/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx b/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx index ce11e94e..5b9861db 100644 --- a/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx +++ b/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx @@ -4,12 +4,11 @@ import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded"; import { selectedDataUpdater } from "components/VerticalClusterList/VerticalClusterList.util"; import { getInitData, getClusterById } from "components/VerticalClusterList/Summary/Summary.util"; -import { useGlobalData } from "hooks"; - import "./SelectedClusterGroup.scss"; +import { useDataStore } from "store"; const SelectedClusterGroup = () => { - const { selectedData, setSelectedData } = useGlobalData(); + const { selectedData, setSelectedData } = useDataStore(); const selectedClusters = getInitData(selectedData); const [isOpen, setIsOpen] = useState(false); diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx index bc81fad1..bb6d3e23 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx @@ -4,8 +4,8 @@ import * as d3 from "d3"; import type { SelectChangeEvent } from "@mui/material"; import { FormControl, MenuItem, Select } from "@mui/material"; +import { useDataStore } from "store"; import type { ClusterNode, AuthorInfo } from "types"; -import { useGlobalData } from "hooks"; import { getAuthorProfileImgSrc } from "utils/author"; import { useGetSelectedData } from "../Statistics.hook"; @@ -17,7 +17,7 @@ import { DIMENSIONS, METRIC_TYPE } from "./AuthorBarChart.const"; import "./AuthorBarChart.scss"; const AuthorBarChart = () => { - const { data: totalData, filteredData, setSelectedData, setFilteredData } = useGlobalData(); + const { data: totalData, filteredData, setSelectedData, setFilteredData } = useDataStore(); const rawData = useGetSelectedData(); const svgRef = useRef(null); diff --git a/packages/view/src/components/Statistics/Statistics.hook.tsx b/packages/view/src/components/Statistics/Statistics.hook.tsx index 509b7b88..c478ac3f 100644 --- a/packages/view/src/components/Statistics/Statistics.hook.tsx +++ b/packages/view/src/components/Statistics/Statistics.hook.tsx @@ -1,6 +1,6 @@ -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; export const useGetSelectedData = () => { - const { filteredData, selectedData } = useGlobalData(); + const { filteredData, selectedData } = useDataStore(); return selectedData.length ? selectedData : filteredData; }; diff --git a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx index 686e305d..98946bd2 100644 --- a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx +++ b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx @@ -5,8 +5,7 @@ import * as d3 from "d3"; import BounceLoader from "react-spinners/BounceLoader"; import { Button } from "@mui/material"; -import { useGlobalData } from "hooks"; -import { useLoadingStore, useFilteredRangeStore } from "store"; +import { useLoadingStore, useFilteredRangeStore, useDataStore } from "store"; import { filterDataByDate, getMinMaxDate, lineChartTimeFormatter, sortBasedOnCommitNode } from "./TemporalFilter.util"; import "./TemporalFilter.scss"; @@ -18,7 +17,7 @@ import { createBrush, drawBrush, resetBrush } from "./LineChartBrush"; import { BRUSH_MARGIN, TEMPORAL_FILTER_LINE_CHART_STYLES } from "./LineChart.const"; const TemporalFilter = () => { - const { data, filteredData, setFilteredData, setSelectedData } = useGlobalData(); + const { data, filteredData, setFilteredData, setSelectedData } = useDataStore(); const { loading } = useLoadingStore(); const { filteredRange, setFilteredRange } = useFilteredRangeStore(); const brushGroupRef = useRef(null); diff --git a/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx b/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx index 108a5771..d22006f1 100644 --- a/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx +++ b/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; import type { ClusterGraphProps } from "types/ClusterGraphProps"; import { getGraphHeight, getSelectedIndex } from "./ClusterGraph.util"; @@ -10,7 +10,7 @@ import { useHandleClusterGraph } from "./ClusterGraph.hook"; import "./ClusterGraph.scss"; const ClusterGraph: React.FC = ({ data, clusterSizes }) => { - const { selectedData, setSelectedData } = useGlobalData(); + const { selectedData, setSelectedData } = useDataStore(); const selectedIndex = getSelectedIndex(data, selectedData); const graphHeight = getGraphHeight(clusterSizes) + selectedIndex.length * DETAIL_HEIGHT; diff --git a/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx b/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx index 27190177..cc160be3 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx @@ -1,12 +1,12 @@ import { useEffect, useState } from "react"; -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; import { getAuthSrcMap } from "./Summary.util"; import type { AuthSrcMap } from "./Summary.type"; export const usePreLoadAuthorImg = () => { - const { data } = useGlobalData(); + const { data } = useDataStore(); const [authSrcMap, setAuthSrcMap] = useState(null); useEffect(() => { diff --git a/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx b/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx index 3d8a91e0..b2557a5e 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx @@ -4,7 +4,7 @@ import { List, AutoSizer } from "react-virtualized"; import type { ClusterNode } from "types"; import { Detail } from "components"; -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; import "./Summary.scss"; import { Author } from "../../@common/Author"; @@ -21,7 +21,7 @@ const COLLAPSED_ROW_HEIGHT = CLUSTER_HEIGHT + NODE_GAP * 2; const EXPANDED_ROW_HEIGHT = DETAIL_HEIGHT + COLLAPSED_ROW_HEIGHT; const Summary = () => { - const { filteredData: data, selectedData, setSelectedData } = useGlobalData(); + const { filteredData: data, selectedData, setSelectedData } = useDataStore(); const clusters = getInitData(data); const detailRef = useRef(null); const authSrcMap = usePreLoadAuthorImg(); diff --git a/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx b/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx index 892ed2dc..972a820b 100644 --- a/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx +++ b/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx @@ -1,4 +1,4 @@ -import { useGlobalData } from "hooks"; +import { useDataStore } from "store"; import { FilteredAuthors } from "components/FilteredAuthors"; import { SelectedClusterGroup } from "components/SelectedClusterGroup"; @@ -7,7 +7,7 @@ import { Summary } from "./Summary"; import "./VerticalClusterList.scss"; const VerticalClusterList = () => { - const { selectedData } = useGlobalData(); + const { selectedData } = useDataStore(); return (
diff --git a/packages/view/src/hooks/index.ts b/packages/view/src/hooks/index.ts index 10d2f0ec..abc96b1c 100644 --- a/packages/view/src/hooks/index.ts +++ b/packages/view/src/hooks/index.ts @@ -1 +1 @@ -export * from "./useGlobalData"; +export * from "./useAnalayzedData"; diff --git a/packages/view/src/hooks/useAnalayzedData.ts b/packages/view/src/hooks/useAnalayzedData.ts new file mode 100644 index 00000000..e8275a94 --- /dev/null +++ b/packages/view/src/hooks/useAnalayzedData.ts @@ -0,0 +1,16 @@ +import { useDataStore, useLoadingStore } from "store"; +import type { ClusterNode } from "types"; + +export const useAnalayzedData = () => { + const { setData, setFilteredData, setSelectedData } = useDataStore(); + const { setLoading } = useLoadingStore(); + + const handleChangeAnalyzedData = (analyzedData: ClusterNode[]) => { + setData(analyzedData); + setFilteredData([...analyzedData.reverse()]); + setSelectedData([]); + setLoading(false); + }; + + return { handleChangeAnalyzedData }; +}; diff --git a/packages/view/src/index.common.tsx b/packages/view/src/index.common.tsx index 80500cbf..7bd8f6de 100644 --- a/packages/view/src/index.common.tsx +++ b/packages/view/src/index.common.tsx @@ -1,7 +1,7 @@ import ReactDOM from "react-dom/client"; import "./App.scss"; -import { GlobalDataProvider } from "./context/GlobalDataProvider"; + import App from "./App"; export const initRender = () => { @@ -10,9 +10,7 @@ export const initRender = () => { // TODO - StrictMode disabled temporarily to review performance of visualization. ReactDOM.createRoot(rootContainer).render( // - - - + // ); }; diff --git a/packages/view/src/store/data.ts b/packages/view/src/store/data.ts new file mode 100644 index 00000000..97f4e3c6 --- /dev/null +++ b/packages/view/src/store/data.ts @@ -0,0 +1,25 @@ +import { create } from "zustand"; +import type { Dispatch, SetStateAction } from "react"; + +import type { ClusterNode } from "types"; + +interface DataState { + data: ClusterNode[]; + filteredData: ClusterNode[]; + selectedData: ClusterNode[]; + setData: (data: ClusterNode[]) => void; + setFilteredData: (filteredData: ClusterNode[]) => void; + setSelectedData: Dispatch>; +} + +export const useDataStore = create((set) => ({ + data: [], + filteredData: [], + selectedData: [], + setData: (data) => set({ data }), + setFilteredData: (filteredData) => set({ filteredData }), + setSelectedData: (selectedData) => + set((state) => ({ + selectedData: typeof selectedData === "function" ? selectedData(state.selectedData) : selectedData, + })), +})); diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index 991b1d87..e9d468f6 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -3,3 +3,4 @@ export * from "./filteredRange"; export * from "./branch"; export * from "./repo"; export * from "./owner"; +export * from "./data"; From d7257e8c736c4ec7dceb9a0106b67a0870cf0745 Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:09:24 +0900 Subject: [PATCH 06/49] =?UTF-8?q?refactor:=20=EC=A0=84=EC=97=AD=20context?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/src/context/GlobalDataProvider.tsx | 34 ------------------- packages/view/src/hooks/useGlobalData.ts | 24 ------------- 2 files changed, 58 deletions(-) delete mode 100644 packages/view/src/context/GlobalDataProvider.tsx delete mode 100644 packages/view/src/hooks/useGlobalData.ts diff --git a/packages/view/src/context/GlobalDataProvider.tsx b/packages/view/src/context/GlobalDataProvider.tsx deleted file mode 100644 index b1b61811..00000000 --- a/packages/view/src/context/GlobalDataProvider.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import type { PropsWithChildren } from "react"; -import { useMemo, useState } from "react"; - -import { GlobalDataContext } from "hooks"; -import type { ClusterNode } from "types"; -import { useLoadingStore } from "store"; - -export const GlobalDataProvider = ({ children }: PropsWithChildren) => { - const [data, setData] = useState([]); - const [filteredData, setFilteredData] = useState(data); - const [selectedData, setSelectedData] = useState([]); - const { setLoading } = useLoadingStore(); - - const handleChangeAnalyzedData = (analyzedData: ClusterNode[]) => { - setData(analyzedData); - setFilteredData([...analyzedData.reverse()]); - setSelectedData([]); - setLoading(false); - }; - - const value = useMemo( - () => ({ - data, - filteredData, - setFilteredData, - selectedData, - setSelectedData, - handleChangeAnalyzedData, - }), - [data, filteredData, selectedData] - ); - - return {children}; -}; diff --git a/packages/view/src/hooks/useGlobalData.ts b/packages/view/src/hooks/useGlobalData.ts deleted file mode 100644 index 45f70a77..00000000 --- a/packages/view/src/hooks/useGlobalData.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Dispatch, SetStateAction } from "react"; -import { createContext, useContext } from "react"; - -import type { ClusterNode } from "types"; - -type GlobalDataState = { - data: ClusterNode[]; - filteredData: ClusterNode[]; - selectedData: ClusterNode[]; - setFilteredData: Dispatch>; - setSelectedData: Dispatch>; - handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; -}; // handleChangeBranchList를 임시로 제외 -> 추후 GlobalDataContext를 삭제할 예정 - -export const GlobalDataContext = createContext(undefined); - -export const useGlobalData = () => { - const globalData = useContext(GlobalDataContext); - if (!globalData) { - throw new Error("Cannot find GlobalDataProvider"); - } - - return globalData; -}; From 67175be061c6ae8d7b2eb2dc3b064ddad5dd7d22 Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Thu, 3 Oct 2024 16:21:47 +0900 Subject: [PATCH 07/49] =?UTF-8?q?refactor:=20dataStore=EB=A5=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=A0=20=EB=95=8C=20useShallow=EC=99=80?= =?UTF-8?q?=20=EC=84=A0=ED=83=9D=EC=A0=81=20=EA=B5=AC=EB=8F=85=EC=9D=84=20?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=ED=95=B4=EC=84=9C=20=EB=A6=AC=EB=A0=8C?= =?UTF-8?q?=EB=8D=94=EB=A7=81=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 하나의 상태만 가져오는 경우 선택적 구독 방식 사용 - 여러 상태와 액션 함수를 가져와야하는경우 useShallow를 사용 - useShallow사용시 배열 방식을 이용해서 코드를 간결하게 작성 --- packages/view/src/App.tsx | 3 +-- .../components/FilteredAuthors/FilteredAuthors.tsx | 2 +- .../SelectedClusterGroup/SelectedClusterGroup.tsx | 5 ++++- .../Statistics/AuthorBarChart/AuthorBarChart.tsx | 5 ++++- .../src/components/Statistics/Statistics.hook.tsx | 4 +++- .../components/TemporalFilter/TemporalFilter.tsx | 13 +++++++++---- .../ClusterGraph/ClusterGraph.tsx | 5 ++++- .../VerticalClusterList/Summary/Summary.hook.tsx | 2 +- .../VerticalClusterList/Summary/Summary.tsx | 13 ++++++++----- .../VerticalClusterList/VerticalClusterList.tsx | 2 +- packages/view/src/hooks/useAnalayzedData.ts | 6 +++++- 11 files changed, 41 insertions(+), 19 deletions(-) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 1e21f10f..217a7f9d 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -16,7 +16,7 @@ import { useBranchStore, useDataStore, useLoadingStore, useOwnerStore, useRepoSt const App = () => { const initRef = useRef(false); const { handleChangeAnalyzedData } = useAnalayzedData(); - const { filteredData } = useDataStore(); + const filteredData = useDataStore((state) => state.filteredData); const { handleChangeBranchList } = useBranchStore(); const { loading, setLoading } = useLoadingStore(); const { setOwner } = useOwnerStore(); @@ -29,7 +29,6 @@ const App = () => { handleChangeAnalyzedData, handleChangeBranchList, }; - setLoading(true); ideAdapter.addIDESentEventListener(callbacks); ideAdapter.sendFetchAnalyzedDataMessage(); diff --git a/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx b/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx index e7a0ad08..82ad83a9 100644 --- a/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx +++ b/packages/view/src/components/FilteredAuthors/FilteredAuthors.tsx @@ -6,7 +6,7 @@ import { useDataStore } from "store"; import "./FilteredAuthors.scss"; const FilteredAuthors = () => { - const { selectedData } = useDataStore(); + const selectedData = useDataStore((state) => state.selectedData); const authSrcMap = usePreLoadAuthorImg(); const selectedClusters = getInitData(selectedData); diff --git a/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx b/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx index 5b9861db..4324cd7e 100644 --- a/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx +++ b/packages/view/src/components/SelectedClusterGroup/SelectedClusterGroup.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import { useShallow } from "zustand/react/shallow"; import Chip from "@mui/material/Chip"; import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded"; @@ -8,7 +9,9 @@ import "./SelectedClusterGroup.scss"; import { useDataStore } from "store"; const SelectedClusterGroup = () => { - const { selectedData, setSelectedData } = useDataStore(); + const [selectedData, setSelectedData] = useDataStore( + useShallow((state) => [state.selectedData, state.setSelectedData]) + ); const selectedClusters = getInitData(selectedData); const [isOpen, setIsOpen] = useState(false); diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx index bb6d3e23..4a3c4786 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.tsx @@ -1,5 +1,6 @@ import type { MouseEvent } from "react"; import { useRef, useEffect, useState } from "react"; +import { useShallow } from "zustand/react/shallow"; import * as d3 from "d3"; import type { SelectChangeEvent } from "@mui/material"; import { FormControl, MenuItem, Select } from "@mui/material"; @@ -17,7 +18,9 @@ import { DIMENSIONS, METRIC_TYPE } from "./AuthorBarChart.const"; import "./AuthorBarChart.scss"; const AuthorBarChart = () => { - const { data: totalData, filteredData, setSelectedData, setFilteredData } = useDataStore(); + const [totalData, filteredData, setSelectedData, setFilteredData] = useDataStore( + useShallow((state) => [state.data, state.filteredData, state.setSelectedData, state.setFilteredData]) + ); const rawData = useGetSelectedData(); const svgRef = useRef(null); diff --git a/packages/view/src/components/Statistics/Statistics.hook.tsx b/packages/view/src/components/Statistics/Statistics.hook.tsx index c478ac3f..01017192 100644 --- a/packages/view/src/components/Statistics/Statistics.hook.tsx +++ b/packages/view/src/components/Statistics/Statistics.hook.tsx @@ -1,6 +1,8 @@ +import { useShallow } from "zustand/react/shallow"; + import { useDataStore } from "store"; export const useGetSelectedData = () => { - const { filteredData, selectedData } = useDataStore(); + const [filteredData, selectedData] = useDataStore(useShallow((state) => [state.filteredData, state.selectedData])); return selectedData.length ? selectedData : filteredData; }; diff --git a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx index 98946bd2..535e11e8 100644 --- a/packages/view/src/components/TemporalFilter/TemporalFilter.tsx +++ b/packages/view/src/components/TemporalFilter/TemporalFilter.tsx @@ -1,8 +1,9 @@ import "reflect-metadata"; import type { CSSProperties } from "react"; import { useEffect, useMemo, useRef } from "react"; -import * as d3 from "d3"; import BounceLoader from "react-spinners/BounceLoader"; +import * as d3 from "d3"; +import { useShallow } from "zustand/react/shallow"; import { Button } from "@mui/material"; import { useLoadingStore, useFilteredRangeStore, useDataStore } from "store"; @@ -17,9 +18,13 @@ import { createBrush, drawBrush, resetBrush } from "./LineChartBrush"; import { BRUSH_MARGIN, TEMPORAL_FILTER_LINE_CHART_STYLES } from "./LineChart.const"; const TemporalFilter = () => { - const { data, filteredData, setFilteredData, setSelectedData } = useDataStore(); - const { loading } = useLoadingStore(); - const { filteredRange, setFilteredRange } = useFilteredRangeStore(); + const [data, filteredData, setFilteredData, setSelectedData] = useDataStore( + useShallow((state) => [state.data, state.filteredData, state.setFilteredData, state.setSelectedData]) + ); + const [loading] = useLoadingStore(useShallow((state) => [state.loading])); + const [filteredRange, setFilteredRange] = useFilteredRangeStore( + useShallow((state) => [state.filteredRange, state.setFilteredRange]) + ); const brushGroupRef = useRef(null); const brushRef = useRef>(); diff --git a/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx b/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx index d22006f1..3666bcdf 100644 --- a/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx +++ b/packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { useShallow } from "zustand/react/shallow"; import { useDataStore } from "store"; import type { ClusterGraphProps } from "types/ClusterGraphProps"; @@ -10,7 +11,9 @@ import { useHandleClusterGraph } from "./ClusterGraph.hook"; import "./ClusterGraph.scss"; const ClusterGraph: React.FC = ({ data, clusterSizes }) => { - const { selectedData, setSelectedData } = useDataStore(); + const [selectedData, setSelectedData] = useDataStore( + useShallow((state) => [state.selectedData, state.setSelectedData]) + ); const selectedIndex = getSelectedIndex(data, selectedData); const graphHeight = getGraphHeight(clusterSizes) + selectedIndex.length * DETAIL_HEIGHT; diff --git a/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx b/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx index cc160be3..c1c1acf7 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Summary.hook.tsx @@ -6,7 +6,7 @@ import { getAuthSrcMap } from "./Summary.util"; import type { AuthSrcMap } from "./Summary.type"; export const usePreLoadAuthorImg = () => { - const { data } = useDataStore(); + const data = useDataStore((state) => state.data); const [authSrcMap, setAuthSrcMap] = useState(null); useEffect(() => { diff --git a/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx b/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx index b2557a5e..ce4217f0 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Summary.tsx @@ -1,6 +1,7 @@ import { useRef, useEffect } from "react"; import type { ListRowProps } from "react-virtualized"; import { List, AutoSizer } from "react-virtualized"; +import { useShallow } from "zustand/react/shallow"; import type { ClusterNode } from "types"; import { Detail } from "components"; @@ -21,16 +22,18 @@ const COLLAPSED_ROW_HEIGHT = CLUSTER_HEIGHT + NODE_GAP * 2; const EXPANDED_ROW_HEIGHT = DETAIL_HEIGHT + COLLAPSED_ROW_HEIGHT; const Summary = () => { - const { filteredData: data, selectedData, setSelectedData } = useDataStore(); - const clusters = getInitData(data); + const [filteredData, selectedData, setSelectedData] = useDataStore( + useShallow((state) => [state.filteredData, state.selectedData, state.setSelectedData]) + ); + const clusters = getInitData(filteredData); const detailRef = useRef(null); const authSrcMap = usePreLoadAuthorImg(); const selectedClusterId = getClusterIds(selectedData); const listRef = useRef(null); - const clusterSizes = getClusterSizes(data); + const clusterSizes = getClusterSizes(filteredData); const onClickClusterSummary = (clusterId: number) => () => { - const selected = getClusterById(data, clusterId); + const selected = getClusterById(filteredData, clusterId); setSelectedData((prevState: ClusterNode[]) => { return selectedDataUpdater(selected, clusterId)(prevState); }); @@ -63,7 +66,7 @@ const Summary = () => { >
diff --git a/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx b/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx index 972a820b..b3bc1680 100644 --- a/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx +++ b/packages/view/src/components/VerticalClusterList/VerticalClusterList.tsx @@ -7,7 +7,7 @@ import { Summary } from "./Summary"; import "./VerticalClusterList.scss"; const VerticalClusterList = () => { - const { selectedData } = useDataStore(); + const selectedData = useDataStore((state) => state.selectedData); return (
diff --git a/packages/view/src/hooks/useAnalayzedData.ts b/packages/view/src/hooks/useAnalayzedData.ts index e8275a94..0edbbaf8 100644 --- a/packages/view/src/hooks/useAnalayzedData.ts +++ b/packages/view/src/hooks/useAnalayzedData.ts @@ -1,8 +1,12 @@ +import { useShallow } from "zustand/react/shallow"; + import { useDataStore, useLoadingStore } from "store"; import type { ClusterNode } from "types"; export const useAnalayzedData = () => { - const { setData, setFilteredData, setSelectedData } = useDataStore(); + const [setData, setFilteredData, setSelectedData] = useDataStore( + useShallow((state) => [state.setData, state.setFilteredData, state.setSelectedData]) + ); const { setLoading } = useLoadingStore(); const handleChangeAnalyzedData = (analyzedData: ClusterNode[]) => { From f9821f3254c781ffc9520fdc287e4fbf79a9bd77 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:13:41 +0900 Subject: [PATCH 08/49] =?UTF-8?q?feat:=20vscode=20configuration=EC=9D=98?= =?UTF-8?q?=20custom-theme=20=EA=B0=92=EC=9D=84=20window=20=EC=A0=84?= =?UTF-8?q?=EC=97=AD=20=EB=B3=80=EC=88=98=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/public/index.html | 11 +++++++---- packages/view/src/types/custom.d.ts | 2 +- packages/vscode/src/webview-loader.ts | 16 +++++++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/view/public/index.html b/packages/view/public/index.html index 659b7f36..fcbf34de 100644 --- a/packages/view/public/index.html +++ b/packages/view/public/index.html @@ -1,11 +1,14 @@ - + - + Githru diff --git a/packages/view/src/types/custom.d.ts b/packages/view/src/types/custom.d.ts index d6311df9..cbe438ed 100644 --- a/packages/view/src/types/custom.d.ts +++ b/packages/view/src/types/custom.d.ts @@ -3,7 +3,7 @@ interface Window { githruNodesData: unknown; githruBranchesData: unknown; isProduction: boolean; - primaryColor: string; + theme: string; } declare module "*.svg" { diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index c7a19c65..579ae2ba 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -92,7 +92,7 @@ export default class WebviewLoader implements vscode.Disposable { // this.dispose(); // throw new Error("Project not connected to Git."); // } - this._panel.webview.html = this.getWebviewContent(this._panel.webview); + this.setWebviewContent(); } dispose() { @@ -111,13 +111,12 @@ export default class WebviewLoader implements vscode.Disposable { }); } - private getWebviewContent(webview: vscode.Webview): string { + private async getWebviewContent(webview: vscode.Webview): Promise { const reactAppPathOnDisk = vscode.Uri.file(path.join(this.extensionPath, "dist", "webviewApp.js")); const reactAppUri = webview.asWebviewUri(reactAppPathOnDisk); // const reactAppUri = reactAppPathOnDisk.with({ scheme: "vscode-resource" }); - const primaryColor = getPrimaryColor(); - + const theme = await getTheme(); const returnString = ` @@ -127,7 +126,7 @@ export default class WebviewLoader implements vscode.Disposable { githru-vscode-ext webview @@ -141,6 +140,13 @@ export default class WebviewLoader implements vscode.Disposable { `; return returnString; } + + private async setWebviewContent() { + if (this._panel) { + this._panel.webview.html = await this.getWebviewContent(this._panel.webview); + } + } + public setGlobalOwnerAndRepo(owner: string, repo: string) { if (this._panel) { this._panel.webview.postMessage({ From c6bd614a7f4a41e64fa578f7966a212357a261d7 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:15:04 +0900 Subject: [PATCH 09/49] =?UTF-8?q?feat:=20=ED=95=A8=EC=88=98/=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/ide/FakeIDEAdapter.ts | 8 ++++---- packages/view/src/ide/IDEPort.ts | 2 +- packages/view/src/ide/VSCodeIDEAdapter.ts | 6 +++--- packages/view/src/services/index.ts | 4 ++-- packages/view/src/types/IDEMessage.ts | 2 +- packages/vscode/package.json | 6 +++--- packages/vscode/src/setting-repository.ts | 23 +++++++++++------------ packages/vscode/src/webview-loader.ts | 8 ++++---- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/packages/view/src/ide/FakeIDEAdapter.ts b/packages/view/src/ide/FakeIDEAdapter.ts index 4a15f886..c23ddbc4 100644 --- a/packages/view/src/ide/FakeIDEAdapter.ts +++ b/packages/view/src/ide/FakeIDEAdapter.ts @@ -54,10 +54,10 @@ export default class FakeIDEAdapter implements IDEPort { this.sendMessageToMe(message); } - public setPrimaryColor(color: string) { + public setCustomTheme(color: string) { sessionStorage.setItem("PRIMARY_COLOR", color); const message: IDEMessage = { - command: "updatePrimaryColor", + command: "updateCustomTheme", }; this.sendMessageToMe(message); } @@ -76,10 +76,10 @@ export default class FakeIDEAdapter implements IDEPort { command, payload: JSON.stringify(fakeBranchList), }; - case "updatePrimaryColor": + case "updateCustomTheme": return { command, - payload: sessionStorage.getItem("PRIMARY_COLOR") as string, + payload: sessionStorage.getItem("CUSTOM_THEME") as string, }; default: return { diff --git a/packages/view/src/ide/IDEPort.ts b/packages/view/src/ide/IDEPort.ts index 5f13595f..77afc509 100644 --- a/packages/view/src/ide/IDEPort.ts +++ b/packages/view/src/ide/IDEPort.ts @@ -10,5 +10,5 @@ export default interface IDEPort { sendRefreshDataMessage: (payload?: string) => void; sendFetchAnalyzedDataMessage: (payload?: string) => void; sendFetchBranchListMessage: () => void; - setPrimaryColor: (color: string) => void; + setCustomTheme: (theme: string) => void; } diff --git a/packages/view/src/ide/VSCodeIDEAdapter.ts b/packages/view/src/ide/VSCodeIDEAdapter.ts index bee344a9..4d842209 100644 --- a/packages/view/src/ide/VSCodeIDEAdapter.ts +++ b/packages/view/src/ide/VSCodeIDEAdapter.ts @@ -49,10 +49,10 @@ export default class VSCodeIDEAdapter implements IDEPort { this.sendMessageToIDE(message); } - public setPrimaryColor(color: string) { + public setCustomTheme(theme: string) { const message: IDEMessage = { - command: "updatePrimaryColor", - payload: JSON.stringify({ primary: color }), + command: "updateCustomTheme", + payload: JSON.stringify({ theme }), }; this.sendMessageToIDE(message); } diff --git a/packages/view/src/services/index.ts b/packages/view/src/services/index.ts index ac523f27..8a29aa82 100644 --- a/packages/view/src/services/index.ts +++ b/packages/view/src/services/index.ts @@ -2,9 +2,9 @@ import { container } from "tsyringe"; import type IDEPort from "ide/IDEPort"; -export const setPrimaryColor = (color: string) => { +export const setCustomTheme = (color: string) => { const ideAdapter = container.resolve("IDEAdapter"); - ideAdapter.setPrimaryColor(color); + ideAdapter.setCustomTheme(color); }; export const sendFetchAnalyzedDataCommand = (selectedBranch?: string) => { diff --git a/packages/view/src/types/IDEMessage.ts b/packages/view/src/types/IDEMessage.ts index fe2deb2b..81881572 100644 --- a/packages/view/src/types/IDEMessage.ts +++ b/packages/view/src/types/IDEMessage.ts @@ -12,4 +12,4 @@ export type IDEMessageCommandNames = | "fetchAnalyzedData" | "fetchBranchList" | "fetchCurrentBranch" - | "updatePrimaryColor"; + | "updateCustomTheme"; diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 4f383b53..6d912420 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -62,10 +62,10 @@ "configuration": { "title": "Githru", "properties": { - "githru.color.primary": { + "githru.theme": { "type": "string", - "default": "#ff8272", - "description": "Insert your primary color." + "default": "githru", + "description": "Insert your theme name: githru, hacker-blue, aqua, cotton-candy, mono" } } } diff --git a/packages/vscode/src/setting-repository.ts b/packages/vscode/src/setting-repository.ts index a82726b4..a391aac3 100644 --- a/packages/vscode/src/setting-repository.ts +++ b/packages/vscode/src/setting-repository.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode"; const SETTING_PROPERTY_NAMES = { GITHUB_TOKEN: "githru.github.token", - PRIMARY_COLOR: "githru.color.primary", + THEME: "githru.theme", }; export const getGithubToken = async (secrets: vscode.SecretStorage) => { @@ -14,22 +14,21 @@ export const setGithubToken = async (secrets: vscode.SecretStorage, newGithubTok }; export const deleteGithubToken = async (secrets: vscode.SecretStorage) => { - return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); -} + return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); +}; -export const setPrimaryColor = (color: string) => { +export const setTheme = async (newTheme: string) => { const configuration = vscode.workspace.getConfiguration(); - configuration.update(SETTING_PROPERTY_NAMES.PRIMARY_COLOR, color); + configuration.update(SETTING_PROPERTY_NAMES.THEME, newTheme); }; -export const getPrimaryColor = (): string => { +export const getTheme = async (): Promise => { const configuration = vscode.workspace.getConfiguration(); - const primaryColor = configuration.get(SETTING_PROPERTY_NAMES.PRIMARY_COLOR) as string; + const theme = configuration.get(SETTING_PROPERTY_NAMES.THEME) as string; - if (!primaryColor) { - configuration.update(SETTING_PROPERTY_NAMES.PRIMARY_COLOR, "#ff8272"); - return "#ff8272"; - } else { - return primaryColor; + if (!theme) { + await setTheme("githru"); + return "githru"; } + return theme; }; diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 579ae2ba..4eaa8265 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -1,7 +1,7 @@ import * as path from "path"; import * as vscode from "vscode"; -import { getPrimaryColor, setPrimaryColor } from "./setting-repository"; +import { getTheme, setTheme } from "./setting-repository"; import type { ClusterNode } from "./types/Node"; const ANALYZE_DATA_KEY = "memento_analyzed_data"; @@ -77,10 +77,10 @@ export default class WebviewLoader implements vscode.Disposable { }); } - if (command === "updatePrimaryColor") { + if (command === "updateCustomTheme") { const colorCode = payload && JSON.parse(payload); - if (colorCode.primary) { - setPrimaryColor(colorCode.primary); + if (colorCode.theme) { + setTheme(colorCode.theme); } } } catch (e) { From c49f15d5950a6c5be4b100fc2604e273c4a6c5e4 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:17:10 +0900 Subject: [PATCH 10/49] =?UTF-8?q?feat:=20window=20=EC=A0=84=EC=97=AD=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EC=97=90=EC=84=9C=20custom-theme=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/components/ThemeSelector/ThemeSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index bb8efdbd..9393991d 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -104,7 +104,7 @@ const ThemeSelector = () => { }; useEffect(() => { - document.documentElement.setAttribute("custom-type", "githru"); + document.documentElement.setAttribute("custom-type", window.theme); }, []); return ( From 78e43a954a7551e93f65f4b4a69c58989e824dac Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:17:48 +0900 Subject: [PATCH 11/49] =?UTF-8?q?refactor:=20themeInfo=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThemeSelector/ThemeSelector.tsx | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 9393991d..045a0337 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -3,7 +3,23 @@ import "./ThemeSelector.scss"; import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome"; import CloseIcon from "@mui/icons-material/Close"; -const themes = [ +import { setCustomTheme } from "services"; + +type ThemeInfo = { + title: string; + value: string; + colors: { + primary: string; + secondary: string; + tertiary: string; + }; +}; + +type ThemeIconsProps = ThemeInfo & { + onClick: () => void; +}; + +const themeInfo: ThemeInfo[] = [ { title: "Githru", value: "githru", @@ -52,17 +68,6 @@ const themes = [ }, ]; -type ThemeIconsProps = { - title: string; - value: string; - colors: { - primary: string; - secondary: string; - tertiary: string; - }; - onClick: () => void; -}; - const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { const [isSelected, setIsSelected] = useState(""); From e03075f0fe25a3c51148c2b0e6cbb1b7d6b5dca8 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:18:17 +0900 Subject: [PATCH 12/49] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EC=9D=BC=EB=B6=80=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThemeSelector/ThemeSelector.tsx | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 045a0337..8e269a26 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -69,32 +69,27 @@ const themeInfo: ThemeInfo[] = [ ]; const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { - const [isSelected, setIsSelected] = useState(""); + const [selectedItem, setSelectedItem] = useState(""); useEffect(() => { const selectedTheme = document.documentElement.getAttribute("custom-type"); - if (selectedTheme) setIsSelected(selectedTheme); + if (selectedTheme) setSelectedItem(selectedTheme); }, []); return (
-
-
-
+ {Object.values(colors).map((color, index) => ( +
+ ))}

{title}

@@ -102,9 +97,10 @@ const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { }; const ThemeSelector = () => { - const [open, setOpen] = useState(false); + const [isOpen, setIsOpen] = useState(false); const handleTheme = (value: string) => { + setCustomTheme(value); document.documentElement.setAttribute("custom-type", value); }; @@ -114,26 +110,24 @@ const ThemeSelector = () => { return (
- setOpen(true)} /> - {open && ( + setIsOpen(true)} /> + {isOpen && (

Theme

setOpen(false)} + onClick={() => setIsOpen(false)} />
- {themes.map((theme) => ( + {themeInfo.map((theme) => ( { handleTheme(theme.value); - setOpen(false); + setIsOpen(false); }} /> ))} From 7bd6aa53899f5e253685cbdc369fa10864ed42b4 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sat, 5 Oct 2024 11:21:26 +0900 Subject: [PATCH 13/49] =?UTF-8?q?feat:=20ThemeSelector=20=EC=98=81?= =?UTF-8?q?=EC=97=AD=20=EC=99=B8=20=ED=81=B4=EB=A6=AD=20=EC=8B=9C=20?= =?UTF-8?q?=EC=B0=BD=20=EB=8B=AB=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThemeSelector/ThemeSelector.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 8e269a26..d5abaebb 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import "./ThemeSelector.scss"; import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome"; import CloseIcon from "@mui/icons-material/Close"; @@ -98,18 +98,34 @@ const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { const ThemeSelector = () => { const [isOpen, setIsOpen] = useState(false); + const themeSelectorRef = useRef(null); const handleTheme = (value: string) => { setCustomTheme(value); document.documentElement.setAttribute("custom-type", value); }; + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (themeSelectorRef.current && !themeSelectorRef.current.contains(event.target as Node)) { + setIsOpen(false); + } + }; + document.addEventListener("mousedown", handleClickOutside); + return () => { + document.removeEventListener("mousedown", handleClickOutside); + }; + }, []); + useEffect(() => { document.documentElement.setAttribute("custom-type", window.theme); }, []); return ( -
+
setIsOpen(true)} /> {isOpen && (
From 40c1ffa32a0d71a01081f53b47010af71657cc5e Mon Sep 17 00:00:00 2001 From: Sang-minKIM <87116017+Sang-minKIM@users.noreply.github.com> Date: Sat, 5 Oct 2024 21:54:00 +0900 Subject: [PATCH 14/49] =?UTF-8?q?chore:=20interface=EB=A5=BC=20type?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/store/data.ts | 4 ++-- packages/view/src/store/loading.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/view/src/store/data.ts b/packages/view/src/store/data.ts index 97f4e3c6..55475ab6 100644 --- a/packages/view/src/store/data.ts +++ b/packages/view/src/store/data.ts @@ -3,14 +3,14 @@ import type { Dispatch, SetStateAction } from "react"; import type { ClusterNode } from "types"; -interface DataState { +type DataState = { data: ClusterNode[]; filteredData: ClusterNode[]; selectedData: ClusterNode[]; setData: (data: ClusterNode[]) => void; setFilteredData: (filteredData: ClusterNode[]) => void; setSelectedData: Dispatch>; -} +}; export const useDataStore = create((set) => ({ data: [], diff --git a/packages/view/src/store/loading.ts b/packages/view/src/store/loading.ts index 921810d5..c3e31d28 100644 --- a/packages/view/src/store/loading.ts +++ b/packages/view/src/store/loading.ts @@ -1,9 +1,9 @@ import { create } from "zustand"; -interface LoadingState { +type LoadingState = { loading: boolean; setLoading: (loading: boolean) => void; -} +}; export const useLoadingStore = create((set) => ({ loading: false, From 68b0205676b1bc9dc3f86aa01124a31c086c3863 Mon Sep 17 00:00:00 2001 From: shgusgh12 Date: Sun, 6 Oct 2024 21:08:59 +0900 Subject: [PATCH 15/49] test(view): debounce test --- packages/view/src/utils/debounce.test.ts | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/view/src/utils/debounce.test.ts diff --git a/packages/view/src/utils/debounce.test.ts b/packages/view/src/utils/debounce.test.ts new file mode 100644 index 00000000..6649f92f --- /dev/null +++ b/packages/view/src/utils/debounce.test.ts @@ -0,0 +1,35 @@ +import { debounce } from "./debounce"; + +jest.useFakeTimers(); + +describe("debounce", () => { + it("check debounce", () => { + const mockFn = jest.fn(); + const debouncedFunc = debounce(mockFn, 1000); + + debouncedFunc("test1"); + debouncedFunc("test2"); + + expect(mockFn).not.toBeCalled(); + + jest.advanceTimersByTime(999); + expect(mockFn).not.toBeCalled(); + + jest.advanceTimersByTime(1); + expect(mockFn).toHaveBeenCalledTimes(1); + expect(mockFn).toHaveBeenCalledWith("test2"); + }); + + it("check default delay", () => { + const mockFn = jest.fn(); + const debouncedFunc = debounce(mockFn); + + debouncedFunc("test"); + + jest.advanceTimersByTime(999); + expect(mockFn).not.toBeCalled(); + + jest.advanceTimersByTime(1); + expect(mockFn).toHaveBeenCalledTimes(1); + }); +}); From 584623c88d20146221580adba0701ec2b7bebbee Mon Sep 17 00:00:00 2001 From: shgusgh12 Date: Sun, 6 Oct 2024 21:09:15 +0900 Subject: [PATCH 16/49] test(view): throttle test --- packages/view/src/utils/throttle.test.ts | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 packages/view/src/utils/throttle.test.ts diff --git a/packages/view/src/utils/throttle.test.ts b/packages/view/src/utils/throttle.test.ts new file mode 100644 index 00000000..7b05b4e3 --- /dev/null +++ b/packages/view/src/utils/throttle.test.ts @@ -0,0 +1,41 @@ +import { throttle } from "./throttle"; + +jest.useFakeTimers(); + +describe("throttle", () => { + it("check throttle", () => { + const mockFn = jest.fn(); + const throttledFunc = throttle(mockFn, 1000); + + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(1); + + throttledFunc(); + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(1); + + jest.advanceTimersByTime(999); + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(1); + + jest.advanceTimersByTime(1); + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(2); + }); + + it("check default delay", () => { + const mockFn = jest.fn(); + const throttledFunc = throttle(mockFn); + + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(1); + + throttledFunc(); + jest.advanceTimersByTime(999); + expect(mockFn).toHaveBeenCalledTimes(1); + + jest.advanceTimersByTime(1); + throttledFunc(); + expect(mockFn).toHaveBeenCalledTimes(2); + }); +}); From ec870274efe6ccc39c5f1b146bdaf1e1c3c05b2c Mon Sep 17 00:00:00 2001 From: HyunJin <102955516+xxxjinn@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:36:56 +0900 Subject: [PATCH 17/49] =?UTF-8?q?[view]=20AuthorBarChart=20util=20test=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1=20(#746)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: edit author bar chart width (200 to 250) * style: edit select-box styling * feat: change select box from select tag to mui select * style: edit style branch select dropdown (add marginTop) * feat: edit branch-list fake-assets for branch name length test * feat: add BranchSelector.const file for branch name slice length * feat: add suffix (...) to branch name * refactor(view): edit branch-list fake-assets * test(view): AuthorBarChart util test - return empty data * test(view): AuthorBarChart util test- correctly provide commit information * refactor(view): AuthorBarChart util test expect에 type 추가 * test(view): AuthorBarChart util - sortDataByName test * test(view): AuthorBarChart util - convertNumberFormat test * test(view): AuthorBarChart util - sortDataByAuthor test * test(view): AuthorBarChart util - convertNumberFormat delete tc --- .../AuthorBarChart.util.test.ts | 146 +++++++++++++++++- 1 file changed, 143 insertions(+), 3 deletions(-) diff --git a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts index 57bec39f..37f60ef7 100644 --- a/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts +++ b/packages/view/src/components/Statistics/AuthorBarChart/AuthorBarChart.util.test.ts @@ -1,7 +1,8 @@ -import type { ClusterNode } from "types"; +import type { ClusterNode, CommitNode } from "types"; import type { Commit } from "types/Commit"; -import { getDataByAuthor } from "./AuthorBarChart.util"; +import { convertNumberFormat, getDataByAuthor, sortDataByAuthor, sortDataByName } from "./AuthorBarChart.util"; +import type { AuthorDataType } from "./AuthorBarChart.type"; describe("getDataByAuthor", () => { it("should return empty array if no data is provided", () => { @@ -87,6 +88,145 @@ describe("getDataByAuthor", () => { insertion: 3, deletion: 2, }, - ]); + ] as AuthorDataType[]); + }); +}); + +describe("sortDataByName", () => { + it("should return 1 when nameA is lexicographically smaller than nameB", () => { + const result = sortDataByName("apple", "banana"); + expect(result).toBe(1); + }); + + it("should return -1 when nameA is lexicographically larger than nameB", () => { + const result = sortDataByName("banana", "apple"); + expect(result).toBe(-1); + }); + + it("should return 0 when nameA is equal to nameB", () => { + const result = sortDataByName("apple", "APPLE"); + expect(result).toBe(0); + }); +}); + +describe("convertNumberFormat", () => { + it("should return the number as a string if it's between 0 and 1", () => { + const result = convertNumberFormat(0.5); + expect(result).toBe("0.5"); + }); + + it("should format numbers greater than 1", () => { + const result = convertNumberFormat(1000); + expect(result).toBe("1k"); + }); +}); + +describe("sortDataByAuthor", () => { + it("should filter clusters based on author names", () => { + const fakeData: ClusterNode[] = [ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + } as CommitNode["commit"], + seq: 1, + clusterId: 101, + }, + { + nodeTypeName: "COMMIT", + commit: { + id: "2", + parentIds: ["1"], + author: { names: ["author2"] }, + committer: { names: ["author2"] }, + authorDate: "2024-01-02T00:00:00Z", + commitDate: "2024-01-02T00:00:00Z", + diffStatistics: { + insertions: 2, + deletions: 1, + }, + message: "Second commit", + } as CommitNode["commit"], + seq: 2, + clusterId: 101, + }, + ], + }, + ]; + + const names = ["author1"]; + const result = sortDataByAuthor(fakeData, names); + + expect(result).toEqual([ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + }, + seq: 1, + clusterId: 101, + }, + ], + }, + ] as ClusterNode[]); + }); + + it("should return an empty array if no author matches", () => { + const fakeData: ClusterNode[] = [ + { + nodeTypeName: "CLUSTER", + commitNodeList: [ + { + nodeTypeName: "COMMIT", + commit: { + id: "1", + parentIds: ["0"], + author: { names: ["author1"] }, + committer: { names: ["author1"] }, + authorDate: "2024-01-01T00:00:00Z", + commitDate: "2024-01-01T00:00:00Z", + diffStatistics: { + insertions: 5, + deletions: 3, + }, + message: "Initial commit", + } as CommitNode["commit"], + seq: 1, + clusterId: 101, + }, + ], + }, + ]; + + const names = ["nonexistentAuthor"]; + const result = sortDataByAuthor(fakeData, names); + + expect(result).toEqual([]); }); }); From 819a9dc1a298d21c314a4b25b3d03880d4fd0127 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sun, 13 Oct 2024 14:45:18 +0900 Subject: [PATCH 18/49] =?UTF-8?q?feat(view):=20=ED=85=8C=EB=A7=88=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EC=8B=9C=20window.value=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/components/ThemeSelector/ThemeSelector.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index d5abaebb..5057c983 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -102,6 +102,7 @@ const ThemeSelector = () => { const handleTheme = (value: string) => { setCustomTheme(value); + window.theme = value; document.documentElement.setAttribute("custom-type", value); }; From 031deaf16aaa4a3951e278d8dc81e9b591decea3 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sun, 13 Oct 2024 14:46:17 +0900 Subject: [PATCH 19/49] =?UTF-8?q?feat(view):=20=EB=A1=9C=EB=94=A9=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=ED=85=8C=EB=A7=88?= =?UTF-8?q?=EC=83=89=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 217a7f9d..175c0746 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -12,6 +12,7 @@ import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; import { useBranchStore, useDataStore, useLoadingStore, useOwnerStore, useRepoStore } from "store"; +import { THEME_INFO } from "components/ThemeSelector/ThemeSelector.const"; const App = () => { const initRef = useRef(false); @@ -53,7 +54,7 @@ const App = () => { if (loading) { return ( Date: Sun, 13 Oct 2024 14:50:54 +0900 Subject: [PATCH 20/49] =?UTF-8?q?refactor(view):=20=ED=85=8C=EB=A7=88=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EB=B3=80=EC=88=98,=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThemeSelector/ThemeSelector.const.ts | 49 ++++++++++++++ .../ThemeSelector/ThemeSelector.tsx | 64 ++----------------- .../ThemeSelector/ThemeSelector.type.ts | 11 ++++ 3 files changed, 64 insertions(+), 60 deletions(-) create mode 100644 packages/view/src/components/ThemeSelector/ThemeSelector.const.ts create mode 100644 packages/view/src/components/ThemeSelector/ThemeSelector.type.ts diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.const.ts b/packages/view/src/components/ThemeSelector/ThemeSelector.const.ts new file mode 100644 index 00000000..c37dc922 --- /dev/null +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.const.ts @@ -0,0 +1,49 @@ +import type { ThemeInfo } from "./ThemeSelector.type"; + +export const THEME_INFO: ThemeInfo = { + githru: { + title: "Githru", + value: "githru", + colors: { + primary: "#e06091", + secondary: "#8840bb", + tertiary: "#ffd08a", + }, + }, + "hacker-blue": { + title: "Hacker Blue", + value: "hacker-blue", + colors: { + primary: "#456cf7", + secondary: "#3f4c73", + tertiary: "#6c60f0", + }, + }, + aqua: { + title: "Aqua", + value: "aqua", + colors: { + primary: "#51decd", + secondary: "#0687a3", + tertiary: "#a7ffff", + }, + }, + "cotton-candy": { + title: "Cotton Candy", + value: "cotton-candy", + colors: { + primary: "#ffcccb", + secondary: "#feffd1", + tertiary: "#a39aeb", + }, + }, + mono: { + title: "Mono", + value: "mono", + colors: { + primary: "#68788f", + secondary: "#3a4776", + tertiary: "#9aaed1", + }, + }, +}; diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 5057c983..61cedf4d 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -5,69 +5,13 @@ import CloseIcon from "@mui/icons-material/Close"; import { setCustomTheme } from "services"; -type ThemeInfo = { - title: string; - value: string; - colors: { - primary: string; - secondary: string; - tertiary: string; - }; -}; +import { THEME_INFO } from "./ThemeSelector.const"; +import type { ThemeInfo } from "./ThemeSelector.type"; -type ThemeIconsProps = ThemeInfo & { +type ThemeIconsProps = ThemeInfo[keyof ThemeInfo] & { onClick: () => void; }; -const themeInfo: ThemeInfo[] = [ - { - title: "Githru", - value: "githru", - colors: { - primary: "#e06091", - secondary: "#8840bb", - tertiary: "#ffd08a", - }, - }, - { - title: "Hacker Blue", - value: "hacker-blue", - colors: { - primary: "#456cf7", - secondary: "#3f4c73", - tertiary: "#6c60f0", - }, - }, - { - title: "Aqua", - value: "aqua", - colors: { - primary: "#51decd", - secondary: "#0687a3", - tertiary: "#a7ffff", - }, - }, - { - title: "Cotton Candy", - value: "cotton-candy", - colors: { - primary: "#ffcccb", - secondary: "#feffd1", - tertiary: "#a39aeb", - }, - }, - - { - title: "Mono", - value: "mono", - colors: { - primary: "#68788f", - secondary: "#3a4776", - tertiary: "#9aaed1", - }, - }, -]; - const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { const [selectedItem, setSelectedItem] = useState(""); @@ -138,7 +82,7 @@ const ThemeSelector = () => { />
- {themeInfo.map((theme) => ( + {Object.entries(THEME_INFO).map(([_, theme]) => ( Date: Sun, 13 Oct 2024 14:54:04 +0900 Subject: [PATCH 21/49] =?UTF-8?q?fix(view):=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=B9=84=EB=8F=99=EA=B8=B0=20=EA=B5=AC=EB=AC=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/setting-repository.ts | 6 +++--- packages/vscode/src/webview-loader.ts | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/vscode/src/setting-repository.ts b/packages/vscode/src/setting-repository.ts index a391aac3..16bbbeb3 100644 --- a/packages/vscode/src/setting-repository.ts +++ b/packages/vscode/src/setting-repository.ts @@ -17,17 +17,17 @@ export const deleteGithubToken = async (secrets: vscode.SecretStorage) => { return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); }; -export const setTheme = async (newTheme: string) => { +export const setTheme = (newTheme: string) => { const configuration = vscode.workspace.getConfiguration(); configuration.update(SETTING_PROPERTY_NAMES.THEME, newTheme); }; -export const getTheme = async (): Promise => { +export const getTheme = () => { const configuration = vscode.workspace.getConfiguration(); const theme = configuration.get(SETTING_PROPERTY_NAMES.THEME) as string; if (!theme) { - await setTheme("githru"); + setTheme("githru"); return "githru"; } return theme; diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 4eaa8265..920e2ae9 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -92,7 +92,7 @@ export default class WebviewLoader implements vscode.Disposable { // this.dispose(); // throw new Error("Project not connected to Git."); // } - this.setWebviewContent(); + this._panel.webview.html = this.getWebviewContent(this._panel.webview); } dispose() { @@ -111,12 +111,12 @@ export default class WebviewLoader implements vscode.Disposable { }); } - private async getWebviewContent(webview: vscode.Webview): Promise { + private getWebviewContent(webview: vscode.Webview) { const reactAppPathOnDisk = vscode.Uri.file(path.join(this.extensionPath, "dist", "webviewApp.js")); const reactAppUri = webview.asWebviewUri(reactAppPathOnDisk); // const reactAppUri = reactAppPathOnDisk.with({ scheme: "vscode-resource" }); - const theme = await getTheme(); + const theme = getTheme(); const returnString = ` @@ -141,12 +141,6 @@ export default class WebviewLoader implements vscode.Disposable { return returnString; } - private async setWebviewContent() { - if (this._panel) { - this._panel.webview.html = await this.getWebviewContent(this._panel.webview); - } - } - public setGlobalOwnerAndRepo(owner: string, repo: string) { if (this._panel) { this._panel.webview.postMessage({ From 651ce0c7a6584a67a167ec03c4842d35312ee3f6 Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sun, 13 Oct 2024 15:12:47 +0900 Subject: [PATCH 22/49] =?UTF-8?q?refactor(view):=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=AA=85=20CustomTheme=20->=20Theme=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ThemeSelector/ThemeSelector.tsx | 10 +++++----- packages/view/src/ide/FakeIDEAdapter.ts | 8 ++++---- packages/view/src/ide/IDEPort.ts | 2 +- packages/view/src/ide/VSCodeIDEAdapter.ts | 4 ++-- packages/view/src/services/index.ts | 4 ++-- packages/view/src/styles/_colors.scss | 10 +++++----- packages/view/src/types/IDEMessage.ts | 2 +- packages/vscode/src/setting-repository.ts | 4 ++-- packages/vscode/src/webview-loader.ts | 8 ++++---- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 61cedf4d..8eccc812 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -3,7 +3,7 @@ import "./ThemeSelector.scss"; import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome"; import CloseIcon from "@mui/icons-material/Close"; -import { setCustomTheme } from "services"; +import { sendUpdateThemeCommand } from "services"; import { THEME_INFO } from "./ThemeSelector.const"; import type { ThemeInfo } from "./ThemeSelector.type"; @@ -16,7 +16,7 @@ const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { const [selectedItem, setSelectedItem] = useState(""); useEffect(() => { - const selectedTheme = document.documentElement.getAttribute("custom-type"); + const selectedTheme = document.documentElement.getAttribute("theme"); if (selectedTheme) setSelectedItem(selectedTheme); }, []); @@ -45,9 +45,9 @@ const ThemeSelector = () => { const themeSelectorRef = useRef(null); const handleTheme = (value: string) => { - setCustomTheme(value); + sendUpdateThemeCommand(value); window.theme = value; - document.documentElement.setAttribute("custom-type", value); + document.documentElement.setAttribute("theme", value); }; useEffect(() => { @@ -63,7 +63,7 @@ const ThemeSelector = () => { }, []); useEffect(() => { - document.documentElement.setAttribute("custom-type", window.theme); + document.documentElement.setAttribute("theme", window.theme); }, []); return ( diff --git a/packages/view/src/ide/FakeIDEAdapter.ts b/packages/view/src/ide/FakeIDEAdapter.ts index c23ddbc4..8efd3827 100644 --- a/packages/view/src/ide/FakeIDEAdapter.ts +++ b/packages/view/src/ide/FakeIDEAdapter.ts @@ -54,10 +54,10 @@ export default class FakeIDEAdapter implements IDEPort { this.sendMessageToMe(message); } - public setCustomTheme(color: string) { - sessionStorage.setItem("PRIMARY_COLOR", color); + public sendUpdateThemeMessage(theme: string) { + sessionStorage.setItem("THEME", theme); const message: IDEMessage = { - command: "updateCustomTheme", + command: "updateTheme", }; this.sendMessageToMe(message); } @@ -76,7 +76,7 @@ export default class FakeIDEAdapter implements IDEPort { command, payload: JSON.stringify(fakeBranchList), }; - case "updateCustomTheme": + case "updateTheme": return { command, payload: sessionStorage.getItem("CUSTOM_THEME") as string, diff --git a/packages/view/src/ide/IDEPort.ts b/packages/view/src/ide/IDEPort.ts index 77afc509..9a96c89c 100644 --- a/packages/view/src/ide/IDEPort.ts +++ b/packages/view/src/ide/IDEPort.ts @@ -10,5 +10,5 @@ export default interface IDEPort { sendRefreshDataMessage: (payload?: string) => void; sendFetchAnalyzedDataMessage: (payload?: string) => void; sendFetchBranchListMessage: () => void; - setCustomTheme: (theme: string) => void; + sendUpdateThemeMessage: (theme: string) => void; } diff --git a/packages/view/src/ide/VSCodeIDEAdapter.ts b/packages/view/src/ide/VSCodeIDEAdapter.ts index 4d842209..4d4d3e30 100644 --- a/packages/view/src/ide/VSCodeIDEAdapter.ts +++ b/packages/view/src/ide/VSCodeIDEAdapter.ts @@ -49,9 +49,9 @@ export default class VSCodeIDEAdapter implements IDEPort { this.sendMessageToIDE(message); } - public setCustomTheme(theme: string) { + public sendUpdateThemeMessage(theme: string) { const message: IDEMessage = { - command: "updateCustomTheme", + command: "updateTheme", payload: JSON.stringify({ theme }), }; this.sendMessageToIDE(message); diff --git a/packages/view/src/services/index.ts b/packages/view/src/services/index.ts index 8a29aa82..754ca3c8 100644 --- a/packages/view/src/services/index.ts +++ b/packages/view/src/services/index.ts @@ -2,9 +2,9 @@ import { container } from "tsyringe"; import type IDEPort from "ide/IDEPort"; -export const setCustomTheme = (color: string) => { +export const sendUpdateThemeCommand = (theme: string) => { const ideAdapter = container.resolve("IDEAdapter"); - ideAdapter.setCustomTheme(color); + ideAdapter.sendUpdateThemeMessage(theme); }; export const sendFetchAnalyzedDataCommand = (selectedBranch?: string) => { diff --git a/packages/view/src/styles/_colors.scss b/packages/view/src/styles/_colors.scss index d7294f6d..31d45d87 100644 --- a/packages/view/src/styles/_colors.scss +++ b/packages/view/src/styles/_colors.scss @@ -5,7 +5,7 @@ $color-medium-gray: #757880; $color-dark-gray: #3c4048; $color-background: #222324; -html[custom-type="githru"] { +html[theme="githru"] { --color-primary: #e06091; --color-secondary: #8840bb; --color-tertiary: #ffd08a; @@ -13,7 +13,7 @@ html[custom-type="githru"] { --color-failed: #ee2479; } -html[custom-type="hacker-blue"] { +html[theme="hacker-blue"] { --color-primary: #456cf7; --color-secondary: #3f4c73; --color-tertiary: #6c60f0; @@ -21,7 +21,7 @@ html[custom-type="hacker-blue"] { --color-failed: #ee2479; } -html[custom-type="aqua"] { +html[theme="aqua"] { --color-primary: #51decd; --color-secondary: #0687a3; --color-tertiary: #a7ffff; @@ -29,7 +29,7 @@ html[custom-type="aqua"] { --color-failed: #ee2479; } -html[custom-type="cotton-candy"] { +html[theme="cotton-candy"] { --color-primary: #ffcccb; --color-secondary: #feffd1; --color-tertiary: #a39aeb; @@ -37,7 +37,7 @@ html[custom-type="cotton-candy"] { --color-failed: #ff8bbc; } -html[custom-type="mono"] { +html[theme="mono"] { --color-primary: #68788f; --color-secondary: #3a4776; --color-tertiary: #9aaed1; diff --git a/packages/view/src/types/IDEMessage.ts b/packages/view/src/types/IDEMessage.ts index 81881572..bbe48a88 100644 --- a/packages/view/src/types/IDEMessage.ts +++ b/packages/view/src/types/IDEMessage.ts @@ -12,4 +12,4 @@ export type IDEMessageCommandNames = | "fetchAnalyzedData" | "fetchBranchList" | "fetchCurrentBranch" - | "updateCustomTheme"; + | "updateTheme"; diff --git a/packages/vscode/src/setting-repository.ts b/packages/vscode/src/setting-repository.ts index 16bbbeb3..0a62b45a 100644 --- a/packages/vscode/src/setting-repository.ts +++ b/packages/vscode/src/setting-repository.ts @@ -17,9 +17,9 @@ export const deleteGithubToken = async (secrets: vscode.SecretStorage) => { return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); }; -export const setTheme = (newTheme: string) => { +export const setTheme = (theme: string) => { const configuration = vscode.workspace.getConfiguration(); - configuration.update(SETTING_PROPERTY_NAMES.THEME, newTheme); + configuration.update(SETTING_PROPERTY_NAMES.THEME, theme); }; export const getTheme = () => { diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 920e2ae9..ad62c53c 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -77,10 +77,10 @@ export default class WebviewLoader implements vscode.Disposable { }); } - if (command === "updateCustomTheme") { - const colorCode = payload && JSON.parse(payload); - if (colorCode.theme) { - setTheme(colorCode.theme); + if (command === "updateTheme") { + const themeInfo = payload && JSON.parse(payload); + if (themeInfo.theme) { + setTheme(themeInfo.theme); } } } catch (e) { From 0f92f97c606dd47aa86f5cdb3bf245f1e6e25ddb Mon Sep 17 00:00:00 2001 From: taboowiths Date: Sun, 13 Oct 2024 15:27:10 +0900 Subject: [PATCH 23/49] =?UTF-8?q?fix(view):=20window.theme=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=ED=9B=84=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/src/components/ThemeSelector/ThemeSelector.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx index 8eccc812..c5410927 100644 --- a/packages/view/src/components/ThemeSelector/ThemeSelector.tsx +++ b/packages/view/src/components/ThemeSelector/ThemeSelector.tsx @@ -13,16 +13,9 @@ type ThemeIconsProps = ThemeInfo[keyof ThemeInfo] & { }; const ThemeIcons = ({ title, value, colors, onClick }: ThemeIconsProps) => { - const [selectedItem, setSelectedItem] = useState(""); - - useEffect(() => { - const selectedTheme = document.documentElement.getAttribute("theme"); - if (selectedTheme) setSelectedItem(selectedTheme); - }, []); - return (
From 32d04750d0d5070091a8899cba9304f795d4478c Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 19:55:29 +0900 Subject: [PATCH 24/49] =?UTF-8?q?chore(engine):=20constant=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/constant.ts | 2 -- packages/analysis-engine/src/index.ts | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 packages/analysis-engine/src/constant.ts diff --git a/packages/analysis-engine/src/constant.ts b/packages/analysis-engine/src/constant.ts deleted file mode 100644 index 07a83dad..00000000 --- a/packages/analysis-engine/src/constant.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const COMMIT_SEPARATOR = "4itc2s8hH-oA64s08h19"; -export const GIT_LOG_SEPARATOR = "I9M-0XOzvHlYPegVPpzb"; diff --git a/packages/analysis-engine/src/index.ts b/packages/analysis-engine/src/index.ts index 1549803d..91bf1899 100644 --- a/packages/analysis-engine/src/index.ts +++ b/packages/analysis-engine/src/index.ts @@ -75,7 +75,7 @@ export class AnalysisEngine { if (this.isDebugMode) console.log("stemDict: ", stemDict); const csmDict = buildCSMDict(commitDict, stemDict, this.baseBranchName, pullRequests); if (this.isDebugMode) console.log("csmDict: ", csmDict); - const nodes = stemDict.get(this.baseBranchName)?.nodes?.map(({commit}) => commit); + const nodes = stemDict.get(this.baseBranchName)?.nodes?.map(({ commit }) => commit); const geminiCommitSummary = await getSummary(nodes ? nodes?.slice(-10) : []); if (this.isDebugMode) console.log("GeminiCommitSummary: ", geminiCommitSummary); @@ -92,4 +92,3 @@ export class AnalysisEngine { } export default AnalysisEngine; -export { COMMIT_SEPARATOR, GIT_LOG_SEPARATOR } from "./constant"; From 67020244c44f4eb526b594ba06c1a277c3831526 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 20:03:54 +0900 Subject: [PATCH 25/49] =?UTF-8?q?feat(engine):=20commit=20separator=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 86 +++++++++++++++----------- packages/vscode/src/utils/git.util.ts | 17 ++--- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index eb17eb44..ec8cd236 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -1,18 +1,23 @@ import { getCommitMessageType } from "./commit.util"; -import { COMMIT_SEPARATOR, GIT_LOG_SEPARATOR } from "./constant"; -import type { CommitRaw } from "./types"; +import type { CommitRaw, DifferenceStatistic } from "./types"; export default function getCommitRaws(log: string) { if (!log) return []; + console.log(log); const EOL_REGEX = /\r?\n/; + const COMMIT_SEPARATOR = new RegExp(`${EOL_REGEX.source}{4}`); + const COMMIT_MESSAGE_BODY_INDENTATION = " "; // step 0: Split log into commits - const commits = log.split(COMMIT_SEPARATOR); + const commits = log.substring(2).split(COMMIT_SEPARATOR); const commitRaws: CommitRaw[] = []; - // skip the first empty element - for (let commitIdx = 1; commitIdx < commits.length; commitIdx += 1) { - // step 1: Extract commitData from the first line of the commit - const commitData = commits[commitIdx].split(GIT_LOG_SEPARATOR); + console.log("length: ", commits.length); + console.log(commits[0]); + console.log("-----------------"); + console.log(commits[commits.length - 1]); + for (let commitIdx = 0; commitIdx < commits.length; commitIdx += 1) { + // step 1: Extract commitData + const commitData = commits[commitIdx].split(EOL_REGEX); const [ id, parents, @@ -23,10 +28,9 @@ export default function getCommitRaws(log: string) { committerName, committerEmail, committerDate, - message, - diffStats, + ...messageAndDiffStats ] = commitData; - // Extract branch and tag data from refs + // step 2: Extract branch and tag data from refs const refsArray = refs.replace(" -> ", ", ").split(", "); const [branches, tags]: string[][] = refsArray.reduce( ([branches, tags], ref) => { @@ -41,7 +45,41 @@ export default function getCommitRaws(log: string) { [new Array(), new Array()] ); - // make base commitRaw object + // step 3: Extract message and diffStats + let messageAndDiffStatsIdx = 0; + let message = ""; + const diffStats: DifferenceStatistic = { + totalInsertionCount: 0, + totalDeletionCount: 0, + fileDictionary: {}, + }; + // Extract message + while (messageAndDiffStatsIdx < messageAndDiffStats.length && messageAndDiffStats[messageAndDiffStatsIdx] !== "") { + const line = messageAndDiffStats[messageAndDiffStatsIdx]; + if (line.startsWith(COMMIT_MESSAGE_BODY_INDENTATION)) message += "\n" + line.trim(); + else message += line; + messageAndDiffStatsIdx++; + } + // Extract diffStats + while (messageAndDiffStatsIdx < messageAndDiffStats.length) { + const line = messageAndDiffStats[messageAndDiffStatsIdx]; + if (line === "") { + messageAndDiffStatsIdx++; + continue; + } + const [insertions, deletions, path] = line.split("\t"); + const numberedInsertions = insertions === "-" ? 0 : Number(insertions); + const numberedDeletions = deletions === "-" ? 0 : Number(deletions); + diffStats.totalInsertionCount += numberedInsertions; + diffStats.totalDeletionCount += numberedDeletions; + diffStats.fileDictionary[path] = { + insertionCount: numberedInsertions, + deletionCount: numberedDeletions, + }; + messageAndDiffStatsIdx++; + } + + // step 4: Construct commitRaw const commitRaw: CommitRaw = { sequence: commitIdx - 1, id, @@ -60,32 +98,8 @@ export default function getCommitRaws(log: string) { committerDate: new Date(committerDate), message, commitMessageType: getCommitMessageType(message), - differenceStatistic: { - totalInsertionCount: 0, - totalDeletionCount: 0, - fileDictionary: {}, - }, + differenceStatistic: diffStats, }; - - // step 2: Extract diffStats from the rest of the commit - if (!diffStats) { - commitRaws.push(commitRaw); - continue; - } - const diffStatsArray = diffStats.split(EOL_REGEX); - // pass the first empty element - for (let diffIdx = 1; diffIdx < diffStatsArray.length; diffIdx += 1) { - if (diffStatsArray[diffIdx] === "") continue; - const [insertions, deletions, path] = diffStatsArray[diffIdx].split("\t"); - const numberedInsertions = insertions === "-" ? 0 : Number(insertions); - const numberedDeletions = deletions === "-" ? 0 : Number(deletions); - commitRaw.differenceStatistic.totalInsertionCount += numberedInsertions; - commitRaw.differenceStatistic.totalDeletionCount += numberedDeletions; - commitRaw.differenceStatistic.fileDictionary[path] = { - insertionCount: numberedInsertions, - deletionCount: numberedDeletions, - }; - } commitRaws.push(commitRaw); } diff --git a/packages/vscode/src/utils/git.util.ts b/packages/vscode/src/utils/git.util.ts index d18bc8e2..70eef0d5 100644 --- a/packages/vscode/src/utils/git.util.ts +++ b/packages/vscode/src/utils/git.util.ts @@ -155,8 +155,10 @@ export async function getGitExecutableFromPaths(paths: string[]): Promise { return new Promise((resolve, reject) => { + const GIT_LOG_SEPARATOR = "%n"; // newline + const gitLogFormat = - COMMIT_SEPARATOR + + "%n%n" + [ "%H", // commit hash (id) "%P", // parent hashes @@ -164,12 +166,13 @@ export async function getGitLog(gitPath: string, currentWorkspacePath: string): "%an", // author name "%ae", // author email "%ad", // author date - "%cn", - "%ce", - "%cd", // committer name, committer email and committer date - "%B", // commit message (subject and body) - ].join(GIT_LOG_SEPARATOR) + - GIT_LOG_SEPARATOR; + "%cn", // committer name + "%ce", // committer email + "%cd", // committer date + "%w(0,0,4)%s", // commit message subject + "%b", // commit message body + ].join(GIT_LOG_SEPARATOR); + console.log("gitLogFormat: ", gitLogFormat); const args = [ "--no-pager", "log", From e6d29c7cec440464af16ccff986c832296659b88 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 20:06:15 +0900 Subject: [PATCH 26/49] =?UTF-8?q?fix(engine):=20sequence=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index ec8cd236..a694b572 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -81,7 +81,7 @@ export default function getCommitRaws(log: string) { // step 4: Construct commitRaw const commitRaw: CommitRaw = { - sequence: commitIdx - 1, + sequence: commitIdx, id, parents: parents.split(" "), branches, From b53e520adf8fe21141e507ef777bee561dd992a9 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 20:12:54 +0900 Subject: [PATCH 27/49] =?UTF-8?q?fix(engine):=20parents=EA=B0=80=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EC=9D=98=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index a694b572..04a7a904 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -83,7 +83,7 @@ export default function getCommitRaws(log: string) { const commitRaw: CommitRaw = { sequence: commitIdx, id, - parents: parents.split(" "), + parents: parents.length === 0 ? [] : parents.split(" "), branches, tags, author: { From 55e137a12b57eaf549fcd76058f1d7824f38ce81 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 20:19:03 +0900 Subject: [PATCH 28/49] =?UTF-8?q?chore(engine):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=B6=9C=EB=A0=A5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index 04a7a904..b706862e 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -3,7 +3,6 @@ import type { CommitRaw, DifferenceStatistic } from "./types"; export default function getCommitRaws(log: string) { if (!log) return []; - console.log(log); const EOL_REGEX = /\r?\n/; const COMMIT_SEPARATOR = new RegExp(`${EOL_REGEX.source}{4}`); const COMMIT_MESSAGE_BODY_INDENTATION = " "; @@ -11,10 +10,6 @@ export default function getCommitRaws(log: string) { // step 0: Split log into commits const commits = log.substring(2).split(COMMIT_SEPARATOR); const commitRaws: CommitRaw[] = []; - console.log("length: ", commits.length); - console.log(commits[0]); - console.log("-----------------"); - console.log(commits[commits.length - 1]); for (let commitIdx = 0; commitIdx < commits.length; commitIdx += 1) { // step 1: Extract commitData const commitData = commits[commitIdx].split(EOL_REGEX); From d9c53fd488b72b0e629d03c12761a4f726148e2c Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 22:39:41 +0900 Subject: [PATCH 29/49] =?UTF-8?q?chore(vscode):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/utils/git.util.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vscode/src/utils/git.util.ts b/packages/vscode/src/utils/git.util.ts index 70eef0d5..128f6095 100644 --- a/packages/vscode/src/utils/git.util.ts +++ b/packages/vscode/src/utils/git.util.ts @@ -1,4 +1,3 @@ -import { COMMIT_SEPARATOR, GIT_LOG_SEPARATOR } from "@githru-vscode-ext/analysis-engine"; import * as cp from "child_process"; import * as fs from "fs"; import * as path from "path"; From 4f973655ef69c9757cf444e504d919dbb1804038 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 22:40:35 +0900 Subject: [PATCH 30/49] =?UTF-8?q?fix(engine):=20commit=20message,=20diffst?= =?UTF-8?q?at=20=ED=8C=8C=EC=8B=B1=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index b706862e..4eef9189 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -41,39 +41,39 @@ export default function getCommitRaws(log: string) { ); // step 3: Extract message and diffStats - let messageAndDiffStatsIdx = 0; - let message = ""; + let messageSubject = ""; + let messageBody = ""; const diffStats: DifferenceStatistic = { totalInsertionCount: 0, totalDeletionCount: 0, fileDictionary: {}, }; - // Extract message - while (messageAndDiffStatsIdx < messageAndDiffStats.length && messageAndDiffStats[messageAndDiffStatsIdx] !== "") { - const line = messageAndDiffStats[messageAndDiffStatsIdx]; - if (line.startsWith(COMMIT_MESSAGE_BODY_INDENTATION)) message += "\n" + line.trim(); - else message += line; - messageAndDiffStatsIdx++; - } - // Extract diffStats - while (messageAndDiffStatsIdx < messageAndDiffStats.length) { - const line = messageAndDiffStats[messageAndDiffStatsIdx]; - if (line === "") { - messageAndDiffStatsIdx++; + for (let idx = 0; idx < messageAndDiffStats.length; idx++) { + const line = messageAndDiffStats[idx]; + if (idx === 0) + // message subject + messageSubject = line; + else if (line.startsWith(COMMIT_MESSAGE_BODY_INDENTATION)) { + // message body (add newline if not first line) + messageBody += idx === 1 ? line.trim() : `\n${line.trim()}`; + } else if (line === "") + // pass empty line continue; + else { + // diffStats + const [insertions, deletions, path] = line.split("\t"); + const numberedInsertions = insertions === "-" ? 0 : Number(insertions); + const numberedDeletions = deletions === "-" ? 0 : Number(deletions); + diffStats.totalInsertionCount += numberedInsertions; + diffStats.totalDeletionCount += numberedDeletions; + diffStats.fileDictionary[path] = { + insertionCount: numberedInsertions, + deletionCount: numberedDeletions, + }; } - const [insertions, deletions, path] = line.split("\t"); - const numberedInsertions = insertions === "-" ? 0 : Number(insertions); - const numberedDeletions = deletions === "-" ? 0 : Number(deletions); - diffStats.totalInsertionCount += numberedInsertions; - diffStats.totalDeletionCount += numberedDeletions; - diffStats.fileDictionary[path] = { - insertionCount: numberedInsertions, - deletionCount: numberedDeletions, - }; - messageAndDiffStatsIdx++; } + const message = messageBody === "" ? messageSubject : `${messageSubject}\n${messageBody}`; // step 4: Construct commitRaw const commitRaw: CommitRaw = { sequence: commitIdx, From 17901e12004273c5fde18dd82646b179f92a6749 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 13 Oct 2024 22:41:15 +0900 Subject: [PATCH 31/49] =?UTF-8?q?test(engine):=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EB=90=9C=20=ED=8F=AC=EB=A7=B7=EC=97=90=20=EB=A7=9E=EA=B2=8C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.spec.ts | 199 +++++++++++++++++--- 1 file changed, 171 insertions(+), 28 deletions(-) diff --git a/packages/analysis-engine/src/parser.spec.ts b/packages/analysis-engine/src/parser.spec.ts index d86a36eb..0bb2b0c4 100644 --- a/packages/analysis-engine/src/parser.spec.ts +++ b/packages/analysis-engine/src/parser.spec.ts @@ -1,5 +1,4 @@ import { getCommitMessageType } from "./commit.util"; -import { COMMIT_SEPARATOR, GIT_LOG_SEPARATOR } from "./constant"; import getCommitRaws from "./parser"; import type { CommitRaw, DifferenceStatistic } from "./types"; @@ -36,11 +35,23 @@ describe("commit message type", () => { }); describe("getCommitRaws", () => { - const fakeAuthorAndCommitter = `${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900`; - const fakeCommitMessage = `${GIT_LOG_SEPARATOR}commit message${GIT_LOG_SEPARATOR}`; - const fakeCommitMessageAndBody = `${GIT_LOG_SEPARATOR}commit message title\n\ncommit message body${GIT_LOG_SEPARATOR}`; - const fakeCommitHash = `a${GIT_LOG_SEPARATOR}b`; - const fakeCommitRef = `${GIT_LOG_SEPARATOR}HEAD`; + const FRONT_NEW_LINE = "\n\n"; + const COMMIT_MESSAGE_BODY_INDENTATION = " "; + + const fakeAuthor = `John Park +mail@gmail.com +Sun Sep 4 20:17:59 2022 +0900`; + const fakeCommitter = `John Park 2 +mail2@gmail.com +Sun Sep 5 20:17:59 2022 +0900`; + const fakeCommitMessage = `commit message +${COMMIT_MESSAGE_BODY_INDENTATION}`; + const fakeCommitMessageAndBody = `commit message title + +${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`; + const fakeCommitHash = `a +b`; + const fakeCommitRef = "HEAD"; const fakeCommitFileChange = "10\t0\ta.ts\n1\t0\tREADME.md"; const commonExpectatedResult: CommitRaw = { @@ -73,15 +84,27 @@ describe("getCommitRaws", () => { it.each([ [ - `${COMMIT_SEPARATOR}${`a${GIT_LOG_SEPARATOR}`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `a + +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, id: "a", - parents: [""], + parents: [], }, ], [ - `${COMMIT_SEPARATOR}${`c${GIT_LOG_SEPARATOR}b`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `c +b +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, id: "c", @@ -89,7 +112,13 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${`d${GIT_LOG_SEPARATOR}e f`}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `d +e f +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, id: "d", @@ -103,7 +132,12 @@ describe("getCommitRaws", () => { it.each([ [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +HEAD +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -111,7 +145,12 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +HEAD -> main, origin/main, origin/HEAD +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD", "main", "origin/main", "origin/HEAD"], @@ -119,7 +158,12 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD, tag: v1.0.0`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +HEAD, tag: v1.0.0 +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -127,7 +171,12 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0 +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD", "main", "origin/main", "origin/HEAD"], @@ -135,7 +184,12 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${`${GIT_LOG_SEPARATOR}HEAD, tag: v2.0.0, tag: v1.4`}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +HEAD, tag: v2.0.0, tag: v1.4 +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -143,7 +197,12 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${GIT_LOG_SEPARATOR}${fakeAuthorAndCommitter}${fakeCommitMessage}`, + FRONT_NEW_LINE + + `${fakeCommitHash} + +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`, { ...commonExpectatedResult, branches: [], @@ -157,7 +216,14 @@ describe("getCommitRaws", () => { it.each([ [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"10\t0\ta.ts\n1\t0\tREADME.md"}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage} +10\t0\ta.ts +1\t0\tREADME.md`, { ...commonExpectatedResult, differenceStatistic: { @@ -171,7 +237,13 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"3\t3\ta.ts"}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage} +3\t3\ta.ts`, { ...commonExpectatedResult, differenceStatistic: { @@ -182,7 +254,13 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"4\t0\ta.ts"}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage} +4\t0\ta.ts`, { ...commonExpectatedResult, differenceStatistic: { @@ -193,7 +271,15 @@ describe("getCommitRaws", () => { }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${"0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts"}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage} +0\t6\ta.ts +2\t0\tb.ts +3\t3\tc.ts`, { ...commonExpectatedResult, differenceStatistic: { @@ -213,8 +299,25 @@ describe("getCommitRaws", () => { }); it(`should parse gitlog to commitRaw(multiple commits)`, () => { - const mockLog = `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}\n${fakeCommitFileChange}${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessage}`; + const mockLog = + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage} +${fakeCommitFileChange} + + + +${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessage}`; + console.log(mockLog); const result = getCommitRaws(mockLog); + console.log(result); const expectedResult = [ { ...commonExpectatedResult, differenceStatistic: expectedFileChange }, { ...commonExpectatedResult, sequence: 1 }, @@ -225,23 +328,56 @@ describe("getCommitRaws", () => { it.each([ [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title${GIT_LOG_SEPARATOR}`}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +commit message title +${COMMIT_MESSAGE_BODY_INDENTATION}`, { ...commonExpectatedResult, message: "commit message title" }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\ncommit message${GIT_LOG_SEPARATOR}`}`, - { ...commonExpectatedResult, message: "commit message title\ncommit message" }, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +commit message title +${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, + { ...commonExpectatedResult, message: "commit message title\ncommit message body" }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\n\ncommit message body${GIT_LOG_SEPARATOR}`}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +commit message title +${COMMIT_MESSAGE_BODY_INDENTATION} +${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, { ...commonExpectatedResult, message: "commit message title\n\ncommit message body" }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}commit message title\n\n\ncommit message body${GIT_LOG_SEPARATOR}`}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +commit message title +${COMMIT_MESSAGE_BODY_INDENTATION} +${COMMIT_MESSAGE_BODY_INDENTATION} +${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, { ...commonExpectatedResult, message: "commit message title\n\n\ncommit message body" }, ], [ - `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${`${GIT_LOG_SEPARATOR}${GIT_LOG_SEPARATOR}`}`, + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} + +${COMMIT_MESSAGE_BODY_INDENTATION}`, { ...commonExpectatedResult, message: "" }, ], ])("should parse gitlog to commitRaw(commit message)", (mockLog, expectedResult) => { @@ -250,7 +386,14 @@ describe("getCommitRaws", () => { }); it(`should parse gitlog to commitRaw(commit message body and file change)`, () => { - const mockLog = `${COMMIT_SEPARATOR}${fakeCommitHash}${fakeCommitRef}${fakeAuthorAndCommitter}${fakeCommitMessageAndBody}\n${fakeCommitFileChange}`; + const mockLog = + FRONT_NEW_LINE + + `${fakeCommitHash} +${fakeCommitRef} +${fakeAuthor} +${fakeCommitter} +${fakeCommitMessageAndBody} +${fakeCommitFileChange}`; const result = getCommitRaws(mockLog); const expectedResult = { ...commonExpectatedResult, From c12c493cee26755683b50bb2980bd5dfbd208cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 13:57:28 +0900 Subject: [PATCH 32/49] =?UTF-8?q?refactor(view):=20EventListner=EB=A5=BC?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=ED=95=98=EC=97=AC=20owner,=20repo=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=ED=95=A0=EB=8B=B9=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 17 +---------------- .../Summary/Content/Content.tsx | 5 ++--- packages/view/src/types/RemoteGitHubInfo.ts | 6 ------ 3 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 packages/view/src/types/RemoteGitHubInfo.ts diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 217a7f9d..4ea2656f 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -19,8 +19,6 @@ const App = () => { const filteredData = useDataStore((state) => state.filteredData); const { handleChangeBranchList } = useBranchStore(); const { loading, setLoading } = useLoadingStore(); - const { setOwner } = useOwnerStore(); - const { setRepo } = useRepoStore(); const ideAdapter = container.resolve("IDEAdapter"); useEffect(() => { @@ -35,20 +33,7 @@ const App = () => { ideAdapter.sendFetchBranchListMessage(); initRef.current = true; } - }, [handleChangeAnalyzedData, handleChangeBranchList, ideAdapter, setLoading]); - - useEffect(() => { - const handleMessage = (event: MessageEvent) => { - const message = event.data; - if (message.data) { - setOwner(message.data.owner); - setRepo(message.data.repo); - } - }; - - window.addEventListener("message", handleMessage); - return () => window.removeEventListener("message", handleMessage); - }, []); + }, [handleChangeAnalyzedData, handleChangeBranchList, handleGithubInfo, ideAdapter, setLoading]); if (loading) { return ( diff --git a/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx b/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx index 44291936..b8c61f2a 100644 --- a/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx +++ b/packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx @@ -1,13 +1,12 @@ import React, { useEffect, useState } from "react"; import ArrowDropDownCircleRoundedIcon from "@mui/icons-material/ArrowDropDownCircleRounded"; -import { useOwnerStore, useRepoStore } from "store"; +import { useGithubInfo } from "store"; import type { ContentProps } from "../Summary.type"; const Content = ({ content, clusterId, selectedClusterId }: ContentProps) => { - const { owner } = useOwnerStore(); - const { repo } = useRepoStore(); + const { owner, repo } = useGithubInfo(); const [linkedStr, setLinkedStr] = useState([]); useEffect(() => { diff --git a/packages/view/src/types/RemoteGitHubInfo.ts b/packages/view/src/types/RemoteGitHubInfo.ts deleted file mode 100644 index c2564690..00000000 --- a/packages/view/src/types/RemoteGitHubInfo.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface RemoteGitHubInfo { - data: { - owner: string; - repo: string; - }; -} From 9dbdb2f58ddb0c78cee2751932ded24ef69856e2 Mon Sep 17 00:00:00 2001 From: seungineer Date: Mon, 14 Oct 2024 13:58:59 +0900 Subject: [PATCH 33/49] =?UTF-8?q?feat(view):=20owner,=20repo=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EB=8B=B4=EB=8A=94=20githubInfo=20store=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/store/githubInfo.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/view/src/store/githubInfo.ts diff --git a/packages/view/src/store/githubInfo.ts b/packages/view/src/store/githubInfo.ts new file mode 100644 index 00000000..1316143c --- /dev/null +++ b/packages/view/src/store/githubInfo.ts @@ -0,0 +1,20 @@ +import { create } from "zustand"; + +export type githubInfo = { + owner: string; + repo: string; +}; + +export const useGithubInfo = create< + githubInfo & { + handleGithubInfo: (repoInfo: githubInfo) => void; + } +>((set) => ({ + owner: "githru", + repo: "githru-vscode-ext", + handleGithubInfo: (repoInfo: githubInfo) => { + if (repoInfo) { + set({ owner: repoInfo.owner, repo: repoInfo.repo }); + } + }, +})); From 7ee620bd91d86423dbaf8ce583c42d5ed98b20c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 14:40:22 +0900 Subject: [PATCH 34/49] =?UTF-8?q?feat(view):=20githubInfo=20=EC=A1=B0?= =?UTF-8?q?=EC=9E=91=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 5 +++-- packages/view/src/store/index.ts | 1 + packages/view/src/types/IDESentEvents.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 4ea2656f..c8c682f6 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -10,14 +10,14 @@ import type IDEPort from "ide/IDEPort"; import { useAnalayzedData } from "hooks"; import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; -import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; -import { useBranchStore, useDataStore, useLoadingStore, useOwnerStore, useRepoStore } from "store"; +import { useBranchStore, useDataStore, useGithubInfo, useLoadingStore } from "store"; const App = () => { const initRef = useRef(false); const { handleChangeAnalyzedData } = useAnalayzedData(); const filteredData = useDataStore((state) => state.filteredData); const { handleChangeBranchList } = useBranchStore(); + const { handleGithubInfo } = useGithubInfo(); const { loading, setLoading } = useLoadingStore(); const ideAdapter = container.resolve("IDEAdapter"); @@ -26,6 +26,7 @@ const App = () => { const callbacks: IDESentEvents = { handleChangeAnalyzedData, handleChangeBranchList, + handleGithubInfo, }; setLoading(true); ideAdapter.addIDESentEventListener(callbacks); diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index e9d468f6..6c545118 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -3,4 +3,5 @@ export * from "./filteredRange"; export * from "./branch"; export * from "./repo"; export * from "./owner"; +export * from "./githubInfo"; export * from "./data"; diff --git a/packages/view/src/types/IDESentEvents.ts b/packages/view/src/types/IDESentEvents.ts index e1420a41..ea127181 100644 --- a/packages/view/src/types/IDESentEvents.ts +++ b/packages/view/src/types/IDESentEvents.ts @@ -1,8 +1,9 @@ -import type { BranchListPayload } from "store"; +import type { BranchListPayload, githubInfo } from "store"; import type { ClusterNode } from "types"; // triggered by ide response export type IDESentEvents = { handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; handleChangeBranchList: (branches: BranchListPayload) => void; + handleGithubInfo: (repoInfo: githubInfo) => void; }; From 596d5a135c7c3c5428b17007d30769cc3d03af30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 14:44:13 +0900 Subject: [PATCH 35/49] =?UTF-8?q?refactor(vscode):=20vscode=EC=97=90?= =?UTF-8?q?=EC=84=9C=20owner,=20repo=EB=A5=BC=20=EC=9C=84=ED=95=9C=20postM?= =?UTF-8?q?essage=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/extension.ts | 1 - packages/vscode/src/webview-loader.ts | 8 -------- 2 files changed, 9 deletions(-) diff --git a/packages/vscode/src/extension.ts b/packages/vscode/src/extension.ts index e1c6357f..c06be041 100644 --- a/packages/vscode/src/extension.ts +++ b/packages/vscode/src/extension.ts @@ -80,7 +80,6 @@ export async function activate(context: vscode.ExtensionContext) { const gitConfig = await getGitConfig(gitPath, currentWorkspacePath, "origin"); const { owner, repo: initialRepo } = getRepo(gitConfig); - webLoader.setGlobalOwnerAndRepo(owner, initialRepo); const repo = initialRepo[0]; const engine = new AnalysisEngine({ isDebugMode: true, diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 4eaa8265..5ce5b8f6 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -147,14 +147,6 @@ export default class WebviewLoader implements vscode.Disposable { } } - public setGlobalOwnerAndRepo(owner: string, repo: string) { - if (this._panel) { - this._panel.webview.postMessage({ - command: "setGlobalOwnerAndRepo", - data: { owner, repo }, - }); - } - } } type GithruFetcher = (...params: P) => Promise; From 19beb0707ee8b6a8e910be31cb30298603a8c740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 15:04:07 +0900 Subject: [PATCH 36/49] =?UTF-8?q?feat(vscode):=20Github=20Info=EB=A5=BC=20?= =?UTF-8?q?fetch=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/extension.ts | 5 +++-- packages/vscode/src/webview-loader.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/vscode/src/extension.ts b/packages/vscode/src/extension.ts index c06be041..1513e06e 100644 --- a/packages/vscode/src/extension.ts +++ b/packages/vscode/src/extension.ts @@ -58,6 +58,8 @@ export async function activate(context: vscode.ExtensionContext) { } const fetchBranches = async () => await getBranches(gitPath, currentWorkspacePath); + const gitConfig = await getGitConfig(gitPath, currentWorkspacePath, "origin"); + const fetchGithubInfo = async () => getRepo(gitConfig); const fetchCurrentBranch = async () => { let branchName; @@ -77,8 +79,6 @@ export async function activate(context: vscode.ExtensionContext) { const initialBaseBranchName = await fetchCurrentBranch(); const fetchClusterNodes = async (baseBranchName = initialBaseBranchName) => { const gitLog = await getGitLog(gitPath, currentWorkspacePath); - const gitConfig = await getGitConfig(gitPath, currentWorkspacePath, "origin"); - const { owner, repo: initialRepo } = getRepo(gitConfig); const repo = initialRepo[0]; const engine = new AnalysisEngine({ @@ -99,6 +99,7 @@ export async function activate(context: vscode.ExtensionContext) { fetchClusterNodes, fetchBranches, fetchCurrentBranch, + fetchGithubInfo, }); currentPanel = webLoader.getPanel(); diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 5ce5b8f6..26a3d0b1 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -14,7 +14,7 @@ export default class WebviewLoader implements vscode.Disposable { context: vscode.ExtensionContext, fetcher: GithruFetcherMap ) { - const { fetchClusterNodes, fetchBranches, fetchCurrentBranch } = fetcher; + const { fetchClusterNodes, fetchBranches, fetchCurrentBranch, fetchGithubInfo } = fetcher; const viewColumn = vscode.ViewColumn.One; //캐시 초기화 @@ -76,6 +76,14 @@ export default class WebviewLoader implements vscode.Disposable { payload: branches, }); } + + if (command === "fetchGithubInfo") { + const githubInfo = await fetchGithubInfo(); + await this.respondToMessage({ + ...message, + payload: githubInfo, + }); + } if (command === "updateCustomTheme") { const colorCode = payload && JSON.parse(payload); @@ -154,4 +162,5 @@ type GithruFetcherMap = { fetchClusterNodes: GithruFetcher; fetchBranches: GithruFetcher<{ branchList: string[]; head: string | null }>; fetchCurrentBranch: GithruFetcher; + fetchGithubInfo: GithruFetcher<{ owner: string; repo: string }>; }; From 79bbf99a22832fb79a16e873846cae959dfba283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 15:06:17 +0900 Subject: [PATCH 37/49] =?UTF-8?q?feat(view):=20view=EC=97=90=EC=84=9C=20Gi?= =?UTF-8?q?thub=20Info=EB=A5=BC=20fetch=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=AA=85=EB=A0=B9=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 1 + packages/view/src/ide/IDEPort.ts | 1 + packages/view/src/ide/VSCodeIDEAdapter.ts | 9 +++++++++ packages/view/src/types/IDEMessage.ts | 1 + 4 files changed, 12 insertions(+) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index c8c682f6..8a3f21f7 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -32,6 +32,7 @@ const App = () => { ideAdapter.addIDESentEventListener(callbacks); ideAdapter.sendFetchAnalyzedDataMessage(); ideAdapter.sendFetchBranchListMessage(); + ideAdapter.sendFetchGithubInfo(); initRef.current = true; } }, [handleChangeAnalyzedData, handleChangeBranchList, handleGithubInfo, ideAdapter, setLoading]); diff --git a/packages/view/src/ide/IDEPort.ts b/packages/view/src/ide/IDEPort.ts index 77afc509..163b9acd 100644 --- a/packages/view/src/ide/IDEPort.ts +++ b/packages/view/src/ide/IDEPort.ts @@ -10,5 +10,6 @@ export default interface IDEPort { sendRefreshDataMessage: (payload?: string) => void; sendFetchAnalyzedDataMessage: (payload?: string) => void; sendFetchBranchListMessage: () => void; + sendFetchGithubInfo: () => void; setCustomTheme: (theme: string) => void; } diff --git a/packages/view/src/ide/VSCodeIDEAdapter.ts b/packages/view/src/ide/VSCodeIDEAdapter.ts index 4d842209..cd666a2c 100644 --- a/packages/view/src/ide/VSCodeIDEAdapter.ts +++ b/packages/view/src/ide/VSCodeIDEAdapter.ts @@ -19,6 +19,8 @@ export default class VSCodeIDEAdapter implements IDEPort { return events.handleChangeAnalyzedData(payloadData); case "fetchBranchList": return events.handleChangeBranchList(payloadData); + case "fetchGithubInfo": + return events.handleGithubInfo(payloadData); default: console.log("Unknown Message"); } @@ -49,6 +51,13 @@ export default class VSCodeIDEAdapter implements IDEPort { this.sendMessageToIDE(message); } + public sendFetchGithubInfo() { + const message: IDEMessage = { + command: "fetchGithubInfo", + }; + this.sendMessageToIDE(message); + } + public setCustomTheme(theme: string) { const message: IDEMessage = { command: "updateCustomTheme", diff --git a/packages/view/src/types/IDEMessage.ts b/packages/view/src/types/IDEMessage.ts index 81881572..69c3bfb9 100644 --- a/packages/view/src/types/IDEMessage.ts +++ b/packages/view/src/types/IDEMessage.ts @@ -12,4 +12,5 @@ export type IDEMessageCommandNames = | "fetchAnalyzedData" | "fetchBranchList" | "fetchCurrentBranch" + | "fetchGithubInfo" | "updateCustomTheme"; From bcf093153eac76fe0492e70ec821e21f69b35b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 15:07:57 +0900 Subject: [PATCH 38/49] =?UTF-8?q?feat(view):=20dev=20mode=EC=97=90?= =?UTF-8?q?=EC=84=9C=EB=8F=84=20Github=20Info=EB=A5=BC=20fetch=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/ide/FakeIDEAdapter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/view/src/ide/FakeIDEAdapter.ts b/packages/view/src/ide/FakeIDEAdapter.ts index c23ddbc4..365eeebd 100644 --- a/packages/view/src/ide/FakeIDEAdapter.ts +++ b/packages/view/src/ide/FakeIDEAdapter.ts @@ -20,6 +20,8 @@ export default class FakeIDEAdapter implements IDEPort { return events.handleChangeAnalyzedData(payload ? JSON.parse(payload) : undefined); case "fetchBranchList": return events.handleChangeBranchList(payload ? JSON.parse(payload) : undefined); + case "fetchGithubInfo": + return events.handleGithubInfo(payload ? JSON.parse(payload) : undefined); default: console.log("Unknown Message"); } @@ -54,6 +56,13 @@ export default class FakeIDEAdapter implements IDEPort { this.sendMessageToMe(message); } + public sendFetchGithubInfo() { + const message: IDEMessage = { + command: "fetchGithubInfo", + }; + this.sendMessageToMe(message); + } + public setCustomTheme(color: string) { sessionStorage.setItem("PRIMARY_COLOR", color); const message: IDEMessage = { From d90d0d8ac0a9f308412916814936684b34763c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=8A=B9=EC=9A=B0?= Date: Mon, 14 Oct 2024 15:09:44 +0900 Subject: [PATCH 39/49] =?UTF-8?q?refactor(view):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20owner,=20repo=20store=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/store/owner.ts | 11 ----------- packages/view/src/store/repo.ts | 11 ----------- 2 files changed, 22 deletions(-) delete mode 100644 packages/view/src/store/owner.ts delete mode 100644 packages/view/src/store/repo.ts diff --git a/packages/view/src/store/owner.ts b/packages/view/src/store/owner.ts deleted file mode 100644 index dbeefc29..00000000 --- a/packages/view/src/store/owner.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { create } from "zustand"; - -type OwnerStore = { - owner: string; - setOwner: (owner: string) => void; -}; - -export const useOwnerStore = create((set) => ({ - owner: "", - setOwner: (owner) => set({ owner }), -})); diff --git a/packages/view/src/store/repo.ts b/packages/view/src/store/repo.ts deleted file mode 100644 index d2aac79d..00000000 --- a/packages/view/src/store/repo.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { create } from "zustand"; - -type RepoStore = { - repo: string; - setRepo: (repo: string) => void; -}; - -export const useRepoStore = create((set) => ({ - repo: "", - setRepo: (repo) => set({ repo }), -})); From 961be979ec9ca0cdcc110c444cba26d83f29a290 Mon Sep 17 00:00:00 2001 From: seungineer Date: Mon, 14 Oct 2024 15:53:55 +0900 Subject: [PATCH 40/49] =?UTF-8?q?fix(view):=20=EA=B8=B0=EC=A1=B4=20owner,?= =?UTF-8?q?=20repo=20store=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8D=98?= =?UTF-8?q?=20=EA=B2=83=EC=9D=84=20githubInfo=20store=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/components/Detail/Detail.tsx | 5 ++--- packages/view/src/store/index.ts | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/view/src/components/Detail/Detail.tsx b/packages/view/src/components/Detail/Detail.tsx index 010787fb..3c105172 100644 --- a/packages/view/src/components/Detail/Detail.tsx +++ b/packages/view/src/components/Detail/Detail.tsx @@ -11,7 +11,7 @@ import { import { Tooltip } from "@mui/material"; import { Author } from "components/@common/Author"; -import { useOwnerStore, useRepoStore } from "store"; +import { useGithubInfo } from "store"; import { useCommitListHide } from "./Detail.hook"; import { getCommitListDetail } from "./Detail.util"; @@ -56,8 +56,7 @@ const Detail = ({ selectedData, clusterId, authSrcMap }: DetailProps) => { const commitNodeListInCluster = selectedData?.filter((selected) => selected.commitNodeList[0].clusterId === clusterId)[0].commitNodeList ?? []; const { commitNodeList, toggle, handleToggle } = useCommitListHide(commitNodeListInCluster); - const { owner } = useOwnerStore(); - const { repo } = useRepoStore(); + const { owner, repo } = useGithubInfo(); const isShow = commitNodeListInCluster.length > FIRST_SHOW_NUM; const handleCommitIdCopy = (id: string) => async () => { navigator.clipboard.writeText(id); diff --git a/packages/view/src/store/index.ts b/packages/view/src/store/index.ts index 6c545118..48c46f94 100644 --- a/packages/view/src/store/index.ts +++ b/packages/view/src/store/index.ts @@ -1,7 +1,5 @@ export * from "./loading"; export * from "./filteredRange"; export * from "./branch"; -export * from "./repo"; -export * from "./owner"; export * from "./githubInfo"; export * from "./data"; From bed40d82e735f3215abf1296df4e9c39843ad81f Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Tue, 15 Oct 2024 19:38:45 +0900 Subject: [PATCH 41/49] =?UTF-8?q?test(engine):=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=BC=80=EC=9D=B4=EC=8A=A4=20=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.spec.ts | 194 +++----------------- 1 file changed, 27 insertions(+), 167 deletions(-) diff --git a/packages/analysis-engine/src/parser.spec.ts b/packages/analysis-engine/src/parser.spec.ts index 0bb2b0c4..f7491a2f 100644 --- a/packages/analysis-engine/src/parser.spec.ts +++ b/packages/analysis-engine/src/parser.spec.ts @@ -36,21 +36,13 @@ describe("commit message type", () => { describe("getCommitRaws", () => { const FRONT_NEW_LINE = "\n\n"; - const COMMIT_MESSAGE_BODY_INDENTATION = " "; + const INDENTATION = " "; - const fakeAuthor = `John Park -mail@gmail.com -Sun Sep 4 20:17:59 2022 +0900`; - const fakeCommitter = `John Park 2 -mail2@gmail.com -Sun Sep 5 20:17:59 2022 +0900`; - const fakeCommitMessage = `commit message -${COMMIT_MESSAGE_BODY_INDENTATION}`; - const fakeCommitMessageAndBody = `commit message title - -${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`; - const fakeCommitHash = `a -b`; + const fakeAuthor = "John Park\nmail@gmail.com\nSun Sep 4 20:17:59 2022 +0900"; + const fakeCommitter = `John Park 2\nmail2@gmail.com\nSun Sep 5 20:17:59 2022 +0900`; + const fakeCommitMessage = `commit message\n${INDENTATION}`; + const fakeCommitMessageAndBody = `commit message title\n${INDENTATION}\n${INDENTATION}commit message body`; + const fakeCommitHash = "a\nb"; const fakeCommitRef = "HEAD"; const fakeCommitFileChange = "10\t0\ta.ts\n1\t0\tREADME.md"; @@ -84,13 +76,7 @@ b`; it.each([ [ - FRONT_NEW_LINE + - `a - -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${"a\n"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, id: "a", @@ -98,27 +84,15 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `c -b -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${"c\nd"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, id: "c", - parents: ["b"], + parents: ["d"], }, ], [ - FRONT_NEW_LINE + - `d -e f -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${"d\ne f"}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, id: "d", @@ -132,12 +106,7 @@ ${fakeCommitMessage}`, it.each([ [ - FRONT_NEW_LINE + - `${fakeCommitHash} -HEAD -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -145,12 +114,7 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -HEAD -> main, origin/main, origin/HEAD -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD -> main, origin/main, origin/HEAD"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD", "main", "origin/main", "origin/HEAD"], @@ -158,12 +122,7 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -HEAD, tag: v1.0.0 -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD, tag: v1.0.0"}\n${fakeAuthor}\n${fakeCommitter}$\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -171,12 +130,7 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0 -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD", "main", "origin/main", "origin/HEAD"], @@ -184,12 +138,7 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -HEAD, tag: v2.0.0, tag: v1.4 -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${"HEAD, tag: v2.0.0, tag: v1.4"}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: ["HEAD"], @@ -197,12 +146,7 @@ ${fakeCommitMessage}`, }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} - -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${""}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`, { ...commonExpectatedResult, branches: [], @@ -216,14 +160,7 @@ ${fakeCommitMessage}`, it.each([ [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage} -10\t0\ta.ts -1\t0\tREADME.md`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"10\t0\ta.ts\n1\t0\tREADME.md"}`, { ...commonExpectatedResult, differenceStatistic: { @@ -237,13 +174,7 @@ ${fakeCommitMessage} }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage} -3\t3\ta.ts`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"3\t3\ta.ts"}`, { ...commonExpectatedResult, differenceStatistic: { @@ -254,13 +185,7 @@ ${fakeCommitMessage} }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage} -4\t0\ta.ts`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"4\t0\ta.ts"}`, { ...commonExpectatedResult, differenceStatistic: { @@ -271,15 +196,7 @@ ${fakeCommitMessage} }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage} -0\t6\ta.ts -2\t0\tb.ts -3\t3\tc.ts`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${"0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts"}`, { ...commonExpectatedResult, differenceStatistic: { @@ -299,25 +216,8 @@ ${fakeCommitMessage} }); it(`should parse gitlog to commitRaw(multiple commits)`, () => { - const mockLog = - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage} -${fakeCommitFileChange} - - - -${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessage}`; - console.log(mockLog); + const mockLog = `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}\n${fakeCommitFileChange}\n\n\n\n${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessage}`; const result = getCommitRaws(mockLog); - console.log(result); const expectedResult = [ { ...commonExpectatedResult, differenceStatistic: expectedFileChange }, { ...commonExpectatedResult, sequence: 1 }, @@ -328,56 +228,23 @@ ${fakeCommitMessage}`; it.each([ [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -commit message title -${COMMIT_MESSAGE_BODY_INDENTATION}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}`, { ...commonExpectatedResult, message: "commit message title" }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -commit message title -${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}${"commit message body"}`, { ...commonExpectatedResult, message: "commit message title\ncommit message body" }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -commit message title -${COMMIT_MESSAGE_BODY_INDENTATION} -${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}\n${INDENTATION}${"commit message body"}`, { ...commonExpectatedResult, message: "commit message title\n\ncommit message body" }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -commit message title -${COMMIT_MESSAGE_BODY_INDENTATION} -${COMMIT_MESSAGE_BODY_INDENTATION} -${COMMIT_MESSAGE_BODY_INDENTATION}commit message body`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${"commit message title"}\n${INDENTATION}\n${INDENTATION}\n${INDENTATION}${"commit message body"}`, { ...commonExpectatedResult, message: "commit message title\n\n\ncommit message body" }, ], [ - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} - -${COMMIT_MESSAGE_BODY_INDENTATION}`, + `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n\n${INDENTATION}`, { ...commonExpectatedResult, message: "" }, ], ])("should parse gitlog to commitRaw(commit message)", (mockLog, expectedResult) => { @@ -386,14 +253,7 @@ ${COMMIT_MESSAGE_BODY_INDENTATION}`, }); it(`should parse gitlog to commitRaw(commit message body and file change)`, () => { - const mockLog = - FRONT_NEW_LINE + - `${fakeCommitHash} -${fakeCommitRef} -${fakeAuthor} -${fakeCommitter} -${fakeCommitMessageAndBody} -${fakeCommitFileChange}`; + const mockLog = `${FRONT_NEW_LINE}${fakeCommitHash}\n${fakeCommitRef}\n${fakeAuthor}\n${fakeCommitter}\n${fakeCommitMessageAndBody}\n${fakeCommitFileChange}`; const result = getCommitRaws(mockLog); const expectedResult = { ...commonExpectatedResult, From 2ef4001ff8698a8350ca43bba7377681f4ad3837 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Tue, 15 Oct 2024 19:51:59 +0900 Subject: [PATCH 42/49] =?UTF-8?q?style(vscode):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=B6=9C=EB=A0=A5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/utils/git.util.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vscode/src/utils/git.util.ts b/packages/vscode/src/utils/git.util.ts index 128f6095..6452f0a6 100644 --- a/packages/vscode/src/utils/git.util.ts +++ b/packages/vscode/src/utils/git.util.ts @@ -171,7 +171,6 @@ export async function getGitLog(gitPath: string, currentWorkspacePath: string): "%w(0,0,4)%s", // commit message subject "%b", // commit message body ].join(GIT_LOG_SEPARATOR); - console.log("gitLogFormat: ", gitLogFormat); const args = [ "--no-pager", "log", From 1a9842f7ba2b0cdfad339c5f48f6ed03a4758f94 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Tue, 15 Oct 2024 20:04:47 +0900 Subject: [PATCH 43/49] =?UTF-8?q?style(vscode):=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/utils/git.util.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/vscode/src/utils/git.util.ts b/packages/vscode/src/utils/git.util.ts index 6452f0a6..feb0ecb4 100644 --- a/packages/vscode/src/utils/git.util.ts +++ b/packages/vscode/src/utils/git.util.ts @@ -154,8 +154,6 @@ export async function getGitExecutableFromPaths(paths: string[]): Promise { return new Promise((resolve, reject) => { - const GIT_LOG_SEPARATOR = "%n"; // newline - const gitLogFormat = "%n%n" + [ @@ -170,7 +168,7 @@ export async function getGitLog(gitPath: string, currentWorkspacePath: string): "%cd", // committer date "%w(0,0,4)%s", // commit message subject "%b", // commit message body - ].join(GIT_LOG_SEPARATOR); + ].join("%n"); const args = [ "--no-pager", "log", From 23cb12762cc421e75febb5fc4e4272024329099f Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Tue, 15 Oct 2024 20:06:42 +0900 Subject: [PATCH 44/49] =?UTF-8?q?style(engine):=20=EC=83=81=EC=88=98?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/analysis-engine/src/parser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/analysis-engine/src/parser.ts b/packages/analysis-engine/src/parser.ts index 4eef9189..985a10ad 100644 --- a/packages/analysis-engine/src/parser.ts +++ b/packages/analysis-engine/src/parser.ts @@ -5,7 +5,7 @@ export default function getCommitRaws(log: string) { if (!log) return []; const EOL_REGEX = /\r?\n/; const COMMIT_SEPARATOR = new RegExp(`${EOL_REGEX.source}{4}`); - const COMMIT_MESSAGE_BODY_INDENTATION = " "; + const INDENTATION = " "; // step 0: Split log into commits const commits = log.substring(2).split(COMMIT_SEPARATOR); @@ -53,7 +53,7 @@ export default function getCommitRaws(log: string) { if (idx === 0) // message subject messageSubject = line; - else if (line.startsWith(COMMIT_MESSAGE_BODY_INDENTATION)) { + else if (line.startsWith(INDENTATION)) { // message body (add newline if not first line) messageBody += idx === 1 ? line.trim() : `\n${line.trim()}`; } else if (line === "") From d7f115da18d708c0aa7f5f1116c56022024a665a Mon Sep 17 00:00:00 2001 From: taboowiths Date: Wed, 16 Oct 2024 09:36:06 +0900 Subject: [PATCH 45/49] =?UTF-8?q?fix(view):=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/view/src/App.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/view/src/App.tsx b/packages/view/src/App.tsx index 0c89f451..869281d7 100644 --- a/packages/view/src/App.tsx +++ b/packages/view/src/App.tsx @@ -10,8 +10,6 @@ import type IDEPort from "ide/IDEPort"; import { useAnalayzedData } from "hooks"; import { RefreshButton } from "components/RefreshButton"; import type { IDESentEvents } from "types/IDESentEvents"; - -import type { RemoteGitHubInfo } from "types/RemoteGitHubInfo"; import { useBranchStore, useDataStore, useGithubInfo, useLoadingStore } from "store"; import { THEME_INFO } from "components/ThemeSelector/ThemeSelector.const"; From 616e3e700bc564792a3c6274f3c2d825c5699cfe Mon Sep 17 00:00:00 2001 From: "ytaek.kim" Date: Thu, 17 Oct 2024 00:25:46 +0900 Subject: [PATCH 46/49] env(all): ready for v0.7.3 --- package-lock.json | 120 ++++++++++++++------------ packages/analysis-engine/package.json | 2 +- packages/view/package.json | 2 +- packages/vscode/README.md | 5 ++ packages/vscode/package.json | 4 +- 5 files changed, 75 insertions(+), 58 deletions(-) diff --git a/package-lock.json b/package-lock.json index b3a24871..1604f836 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "githru-vscode-ext", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "githru-vscode-ext", - "version": "0.7.0", + "version": "0.7.1", "license": "MIT", "workspaces": [ "./packages/*" @@ -8158,9 +8158,9 @@ } }, "node_modules/body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "dev": true, "dependencies": { "bytes": "3.1.2", @@ -8171,7 +8171,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", + "qs": "6.13.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -9271,9 +9271,9 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "dev": true, "engines": { "node": ">= 0.6" @@ -10763,9 +10763,9 @@ } }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "dev": true, "engines": { "node": ">= 0.8" @@ -13176,37 +13176,37 @@ "peer": true }, "node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dev": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -13493,13 +13493,13 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dev": true, "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -18912,10 +18912,13 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", - "dev": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/merge-stream": { "version": "2.0.0", @@ -20928,9 +20931,9 @@ "peer": true }, "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", "dev": true }, "node_modules/path-type": { @@ -21501,12 +21504,12 @@ ] }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "dev": true, "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -22419,9 +22422,9 @@ "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==" }, "node_modules/rollup": { - "version": "2.79.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", - "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "version": "2.79.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", + "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -22742,9 +22745,9 @@ } }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dev": true, "dependencies": { "debug": "2.6.9", @@ -22780,6 +22783,15 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/send/node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -22886,15 +22898,15 @@ } }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dev": true, "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" @@ -28248,7 +28260,7 @@ }, "packages/analysis-engine": { "name": "@githru-vscode-ext/analysis-engine", - "version": "0.7.0", + "version": "0.7.2", "license": "MIT", "dependencies": { "@octokit/core": "^4.0.4", @@ -29650,7 +29662,7 @@ }, "packages/view": { "name": "@githru-vscode-ext/view", - "version": "0.7.0", + "version": "0.7.2", "license": "MIT", "dependencies": { "@emotion/react": "^11.13.0", @@ -29748,9 +29760,9 @@ }, "packages/vscode": { "name": "githru-vscode-ext", - "version": "0.7.0", + "version": "0.7.2", "dependencies": { - "@githru-vscode-ext/analysis-engine": "^0.7.0", + "@githru-vscode-ext/analysis-engine": "^0.7.2", "@octokit/rest": "^20.0.1", "node-fetch": "^3.3.2" }, diff --git a/packages/analysis-engine/package.json b/packages/analysis-engine/package.json index 07db8929..af51d81f 100644 --- a/packages/analysis-engine/package.json +++ b/packages/analysis-engine/package.json @@ -1,6 +1,6 @@ { "name": "@githru-vscode-ext/analysis-engine", - "version": "0.7.1", + "version": "0.7.2", "description": "analysis-engine module for githru", "main": "dist/index.js", "module": "dist/index.es.js", diff --git a/packages/view/package.json b/packages/view/package.json index 2def9b48..3e2733c7 100644 --- a/packages/view/package.json +++ b/packages/view/package.json @@ -1,6 +1,6 @@ { "name": "@githru-vscode-ext/view", - "version": "0.7.1", + "version": "0.7.2", "description": "view module for githru", "engines": { "node": ">=16", diff --git a/packages/vscode/README.md b/packages/vscode/README.md index b26206cf..e9978b3b 100644 --- a/packages/vscode/README.md +++ b/packages/vscode/README.md @@ -32,6 +32,11 @@ This extension contributes the following settings: Calling out known issues can help limit users opening duplicate issues against your extension. --> ## Release Notes +### 0.7.2 +- Show TAG information +- Update internal frameworks +- UI enhancement, Bug Fix + ### 0.7.1 - Theme Selector! - Optimized UI Rendering diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 88b72d47..0590f7fc 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/githru/githru-vscode-ext", "type": "git" }, - "version": "0.7.1", + "version": "0.7.2", "engines": { "vscode": "^1.67.0" }, @@ -84,7 +84,7 @@ "test": "jest" }, "dependencies": { - "@githru-vscode-ext/analysis-engine": "^0.7.1", + "@githru-vscode-ext/analysis-engine": "^0.7.2", "@octokit/rest": "^20.0.1", "node-fetch": "^3.3.2" }, From a94f52e3db0c343545c29b8a87f619a01ea5442e Mon Sep 17 00:00:00 2001 From: MINJEONG Date: Thu, 17 Oct 2024 08:49:51 +0900 Subject: [PATCH 47/49] =?UTF-8?q?test(view):=20File=20Icicle=20Summary?= =?UTF-8?q?=EC=9D=98=20util=20=ED=95=A8=EC=88=98=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1=20(#769)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FileIcicleSummary.util.test.ts | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 packages/view/src/components/Statistics/FileIcicleSummary/FileIcicleSummary.util.test.ts diff --git a/packages/view/src/components/Statistics/FileIcicleSummary/FileIcicleSummary.util.test.ts b/packages/view/src/components/Statistics/FileIcicleSummary/FileIcicleSummary.util.test.ts new file mode 100644 index 00000000..45becfe8 --- /dev/null +++ b/packages/view/src/components/Statistics/FileIcicleSummary/FileIcicleSummary.util.test.ts @@ -0,0 +1,103 @@ +import type { ClusterNode } from "types"; + +import { fakePrev } from "../../../../tests/fakeAsset"; + +import type { FileChangesMap, FileScoresMap, FileChangesNode } from "./FileIcicleSummary.type"; +import { getFileChangesMap, getFileScoresMap, getFileChangesTree } from "./FileIcicleSummary.util"; + +describe("getFileChangesMap", () => { + it("should return empty object if no data is provided", () => { + const fakeData: ClusterNode[] = []; + const result = getFileChangesMap(fakeData); + + expect(result).not.toBeUndefined(); + expect(result).toEqual({}); + }); + + it("should return summed insertions, deletions and commits for each file", () => { + const result = getFileChangesMap(fakePrev); + + expect(result).not.toBeUndefined(); + expect(result).toEqual({ + "package-lock.json": { insertions: 751, deletions: 15, commits: 2 }, + "packages/view/.gitignore": { insertions: 2, deletions: 0, commits: 1 }, + "packages/view/package.json": { insertions: 10, deletions: 4, commits: 2 }, + "packages/view/src/reportWebVitals.js": { insertions: 0, deletions: 13, commits: 1 }, + "packages/vscode/.eslintrc.json": { insertions: 15, deletions: 7, commits: 1 }, + "packages/vscode/CHANGELOG.md": { insertions: 0, deletions: 9, commits: 1 }, + } as FileChangesMap); + }); +}); + +describe("getFileScoresMap", () => { + it("should return empty object if no data is provided", () => { + const fakeData: ClusterNode[] = []; + const result = getFileScoresMap(fakeData); + + expect(result).not.toBeUndefined(); + expect(result).toEqual({}); + }); + + it("should return score for each file", () => { + const result = getFileScoresMap(fakePrev); + + expect(result).not.toBeUndefined(); + expect(result).toEqual({ + "package-lock.json": 1, + "packages/view/.gitignore": 1, + "packages/view/package.json": 1, + "packages/view/src/reportWebVitals.js": 1, + "packages/vscode/.eslintrc.json": 1, + "packages/vscode/CHANGELOG.md": 1, + } as FileScoresMap); + }); +}); + +describe("getFileChangesTree", () => { + it("should return empty object if no data is provided", () => { + const fakeData: ClusterNode[] = []; + const result = getFileChangesTree(fakeData); + + expect(result).not.toBeUndefined(); + expect(result).toEqual({ name: "root", children: [] } as FileChangesNode); + }); + + it("should represent file changes in tree structure", () => { + const result = getFileChangesTree(fakePrev); + + expect(result).not.toBeUndefined(); + expect(result.name).toBe("root"); + expect(result.children).toHaveLength(2); + expect(result).toEqual({ + name: "root", + children: [ + { name: "package-lock.json", children: [], value: 1, insertions: 751, deletions: 15, commits: 2 }, + { + name: "packages", + children: [ + { + name: "view", + children: [ + { name: ".gitignore", children: [], value: 1, insertions: 2, deletions: 0, commits: 1 }, + { name: "package.json", children: [], value: 1, insertions: 10, deletions: 4, commits: 2 }, + { + name: "src", + children: [ + { name: "reportWebVitals.js", children: [], value: 1, insertions: 0, deletions: 13, commits: 1 }, + ], + }, + ], + }, + { + name: "vscode", + children: [ + { name: ".eslintrc.json", children: [], value: 1, insertions: 15, deletions: 7, commits: 1 }, + { name: "CHANGELOG.md", children: [], value: 1, insertions: 0, deletions: 9, commits: 1 }, + ], + }, + ], + }, + ], + } as FileChangesNode); + }); +}); From 15096a9b8f9e4f68be8bcb2b2392bb3a87d6fd30 Mon Sep 17 00:00:00 2001 From: "ytaek.kim" Date: Thu, 17 Oct 2024 13:32:30 +0900 Subject: [PATCH 48/49] fix(all): fix typo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9fffd97..486ffe77 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "githru-vscode-ext", - "version": "0.7.1", + "version": "0.7.2", "description": "githru-vscode-ext root package.json", "scripts": { "build:all": "npm run build --workspaces", From afe60e03fb2d56c2104df5dcfe5a5ff8304fd78d Mon Sep 17 00:00:00 2001 From: "ytaek.kim" Date: Thu, 17 Oct 2024 14:52:40 +0900 Subject: [PATCH 49/49] fix(all): fix package-lock --- package-lock.json | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1604f836..424e5f31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "githru-vscode-ext", - "version": "0.7.1", + "version": "0.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "githru-vscode-ext", - "version": "0.7.1", + "version": "0.7.2", "license": "MIT", "workspaces": [ "./packages/*" @@ -13938,19 +13938,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/fullname": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fullname/-/fullname-2.1.0.tgz", @@ -21090,20 +21077,6 @@ "node": ">=18" } }, - "node_modules/playwright/node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",