Skip to content

Commit cdd59c6

Browse files
committed
Npm cmd run fix for env_config file fetching modules and args refactoring for delete repo
1 parent 22cad9e commit cdd59c6

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

API/deleteRepoApi.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
const fs = require("fs");
2-
const dotenv = require("dotenv").config();
3-
const { DATABASE_FILE } = require("../global/envConfigReader").getEnvData();
2+
const path = require("path");
43

5-
async function deleteRepoApi(repoId, name, pathName, time) {
6-
const dataStoreFile = DATABASE_FILE || "./database/repo-datastore.json";
4+
function getEnvData() {
5+
const envFileData = fs.readFileSync(
6+
path.join(__dirname, "..", "env_config.json")
7+
);
8+
9+
const envContent = envFileData.toString();
10+
let envData = JSON.parse(envContent)[0];
11+
12+
return {
13+
DATABASE_FILE: envData.databaseFile,
14+
GITCONVEX_PORT: envData.port,
15+
};
16+
}
17+
18+
async function deleteRepoApi(repoId) {
19+
const dataStoreFile = getEnvData().DATABASE_FILE;
720

821
return await fs.promises
922
.readFile(dataStoreFile)

API/fetchRepoApi.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
const fs = require("fs");
22
const dotnev = require("dotenv").config();
3-
const { DATABASE_FILE } = require("../global/envConfigReader").getEnvData();
3+
const path = require("path");
44

5-
async function fetchRepoHandler() {
6-
var repoDSContent = fs.readFileSync(
7-
DATABASE_FILE || "./database/repo-datastore.json"
5+
function getEnvData() {
6+
const envFileData = fs.readFileSync(
7+
path.join(__dirname, "..", "env_config.json")
88
);
99

10+
const envContent = envFileData.toString();
11+
let envData = JSON.parse(envContent)[0];
12+
13+
return {
14+
DATABASE_FILE: envData.databaseFile,
15+
GITCONVEX_PORT: envData.port,
16+
};
17+
}
18+
19+
async function fetchRepoHandler() {
20+
var repoDSContent = fs.readFileSync(getEnvData().DATABASE_FILE);
21+
1022
repoDSContent = repoDSContent.toString();
1123

1224
if (repoDSContent !== "") {

global/globalAPIHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ app.use(
134134
return await gitPullFromRemote(repoId);
135135
},
136136
deleteRepo: async (args) => {
137-
const { repoId, name, pathName, time } = args;
138-
return await deleteRepo(repoId, name, pathName, time);
137+
const { repoId } = args;
138+
return await deleteRepo(repoId);
139139
},
140140
addBranch: async (args) => {
141141
const { repoId, branchName } = args;

global/globalFunctionStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ module.exports.deleteRepo = deleteRepo = async (
242242
pathName,
243243
time
244244
) => {
245-
return await deleteRepoApi(repoId, name, pathName, time);
245+
return await deleteRepoApi(repoId);
246246
};
247247

248248
module.exports.addBranch = addBranch = async (repoId, branchName) => {

global/gqlGlobalAPISchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const globalAPISchema = new buildSchema(
106106
fetchFromRemote(repoId: String!): gitFetchStatus!
107107
pullFromRemote(repoId: String!): gitPullStatus!
108108
updateRepoDataFile(newDbFile: String!): String!
109-
deleteRepo(repoId: String!, name: String!, pathName: String!, time: String!): deleteRepoStatus!
109+
deleteRepo(repoId: String!): deleteRepoStatus!
110110
}
111111
112112
type gitFetchStatus{

0 commit comments

Comments
 (0)