From 829361381cc54bdac39772d27a740b6bec59489b Mon Sep 17 00:00:00 2001 From: srijitcoder Date: Wed, 23 Oct 2024 14:46:53 +0530 Subject: [PATCH] fix: build issue --- package-lock.json | 51 +++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/App.vue | 21 +++++++++++++++--- src/api/index.js | 37 +++++++++++++++++++++++++------ src/main.js | 3 +++ src/stores/octokit.js | 23 +++++++++++++++++++ 6 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 src/stores/octokit.js diff --git a/package-lock.json b/package-lock.json index 631f697..1d595bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@primer/octicons": "^19.11.0", "dayjs": "^1.11.13", "octokit": "^4.0.2", + "pinia": "^2.2.4", "slugify": "^1.6.6", "vue": "^3.4.29", "vue-loading-overlay": "^6.0.6", @@ -2579,6 +2580,56 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pinia": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.2.4.tgz", + "integrity": "sha512-K7ZhpMY9iJ9ShTC0cR2+PnxdQRuwVIsXDO/WIEV/RnMC/vmSoKDTKW/exNQYPI+4ij10UjXqdNiEHwn47McANQ==", + "dependencies": { + "@vue/devtools-api": "^6.6.3", + "vue-demi": "^0.14.10" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.3.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/pinia/node_modules/vue-demi": { + "version": "0.14.10", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz", + "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, "node_modules/postcss": { "version": "8.4.47", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", diff --git a/package.json b/package.json index 53041c5..c8cad32 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@primer/octicons": "^19.11.0", "dayjs": "^1.11.13", "octokit": "^4.0.2", + "pinia": "^2.2.4", "slugify": "^1.6.6", "vue": "^3.4.29", "vue-loading-overlay": "^6.0.6", diff --git a/src/App.vue b/src/App.vue index d0dcbb2..1a6a83b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,33 @@ diff --git a/src/api/index.js b/src/api/index.js index 6d7f310..39265d2 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -8,41 +8,64 @@ import { sessionReviewStatus, } from "@/api/session"; import config from "@/../config.js"; +import useOctokitStore from "@/stores/octokit"; -const auth = await config.githubAuthToken(); -const username = config.githubOwner; -const repo = config.githubRepo; +export async function initOctokit() { + try { + const auth = await config.githubAuthToken(); + const username = config.githubOwner; + const repo = config.githubRepo; -const githubConfig = { auth, username, repo }; + const octokit = new Octokit({ auth }); -const octokit = new Octokit({ auth: githubConfig.auth }); + const { data } = await octokit.rest.users.getAuthenticated(); -const { data } = await octokit.rest.users.getAuthenticated(); + return { + githubConfig: { auth, username, repo }, + githubUserData: data, + octokit, + }; + } catch (error) { + console.error(error); + } +} export async function getLoginData() { return data; } export async function getSessionsList(currPage, cache) { - return sessionsList(octokit, githubConfig, currPage, cache, data.login); + const { githubConfig, githubUserData, octokit } = useOctokitStore(); + return sessionsList( + octokit, + githubConfig, + currPage, + cache, + githubUserData.login, + ); } export async function deleteBySessionNumber(sessionNumber) { + const { githubConfig, octokit } = useOctokitStore(); return deleteSession(octokit, githubConfig, sessionNumber); } export async function reviewBySessionNumber(sessionNumber, pullRequestId) { + const { githubConfig, octokit } = useOctokitStore(); return reviewSession(octokit, githubConfig, sessionNumber, pullRequestId); } export async function getCheckStatus(sessionNumber) { + const { githubConfig, octokit } = useOctokitStore(); return checkStatus(octokit, githubConfig, sessionNumber); } export async function getSessionReviewStatus(sessionNumber) { + const { githubConfig, octokit } = useOctokitStore(); return sessionReviewStatus(octokit, githubConfig, sessionNumber); } export async function createSessionByName(name) { + const { githubConfig, octokit } = useOctokitStore(); return createSession(octokit, githubConfig, name); } diff --git a/src/main.js b/src/main.js index eb2e3b2..f2c088b 100644 --- a/src/main.js +++ b/src/main.js @@ -6,9 +6,12 @@ import App from "./App.vue"; import router from "@/router"; import vuetify from "@/plugins/vuetify"; import { LoadingPlugin } from "vue-loading-overlay"; +import { createPinia } from "pinia"; const app = createApp(App); +const pinia = createPinia(); +app.use(pinia); app.use(vuetify); app.use(router); app.use(LoadingPlugin); diff --git a/src/stores/octokit.js b/src/stores/octokit.js new file mode 100644 index 0000000..f71656c --- /dev/null +++ b/src/stores/octokit.js @@ -0,0 +1,23 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; + +const useOctokitStore = defineStore("octokit", () => { + const githubConfig = ref(null); + const githubUserData = ref(null); + const octokit = ref(null); + + function setOctokit(instance) { + githubConfig.value = instance.githubConfig; + githubUserData.value = instance.githubUserData; + octokit.value = instance.octokit; + } + + return { + githubConfig, + githubUserData, + octokit, + setOctokit, + }; +}); + +export default useOctokitStore;