restructure

This commit is contained in:
2024-05-22 20:47:27 -04:00
parent 53c23e694a
commit ba41930a38
6 changed files with 88 additions and 5 deletions
View File
+20 -2
View File
@@ -1,16 +1,28 @@
{
"name": "github-to-fs",
"version": "1.0.0",
"version": "1.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "github-to-fs",
"version": "1.0.0",
"version": "1.0.2",
"license": "ISC",
"dependencies": {
"axios": "^1.7.2",
"base-64": "^1.0.0"
},
"devDependencies": {
"@types/node": "^20.12.12"
}
},
"node_modules/@types/node": {
"version": "20.12.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
"integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/asynckit": {
@@ -107,6 +119,12 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
}
}
}
+5 -2
View File
@@ -2,7 +2,7 @@
"name": "github-to-fs",
"version": "1.0.2",
"description": "a package that allows you to use github like file storage",
"main": "customFileSystem.js",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -18,5 +18,8 @@
"fs",
"filesystem",
"files"
]
],
"devDependencies": {
"@types/node": "^20.12.12"
}
}
+54
View File
@@ -0,0 +1,54 @@
type AuthHeaders = {
'Authorization': string;
};
type UpdateData = {
message: string;
content: string;
sha?: string;
};
type FileType = {
type: "dir" | "file";
name: string;
};
declare class ghelper {
private ghurl: string;
private authHeaders: AuthHeaders;
private errhelper(err: any): null;
constructor(repoURL: string, token: string);
appendToFile(fpath: string, toAdd: string): Promise<any>;
addToRepo(fpath: string, contentRaw: string | Buffer, sha?: string): Promise<any>;
remFromRepo(fpath: string): Promise<any>;
readTree(branchName: string): Promise<any>;
getStructure(dPath?: string, getSha?: boolean): Promise<Buffer | FileType[] | string | false>;
}
declare class mockFileObj {
private fpath: string;
private encoding?: string;
private fptrs: Promise<any>[];
private cfs: customFs;
constructor(cfs: customFs, fpath: string, encoding?: string);
write(toAdd: string): void;
close(): Promise<true | null>;
}
declare class customFs {
private ghs: ghelper;
constructor(repoUrl: string, token: string);
private getFilesInDir(dirPath: string): Promise<string[]>;
rmSync(dirPath: string, opts?: { recursive?: boolean }): Promise<any>;
appendToFile(fPath: string, toWrite: string): Promise<any>;
writeFileSync(fPath: string, toWriteRaw: any, opts?: { encoding?: string }): Promise<any>;
writeFile(fName: string, toWrite: any, cb: (err?: any) => void): void;
readFileSync(fName: string): Promise<any>;
readdirSync(dirName: string): Promise<FileType[]>;
existsSync(p: string): Promise<string | undefined>;
createWriteStream(fpath: string): mockFileObj;
mkdirSync(dirName: string): void;
}
+1 -1
View File
@@ -1,4 +1,4 @@
import customFs from "../customFileSystem";
import customFs from "..";
import fs from 'fs';
const { token } = JSON.parse(fs.readFileSync('config.json'));
+8
View File
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types",
"./src/types"
]
}
}