fluent-file 0.1.0 → 0.1.2
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.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -157,9 +157,9 @@ declare class AFile {
|
|
|
157
157
|
readTextLines: () => neverthrow.ResultAsync<string[], FileNotFoundError | FileReadError | FileWasNotFileError>;
|
|
158
158
|
writeText: (content: string) => neverthrow.ResultAsync<void, FileWriteError | FileWasNotFileError>;
|
|
159
159
|
}
|
|
160
|
-
declare function
|
|
160
|
+
declare function afile(file: AFile | Folder | string, ...extraPathPieces: Strings): AFile;
|
|
161
161
|
declare function homeFile(file: AFile | Folder | string, ...extraPathPieces: Strings): AFile;
|
|
162
|
-
declare function
|
|
162
|
+
declare function findFiles(inFolder?: Folder, anyGlob?: AnyGlob): neverthrow.ResultAsync<AFile[], NodeError | FolderWasNotFolderError>;
|
|
163
163
|
|
|
164
164
|
declare class ZodParseError extends Error {
|
|
165
165
|
nestedErrors: UnknownObject;
|
|
@@ -185,7 +185,7 @@ type YamlStringifyOptions = (DocumentOptions & SchemaOptions & CreateNodeOptions
|
|
|
185
185
|
declare const YAML_EXTENSIONS: string[];
|
|
186
186
|
declare class YamlFile<FileSchema extends ZodTypeAny> extends JsonFile<FileSchema> {
|
|
187
187
|
read: (parseOptions?: YamlParseOptions) => neverthrow.ResultAsync<z.TypeOf<FileSchema>, FileNotFoundError | FileReadError | FileWasNotFileError | ZodParseError | YAMLParseError>;
|
|
188
|
-
write: (
|
|
188
|
+
write: (contents: z.infer<FileSchema>, stringifyOptions?: YamlStringifyOptions) => neverthrow.ResultAsync<void, FileWriteError | FileWasNotFileError | StringifyError | ZodParseError>;
|
|
189
189
|
}
|
|
190
190
|
declare function yamlFile<FileSchema extends ZodTypeAny>(fileSchema: FileSchema, filePath: AFile | Folder | string, ...extraPathPieces: Strings): YamlFile<FileSchema>;
|
|
191
191
|
declare function findYamlFiles<FileSchema extends ZodTypeAny>(fileSchema: FileSchema, inFolder?: Folder, anyGlob?: AnyGlob): neverthrow.ResultAsync<YamlFile<FileSchema>[], NodeError | FolderWasNotFolderError>;
|
|
@@ -267,4 +267,4 @@ declare class GitFolder extends Folder {
|
|
|
267
267
|
getReadMe: () => AFile;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
export { AFile
|
|
270
|
+
export { AFile, Folder, GitFolder, IMAGE_EXTENSIONS, ImageFile, JsonFile, PhashSimilarity, type PhashSimilarityResult, type ToAvifOptions, VIDEO_EXTENSIONS, VideoFile, YAML_EXTENSIONS, YamlFile, afile, base2to36, base36to2, cwd, findFiles, findImageFiles, findJsonFiles, findVideoFiles, findYamlFiles, folder, homeFile, homeFolder, imageFile, jsonFile, phashCheck, videoFile, yamlFile };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import{constants as kt}from"node:fs";import{copyFile as Gt}from"node:fs/promises";import{homedir as $t}from"node:os";import{inspect as Ut}from"node:util";import{stat as V}from"node:fs/promises";var J=Object.keys;function F(e){if(!(e instanceof Error&&"code"in e&&typeof e.code=="string"))throw new Error("was not a Node error",{cause:e})}var T=(s=>(s.BlockDevice="BlockDevice",s.CharacterDevice="CharacterDevice",s.Directory="Directory",s.FIFO="FIFO",s.File="File",s.Socket="Socket",s.SymbolicLink="SymbolicLink",s))(T||{});function U(e){for(let t of J(T))if(e[`is${t}`]())return T[t];return"File"}var A=class extends Error{constructor(t,r){super(t,{cause:r}),this.name=this.constructor.name}},O=class extends Error{constructor(t,r){super(t,{cause:r}),this.name=this.constructor.name}},P=class extends Error{constructor(t,r){super(t,{cause:r}),this.name=this.constructor.name}},u=class extends Error{actualFileEntryType;constructor(t,r,o){let i=`${t}
|
|
2
2
|
was actually a ${r} instead of a Folder`;o?super(i,{cause:o}):super(i),this.name=this.constructor.name,this.actualFileEntryType=r}};var E=class extends Error{actualFileEntryType;constructor(t,r,o){let i=`${t}
|
|
3
|
-
was actually a ${r} instead of a Folder`;o?super(i,{cause:o}):super(i),this.name=this.constructor.name,this.actualFileEntryType=r}};import{ResultAsync as W}from"neverthrow";function w(e){return W.fromThrowable(async()=>{let t=await V(e.path);if(t.isDirectory())return t;throw new E(e.path,U(t))},t=>(t instanceof E||F(t),t))()}function _(e){return W.fromThrowable(async()=>{let t=await V(e.path);if(t.isFile())return t;throw new u(e.path,U(t))},t=>(t instanceof u||F(t),t))()}import{homedir as wt}from"node:os";import{inspect as bt}from"node:util";import{emptyDir as Tt,ensureDir as At,remove as Ot}from"fs-extra/esm";import{basename as X,dirname as Pt,resolve as K}from"pathe";var h=class e{#t;#e;#r;#o;constructor(t,...r){let o=t instanceof e?t.path:t;this.#t=K(o,...r),this.#e=X(this.#t),this.#e||(this.#e=this.#t),this.#o=Pt(this.path),this.#r=X(this.#o),this.#r||(this.#r=this.#e)}get path(){return this.#t}get name(){return this.#e}get parentName(){return this.#r}get parentPath(){return this.#o}get info(){return{path:this.#t,name:this.#e,parentName:this.#r,parentPath:this.#o}}relativePath=(t=N())=>this.#t.startsWith(t)?this.#t.slice(t.length+1):this.#t;toString=()=>this.#t;toJSON=()=>({Folder:this.info});[bt.custom]=()=>this.toJSON();getStats=()=>w(this);exists=async()=>(await this.getStats()).isOk();ensureExists=()=>At(this.#t);ensureEmpty=()=>Tt(this.#t);delete=()=>Ot(this.#t);getParentFolder=()=>new e(this.#o);subFolder=(t,...r)=>{let o=t instanceof e?t.path:t;return new e(this.#t,o,...r)};childFolders=t=>M(this,t,1);findFolders=t=>M(this,t)};function l(e,...t){return e===void 0?new h(""):new h(e,...t)}function Nt(...e){return new h(wt(),...e)}function N(){return K(process.cwd())}import{globby as It}from"globby";var j="**",vt={absolute:!0,gitignore:!0};async function q(e,t,r,o){let i={cwd:t.path,...vt,...r},a=j;if(typeof o=="string"||Array.isArray(o))a=o;else{let{patterns:n,extensions:s,expandDirectories:d,...m}=o;n&&(a=n),i={expandDirectories:s?{extensions:s}:!0,...m,...i}}return(await It(a,i)).sort().map(n=>e(n))}function f(e,t,r=j,o=Number.POSITIVE_INFINITY){return w(t).map(()=>q(e,t,{deep:o},r))}function M(e,t=j,r=Number.POSITIVE_INFINITY){return w(e).map(()=>q(l,e,{onlyDirectories:!0,deep:r},t))}import{readFile as Rt}from"node:fs/promises";import{outputFile as Dt}from"fs-extra/esm";import{ResultAsync as H}from"neverthrow";var B=/\n|\r|\r\n/;function Q(e){return H.fromThrowable(()=>Rt(e,"utf8"),t=>(F(t),t.code==="ENOENT"?new A(e,t):t.code==="EISDIR"?new u(e,"Directory",t):new O(e,t)))()}function tt(e,t){return H.fromThrowable(()=>Dt(e,t),r=>(F(r),r.code==="EISDIR"?new u(e,"Directory",r):new P(e,r)))()}import{ensureFile as Mt,ensureLink as jt,ensureSymlink as Ct,move as Yt,remove as zt}from"fs-extra/esm";import{basename as et,dirname as Lt,resolve as Zt}from"pathe";var c=class e{#t;#e;#r;#o;#i;#s;constructor(t,...r){let o=rt(t);this.#t=Zt(o,...r),this.#e=et(this.#t);let i=this.#e.lastIndexOf(".");i<=0?(this.#r=this.#e,this.#o=""):(this.#r=this.#e.slice(0,i),this.#o=this.#e.slice(i+1)),this.#s=Lt(this.path),this.#i=et(this.#s),this.#i||(this.#i=this.#e)}get path(){return this.#t}get fullName(){return this.#e}get name(){return this.#r}get ext(){return this.#o}get parentName(){return this.#i}get parentPath(){return this.#s}get info(){return{path:this.#t,fullName:this.#e,name:this.#r,ext:this.#o,parentName:this.#i,parentPath:this.#s}}relativePath=(t=N())=>this.#t.startsWith(t)?this.#t.slice(t.length+1):this.#t;toString=()=>this.#t;toJSON=()=>({File:this.info});[Ut.custom]=()=>this.toJSON();getParentFolder=()=>new h(this.#s);getStats=()=>_(this);exists=async()=>(await this.getStats()).isOk();ensureExists=()=>Mt(this.#t);copyTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Gt(this.#t,r.path,kt.COPYFILE_FICLONE)};moveTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Yt(this.#t,r.path)};linkTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await jt(this.#t,r.path)};symlinkTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Ct(this.#t,r.path)};delete=()=>zt(this.#t);readText=()=>Q(this.path);readTextLines=()=>this.readText().map(t=>t.split(B));writeText=t=>tt(this.path,t)};function g(e,...t){return new c(e,...t)}function Jt(e,...t){return new c($t(),rt(e),...t)}function rt(e){return e instanceof c||e instanceof h?e.path:e}function Vt(e=l(),t){return f(g,e,t)}import{inspect as Wt}from"node:util";import{fromThrowable as _t}from"neverthrow";var C=class extends Error{nestedErrors;constructor({cause:t,nestedErrors:r}){super(`ZodParseError: ${Wt(r)}`,{cause:t}),this.nestedErrors=r}};function I(e,t){return _t(()=>e.parse(t),r=>{let o=r;return new C({cause:o,nestedErrors:o.format(i=>({...i,actual:Xt(t,i.path)}))})})()}function Xt(e,t){let r=e[t[0]];for(let o of t)r=r[o];return r}import{fromThrowable as ot}from"neverthrow";import Kt from"parse-json";import{configure as qt}from"safe-stable-stringify";var Ht=ot(e=>Kt(e),e=>e),Bt=qt({circularValue:Error,strict:!0}),Qt=ot((e,t)=>{let r=Bt(e,null,t);if(r===void 0)throw new Error("Undefined returned from stringify!!!");if(r.trim().length===0)throw new Error("Empty string returned from stringify!!!");return r},e=>e),x=class extends c{fileSchema;constructor(t,r,...o){super(r,...o),this.fileSchema=t}validateUnknown=t=>I(this.fileSchema,t);read=()=>this.readText().andThen(Ht).andThen(this.validateUnknown);write=(t,r=2)=>this.validateUnknown(t).andThen(o=>Qt(o,r)).asyncAndThen(this.writeText)};function it(e,t,...r){return new x(e,t,...r)}function te(e,t=l(),r="*.json"){return f(o=>it(e,o),t,r)}import{fromThrowable as st}from"neverthrow";import{parse as ee,stringify as Y}from"yaml";var nt=["yaml","yml"],re=st((e,t)=>ee(e,t),e=>e),oe=st((e,t=2)=>typeof t=="string"?Y(e,{indent:Number.parseInt(t),sortMapEntries:!0}):typeof t=="number"?Y(e,{indent:t,sortMapEntries:!0}):Y(e,{sortMapEntries:!0,...t}),e=>e),v=class extends x{read=t=>this.readText().andThen(r=>re(r,t)).andThen(r=>this.validateUnknown(r));write=(t,r)=>this.validateUnknown(
|
|
3
|
+
was actually a ${r} instead of a Folder`;o?super(i,{cause:o}):super(i),this.name=this.constructor.name,this.actualFileEntryType=r}};import{ResultAsync as W}from"neverthrow";function w(e){return W.fromThrowable(async()=>{let t=await V(e.path);if(t.isDirectory())return t;throw new E(e.path,U(t))},t=>(t instanceof E||F(t),t))()}function _(e){return W.fromThrowable(async()=>{let t=await V(e.path);if(t.isFile())return t;throw new u(e.path,U(t))},t=>(t instanceof u||F(t),t))()}import{homedir as wt}from"node:os";import{inspect as bt}from"node:util";import{emptyDir as Tt,ensureDir as At,remove as Ot}from"fs-extra/esm";import{basename as X,dirname as Pt,resolve as K}from"pathe";var h=class e{#t;#e;#r;#o;constructor(t,...r){let o=t instanceof e?t.path:t;this.#t=K(o,...r),this.#e=X(this.#t),this.#e||(this.#e=this.#t),this.#o=Pt(this.path),this.#r=X(this.#o),this.#r||(this.#r=this.#e)}get path(){return this.#t}get name(){return this.#e}get parentName(){return this.#r}get parentPath(){return this.#o}get info(){return{path:this.#t,name:this.#e,parentName:this.#r,parentPath:this.#o}}relativePath=(t=N())=>this.#t.startsWith(t)?this.#t.slice(t.length+1):this.#t;toString=()=>this.#t;toJSON=()=>({Folder:this.info});[bt.custom]=()=>this.toJSON();getStats=()=>w(this);exists=async()=>(await this.getStats()).isOk();ensureExists=()=>At(this.#t);ensureEmpty=()=>Tt(this.#t);delete=()=>Ot(this.#t);getParentFolder=()=>new e(this.#o);subFolder=(t,...r)=>{let o=t instanceof e?t.path:t;return new e(this.#t,o,...r)};childFolders=t=>M(this,t,1);findFolders=t=>M(this,t)};function l(e,...t){return e===void 0?new h(""):new h(e,...t)}function Nt(...e){return new h(wt(),...e)}function N(){return K(process.cwd())}import{globby as It}from"globby";var j="**",vt={absolute:!0,gitignore:!0};async function q(e,t,r,o){let i={cwd:t.path,...vt,...r},a=j;if(typeof o=="string"||Array.isArray(o))a=o;else{let{patterns:n,extensions:s,expandDirectories:d,...m}=o;n&&(a=n),i={expandDirectories:s?{extensions:s}:!0,...m,...i}}return(await It(a,i)).sort().map(n=>e(n))}function f(e,t,r=j,o=Number.POSITIVE_INFINITY){return w(t).map(()=>q(e,t,{deep:o},r))}function M(e,t=j,r=Number.POSITIVE_INFINITY){return w(e).map(()=>q(l,e,{onlyDirectories:!0,deep:r},t))}import{readFile as Rt}from"node:fs/promises";import{outputFile as Dt}from"fs-extra/esm";import{ResultAsync as H}from"neverthrow";var B=/\n|\r|\r\n/;function Q(e){return H.fromThrowable(()=>Rt(e,"utf8"),t=>(F(t),t.code==="ENOENT"?new A(e,t):t.code==="EISDIR"?new u(e,"Directory",t):new O(e,t)))()}function tt(e,t){return H.fromThrowable(()=>Dt(e,t),r=>(F(r),r.code==="EISDIR"?new u(e,"Directory",r):new P(e,r)))()}import{ensureFile as Mt,ensureLink as jt,ensureSymlink as Ct,move as Yt,remove as zt}from"fs-extra/esm";import{basename as et,dirname as Lt,resolve as Zt}from"pathe";var c=class e{#t;#e;#r;#o;#i;#s;constructor(t,...r){let o=rt(t);this.#t=Zt(o,...r),this.#e=et(this.#t);let i=this.#e.lastIndexOf(".");i<=0?(this.#r=this.#e,this.#o=""):(this.#r=this.#e.slice(0,i),this.#o=this.#e.slice(i+1)),this.#s=Lt(this.path),this.#i=et(this.#s),this.#i||(this.#i=this.#e)}get path(){return this.#t}get fullName(){return this.#e}get name(){return this.#r}get ext(){return this.#o}get parentName(){return this.#i}get parentPath(){return this.#s}get info(){return{path:this.#t,fullName:this.#e,name:this.#r,ext:this.#o,parentName:this.#i,parentPath:this.#s}}relativePath=(t=N())=>this.#t.startsWith(t)?this.#t.slice(t.length+1):this.#t;toString=()=>this.#t;toJSON=()=>({File:this.info});[Ut.custom]=()=>this.toJSON();getParentFolder=()=>new h(this.#s);getStats=()=>_(this);exists=async()=>(await this.getStats()).isOk();ensureExists=()=>Mt(this.#t);copyTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Gt(this.#t,r.path,kt.COPYFILE_FICLONE)};moveTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Yt(this.#t,r.path)};linkTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await jt(this.#t,r.path)};symlinkTo=async t=>{let r=t instanceof e?t:g(t,this.#e);await r.getParentFolder().ensureExists(),await r.delete(),await Ct(this.#t,r.path)};delete=()=>zt(this.#t);readText=()=>Q(this.path);readTextLines=()=>this.readText().map(t=>t.split(B));writeText=t=>tt(this.path,t)};function g(e,...t){return new c(e,...t)}function Jt(e,...t){return new c($t(),rt(e),...t)}function rt(e){return e instanceof c||e instanceof h?e.path:e}function Vt(e=l(),t){return f(g,e,t)}import{inspect as Wt}from"node:util";import{fromThrowable as _t}from"neverthrow";var C=class extends Error{nestedErrors;constructor({cause:t,nestedErrors:r}){super(`ZodParseError: ${Wt(r)}`,{cause:t}),this.nestedErrors=r}};function I(e,t){return _t(()=>e.parse(t),r=>{let o=r;return new C({cause:o,nestedErrors:o.format(i=>({...i,actual:Xt(t,i.path)}))})})()}function Xt(e,t){let r=e[t[0]];for(let o of t)r=r[o];return r}import{fromThrowable as ot}from"neverthrow";import Kt from"parse-json";import{configure as qt}from"safe-stable-stringify";var Ht=ot(e=>Kt(e),e=>e),Bt=qt({circularValue:Error,strict:!0}),Qt=ot((e,t)=>{let r=Bt(e,null,t);if(r===void 0)throw new Error("Undefined returned from stringify!!!");if(r.trim().length===0)throw new Error("Empty string returned from stringify!!!");return r},e=>e),x=class extends c{fileSchema;constructor(t,r,...o){super(r,...o),this.fileSchema=t}validateUnknown=t=>I(this.fileSchema,t);read=()=>this.readText().andThen(Ht).andThen(this.validateUnknown);write=(t,r=2)=>this.validateUnknown(t).andThen(o=>Qt(o,r)).asyncAndThen(this.writeText)};function it(e,t,...r){return new x(e,t,...r)}function te(e,t=l(),r="*.json"){return f(o=>it(e,o),t,r)}import{fromThrowable as st}from"neverthrow";import{parse as ee,stringify as Y}from"yaml";var nt=["yaml","yml"],re=st((e,t)=>ee(e,t),e=>e),oe=st((e,t=2)=>typeof t=="string"?Y(e,{indent:Number.parseInt(t),sortMapEntries:!0}):typeof t=="number"?Y(e,{indent:t,sortMapEntries:!0}):Y(e,{sortMapEntries:!0,...t}),e=>e),v=class extends x{read=t=>this.readText().andThen(r=>re(r,t)).andThen(r=>this.validateUnknown(r));write=(t,r)=>this.validateUnknown(t).andThen(o=>oe(o,r)).asyncAndThen(this.writeText)};function at(e,t,...r){return new v(e,t,...r)}function ie(e,t=l(),r={extensions:nt}){return f(o=>at(e,o),t,r)}import se from"sharp";import ne from"sharp-phash";var pt=6,lt=".avif",mt=["avif","gif","jpeg","jpg","png","svg","tiff","webp"],R=class extends c{sharp;constructor(t,...r){super(t,...r),this.sharp=se(this.path)}convertToAvif=async({newFolder:t,newName:r,height:o,width:i,effort:a=9,quality:n}={})=>{let s=t||this.getParentFolder(),d=r??this.name;d.endsWith(lt)||(d+=lt);let m=L(s,d);return await m.exists()||(await m.getParentFolder().ensureExists(),await this.sharp.resize({fit:"contain",height:o,width:i,withoutEnlargement:!0}).avif({effort:a,quality:n}).toFile(m.path)),m};getPhash=async()=>{let t=await ne(this.path);return ct(t)}};function L(e,...t){return new R(e,...t)}function ae(e=l(),t={extensions:mt}){return f(L,e,t)}function ct(e){return Number.parseInt(e,2).toString(36)}function z(e){return Number.parseInt(e,36).toString(2)}function pe(e,t){if(t.includes(e))return{case:"Exact",phash:e};let o=z(e);for(let i of t){let a=z(i),n=0,s=o.length;for(;s--&&n<=pt;)n+=Math.abs(o.charCodeAt(s)-a.charCodeAt(s));if(n<pt)return{case:"Similar",phash:i}}return{case:"Unique",phash:e}}var ht=(o=>(o.Exact="Exact",o.Similar="Similar",o.Unique="Unique",o))(ht||{});import p from"zod";var Pr=p.object({codec_type:p.literal("data")}),le=p.object({codec_type:p.literal("audio")}),me=p.object({codec_type:p.literal("video"),height:p.number().int().positive(),width:p.number().int().positive()}),ft=p.object({format:p.object({bit_rate:p.coerce.number(),duration:p.coerce.number(),size:p.coerce.number()}),streams:p.array(p.union([le,me]))}).transform(({format:{bit_rate:e,duration:t,size:r},streams:o},{addIssue:i})=>{for(let a of o)if(a.codec_type==="video"){let{height:n,width:s}=a,d=Math.round(t*1e3),m=Math.trunc(t%60),b=Math.trunc(t/60%60),$=Math.trunc(t/60/60%60);return{bitRate:e,bytes:r,height:n,hours:$,millis:d,minutes:b,seconds:m,width:s}}return i({code:p.ZodIssueCode.custom,message:"Video was missing video stream"}),p.NEVER});import ut from"fluent-ffmpeg";import{ResultAsync as dt}from"neverthrow";var D=class extends Error{constructor(t,r){super(t,{cause:r}),this.name=this.constructor.name}},k=class extends Error{constructor(t,r){super(t,{cause:r}),this.name=this.constructor.name}};var gt=["avi","flv","mkv","mov","mp4","mpeg","mpg","rm","rmvb","webm","wmv"],ce=e=>new Promise((t,r)=>ut.ffprobe(e,(o,i)=>{o&&r(o),t(i)})),he=(e,t,r,o)=>new Promise((i,a)=>ut(e).on("error",n=>a(n)).on("end",()=>i()).screenshot({filename:r,folder:t,timestamps:typeof o=="string"?[o]:[o]})),G=class extends c{getMetaData=()=>this.getStats().andThen(()=>dt.fromThrowable(()=>ce(this.path),t=>new D(this.path,t))().andThen(t=>I(ft,t)));getThumbnail=(t,r)=>dt.fromThrowable(async()=>{if(await r.exists())return r;let i=r.getParentFolder();return await i.ensureExists(),await he(this.path,i.path,`${r.name}.png`,t),r},o=>new k(this.path,o))()};function yt(e,...t){return new G(e,...t)}function fe(e=l(),t={extensions:gt}){return f(yt,e,t)}import y from"log-update";import{CheckRepoActions as de,simpleGit as Ft}from"simple-git";var ue=e=>e.padEnd(11),S="";function ge({method:e,stage:t,progress:r,processed:o,total:i}){let a=e.toUpperCase(),n=ue(t);if(n!==S){S&&(y(a,S,"completed"),y.done()),S=n;return}let s=i.toString().length,d=process.stdout.columns,m=Math.max(1,Math.ceil(d*r/100)),b=d-m,$="=".repeat(m),xt="_".repeat(b),St=[a,n,o.toString().padStart(s),"of",i.toString(),`(${r.toString().padStart(2)}%)`].join(" "),Et=`${$}${xt}`;y(`${St}
|
|
4
4
|
${Et}`)}var Z=class extends h{owner;repo;baseUrl;shortUrl;fullUrl;progress;constructor({owner:t,repo:r,onProgress:o,baseUrl:i},a,...n){let s=[...n,t,r];super(a,...s),this.owner=t,this.repo=r,this.baseUrl=i??"https://github.com",this.shortUrl=`${t}/${r}`,this.fullUrl=`${this.baseUrl}/${this.shortUrl}`,this.progress=o??ge}get git(){return Ft({baseDir:this.path,progress:this.progress})}isaRepo=async()=>await Ft(this.path).checkIsRepo(de.IS_REPO_ROOT);clone=async()=>{if(console.log(`Cloning
|
|
5
5
|
`,this.fullUrl,`
|
|
6
6
|
into:
|
|
7
7
|
`,this.relativePath()),await this.ensureExists(),await this.isaRepo()){console.log(this.fullUrl,"is already cloned");return}await this.git.clone(this.fullUrl,this.path),y("CLONE",S,"completed"),y.done(),console.log(`Cloned
|
|
8
8
|
`,this.fullUrl,`
|
|
9
9
|
into:
|
|
10
|
-
`,this.relativePath())};pull=async()=>{console.log("Pulling",this.fullUrl),await this.ensureExists(),await this.isaRepo()||(console.log(this.fullUrl,"does not exist yet, cloning..."),await this.clone());let r=await this.git.pull();return y("PULL",S,"completed"),y.done(),console.log("Pulled",this.fullUrl),r};getReadMe=()=>g(this.path,"README.md")};export{c as
|
|
10
|
+
`,this.relativePath())};pull=async()=>{console.log("Pulling",this.fullUrl),await this.ensureExists(),await this.isaRepo()||(console.log(this.fullUrl,"does not exist yet, cloning..."),await this.clone());let r=await this.git.pull();return y("PULL",S,"completed"),y.done(),console.log("Pulled",this.fullUrl),r};getReadMe=()=>g(this.path,"README.md")};export{c as AFile,h as Folder,Z as GitFolder,mt as IMAGE_EXTENSIONS,R as ImageFile,x as JsonFile,ht as PhashSimilarity,gt as VIDEO_EXTENSIONS,G as VideoFile,nt as YAML_EXTENSIONS,v as YamlFile,g as afile,ct as base2to36,z as base36to2,N as cwd,Vt as findFiles,ae as findImageFiles,te as findJsonFiles,fe as findVideoFiles,ie as findYamlFiles,l as folder,Jt as homeFile,Nt as homeFolder,L as imageFile,it as jsonFile,pe as phashCheck,yt as videoFile,at as yamlFile};
|