From c163392e564ccb1003bd19c4d35c86e9ddd1154e Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Thu, 11 Apr 2024 23:51:15 +0530 Subject: [PATCH 01/15] changed stage.ts and branching.js --- package-lock.json | 4 +-- src/vc/branching.ts | 87 ++++++++++++++++++++++++++++++--------------- src/vc/stage.ts | 30 +++++++++------- 3 files changed, 77 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index b16493a..71e3fa7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "statikvc", - "version": "1.0.5-alpha", + "version": "1.1.0-alpha", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "statikvc", - "version": "1.0.5-alpha", + "version": "1.1.0-alpha", "license": "ISC", "dependencies": { "commander": "^11.0.0", diff --git a/src/vc/branching.ts b/src/vc/branching.ts index 7b772b5..51eed7a 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -2,11 +2,39 @@ import { create } from "ipfs-http-client"; import { IsStatik } from "../utils/checkStatik.js"; import fs from 'fs' import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; import Path from 'path' import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +function deleteDirectoryRecursive(directoryPath:string) { + if (!fs.existsSync(directoryPath)) { + console.error("Directory does not exist:", directoryPath); + return; + } + + // Get all items in the directory + const items = fs.readdirSync(directoryPath); + + items.forEach(item => { + const itemPath = path.join(directoryPath, item); + const stats = fs.statSync(itemPath); + + if (stats.isDirectory()) { + // Recursively delete subdirectories + deleteDirectoryRecursive(itemPath); + } else { + // Delete files + fs.unlinkSync(itemPath); + console.log(`Deleted file: ${itemPath}`); + } + }); + + // Finally, delete the empty directory + fs.rmdirSync(directoryPath); + console.log(`Deleted directory: ${directoryPath}`); +} export async function List(cwd: string){ try{ IsStatik(cwd) @@ -53,23 +81,7 @@ export async function Jump(cwd: string,branch: string){ // Check for unstaged changes const oldBranchContent = await commitContent(currentHead,client) const {overrides:hasUnstagedChanges,newFiles:addedFiles,updated:unstagedChanges,deletedFiles} = await isOverriding(cwd,client,oldBranchContent,currentFiles) - if(hasUnstagedChanges){ - if(unstagedChanges.length>0){ - console.log("\nUnstaged changes:") - for(const file of unstagedChanges){ - console.log(file) - } - } - if(deletedFiles.length>0){ - console.log("\nDeleted files:") - for(const file of deletedFiles){ - console.log(file) - } - } - console.log("\nThere are unstaged changes. You cannot switch branch without commiting it") - console.log("Abort") - process.exit(1) - } + // Handle the case where not unstaged but overriding // Solution: Prevent only if added files and deleted files are overriding // Check for overriding changes @@ -100,20 +112,37 @@ export async function Jump(cwd: string,branch: string){ // Conditionally delete files. Exempt new files under basepath const basepath = Path.dirname(newBranchContent[index].path) - deleteAllFiles(cwd+"/"+basepath,newFiles) - for(const obj of newBranchContent){ - const path = obj.path + let basepathnew + let dir; + basepathnew = newBranchContent[0].path.split("/"); + if(newBranchContent[0].path.split("/").length==1){ +dir=basepathnew[0] + } + else{ + dir=basepathnew[0]+"/" + } +console.log(basepathnew) + const directoryPath=cwd+"/"+dir + + + + + + // Recursively delete subdirectories + deleteDirectoryRecursive(directoryPath); + // deleteAllFiles(cwd+"/"+basepath,newFiles) + let data + for (const obj of newBranchContent) { + const path = obj.path; // Derive CID from multihash - const cid = multihashToCID(obj.cid) + const cid = multihashToCID(obj.cid); // console.log(cid,path) - const asyncitr = client.cat(cid) - for await(const itr of asyncitr){ - const data = Buffer.from(itr).toString() - const dirname = Path.dirname(cwd+"/"+path) - if(!fs.existsSync(dirname)){ - fs.mkdirSync(dirname,{recursive:true}) - } - fs.writeFileSync(path,data) + const asyncitr = client.cat(cid); + const dirname = Path.dirname(cwd + "/" + path); + for await (const itr of asyncitr) { + fs.mkdirSync(dirname, { recursive: true }); + data = Buffer.from(itr).toString(); + fs.writeFileSync(path, data); } } fs.writeFileSync(cwd+"/.statik/HEAD",branch); diff --git a/src/vc/stage.ts b/src/vc/stage.ts index 90f5822..335406c 100644 --- a/src/vc/stage.ts +++ b/src/vc/stage.ts @@ -18,7 +18,7 @@ export async function Add(cwd:string,paths:string[]){ let snapshot=[]; for (const path of paths){ for await (const result of client.addAll(globSource(path,{recursive:true}))) { - if(fs.statSync(cwd+"/"+path).isDirectory()) continue; + if(fs.statSync(cwd+"/"+result.path).isDirectory()) continue; snapshot.push(result) } } @@ -26,7 +26,7 @@ export async function Add(cwd:string,paths:string[]){ const result = await client.add(JSON.stringify(snapshot)) fs.writeFileSync(cwd+"/.statik/SNAPSHOT",result.path) console.log( - "Files staged to IPFS with cid: "+result.path + "Files staged to IPFS withmm cid: "+result.path ) }else{ let asyncitr = client.cat(prevCommit) @@ -42,23 +42,27 @@ export async function Add(cwd:string,paths:string[]){ prevContent = JSON.parse(data) } // Not optimized + let Content1=[] for (const path of paths){ for await (const result of client.addAll(globSource(path,{recursive:true}))) { // Check if the path is a directory const path = result.path - if(fs.statSync(cwd+"/"+path).isDirectory()) continue; - let flag = true - for(const prev of prevContent){ - if(prev.path==result.path){ - prevContent.splice(prevContent.indexOf(prev),1,result) - flag = false - break; - } - } - if(flag) prevContent.push(result) + if(fs.statSync(cwd+"/"+path).isDirectory()) { + continue;} + Content1.push(result) + + // let flag = true + // for(const prev of prevContent){ + // if(prev.path==result.path){ + // prevContent.splice(prevContent.indexOf(prev),1,result) + // flag = false + // break; + // } + // } + // if(flag) prevContent.push(result) } } - const result = await client.add(JSON.stringify(prevContent)) + const result = await client.add(JSON.stringify(Content1)) // console.log(result.path,prevSnapshot) if(result.path==prevSnapshot){ console.log("There are no changes to add") From 832eb7155094ffc15c625b7184a0abf6d89f951f Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 12 Apr 2024 16:47:22 +0530 Subject: [PATCH 02/15] fixed the recent issue in fixes --- dist/vc/branching.js | 95 ++++++++++++++++++++++++++++++---------- dist/vc/branching.js.map | 2 +- dist/vc/stage.js | 28 ++++++------ dist/vc/stage.js.map | 2 +- src/vc/branching.ts | 34 ++++++++++++-- 5 files changed, 118 insertions(+), 43 deletions(-) diff --git a/dist/vc/branching.js b/dist/vc/branching.js index bb03d4e..887cbfb 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -2,11 +2,60 @@ import { create } from "ipfs-http-client"; import { IsStatik } from "../utils/checkStatik.js"; import fs from 'fs'; import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; import Path from 'path'; import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; -import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +import { readAllFiles } from "../utils/dirwalk.js"; +function deleteFile(filePath) { + return new Promise((resolve, reject) => { + // Use fs.unlink to delete the file + fs.unlink(filePath, (err) => { + if (err) { + // If there's an error, reject the promise with the error + reject(err); + return; + } + // If deletion is successful, resolve the promise + resolve(); + }); + }); +} +function deleteDirectoryRecursive(directoryPath, isfile) { + if (!fs.existsSync(directoryPath)) { + console.error("Directory does not exist:", directoryPath); + return; + } + if (isfile == "1") { + deleteFile(directoryPath) + .then(() => { + console.log(`File ${directoryPath} deleted successfully.`); + }) + .catch((err) => { + console.error(`Error deleting file ${directoryPath}: ${err}`); + }); + return; + } + // Get all items in the directory + const items = fs.readdirSync(directoryPath); + items.forEach(item => { + const itemPath = path.join(directoryPath, item); + const stats = fs.statSync(itemPath); + if (stats.isDirectory()) { + // Recursively delete subdirectories + deleteDirectoryRecursive(itemPath, isfile); + } + else { + // Delete files + fs.unlinkSync(itemPath); + console.log(`Deleted file: ${itemPath}`); + } + }); + // Finally, delete the empty directory + fs.rmdirSync(directoryPath); + console.log(`Deleted directory: ${directoryPath}`); +} export async function List(cwd) { try { IsStatik(cwd); @@ -53,23 +102,6 @@ export async function Jump(cwd, branch) { // Check for unstaged changes const oldBranchContent = await commitContent(currentHead, client); const { overrides: hasUnstagedChanges, newFiles: addedFiles, updated: unstagedChanges, deletedFiles } = await isOverriding(cwd, client, oldBranchContent, currentFiles); - if (hasUnstagedChanges) { - if (unstagedChanges.length > 0) { - console.log("\nUnstaged changes:"); - for (const file of unstagedChanges) { - console.log(file); - } - } - if (deletedFiles.length > 0) { - console.log("\nDeleted files:"); - for (const file of deletedFiles) { - console.log(file); - } - } - console.log("\nThere are unstaged changes. You cannot switch branch without commiting it"); - console.log("Abort"); - process.exit(1); - } // Handle the case where not unstaged but overriding // Solution: Prevent only if added files and deleted files are overriding // Check for overriding changes @@ -98,19 +130,34 @@ export async function Jump(cwd, branch) { } // Conditionally delete files. Exempt new files under basepath const basepath = Path.dirname(newBranchContent[index].path); - deleteAllFiles(cwd + "/" + basepath, newFiles); + let basepathnew; + let dir; + basepathnew = newBranchContent[0].path.split("/"); + let isfile; + if (newBranchContent[0].path.split("/").length == 1) { + dir = basepathnew[0]; + isfile = "1"; + } + else { + dir = basepathnew[0] + "/"; + isfile = "0"; + } + console.log(basepathnew); + const directoryPath = cwd + "/" + dir; + // Recursively delete subdirectories + deleteDirectoryRecursive(directoryPath, isfile); + // deleteAllFiles(cwd+"/"+basepath,newFiles) + let data; for (const obj of newBranchContent) { const path = obj.path; // Derive CID from multihash const cid = multihashToCID(obj.cid); // console.log(cid,path) const asyncitr = client.cat(cid); + const dirname = Path.dirname(cwd + "/" + path); for await (const itr of asyncitr) { - const data = Buffer.from(itr).toString(); - const dirname = Path.dirname(cwd + "/" + path); - if (!fs.existsSync(dirname)) { - fs.mkdirSync(dirname, { recursive: true }); - } + fs.mkdirSync(dirname, { recursive: true }); + data = Buffer.from(itr).toString(); fs.writeFileSync(path, data); } } diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index a2ed17e..eca83e1 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kB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EAAE;oBAC9B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;oBACnC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACJ;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/dist/vc/stage.js b/dist/vc/stage.js index 84cfcf8..fe8c1d7 100644 --- a/dist/vc/stage.js +++ b/dist/vc/stage.js @@ -17,7 +17,7 @@ export async function Add(cwd, paths) { let snapshot = []; for (const path of paths) { for await (const result of client.addAll(globSource(path, { recursive: true }))) { - if (fs.statSync(cwd + "/" + path).isDirectory()) + if (fs.statSync(cwd + "/" + result.path).isDirectory()) continue; snapshot.push(result); } @@ -25,7 +25,7 @@ export async function Add(cwd, paths) { // console.log(snapshot) const result = await client.add(JSON.stringify(snapshot)); fs.writeFileSync(cwd + "/.statik/SNAPSHOT", result.path); - console.log("Files staged to IPFS with cid: " + result.path); + console.log("Files staged to IPFS withmm cid: " + result.path); } else { let asyncitr = client.cat(prevCommit); @@ -41,25 +41,27 @@ export async function Add(cwd, paths) { prevContent = JSON.parse(data); } // Not optimized + let Content1 = []; for (const path of paths) { for await (const result of client.addAll(globSource(path, { recursive: true }))) { // Check if the path is a directory const path = result.path; - if (fs.statSync(cwd + "/" + path).isDirectory()) + if (fs.statSync(cwd + "/" + path).isDirectory()) { continue; - let flag = true; - for (const prev of prevContent) { - if (prev.path == result.path) { - prevContent.splice(prevContent.indexOf(prev), 1, result); - flag = false; - break; - } } - if (flag) - prevContent.push(result); + Content1.push(result); + // let flag = true + // for(const prev of prevContent){ + // if(prev.path==result.path){ + // prevContent.splice(prevContent.indexOf(prev),1,result) + // flag = false + // break; + // } + // } + // if(flag) prevContent.push(result) } } - const result = await client.add(JSON.stringify(prevContent)); + const result = await client.add(JSON.stringify(Content1)); // console.log(result.path,prevSnapshot) if (result.path == prevSnapshot) { console.log("There are no changes to add"); diff --git a/dist/vc/stage.js.map b/dist/vc/stage.js.map index 8da85a0..8d5e982 100644 --- a/dist/vc/stage.js.map +++ b/dist/vc/stage.js.map @@ -1 +1 @@ -{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/vc/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,GAAU,EAAC,KAAc;IAC/C,IAAG;QACC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACb,IAAG,CAAC,KAAK,CAAC,MAAM,EAAC;YACb,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;YACtC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;YAChC,OAAM;SACT;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,EAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,aAAa,EAAC,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC9D,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,iBAAiB,GAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC3E,IAAG,CAAC,UAAU,CAAC,MAAM,EAA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/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -8,12 +8,35 @@ import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; -function deleteDirectoryRecursive(directoryPath:string) { +function deleteFile(filePath: string): Promise { + return new Promise((resolve, reject) => { + // Use fs.unlink to delete the file + fs.unlink(filePath, (err) => { + if (err) { + // If there's an error, reject the promise with the error + reject(err); + return; + } + // If deletion is successful, resolve the promise + resolve(); + }); + }); +} +function deleteDirectoryRecursive(directoryPath:string,isfile:string) { if (!fs.existsSync(directoryPath)) { console.error("Directory does not exist:", directoryPath); return; } - + if(isfile=="1"){ + deleteFile(directoryPath) + .then(() => { + console.log(`File ${directoryPath} deleted successfully.`); + }) + .catch((err) => { + console.error(`Error deleting file ${directoryPath}: ${err}`); + }); + return ; + } // Get all items in the directory const items = fs.readdirSync(directoryPath); @@ -23,7 +46,7 @@ function deleteDirectoryRecursive(directoryPath:string) { if (stats.isDirectory()) { // Recursively delete subdirectories - deleteDirectoryRecursive(itemPath); + deleteDirectoryRecursive(itemPath,isfile); } else { // Delete files fs.unlinkSync(itemPath); @@ -115,11 +138,14 @@ export async function Jump(cwd: string,branch: string){ let basepathnew let dir; basepathnew = newBranchContent[0].path.split("/"); + let isfile; if(newBranchContent[0].path.split("/").length==1){ dir=basepathnew[0] +isfile="1" } else{ dir=basepathnew[0]+"/" + isfile="0" } console.log(basepathnew) const directoryPath=cwd+"/"+dir @@ -129,7 +155,7 @@ console.log(basepathnew) // Recursively delete subdirectories - deleteDirectoryRecursive(directoryPath); + deleteDirectoryRecursive(directoryPath,isfile); // deleteAllFiles(cwd+"/"+basepath,newFiles) let data for (const obj of newBranchContent) { From c4e871b22c4a1dc3a76562b084e4d63a37526012 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 12 Apr 2024 16:49:06 +0530 Subject: [PATCH 03/15] fixed the recent issue in fixes --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 60f6da1..e74495d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,7 +11,7 @@ const program = new Command(); program .name("statik") .version("1.1.0-alpha") - .description(figlet.textSync("Statik")+"\nAn IPFS based version control system with static file hosting features") + .description(figlet.textSync("Statik")+"\n An IPFS based version control system with static file hosting features") program.command("init ").description("Initialize a new Statik repository") program.command("add [file_path]").description("Add a file to the Statik repository") program.command("commit ").description("Commit changes to the Statik repository") From f5957137e243374fd9c20ede035908063890901b Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 00:27:43 +0530 Subject: [PATCH 04/15] fixed typos and console.logs() --- demo/a.txt | 2 +- dist/index.js | 2 +- dist/index.js.map | 2 +- dist/vc/branching.js | 8 -------- dist/vc/branching.js.map | 2 +- dist/vc/stage.js | 19 ++++--------------- dist/vc/stage.js.map | 2 +- src/index.ts | 2 +- src/vc/branching.ts | 10 +--------- src/vc/stage.ts | 21 ++++++--------------- 10 files changed, 17 insertions(+), 53 deletions(-) diff --git a/demo/a.txt b/demo/a.txt index c79c59e..23deba2 100644 --- a/demo/a.txt +++ b/demo/a.txt @@ -1 +1 @@ -Updated A \ No newline at end of file +Updated A diff --git a/dist/index.js b/dist/index.js index f6d586c..4624b87 100755 --- a/dist/index.js +++ b/dist/index.js @@ -10,7 +10,7 @@ const program = new Command(); program .name("statik") .version("1.1.0-alpha") - .description(figlet.textSync("Statik") + "\nAn IPFS based version control system with static file hosting features"); + .description(figlet.textSync("Statik") + "\n An IPFS based version control system with static file hosting features"); program.command("init ").description("Initialize a new Statik repository"); program.command("add [file_path]").description("Add a file to the Statik repository"); program.command("commit ").description("Commit changes to the Statik repository"); diff --git a/dist/index.js.map b/dist/index.js.map index e7c6e4f..9359ed5 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":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R,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM;IACR,KAAK,QAAQ;QACX,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM;IACR,KAAK,KAAK;QACR,GAAG,CAAC,GAAG,CAAC,CAAC;QACT,MAAM;IACR,KAAK,QAAQ;QACX,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,MAAM;IACR,KAAK,MAAM;QACT,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM;IAER;QACE,OAAO,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;CAClB"} \ No newline at end of file diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 887cbfb..5571cb2 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -30,10 +30,8 @@ function deleteDirectoryRecursive(directoryPath, isfile) { if (isfile == "1") { deleteFile(directoryPath) .then(() => { - console.log(`File ${directoryPath} deleted successfully.`); }) .catch((err) => { - console.error(`Error deleting file ${directoryPath}: ${err}`); }); return; } @@ -49,12 +47,10 @@ function deleteDirectoryRecursive(directoryPath, isfile) { else { // Delete files fs.unlinkSync(itemPath); - console.log(`Deleted file: ${itemPath}`); } }); // Finally, delete the empty directory fs.rmdirSync(directoryPath); - console.log(`Deleted directory: ${directoryPath}`); } export async function List(cwd) { try { @@ -142,17 +138,13 @@ export async function Jump(cwd, branch) { dir = basepathnew[0] + "/"; isfile = "0"; } - console.log(basepathnew); const directoryPath = cwd + "/" + dir; - // Recursively delete subdirectories deleteDirectoryRecursive(directoryPath, isfile); - // deleteAllFiles(cwd+"/"+basepath,newFiles) let data; for (const obj of newBranchContent) { const path = obj.path; // Derive CID from multihash const cid = multihashToCID(obj.cid); - // console.log(cid,path) const asyncitr = client.cat(cid); const dirname = Path.dirname(cwd + "/" + path); for await (const itr of asyncitr) { diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index eca83e1..669d549 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAkB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnE,SAAS,UAAU,CAAC,QAAgB;IAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,mCAAmC;QACnC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,GAAG,EAAE;gBACL,yDAAyD;gBACzD,MAAM,CAAC,GAAG,CAAC,CAAC;gBACZ,OAAO;aACV;YACD,iDAAiD;YACjD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AACD,SAAS,wBAAwB,CAAC,aAAoB,EAAC,MAAa;IAChE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,aAAa,CAAC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,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;gBAC/C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,QAAQ,EAAE;oBAC9B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;oBACnC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACJ;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/dist/vc/stage.js b/dist/vc/stage.js index fe8c1d7..f05aebc 100644 --- a/dist/vc/stage.js +++ b/dist/vc/stage.js @@ -22,10 +22,9 @@ export async function Add(cwd, paths) { snapshot.push(result); } } - // console.log(snapshot) const result = await client.add(JSON.stringify(snapshot)); fs.writeFileSync(cwd + "/.statik/SNAPSHOT", result.path); - console.log("Files staged to IPFS withmm cid: " + result.path); + console.log("Files staged to IPFS with cid: " + result.path); } else { let asyncitr = client.cat(prevCommit); @@ -41,7 +40,7 @@ export async function Add(cwd, paths) { prevContent = JSON.parse(data); } // Not optimized - let Content1 = []; + let newContent = []; for (const path of paths) { for await (const result of client.addAll(globSource(path, { recursive: true }))) { // Check if the path is a directory @@ -49,20 +48,10 @@ export async function Add(cwd, paths) { if (fs.statSync(cwd + "/" + path).isDirectory()) { continue; } - Content1.push(result); - // let flag = true - // for(const prev of prevContent){ - // if(prev.path==result.path){ - // prevContent.splice(prevContent.indexOf(prev),1,result) - // flag = false - // break; - // } - // } - // if(flag) prevContent.push(result) + newContent.push(result); } } - const result = await client.add(JSON.stringify(Content1)); - // console.log(result.path,prevSnapshot) + const result = await client.add(JSON.stringify(newContent)); if (result.path == prevSnapshot) { console.log("There are no changes to add"); return; diff --git a/dist/vc/stage.js.map b/dist/vc/stage.js.map index 8d5e982..c9cd034 100644 --- a/dist/vc/stage.js.map +++ b/dist/vc/stage.js.map @@ -1 +1 @@ -{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/vc/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,GAAU,EAAC,KAAc;IAC/C,IAAG;QACC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACb,IAAG,CAAC,KAAK,CAAC,MAAM,EAAC;YACb,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;YACtC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;YAChC,OAAM;SACT;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,EAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,aAAa,EAAC,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC9D,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,iBAAiB,GAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC3E,IAAG,CAAC,UAAU,CAAC,MAAM,EAAC;YAClB,IAAI,QAAQ,GAAC,EAAE,CAAC;YACh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C,EAAE;oBACzE,mCAAmC;oBACnC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;oBACxB,IAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAC,GAAG,GAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;wBACxC,SAAS;qBAAC;oBACd,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;iBAG1B;aACJ;YACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAA;YAC3D,IAAG,MAAM,CAAC,IAAI,IAAE,YAAY,EAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;gBAC1C,OAAM;aACT;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,mBAAmB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACrD,OAAO,CAAC,GAAG,CACP,iCAAiC,GAAC,MAAM,CAAC,IAAI,CAChD,CAAA;SACJ;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;IAAA,OAAM,CAAC,EAAC;QACL,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index e74495d..8d9f838 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,6 @@ import { Add } from "./vc/stage.js"; import { Commit } from "./vc/commit.js"; import { Log } from "./vc/history.js"; import { Jump, List } from "./vc/branching.js"; - const program = new Command(); program .name("statik") @@ -47,6 +46,7 @@ switch (program.args[0]) { case "jump": Jump(cwd, program.args[1]); break; + default: program.outputHelp(); process.exit(0) diff --git a/src/vc/branching.ts b/src/vc/branching.ts index 4a4aadc..ec04d12 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -30,10 +30,8 @@ function deleteDirectoryRecursive(directoryPath:string,isfile:string) { if(isfile=="1"){ deleteFile(directoryPath) .then(() => { - console.log(`File ${directoryPath} deleted successfully.`); - }) + }) .catch((err) => { - console.error(`Error deleting file ${directoryPath}: ${err}`); }); return ; } @@ -50,13 +48,11 @@ function deleteDirectoryRecursive(directoryPath:string,isfile:string) { } else { // Delete files fs.unlinkSync(itemPath); - console.log(`Deleted file: ${itemPath}`); } }); // Finally, delete the empty directory fs.rmdirSync(directoryPath); - console.log(`Deleted directory: ${directoryPath}`); } export async function List(cwd: string){ try{ @@ -147,22 +143,18 @@ isfile="1" dir=basepathnew[0]+"/" isfile="0" } -console.log(basepathnew) const directoryPath=cwd+"/"+dir - // Recursively delete subdirectories deleteDirectoryRecursive(directoryPath,isfile); - // deleteAllFiles(cwd+"/"+basepath,newFiles) let data for (const obj of newBranchContent) { const path = obj.path; // Derive CID from multihash const cid = multihashToCID(obj.cid); - // console.log(cid,path) const asyncitr = client.cat(cid); const dirname = Path.dirname(cwd + "/" + path); for await (const itr of asyncitr) { diff --git a/src/vc/stage.ts b/src/vc/stage.ts index 335406c..89fccd9 100644 --- a/src/vc/stage.ts +++ b/src/vc/stage.ts @@ -3,6 +3,7 @@ import { IsStatik } from "../utils/checkStatik.js"; import fs from 'fs' import { FetchConfig } from "../utils/fetchConfig.js"; import Path from 'path' +import { Duplex } from "stream"; export async function Add(cwd:string,paths:string[]){ try{ IsStatik(cwd) @@ -22,11 +23,10 @@ export async function Add(cwd:string,paths:string[]){ snapshot.push(result) } } - // console.log(snapshot) const result = await client.add(JSON.stringify(snapshot)) fs.writeFileSync(cwd+"/.statik/SNAPSHOT",result.path) console.log( - "Files staged to IPFS withmm cid: "+result.path + "Files staged to IPFS with cid: "+result.path ) }else{ let asyncitr = client.cat(prevCommit) @@ -42,28 +42,19 @@ export async function Add(cwd:string,paths:string[]){ prevContent = JSON.parse(data) } // Not optimized - let Content1=[] + let newContent=[] for (const path of paths){ for await (const result of client.addAll(globSource(path,{recursive:true}))) { // Check if the path is a directory const path = result.path if(fs.statSync(cwd+"/"+path).isDirectory()) { continue;} - Content1.push(result) + newContent.push(result) - // let flag = true - // for(const prev of prevContent){ - // if(prev.path==result.path){ - // prevContent.splice(prevContent.indexOf(prev),1,result) - // flag = false - // break; - // } - // } - // if(flag) prevContent.push(result) + } } - const result = await client.add(JSON.stringify(Content1)) - // console.log(result.path,prevSnapshot) + const result = await client.add(JSON.stringify(newContent)) if(result.path==prevSnapshot){ console.log("There are no changes to add") return From 2a2d8ec48b3ce624b607bfdcaf14b3b9d42e4bbe Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 21:26:45 +0530 Subject: [PATCH 05/15] latest branching fixes --- demo/.statik/heads/main | 2 +- demo/.statik/heads/test | 1 - demo/a.txt | 2 +- demo/b/b.txt | 2 +- dist/vc/branching.js | 40 ++++++++++++++++++++++++++++++++- dist/vc/branching.js.map | 2 +- dist/vc/stage.js | 9 ++++++++ dist/vc/stage.js.map | 2 +- src/vc/branching.ts | 48 +++++++++++++++++++++++++++++++++++++--- src/vc/stage.ts | 16 +++++++++++++- 10 files changed, 113 insertions(+), 11 deletions(-) delete mode 100644 demo/.statik/heads/test diff --git a/demo/.statik/heads/main b/demo/.statik/heads/main index b8dde4f..34df2b1 100644 --- a/demo/.statik/heads/main +++ b/demo/.statik/heads/main @@ -1 +1 @@ -QmSVvrt5Vcp9ACfoaAp3uZYzNppAN6PYGA7Jy9y9LFe8JL \ No newline at end of file +QmaKj3LgquHaf6uRWC5UiPKMdSpRk7NmGzh7Piufx5ZywU \ No newline at end of file diff --git a/demo/.statik/heads/test b/demo/.statik/heads/test deleted file mode 100644 index 46fcb3e..0000000 --- a/demo/.statik/heads/test +++ /dev/null @@ -1 +0,0 @@ -QmboP4hnUe7S1UWPDFPDBirRBJ6D3BKe2cukmmx8Fmyb2V \ No newline at end of file diff --git a/demo/a.txt b/demo/a.txt index 23deba2..33fc59f 100644 --- a/demo/a.txt +++ b/demo/a.txt @@ -1 +1 @@ -Updated A +A \ No newline at end of file diff --git a/demo/b/b.txt b/demo/b/b.txt index 7371f47..2b4c28c 100644 --- a/demo/b/b.txt +++ b/demo/b/b.txt @@ -1 +1 @@ -B \ No newline at end of file +B \ No newline at end of file diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 5571cb2..96c56cb 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -8,6 +8,40 @@ import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { readAllFiles } from "../utils/dirwalk.js"; +function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { + const statikPath = path.join(cwd, 'statik'); + if (!fs.existsSync(statikPath)) { + return; + } + const filesAndFolders = fs.readdirSync(cwd); + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + if (fileOrFolder === 'statik' || pathsToKeep.includes(filePath)) { + continue; + } + const stats = fs.statSync(filePath); + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } + else { + fs.unlinkSync(filePath); + } + } +} +function deleteFolderRecursive(folderPath) { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } + else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} function deleteFile(filePath) { return new Promise((resolve, reject) => { // Use fs.unlink to delete the file @@ -139,7 +173,11 @@ export async function Jump(cwd, branch) { isfile = "0"; } const directoryPath = cwd + "/" + dir; - deleteDirectoryRecursive(directoryPath, isfile); + let newBranchaddedpaths = []; + newBranchContent.forEach((e) => { + newBranchaddedpaths.push(e.path); + }); + deleteFoldersAndFilesExceptStatikAndPaths(cwd, newBranchaddedpaths); let data; for (const obj of newBranchContent) { const path = obj.path; diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index 669d549..6f0de52 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAkB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnE,SAAS,UAAU,CAAC,QAAgB;IAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,mCAAmC;QACnC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,GAAG,EAAE;gBACL,yDAAyD;gBACzD,MAAM,CAAC,GAAG,CAAC,CAAC;gBACZ,OAAO;aACV;YACD,iDAAiD;YACjD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AACD,SAAS,wBAAwB,CAAC,aAAoB,EAAC,MAAa;IAChE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,aAAa,CAAC,CAAC;QAC1D,OAAO;KACV;IACH,IAAG,MAAM,IAAE,GAAG,EAAC;QACb,UAAU,CAAC,aAAa,CAAC;aACxB,IAAI,CAAC,GAAG,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AO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;oBACnC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACJ;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/dist/vc/stage.js b/dist/vc/stage.js index f05aebc..2596278 100644 --- a/dist/vc/stage.js +++ b/dist/vc/stage.js @@ -51,6 +51,15 @@ export async function Add(cwd, paths) { newContent.push(result); } } + let newContentaddedpaths = []; + newContent.forEach((e) => { + newContentaddedpaths.push(e.path); + }); + prevContent.forEach((e) => { + if (!newContentaddedpaths.includes(e.path)) { + newContent.push(e); + } + }); const result = await client.add(JSON.stringify(newContent)); if (result.path == prevSnapshot) { console.log("There are no changes to add"); diff --git a/dist/vc/stage.js.map b/dist/vc/stage.js.map index c9cd034..23aadd1 100644 --- a/dist/vc/stage.js.map +++ b/dist/vc/stage.js.map @@ -1 +1 @@ -{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/vc/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,GAAU,EAAC,KAAc;IAC/C,IAAG;QACC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACb,IAAG,CAAC,KAAK,CAAC,M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YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,mBAAmB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACrD,OAAO,CAAC,GAAG,CACP,iCAAiC,GAAC,MAAM,CAAC,IAAI,CAChD,CAAA;SACJ;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;IAAA,OAAM,CAAC,EAAC;QACL,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC"} \ No newline at end of file diff --git a/src/vc/branching.ts b/src/vc/branching.ts index ec04d12..bd21496 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -8,6 +8,46 @@ import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: string[]): void { + const statikPath = path.join(cwd, 'statik'); + + if (!fs.existsSync(statikPath)) { + return; + } + + const filesAndFolders = fs.readdirSync(cwd); + + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + + if (fileOrFolder === 'statik' || pathsToKeep.includes(filePath)) { + continue; + } + + const stats = fs.statSync(filePath); + + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } else { + fs.unlinkSync(filePath); + } + } +} + +function deleteFolderRecursive(folderPath: string): void { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} + function deleteFile(filePath: string): Promise { return new Promise((resolve, reject) => { // Use fs.unlink to delete the file @@ -146,10 +186,12 @@ isfile="1" const directoryPath=cwd+"/"+dir - +let newBranchaddedpaths:string[]=[] +newBranchContent.forEach((e:any)=>{ + newBranchaddedpaths.push(e.path) +}) - - deleteDirectoryRecursive(directoryPath,isfile); + deleteFoldersAndFilesExceptStatikAndPaths(cwd,newBranchaddedpaths) let data for (const obj of newBranchContent) { const path = obj.path; diff --git a/src/vc/stage.ts b/src/vc/stage.ts index 89fccd9..57a0c79 100644 --- a/src/vc/stage.ts +++ b/src/vc/stage.ts @@ -4,6 +4,7 @@ import fs from 'fs' import { FetchConfig } from "../utils/fetchConfig.js"; import Path from 'path' import { Duplex } from "stream"; + export async function Add(cwd:string,paths:string[]){ try{ IsStatik(cwd) @@ -42,7 +43,7 @@ export async function Add(cwd:string,paths:string[]){ prevContent = JSON.parse(data) } // Not optimized - let newContent=[] + let newContent:any[]=[] for (const path of paths){ for await (const result of client.addAll(globSource(path,{recursive:true}))) { // Check if the path is a directory @@ -54,6 +55,19 @@ export async function Add(cwd:string,paths:string[]){ } } +let newContentaddedpaths:string[]=[]; + +newContent.forEach((e:any)=>{ + newContentaddedpaths.push(e.path); +}) + +prevContent.forEach((e:any)=>{ + if(!newContentaddedpaths.includes(e.path)){ + newContent.push(e); + } +}) + + const result = await client.add(JSON.stringify(newContent)) if(result.path==prevSnapshot){ console.log("There are no changes to add") From 59c906ca2a264965b5a9ade8952d62ddbf43f0b8 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 21:55:04 +0530 Subject: [PATCH 06/15] latest branching fixes 21:55 --- demo/.statik/heads/main | 2 +- demo/b/b.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/.statik/heads/main b/demo/.statik/heads/main index 34df2b1..c699df0 100644 --- a/demo/.statik/heads/main +++ b/demo/.statik/heads/main @@ -1 +1 @@ -QmaKj3LgquHaf6uRWC5UiPKMdSpRk7NmGzh7Piufx5ZywU \ No newline at end of file +Qmap618rCufuSyjHG3TGwydCyD1bX6kgD79pcvLPEGqRVn \ No newline at end of file diff --git a/demo/b/b.txt b/demo/b/b.txt index 2b4c28c..7371f47 100644 --- a/demo/b/b.txt +++ b/demo/b/b.txt @@ -1 +1 @@ -B \ No newline at end of file +B \ No newline at end of file From da5fa6a71e1a996063d3901c446acac2d7469ec8 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 21:57:29 +0530 Subject: [PATCH 07/15] latest branching fixes 21:55 --- dist/vc/branching.js | 71 ++++++++----------------------------- dist/vc/branching.js.map | 2 +- src/vc/branching.ts | 76 +++++++++------------------------------- 3 files changed, 31 insertions(+), 118 deletions(-) diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 96c56cb..4b473b6 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -8,26 +8,6 @@ import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { readAllFiles } from "../utils/dirwalk.js"; -function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { - const statikPath = path.join(cwd, 'statik'); - if (!fs.existsSync(statikPath)) { - return; - } - const filesAndFolders = fs.readdirSync(cwd); - for (const fileOrFolder of filesAndFolders) { - const filePath = path.join(cwd, fileOrFolder); - if (fileOrFolder === 'statik' || pathsToKeep.includes(filePath)) { - continue; - } - const stats = fs.statSync(filePath); - if (stats.isDirectory()) { - deleteFolderRecursive(filePath); - } - else { - fs.unlinkSync(filePath); - } - } -} function deleteFolderRecursive(folderPath) { if (fs.existsSync(folderPath)) { fs.readdirSync(folderPath).forEach((file) => { @@ -42,49 +22,25 @@ function deleteFolderRecursive(folderPath) { fs.rmdirSync(folderPath); } } -function deleteFile(filePath) { - return new Promise((resolve, reject) => { - // Use fs.unlink to delete the file - fs.unlink(filePath, (err) => { - if (err) { - // If there's an error, reject the promise with the error - reject(err); - return; - } - // If deletion is successful, resolve the promise - resolve(); - }); - }); -} -function deleteDirectoryRecursive(directoryPath, isfile) { - if (!fs.existsSync(directoryPath)) { - console.error("Directory does not exist:", directoryPath); - return; - } - if (isfile == "1") { - deleteFile(directoryPath) - .then(() => { - }) - .catch((err) => { - }); +function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { + const statikPath = path.join(cwd, '.statik'); + if (!fs.existsSync(statikPath)) { return; } - // Get all items in the directory - const items = fs.readdirSync(directoryPath); - items.forEach(item => { - const itemPath = path.join(directoryPath, item); - const stats = fs.statSync(itemPath); + const filesAndFolders = fs.readdirSync(cwd); + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { + continue; + } + const stats = fs.statSync(filePath); if (stats.isDirectory()) { - // Recursively delete subdirectories - deleteDirectoryRecursive(itemPath, isfile); + deleteFolderRecursive(filePath); } else { - // Delete files - fs.unlinkSync(itemPath); + fs.unlinkSync(filePath); } - }); - // Finally, delete the empty directory - fs.rmdirSync(directoryPath); + } } export async function List(cwd) { try { @@ -177,6 +133,7 @@ export async function Jump(cwd, branch) { newBranchContent.forEach((e) => { newBranchaddedpaths.push(e.path); }); + console.log(newBranchaddedpaths); deleteFoldersAndFilesExceptStatikAndPaths(cwd, newBranchaddedpaths); let data; for (const obj of newBranchContent) { diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index 6f0de52..cff23e8 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAA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YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/src/vc/branching.ts b/src/vc/branching.ts index bd21496..6a2d743 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -8,8 +8,21 @@ import { multihashToCID } from "../utils/cid.js"; import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +function deleteFolderRecursive(folderPath: string): void { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: string[]): void { - const statikPath = path.join(cwd, 'statik'); + const statikPath = path.join(cwd, '.statik'); if (!fs.existsSync(statikPath)) { return; @@ -20,7 +33,7 @@ function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: str for (const fileOrFolder of filesAndFolders) { const filePath = path.join(cwd, fileOrFolder); - if (fileOrFolder === 'statik' || pathsToKeep.includes(filePath)) { + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { continue; } @@ -34,66 +47,8 @@ function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: str } } -function deleteFolderRecursive(folderPath: string): void { - if (fs.existsSync(folderPath)) { - fs.readdirSync(folderPath).forEach((file) => { - const curPath = path.join(folderPath, file); - if (fs.lstatSync(curPath).isDirectory()) { // recurse - deleteFolderRecursive(curPath); - } else { // delete file - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(folderPath); - } -} - -function deleteFile(filePath: string): Promise { - return new Promise((resolve, reject) => { - // Use fs.unlink to delete the file - fs.unlink(filePath, (err) => { - if (err) { - // If there's an error, reject the promise with the error - reject(err); - return; - } - // If deletion is successful, resolve the promise - resolve(); - }); - }); -} -function deleteDirectoryRecursive(directoryPath:string,isfile:string) { - if (!fs.existsSync(directoryPath)) { - console.error("Directory does not exist:", directoryPath); - return; - } - if(isfile=="1"){ - deleteFile(directoryPath) - .then(() => { - }) - .catch((err) => { - }); - return ; - } - // Get all items in the directory - const items = fs.readdirSync(directoryPath); - items.forEach(item => { - const itemPath = path.join(directoryPath, item); - const stats = fs.statSync(itemPath); - if (stats.isDirectory()) { - // Recursively delete subdirectories - deleteDirectoryRecursive(itemPath,isfile); - } else { - // Delete files - fs.unlinkSync(itemPath); - } - }); - - // Finally, delete the empty directory - fs.rmdirSync(directoryPath); -} export async function List(cwd: string){ try{ IsStatik(cwd) @@ -190,6 +145,7 @@ let newBranchaddedpaths:string[]=[] newBranchContent.forEach((e:any)=>{ newBranchaddedpaths.push(e.path) }) +console.log(newBranchaddedpaths) deleteFoldersAndFilesExceptStatikAndPaths(cwd,newBranchaddedpaths) let data From 272457e743646b107702fee36969305a4eaee5c1 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 22:24:21 +0530 Subject: [PATCH 08/15] latest branching fixes 22:24 : removed console.logs --- demo/.statik/SNAPSHOT | 1 + demo/b/b.txt | 2 +- dist/vc/branching.js | 1 - dist/vc/branching.js.map | 2 +- src/vc/branching.ts | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/demo/.statik/SNAPSHOT b/demo/.statik/SNAPSHOT index e69de29..babaeda 100644 --- a/demo/.statik/SNAPSHOT +++ b/demo/.statik/SNAPSHOT @@ -0,0 +1 @@ +QmQEEHtK7J3Nq9qeaAobUxFZs2enbJWAA8iAzyhVJnsfmp \ No newline at end of file diff --git a/demo/b/b.txt b/demo/b/b.txt index 7371f47..c5bc7be 100644 --- a/demo/b/b.txt +++ b/demo/b/b.txt @@ -1 +1 @@ -B \ No newline at end of file +Bbb \ No newline at end of file diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 4b473b6..940e8ae 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -133,7 +133,6 @@ export async function Jump(cwd, branch) { newBranchContent.forEach((e) => { newBranchaddedpaths.push(e.path); }); - console.log(newBranchaddedpaths); deleteFoldersAndFilesExceptStatikAndPaths(cwd, newBranchaddedpaths); let data; for (const obj of newBranchContent) { diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index cff23e8..50e7f5e 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAkB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnE,SAAS,qBAAqB,CAAC,UAAkB;IAC7C,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC3B,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC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C,CAAA;YAES,yCAAyC,CAAC,GAAG,EAAC,mBAAmB,CAAC,CAAA;YACjE,IAAI,IAAI,CAAA;YACR,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE;gBAChC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;gBACtB,4BAA4B;gBAC5B,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;gBAC/C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,QAAQ,EAAE;oBAC9B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;oBACnC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACJ;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/src/vc/branching.ts b/src/vc/branching.ts index 6a2d743..70d9363 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -145,7 +145,6 @@ let newBranchaddedpaths:string[]=[] newBranchContent.forEach((e:any)=>{ newBranchaddedpaths.push(e.path) }) -console.log(newBranchaddedpaths) deleteFoldersAndFilesExceptStatikAndPaths(cwd,newBranchaddedpaths) let data From fd7247bbbf0496edd3cce9726b068876e04e727c Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sat, 13 Apr 2024 23:26:37 +0530 Subject: [PATCH 09/15] fixed branch 23:26 --- demo/.statik/SNAPSHOT | 1 - demo/.statik/heads/main | 2 +- demo/.statik/heads/test | 1 + demo/a.txt | 2 +- demo/b/b.txt | 1 - demo/c/c.txt | 0 dist/vc/branching.js | 29 +++++++++++++++++++++++++---- dist/vc/branching.js.map | 2 +- src/vc/branching.ts | 35 +++++++++++++++++++++++++++++------ 9 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 demo/.statik/heads/test delete mode 100644 demo/b/b.txt create mode 100644 demo/c/c.txt diff --git a/demo/.statik/SNAPSHOT b/demo/.statik/SNAPSHOT index babaeda..e69de29 100644 --- a/demo/.statik/SNAPSHOT +++ b/demo/.statik/SNAPSHOT @@ -1 +0,0 @@ -QmQEEHtK7J3Nq9qeaAobUxFZs2enbJWAA8iAzyhVJnsfmp \ No newline at end of file diff --git a/demo/.statik/heads/main b/demo/.statik/heads/main index c699df0..776c70c 100644 --- a/demo/.statik/heads/main +++ b/demo/.statik/heads/main @@ -1 +1 @@ -Qmap618rCufuSyjHG3TGwydCyD1bX6kgD79pcvLPEGqRVn \ No newline at end of file +QmVrD22M7cHJq6u9NrV98JRQf9NAC6pnMsZkZDbqMKQ2q8 \ No newline at end of file diff --git a/demo/.statik/heads/test b/demo/.statik/heads/test new file mode 100644 index 0000000..6432ae1 --- /dev/null +++ b/demo/.statik/heads/test @@ -0,0 +1 @@ +QmaEhqH6ySj5j85shZKumKbJuLLyPMTrEDZhTAvvVJg3e4 \ No newline at end of file diff --git a/demo/a.txt b/demo/a.txt index 33fc59f..dfc9179 100644 --- a/demo/a.txt +++ b/demo/a.txt @@ -1 +1 @@ -A \ No newline at end of file +AB \ No newline at end of file diff --git a/demo/b/b.txt b/demo/b/b.txt deleted file mode 100644 index c5bc7be..0000000 --- a/demo/b/b.txt +++ /dev/null @@ -1 +0,0 @@ -Bbb \ No newline at end of file diff --git a/demo/c/c.txt b/demo/c/c.txt new file mode 100644 index 0000000..e69de29 diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 940e8ae..2919e4e 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -135,17 +135,38 @@ export async function Jump(cwd, branch) { }); deleteFoldersAndFilesExceptStatikAndPaths(cwd, newBranchaddedpaths); let data; + let flag = false; for (const obj of newBranchContent) { - const path = obj.path; + const path1 = obj.path; // Derive CID from multihash const cid = multihashToCID(obj.cid); const asyncitr = client.cat(cid); - const dirname = Path.dirname(cwd + "/" + path); + const dirname = Path.dirname(cwd + "/" + path1); + fs.mkdirSync(dirname, { recursive: true }); for await (const itr of asyncitr) { - fs.mkdirSync(dirname, { recursive: true }); data = Buffer.from(itr).toString(); - fs.writeFileSync(path, data); + if (data) { + fs.writeFileSync(path1, data); + console.log(data); + } + else { + } + flag = true; } + if (!flag) { + try { + const directoryPath = path.join(cwd, path.dirname(path1)); + const fileName = path.basename(path1); + // Create the directory + fs.mkdirSync(directoryPath, { recursive: true }); + // Create the empty file + fs.writeFileSync(path.join(directoryPath, fileName), ''); + } + catch (err) { + console.error(`Error creating empty file: ${err}`); + } + } + flag = false; } fs.writeFileSync(cwd + "/.statik/HEAD", branch); return; diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index 50e7f5e..78ed052 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OA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,CAAC,IAAI,EAAC;oBAGV,IAAI;wBACA,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;wBAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAEtC,uBAAuB;wBACvB,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;wBAEjD,wBAAwB;wBACxB,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;qBAC5D;oBAAC,OAAO,GAAG,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;qBACtD;iBACJ;gBACD,IAAI,GAAC,KAAK,CAAC;aACV;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/src/vc/branching.ts b/src/vc/branching.ts index 70d9363..bec4213 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -1,6 +1,6 @@ import { create } from "ipfs-http-client"; import { IsStatik } from "../utils/checkStatik.js"; -import fs from 'fs' +import fs, { writeFileSync } from 'fs' import { FetchConfig } from "../utils/fetchConfig.js"; import path from "path"; import Path from 'path' @@ -145,21 +145,44 @@ let newBranchaddedpaths:string[]=[] newBranchContent.forEach((e:any)=>{ newBranchaddedpaths.push(e.path) }) - deleteFoldersAndFilesExceptStatikAndPaths(cwd,newBranchaddedpaths) let data + let flag=false for (const obj of newBranchContent) { - const path = obj.path; + const path1 = obj.path; // Derive CID from multihash const cid = multihashToCID(obj.cid); const asyncitr = client.cat(cid); - const dirname = Path.dirname(cwd + "/" + path); + const dirname = Path.dirname(cwd + "/" + path1); + fs.mkdirSync(dirname, { recursive: true }); for await (const itr of asyncitr) { - fs.mkdirSync(dirname, { recursive: true }); data = Buffer.from(itr).toString(); - fs.writeFileSync(path, data); + if(data){ + fs.writeFileSync(path1, data); + console.log(data) + } + else{ + } + flag=true + } + if (!flag){ + + + try { + const directoryPath = path.join(cwd, path.dirname(path1)); + const fileName = path.basename(path1); + + // Create the directory + fs.mkdirSync(directoryPath, { recursive: true }); + + // Create the empty file + fs.writeFileSync(path.join(directoryPath, fileName), ''); + } catch (err) { + console.error(`Error creating empty file: ${err}`); } } + flag=false; + } fs.writeFileSync(cwd+"/.statik/HEAD",branch); return } From 959ca9ccc83d10b5e9819af119b47e094415bb45 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Sun, 14 Apr 2024 14:59:00 +0530 Subject: [PATCH 10/15] fixed console logs 14:58 --- dist/vc/branching.js | 1 - dist/vc/branching.js.map | 2 +- src/vc/branching.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dist/vc/branching.js b/dist/vc/branching.js index 2919e4e..af741fe 100644 --- a/dist/vc/branching.js +++ b/dist/vc/branching.js @@ -147,7 +147,6 @@ export async function Jump(cwd, branch) { data = Buffer.from(itr).toString(); if (data) { fs.writeFileSync(path1, data); - console.log(data); } else { } diff --git a/dist/vc/branching.js.map b/dist/vc/branching.js.map index 78ed052..8b5b600 100644 --- a/dist/vc/branching.js.map +++ b/dist/vc/branching.js.map @@ -1 +1 @@ -{"version":3,"file":"branching.js","sourceRoot":"","sources":["../../src/vc/branching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAqB,MAAM,IAAI,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,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AQ,CAAC,EAAE,EAAE,CAAC,CAAC;qBAC5D;oBAAC,OAAO,GAAG,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;qBACtD;iBACJ;gBACD,IAAI,GAAC,KAAK,CAAC;aACV;YACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,eAAe,EAAC,MAAM,CAAC,CAAC;YAC7C,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/src/vc/branching.ts b/src/vc/branching.ts index bec4213..af1cdaa 100644 --- a/src/vc/branching.ts +++ b/src/vc/branching.ts @@ -159,7 +159,6 @@ newBranchContent.forEach((e:any)=>{ data = Buffer.from(itr).toString(); if(data){ fs.writeFileSync(path1, data); - console.log(data) } else{ } From adbddd67d08a5cebb176a047fb403c34e5c312c5 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 19 Apr 2024 09:03:53 +0530 Subject: [PATCH 11/15] latest branching fixes --- demo/.statik/HEAD | 2 +- demo/.statik/heads/main | 2 +- demo/.statik/heads/new | 1 + demo/.statik/heads/test | 1 - demo/a.txt | 1 - demo/b/c/c | 1 + demo/c/c.txt | 0 dist/index.js | 5 ++ dist/index.js.map | 2 +- dist/vc/Switch.js | 146 +++++++++++++++++++++++++++++++++++ dist/vc/Switch.js.map | 1 + dist/vc/stage.js | 10 ++- dist/vc/stage.js.map | 2 +- package.json | 2 +- src/index.ts | 6 ++ src/vc/Switch.ts | 163 ++++++++++++++++++++++++++++++++++++++++ src/vc/stage.ts | 11 ++- 17 files changed, 347 insertions(+), 9 deletions(-) create mode 100644 demo/.statik/heads/new delete mode 100644 demo/.statik/heads/test delete mode 100644 demo/a.txt create mode 100644 demo/b/c/c delete mode 100644 demo/c/c.txt create mode 100644 dist/vc/Switch.js create mode 100644 dist/vc/Switch.js.map create mode 100644 src/vc/Switch.ts diff --git a/demo/.statik/HEAD b/demo/.statik/HEAD index 88d050b..3e5126c 100644 --- a/demo/.statik/HEAD +++ b/demo/.statik/HEAD @@ -1 +1 @@ -main \ No newline at end of file +new \ No newline at end of file diff --git a/demo/.statik/heads/main b/demo/.statik/heads/main index 776c70c..4b715ce 100644 --- a/demo/.statik/heads/main +++ b/demo/.statik/heads/main @@ -1 +1 @@ -QmVrD22M7cHJq6u9NrV98JRQf9NAC6pnMsZkZDbqMKQ2q8 \ No newline at end of file +QmbcRyckUhmRPsvX5Py174K1asLF2Mnjeh5TCnBB5fyjXa \ No newline at end of file diff --git a/demo/.statik/heads/new b/demo/.statik/heads/new new file mode 100644 index 0000000..3fa756b --- /dev/null +++ b/demo/.statik/heads/new @@ -0,0 +1 @@ +QmeAxpKT7kNngfNXgLPozU12Ukrb1zr5A8KovUFWc7hUmb \ No newline at end of file diff --git a/demo/.statik/heads/test b/demo/.statik/heads/test deleted file mode 100644 index 6432ae1..0000000 --- a/demo/.statik/heads/test +++ /dev/null @@ -1 +0,0 @@ -QmaEhqH6ySj5j85shZKumKbJuLLyPMTrEDZhTAvvVJg3e4 \ No newline at end of file diff --git a/demo/a.txt b/demo/a.txt deleted file mode 100644 index dfc9179..0000000 --- a/demo/a.txt +++ /dev/null @@ -1 +0,0 @@ -AB \ No newline at end of file diff --git a/demo/b/c/c b/demo/b/c/c new file mode 100644 index 0000000..3410062 --- /dev/null +++ b/demo/b/c/c @@ -0,0 +1 @@ +c \ No newline at end of file diff --git a/demo/c/c.txt b/demo/c/c.txt deleted file mode 100644 index e69de29..0000000 diff --git a/dist/index.js b/dist/index.js index 4624b87..fcc9f4b 100755 --- a/dist/index.js +++ b/dist/index.js @@ -6,6 +6,7 @@ import { Add } from "./vc/stage.js"; import { Commit } from "./vc/commit.js"; import { Log } from "./vc/history.js"; import { Jump, List } from "./vc/branching.js"; +import { Switch } from "./vc/Switch.js"; const program = new Command(); program .name("statik") @@ -17,6 +18,7 @@ program.command("commit ").description("Commit changes to the Statik re program.command("log").description("View the commit history of the current branch"); program.command("branch").description("List all branches in the Statik repository"); program.command("jump ").description("Switch between branches"); +program.command("switch ").description("Switch between commits"); program.parse(process.argv); if (program.args.length < 1) { program.outputHelp(); @@ -43,6 +45,9 @@ switch (program.args[0]) { case "jump": Jump(cwd, program.args[1]); break; + case "switch": + Switch(cwd, program.args[1]); + break; default: program.outputHelp(); process.exit(0); diff --git a/dist/index.js.map b/dist/index.js.map index 9359ed5..291372a 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC/C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAC,4EAA4E,CAAC,CAAA;AACtH,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAA;AACzF,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,WAAW,CAAC,qCAAqC,CAAC,CAAA;AACrF,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAA;AAC1F,OAAO,CAAC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ev/null +++ b/dist/vc/Switch.js @@ -0,0 +1,146 @@ +import { create } from "ipfs-http-client"; +import { IsStatik } from "../utils/checkStatik.js"; +import fs from 'fs'; +import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; +import Path from 'path'; +import { multihashToCID } from "../utils/cid.js"; +import { commitContent } from "../utils/fetchContent.js"; +function deleteFolderRecursive(folderPath) { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } + else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} +function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { + const statikPath = path.join(cwd, '.statik'); + if (!fs.existsSync(statikPath)) { + return; + } + const filesAndFolders = fs.readdirSync(cwd); + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { + continue; + } + const stats = fs.statSync(filePath); + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } + else { + fs.unlinkSync(filePath); + } + } +} +export async function List(cwd) { + try { + IsStatik(cwd); + // List all files + const currentBranch = fs.readFileSync(cwd + "/.statik/HEAD").toString(); + const files = fs.readdirSync(cwd + "/.statik/heads"); + for (const file of files) { + if (file === currentBranch) { + console.log("-> " + file + " <-"); + } + else { + console.log(file); + } + } + } + catch (err) { + console.error(err); + } +} +export async function Switch(cwd, CID) { + try { + IsStatik(cwd); + const currentBranch = fs.readFileSync(cwd + "/.statik/HEAD").toString(); + const currentHead = fs.readFileSync(cwd + "/.statik/heads/" + currentBranch).toString(); + // Check for staged changes + if (fs.readFileSync(cwd + "/.statik/SNAPSHOT").toString().length) { + console.log("There are staged changes. You cannot switch to other commit without commiting it"); + return; + } + else { + const commitId = CID; + const client = create({ url: FetchConfig(cwd).ipfs_node_url }); + // Check for unstaged changes + const headContent = await commitContent(currentHead, client); + // Handle the case where not unstaged but overriding + // Solution: Prevent only if added files and deleted files are overriding + // Check for overriding changes + let newcommitContent; + if (CID == "head") { + newcommitContent = headContent; + } + else { + newcommitContent = await commitContent(commitId, client); + } + // Conditionally delete files. Exempt new files under basepath + let basepathnew; + let dir; + basepathnew = newcommitContent[0].path.split("/"); + let isfile; + if (newcommitContent[0].path.split("/").length == 1) { + dir = basepathnew[0]; + isfile = "1"; + } + else { + dir = basepathnew[0] + "/"; + isfile = "0"; + } + const directoryPath = cwd + "/" + dir; + let newBranchaddedpaths = []; + newcommitContent.forEach((e) => { + newBranchaddedpaths.push(e.path); + }); + deleteFoldersAndFilesExceptStatikAndPaths(cwd, newBranchaddedpaths); + let data; + let flag = false; + for (const obj of newcommitContent) { + const path1 = obj.path; + // Derive CID from multihash + const cid = multihashToCID(obj.cid); + const asyncitr = client.cat(cid); + const dirname = Path.dirname(cwd + "/" + path1); + fs.mkdirSync(dirname, { recursive: true }); + for await (const itr of asyncitr) { + data = Buffer.from(itr).toString(); + if (data) { + fs.writeFileSync(path1, data); + } + else { + } + flag = true; + } + if (!flag) { + try { + const directoryPath = path.join(cwd, path.dirname(path1)); + const fileName = path.basename(path1); + // Create the directory + fs.mkdirSync(directoryPath, { recursive: true }); + // Create the empty file + fs.writeFileSync(path.join(directoryPath, fileName), ''); + } + catch (err) { + console.error(`Error creating empty file: ${err}`); + } + } + flag = false; + } + return; + } + } + catch (err) { + console.error(err); + } +} +//# sourceMappingURL=Switch.js.map \ No newline at end of file diff --git a/dist/vc/Switch.js.map b/dist/vc/Switch.js.map new file mode 100644 index 0000000..4915951 --- /dev/null +++ b/dist/vc/Switch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/vc/Switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,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S,EAAE,IAAI,EAAE,CAAC,CAAC;wBAEjD,wBAAwB;wBACxB,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;qBAC5D;oBAAC,OAAO,GAAG,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;qBACtD;iBACJ;gBACD,IAAI,GAAC,KAAK,CAAC;aACV;YACD,OAAM;SACT;KACJ;IAAA,OAAM,GAAG,EAAC;QACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACL,CAAC"} \ No newline at end of file diff --git a/dist/vc/stage.js b/dist/vc/stage.js index 2596278..d08a75c 100644 --- a/dist/vc/stage.js +++ b/dist/vc/stage.js @@ -22,6 +22,7 @@ export async function Add(cwd, paths) { snapshot.push(result); } } + console.log(snapshot); const result = await client.add(JSON.stringify(snapshot)); fs.writeFileSync(cwd + "/.statik/SNAPSHOT", result.path); console.log("Files staged to IPFS with cid: " + result.path); @@ -56,7 +57,14 @@ export async function Add(cwd, paths) { newContentaddedpaths.push(e.path); }); prevContent.forEach((e) => { - if (!newContentaddedpaths.includes(e.path)) { + let flag = false; + if (fs.existsSync(e.path)) { + flag = false; + } + else { + flag = true; + } + if (!newContentaddedpaths.includes(e.path) && !flag) { newContent.push(e); } }); diff --git a/dist/vc/stage.js.map b/dist/vc/stage.js.map index 23aadd1..17b5a8d 100644 --- a/dist/vc/stage.js.map +++ b/dist/vc/stage.js.map @@ -1 +1 @@ -{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/vc/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAA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 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "statik": "./dist/index.js" + "statik":"./dist/index.js" }, "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 8d9f838..74e1897 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import { Add } from "./vc/stage.js"; import { Commit } from "./vc/commit.js"; import { Log } from "./vc/history.js"; import { Jump, List } from "./vc/branching.js"; +import { Switch } from "./vc/Switch.js"; const program = new Command(); program .name("statik") @@ -17,6 +18,8 @@ program.command("commit ").description("Commit changes to the Statik re program.command("log").description("View the commit history of the current branch") program.command("branch").description("List all branches in the Statik repository") program.command("jump ").description("Switch between branches") +program.command("switch ").description("Switch between commits") + program.parse(process.argv); if (program.args.length < 1) { @@ -46,6 +49,9 @@ switch (program.args[0]) { case "jump": Jump(cwd, program.args[1]); break; + case "switch": + Switch(cwd, program.args[1]); + break; default: program.outputHelp(); diff --git a/src/vc/Switch.ts b/src/vc/Switch.ts new file mode 100644 index 0000000..537ac92 --- /dev/null +++ b/src/vc/Switch.ts @@ -0,0 +1,163 @@ +import { create } from "ipfs-http-client"; +import { IsStatik } from "../utils/checkStatik.js"; +import fs, { writeFileSync } from 'fs' +import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; +import Path from 'path' +import { multihashToCID } from "../utils/cid.js"; +import { isOverriding } from "../utils/changes.js"; +import { commitContent } from "../utils/fetchContent.js"; +import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +function deleteFolderRecursive(folderPath: string): void { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} +function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: string[]): void { + const statikPath = path.join(cwd, '.statik'); + + if (!fs.existsSync(statikPath)) { + return; + } + + const filesAndFolders = fs.readdirSync(cwd); + + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { + continue; + } + + const stats = fs.statSync(filePath); + + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } else { + fs.unlinkSync(filePath); + } + } +} + + + +export async function List(cwd: string){ + try{ + IsStatik(cwd) + // List all files + const currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() + const files = fs.readdirSync(cwd+"/.statik/heads") + for(const file of files){ + if(file===currentBranch){ + console.log("-> "+file+" <-") + }else{ + console.log(file) + } + } + }catch(err){ + console.error(err) + } +} + +export async function Switch(cwd: string,CID: string){ + try{ + IsStatik(cwd) + const currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() + + const currentHead = fs.readFileSync(cwd+"/.statik/heads/"+currentBranch).toString() + // Check for staged changes + if(fs.readFileSync(cwd+"/.statik/SNAPSHOT").toString().length){ + console.log("There are staged changes. You cannot switch to other commit without commiting it") + return + } + + else{ + const commitId = CID + const client = create({url: FetchConfig(cwd).ipfs_node_url}) + + // Check for unstaged changes + const headContent = await commitContent(currentHead,client) + + // Handle the case where not unstaged but overriding + // Solution: Prevent only if added files and deleted files are overriding + // Check for overriding changes + let newcommitContent + if(CID=="head"){ + newcommitContent=headContent + } +else{ + newcommitContent = await commitContent(commitId,client) + +} + + // Conditionally delete files. Exempt new files under basepath + let basepathnew + let dir; + basepathnew = newcommitContent[0].path.split("/"); + let isfile; + if(newcommitContent[0].path.split("/").length==1){ +dir=basepathnew[0] +isfile="1" + } + else{ + dir=basepathnew[0]+"/" + isfile="0" + } + const directoryPath=cwd+"/"+dir + + +let newBranchaddedpaths:string[]=[] +newcommitContent.forEach((e:any)=>{ + newBranchaddedpaths.push(e.path) +}) + deleteFoldersAndFilesExceptStatikAndPaths(cwd,newBranchaddedpaths) + let data + let flag=false + for (const obj of newcommitContent) { + const path1 = obj.path; + // Derive CID from multihash + const cid = multihashToCID(obj.cid); + const asyncitr = client.cat(cid); + const dirname = Path.dirname(cwd + "/" + path1); + fs.mkdirSync(dirname, { recursive: true }); + for await (const itr of asyncitr) { + data = Buffer.from(itr).toString(); + if(data){ + fs.writeFileSync(path1, data); + } + else{ + } + flag=true + } + if (!flag){ + + + try { + const directoryPath = path.join(cwd, path.dirname(path1)); + const fileName = path.basename(path1); + + // Create the directory + fs.mkdirSync(directoryPath, { recursive: true }); + + // Create the empty file + fs.writeFileSync(path.join(directoryPath, fileName), ''); + } catch (err) { + console.error(`Error creating empty file: ${err}`); + } + } + flag=false; + } + return + } + }catch(err){ + console.error(err) + } +} \ No newline at end of file diff --git a/src/vc/stage.ts b/src/vc/stage.ts index 57a0c79..9b9e2a0 100644 --- a/src/vc/stage.ts +++ b/src/vc/stage.ts @@ -24,6 +24,7 @@ export async function Add(cwd:string,paths:string[]){ snapshot.push(result) } } + console.log(snapshot) const result = await client.add(JSON.stringify(snapshot)) fs.writeFileSync(cwd+"/.statik/SNAPSHOT",result.path) console.log( @@ -62,9 +63,17 @@ newContent.forEach((e:any)=>{ }) prevContent.forEach((e:any)=>{ - if(!newContentaddedpaths.includes(e.path)){ + + let flag=false + if (fs.existsSync(e.path)) { +flag=false + } else { +flag=true + } + if(!newContentaddedpaths.includes(e.path)&&!flag){ newContent.push(e); } + }) From d311ffe65362e314295fafaa0090f08666d0eea4 Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 19 Apr 2024 09:09:41 +0530 Subject: [PATCH 12/15] description change --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 74e1897..4b4f671 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ program.command("commit ").description("Commit changes to the Statik re program.command("log").description("View the commit history of the current branch") program.command("branch").description("List all branches in the Statik repository") program.command("jump ").description("Switch between branches") -program.command("switch ").description("Switch between commits") +program.command("switch ").description("Switch between commits,switch to jump to head commit'") program.parse(process.argv); From 99cbc0e29e7481e686df69a3157ddd325d3bfbad Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 19 Apr 2024 09:10:18 +0530 Subject: [PATCH 13/15] description change --- dist/index.js | 2 +- dist/index.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index fcc9f4b..7ca8d10 100755 --- a/dist/index.js +++ b/dist/index.js @@ -18,7 +18,7 @@ program.command("commit ").description("Commit changes to the Statik re program.command("log").description("View the commit history of the current branch"); program.command("branch").description("List all branches in the Statik repository"); program.command("jump ").description("Switch between branches"); -program.command("switch ").description("Switch between commits"); +program.command("switch ").description("Switch between commits,switch to jump to head commit'"); program.parse(process.argv); if (program.args.length < 1) { program.outputHelp(); diff --git a/dist/index.js.map b/dist/index.js.map index 291372a..7f5d1ea 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAC,4E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AG,CAAC,CAAC;QACT,MAAM;IACR,KAAK,QAAQ;QACX,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,MAAM;IACR,KAAK,MAAM;QACT,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM;IACR,KAAK,QAAQ;QACX,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM;IAER;QACE,OAAO,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;CAClB"} \ No newline at end of file From a5913d100e67f8a52c1ac47628e1907bf8ef35cb Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 19 Apr 2024 17:01:40 +0530 Subject: [PATCH 14/15] reset --- demo/.statik/HEAD | 2 +- demo/.statik/SNAPSHOT | 1 + demo/.statik/heads/main | 2 +- demo/.statik/heads/new | 1 - demo/b/c/c | 6 ++- dist/index.js | 9 +++++ dist/index.js.map | 2 +- dist/vc/Switch.js | 4 ++ dist/vc/Switch.js.map | 2 +- dist/vc/reset.js | 63 +++++++++++++++++++++++++++++ dist/vc/reset.js.map | 1 + src/index.ts | 10 +++++ src/vc/Switch.ts | 16 +++++--- src/vc/reset.ts | 88 +++++++++++++++++++++++++++++++++++++++++ 14 files changed, 195 insertions(+), 12 deletions(-) delete mode 100644 demo/.statik/heads/new create mode 100644 dist/vc/reset.js create mode 100644 dist/vc/reset.js.map create mode 100644 src/vc/reset.ts diff --git a/demo/.statik/HEAD b/demo/.statik/HEAD index 3e5126c..88d050b 100644 --- a/demo/.statik/HEAD +++ b/demo/.statik/HEAD @@ -1 +1 @@ -new \ No newline at end of file +main \ No newline at end of file diff --git a/demo/.statik/SNAPSHOT b/demo/.statik/SNAPSHOT index e69de29..188d141 100644 --- a/demo/.statik/SNAPSHOT +++ b/demo/.statik/SNAPSHOT @@ -0,0 +1 @@ +QmQHSVaxoNZeSugM5P9B6XFfVT1tofJskXgisQVesvZdqS \ No newline at end of file diff --git a/demo/.statik/heads/main b/demo/.statik/heads/main index 4b715ce..e58498f 100644 --- a/demo/.statik/heads/main +++ b/demo/.statik/heads/main @@ -1 +1 @@ -QmbcRyckUhmRPsvX5Py174K1asLF2Mnjeh5TCnBB5fyjXa \ No newline at end of file +QmcvVE9k7JUQNXQPYi9LJ9i2KAa41AgtjdzQ9paeEHXHpJ \ No newline at end of file diff --git a/demo/.statik/heads/new b/demo/.statik/heads/new deleted file mode 100644 index 3fa756b..0000000 --- a/demo/.statik/heads/new +++ /dev/null @@ -1 +0,0 @@ -QmeAxpKT7kNngfNXgLPozU12Ukrb1zr5A8KovUFWc7hUmb \ No newline at end of file diff --git a/demo/b/c/c b/demo/b/c/c index 3410062..85954ea 100644 --- a/demo/b/c/c +++ b/demo/b/c/c @@ -1 +1,5 @@ -c \ No newline at end of file +1 +2 +3 +4 +5 \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 7ca8d10..e824338 100755 --- a/dist/index.js +++ b/dist/index.js @@ -7,6 +7,7 @@ import { Commit } from "./vc/commit.js"; import { Log } from "./vc/history.js"; import { Jump, List } from "./vc/branching.js"; import { Switch } from "./vc/Switch.js"; +import { hardreset, softreset } from "./vc/reset.js"; const program = new Command(); program .name("statik") @@ -19,6 +20,8 @@ program.command("log").description("View the commit history of the current branc program.command("branch").description("List all branches in the Statik repository"); program.command("jump ").description("Switch between branches"); program.command("switch ").description("Switch between commits,switch to jump to head commit'"); +program.command("hardreset ").description(" hard reset "); +program.command("softreset ").description(" soft reset "); program.parse(process.argv); if (program.args.length < 1) { program.outputHelp(); @@ -48,6 +51,12 @@ switch (program.args[0]) { case "switch": Switch(cwd, program.args[1]); break; + case "hardreset": + hardreset(program.args[1]); + break; + case "softreset": + softreset(program.args[1]); + break; default: program.outputHelp(); process.exit(0); diff --git a/dist/index.js.map b/dist/index.js.map index 7f5d1ea..00cd91e 100644 --- a/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,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM;IACR,KAAK,WAAW;QACd,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM;IAER;QACE,OAAO,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;CAClB"} \ No newline at end of file diff --git a/dist/vc/Switch.js b/dist/vc/Switch.js index a3398bc..125c802 100644 --- a/dist/vc/Switch.js +++ b/dist/vc/Switch.js @@ -41,6 +41,7 @@ function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { } } export async function List(cwd) { + console.log("done"); try { IsStatik(cwd); // List all files @@ -74,6 +75,7 @@ export async function Switch(cwd, CID) { const client = create({ url: FetchConfig(cwd).ipfs_node_url }); // Check for unstaged changes const headContent = await commitContent(currentHead, client); + console.log(commitId); // Handle the case where not unstaged but overriding // Solution: Prevent only if added files and deleted files are overriding // Check for overriding changes @@ -83,6 +85,7 @@ export async function Switch(cwd, CID) { } else { newcommitContent = await commitContent(commitId, client); + console.log("djcin"); } // Conditionally delete files. Exempt new files under basepath let basepathnew; @@ -114,6 +117,7 @@ export async function Switch(cwd, CID) { fs.mkdirSync(dirname, { recursive: true }); for await (const itr of asyncitr) { data = Buffer.from(itr).toString(); + console.log(data); if (data) { fs.writeFileSync(path1, data); } diff --git a/dist/vc/Switch.js.map b/dist/vc/Switch.js.map index 4915951..417f4f7 100644 --- a/dist/vc/Switch.js.map +++ b/dist/vc/Switch.js.map @@ -1 +1 @@ -{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/vc/Switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAqB,MAAM,IAAI,CAAA;AACtC,OAAO,EAAE,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3999b36 --- /dev/null +++ b/dist/vc/reset.js @@ -0,0 +1,63 @@ +import { create } from "ipfs-http-client"; +import { IsStatik } from "../utils/checkStatik.js"; +import fs from 'fs'; +import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; +import { Switch } from "./Switch.js"; +function deleteFolderRecursive(folderPath) { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } + else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} +function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { + const statikPath = path.join(cwd, '.statik'); + if (!fs.existsSync(statikPath)) { + return; + } + const filesAndFolders = fs.readdirSync(cwd); + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { + continue; + } + const stats = fs.statSync(filePath); + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } + else { + fs.unlinkSync(filePath); + } + } +} +export async function hardreset(CID) { + let cwd = process.cwd(); + let client = create({ url: FetchConfig(cwd).ipfs_node_url }); + IsStatik(cwd); + const currentBranch = fs.readFileSync(cwd + "/.statik/HEAD").toString(); + fs.writeFileSync(cwd + "/.statik/heads/" + currentBranch, CID); + Switch(cwd, CID); +} +export async function softreset(CID) { + let cwd = process.cwd(); + let client = create({ url: FetchConfig(cwd).ipfs_node_url }); + let currentBranch = fs.readFileSync(cwd + "/.statik/HEAD").toString(); + const commitId = fs.readFileSync(cwd + "/.statik/heads/" + currentBranch).toString(); + let prevSnapshot = ""; + let asyncitr = client.cat(commitId); + for await (const itr of asyncitr) { + const data = Buffer.from(itr).toString(); + prevSnapshot = JSON.parse(data).snapshot; + } + fs.writeFileSync(cwd + "/.statik/heads/" + currentBranch, CID); + fs.writeFileSync(cwd + "/.statik/SNAPSHOT", prevSnapshot); +} +//# sourceMappingURL=reset.js.map \ No newline at end of file diff --git a/dist/vc/reset.js.map b/dist/vc/reset.js.map new file mode 100644 index 0000000..55b7d01 --- /dev/null +++ b/dist/vc/reset.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/vc/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAqB,MAAM,IAAI,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,SAAS,qBAAqB,CAAC,UAAkB;IAC7C,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC3B,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC5C,IAAI,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,UAAU;gBACjD,qBAAqB,CAAC,OAAO,CAAC,CAAC;aAClC;iBAAM,EAAE,cAAc;gBACnB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC1B;QACL,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;KAC5B;AACL,CAAC;AACD,SAAS,yCAAyC,CAAC,GAAW,EAAE,WAAqB;IACjF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAE7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC5B,OAAO;KACV;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D,IAAI,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;IAE3D,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,iBAAiB,GAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAA;IACpF,IAAI,YAAY,GAAG,EAAE,CAAC;IAClB,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,KAAK,EAAC,MAAM,GAAG,IAAI,QAAQ,EAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QACxC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAA;KAC3C;IACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,iBAAiB,GAAC,aAAa,EAAC,GAAG,CAAC,CAAA;IAEzD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,mBAAmB,EAAC,YAAY,CAAC,CAAA;AAE9D,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 4b4f671..a86ed8d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import { Commit } from "./vc/commit.js"; import { Log } from "./vc/history.js"; import { Jump, List } from "./vc/branching.js"; import { Switch } from "./vc/Switch.js"; +import { hardreset, softreset } from "./vc/reset.js"; const program = new Command(); program .name("statik") @@ -19,6 +20,9 @@ program.command("log").description("View the commit history of the current branc program.command("branch").description("List all branches in the Statik repository") program.command("jump ").description("Switch between branches") program.command("switch ").description("Switch between commits,switch to jump to head commit'") +program.command("hardreset ").description(" hard reset ") +program.command("softreset ").description(" soft reset ") + program.parse(process.argv); @@ -52,6 +56,12 @@ switch (program.args[0]) { case "switch": Switch(cwd, program.args[1]); break; + case "hardreset": + hardreset(program.args[1]); + break; + case "softreset": + softreset(program.args[1]); + break; default: program.outputHelp(); diff --git a/src/vc/Switch.ts b/src/vc/Switch.ts index 537ac92..7f9b5c9 100644 --- a/src/vc/Switch.ts +++ b/src/vc/Switch.ts @@ -50,8 +50,10 @@ function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: str export async function List(cwd: string){ + console.log("done") try{ IsStatik(cwd) + // List all files const currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() const files = fs.readdirSync(cwd+"/.statik/heads") @@ -78,14 +80,15 @@ export async function Switch(cwd: string,CID: string){ console.log("There are staged changes. You cannot switch to other commit without commiting it") return } - - else{ + + else{ const commitId = CID const client = create({url: FetchConfig(cwd).ipfs_node_url}) - + // Check for unstaged changes const headContent = await commitContent(currentHead,client) - + console.log(commitId) + // Handle the case where not unstaged but overriding // Solution: Prevent only if added files and deleted files are overriding // Check for overriding changes @@ -93,9 +96,9 @@ export async function Switch(cwd: string,CID: string){ if(CID=="head"){ newcommitContent=headContent } -else{ + else{ newcommitContent = await commitContent(commitId,client) - +console.log("djcin") } // Conditionally delete files. Exempt new files under basepath @@ -130,6 +133,7 @@ newcommitContent.forEach((e:any)=>{ fs.mkdirSync(dirname, { recursive: true }); for await (const itr of asyncitr) { data = Buffer.from(itr).toString(); + console.log(data) if(data){ fs.writeFileSync(path1, data); } diff --git a/src/vc/reset.ts b/src/vc/reset.ts new file mode 100644 index 0000000..3e83c54 --- /dev/null +++ b/src/vc/reset.ts @@ -0,0 +1,88 @@ +import { create } from "ipfs-http-client"; +import { IsStatik } from "../utils/checkStatik.js"; +import fs, { writeFileSync } from 'fs' +import { FetchConfig } from "../utils/fetchConfig.js"; +import path from "path"; +import Path from 'path' +import { multihashToCID } from "../utils/cid.js"; +import { isOverriding } from "../utils/changes.js"; +import { commitContent } from "../utils/fetchContent.js"; +import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; +import { Switch } from "./Switch.js"; +function deleteFolderRecursive(folderPath: string): void { + if (fs.existsSync(folderPath)) { + fs.readdirSync(folderPath).forEach((file) => { + const curPath = path.join(folderPath, file); + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(folderPath); + } +} +function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: string[]): void { + const statikPath = path.join(cwd, '.statik'); + + if (!fs.existsSync(statikPath)) { + return; + } + + const filesAndFolders = fs.readdirSync(cwd); + + for (const fileOrFolder of filesAndFolders) { + const filePath = path.join(cwd, fileOrFolder); + + if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { + continue; + } + + const stats = fs.statSync(filePath); + + if (stats.isDirectory()) { + deleteFolderRecursive(filePath); + } else { + fs.unlinkSync(filePath); + } + } +} + + + + + +export async function hardreset(CID:string) { + + let cwd=process.cwd(); + let client = create({url: FetchConfig(cwd).ipfs_node_url}) + IsStatik(cwd) + const currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() + fs.writeFileSync(cwd+"/.statik/heads/"+currentBranch,CID) + + Switch(cwd,CID) + + + } + + export async function softreset(CID:string) + + { + let cwd=process.cwd() + let client = create({url: FetchConfig(cwd).ipfs_node_url}) + let currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() + + const commitId = fs.readFileSync(cwd+"/.statik/heads/"+currentBranch).toString() + let prevSnapshot = ""; + let asyncitr = client.cat(commitId) + + for await(const itr of asyncitr){ + const data = Buffer.from(itr).toString() + prevSnapshot = JSON.parse(data).snapshot + } + fs.writeFileSync(cwd+"/.statik/heads/"+currentBranch,CID) + + fs.writeFileSync(cwd+"/.statik/SNAPSHOT",prevSnapshot) + + } + \ No newline at end of file From c0e570b0d104bcffc14a3c5aeccc38b662f5c8ac Mon Sep 17 00:00:00 2001 From: GABRIEL-star-alt Date: Fri, 19 Apr 2024 17:02:26 +0530 Subject: [PATCH 15/15] reset --- dist/vc/reset.js | 36 ------------------------------------ dist/vc/reset.js.map | 2 +- src/vc/reset.ts | 42 ------------------------------------------ 3 files changed, 1 insertion(+), 79 deletions(-) diff --git a/dist/vc/reset.js b/dist/vc/reset.js index 3999b36..a0048b6 100644 --- a/dist/vc/reset.js +++ b/dist/vc/reset.js @@ -2,45 +2,9 @@ import { create } from "ipfs-http-client"; import { IsStatik } from "../utils/checkStatik.js"; import fs from 'fs'; import { FetchConfig } from "../utils/fetchConfig.js"; -import path from "path"; import { Switch } from "./Switch.js"; -function deleteFolderRecursive(folderPath) { - if (fs.existsSync(folderPath)) { - fs.readdirSync(folderPath).forEach((file) => { - const curPath = path.join(folderPath, file); - if (fs.lstatSync(curPath).isDirectory()) { // recurse - deleteFolderRecursive(curPath); - } - else { // delete file - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(folderPath); - } -} -function deleteFoldersAndFilesExceptStatikAndPaths(cwd, pathsToKeep) { - const statikPath = path.join(cwd, '.statik'); - if (!fs.existsSync(statikPath)) { - return; - } - const filesAndFolders = fs.readdirSync(cwd); - for (const fileOrFolder of filesAndFolders) { - const filePath = path.join(cwd, fileOrFolder); - if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { - continue; - } - const stats = fs.statSync(filePath); - if (stats.isDirectory()) { - deleteFolderRecursive(filePath); - } - else { - fs.unlinkSync(filePath); - } - } -} export async function hardreset(CID) { let cwd = process.cwd(); - let client = create({ url: FetchConfig(cwd).ipfs_node_url }); IsStatik(cwd); const currentBranch = fs.readFileSync(cwd + "/.statik/HEAD").toString(); fs.writeFileSync(cwd + "/.statik/heads/" + currentBranch, CID); diff --git a/dist/vc/reset.js.map b/dist/vc/reset.js.map index 55b7d01..e384105 100644 --- a/dist/vc/reset.js.map +++ b/dist/vc/reset.js.map @@ -1 +1 @@ -{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/vc/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,C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AAG,MAAM,CAAC,EAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,aAAa,EAAC,CAAC,CAAA;IAC1D,IAAI,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;IAE3D,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,GAAC,iBAAiB,GAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAA;IACpF,IAAI,YAAY,GAAG,EAAE,CAAC;IAClB,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,KAAK,EAAC,MAAM,GAAG,IAAI,QAAQ,EAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QACxC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAA;KAC3C;IACD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,iBAAiB,GAAC,aAAa,EAAC,GAAG,CAAC,CAAA;IAEzD,EAAE,CAAC,aAAa,CAAC,GAAG,GAAC,mBAAmB,EAAC,YAAY,CAAC,CAAA;AAE9D,CAAC"} \ No newline at end of file diff --git a/src/vc/reset.ts b/src/vc/reset.ts index 3e83c54..78cb34a 100644 --- a/src/vc/reset.ts +++ b/src/vc/reset.ts @@ -9,53 +9,11 @@ import { isOverriding } from "../utils/changes.js"; import { commitContent } from "../utils/fetchContent.js"; import { deleteAllFiles, readAllFiles } from "../utils/dirwalk.js"; import { Switch } from "./Switch.js"; -function deleteFolderRecursive(folderPath: string): void { - if (fs.existsSync(folderPath)) { - fs.readdirSync(folderPath).forEach((file) => { - const curPath = path.join(folderPath, file); - if (fs.lstatSync(curPath).isDirectory()) { // recurse - deleteFolderRecursive(curPath); - } else { // delete file - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(folderPath); - } -} -function deleteFoldersAndFilesExceptStatikAndPaths(cwd: string, pathsToKeep: string[]): void { - const statikPath = path.join(cwd, '.statik'); - - if (!fs.existsSync(statikPath)) { - return; - } - - const filesAndFolders = fs.readdirSync(cwd); - - for (const fileOrFolder of filesAndFolders) { - const filePath = path.join(cwd, fileOrFolder); - - if (fileOrFolder === '.statik' || pathsToKeep.includes(filePath)) { - continue; - } - - const stats = fs.statSync(filePath); - - if (stats.isDirectory()) { - deleteFolderRecursive(filePath); - } else { - fs.unlinkSync(filePath); - } - } -} - - - export async function hardreset(CID:string) { let cwd=process.cwd(); - let client = create({url: FetchConfig(cwd).ipfs_node_url}) IsStatik(cwd) const currentBranch = fs.readFileSync(cwd+"/.statik/HEAD").toString() fs.writeFileSync(cwd+"/.statik/heads/"+currentBranch,CID)