@bemoje/fs 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/index.cjs.js +6 -0
  2. package/dist/index.cjs.js.map +1 -0
  3. package/dist/index.esm.js +6 -0
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/types/index.d.ts +36 -0
  6. package/dist/types/index.d.ts.map +1 -0
  7. package/dist/types/lib/AppData.d.ts +11 -0
  8. package/dist/types/lib/AppData.d.ts.map +1 -0
  9. package/dist/types/lib/JsonFile.d.ts +79 -0
  10. package/dist/types/lib/JsonFile.d.ts.map +1 -0
  11. package/dist/types/lib/LogFile.d.ts +51 -0
  12. package/dist/types/lib/LogFile.d.ts.map +1 -0
  13. package/{src/lib/absoluteToRelativePath.ts → dist/types/lib/absoluteToRelativePath.d.ts} +14 -20
  14. package/dist/types/lib/absoluteToRelativePath.d.ts.map +1 -0
  15. package/dist/types/lib/appendLineToFile.d.ts +12 -0
  16. package/dist/types/lib/appendLineToFile.d.ts.map +1 -0
  17. package/{src/lib/cleanDirectorySync.ts → dist/types/lib/cleanDirectorySync.d.ts} +17 -24
  18. package/dist/types/lib/cleanDirectorySync.d.ts.map +1 -0
  19. package/{src/lib/createDirectory.ts → dist/types/lib/createDirectory.d.ts} +2 -5
  20. package/dist/types/lib/createDirectory.d.ts.map +1 -0
  21. package/{src/lib/createDirectorySync.ts → dist/types/lib/createDirectorySync.d.ts} +2 -6
  22. package/dist/types/lib/createDirectorySync.d.ts.map +1 -0
  23. package/{src/lib/createFileExtensionFilter.ts → dist/types/lib/createFileExtensionFilter.d.ts} +2 -14
  24. package/dist/types/lib/createFileExtensionFilter.d.ts.map +1 -0
  25. package/{src/lib/cwdpath.ts → dist/types/lib/cwdpath.d.ts} +13 -16
  26. package/dist/types/lib/cwdpath.d.ts.map +1 -0
  27. package/{src/lib/deleteDirectory.ts → dist/types/lib/deleteDirectory.d.ts} +2 -5
  28. package/dist/types/lib/deleteDirectory.d.ts.map +1 -0
  29. package/{src/lib/deleteDirectorySafe.ts → dist/types/lib/deleteDirectorySafe.d.ts} +2 -5
  30. package/dist/types/lib/deleteDirectorySafe.d.ts.map +1 -0
  31. package/{src/lib/deleteDirectorySafeSync.ts → dist/types/lib/deleteDirectorySafeSync.d.ts} +2 -7
  32. package/dist/types/lib/deleteDirectorySafeSync.d.ts.map +1 -0
  33. package/{src/lib/deleteDirectorySync.ts → dist/types/lib/deleteDirectorySync.d.ts} +2 -6
  34. package/dist/types/lib/deleteDirectorySync.d.ts.map +1 -0
  35. package/{src/lib/ensureValidWindowsPath.ts → dist/types/lib/ensureValidWindowsPath.d.ts} +23 -57
  36. package/dist/types/lib/ensureValidWindowsPath.d.ts.map +1 -0
  37. package/dist/types/lib/getDiskDrivesWindows.d.ts +2 -0
  38. package/dist/types/lib/getDiskDrivesWindows.d.ts.map +1 -0
  39. package/dist/types/lib/getDownloadsDirectory.d.ts +2 -0
  40. package/dist/types/lib/getDownloadsDirectory.d.ts.map +1 -0
  41. package/dist/types/lib/getHomeDirectory.d.ts +2 -0
  42. package/dist/types/lib/getHomeDirectory.d.ts.map +1 -0
  43. package/dist/types/lib/getLastMofifiedFileIn.d.ts +2 -0
  44. package/dist/types/lib/getLastMofifiedFileIn.d.ts.map +1 -0
  45. package/dist/types/lib/getRootDir.d.ts +2 -0
  46. package/dist/types/lib/getRootDir.d.ts.map +1 -0
  47. package/dist/types/lib/isWindows.d.ts +2 -0
  48. package/dist/types/lib/isWindows.d.ts.map +1 -0
  49. package/{src/lib/normalizeFileExtension.ts → dist/types/lib/normalizeFileExtension.d.ts} +23 -29
  50. package/dist/types/lib/normalizeFileExtension.d.ts.map +1 -0
  51. package/{src/lib/readFileLastLines.ts → dist/types/lib/readFileLastLines.d.ts} +3 -5
  52. package/dist/types/lib/readFileLastLines.d.ts.map +1 -0
  53. package/{src/lib/readJsonFile.ts → dist/types/lib/readJsonFile.d.ts} +13 -16
  54. package/dist/types/lib/readJsonFile.d.ts.map +1 -0
  55. package/{src/lib/readJsonFileSync.ts → dist/types/lib/readJsonFileSync.d.ts} +13 -16
  56. package/dist/types/lib/readJsonFileSync.d.ts.map +1 -0
  57. package/dist/types/lib/readPackageJson.d.ts +2 -0
  58. package/dist/types/lib/readPackageJson.d.ts.map +1 -0
  59. package/dist/types/lib/removeIllegalFilenameCharacters.d.ts +2 -0
  60. package/dist/types/lib/removeIllegalFilenameCharacters.d.ts.map +1 -0
  61. package/dist/types/lib/tempFile.d.ts +7 -0
  62. package/dist/types/lib/tempFile.d.ts.map +1 -0
  63. package/dist/types/lib/types/IEnsureValidWindowsPathOptions.d.ts +11 -0
  64. package/dist/types/lib/types/IEnsureValidWindowsPathOptions.d.ts.map +1 -0
  65. package/dist/types/lib/types/ILogFileData.d.ts +6 -0
  66. package/dist/types/lib/types/ILogFileData.d.ts.map +1 -0
  67. package/dist/types/lib/unzipFile.d.ts +2 -0
  68. package/dist/types/lib/unzipFile.d.ts.map +1 -0
  69. package/dist/types/lib/unzipMergeFiles.d.ts +5 -0
  70. package/dist/types/lib/unzipMergeFiles.d.ts.map +1 -0
  71. package/dist/types/lib/wipeDirectorySafe.d.ts +2 -0
  72. package/dist/types/lib/wipeDirectorySafe.d.ts.map +1 -0
  73. package/{src/lib/writeJsonFile.ts → dist/types/lib/writeJsonFile.d.ts} +2 -5
  74. package/dist/types/lib/writeJsonFile.d.ts.map +1 -0
  75. package/{src/lib/writeJsonFileSync.ts → dist/types/lib/writeJsonFileSync.d.ts} +2 -5
  76. package/dist/types/lib/writeJsonFileSync.d.ts.map +1 -0
  77. package/package.json +3 -3
  78. package/src/index.ts +0 -35
  79. package/src/lib/AppData.ts +0 -25
  80. package/src/lib/JsonFile.ts +0 -158
  81. package/src/lib/LogFile.ts +0 -117
  82. package/src/lib/absoluteToRelativePath.test.ts +0 -11
  83. package/src/lib/appendLineToFile.test.ts +0 -49
  84. package/src/lib/appendLineToFile.ts +0 -21
  85. package/src/lib/cleanDirectorySync.test.ts +0 -57
  86. package/src/lib/createDirectory.test.ts +0 -14
  87. package/src/lib/createDirectorySync.test.ts +0 -14
  88. package/src/lib/createFileExtensionFilter.test.ts +0 -17
  89. package/src/lib/cwdpath.test.ts +0 -48
  90. package/src/lib/deleteDirectory.test.ts +0 -24
  91. package/src/lib/deleteDirectorySafe.test.ts +0 -40
  92. package/src/lib/deleteDirectorySafeSync.test.ts +0 -30
  93. package/src/lib/deleteDirectorySync.test.ts +0 -23
  94. package/src/lib/ensureValidWindowsPath.test.ts +0 -80
  95. package/src/lib/getDiskDrivesWindows.ts +0 -13
  96. package/src/lib/getDownloadsDirectory.ts +0 -6
  97. package/src/lib/getHomeDirectory.ts +0 -7
  98. package/src/lib/getLastMofifiedFileIn.ts +0 -15
  99. package/src/lib/getRootDir.ts +0 -5
  100. package/src/lib/isWindows.ts +0 -3
  101. package/src/lib/normalizeFileExtension.test.ts +0 -15
  102. package/src/lib/readJsonFile.test.ts +0 -34
  103. package/src/lib/readJsonFileSync.test.ts +0 -36
  104. package/src/lib/readPackageJson.ts +0 -9
  105. package/src/lib/removeIllegalFilenameCharacters.ts +0 -3
  106. package/src/lib/tempFile.ts +0 -20
  107. package/src/lib/types/IEnsureValidWindowsPathOptions.ts +0 -10
  108. package/src/lib/types/ILogFileData.ts +0 -5
  109. package/src/lib/unzipFile.ts +0 -5
  110. package/src/lib/unzipMergeFiles.ts +0 -20
  111. package/src/lib/wipeDirectorySafe.ts +0 -7
  112. package/src/lib/writeJsonFile.test.ts +0 -26
  113. package/src/lib/writeJsonFileSync.test.ts +0 -28
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @bemoje/fs v0.0.12
3
+ * (c) Benjamin Møller Jensen
4
+ * Released under the MIT License.
5
+ */"use strict";var string=require("@bemoje/string"),path=require("path"),getAppDataPath=require("appdata-path"),EventEmitter=require("events"),fs=require("fs"),readline=require("readline"),child_process=require("child_process"),readLastLines=require("read-last-lines"),extract=require("extract-zip");function absoluteToRelativePath(absolute,workingDirectory=process.cwd()){return path.normalize(absolute).replace(new RegExp(string.regexEscapeString(path.normalize(workingDirectory)+path.sep),"i"),"")}function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}function __classPrivateFieldGet(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)}function __classPrivateFieldSet(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};function readJsonFileSync(filepath){return JSON.parse(fs.readFileSync(filepath,"utf8"))}function writeJsonFileSync(filepath,data,pretty=!1){fs.writeFileSync(filepath,JSON.stringify(data,null,pretty?2:void 0))}var _JsonFile_data;class JsonFile extends EventEmitter{get data(){return JSON.parse(JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")))}constructor(filepath,prettyPrint=!1){super(),_JsonFile_data.set(this,void 0),this.filepath=filepath,__classPrivateFieldSet(this,_JsonFile_data,{},"f"),this.prettyPrint=prettyPrint,this.ensureDirectoryExists(),fs.existsSync(this.filepath)?this.loadFile():writeJsonFileSync(this.filepath,__classPrivateFieldGet(this,_JsonFile_data,"f"),this.prettyPrint)}get(key){return JSON.parse(JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key]))}set(key,value){if(__classPrivateFieldGet(this,_JsonFile_data,"f")[key]!==value){const json=JSON.stringify(value);json===JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key])||(value=JSON.parse(json),__classPrivateFieldGet(this,_JsonFile_data,"f")[key]=value,this.saveFile(),this.emit("set",Date.now(),key,value))}}has(key){return __classPrivateFieldGet(this,_JsonFile_data,"f")[key]!==void 0}delete(key){delete __classPrivateFieldGet(this,_JsonFile_data,"f")[key],this.saveFile(),this.emit("set",Date.now(),key,void 0)}getOrElse(key,getValue){if(this.has(key))return JSON.parse(JSON.stringify(this.get(key)));const value=JSON.parse(JSON.stringify(getValue()));return this.set(key,value),value}clear(){const time=Date.now();for(const key of Object.keys(__classPrivateFieldGet(this,_JsonFile_data,"f")))this.emit("set",time,key,void 0);__classPrivateFieldSet(this,_JsonFile_data,{},"f"),fs.writeFileSync(this.filepath,"{}","utf8")}assign(data){data=JSON.parse(JSON.stringify(data));const time=Date.now();for(const[key,value]of Object.entries(data))__classPrivateFieldGet(this,_JsonFile_data,"f")[key]&&JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key])!==JSON.stringify(value)&&this.emit("set",time,key,value);Object.assign(__classPrivateFieldGet(this,_JsonFile_data,"f"),data),this.saveFile()}ensureDirectoryExists(){fs.mkdirSync(path.dirname(this.filepath),{recursive:!0})}saveFile(){writeJsonFileSync(this.filepath,__classPrivateFieldGet(this,_JsonFile_data,"f"),this.prettyPrint)}loadFile(){__classPrivateFieldSet(this,_JsonFile_data,readJsonFileSync(this.filepath),"f")}}_JsonFile_data=new WeakMap;class LogFile{constructor(filepath){this.filepath=filepath,this.ensureDirectoryExists()}append(data,time=Date.now()){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.appendFile(this.filepath,time+"|"+JSON.stringify(data)+"\n","utf8")})}reset(){fs.rmSync(this.filepath)}readFile(){const data=fs.readFileSync(this.filepath,"utf8"),lines=data.split("\n"),result=[];for(const line of lines){const i=line.indexOf("|");if(-1===i)continue;const time=parseInt(line.substring(0,i)),data=JSON.parse(line.substring(i+1));result.push([time,data])}return result.sort((a,b)=>b[0]-a[0])}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_1,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_1_1,_d=!0,rl_1=__asyncValues(rl);rl_1_1=yield __await(rl_1.next()),_a=rl_1_1.done,!_a;_d=!0){_c=rl_1_1.value,_d=!1;const line=_c,i=line.indexOf("|"),time=parseInt(line.substring(0,i));yield yield __await(time)}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=rl_1.return)||(yield __await(_b.call(rl_1)))}finally{if(e_1)throw e_1.error}}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_2,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_2_1,_d=!0,rl_2=__asyncValues(rl);rl_2_1=yield __await(rl_2.next()),_a=rl_2_1.done,!_a;_d=!0){_c=rl_2_1.value,_d=!1;const line=_c,i=line.indexOf("|"),data=JSON.parse(line.substring(i+1));yield yield __await(data)}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=rl_2.return)||(yield __await(_b.call(rl_2)))}finally{if(e_2)throw e_2.error}}})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_3,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_3_1,_d=!0,rl_3=__asyncValues(rl);rl_3_1=yield __await(rl_3.next()),_a=rl_3_1.done,!_a;_d=!0){_c=rl_3_1.value,_d=!1;const line=_c,i=line.indexOf("|"),time=parseInt(line.substring(0,i)),data=JSON.parse(line.substring(i+1));yield yield __await([time,data])}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=rl_3.return)||(yield __await(_b.call(rl_3)))}finally{if(e_3)throw e_3.error}}})}ensureDirectoryExists(){fs.mkdirSync(path.dirname(this.filepath),{recursive:!0})}}class AppData{constructor(appAuthor,appName,configName){this.directory=path.join(getAppDataPath(),appAuthor,appName,configName),this.app=new JsonFile(path.join(this.directory,"appdata.json"),!1),this.user=new JsonFile(path.join(this.directory,"config.json"),!0),this.history=new LogFile(path.join(this.directory,"history.log")),this.app.on("set",(time,k,v)=>__awaiter(this,void 0,void 0,function*(){yield this.history.append({source:"app",key:k,value:v},time)})),this.user.on("set",(time,k,v)=>__awaiter(this,void 0,void 0,function*(){yield this.history.append({source:"user",key:k,value:v},time)}))}}function createDirectory(dirpath){return __awaiter(this,void 0,void 0,function*(){return yield fs.promises.mkdir(dirpath,{recursive:!0}),dirpath})}function appendLineToFile(filepath,line,linebreakBefore=!1){return __awaiter(this,void 0,void 0,function*(){fs.existsSync(filepath)||(yield createDirectory(path.dirname(filepath)),yield fs.promises.writeFile(filepath,"")),yield fs.promises.appendFile(filepath,linebreakBefore?"\n"+line:line+"\n")})}function cleanDirectorySync(dirpath,predicate){for(const filename of fs.readdirSync(dirpath)){const filepath=path.join(dirpath,filename),stat=fs.statSync(filepath);predicate(filepath,stat)&&fs.unlinkSync(filepath)}}function createDirectorySync(dirpath){return fs.mkdirSync(dirpath,{recursive:!0}),dirpath}function normalizeFileExtension(ext){if(""===ext||"."===ext)return"";if(/[<>"|?*:]/g.test(ext))throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>"|?:*`);return ext.includes(".")?ext.substring(ext.lastIndexOf(".")):"."+ext}function createFileExtensionFilter(...fileExtensions){return fileExtensions.length?filepath=>{for(const ext of fileExtensions.map(normalizeFileExtension))if(path.extname(filepath)===ext)return!0;return!1}:()=>!0}function cwdpath(...paths){return path.join(process.cwd(),...paths)}function deleteDirectory(dirpath){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.rm(dirpath,{recursive:!0,force:!0})})}function deleteDirectorySafe(dirpath){return __awaiter(this,void 0,void 0,function*(){fs.existsSync(dirpath)&&(yield fs.promises.rm(dirpath,{recursive:!0,force:!0}))})}function deleteDirectorySafeSync(dirpath){return fs.existsSync(dirpath)?(fs.rmSync(dirpath,{recursive:!0,force:!0}),dirpath):dirpath}function deleteDirectorySync(dirpath){return fs.rmSync(dirpath,{recursive:!0,force:!0}),dirpath}function ensureValidWindowsPath(path,options){const throwOrFalse=msg=>{if(options&&!0===options.assert)throw new Error(`Invalid windows path. ${msg} | input received: ${path}`);return!1};if(0===path.length)return throwOrFalse("Path string is length 0.");if(-1!==path.indexOf("/")&&-1!==path.indexOf("\\"))return throwOrFalse("Path contains both backslash and forward slash.");const maxLength=(options&&options.extendedMaxLength?32767:260)-12;if(path.length>maxLength)return throwOrFalse(`Maximum length of ${maxLength} exceeded`);let noDriveLetter=path;return /^\w:(\\|\/)/g.test(path)&&(noDriveLetter=path.substring(2)),/[<>"|?*:]/g.test(noDriveLetter)?throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>"|?:*`):!/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)||throwOrFalse("Illegal name in path string")}function isWindows(){return process.platform.includes("win")}function getDiskDrivesWindows(){if(!isWindows())throw new Error("This function is only available on Windows.");return child_process.execSync("wmic logicaldisk get name").toString().split("\n").map(s=>s.trim()).filter(s=>/^[a-z]:/i.test(s)).map(s=>s.substring(0,2)+path.sep)}function getHomeDirectory(){const home=path.resolve(process.env.HOME||process.env.USERPROFILE||"");if(!home)throw new Error("Home directory not found");return home}function getDownloadsDirectory(){return path.join(getHomeDirectory(),"Downloads")}function getLastMofifiedFileIn(dirpath){return __awaiter(this,void 0,void 0,function*(){const children=yield fs.promises.readdir(dirpath),filtered=children.map(fname=>{const fpath=path.join(dirpath,fname),stat=fs.statSync(fpath);return[fpath,stat.mtimeMs,stat.isFile()]}).filter(a=>a[2]),sorted=filtered.sort((a,b)=>b[1]-a[1]);return sorted[0][0]})}function getRootDir(){return path.parse(process.cwd()).root}function readFileLastLines(filepath,n,encoding="utf8"){return __awaiter(this,void 0,void 0,function*(){return yield readLastLines.read(filepath,n,encoding)})}function readJsonFile(filepath){return __awaiter(this,void 0,void 0,function*(){return JSON.parse(yield fs.promises.readFile(filepath,"utf8"))})}function readPackageJson(projectRoot=process.cwd()){const filepath=path.join(projectRoot,"package.json");return fs.existsSync(filepath)?readJsonFileSync(filepath):void 0}function removeIllegalFilenameCharacters(string){return string.replace(/[/\\?%*:|"<>]/g,"")}function tempFile(fileExtension,callback){const dir=path.join(process.env.TEMP,"bemoje","temp"),fpath=path.join(dir,Date.now()+fileExtension);fs.mkdirSync(dir,{recursive:!0});const prom=callback(fpath);if(prom instanceof Promise){const rm=()=>fs.rmSync(fpath);prom.then(rm).catch(rm)}else fs.rmSync(fpath)}function unzipFile(filepath,outdir){return __awaiter(this,void 0,void 0,function*(){yield extract(filepath,{dir:outdir})})}function unzipMergeFiles(source,target){return __awaiter(this,void 0,void 0,function*(){"string"==typeof source&&(source=fs.readdirSync(source).map(filename=>path.join(source,filename)));for(const filepath of source){const stat=yield fs.promises.stat(filepath);stat.isDirectory()||filepath.endsWith(".zip")&&(yield extract(filepath,{dir:target}))}})}function wipeDirectorySafe(dirpath){return __awaiter(this,void 0,void 0,function*(){yield deleteDirectorySafe(dirpath),yield createDirectory(dirpath)})}function writeJsonFile(filepath,data,pretty=!1){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.writeFile(filepath,JSON.stringify(data,null,pretty?2:void 0))})}exports.AppData=AppData,exports.JsonFile=JsonFile,exports.LogFile=LogFile,exports.absoluteToRelativePath=absoluteToRelativePath,exports.appendLineToFile=appendLineToFile,exports.cleanDirectorySync=cleanDirectorySync,exports.createDirectory=createDirectory,exports.createDirectorySync=createDirectorySync,exports.createFileExtensionFilter=createFileExtensionFilter,exports.cwdpath=cwdpath,exports.deleteDirectory=deleteDirectory,exports.deleteDirectorySafe=deleteDirectorySafe,exports.deleteDirectorySafeSync=deleteDirectorySafeSync,exports.deleteDirectorySync=deleteDirectorySync,exports.ensureValidWindowsPath=ensureValidWindowsPath,exports.getDiskDrivesWindows=getDiskDrivesWindows,exports.getDownloadsDirectory=getDownloadsDirectory,exports.getHomeDirectory=getHomeDirectory,exports.getLastMofifiedFileIn=getLastMofifiedFileIn,exports.getRootDir=getRootDir,exports.isWindows=isWindows,exports.normalizeFileExtension=normalizeFileExtension,exports.readFileLastLines=readFileLastLines,exports.readJsonFile=readJsonFile,exports.readJsonFileSync=readJsonFileSync,exports.readPackageJson=readPackageJson,exports.removeIllegalFilenameCharacters=removeIllegalFilenameCharacters,exports.tempFile=tempFile,exports.unzipFile=unzipFile,exports.unzipMergeFiles=unzipMergeFiles,exports.wipeDirectorySafe=wipeDirectorySafe,exports.writeJsonFile=writeJsonFile,exports.writeJsonFileSync=writeJsonFileSync;
6
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/lib/absoluteToRelativePath.ts","../src/lib/readJsonFileSync.ts","../src/lib/writeJsonFileSync.ts","../src/lib/JsonFile.ts","../src/lib/LogFile.ts","../src/lib/AppData.ts","../src/lib/createDirectory.ts","../src/lib/appendLineToFile.ts","../src/lib/cleanDirectorySync.ts","../src/lib/createDirectorySync.ts","../src/lib/normalizeFileExtension.ts","../src/lib/createFileExtensionFilter.ts","../src/lib/cwdpath.ts","../src/lib/deleteDirectory.ts","../src/lib/deleteDirectorySafe.ts","../src/lib/deleteDirectorySafeSync.ts","../src/lib/deleteDirectorySync.ts","../src/lib/ensureValidWindowsPath.ts","../src/lib/isWindows.ts","../src/lib/getDiskDrivesWindows.ts","../src/lib/getHomeDirectory.ts","../src/lib/getDownloadsDirectory.ts","../src/lib/getLastMofifiedFileIn.ts","../src/lib/getRootDir.ts","../src/lib/readFileLastLines.ts","../src/lib/readJsonFile.ts","../src/lib/readPackageJson.ts","../src/lib/removeIllegalFilenameCharacters.ts","../src/lib/tempFile.ts","../src/lib/unzipFile.ts","../src/lib/unzipMergeFiles.ts","../src/lib/wipeDirectorySafe.ts","../src/lib/writeJsonFile.ts"],"sourcesContent":["import { regexEscapeString } from '@bemoje/string'\r\nimport path from 'path'\r\n\r\n/**\r\n * If the filepath is somewhere in the current working directory, it can be converted into a relative path.\r\n * @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,\r\n * replaces all backslashes with forward slashes, and removes any leading forward slashes.\r\n * @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.\r\n * @returns The relative path.\r\n * @param absolute the absolute filepath to convert.\r\n * @example ```ts\r\n * absoluteToRelativePath(__filename)\r\n * //=> 'src/absoluteToRelativePath.ts'\r\n * ```\r\n */\r\nexport function absoluteToRelativePath(absolute: string, workingDirectory = process.cwd()): string {\r\n return path\r\n .normalize(absolute)\r\n .replace(new RegExp(regexEscapeString(path.normalize(workingDirectory) + path.sep), 'i'), '')\r\n}\r\n","import fs from 'fs'\r\n\r\n/**\r\n * Reads a JSON file synchronously and returns a Promise that resolves with the parsed JSON data.\r\n * @template T The expected return type of the JSON data.\r\n * @param filepath The path to the JSON file to read.\r\n * @returns A Promise that resolves with the parsed JSON data.\r\n * @throws If the file cannot be read or the content cannot be parsed as JSON.\r\n * @example ```ts\r\n * const data = await readJsonFileSync<MyType>('/path/to/file.json');\r\n * console.log(data);\r\n * ```\r\n */\r\nexport function readJsonFileSync<T>(filepath: string): T {\r\n return JSON.parse(fs.readFileSync(filepath, 'utf8'))\r\n}\r\n","import fs from 'fs'\n\n/**\n * Writes a JSON object to a file synchronously.\n * @typeParam T - The type of the JSON object.\n * @param filepath - The path of the file where the JSON object will be written.\n * @param data - The JSON object that will be written to the file.\n * @param pretty - If true, the JSON object will be formatted with indentation and line breaks. Default is false.\n * @throws If the file cannot be written.\n * @example ```ts\n * const data = { name: 'John', age: 30 };\n * writeJsonFileSync('./data.json', data, true);\n * ```\n */\nexport function writeJsonFileSync<T>(filepath: string, data: T, pretty = false): void {\n fs.writeFileSync(filepath, JSON.stringify(data, null, pretty ? 2 : undefined))\n}\n","import EventEmitter from 'events'\nimport fs from 'fs'\nimport path from 'path'\nimport { readJsonFileSync } from './readJsonFileSync'\nimport { writeJsonFileSync } from './writeJsonFileSync'\n\n/**\n * Represents a JSON file manager that ensures immutable data since everything is serialized and deserialized before receiving or returning any data.\n */\nexport class JsonFile<T extends Record<string, any>> extends EventEmitter {\n /**\n * The filepath of the JSON file.\n */\n readonly filepath: string\n\n /**\n * The data stored in the JSON file.\n */\n #data: T\n\n /**\n * Determines whether the JSON file should be pretty-printed.\n */\n prettyPrint: boolean\n\n /**\n * Gets the data stored in the JSON file.\n * @returns A deep copy of the data.\n */\n get data(): T {\n return JSON.parse(JSON.stringify(this.#data))\n }\n\n /**\n * Constructs a new instance of the JsonFile class.\n * @param filepath - The filepath of the JSON file.\n * @param prettyPrint - Determines whether the JSON file should be pretty-printed.\n */\n constructor(filepath: string, prettyPrint = false) {\n super()\n this.filepath = filepath\n this.#data = {} as T\n this.prettyPrint = prettyPrint\n this.ensureDirectoryExists()\n if (fs.existsSync(this.filepath)) {\n this.loadFile()\n } else {\n writeJsonFileSync(this.filepath, this.#data, this.prettyPrint)\n }\n }\n\n /**\n * Gets the value associated with the specified key.\n * @param key - The key to retrieve the value for.\n * @returns The value associated with the key.\n */\n get(key: keyof T): any {\n return JSON.parse(JSON.stringify(this.#data[key]))\n }\n\n /**\n * Sets the value associated with the specified key.\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n set(key: keyof T, value: any): void {\n if (this.#data[key] === value) return\n const json = JSON.stringify(value)\n if (json === JSON.stringify(this.#data[key])) return\n value = JSON.parse(json)\n this.#data[key] = value\n this.saveFile()\n this.emit('set', Date.now(), key, value)\n }\n\n /**\n * Checks if the specified key exists in the JSON file.\n * @param key - The key to check.\n * @returns True if the key exists, false otherwise.\n */\n has(key: keyof T): boolean {\n return this.#data[key] !== undefined\n }\n\n /**\n * Deletes the value associated with the specified key.\n * @param key - The key to delete.\n */\n delete(key: keyof T): void {\n delete this.#data[key]\n this.saveFile()\n this.emit('set', Date.now(), key, void 0)\n }\n\n /**\n * Gets the value associated with the specified key, or sets it to the provided default value if it doesn't exist.\n * @param key - The key to get or set.\n * @param getValue - A function that returns the default value if the key doesn't exist.\n * @returns The value associated with the key, or the default value if it doesn't exist.\n */\n getOrElse(key: string, getValue: () => any): any {\n if (this.has(key)) {\n return JSON.parse(JSON.stringify(this.get(key)))\n }\n const value = JSON.parse(JSON.stringify(getValue()))\n this.set(key, value)\n return value\n }\n\n /**\n * Clears all the data in the JSON file.\n */\n clear(): void {\n const time = Date.now()\n for (const key of Object.keys(this.#data)) {\n this.emit('set', time, key, void 0)\n }\n this.#data = {} as T\n fs.writeFileSync(this.filepath, '{}', 'utf8')\n }\n\n /**\n * Assigns new data to the JSON file.\n * @param data - The data to assign.\n */\n assign(data: T): void {\n data = JSON.parse(JSON.stringify(data))\n const time = Date.now()\n for (const [key, value] of Object.entries(data)) {\n if (this.#data[key] && JSON.stringify(this.#data[key]) !== JSON.stringify(value)) {\n this.emit('set', time, key, value)\n }\n }\n Object.assign(this.#data, data)\n this.saveFile()\n }\n\n /**\n * Ensures that the directory containing the JSON file exists.\n */\n ensureDirectoryExists(): void {\n fs.mkdirSync(path.dirname(this.filepath), { recursive: true })\n }\n\n /**\n * Saves the data to the JSON file.\n */\n saveFile(): void {\n writeJsonFileSync(this.filepath, this.#data, this.prettyPrint)\n }\n\n /**\n * Loads the data from the JSON file.\n */\n loadFile(): void {\n this.#data = readJsonFileSync(this.filepath) as T\n }\n}\n","import fs from 'fs'\nimport path from 'path'\nimport readline from 'readline'\n\n/**\n * Represents a log file manager that appends log entries to a file.\n * It does not ensure extremely precise ordering of log entries' timestamps if used asynchronously. It logs them as they are received.\n */\nexport class LogFile<T> {\n /**\n * The path to the log file.\n */\n filepath: string\n\n /**\n * Creates a new instance of the LogFile class.\n * @param filepath - The path to the log file.\n */\n constructor(filepath: string) {\n this.filepath = filepath\n this.ensureDirectoryExists()\n }\n\n /**\n * Appends a log entry to the log file.\n * @param data - The data to be logged.\n * @param time - The timestamp of the log entry. Defaults to the current time.\n * @returns A promise that resolves when the log entry is appended.\n */\n async append(data: T, time = Date.now()): Promise<void> {\n await fs.promises.appendFile(this.filepath, time + '|' + JSON.stringify(data) + '\\n', 'utf8')\n }\n\n /**\n * Resets the log file by removing it.\n */\n reset(): void {\n fs.rmSync(this.filepath)\n }\n\n /**\n * Reads the log entire file and returns an array of log entries, sorted by timestamp in descending order.\n * @returns An array of log entries, sorted by timestamp in descending order.\n */\n readFile(): [number, T][] {\n const data = fs.readFileSync(this.filepath, 'utf8')\n const lines = data.split('\\n')\n const result = [] as [number, T][]\n for (const line of lines) {\n const i = line.indexOf('|')\n if (i === -1) continue\n const time = parseInt(line.substring(0, i))\n const data = JSON.parse(line.substring(i + 1)) as T\n result.push([time, data])\n }\n return result.sort((a, b) => b[0] - a[0])\n }\n\n /**\n * Returns an async generator that yields the timestamps of log entries in the log file.\n * @yields The timestamps of log entries.\n */\n async *keys(): AsyncGenerator<number> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const time = parseInt(line.substring(0, i))\n yield time\n }\n }\n\n /**\n * Returns an async generator that yields the values of log entries in the log file.\n * @yields The values of log entries.\n */\n async *values(): AsyncGenerator<T> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const data = JSON.parse(line.substring(i + 1)) as T\n yield data\n }\n }\n\n /**\n * Returns an async generator that yields the entries (timestamp and value) of log entries in the log file.\n * @yields The entries (timestamp and value) of log entries.\n */\n async *entries(): AsyncGenerator<[number, T]> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const time = parseInt(line.substring(0, i))\n const data = JSON.parse(line.substring(i + 1)) as T\n yield [time, data]\n }\n }\n\n /**\n * Ensures that the directory containing the log file exists.\n */\n ensureDirectoryExists(): void {\n fs.mkdirSync(path.dirname(this.filepath), { recursive: true })\n }\n}\n","import getAppDataPath from 'appdata-path'\nimport path from 'path'\nimport { JsonFile } from './JsonFile'\nimport { LogFile } from './LogFile'\nimport { ILogFileData } from './types/ILogFileData'\n\nexport class AppData<A extends Record<string, unknown>, C extends Record<string, unknown>> {\n directory: string\n app: JsonFile<A>\n user: JsonFile<C>\n history: LogFile<ILogFileData<C>>\n\n constructor(appAuthor: string, appName: string, configName: string) {\n this.directory = path.join(getAppDataPath(), appAuthor, appName, configName)\n this.app = new JsonFile(path.join(this.directory, 'appdata.json'), false)\n this.user = new JsonFile(path.join(this.directory, 'config.json'), true)\n this.history = new LogFile(path.join(this.directory, 'history.log'))\n this.app.on('set', async (time, k: string, v: C) => {\n await this.history.append({ source: 'app', key: k, value: v }, time)\n })\n this.user.on('set', async (time, k: string, v: C) => {\n await this.history.append({ source: 'user', key: k, value: v }, time)\n })\n }\n}\n","import fs from 'fs'\n/**\n * Create a directory at a given path if it does not exist.\n * Automatically creates parent directories if they do not exist.\n * @param dirpath The path where the directory should be created.\n * @returns The path of the directory.\n * @throws Will throw an error if the directory cannot be created.\n * @example ```ts\n * createDirectory('/path/to/directory').then((dirpath) => {\n * //=> `Directory created at ${dirpath}`\n * });\n * ```\n */\nexport async function createDirectory(dirpath: string): Promise<string> {\n await fs.promises.mkdir(dirpath, { recursive: true })\n return dirpath\n}\n","import fs from 'fs'\r\nimport path from 'path'\r\nimport { createDirectory } from './createDirectory'\r\n\r\n/**\r\n * Append a line to a file. Creates the file if it does not exist.\r\n * @param filepath The path of the file.\r\n * @param line The string data to append.\r\n * @returns A Promise that resolves when the line has been appended to the file.\r\n * @throws Will throw an error if the operation fails.\r\n * @example ```ts\r\n * await appendLineToFile('/path/to/file', 'This is a new line')\r\n * ```\r\n */\r\nexport async function appendLineToFile(filepath: string, line: string, linebreakBefore = false): Promise<void> {\r\n if (!fs.existsSync(filepath)) {\r\n await createDirectory(path.dirname(filepath))\r\n await fs.promises.writeFile(filepath, '')\r\n }\r\n await fs.promises.appendFile(filepath, linebreakBefore ? '\\n' + line : line + '\\n')\r\n}\r\n","import type { Stats } from 'fs'\r\nimport fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * Synchronously cleans a directory by removing files that satisfy a given predicate.\r\n * @remarks This function is a part of the File System module.\r\n * @param dirpath - The path to the directory that needs to be cleaned.\r\n * @param predicate - A function that takes a filepath and its stats as arguments and returns a boolean. If the function returns true for a file, that file is removed from the directory.\r\n * @throws If the directory at the provided path does not exist or cannot be read.\r\n * @example ```ts\r\n * import { Stats } from 'fs';\r\n * const dirpath = './my-directory';\r\n * const predicate = (filepath: string, stat: Stats) => stat.size > 1024;\r\n * cleanDirectorySync(dirpath, predicate);\r\n * ```\r\n */\r\nexport function cleanDirectorySync(dirpath: string, predicate: (filepath: string, stat: Stats) => boolean): void {\r\n for (const filename of fs.readdirSync(dirpath)) {\r\n const filepath = path.join(dirpath, filename)\r\n const stat = fs.statSync(filepath)\r\n if (predicate(filepath, stat)) fs.unlinkSync(filepath)\r\n }\r\n}\r\n","import fs from 'fs'\n\n/**\n * Create a directory at a given path if it does not exist.\n * Automatically creates parent directories if they do not exist.\n * @param dirpath The path where the directory should be created.\n * @returns The path of the directory.\n * @example ```ts\n * createDirectorySync('/path/to/directory')\n * ```\n */\nexport function createDirectorySync(dirpath: string): string {\n fs.mkdirSync(dirpath, { recursive: true })\n return dirpath\n}\n","/**\r\n * Normalize a file extension to the form: .[ext]\r\n * Anything before the last \".\" is not returned.\r\n * @returns The normalized file extension.\r\n * @throws If the extension contains illegal characters.\r\n * @param ext file extension\r\n * @example ```ts\r\n * normalizeFileExtension('jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('.jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('..jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('');;\r\n * //=> ''\r\n * normalizeFileExtension('.');;\r\n * //=> ''\r\n * normalizeFileExtension('jpg|png');;\r\n * //=> Error\r\n * ```\r\n */\r\nexport function normalizeFileExtension(ext: string): string {\r\n if (ext === '' || ext === '.') return ''\r\n if (/[<>\"|?*:]/g.test(ext)) {\r\n throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>\"|?:*`)\r\n }\r\n if (!ext.includes('.')) return '.' + ext\r\n return ext.substring(ext.lastIndexOf('.'))\r\n}\r\n","import path from 'path'\nimport { normalizeFileExtension } from './normalizeFileExtension'\n\n/**\n * Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.\n * @remarks If no file extensions are provided, the filter will always return true.\n * @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.\n * @param fileExtensions file extensions\n * @example ```ts\n * createFileExtensionFilter('.ts', '.tsx')('index.ts');;\n * //=> true\n * createFileExtensionFilter('.ts', '.tsx')('index.js');;\n * //=> false\n * ```\n */\nexport function createFileExtensionFilter(...fileExtensions: string[]): (filepath: string) => boolean {\n if (!fileExtensions.length) return () => true\n return (filepath: string) => {\n for (const ext of fileExtensions.map(normalizeFileExtension)) {\n if (path.extname(filepath) === ext) {\n return true\n }\n }\n return false\n }\n}\n","import path from 'path'\r\n\r\n/**\r\n * Joins the given path segments to the current working directory path, and normalizes the resulting path.\r\n * @remarks\r\n * The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.\r\n * @param paths - The path segments to join to the current working directory path.\r\n * @returns The resulting path.\r\n * @example ```ts\r\n * console.log(cwdpath('src', 'index.ts'));\r\n * //=> '{working_directory}/src/index.ts'\r\n * ```\r\n */\r\nexport function cwdpath(...paths: string[]): string {\r\n return path.join(process.cwd(), ...paths)\r\n}\r\n","import fs from 'fs'\n\n/**\n * Deletes a directory and all of its contents.\n * @remarks This function uses Node.js's `fs.promises.rm` method with the `recursive` and `force` options set to `true`.\n * This means it will delete the directory and all of its contents, even if the directory is not empty.\n * @param dirpath The path to the directory to delete.\n * @returns A Promise that resolves when the directory has been deleted.\n * @throws Will throw an error if the directory does not exist, or if there was a problem deleting the directory.\n * @example ```ts\n * deleteDirectory('/path/to/directory');\n * ```\n */\nexport async function deleteDirectory(dirpath: string): Promise<void> {\n await fs.promises.rm(dirpath, { recursive: true, force: true })\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory safely if it exists.\n * @remarks This function uses Node.js' `fs.promises.rm` method with the `recursive` and `force` options set to `true`.\n * This means it will delete the directory and all its contents, even if the directory is not empty.\n * @param dirpath The path of the directory to delete.\n * @returns A promise that resolves to `void` when the directory has been deleted.\n * @throws Will throw an error if the `fs.promises.rm` operation fails.\n * @example ```ts\n * deleteDirectorySafe('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport async function deleteDirectorySafe(dirpath: string): Promise<void> {\n if (fs.existsSync(dirpath)) await fs.promises.rm(dirpath, { recursive: true, force: true })\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory synchronously in a safe manner. If the directory does not exist, it will simply return the directory path without throwing an error.\n * @param dirpath The path of the directory to be deleted.\n * @returns The path of the directory that was intended to be deleted.\n * @throws Will throw an error if the operation fails for reasons other than the directory not existing.\n * @example ```ts\n * deleteDirectorySafeSync('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport function deleteDirectorySafeSync(dirpath: string): string {\n if (!fs.existsSync(dirpath)) return dirpath\n fs.rmSync(dirpath, { recursive: true, force: true })\n return dirpath\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory synchronously.\n * @remarks This function uses Node.js's `fs.rmSync` method with the options `{ recursive: true, force: true }`.\n * @param dirpath The path of the directory to delete.\n * @returns The path of the deleted directory.\n * @throws Will throw an error if the directory does not exist or if the process lacks permissions to delete it.\n * @example ```ts\n * deleteDirectorySync('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport function deleteDirectorySync(dirpath: string): string {\n fs.rmSync(dirpath, { recursive: true, force: true })\n return dirpath\n}\n","import { IEnsureValidWindowsPathOptions } from './types/IEnsureValidWindowsPathOptions'\r\n\r\n/**\r\n * Check whether a provided windows filesystem path string is valid according to:\r\n * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx\r\n * @param path The path to validate.\r\n * @returns A boolean indicating whether the path is valid. If the `assert` option is true, the function will throw an error instead of returning false.\r\n * @throws Will throw an error if the `assert` option is true and the path is invalid.\r\n * @param options An optional object that may contain the following properties:\r\n * - `assert`: If true, the function will throw an error if the path is invalid. Default is false.\r\n * - `extendedMaxLength`: If true, the function will allow paths up to 32767 characters long. Default is false.\r\n * @example ```ts\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt');;\r\n * //=> true\r\n * ensureValidWindowsPath('C:/Users/User/Documents/file.txt');;\r\n * //=> false\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt', { assert: true });;\r\n * //=> throws an error\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt', { extendedMaxLength: true });;\r\n * //=> true\r\n * ```\r\n */\r\nexport function ensureValidWindowsPath(path: string, options?: IEnsureValidWindowsPathOptions): boolean {\r\n const throwOrFalse = (msg: string) => {\r\n if (options && options.assert === true) {\r\n throw new Error(`Invalid windows path. ${msg} | input received: ${path}`)\r\n }\r\n return false\r\n }\r\n\r\n if (path.length === 0) {\r\n return throwOrFalse('Path string is length 0.')\r\n }\r\n\r\n if (path.indexOf('/') !== -1 && path.indexOf('\\\\') !== -1) {\r\n return throwOrFalse('Path contains both backslash and forward slash.')\r\n }\r\n\r\n const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12\r\n if (path.length > maxLength) {\r\n return throwOrFalse(`Maximum length of ${maxLength} exceeded`)\r\n }\r\n\r\n let noDriveLetter = path\r\n if (/^\\w:(\\\\|\\/)/g.test(path)) {\r\n noDriveLetter = path.substring(2)\r\n }\r\n if (/[<>\"|?*:]/g.test(noDriveLetter)) {\r\n return throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>\"|?:*`)\r\n }\r\n\r\n if (/(\\\\|\\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\\\|\\/)|$)/g.test(path)) {\r\n return throwOrFalse('Illegal name in path string')\r\n }\r\n\r\n return true\r\n}\r\n","export function isWindows() {\r\n return process.platform.includes('win')\r\n}\r\n","import { execSync } from 'child_process'\r\nimport path from 'path'\r\nimport { isWindows } from './isWindows'\r\n\r\nexport function getDiskDrivesWindows(): string[] {\r\n if (!isWindows()) throw new Error('This function is only available on Windows.')\r\n return execSync('wmic logicaldisk get name')\r\n .toString()\r\n .split('\\n')\r\n .map((s) => s.trim())\r\n .filter((s) => /^[a-z]:/i.test(s))\r\n .map((s) => s.substring(0, 2) + path.sep)\r\n}\r\n","import path from 'path'\r\n\r\nexport function getHomeDirectory(): string {\r\n const home = path.resolve(process.env['HOME'] || process.env['USERPROFILE'] || '')\r\n if (!home) throw new Error('Home directory not found')\r\n return home\r\n}\r\n","import path from 'path'\r\nimport { getHomeDirectory } from './getHomeDirectory'\r\n\r\nexport function getDownloadsDirectory() {\r\n return path.join(getHomeDirectory(), 'Downloads')\r\n}\r\n","import fs from 'fs'\r\nimport path from 'path'\r\n\r\nexport async function getLastMofifiedFileIn(dirpath: string): Promise<string> {\r\n const children = await fs.promises.readdir(dirpath)\r\n const filtered = children\r\n .map((fname: string) => {\r\n const fpath = path.join(dirpath, fname)\r\n const stat = fs.statSync(fpath)\r\n return [fpath, stat.mtimeMs, stat.isFile()]\r\n })\r\n .filter((a) => a[2]) as [string, number, boolean][]\r\n const sorted = filtered.sort((a, b) => b[1] - a[1])\r\n return sorted[0][0]\r\n}\r\n","import path from 'path'\r\n\r\nexport function getRootDir() {\r\n return path.parse(process.cwd()).root\r\n}\r\n","import readLastLines from 'read-last-lines'\n\n/**\n * Read the last n lines of a file.\n * @param filepath The path to the file.\n * @param n The number of lines to read.\n * @param encoding The encoding of the file.\n * @example await readLastLines.read('path/to/file.log', 50)\n */\nexport async function readFileLastLines(filepath: string, n: number, encoding: NodeJS.BufferEncoding = 'utf8') {\n return await readLastLines.read(filepath, n, encoding)\n}\n","import fs from 'fs'\r\n\r\n/**\r\n * Reads a JSON file from the given filepath and returns its content as a Promise.\r\n * The Promise will resolve with the parsed JSON content as an object of type T.\r\n * @template T The expected return type of the JSON object.\r\n * @param filepath The path to the JSON file to read.\r\n * @returns A Promise that resolves with the parsed JSON content as an object of type T.\r\n * @throws Will throw an error if reading the file fails for any reason.\r\n * @example ```ts\r\n * const data: MyType = await readJsonFile<MyType>('path/to/myfile.json');\r\n * ```\r\n */\r\nexport async function readJsonFile<T>(filepath: string): Promise<T> {\r\n return JSON.parse(await fs.promises.readFile(filepath, 'utf8'))\r\n}\r\n","import fs from 'fs'\r\nimport path from 'path'\r\nimport { readJsonFileSync } from './readJsonFileSync'\r\n\r\nexport function readPackageJson(projectRoot = process.cwd()): Record<string, any> | undefined {\r\n const filepath = path.join(projectRoot, 'package.json')\r\n if (!fs.existsSync(filepath)) return\r\n return readJsonFileSync(filepath)\r\n}\r\n","export function removeIllegalFilenameCharacters(string: string) {\r\n return string.replace(/[/\\\\?%*:|\"<>]/g, '')\r\n}\r\n","import fs from 'fs'\nimport path from 'path'\n\n/**\n * Creates a temporary file and deletes it after the callback has finished.\n * @param fileExtension - The file extension to use for the temporary file.\n * @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.\n */\nexport function tempFile(fileExtension: string, callback: (fpath: string) => void | Promise<void>): void {\n const dir = path.join(process.env['TEMP']!, 'bemoje', 'temp')\n const fpath = path.join(dir, Date.now() + fileExtension)\n fs.mkdirSync(dir, { recursive: true })\n const prom = callback(fpath)\n if (prom instanceof Promise) {\n const rm = () => fs.rmSync(fpath)\n prom.then(rm).catch(rm)\n } else {\n fs.rmSync(fpath)\n }\n}\n","import extract from 'extract-zip'\r\n\r\nexport async function unzipFile(filepath: string, outdir: string) {\r\n await extract(filepath, { dir: outdir })\r\n}\r\n","import extract from 'extract-zip'\r\nimport fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @param source Either a directory containing zip files or an array of zip file paths.\r\n */\r\nexport async function unzipMergeFiles(source: string | string[], target: string) {\r\n if (typeof source === 'string') {\r\n source = fs.readdirSync(source).map((filename) => {\r\n return path.join(source as string, filename)\r\n })\r\n }\r\n for (const filepath of source) {\r\n const stat = await fs.promises.stat(filepath)\r\n if (stat.isDirectory()) continue\r\n if (!filepath.endsWith('.zip')) continue\r\n await extract(filepath, { dir: target })\r\n }\r\n}\r\n","import { createDirectory } from './createDirectory'\r\nimport { deleteDirectorySafe } from './deleteDirectorySafe'\r\n\r\nexport async function wipeDirectorySafe(dirpath: string) {\r\n await deleteDirectorySafe(dirpath)\r\n await createDirectory(dirpath)\r\n}\r\n","import fs from 'fs'\n\n/**\n * Writes a JSON file to the specified filepath. The data to be written is passed as an argument.\n * If the 'pretty' argument is set to true, the JSON data will be formatted in a more human-readable way.\n * @template T - The type of the data to be written to the file.\n * @param filepath - The path to the file where the data should be written.\n * @param data - The data to be written to the file.\n * @param pretty - Optional. If set to true, formats the JSON data in a more human-readable way. Default is false.\n * @returns A Promise that resolves when the file has been successfully written.\n * @example ```ts\n * const data = { name: 'John', age: 30 };\n * await writeJsonFile('./data.json', data, true);\n * ```\n */\nexport async function writeJsonFile<T>(filepath: string, data: T, pretty = false): Promise<void> {\n await fs.promises.writeFile(filepath, JSON.stringify(data, null, pretty ? 2 : undefined))\n}\n"],"names":["absoluteToRelativePath","absolute","workingDirectory","process","cwd","path","normalize","replace","RegExp","regexEscapeString","sep","readJsonFileSync","filepath","JSON","parse","fs","readFileSync","writeJsonFileSync","data","pretty","writeFileSync","stringify","JsonFile","EventEmitter","__classPrivateFieldGet","_JsonFile_data","constructor","prettyPrint","set","__classPrivateFieldSet","ensureDirectoryExists","existsSync","loadFile","get","key","value","json","saveFile","emit","Date","now","has","delete","getOrElse","getValue","clear","time","Object","keys","assign","entries","mkdirSync","dirname","recursive","LogFile","append","promises","appendFile","reset","rmSync","readFile","lines","split","result","line","i","indexOf","parseInt","substring","push","sort","a","b","fileStream","createReadStream","rl","readline","createInterface","input","crlfDelay","rl_1","__asyncValues","rl_1_1","__await","next","_a","done","_d","_c","values","rl_2","rl_2_1","rl_3","rl_3_1","AppData","appAuthor","appName","configName","directory","join","getAppDataPath","app","user","history","on","k","v","__awaiter","source","createDirectory","dirpath","mkdir","appendLineToFile","linebreakBefore","writeFile","cleanDirectorySync","predicate","filename","readdirSync","stat","statSync","unlinkSync","createDirectorySync","normalizeFileExtension","ext","test","Error","includes","lastIndexOf","createFileExtensionFilter","fileExtensions","length","map","extname","cwdpath","paths","deleteDirectory","rm","force","deleteDirectorySafe","deleteDirectorySafeSync","deleteDirectorySync","ensureValidWindowsPath","options","throwOrFalse","msg","assert","maxLength","extendedMaxLength","noDriveLetter","isWindows","platform","getDiskDrivesWindows","execSync","toString","s","trim","filter","getHomeDirectory","home","resolve","env","HOME","USERPROFILE","getDownloadsDirectory","getLastMofifiedFileIn","children","readdir","filtered","fname","fpath","mtimeMs","isFile","sorted","getRootDir","root","readFileLastLines","n","encoding","readLastLines","read","readJsonFile","readPackageJson","projectRoot","removeIllegalFilenameCharacters","string","tempFile","fileExtension","callback","dir","TEMP","prom","Promise","then","catch","unzipFile","outdir","extract","unzipMergeFiles","target","isDirectory","endsWith","wipeDirectorySafe","writeJsonFile"],"mappings":";;;;6SAeM,QAAU,CAAAA,sBAAsBA,CAACC,QAAgB,CAAEC,gBAAgB,CAAGC,OAAO,CAACC,GAAG,CAAA,CAAE,CAAA,CACvF,MAAO,CAAAC,IAAI,CACRC,SAAS,CAACL,QAAQ,CAAC,CACnBM,OAAO,CAAC,GAAI,CAAAC,MAAM,CAACC,wBAAiB,CAACJ,IAAI,CAACC,SAAS,CAACJ,gBAAgB,CAAC,CAAGG,IAAI,CAACK,GAAG,CAAC,CAAE,GAAG,CAAC,CAAE,EAAE,CAChG,ksGCNM,QAAU,CAAAC,gBAAgBA,CAAIC,QAAgB,CAAA,CAClD,MAAO,CA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QAAQ,CAC5C,CAAC,EAEJ,IAAK,KAAM,CAAAzG,QAAQ,GAAI,CAAAgG,MAAM,CAAE,CAC7B,KAAM,CAAAW,IAAI,CAAG,KAAM,CAAAxG,EAAE,CAACyC,QAAQ,CAAC+D,IAAI,CAAC3G,QAAQ,CAAC,CACzC2G,IAAI,CAACiF,WAAW,CAAE,CAAA,EACjB5L,QAAQ,CAAC6L,QAAQ,CAAC,MAAM,CAAC,GAC9B,KAAM,CAAAJ,OAAO,CAACzL,QAAQ,CAAE,CAAEiL,GAAG,CAAEU,MAAQ,CAAA,CAAC,CACzC,EACF,CAAA,CChBK,QAAgB,CAAAG,iBAAiBA,CAAC5F,OAAe,CAAA,iDACrD,KAAM,CAAA6B,mBAAmB,CAAC7B,OAAO,CAAC,CAClC,KAAM,CAAAD,eAAe,CAACC,OAAO,EAC9B,CAAA,CCSK,QAAgB,CAAA6F,aAAaA,CAAI/L,QAAgB,CAAEM,IAAO,CAAEC,MAAM,GAAQ,CAAA,iDAC9E,KAAM,CAAAJ,EAAE,CAACyC,QAAQ,CAAC0D,SAAS,CAACtG,QAAQ,CAAEC,IAAI,CAACQ,SAAS,CAACH,IAAI,CAAE,IAAI,CAAEC,MAAM,CAAG,CAAC,OAAY,CAAC,EACzF,CAAA"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @bemoje/fs v0.0.12
3
+ * (c) Benjamin Møller Jensen
4
+ * Released under the MIT License.
5
+ */import{regexEscapeString}from"@bemoje/string";import path from"path";import getAppDataPath from"appdata-path";import EventEmitter from"events";import fs from"fs";import readline from"readline";import{execSync}from"child_process";import readLastLines from"read-last-lines";import extract from"extract-zip";function absoluteToRelativePath(absolute,workingDirectory=process.cwd()){return path.normalize(absolute).replace(new RegExp(regexEscapeString(path.normalize(workingDirectory)+path.sep),"i"),"")}function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}function __classPrivateFieldGet(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)}function __classPrivateFieldSet(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};function readJsonFileSync(filepath){return JSON.parse(fs.readFileSync(filepath,"utf8"))}function writeJsonFileSync(filepath,data,pretty=!1){fs.writeFileSync(filepath,JSON.stringify(data,null,pretty?2:void 0))}var _JsonFile_data;class JsonFile extends EventEmitter{get data(){return JSON.parse(JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")))}constructor(filepath,prettyPrint=!1){super(),_JsonFile_data.set(this,void 0),this.filepath=filepath,__classPrivateFieldSet(this,_JsonFile_data,{},"f"),this.prettyPrint=prettyPrint,this.ensureDirectoryExists(),fs.existsSync(this.filepath)?this.loadFile():writeJsonFileSync(this.filepath,__classPrivateFieldGet(this,_JsonFile_data,"f"),this.prettyPrint)}get(key){return JSON.parse(JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key]))}set(key,value){if(__classPrivateFieldGet(this,_JsonFile_data,"f")[key]!==value){const json=JSON.stringify(value);json===JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key])||(value=JSON.parse(json),__classPrivateFieldGet(this,_JsonFile_data,"f")[key]=value,this.saveFile(),this.emit("set",Date.now(),key,value))}}has(key){return __classPrivateFieldGet(this,_JsonFile_data,"f")[key]!==void 0}delete(key){delete __classPrivateFieldGet(this,_JsonFile_data,"f")[key],this.saveFile(),this.emit("set",Date.now(),key,void 0)}getOrElse(key,getValue){if(this.has(key))return JSON.parse(JSON.stringify(this.get(key)));const value=JSON.parse(JSON.stringify(getValue()));return this.set(key,value),value}clear(){const time=Date.now();for(const key of Object.keys(__classPrivateFieldGet(this,_JsonFile_data,"f")))this.emit("set",time,key,void 0);__classPrivateFieldSet(this,_JsonFile_data,{},"f"),fs.writeFileSync(this.filepath,"{}","utf8")}assign(data){data=JSON.parse(JSON.stringify(data));const time=Date.now();for(const[key,value]of Object.entries(data))__classPrivateFieldGet(this,_JsonFile_data,"f")[key]&&JSON.stringify(__classPrivateFieldGet(this,_JsonFile_data,"f")[key])!==JSON.stringify(value)&&this.emit("set",time,key,value);Object.assign(__classPrivateFieldGet(this,_JsonFile_data,"f"),data),this.saveFile()}ensureDirectoryExists(){fs.mkdirSync(path.dirname(this.filepath),{recursive:!0})}saveFile(){writeJsonFileSync(this.filepath,__classPrivateFieldGet(this,_JsonFile_data,"f"),this.prettyPrint)}loadFile(){__classPrivateFieldSet(this,_JsonFile_data,readJsonFileSync(this.filepath),"f")}}_JsonFile_data=new WeakMap;class LogFile{constructor(filepath){this.filepath=filepath,this.ensureDirectoryExists()}append(data,time=Date.now()){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.appendFile(this.filepath,time+"|"+JSON.stringify(data)+"\n","utf8")})}reset(){fs.rmSync(this.filepath)}readFile(){const data=fs.readFileSync(this.filepath,"utf8"),lines=data.split("\n"),result=[];for(const line of lines){const i=line.indexOf("|");if(-1===i)continue;const time=parseInt(line.substring(0,i)),data=JSON.parse(line.substring(i+1));result.push([time,data])}return result.sort((a,b)=>b[0]-a[0])}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_1,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_1_1,_d=!0,rl_1=__asyncValues(rl);rl_1_1=yield __await(rl_1.next()),_a=rl_1_1.done,!_a;_d=!0){_c=rl_1_1.value,_d=!1;const line=_c,i=line.indexOf("|"),time=parseInt(line.substring(0,i));yield yield __await(time)}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=rl_1.return)||(yield __await(_b.call(rl_1)))}finally{if(e_1)throw e_1.error}}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_2,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_2_1,_d=!0,rl_2=__asyncValues(rl);rl_2_1=yield __await(rl_2.next()),_a=rl_2_1.done,!_a;_d=!0){_c=rl_2_1.value,_d=!1;const line=_c,i=line.indexOf("|"),data=JSON.parse(line.substring(i+1));yield yield __await(data)}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=rl_2.return)||(yield __await(_b.call(rl_2)))}finally{if(e_2)throw e_2.error}}})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_3,_b,_c;const fileStream=fs.createReadStream(this.filepath,"utf8"),rl=readline.createInterface({input:fileStream,crlfDelay:1/0});try{for(var rl_3_1,_d=!0,rl_3=__asyncValues(rl);rl_3_1=yield __await(rl_3.next()),_a=rl_3_1.done,!_a;_d=!0){_c=rl_3_1.value,_d=!1;const line=_c,i=line.indexOf("|"),time=parseInt(line.substring(0,i)),data=JSON.parse(line.substring(i+1));yield yield __await([time,data])}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=rl_3.return)||(yield __await(_b.call(rl_3)))}finally{if(e_3)throw e_3.error}}})}ensureDirectoryExists(){fs.mkdirSync(path.dirname(this.filepath),{recursive:!0})}}class AppData{constructor(appAuthor,appName,configName){this.directory=path.join(getAppDataPath(),appAuthor,appName,configName),this.app=new JsonFile(path.join(this.directory,"appdata.json"),!1),this.user=new JsonFile(path.join(this.directory,"config.json"),!0),this.history=new LogFile(path.join(this.directory,"history.log")),this.app.on("set",(time,k,v)=>__awaiter(this,void 0,void 0,function*(){yield this.history.append({source:"app",key:k,value:v},time)})),this.user.on("set",(time,k,v)=>__awaiter(this,void 0,void 0,function*(){yield this.history.append({source:"user",key:k,value:v},time)}))}}function createDirectory(dirpath){return __awaiter(this,void 0,void 0,function*(){return yield fs.promises.mkdir(dirpath,{recursive:!0}),dirpath})}function appendLineToFile(filepath,line,linebreakBefore=!1){return __awaiter(this,void 0,void 0,function*(){fs.existsSync(filepath)||(yield createDirectory(path.dirname(filepath)),yield fs.promises.writeFile(filepath,"")),yield fs.promises.appendFile(filepath,linebreakBefore?"\n"+line:line+"\n")})}function cleanDirectorySync(dirpath,predicate){for(const filename of fs.readdirSync(dirpath)){const filepath=path.join(dirpath,filename),stat=fs.statSync(filepath);predicate(filepath,stat)&&fs.unlinkSync(filepath)}}function createDirectorySync(dirpath){return fs.mkdirSync(dirpath,{recursive:!0}),dirpath}function normalizeFileExtension(ext){if(""===ext||"."===ext)return"";if(/[<>"|?*:]/g.test(ext))throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>"|?:*`);return ext.includes(".")?ext.substring(ext.lastIndexOf(".")):"."+ext}function createFileExtensionFilter(...fileExtensions){return fileExtensions.length?filepath=>{for(const ext of fileExtensions.map(normalizeFileExtension))if(path.extname(filepath)===ext)return!0;return!1}:()=>!0}function cwdpath(...paths){return path.join(process.cwd(),...paths)}function deleteDirectory(dirpath){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.rm(dirpath,{recursive:!0,force:!0})})}function deleteDirectorySafe(dirpath){return __awaiter(this,void 0,void 0,function*(){fs.existsSync(dirpath)&&(yield fs.promises.rm(dirpath,{recursive:!0,force:!0}))})}function deleteDirectorySafeSync(dirpath){return fs.existsSync(dirpath)?(fs.rmSync(dirpath,{recursive:!0,force:!0}),dirpath):dirpath}function deleteDirectorySync(dirpath){return fs.rmSync(dirpath,{recursive:!0,force:!0}),dirpath}function ensureValidWindowsPath(path,options){const throwOrFalse=msg=>{if(options&&!0===options.assert)throw new Error(`Invalid windows path. ${msg} | input received: ${path}`);return!1};if(0===path.length)return throwOrFalse("Path string is length 0.");if(-1!==path.indexOf("/")&&-1!==path.indexOf("\\"))return throwOrFalse("Path contains both backslash and forward slash.");const maxLength=(options&&options.extendedMaxLength?32767:260)-12;if(path.length>maxLength)return throwOrFalse(`Maximum length of ${maxLength} exceeded`);let noDriveLetter=path;return /^\w:(\\|\/)/g.test(path)&&(noDriveLetter=path.substring(2)),/[<>"|?*:]/g.test(noDriveLetter)?throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>"|?:*`):!/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)||throwOrFalse("Illegal name in path string")}function isWindows(){return process.platform.includes("win")}function getDiskDrivesWindows(){if(!isWindows())throw new Error("This function is only available on Windows.");return execSync("wmic logicaldisk get name").toString().split("\n").map(s=>s.trim()).filter(s=>/^[a-z]:/i.test(s)).map(s=>s.substring(0,2)+path.sep)}function getHomeDirectory(){const home=path.resolve(process.env.HOME||process.env.USERPROFILE||"");if(!home)throw new Error("Home directory not found");return home}function getDownloadsDirectory(){return path.join(getHomeDirectory(),"Downloads")}function getLastMofifiedFileIn(dirpath){return __awaiter(this,void 0,void 0,function*(){const children=yield fs.promises.readdir(dirpath),filtered=children.map(fname=>{const fpath=path.join(dirpath,fname),stat=fs.statSync(fpath);return[fpath,stat.mtimeMs,stat.isFile()]}).filter(a=>a[2]),sorted=filtered.sort((a,b)=>b[1]-a[1]);return sorted[0][0]})}function getRootDir(){return path.parse(process.cwd()).root}function readFileLastLines(filepath,n,encoding="utf8"){return __awaiter(this,void 0,void 0,function*(){return yield readLastLines.read(filepath,n,encoding)})}function readJsonFile(filepath){return __awaiter(this,void 0,void 0,function*(){return JSON.parse(yield fs.promises.readFile(filepath,"utf8"))})}function readPackageJson(projectRoot=process.cwd()){const filepath=path.join(projectRoot,"package.json");return fs.existsSync(filepath)?readJsonFileSync(filepath):void 0}function removeIllegalFilenameCharacters(string){return string.replace(/[/\\?%*:|"<>]/g,"")}function tempFile(fileExtension,callback){const dir=path.join(process.env.TEMP,"bemoje","temp"),fpath=path.join(dir,Date.now()+fileExtension);fs.mkdirSync(dir,{recursive:!0});const prom=callback(fpath);if(prom instanceof Promise){const rm=()=>fs.rmSync(fpath);prom.then(rm).catch(rm)}else fs.rmSync(fpath)}function unzipFile(filepath,outdir){return __awaiter(this,void 0,void 0,function*(){yield extract(filepath,{dir:outdir})})}function unzipMergeFiles(source,target){return __awaiter(this,void 0,void 0,function*(){"string"==typeof source&&(source=fs.readdirSync(source).map(filename=>path.join(source,filename)));for(const filepath of source){const stat=yield fs.promises.stat(filepath);stat.isDirectory()||filepath.endsWith(".zip")&&(yield extract(filepath,{dir:target}))}})}function wipeDirectorySafe(dirpath){return __awaiter(this,void 0,void 0,function*(){yield deleteDirectorySafe(dirpath),yield createDirectory(dirpath)})}function writeJsonFile(filepath,data,pretty=!1){return __awaiter(this,void 0,void 0,function*(){yield fs.promises.writeFile(filepath,JSON.stringify(data,null,pretty?2:void 0))})}export{AppData,JsonFile,LogFile,absoluteToRelativePath,appendLineToFile,cleanDirectorySync,createDirectory,createDirectorySync,createFileExtensionFilter,cwdpath,deleteDirectory,deleteDirectorySafe,deleteDirectorySafeSync,deleteDirectorySync,ensureValidWindowsPath,getDiskDrivesWindows,getDownloadsDirectory,getHomeDirectory,getLastMofifiedFileIn,getRootDir,isWindows,normalizeFileExtension,readFileLastLines,readJsonFile,readJsonFileSync,readPackageJson,removeIllegalFilenameCharacters,tempFile,unzipFile,unzipMergeFiles,wipeDirectorySafe,writeJsonFile,writeJsonFileSync};
6
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/lib/absoluteToRelativePath.ts","../src/lib/readJsonFileSync.ts","../src/lib/writeJsonFileSync.ts","../src/lib/JsonFile.ts","../src/lib/LogFile.ts","../src/lib/AppData.ts","../src/lib/createDirectory.ts","../src/lib/appendLineToFile.ts","../src/lib/cleanDirectorySync.ts","../src/lib/createDirectorySync.ts","../src/lib/normalizeFileExtension.ts","../src/lib/createFileExtensionFilter.ts","../src/lib/cwdpath.ts","../src/lib/deleteDirectory.ts","../src/lib/deleteDirectorySafe.ts","../src/lib/deleteDirectorySafeSync.ts","../src/lib/deleteDirectorySync.ts","../src/lib/ensureValidWindowsPath.ts","../src/lib/isWindows.ts","../src/lib/getDiskDrivesWindows.ts","../src/lib/getHomeDirectory.ts","../src/lib/getDownloadsDirectory.ts","../src/lib/getLastMofifiedFileIn.ts","../src/lib/getRootDir.ts","../src/lib/readFileLastLines.ts","../src/lib/readJsonFile.ts","../src/lib/readPackageJson.ts","../src/lib/removeIllegalFilenameCharacters.ts","../src/lib/tempFile.ts","../src/lib/unzipFile.ts","../src/lib/unzipMergeFiles.ts","../src/lib/wipeDirectorySafe.ts","../src/lib/writeJsonFile.ts"],"sourcesContent":["import { regexEscapeString } from '@bemoje/string'\r\nimport path from 'path'\r\n\r\n/**\r\n * If the filepath is somewhere in the current working directory, it can be converted into a relative path.\r\n * @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,\r\n * replaces all backslashes with forward slashes, and removes any leading forward slashes.\r\n * @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.\r\n * @returns The relative path.\r\n * @param absolute the absolute filepath to convert.\r\n * @example ```ts\r\n * absoluteToRelativePath(__filename)\r\n * //=> 'src/absoluteToRelativePath.ts'\r\n * ```\r\n */\r\nexport function absoluteToRelativePath(absolute: string, workingDirectory = process.cwd()): string {\r\n return path\r\n .normalize(absolute)\r\n .replace(new RegExp(regexEscapeString(path.normalize(workingDirectory) + path.sep), 'i'), '')\r\n}\r\n","import fs from 'fs'\r\n\r\n/**\r\n * Reads a JSON file synchronously and returns a Promise that resolves with the parsed JSON data.\r\n * @template T The expected return type of the JSON data.\r\n * @param filepath The path to the JSON file to read.\r\n * @returns A Promise that resolves with the parsed JSON data.\r\n * @throws If the file cannot be read or the content cannot be parsed as JSON.\r\n * @example ```ts\r\n * const data = await readJsonFileSync<MyType>('/path/to/file.json');\r\n * console.log(data);\r\n * ```\r\n */\r\nexport function readJsonFileSync<T>(filepath: string): T {\r\n return JSON.parse(fs.readFileSync(filepath, 'utf8'))\r\n}\r\n","import fs from 'fs'\n\n/**\n * Writes a JSON object to a file synchronously.\n * @typeParam T - The type of the JSON object.\n * @param filepath - The path of the file where the JSON object will be written.\n * @param data - The JSON object that will be written to the file.\n * @param pretty - If true, the JSON object will be formatted with indentation and line breaks. Default is false.\n * @throws If the file cannot be written.\n * @example ```ts\n * const data = { name: 'John', age: 30 };\n * writeJsonFileSync('./data.json', data, true);\n * ```\n */\nexport function writeJsonFileSync<T>(filepath: string, data: T, pretty = false): void {\n fs.writeFileSync(filepath, JSON.stringify(data, null, pretty ? 2 : undefined))\n}\n","import EventEmitter from 'events'\nimport fs from 'fs'\nimport path from 'path'\nimport { readJsonFileSync } from './readJsonFileSync'\nimport { writeJsonFileSync } from './writeJsonFileSync'\n\n/**\n * Represents a JSON file manager that ensures immutable data since everything is serialized and deserialized before receiving or returning any data.\n */\nexport class JsonFile<T extends Record<string, any>> extends EventEmitter {\n /**\n * The filepath of the JSON file.\n */\n readonly filepath: string\n\n /**\n * The data stored in the JSON file.\n */\n #data: T\n\n /**\n * Determines whether the JSON file should be pretty-printed.\n */\n prettyPrint: boolean\n\n /**\n * Gets the data stored in the JSON file.\n * @returns A deep copy of the data.\n */\n get data(): T {\n return JSON.parse(JSON.stringify(this.#data))\n }\n\n /**\n * Constructs a new instance of the JsonFile class.\n * @param filepath - The filepath of the JSON file.\n * @param prettyPrint - Determines whether the JSON file should be pretty-printed.\n */\n constructor(filepath: string, prettyPrint = false) {\n super()\n this.filepath = filepath\n this.#data = {} as T\n this.prettyPrint = prettyPrint\n this.ensureDirectoryExists()\n if (fs.existsSync(this.filepath)) {\n this.loadFile()\n } else {\n writeJsonFileSync(this.filepath, this.#data, this.prettyPrint)\n }\n }\n\n /**\n * Gets the value associated with the specified key.\n * @param key - The key to retrieve the value for.\n * @returns The value associated with the key.\n */\n get(key: keyof T): any {\n return JSON.parse(JSON.stringify(this.#data[key]))\n }\n\n /**\n * Sets the value associated with the specified key.\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n set(key: keyof T, value: any): void {\n if (this.#data[key] === value) return\n const json = JSON.stringify(value)\n if (json === JSON.stringify(this.#data[key])) return\n value = JSON.parse(json)\n this.#data[key] = value\n this.saveFile()\n this.emit('set', Date.now(), key, value)\n }\n\n /**\n * Checks if the specified key exists in the JSON file.\n * @param key - The key to check.\n * @returns True if the key exists, false otherwise.\n */\n has(key: keyof T): boolean {\n return this.#data[key] !== undefined\n }\n\n /**\n * Deletes the value associated with the specified key.\n * @param key - The key to delete.\n */\n delete(key: keyof T): void {\n delete this.#data[key]\n this.saveFile()\n this.emit('set', Date.now(), key, void 0)\n }\n\n /**\n * Gets the value associated with the specified key, or sets it to the provided default value if it doesn't exist.\n * @param key - The key to get or set.\n * @param getValue - A function that returns the default value if the key doesn't exist.\n * @returns The value associated with the key, or the default value if it doesn't exist.\n */\n getOrElse(key: string, getValue: () => any): any {\n if (this.has(key)) {\n return JSON.parse(JSON.stringify(this.get(key)))\n }\n const value = JSON.parse(JSON.stringify(getValue()))\n this.set(key, value)\n return value\n }\n\n /**\n * Clears all the data in the JSON file.\n */\n clear(): void {\n const time = Date.now()\n for (const key of Object.keys(this.#data)) {\n this.emit('set', time, key, void 0)\n }\n this.#data = {} as T\n fs.writeFileSync(this.filepath, '{}', 'utf8')\n }\n\n /**\n * Assigns new data to the JSON file.\n * @param data - The data to assign.\n */\n assign(data: T): void {\n data = JSON.parse(JSON.stringify(data))\n const time = Date.now()\n for (const [key, value] of Object.entries(data)) {\n if (this.#data[key] && JSON.stringify(this.#data[key]) !== JSON.stringify(value)) {\n this.emit('set', time, key, value)\n }\n }\n Object.assign(this.#data, data)\n this.saveFile()\n }\n\n /**\n * Ensures that the directory containing the JSON file exists.\n */\n ensureDirectoryExists(): void {\n fs.mkdirSync(path.dirname(this.filepath), { recursive: true })\n }\n\n /**\n * Saves the data to the JSON file.\n */\n saveFile(): void {\n writeJsonFileSync(this.filepath, this.#data, this.prettyPrint)\n }\n\n /**\n * Loads the data from the JSON file.\n */\n loadFile(): void {\n this.#data = readJsonFileSync(this.filepath) as T\n }\n}\n","import fs from 'fs'\nimport path from 'path'\nimport readline from 'readline'\n\n/**\n * Represents a log file manager that appends log entries to a file.\n * It does not ensure extremely precise ordering of log entries' timestamps if used asynchronously. It logs them as they are received.\n */\nexport class LogFile<T> {\n /**\n * The path to the log file.\n */\n filepath: string\n\n /**\n * Creates a new instance of the LogFile class.\n * @param filepath - The path to the log file.\n */\n constructor(filepath: string) {\n this.filepath = filepath\n this.ensureDirectoryExists()\n }\n\n /**\n * Appends a log entry to the log file.\n * @param data - The data to be logged.\n * @param time - The timestamp of the log entry. Defaults to the current time.\n * @returns A promise that resolves when the log entry is appended.\n */\n async append(data: T, time = Date.now()): Promise<void> {\n await fs.promises.appendFile(this.filepath, time + '|' + JSON.stringify(data) + '\\n', 'utf8')\n }\n\n /**\n * Resets the log file by removing it.\n */\n reset(): void {\n fs.rmSync(this.filepath)\n }\n\n /**\n * Reads the log entire file and returns an array of log entries, sorted by timestamp in descending order.\n * @returns An array of log entries, sorted by timestamp in descending order.\n */\n readFile(): [number, T][] {\n const data = fs.readFileSync(this.filepath, 'utf8')\n const lines = data.split('\\n')\n const result = [] as [number, T][]\n for (const line of lines) {\n const i = line.indexOf('|')\n if (i === -1) continue\n const time = parseInt(line.substring(0, i))\n const data = JSON.parse(line.substring(i + 1)) as T\n result.push([time, data])\n }\n return result.sort((a, b) => b[0] - a[0])\n }\n\n /**\n * Returns an async generator that yields the timestamps of log entries in the log file.\n * @yields The timestamps of log entries.\n */\n async *keys(): AsyncGenerator<number> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const time = parseInt(line.substring(0, i))\n yield time\n }\n }\n\n /**\n * Returns an async generator that yields the values of log entries in the log file.\n * @yields The values of log entries.\n */\n async *values(): AsyncGenerator<T> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const data = JSON.parse(line.substring(i + 1)) as T\n yield data\n }\n }\n\n /**\n * Returns an async generator that yields the entries (timestamp and value) of log entries in the log file.\n * @yields The entries (timestamp and value) of log entries.\n */\n async *entries(): AsyncGenerator<[number, T]> {\n const fileStream = fs.createReadStream(this.filepath, 'utf8')\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity,\n })\n for await (const line of rl) {\n const i = line.indexOf('|')\n const time = parseInt(line.substring(0, i))\n const data = JSON.parse(line.substring(i + 1)) as T\n yield [time, data]\n }\n }\n\n /**\n * Ensures that the directory containing the log file exists.\n */\n ensureDirectoryExists(): void {\n fs.mkdirSync(path.dirname(this.filepath), { recursive: true })\n }\n}\n","import getAppDataPath from 'appdata-path'\nimport path from 'path'\nimport { JsonFile } from './JsonFile'\nimport { LogFile } from './LogFile'\nimport { ILogFileData } from './types/ILogFileData'\n\nexport class AppData<A extends Record<string, unknown>, C extends Record<string, unknown>> {\n directory: string\n app: JsonFile<A>\n user: JsonFile<C>\n history: LogFile<ILogFileData<C>>\n\n constructor(appAuthor: string, appName: string, configName: string) {\n this.directory = path.join(getAppDataPath(), appAuthor, appName, configName)\n this.app = new JsonFile(path.join(this.directory, 'appdata.json'), false)\n this.user = new JsonFile(path.join(this.directory, 'config.json'), true)\n this.history = new LogFile(path.join(this.directory, 'history.log'))\n this.app.on('set', async (time, k: string, v: C) => {\n await this.history.append({ source: 'app', key: k, value: v }, time)\n })\n this.user.on('set', async (time, k: string, v: C) => {\n await this.history.append({ source: 'user', key: k, value: v }, time)\n })\n }\n}\n","import fs from 'fs'\n/**\n * Create a directory at a given path if it does not exist.\n * Automatically creates parent directories if they do not exist.\n * @param dirpath The path where the directory should be created.\n * @returns The path of the directory.\n * @throws Will throw an error if the directory cannot be created.\n * @example ```ts\n * createDirectory('/path/to/directory').then((dirpath) => {\n * //=> `Directory created at ${dirpath}`\n * });\n * ```\n */\nexport async function createDirectory(dirpath: string): Promise<string> {\n await fs.promises.mkdir(dirpath, { recursive: true })\n return dirpath\n}\n","import fs from 'fs'\r\nimport path from 'path'\r\nimport { createDirectory } from './createDirectory'\r\n\r\n/**\r\n * Append a line to a file. Creates the file if it does not exist.\r\n * @param filepath The path of the file.\r\n * @param line The string data to append.\r\n * @returns A Promise that resolves when the line has been appended to the file.\r\n * @throws Will throw an error if the operation fails.\r\n * @example ```ts\r\n * await appendLineToFile('/path/to/file', 'This is a new line')\r\n * ```\r\n */\r\nexport async function appendLineToFile(filepath: string, line: string, linebreakBefore = false): Promise<void> {\r\n if (!fs.existsSync(filepath)) {\r\n await createDirectory(path.dirname(filepath))\r\n await fs.promises.writeFile(filepath, '')\r\n }\r\n await fs.promises.appendFile(filepath, linebreakBefore ? '\\n' + line : line + '\\n')\r\n}\r\n","import type { Stats } from 'fs'\r\nimport fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * Synchronously cleans a directory by removing files that satisfy a given predicate.\r\n * @remarks This function is a part of the File System module.\r\n * @param dirpath - The path to the directory that needs to be cleaned.\r\n * @param predicate - A function that takes a filepath and its stats as arguments and returns a boolean. If the function returns true for a file, that file is removed from the directory.\r\n * @throws If the directory at the provided path does not exist or cannot be read.\r\n * @example ```ts\r\n * import { Stats } from 'fs';\r\n * const dirpath = './my-directory';\r\n * const predicate = (filepath: string, stat: Stats) => stat.size > 1024;\r\n * cleanDirectorySync(dirpath, predicate);\r\n * ```\r\n */\r\nexport function cleanDirectorySync(dirpath: string, predicate: (filepath: string, stat: Stats) => boolean): void {\r\n for (const filename of fs.readdirSync(dirpath)) {\r\n const filepath = path.join(dirpath, filename)\r\n const stat = fs.statSync(filepath)\r\n if (predicate(filepath, stat)) fs.unlinkSync(filepath)\r\n }\r\n}\r\n","import fs from 'fs'\n\n/**\n * Create a directory at a given path if it does not exist.\n * Automatically creates parent directories if they do not exist.\n * @param dirpath The path where the directory should be created.\n * @returns The path of the directory.\n * @example ```ts\n * createDirectorySync('/path/to/directory')\n * ```\n */\nexport function createDirectorySync(dirpath: string): string {\n fs.mkdirSync(dirpath, { recursive: true })\n return dirpath\n}\n","/**\r\n * Normalize a file extension to the form: .[ext]\r\n * Anything before the last \".\" is not returned.\r\n * @returns The normalized file extension.\r\n * @throws If the extension contains illegal characters.\r\n * @param ext file extension\r\n * @example ```ts\r\n * normalizeFileExtension('jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('.jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('..jpg');;\r\n * //=> '.jpg'\r\n * normalizeFileExtension('');;\r\n * //=> ''\r\n * normalizeFileExtension('.');;\r\n * //=> ''\r\n * normalizeFileExtension('jpg|png');;\r\n * //=> Error\r\n * ```\r\n */\r\nexport function normalizeFileExtension(ext: string): string {\r\n if (ext === '' || ext === '.') return ''\r\n if (/[<>\"|?*:]/g.test(ext)) {\r\n throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>\"|?:*`)\r\n }\r\n if (!ext.includes('.')) return '.' + ext\r\n return ext.substring(ext.lastIndexOf('.'))\r\n}\r\n","import path from 'path'\nimport { normalizeFileExtension } from './normalizeFileExtension'\n\n/**\n * Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.\n * @remarks If no file extensions are provided, the filter will always return true.\n * @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.\n * @param fileExtensions file extensions\n * @example ```ts\n * createFileExtensionFilter('.ts', '.tsx')('index.ts');;\n * //=> true\n * createFileExtensionFilter('.ts', '.tsx')('index.js');;\n * //=> false\n * ```\n */\nexport function createFileExtensionFilter(...fileExtensions: string[]): (filepath: string) => boolean {\n if (!fileExtensions.length) return () => true\n return (filepath: string) => {\n for (const ext of fileExtensions.map(normalizeFileExtension)) {\n if (path.extname(filepath) === ext) {\n return true\n }\n }\n return false\n }\n}\n","import path from 'path'\r\n\r\n/**\r\n * Joins the given path segments to the current working directory path, and normalizes the resulting path.\r\n * @remarks\r\n * The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.\r\n * @param paths - The path segments to join to the current working directory path.\r\n * @returns The resulting path.\r\n * @example ```ts\r\n * console.log(cwdpath('src', 'index.ts'));\r\n * //=> '{working_directory}/src/index.ts'\r\n * ```\r\n */\r\nexport function cwdpath(...paths: string[]): string {\r\n return path.join(process.cwd(), ...paths)\r\n}\r\n","import fs from 'fs'\n\n/**\n * Deletes a directory and all of its contents.\n * @remarks This function uses Node.js's `fs.promises.rm` method with the `recursive` and `force` options set to `true`.\n * This means it will delete the directory and all of its contents, even if the directory is not empty.\n * @param dirpath The path to the directory to delete.\n * @returns A Promise that resolves when the directory has been deleted.\n * @throws Will throw an error if the directory does not exist, or if there was a problem deleting the directory.\n * @example ```ts\n * deleteDirectory('/path/to/directory');\n * ```\n */\nexport async function deleteDirectory(dirpath: string): Promise<void> {\n await fs.promises.rm(dirpath, { recursive: true, force: true })\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory safely if it exists.\n * @remarks This function uses Node.js' `fs.promises.rm` method with the `recursive` and `force` options set to `true`.\n * This means it will delete the directory and all its contents, even if the directory is not empty.\n * @param dirpath The path of the directory to delete.\n * @returns A promise that resolves to `void` when the directory has been deleted.\n * @throws Will throw an error if the `fs.promises.rm` operation fails.\n * @example ```ts\n * deleteDirectorySafe('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport async function deleteDirectorySafe(dirpath: string): Promise<void> {\n if (fs.existsSync(dirpath)) await fs.promises.rm(dirpath, { recursive: true, force: true })\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory synchronously in a safe manner. If the directory does not exist, it will simply return the directory path without throwing an error.\n * @param dirpath The path of the directory to be deleted.\n * @returns The path of the directory that was intended to be deleted.\n * @throws Will throw an error if the operation fails for reasons other than the directory not existing.\n * @example ```ts\n * deleteDirectorySafeSync('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport function deleteDirectorySafeSync(dirpath: string): string {\n if (!fs.existsSync(dirpath)) return dirpath\n fs.rmSync(dirpath, { recursive: true, force: true })\n return dirpath\n}\n","import fs from 'fs'\n\n/**\n * Deletes a directory synchronously.\n * @remarks This function uses Node.js's `fs.rmSync` method with the options `{ recursive: true, force: true }`.\n * @param dirpath The path of the directory to delete.\n * @returns The path of the deleted directory.\n * @throws Will throw an error if the directory does not exist or if the process lacks permissions to delete it.\n * @example ```ts\n * deleteDirectorySync('/path/to/directory');;\n * //=> undefined\n * ```\n */\nexport function deleteDirectorySync(dirpath: string): string {\n fs.rmSync(dirpath, { recursive: true, force: true })\n return dirpath\n}\n","import { IEnsureValidWindowsPathOptions } from './types/IEnsureValidWindowsPathOptions'\r\n\r\n/**\r\n * Check whether a provided windows filesystem path string is valid according to:\r\n * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx\r\n * @param path The path to validate.\r\n * @returns A boolean indicating whether the path is valid. If the `assert` option is true, the function will throw an error instead of returning false.\r\n * @throws Will throw an error if the `assert` option is true and the path is invalid.\r\n * @param options An optional object that may contain the following properties:\r\n * - `assert`: If true, the function will throw an error if the path is invalid. Default is false.\r\n * - `extendedMaxLength`: If true, the function will allow paths up to 32767 characters long. Default is false.\r\n * @example ```ts\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt');;\r\n * //=> true\r\n * ensureValidWindowsPath('C:/Users/User/Documents/file.txt');;\r\n * //=> false\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt', { assert: true });;\r\n * //=> throws an error\r\n * ensureValidWindowsPath('C:\\\\Users\\\\User\\\\Documents\\\\file.txt', { extendedMaxLength: true });;\r\n * //=> true\r\n * ```\r\n */\r\nexport function ensureValidWindowsPath(path: string, options?: IEnsureValidWindowsPathOptions): boolean {\r\n const throwOrFalse = (msg: string) => {\r\n if (options && options.assert === true) {\r\n throw new Error(`Invalid windows path. ${msg} | input received: ${path}`)\r\n }\r\n return false\r\n }\r\n\r\n if (path.length === 0) {\r\n return throwOrFalse('Path string is length 0.')\r\n }\r\n\r\n if (path.indexOf('/') !== -1 && path.indexOf('\\\\') !== -1) {\r\n return throwOrFalse('Path contains both backslash and forward slash.')\r\n }\r\n\r\n const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12\r\n if (path.length > maxLength) {\r\n return throwOrFalse(`Maximum length of ${maxLength} exceeded`)\r\n }\r\n\r\n let noDriveLetter = path\r\n if (/^\\w:(\\\\|\\/)/g.test(path)) {\r\n noDriveLetter = path.substring(2)\r\n }\r\n if (/[<>\"|?*:]/g.test(noDriveLetter)) {\r\n return throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>\"|?:*`)\r\n }\r\n\r\n if (/(\\\\|\\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\\\|\\/)|$)/g.test(path)) {\r\n return throwOrFalse('Illegal name in path string')\r\n }\r\n\r\n return true\r\n}\r\n","export function isWindows() {\r\n return process.platform.includes('win')\r\n}\r\n","import { execSync } from 'child_process'\r\nimport path from 'path'\r\nimport { isWindows } from './isWindows'\r\n\r\nexport function getDiskDrivesWindows(): string[] {\r\n if (!isWindows()) throw new Error('This function is only available on Windows.')\r\n return execSync('wmic logicaldisk get name')\r\n .toString()\r\n .split('\\n')\r\n .map((s) => s.trim())\r\n .filter((s) => /^[a-z]:/i.test(s))\r\n .map((s) => s.substring(0, 2) + path.sep)\r\n}\r\n","import path from 'path'\r\n\r\nexport function getHomeDirectory(): string {\r\n const home = path.resolve(process.env['HOME'] || process.env['USERPROFILE'] || '')\r\n if (!home) throw new Error('Home directory not found')\r\n return home\r\n}\r\n","import path from 'path'\r\nimport { getHomeDirectory } from './getHomeDirectory'\r\n\r\nexport function getDownloadsDirectory() {\r\n return path.join(getHomeDirectory(), 'Downloads')\r\n}\r\n","import fs from 'fs'\r\nimport path from 'path'\r\n\r\nexport async function getLastMofifiedFileIn(dirpath: string): Promise<string> {\r\n const children = await fs.promises.readdir(dirpath)\r\n const filtered = children\r\n .map((fname: string) => {\r\n const fpath = path.join(dirpath, fname)\r\n const stat = fs.statSync(fpath)\r\n return [fpath, stat.mtimeMs, stat.isFile()]\r\n })\r\n .filter((a) => a[2]) as [string, number, boolean][]\r\n const sorted = filtered.sort((a, b) => b[1] - a[1])\r\n return sorted[0][0]\r\n}\r\n","import path from 'path'\r\n\r\nexport function getRootDir() {\r\n return path.parse(process.cwd()).root\r\n}\r\n","import readLastLines from 'read-last-lines'\n\n/**\n * Read the last n lines of a file.\n * @param filepath The path to the file.\n * @param n The number of lines to read.\n * @param encoding The encoding of the file.\n * @example await readLastLines.read('path/to/file.log', 50)\n */\nexport async function readFileLastLines(filepath: string, n: number, encoding: NodeJS.BufferEncoding = 'utf8') {\n return await readLastLines.read(filepath, n, encoding)\n}\n","import fs from 'fs'\r\n\r\n/**\r\n * Reads a JSON file from the given filepath and returns its content as a Promise.\r\n * The Promise will resolve with the parsed JSON content as an object of type T.\r\n * @template T The expected return type of the JSON object.\r\n * @param filepath The path to the JSON file to read.\r\n * @returns A Promise that resolves with the parsed JSON content as an object of type T.\r\n * @throws Will throw an error if reading the file fails for any reason.\r\n * @example ```ts\r\n * const data: MyType = await readJsonFile<MyType>('path/to/myfile.json');\r\n * ```\r\n */\r\nexport async function readJsonFile<T>(filepath: string): Promise<T> {\r\n return JSON.parse(await fs.promises.readFile(filepath, 'utf8'))\r\n}\r\n","import fs from 'fs'\r\nimport path from 'path'\r\nimport { readJsonFileSync } from './readJsonFileSync'\r\n\r\nexport function readPackageJson(projectRoot = process.cwd()): Record<string, any> | undefined {\r\n const filepath = path.join(projectRoot, 'package.json')\r\n if (!fs.existsSync(filepath)) return\r\n return readJsonFileSync(filepath)\r\n}\r\n","export function removeIllegalFilenameCharacters(string: string) {\r\n return string.replace(/[/\\\\?%*:|\"<>]/g, '')\r\n}\r\n","import fs from 'fs'\nimport path from 'path'\n\n/**\n * Creates a temporary file and deletes it after the callback has finished.\n * @param fileExtension - The file extension to use for the temporary file.\n * @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.\n */\nexport function tempFile(fileExtension: string, callback: (fpath: string) => void | Promise<void>): void {\n const dir = path.join(process.env['TEMP']!, 'bemoje', 'temp')\n const fpath = path.join(dir, Date.now() + fileExtension)\n fs.mkdirSync(dir, { recursive: true })\n const prom = callback(fpath)\n if (prom instanceof Promise) {\n const rm = () => fs.rmSync(fpath)\n prom.then(rm).catch(rm)\n } else {\n fs.rmSync(fpath)\n }\n}\n","import extract from 'extract-zip'\r\n\r\nexport async function unzipFile(filepath: string, outdir: string) {\r\n await extract(filepath, { dir: outdir })\r\n}\r\n","import extract from 'extract-zip'\r\nimport fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @param source Either a directory containing zip files or an array of zip file paths.\r\n */\r\nexport async function unzipMergeFiles(source: string | string[], target: string) {\r\n if (typeof source === 'string') {\r\n source = fs.readdirSync(source).map((filename) => {\r\n return path.join(source as string, filename)\r\n })\r\n }\r\n for (const filepath of source) {\r\n const stat = await fs.promises.stat(filepath)\r\n if (stat.isDirectory()) continue\r\n if (!filepath.endsWith('.zip')) continue\r\n await extract(filepath, { dir: target })\r\n }\r\n}\r\n","import { createDirectory } from './createDirectory'\r\nimport { deleteDirectorySafe } from './deleteDirectorySafe'\r\n\r\nexport async function wipeDirectorySafe(dirpath: string) {\r\n await deleteDirectorySafe(dirpath)\r\n await createDirectory(dirpath)\r\n}\r\n","import fs from 'fs'\n\n/**\n * Writes a JSON file to the specified filepath. The data to be written is passed as an argument.\n * If the 'pretty' argument is set to true, the JSON data will be formatted in a more human-readable way.\n * @template T - The type of the data to be written to the file.\n * @param filepath - The path to the file where the data should be written.\n * @param data - The data to be written to the file.\n * @param pretty - Optional. If set to true, formats the JSON data in a more human-readable way. Default is false.\n * @returns A Promise that resolves when the file has been successfully written.\n * @example ```ts\n * const data = { name: 'John', age: 30 };\n * await writeJsonFile('./data.json', data, true);\n * ```\n */\nexport async function writeJsonFile<T>(filepath: string, data: T, pretty = false): Promise<void> {\n await fs.promises.writeFile(filepath, JSON.stringify(data, null, pretty ? 2 : undefined))\n}\n"],"names":["absoluteToRelativePath","absolute","workingDirectory","process","cwd","path","normalize","replace","RegExp","regexEscapeString","sep","readJsonFileSync","filepath","JSON","parse","fs","readFileSync","writeJsonFileSync","data","pretty","writeFileSync","stringify","JsonFile","EventEmitter","__classPrivateFieldGet","_JsonFile_data","constructor","prettyPrint","set","__classPrivateFieldSet","ensureDirectoryExists","existsSync","loadFile","get","key","value","json","saveFile","emit","Date","now","has","delete","getOrElse","getValue","clear","time","Object","keys","assign","entries","mkdirSync","dirname","recursive","LogFile","append","promises","appendFile","reset","rmSync","readFile","lines","split","result","line","i","indexOf","parseInt","substring","push","sort","a","b","fileStream","createReadStream","rl","readline","createInterface","input","crlfDelay","rl_1","__asyncValues","rl_1_1","__await","next","_a","done","_d","_c","values","rl_2","rl_2_1","rl_3","rl_3_1","AppData","appAuthor","appName","configName","directory","join","getAppDataPath","app","user","history","on","k","v","__awaiter","source","createDirectory","dirpath","mkdir","appendLineToFile","linebreakBefore","writeFile","cleanDirectorySync","predicate","filename","readdirSync","stat","statSync","unlinkSync","createDirectorySync","normalizeFileExtension","ext","test","Error","includes","lastIndexOf","createFileExtensionFilter","fileExtensions","length","map","extname","cwdpath","paths","deleteDirectory","rm","force","deleteDirectorySafe","deleteDirectorySafeSync","deleteDirectorySync","ensureValidWindowsPath","options","throwOrFalse","msg","assert","maxLength","extendedMaxLength","noDriveLetter","isWindows","platform","getDiskDrivesWindows","execSync","toString","s","trim","filter","getHomeDirectory","home","resolve","env","HOME","USERPROFILE","getDownloadsDirectory","getLastMofifiedFileIn","children","readdir","filtered","fname","fpath","mtimeMs","isFile","sorted","getRootDir","root","readFileLastLines","n","encoding","readLastLines","read","readJsonFile","readPackageJson","projectRoot","removeIllegalFilenameCharacters","string","tempFile","fileExtension","callback","dir","TEMP","prom","Promise","then","catch","unzipFile","outdir","extract","unzipMergeFiles","target","isDirectory","endsWith","wipeDirectorySafe","writeJsonFile"],"mappings":";;;;oTAeM,QAAU,CAAAA,sBAAsBA,CAACC,QAAgB,CAAEC,gBAAgB,CAAGC,OAAO,CAACC,GAAG,CAAA,CAAE,CAAA,CACvF,MAAO,CAAAC,IAAI,CACRC,SAAS,CAACL,QAAQ,CAAC,CACnBM,OAAO,CAAC,GAAI,CAAAC,MAAM,CAACC,iBAAiB,CAACJ,IAAI,CAACC,SAAS,CAACJ,gBAAgB,CAAC,CAAGG,IAAI,CAACK,GAAG,CAAC,CAAE,GAAG,CAAC,CAAE,EAAE,CAChG,ksGCNM,QAAU,CAAAC,gBAAgBA,CAAIC,QAAgB,CAAA,CAClD,MAAO,CAAAC,IAAI,CAACC,KAAK,CAACC,EAAE,CAACC,YAAY,CAACJ,QAAQ,CAAE,MAAM,CAAC,CACrD,CCDM,QAAU,CAAAK,iBAAiBA,CAAIL,QAAgB,CAAEM,IAAO,CAAEC,MAAM,GAAQ,CAAA,CAC5EJ,EAAE,CAACK,aAAa,CAACR,QAAQ,CAAEC,IAAI,CAACQ,SAAS,CAACH,IAAI,CAAE,IAAI,CAAEC,MAAM,CAAG,CAAC,OAAY,CAAC,CAC/E,oBCPM,KAAO,CAAAG,QAAwC,QAAQ,CAAAC,YAAY,CAoBvE,GAAI,CAAAL,IAAIA,CAAA,CAAA,CACN,MAAO,CAAAL,IAAI,CAACC,KAAK,CAACD,IAAI,CAACQ,SAAS,CAACG,sBAAA,CAAA,IAAI,CAAMC,cAAA,CAAA,GAAA,CAAA,CAAC,CAC7C,CAODC,WAAAA,CAAYd,QAAgB,CAAEe,WAAW,GAAQ,CAAA,CAC/C,KAAK,EAAE,CArBTF,cAAQ,CAAAG,GAAA,CAAA,IAAA,CAAA,IAAA,EAAA,CAAA,CAsBN,IAAI,CAAChB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AAI,CAACQ,SAAS,CAACH,IAAI,CAAE,IAAI,CAAEC,MAAM,CAAG,CAAC,OAAY,CAAC,EACzF,CAAA"}
@@ -0,0 +1,36 @@
1
+ export * from './lib/absoluteToRelativePath';
2
+ export * from './lib/AppData';
3
+ export * from './lib/appendLineToFile';
4
+ export * from './lib/cleanDirectorySync';
5
+ export * from './lib/createDirectory';
6
+ export * from './lib/createDirectorySync';
7
+ export * from './lib/createFileExtensionFilter';
8
+ export * from './lib/cwdpath';
9
+ export * from './lib/deleteDirectory';
10
+ export * from './lib/deleteDirectorySafe';
11
+ export * from './lib/deleteDirectorySafeSync';
12
+ export * from './lib/deleteDirectorySync';
13
+ export * from './lib/ensureValidWindowsPath';
14
+ export * from './lib/getDiskDrivesWindows';
15
+ export * from './lib/getDownloadsDirectory';
16
+ export * from './lib/getHomeDirectory';
17
+ export * from './lib/getLastMofifiedFileIn';
18
+ export * from './lib/getRootDir';
19
+ export * from './lib/isWindows';
20
+ export * from './lib/JsonFile';
21
+ export * from './lib/LogFile';
22
+ export * from './lib/normalizeFileExtension';
23
+ export * from './lib/readFileLastLines';
24
+ export * from './lib/readJsonFile';
25
+ export * from './lib/readJsonFileSync';
26
+ export * from './lib/readPackageJson';
27
+ export * from './lib/removeIllegalFilenameCharacters';
28
+ export * from './lib/tempFile';
29
+ export * from './lib/types/IEnsureValidWindowsPathOptions';
30
+ export * from './lib/types/ILogFileData';
31
+ export * from './lib/unzipFile';
32
+ export * from './lib/unzipMergeFiles';
33
+ export * from './lib/wipeDirectorySafe';
34
+ export * from './lib/writeJsonFile';
35
+ export * from './lib/writeJsonFileSync';
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uCAAuC,CAAA;AACrD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4CAA4C,CAAA;AAC1D,cAAc,0BAA0B,CAAA;AACxC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { JsonFile } from './JsonFile';
2
+ import { LogFile } from './LogFile';
3
+ import { ILogFileData } from './types/ILogFileData';
4
+ export declare class AppData<A extends Record<string, unknown>, C extends Record<string, unknown>> {
5
+ directory: string;
6
+ app: JsonFile<A>;
7
+ user: JsonFile<C>;
8
+ history: LogFile<ILogFileData<C>>;
9
+ constructor(appAuthor: string, appName: string, configName: string);
10
+ }
11
+ //# sourceMappingURL=AppData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppData.d.ts","sourceRoot":"","sources":["../../../src/lib/AppData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,qBAAa,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvF,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IAChB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IACjB,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;gBAErB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAYnE"}
@@ -0,0 +1,79 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ /**
4
+ * Represents a JSON file manager that ensures immutable data since everything is serialized and deserialized before receiving or returning any data.
5
+ */
6
+ export declare class JsonFile<T extends Record<string, any>> extends EventEmitter {
7
+ #private;
8
+ /**
9
+ * The filepath of the JSON file.
10
+ */
11
+ readonly filepath: string;
12
+ /**
13
+ * Determines whether the JSON file should be pretty-printed.
14
+ */
15
+ prettyPrint: boolean;
16
+ /**
17
+ * Gets the data stored in the JSON file.
18
+ * @returns A deep copy of the data.
19
+ */
20
+ get data(): T;
21
+ /**
22
+ * Constructs a new instance of the JsonFile class.
23
+ * @param filepath - The filepath of the JSON file.
24
+ * @param prettyPrint - Determines whether the JSON file should be pretty-printed.
25
+ */
26
+ constructor(filepath: string, prettyPrint?: boolean);
27
+ /**
28
+ * Gets the value associated with the specified key.
29
+ * @param key - The key to retrieve the value for.
30
+ * @returns The value associated with the key.
31
+ */
32
+ get(key: keyof T): any;
33
+ /**
34
+ * Sets the value associated with the specified key.
35
+ * @param key - The key to set the value for.
36
+ * @param value - The value to set.
37
+ */
38
+ set(key: keyof T, value: any): void;
39
+ /**
40
+ * Checks if the specified key exists in the JSON file.
41
+ * @param key - The key to check.
42
+ * @returns True if the key exists, false otherwise.
43
+ */
44
+ has(key: keyof T): boolean;
45
+ /**
46
+ * Deletes the value associated with the specified key.
47
+ * @param key - The key to delete.
48
+ */
49
+ delete(key: keyof T): void;
50
+ /**
51
+ * Gets the value associated with the specified key, or sets it to the provided default value if it doesn't exist.
52
+ * @param key - The key to get or set.
53
+ * @param getValue - A function that returns the default value if the key doesn't exist.
54
+ * @returns The value associated with the key, or the default value if it doesn't exist.
55
+ */
56
+ getOrElse(key: string, getValue: () => any): any;
57
+ /**
58
+ * Clears all the data in the JSON file.
59
+ */
60
+ clear(): void;
61
+ /**
62
+ * Assigns new data to the JSON file.
63
+ * @param data - The data to assign.
64
+ */
65
+ assign(data: T): void;
66
+ /**
67
+ * Ensures that the directory containing the JSON file exists.
68
+ */
69
+ ensureDirectoryExists(): void;
70
+ /**
71
+ * Saves the data to the JSON file.
72
+ */
73
+ saveFile(): void;
74
+ /**
75
+ * Loads the data from the JSON file.
76
+ */
77
+ loadFile(): void;
78
+ }
79
+ //# sourceMappingURL=JsonFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonFile.d.ts","sourceRoot":"","sources":["../../../src/lib/JsonFile.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAMjC;;GAEG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAE,SAAQ,YAAY;;IACvE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAOzB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC,CAEZ;IAED;;;;OAIG;gBACS,QAAQ,EAAE,MAAM,EAAE,WAAW,UAAQ;IAajD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG;IAItB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAUnC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,OAAO;IAI1B;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI;IAM1B;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,GAAG;IAShD;;OAEG;IACH,KAAK,IAAI,IAAI;IASb;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAYrB;;OAEG;IACH,qBAAqB,IAAI,IAAI;IAI7B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,QAAQ,IAAI,IAAI;CAGjB"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Represents a log file manager that appends log entries to a file.
3
+ * It does not ensure extremely precise ordering of log entries' timestamps if used asynchronously. It logs them as they are received.
4
+ */
5
+ export declare class LogFile<T> {
6
+ /**
7
+ * The path to the log file.
8
+ */
9
+ filepath: string;
10
+ /**
11
+ * Creates a new instance of the LogFile class.
12
+ * @param filepath - The path to the log file.
13
+ */
14
+ constructor(filepath: string);
15
+ /**
16
+ * Appends a log entry to the log file.
17
+ * @param data - The data to be logged.
18
+ * @param time - The timestamp of the log entry. Defaults to the current time.
19
+ * @returns A promise that resolves when the log entry is appended.
20
+ */
21
+ append(data: T, time?: number): Promise<void>;
22
+ /**
23
+ * Resets the log file by removing it.
24
+ */
25
+ reset(): void;
26
+ /**
27
+ * Reads the log entire file and returns an array of log entries, sorted by timestamp in descending order.
28
+ * @returns An array of log entries, sorted by timestamp in descending order.
29
+ */
30
+ readFile(): [number, T][];
31
+ /**
32
+ * Returns an async generator that yields the timestamps of log entries in the log file.
33
+ * @yields The timestamps of log entries.
34
+ */
35
+ keys(): AsyncGenerator<number>;
36
+ /**
37
+ * Returns an async generator that yields the values of log entries in the log file.
38
+ * @yields The values of log entries.
39
+ */
40
+ values(): AsyncGenerator<T>;
41
+ /**
42
+ * Returns an async generator that yields the entries (timestamp and value) of log entries in the log file.
43
+ * @yields The entries (timestamp and value) of log entries.
44
+ */
45
+ entries(): AsyncGenerator<[number, T]>;
46
+ /**
47
+ * Ensures that the directory containing the log file exists.
48
+ */
49
+ ensureDirectoryExists(): void;
50
+ }
51
+ //# sourceMappingURL=LogFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogFile.d.ts","sourceRoot":"","sources":["../../../src/lib/LogFile.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,OAAO,CAAC,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;gBACS,QAAQ,EAAE,MAAM;IAK5B;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,SAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE;IAczB;;;OAGG;IACI,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC;IAarC;;;OAGG;IACI,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;IAalC;;;OAGG;IACI,OAAO,IAAI,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAc7C;;OAEG;IACH,qBAAqB,IAAI,IAAI;CAG9B"}
@@ -1,20 +1,14 @@
1
- import { regexEscapeString } from '@bemoje/string'
2
- import path from 'path'
3
-
4
- /**
5
- * If the filepath is somewhere in the current working directory, it can be converted into a relative path.
6
- * @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,
7
- * replaces all backslashes with forward slashes, and removes any leading forward slashes.
8
- * @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.
9
- * @returns The relative path.
10
- * @param absolute the absolute filepath to convert.
11
- * @example ```ts
12
- * absoluteToRelativePath(__filename)
13
- * //=> 'src/absoluteToRelativePath.ts'
14
- * ```
15
- */
16
- export function absoluteToRelativePath(absolute: string, workingDirectory = process.cwd()): string {
17
- return path
18
- .normalize(absolute)
19
- .replace(new RegExp(regexEscapeString(path.normalize(workingDirectory) + path.sep), 'i'), '')
20
- }
1
+ /**
2
+ * If the filepath is somewhere in the current working directory, it can be converted into a relative path.
3
+ * @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,
4
+ * replaces all backslashes with forward slashes, and removes any leading forward slashes.
5
+ * @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.
6
+ * @returns The relative path.
7
+ * @param absolute the absolute filepath to convert.
8
+ * @example ```ts
9
+ * absoluteToRelativePath(__filename)
10
+ * //=> 'src/absoluteToRelativePath.ts'
11
+ * ```
12
+ */
13
+ export declare function absoluteToRelativePath(absolute: string, workingDirectory?: string): string;
14
+ //# sourceMappingURL=absoluteToRelativePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"absoluteToRelativePath.d.ts","sourceRoot":"","sources":["../../../src/lib/absoluteToRelativePath.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,SAAgB,GAAG,MAAM,CAIjG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Append a line to a file. Creates the file if it does not exist.
3
+ * @param filepath The path of the file.
4
+ * @param line The string data to append.
5
+ * @returns A Promise that resolves when the line has been appended to the file.
6
+ * @throws Will throw an error if the operation fails.
7
+ * @example ```ts
8
+ * await appendLineToFile('/path/to/file', 'This is a new line')
9
+ * ```
10
+ */
11
+ export declare function appendLineToFile(filepath: string, line: string, linebreakBefore?: boolean): Promise<void>;
12
+ //# sourceMappingURL=appendLineToFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appendLineToFile.d.ts","sourceRoot":"","sources":["../../../src/lib/appendLineToFile.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7G"}