@tigrisdata/cli 3.0.0-beta.1 → 3.0.0

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.
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-ZP77TNW7.js";import{a as i,k as m}from"./chunk-QWZ6FK7E.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,f as l}from"./chunk-GNWZ7PX2.js";import{a as i,k as m}from"./chunk-QWZ6FK7E.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
@@ -0,0 +1,8 @@
1
+ import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.0.0";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
2
+ ${s}
3
+ ${o("")}
4
+ ${o(r)}
5
+ ${o(t)}
6
+ ${o("")}
7
+ ${l}
8
+ `),v({...e,lastNotified:Date.now()})}let a=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||216e5;(!e||Date.now()-e.lastChecked>a)&&j()}export{u as a,y as b,T as c,M as d,k as e,O as f};
@@ -0,0 +1 @@
1
+ import{extname as t}from"path";var o={html:"text/html",htm:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",cjs:"text/javascript",json:"application/json",map:"application/json",xml:"application/xml",svg:"image/svg+xml",webmanifest:"application/manifest+json",wasm:"application/wasm",txt:"text/plain",log:"text/plain",md:"text/markdown",csv:"text/csv",yaml:"application/yaml",yml:"application/yaml",pdf:"application/pdf",rtf:"application/rtf",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",ico:"image/x-icon",bmp:"image/bmp",tif:"image/tiff",tiff:"image/tiff",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject",mp4:"video/mp4",m4v:"video/x-m4v",webm:"video/webm",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",mp3:"audio/mpeg",m4a:"audio/mp4",wav:"audio/wav",ogg:"audio/ogg",flac:"audio/flac",aac:"audio/aac",opus:"audio/opus",zip:"application/zip",tar:"application/x-tar",gz:"application/gzip",tgz:"application/gzip",bz2:"application/x-bzip2","7z":"application/x-7z-compressed",rar:"application/vnd.rar"};function e(a){let i=t(a).slice(1).toLowerCase();if(i)return o[i]}export{e as a};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-SO7GMI24.js";import"./chunk-ZP77TNW7.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
2
+ import"./chunk-7EHCU6PH.js";import"./chunk-GNWZ7PX2.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-SO7GMI24.js";import"./chunk-ZP77TNW7.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
1
+ import"./chunk-7EHCU6PH.js";import"./chunk-GNWZ7PX2.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as D}from"../chunk-SAAGVLRE.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as C,d as T,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as G}from"../chunk-YN2TKPPT.js";import{a as x,b as q}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{get as V,head as X,list as tt,put as E}from"@tigrisdata/storage";import{createReadStream as et,createWriteStream as ot,existsSync as Y,mkdirSync as it,readdirSync as z,statSync as L}from"fs";import{homedir as nt}from"os";import{basename as M,dirname as K,join as N,relative as _,resolve as H}from"path";import{Readable as Z}from"stream";import{pipeline as rt}from"stream/promises";var h=!1;function at(n,t){let e=U(n),l=U(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function P(n){return n==="~"||n.startsWith("~/")?H(nt(),n.slice(2)):H(n)}function lt(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return N(l,e.name)})}function ct(n,t){let e=K(n),l=M(n),s=O(l);return Y(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&s.test(r.name)).map(r=>{let o=r.parentPath??r.path;return N(o,r.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>N(e,o.name)):[]}async function I(n,t,e,l,s=!1){let p;try{p=L(n).size}catch{return{error:`File not found: ${n}`}}let r=et(n),o=Z.toWeb(r),{error:i}=await E(e,o,{...B(p),onUploadProgress:s?({loaded:a})=>{if(p!==void 0&&p>0){let c=Math.round(a/p*100);process.stdout.write(`\rUploading: ${w(a)} / ${w(p)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(a)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),i?{error:i.message}:{}}async function Q(n,t,e,l,s=!1){let p;if(s){let{data:u}=await X(t,{config:{...l,bucket:n}});p=u?.size}let{data:r,error:o}=await V(t,"stream",{config:{...l,bucket:n}});if(o)return{error:o.message};let i=K(e);Y(i)||it(i,{recursive:!0});let a=ot(e),c=Z.fromWeb(r);if(s&&p!==void 0&&p>0){let u=0;c.on("data",m=>{u+=m.length;let g=Math.round(u/p*100);process.stdout.write(`\rDownloading: ${w(u)} / ${w(p)} (${g}%)`)})}return await rt(c,a),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,l,s,p=!1){if(e.endsWith("/")){let{error:c}=await E(s,"",{config:{...n,bucket:l}});return c?{error:c.message}:{}}let r;if(p){let{data:c}=await X(e,{config:{...n,bucket:t}});r=c?.size}let{data:o,error:i}=await V(e,"stream",{config:{...n,bucket:t}});if(i)return{error:i.message};let{error:a}=await E(s,o,{...B(r),onUploadProgress:p?({loaded:c})=>{if(r!==void 0&&r>0){let u=Math.round(c/r*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(r)} (${u}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...n,bucket:l}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),a?{error:a.message}:{}}async function st(n,t,e,l){let s=P(n);if(n.includes("*")){let o=ct(s,l);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),a=o.map(m=>async()=>{let g=_(i,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`);return}let r;try{r=L(s)}catch{f(`Source not found: ${n}`)}if(r.isDirectory()){l||f(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=lt(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),a=o.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await T(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let a=await I(s,t.bucket,i,e,!h);a.error&&f(a.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function pt(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=P(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&p;if(!o&&!i&&(i=await T(t.bucket,t.path,l)),i&&!o&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let a=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:m}=await j(t.bucket,a||void 0,l);m&&f(m);let g=u.filter(y=>!y.name.endsWith("/"));if(o){let y=t.path.split("/").pop(),b=O(y);g=g.filter(S=>{let d=a?S.name.slice(a.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=a?y.name.slice(a.length):y.name,S=c?N(r,c,b):N(r,b),d=await Q(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await D(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let a=t.path.split("/").pop(),c,u=!1;try{u=L(r).isDirectory()}catch{}u||e.endsWith("/")?c=N(r,a):c=r;let m=await Q(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function ut(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=n.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!r&&!o&&t.path&&(o=await T(t.bucket,t.path,l)),o&&!r&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||o){let i=r?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",a=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",a].filter(Boolean).join("/"),m=u?`${u}/`:"";t.bucket===e.bucket&&i===m&&f("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==i);if(r){let d=t.path.split("/").pop(),W=O(d);$=$.filter(F=>{let v=i?F.name.slice(i.length):F.name;return!s&&v.includes("/")?!1:W.test(v.split("/").pop())})}let R=$.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=u?`${u}/${W}`:W,v=await A(l,t.bucket,d.name,e.bucket,F);return v.error?(console.error(`Failed to copy ${d.name}: ${v.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${F}`),!0)}),b=(await D(R,8)).filter(Boolean).length,S=!1;if(u&&i){let{data:d}=await tt({prefix:i,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${u}/`,F=await A(l,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),a;e.path?e.path.endsWith("/")?a=`${e.path}${i}`:await T(e.bucket,e.path,l)?a=`${e.path}/${i}`:a=e.path:a=i,t.bucket===e.bucket&&t.path===a&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,a,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${a}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${a}`)}}async function ft(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!x(n,["recursive","r"]);h=q(n)==="json";let p=at(t,e),r=await G({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await st(t,o,r,l);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await pt(t,o,e,r,l);break}case"remote-to-remote":{let o=C(t),i=C(e);o.bucket||f("Invalid source path"),i.bucket||f("Invalid destination path"),await ut(t,o,i,r,l);break}}process.exit(0)}export{ft as default};
1
+ import{a as G}from"../chunk-EKW6XTGL.js";import{a as D}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-IRDNZN7R.js";import{a as U,b as v,d as C,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as K}from"../chunk-YN2TKPPT.js";import{a as x,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as P,get as tt,head as et,list as ot,put as V}from"@tigrisdata/storage";import{createReadStream as it,createWriteStream as nt,existsSync as X,mkdirSync as rt,readdirSync as A,statSync as z}from"fs";import{homedir as at}from"os";import{basename as E,dirname as L,join as N,relative as _,resolve as H}from"path";import{Readable as Y}from"stream";import{pipeline as lt}from"stream/promises";var h=!1;function ct(i,t){let e=U(i),r=U(t);return!e&&!r&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&r?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(at(),i.slice(2)):H(i)}function st(i){return A(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let r=e.parentPath??e.path;return N(r,e.name)})}function pt(i,t){let e=L(i),r=E(i),c=O(r);return X(e)?t?A(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&c.test(a.name)).map(a=>{let o=a.parentPath??a.path;return N(o,a.name)}):A(e,{withFileTypes:!0}).filter(o=>o.isFile()&&c.test(o.name)).map(o=>N(e,o.name)):[]}async function B(i,t,e,r,c=!1){let p;try{p=z(i).size}catch{return{error:`File not found: ${i}`}}let a=it(i),o=Y.toWeb(a),n=q(i),{error:l}=await V(e,o,{...G(p),...n?{contentType:n}:{},onUploadProgress:c?({loaded:u})=>{if(p!==void 0&&p>0){let s=Math.round(u/p*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(p)} (${s}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...r,bucket:t}});return c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function Q(i,t,e,r,c=!1){let p;if(c){let{data:s}=await et(t,{config:{...r,bucket:i}});p=s?.size}let{data:a,error:o}=await tt(t,"stream",{config:{...r,bucket:i}});if(o)return{error:o.message};let n=L(e);X(n)||rt(n,{recursive:!0});let l=nt(e),u=Y.fromWeb(a);if(c&&p!==void 0&&p>0){let s=0;u.on("data",m=>{s+=m.length;let d=Math.round(s/p*100);process.stdout.write(`\rDownloading: ${R(s)} / ${R(p)} (${d}%)`)})}return await lt(u,l),c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function I(i,t,e,r,c){if(e.endsWith("/")){let{error:a}=await V(c,"",{config:{...i,bucket:r}});return a?{error:a.message}:{}}let{error:p}=await P(e,c,{srcBucket:t,destBucket:r,config:{...i,bucket:r}});return p?{error:p.message}:{}}async function ut(i,t,e,r){let c=Z(i);if(i.includes("*")){let o=pt(c,r);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let n=L(c),l=o.map(m=>async()=>{let d=_(n,m),w=t.path?`${t.path.replace(/\/$/,"")}/${d}`:d,y=await B(m,t.bucket,w,e);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${w}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`);return}let a;try{a=z(c)}catch{f(`Source not found: ${i}`)}if(a.isDirectory()){r||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let o=st(c);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let n=i.endsWith("/")?"":E(c),l=o.map(m=>async()=>{let d=_(c,m),y=[t.path?.replace(/\/$/,""),n,d].filter(Boolean).join("/"),F=await B(m,t.bucket,y,e);return F.error?(console.error(`Failed to upload ${m}: ${F.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${y}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`)}else{let o=E(c),n;t.path?i.endsWith("/")||t.path.endsWith("/")?n=`${t.path.replace(/\/$/,"")}/${o}`:await C(t.bucket,t.path,e)?n=`${t.path}/${o}`:n=t.path:n=o;let l=await B(c,t.bucket,n,e,!h);l.error&&f(l.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${n}`}):`Uploaded ${i} -> t3://${t.bucket}/${n}`)}}async function ft(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=Z(e),o=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&p;if(!o&&!n&&(n=await C(t.bucket,t.path,r)),n&&!o&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||n){let l=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",u=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:s,error:m}=await j(t.bucket,l||void 0,r);m&&f(m);let d=s.filter($=>!$.name.endsWith("/"));if(o){let $=t.path.split("/").pop(),b=O($);d=d.filter(k=>{let g=l?k.name.slice(l.length):k.name;return!c&&g.includes("/")?!1:b.test(g.split("/").pop())})}if(d.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=d.map($=>async()=>{let b=l?$.name.slice(l.length):$.name,k=u?N(a,u,b):N(a,b),g=await Q(t.bucket,$.name,k,r);return g.error?(console.error(`Failed to download ${$.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${$.name} -> ${k}`),!0)}),F=(await D(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:F}):`Downloaded ${F} file(s)`)}else{let l=t.path.split("/").pop(),u,s=!1;try{s=z(a).isDirectory()}catch{}s||e.endsWith("/")?u=N(a,l):u=a;let m=await Q(t.bucket,t.path,u,r,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:u}):`Downloaded t3://${t.bucket}/${t.path} -> ${u}`)}}async function mt(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=i.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!a&&!o&&t.path&&(o=await C(t.bucket,t.path,r)),o&&!a&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),a||o){let n=a?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",l=!a&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",s=[e.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),m=s?`${s}/`:"";t.bucket===e.bucket&&n===m&&f("Source and destination are the same");let{items:d,error:w}=await j(t.bucket,n||void 0,r);w&&f(w);let y=d.filter(g=>g.name!==n);if(a){let g=t.path.split("/").pop(),S=O(g);y=y.filter(W=>{let T=n?W.name.slice(n.length):W.name;return!c&&T.includes("/")?!1:S.test(T.split("/").pop())})}let F=y.map(g=>async()=>{let S=n?g.name.slice(n.length):g.name,W=s?`${s}/${S}`:S,T=await I(r,t.bucket,g.name,e.bucket,W);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${W}`),!0)}),b=(await D(F,8)).filter(Boolean).length,k=!1;if(s&&n){let{data:g}=await ot({prefix:n,limit:1,config:{...r,bucket:t.bucket}});if(g?.items?.some(S=>S.name===n)){let S=`${s}/`,W=await I(r,t.bucket,n,e.bucket,S);W.error?console.error(`Failed to copy folder marker: ${W.error}`):k=!0}}if(b===0&&k&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let n=t.path.split("/").pop(),l;e.path?e.path.endsWith("/")?l=`${e.path}${n}`:await C(e.bucket,e.path,r)?l=`${e.path}/${n}`:l=e.path:l=n,t.bucket===e.bucket&&t.path===l&&f("Source and destination are the same");let u=await I(r,t.bucket,t.path,e.bucket,l);u.error&&f(u.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${l}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${l}`)}}async function ht(i){let t=x(i,["src"]),e=x(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let r=!!x(i,["recursive","r"]);h=M(i)==="json";let p=ct(t,e),a=await K({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=v(e);o.bucket||f("Invalid destination path"),await ut(t,o,a,r);break}case"remote-to-local":{let o=v(t);o.bucket||f("Invalid source path"),await ft(t,o,e,a,r);break}case"remote-to-remote":{let o=v(t),n=v(e);o.bucket||f("Invalid source path"),n.bucket||f("Invalid destination path"),await mt(t,o,n,a,r);break}}process.exit(0)}export{ht as default};
package/dist/lib/mv.js CHANGED
@@ -1 +1 @@
1
- import{a as J}from"../chunk-EKW6XTGL.js";import{a as y}from"../chunk-IRDNZN7R.js";import{a as x,b as E}from"../chunk-S77OAN6Y.js";import{a as j,b as R,d as A,f as U,g as D,i as z}from"../chunk-RXNG56FL.js";import{d as T}from"../chunk-YN2TKPPT.js";import{a as w,b as O}from"../chunk-S6KFKBMY.js";import{a as n}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{get as L,head as Q,list as V,put as q,remove as I}from"@tigrisdata/storage";var d=!1;async function X(s){let c=w(s,["src"]),l=w(s,["dest"]),h=w(s,["yes","y","force","f"]),g=!!w(s,["recursive","r"]);d=O(s)==="json",(!c||!l)&&n("both src and dest arguments are required"),(!j(c)||!j(l))&&n("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=R(c),t=R(l);e.bucket||n("Invalid source path"),t.bucket||n("Invalid destination path");let P=c.endsWith("/");!e.path&&!P&&n("Cannot move a bucket. Provide a path within the bucket.");let a=await T({withCredentialProvider:!0}),f=e.path.includes("*"),m=e.path.endsWith("/")||!e.path&&P;if(!f&&!m&&e.path&&(m=await A(e.bucket,e.path,a)),m&&!f&&!g&&n("Source is a remote folder (not moved). Use -r to move recursively."),f||m){let r=f?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",i=!f&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",u=[t.path?.replace(/\/$/,"")||"",i].filter(Boolean).join("/"),B=u?`${u}/`:"";e.bucket===t.bucket&&r===B&&n("Source and destination are the same");let{items:_,error:N}=await z(e.bucket,r||void 0,a);N&&n(N);let b=_.filter(o=>o.name!==r);if(f){let o=e.path.split("/").pop(),p=U(o);b=b.filter(v=>{let $=r?v.name.slice(r.length):v.name;return!g&&$.includes("/")?!1:p.test($.split("/").pop())})}let{data:G}=await V({prefix:r,limit:1,config:{...a,bucket:e.bucket}}),F=r?G?.items?.some(o=>o.name===r):!1;if(b.length===0&&!F){console.log(d?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let H=b.length+(F?1:0);if(!h&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move ${H} object(s)?`))){d||console.log("Aborted");return}let k=0;for(let o of b){let p=r?o.name.slice(r.length):o.name,v=u?`${u}/${p}`:p,$=await C(a,e.bucket,o.name,t.bucket,v);$.error?console.error(`Failed to move ${o.name}: ${$.error}`):(d||console.log(`Moved t3://${e.bucket}/${o.name} -> t3://${t.bucket}/${v}`),k++)}let W=!1;if(F)if(u){let o=`${u}/`,p=await C(a,e.bucket,r,t.bucket,o);p.error?console.error(`Failed to move folder marker: ${p.error}`):W=!0}else{let{error:o}=await I(r,{config:{...a,bucket:e.bucket}});o?console.error(`Failed to remove source folder marker: ${o.message}`):W=!0}k===0&&W&&(k=1),console.log(d?JSON.stringify({action:"moved",count:k}):`Moved ${k} object(s)`)}else{let r=e.path.split("/").pop(),i;if(t.path?t.path.endsWith("/")?i=`${t.path}${r}`:await A(t.bucket,t.path,a)?i=`${t.path}/${r}`:i=t.path:i=r,e.bucket===t.bucket&&e.path===i&&n("Source and destination are the same"),!h&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){d||console.log("Aborted");return}let S=await C(a,e.bucket,e.path,t.bucket,i,!d);S.error&&n(S.error),console.log(d?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${i}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${i}`)}process.exit(0)}async function C(s,c,l,h,g,M=!1){if(l.endsWith("/")){let{error:r}=await q(g,"",{config:{...s,bucket:h}});if(r)return{error:r.message};let{error:i}=await I(l,{config:{...s,bucket:c}});return i?{error:`Copied but failed to delete source: ${i.message}`}:{}}let{data:e}=await Q(l,{config:{...s,bucket:c}}),t=e?.size,{data:P,error:a}=await L(l,"stream",{config:{...s,bucket:c}});if(a)return{error:a.message};let{error:f}=await q(g,P,{...J(t),onUploadProgress:M?({loaded:r})=>{if(t!==void 0&&t>0){let i=Math.round(r/t*100);process.stdout.write(`\rMoving: ${y(r)} / ${y(t)} (${i}%)`)}else process.stdout.write(`\rMoving: ${y(r)}`)}:void 0,config:{...s,bucket:h}});if(M&&process.stdout.write("\r"+" ".repeat(60)+"\r"),f)return{error:f.message};let{error:m}=await I(l,{config:{...s,bucket:c}});return m?{error:`Copied but failed to delete source: ${m.message}`}:{}}export{X as default};
1
+ import{a as x,b as M}from"../chunk-S77OAN6Y.js";import{a as E,b as j,d as R,f as T,g as D,i as J}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as w,b as N}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as G,list as H,move as L,put as Q,remove as C}from"@tigrisdata/storage";var d=!1;async function V(i){let a=w(i,["src"]),c=w(i,["dest"]),m=w(i,["yes","y","force","f"]),p=!!w(i,["recursive","r"]);d=N(i)==="json",(!a||!c)&&s("both src and dest arguments are required"),(!E(a)||!E(c))&&s("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(a),t=j(c);e.bucket||s("Invalid source path"),t.bucket||s("Invalid destination path");let g=a.endsWith("/");!e.path&&!g&&s("Cannot move a bucket. Provide a path within the bucket.");let l=await O({withCredentialProvider:!0}),h=e.path.includes("*"),y=e.path.endsWith("/")||!e.path&&g;if(!h&&!y&&e.path&&(y=await R(e.bucket,e.path,l)),y&&!h&&!p&&s("Source is a remote folder (not moved). Use -r to move recursively."),h||y){let r=h?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",n=!h&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",n].filter(Boolean).join("/"),U=f?`${f}/`:"";e.bucket===t.bucket&&r===U&&s("Source and destination are the same");let{items:q,error:I}=await J(e.bucket,r||void 0,l);I&&s(I);let b=q.filter(o=>o.name!==r);if(h){let o=e.path.split("/").pop(),u=T(o);b=b.filter(k=>{let $=r?k.name.slice(r.length):k.name;return!p&&$.includes("/")?!1:u.test($.split("/").pop())})}let{data:_}=await H({prefix:r,limit:1,config:{...l,bucket:e.bucket}}),S=r?_?.items?.some(o=>o.name===r):!1;if(b.length===0&&!S){console.log(d?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let z=b.length+(S?1:0);if(!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move ${z} object(s)?`))){d||console.log("Aborted");return}let v=0;for(let o of b){let u=r?o.name.slice(r.length):o.name,k=f?`${f}/${u}`:u,$=await A(l,e.bucket,o.name,t.bucket,k);$.error?console.error(`Failed to move ${o.name}: ${$.error}`):(d||console.log(`Moved t3://${e.bucket}/${o.name} -> t3://${t.bucket}/${k}`),v++)}let W=!1;if(S)if(f){let o=`${f}/`,u=await A(l,e.bucket,r,t.bucket,o);u.error?console.error(`Failed to move folder marker: ${u.error}`):W=!0}else{let{error:o}=await C(r,{config:{...l,bucket:e.bucket}});o?console.error(`Failed to remove source folder marker: ${o.message}`):W=!0}v===0&&W&&(v=1),console.log(d?JSON.stringify({action:"moved",count:v}):`Moved ${v} object(s)`)}else{let r=e.path.split("/").pop(),n;if(t.path?t.path.endsWith("/")?n=`${t.path}${r}`:await R(t.bucket,t.path,l)?n=`${t.path}/${r}`:n=t.path:n=r,e.bucket===t.bucket&&e.path===n&&s("Source and destination are the same"),!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){d||console.log("Aborted");return}let F=await A(l,e.bucket,e.path,t.bucket,n);F.error&&s(F.error),console.log(d?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${n}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${n}`)}process.exit(0)}async function A(i,a,c,m,p){if(c.endsWith("/")){let{error:t}=await Q(p,"",{config:{...i,bucket:m}});if(t)return{error:t.message};let{error:g}=await C(c,{config:{...i,bucket:a}});return g?{error:`Copied but failed to delete source: ${g.message}`}:{}}if(a===m){let{error:t}=await L(c,p,{config:{...i,bucket:a}});return t?{error:t.message}:{}}let{error:P}=await G(c,p,{srcBucket:a,destBucket:m,config:{...i,bucket:m}});if(P)return{error:P.message};let{error:e}=await C(c,{config:{...i,bucket:a}});return e?{error:`Copied but failed to delete source: ${e.message}`}:{}}export{V as default};
@@ -1 +1 @@
1
- import{a as h,b as j}from"../../chunk-S77OAN6Y.js";import{h as w}from"../../chunk-RXNG56FL.js";import{d as O}from"../../chunk-YN2TKPPT.js";import{a as c,b as x}from"../../chunk-S6KFKBMY.js";import{a as p,b as f,c as b,d as A}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as d,d as k,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{remove as E}from"@tigrisdata/storage";var t=y("objects","delete");async function F(n){l(t);let S=x(n),g=c(n,["bucket"]),v=c(n,["key"]),q=c(n,["yes","y","force"]);g||f(t,"Bucket name or path is required");let m=w(g),o=m.bucket,s=v||m.key||void 0;s||f(t,"Object key is required");let N=await O(),a=Array.isArray(s)?s:[s];if(!q&&(h("Use --yes to skip confirmation"),!await j(`Delete ${a.length} object(s) from '${o}'?`))){console.log("Aborted");return}let u=[],i=[];for(let e of a){let{error:r}=await E(e,{config:{...N,bucket:o}});r?(k(t,r.message,{key:e}),i.push({key:e,error:r.message})):(u.push(e),d(t,{key:e}))}if(S==="json"){let e=b(t,{bucket:o}),r={action:"deleted",bucket:o,keys:u,errors:i};e.length>0&&(r.nextActions=e),console.log(JSON.stringify(r))}i.length>0&&p(i[0].error,t),A(t,{bucket:o})}export{F as default};
1
+ import{a as V,b as N}from"../../chunk-S77OAN6Y.js";import{h as C}from"../../chunk-RXNG56FL.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as d,b as T}from"../../chunk-S6KFKBMY.js";import{a as w,b as o,c as O,d as S}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as $,d as j,j as M}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listVersions as H,remove as R}from"@tigrisdata/storage";var r=M("objects","delete");async function W(c){A(r);let K=T(c),b=d(c,["bucket"]),E=d(c,["key"]),F=d(c,["yes","y","force"]),a=d(c,["version-id","versionId"]),u=!!d(c,["all-versions","allVersions"]);b||o(r,"Bucket name or path is required"),a&&u&&o(r,"Cannot use --version-id with --all-versions");let h=C(b),s=h.bucket,m=E||h.key||void 0;m||o(r,"Object key is required");let I={...await q(),bucket:s},n=Array.isArray(m)?m:[m];a&&n.length>1&&o(r,"--version-id targets a single object; pass exactly one key");let f=[];if(u)for(let e of n){let t=0,g,v,p=!1;for(;;){let{data:l,error:x}=await H({prefix:e,...g?{keyMarker:g}:{},...v?{versionIdMarker:v}:{},config:I});x&&o(r,x);for(let i of l.versions)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);for(let i of l.deleteMarkers)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);if(p||!l.hasMore)break;l.nextKeyMarker||o(r,`listVersions reported more pages but no nextKeyMarker for key '${e}'`),g=l.nextKeyMarker,v=l.nextVersionIdMarker}t===0&&o(r,`No versions or delete markers found for key '${e}'`)}else if(a)f.push({key:n[0],versionId:a});else for(let e of n)f.push({key:e});if(!F){V("Use --yes to skip confirmation");let e=u?`Hard-delete ${f.length} version(s) and delete marker(s) for ${n.length} object(s) from '${s}'?`:a?`Hard-delete version '${a}' of '${n[0]}' from '${s}'?`:`Delete ${n.length} object(s) from '${s}'?`;if(!await N(e)){console.log("Aborted");return}}let y=[],k=[];for(let e of f){let{error:t}=await R(e.key,{...e.versionId?{versionId:e.versionId}:{},config:I});t?(j(r,t.message,e),k.push({...e,error:t.message})):(y.push(e),$(r,e))}if(K==="json"){let e=O(r,{bucket:s}),t={action:"deleted",bucket:s,keys:y.map(g=>g.key),deleted:y,errors:k};e.length>0&&(t.nextActions=e),console.log(JSON.stringify(t))}k.length>0&&w(k[0].error,r),S(r,{bucket:s})}export{W as default};
@@ -1 +1 @@
1
- import{h as k}from"../../chunk-RXNG56FL.js";import{d as j}from"../../chunk-YN2TKPPT.js";import{a as r,b}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as a,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{get as w}from"@tigrisdata/storage";import{createWriteStream as v,writeFileSync as q}from"fs";import{extname as T}from"path";import{Readable as S}from"stream";import{pipeline as x}from"stream/promises";var e=u("objects","get"),C=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function E(s,m){let l=T(m||s).toLowerCase();return C.has(l)?"string":"stream"}async function F(s){h(e);let m=b(s),p=r(s,["bucket"]),l=r(s,["key"]),t=r(s,["output","o","O"]),y=r(s,["mode","m","M"]),g=r(s,["snapshot-version","snapshotVersion","snapshot"]);p||c(e,"Bucket name or path is required");let{bucket:f,key:o}=k(p,l);o||c(e,"Object key is required");let d=await j();if((y||E(o,t))==="stream"){let{data:i,error:n}=await w(o,"stream",{...g?{snapshotVersion:g}:{},config:{...d,bucket:f}});if(n&&c(e,n),t){let O=v(t);await x(S.fromWeb(i),O),a(e,{key:o,output:t}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:f,key:o,output:t}))}else await x(S.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await w(o,"string",{...g?{snapshotVersion:g}:{},config:{...d,bucket:f}});n&&c(e,n),t?(q(t,i),a(e,{key:o,output:t}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:f,key:o,output:t}))):(console.log(i),a(e))}}export{F as default};
1
+ import{h as w}from"../../chunk-RXNG56FL.js";import{d as k}from"../../chunk-YN2TKPPT.js";import{a as r,b as j}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as a,j as b}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{get as S}from"@tigrisdata/storage";import{createWriteStream as q,writeFileSync as T}from"fs";import{extname as C}from"path";import{Readable as x}from"stream";import{pipeline as y}from"stream/promises";var e=b("objects","get"),E=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function F(t,m){let d=C(m||t).toLowerCase();return E.has(d)?"string":"stream"}async function N(t){u(e);let m=j(t),p=r(t,["bucket"]),d=r(t,["key"]),s=r(t,["output","o","O"]),v=r(t,["mode","m","M"]),g=r(t,["snapshot-version","snapshotVersion","snapshot"]),f=r(t,["version-id","versionId"]);p||c(e,"Bucket name or path is required");let{bucket:l,key:o}=w(p,d);o||c(e,"Object key is required");let h=await k();if((v||F(o,s))==="stream"){let{data:i,error:n}=await S(o,"stream",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});if(n&&c(e,n),s){let O=q(s);await y(x.fromWeb(i),O),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))}else await y(x.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await S(o,"string",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});n&&c(e,n),s?(T(s,i),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))):(console.log(i),a(e))}}export{N as default};
@@ -1 +1 @@
1
- import{a as h,f as k}from"../../chunk-IRDNZN7R.js";import{h as d}from"../../chunk-RXNG56FL.js";import{d as l}from"../../chunk-YN2TKPPT.js";import{a as i,b as g}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,j as p}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{head as O}from"@tigrisdata/storage";var e=p("objects","info");async function A(r){m(e);let b=g(r),c=i(r,["bucket"]),v=i(r,["key"]),s=i(r,["snapshot-version","snapshotVersion","snapshot"]);c||o(e,"Bucket name or path is required");let{bucket:a,key:n}=d(c,v);n||o(e,"Object key is required");let y=await l(),{data:t,error:f}=await O(n,{...s?{snapshotVersion:s}:{},config:{...y,bucket:a}});f&&o(e,f),t||o(e,"Object not found");let S=[{metric:"Path",value:t.path},{metric:"Size",value:h(t.size)},{metric:"Content-Type",value:t.contentType||"N/A"},{metric:"Content-Disposition",value:t.contentDisposition||"N/A"},{metric:"Modified",value:t.modified.toISOString()},{metric:"URL",value:t.url}],j=k(S,b,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(j),u(e,{bucket:a,key:n})}export{A as default};
1
+ import{a as h,f as k}from"../../chunk-IRDNZN7R.js";import{h as v}from"../../chunk-RXNG56FL.js";import{d as l}from"../../chunk-YN2TKPPT.js";import{a as i,b as d}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as p,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{head as A}from"@tigrisdata/storage";var e=g("objects","info");async function I(o){u(e);let b=d(o),s=i(o,["bucket"]),y=i(o,["key"]),c=i(o,["snapshot-version","snapshotVersion","snapshot"]),a=i(o,["version-id","versionId"]);s||r(e,"Bucket name or path is required");let{bucket:f,key:n}=v(s,y);n||r(e,"Object key is required");let S=await l(),{data:t,error:m}=await A(n,{...c?{snapshotVersion:c}:{},...a?{versionId:a}:{},config:{...S,bucket:f}});m&&r(e,m),t||r(e,"Object not found");let j=[{metric:"Path",value:t.path},{metric:"Size",value:h(t.size)},{metric:"Content-Type",value:t.contentType||"N/A"},{metric:"Content-Disposition",value:t.contentDisposition||"N/A"},{metric:"Modified",value:t.modified.toISOString()},{metric:"URL",value:t.url}],O=k(j,b,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(O),p(e,{bucket:f,key:n})}export{I as default};
@@ -0,0 +1,6 @@
1
+ import{a as K,b as w,d as l,e as d}from"../../chunk-IRDNZN7R.js";import{e as C}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as o,b as I,c as V}from"../../chunk-S6KFKBMY.js";import{b as a}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as u,e as x,j as v}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listVersions as D}from"@tigrisdata/storage";var i=v("objects","list-versions");async function O(s){p(i);let k=o(s,["bucket"]),z=o(s,["prefix","p","P"]),m=o(s,["delimiter","d"]),c=o(s,["key-marker","keyMarker"]),f=o(s,["version-id-marker","versionIdMarker"]),g=I(s),{limit:y}=V(s);k||a(i,"Bucket name is required");let M=C(k),P=M.bucket,S=z||M.path||void 0,j=await b(),{data:r,error:h}=await D({prefix:S,...m?{delimiter:m}:{},...y!==void 0?{limit:y}:{},...c?{keyMarker:c}:{},...f?{versionIdMarker:f}:{},config:{...j,bucket:P}});h&&a(i,h);let t=r.versions.map(e=>({key:e.name,versionId:e.versionId,latest:e.isLatest?"yes":"",size:K(e.size),modified:e.lastModified})),n=r.deleteMarkers.map(e=>({key:e.name,versionId:e.versionId,latest:e.isLatest?"yes":"",modified:e.lastModified})),L=[{key:"key",header:"Key"},{key:"versionId",header:"Version ID"},{key:"latest",header:"Latest"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}],T=[{key:"key",header:"Key"},{key:"versionId",header:"Version ID"},{key:"latest",header:"Latest"},{key:"modified",header:"Modified"}];if(g==="json")console.log(w({versions:r.versions,deleteMarkers:r.deleteMarkers,commonPrefixes:r.commonPrefixes,nextKeyMarker:r.nextKeyMarker,nextVersionIdMarker:r.nextVersionIdMarker,hasMore:r.hasMore}));else if(g==="xml"){let e=["<listVersions>"];e.push(" "+l(t,"versions","version").replace(/\n/g,`
2
+ `)),e.push(" "+l(n,"deleteMarkers","deleteMarker").replace(/\n/g,`
3
+ `)),e.push("</listVersions>"),console.log(e.join(`
4
+ `))}else{if(t.length===0&&n.length===0){x(i);return}if(t.length>0&&(console.log(`
5
+ Versions`),console.log(d(t,L))),n.length>0&&(console.log("Delete Markers"),console.log(d(n,T))),r.hasMore&&r.nextKeyMarker){let e=`
6
+ Next page: --key-marker "${r.nextKeyMarker}"`;r.nextVersionIdMarker&&(e+=` --version-id-marker "${r.nextVersionIdMarker}"`),console.error(e)}}u(i,{versions:t.length,deleteMarkers:n.length})}export{O as default};
@@ -1 +1 @@
1
- import{a as R}from"../../chunk-EKW6XTGL.js";import{a,f as A}from"../../chunk-IRDNZN7R.js";import{h as j}from"../../chunk-RXNG56FL.js";import{d as w}from"../../chunk-YN2TKPPT.js";import{a as s,b as T}from"../../chunk-S6KFKBMY.js";import{b as i,d as z}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as S,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{put as W}from"@tigrisdata/storage";import{createReadStream as B,statSync as E}from"fs";import{Readable as v}from"stream";var t=h("objects","put");async function M(e){k(t);let u=s(e,["bucket"]),l=s(e,["key"]),g=s(e,["file"]),O=s(e,["access","a","A"],"private"),P=s(e,["content-type","contentType","t","T"]),$=T(e);u||i(t,"Bucket name or path is required");let d=j(u),m=d.bucket,n=d.key||l,r=d.key&&l||g;n||i(t,"Object key is required");let q=!process.stdin.isTTY;!r&&!q&&i(t,"File path is required (or pipe data via stdin)");let f,o;if(r){try{o=E(r).size}catch{i(t,`File not found: ${r}`)}let p=B(r);f=v.toWeb(p)}else f=v.toWeb(process.stdin);let U=await w({withCredentialProvider:!0}),x=r?R(o):{multipart:!0,partSize:5*1024*1024,queueSize:8},{data:c,error:b}=await W(n,f,{access:O==="public"?"public":"private",contentType:P,...x,onUploadProgress:({loaded:p,percentage:y})=>{o!==void 0&&o>0?process.stdout.write(`\rUploading: ${a(p)} / ${a(o)} (${y}%)`):process.stdout.write(`\rUploading: ${a(p)}`)},config:{...U,bucket:m}});process.stdout.write("\r"+" ".repeat(60)+"\r"),b&&i(t,b);let C=[{path:c.path,size:a(c.size??o??0),contentType:c.contentType||"-",modified:c.modified}],F=A(C,$,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(F),S(t,{key:n,bucket:m}),z(t,{key:n,bucket:m})}export{M as default};
1
+ import{a as R}from"../../chunk-EKW6XTGL.js";import{a as A}from"../../chunk-HPICBIXL.js";import{a as s,f as v}from"../../chunk-IRDNZN7R.js";import{h as j}from"../../chunk-RXNG56FL.js";import{d as w}from"../../chunk-YN2TKPPT.js";import{a as n,b as z}from"../../chunk-S6KFKBMY.js";import{b as i,d as T}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as S,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{put as E}from"@tigrisdata/storage";import{createReadStream as M,statSync as N}from"fs";import{Readable as C}from"stream";var t=h("objects","put");async function Y(r){k(t);let u=n(r,["bucket"]),l=n(r,["key"]),y=n(r,["file"]),O=n(r,["access","a","A"],"private"),P=n(r,["content-type","contentType","t","T"]),$=z(r);u||i(t,"Bucket name or path is required");let d=j(u),m=d.bucket,a=d.key||l,e=d.key&&l||y;a||i(t,"Object key is required");let q=!process.stdin.isTTY;!e&&!q&&i(t,"File path is required (or pipe data via stdin)");let f,o;if(e){try{o=N(e).size}catch{i(t,`File not found: ${e}`)}let p=M(e);f=C.toWeb(p)}else f=C.toWeb(process.stdin);let U=await w({withCredentialProvider:!0}),x=e?R(o):{multipart:!0,partSize:5*1024*1024,queueSize:8},F=P??(e?A(e):void 0),{data:c,error:g}=await E(a,f,{access:O==="public"?"public":"private",contentType:F,...x,onUploadProgress:({loaded:p,percentage:b})=>{o!==void 0&&o>0?process.stdout.write(`\rUploading: ${s(p)} / ${s(o)} (${b}%)`):process.stdout.write(`\rUploading: ${s(p)}`)},config:{...U,bucket:m}});process.stdout.write("\r"+" ".repeat(60)+"\r"),g&&i(t,g);let W=[{path:c.path,size:s(c.size??o??0),contentType:c.contentType||"-",modified:c.modified}],B=v(W,$,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(B),S(t,{key:a,bucket:m}),T(t,{key:a,bucket:m})}export{Y as default};
@@ -0,0 +1 @@
1
+ import{h as l}from"../../chunk-RXNG56FL.js";import{d as k}from"../../chunk-YN2TKPPT.js";import{a as o,b}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,j as p}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{setObjectAccess as v}from"@tigrisdata/storage";var e=p("objects","set-access");async function j(r){m(e);let d=b(r),a=o(r,["bucket"]),f=o(r,["key"]),y=o(r,["access"]);a||c(e,"Bucket name or path is required");let i=l(a),n=i.bucket,s=i.key||f,t=i.key?f:y;s||c(e,"Object key is required"),t||c(e,"Access level is required (public or private)"),t!=="public"&&t!=="private"&&c(e,'Access level must be either "public" or "private"');let A=await k(),{error:g}=await v(s,{access:t,config:{...A,bucket:n}});g&&c(e,g),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:s,access:t})),u(e,{key:s,bucket:n,access:t})}export{j as default};
@@ -1 +1 @@
1
- import{h as k}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as c,b as p}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as g,c as m,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateObject as j}from"@tigrisdata/storage";var e=u("objects","set");async function w(t){g(e);let l=p(t),a=c(t,["bucket"]),y=c(t,["key"]),s=c(t,["access","a","A"]),i=c(t,["new-key","n","newKey"]);a||r(e,"Bucket name or path is required");let{bucket:n,key:o}=k(a,y);o||r(e,"Object key is required"),s||r(e,"Access level is required (--access public|private)");let d=await b(),{error:f}=await j(o,{access:s==="public"?"public":"private",...i&&{key:i},config:{...d,bucket:n}});f&&r(e,f),l==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:o,access:s,...i?{newKey:i}:{}})),m(e,{key:o,bucket:n})}export{w as default};
1
+ import{h as d}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as i,b as y}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as k,j as l}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{move as v,setObjectAccess as A}from"@tigrisdata/storage";var e=l("objects","set");async function O(r){p(e);let w=y(r),f=i(r,["bucket"]),j=i(r,["key"]),s=i(r,["access","a","A"]),c=i(r,["new-key","n","newKey"]);f||t(e,"Bucket name or path is required");let{bucket:n,key:a}=d(f,j);a||t(e,"Object key is required"),s||t(e,"Access level is required (--access public|private)");let g={...await b(),bucket:n},o=a;if(c){let{error:u}=await v(a,c,{config:g});u&&t(e,u),o=c}let{error:m}=await A(o,{access:s==="public"?"public":"private",config:g});m&&t(e,m),w==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:o,access:s,...c?{newKey:c}:{}})),k(e,{key:o,bucket:n})}export{O as default};
package/dist/lib/stat.js CHANGED
@@ -1 +1 @@
1
- import{c as w}from"../chunk-HWX63Y3P.js";import{a as d,f as c}from"../chunk-IRDNZN7R.js";import{e as j}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as g,b}from"../chunk-S6KFKBMY.js";import{b as i}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as k,c as n,j as y}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{getBucketInfo as A,getStats as I,head as M}from"@tigrisdata/storage";var t=y("stat");async function z(u){k(t);let h=g(u,["path"]),m=b(u),v=g(u,["snapshot-version","snapshotVersion","snapshot"]),f=await O();if(!h){let{data:o,error:r}=await I({config:f});r&&i(t,r);let p=[{metric:"Active Buckets",value:String(o.stats.activeBuckets)},{metric:"Total Objects",value:String(o.stats.totalObjects)},{metric:"Total Unique Objects",value:String(o.stats.totalUniqueObjects)},{metric:"Total Storage",value:d(o.stats.totalStorageBytes)}],l=c(p,m,"stats","stat",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(l),n(t),process.exit(0)}let{bucket:a,path:s}=j(h);if(a||i(t,"Invalid path"),!s||s==="/"){let{data:o,error:r}=await A(a,{config:f});r&&i(t,r);let p=w(o).map(({label:T,value:V})=>({metric:T,value:V})),l=c(p,m,"bucket-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(l),n(t,{bucket:a}),process.exit(0)}let{data:e,error:S}=await M(s,{...v?{snapshotVersion:v}:{},config:{...f,bucket:a}});S&&i(t,S),e||i(t,"Object not found");let x=[{metric:"Path",value:e.path},{metric:"Size",value:d(e.size)},{metric:"Content-Type",value:e.contentType||"N/A"},{metric:"Content-Disposition",value:e.contentDisposition||"N/A"},{metric:"Modified",value:e.modified.toISOString()}],B=c(x,m,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(B),n(t,{bucket:a,path:s}),process.exit(0)}export{z as default};
1
+ import{c as w}from"../chunk-HWX63Y3P.js";import{a as d,f as m}from"../chunk-IRDNZN7R.js";import{e as I}from"../chunk-RXNG56FL.js";import{d as j}from"../chunk-YN2TKPPT.js";import{a as u,b as O}from"../chunk-S6KFKBMY.js";import{b as i}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as y,c,j as b}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{getBucketInfo as A,getStats as M,head as z}from"@tigrisdata/storage";var t=b("stat");async function C(s){y(t);let h=u(s,["path"]),f=O(s),v=u(s,["snapshot-version","snapshotVersion","snapshot"]),S=u(s,["version-id","versionId"]),l=await j();if(!h){let{data:o,error:a}=await M({config:l});a&&i(t,a);let p=[{metric:"Active Buckets",value:String(o.stats.activeBuckets)},{metric:"Total Objects",value:String(o.stats.totalObjects)},{metric:"Total Unique Objects",value:String(o.stats.totalUniqueObjects)},{metric:"Total Storage",value:d(o.stats.totalStorageBytes)}],g=m(p,f,"stats","stat",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(g),c(t),process.exit(0)}let{bucket:r,path:n}=I(h);if(r||i(t,"Invalid path"),!n||n==="/"){let{data:o,error:a}=await A(r,{config:l});a&&i(t,a);let p=w(o).map(({label:T,value:V})=>({metric:T,value:V})),g=m(p,f,"bucket-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(g),c(t,{bucket:r}),process.exit(0)}let{data:e,error:k}=await z(n,{...v?{snapshotVersion:v}:{},...S?{versionId:S}:{},config:{...l,bucket:r}});k&&i(t,k),e||i(t,"Object not found");let x=[{metric:"Path",value:e.path},{metric:"Size",value:d(e.size)},{metric:"Content-Type",value:e.contentType||"N/A"},{metric:"Content-Disposition",value:e.contentDisposition||"N/A"},{metric:"Modified",value:e.modified.toISOString()}],B=m(x,f,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(B),c(t,{bucket:r,path:n}),process.exit(0)}export{C as default};
@@ -1 +1 @@
1
- import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-ZP77TNW7.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};
1
+ import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-GNWZ7PX2.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};
package/dist/specs.yaml CHANGED
@@ -396,6 +396,8 @@ commands:
396
396
  - name: snapshot-version
397
397
  description: Read from a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464)
398
398
  alias: snapshot
399
+ - name: version-id
400
+ description: Object version id to stat (requires bucket versioning). Omit to stat the latest version
399
401
 
400
402
  # presign
401
403
  - name: presign
@@ -1248,6 +1250,44 @@ commands:
1248
1250
  - name: source
1249
1251
  description: List objects from a specific storage source on buckets with shadow migration enabled
1250
1252
  options: [tigris, shadow]
1253
+ # list-versions
1254
+ - name: list-versions
1255
+ description: List object versions and delete markers in a bucket (requires bucket versioning). Returns both arrays separately to match the S3 ListObjectVersions response
1256
+ alias: lv
1257
+ examples:
1258
+ - "tigris objects list-versions my-bucket"
1259
+ - "tigris objects list-versions t3://my-bucket/logs/"
1260
+ - "tigris objects list-versions my-bucket --prefix images/"
1261
+ - "tigris objects list-versions my-bucket --format json"
1262
+ messages:
1263
+ onStart: 'Listing object versions...'
1264
+ onSuccess: 'Found {{versions}} version(s) and {{deleteMarkers}} delete marker(s)'
1265
+ onFailure: 'Failed to list object versions'
1266
+ onEmpty: 'No versions or delete markers found'
1267
+ arguments:
1268
+ - name: bucket
1269
+ description: Name of the bucket, or a path with optional prefix (t3://bucket/prefix/)
1270
+ type: positional
1271
+ required: true
1272
+ examples:
1273
+ - my-bucket
1274
+ - t3://my-bucket/images/
1275
+ - name: prefix
1276
+ description: Filter by key prefix
1277
+ alias: p
1278
+ - name: delimiter
1279
+ description: Group keys sharing a common prefix up to the delimiter (e.g. "/" for folder-style grouping)
1280
+ alias: d
1281
+ - name: format
1282
+ description: Output format
1283
+ options: [json, table, xml]
1284
+ default: table
1285
+ - name: limit
1286
+ description: Maximum number of items to return per page
1287
+ - name: key-marker
1288
+ description: Pagination marker — the key to start listing from (from a prior nextKeyMarker)
1289
+ - name: version-id-marker
1290
+ description: Pagination marker — the version id to start listing from (from a prior nextVersionIdMarker)
1251
1291
  # get
1252
1292
  - name: get
1253
1293
  description: Download an object by key. Prints to stdout by default, or saves to a file with --output
@@ -1283,6 +1323,8 @@ commands:
1283
1323
  - name: snapshot-version
1284
1324
  description: Read from a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464)
1285
1325
  alias: snapshot
1326
+ - name: version-id
1327
+ description: Object version id to download (requires bucket versioning). Omit to download the latest version
1286
1328
  # put
1287
1329
  - name: put
1288
1330
  description: Upload a local file as an object. Content-type is auto-detected from extension unless overridden
@@ -1330,12 +1372,14 @@ commands:
1330
1372
  default: table
1331
1373
  # delete
1332
1374
  - name: delete
1333
- description: Delete one or more objects by key from the given bucket
1375
+ description: Delete one or more objects by key from the given bucket. On a versioned bucket, the default creates a delete marker; use --version-id or --all-versions to hard-delete versions
1334
1376
  alias: d
1335
1377
  examples:
1336
1378
  - "tigris objects delete my-bucket old-file.txt --yes"
1337
1379
  - "tigris objects delete t3://my-bucket/old-file.txt --yes"
1338
1380
  - "tigris objects delete my-bucket file-a.txt,file-b.txt --yes"
1381
+ - "tigris objects delete my-bucket old-file.txt --version-id abc123 --yes"
1382
+ - "tigris objects delete my-bucket old-file.txt --all-versions --yes"
1339
1383
  messages:
1340
1384
  onStart: 'Deleting object...'
1341
1385
  onSuccess: "Object '{{key}}' deleted successfully"
@@ -1357,13 +1401,19 @@ commands:
1357
1401
  multiple: true
1358
1402
  examples:
1359
1403
  - my-file.txt
1404
+ - name: version-id
1405
+ description: Hard-delete a specific object version (requires bucket versioning). Targets a single key
1406
+ - name: all-versions
1407
+ description: Hard-delete every version and delete marker for the given key(s). Mutually exclusive with --version-id
1408
+ type: flag
1360
1409
  - name: force
1361
1410
  type: flag
1362
1411
  description: Skip confirmation prompts (alias for --yes)
1363
- # set
1412
+ # set (deprecated)
1364
1413
  - name: set
1365
- description: Update settings on an existing object such as access level
1414
+ description: (Deprecated) Update settings on an existing object such as access level. Use `tigris objects set-access` for ACL changes and `tigris mv` to rename
1366
1415
  alias: s
1416
+ deprecated: true
1367
1417
  examples:
1368
1418
  - "tigris objects set my-bucket my-file.txt --access public"
1369
1419
  - "tigris objects set t3://my-bucket/my-file.txt --access public"
@@ -1372,6 +1422,7 @@ commands:
1372
1422
  onStart: 'Updating object...'
1373
1423
  onSuccess: "Object '{{key}}' updated successfully"
1374
1424
  onFailure: 'Failed to update object'
1425
+ onDeprecated: 'tigris objects set is deprecated. Use `tigris objects set-access` for ACL changes and `tigris mv` to rename objects. This command will be removed in a future release.'
1375
1426
  arguments:
1376
1427
  - name: bucket
1377
1428
  description: Name of the bucket, or a full path (t3://bucket/key)
@@ -1388,6 +1439,33 @@ commands:
1388
1439
  - name: new-key
1389
1440
  description: Rename the object to a new key
1390
1441
  alias: n
1442
+ # set-access
1443
+ - name: set-access
1444
+ description: Set the access level (public or private) on an existing object
1445
+ alias: sa
1446
+ examples:
1447
+ - "tigris objects set-access my-bucket my-file.txt public"
1448
+ - "tigris objects set-access t3://my-bucket/my-file.txt private"
1449
+ messages:
1450
+ onStart: 'Updating object access...'
1451
+ onSuccess: "Access for '{{key}}' updated to {{access}}"
1452
+ onFailure: 'Failed to update object access'
1453
+ arguments:
1454
+ - name: bucket
1455
+ description: Name of the bucket, or a full path (t3://bucket/key)
1456
+ type: positional
1457
+ required: true
1458
+ - name: key
1459
+ description: Key of the object (omit if bucket contains the full path)
1460
+ type: positional
1461
+ - name: access
1462
+ description: Access level (public or private)
1463
+ type: positional
1464
+ options: *access_options
1465
+ - name: format
1466
+ description: Output format
1467
+ options: [json, table, xml]
1468
+ default: table
1391
1469
  # info
1392
1470
  - name: info
1393
1471
  description: Show metadata for an object (content type, size, modified date)
@@ -1396,6 +1474,7 @@ commands:
1396
1474
  - "tigris objects info my-bucket report.pdf"
1397
1475
  - "tigris objects info t3://my-bucket/report.pdf"
1398
1476
  - "tigris objects info my-bucket report.pdf --format json"
1477
+ - "tigris objects info my-bucket report.pdf --version-id abc123"
1399
1478
  messages:
1400
1479
  onStart: ''
1401
1480
  onSuccess: ''
@@ -1415,6 +1494,8 @@ commands:
1415
1494
  - name: snapshot-version
1416
1495
  description: Read from a specific bucket snapshot
1417
1496
  alias: snapshot
1497
+ - name: version-id
1498
+ description: Object version id (requires bucket versioning). Omit to read the latest version
1418
1499
 
1419
1500
  #########################
1420
1501
  # Manage access keys
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-HPICBIXL.js";export{a as getContentType};
@@ -1 +1 @@
1
- import{b as a,c as b,d as c,e as d,f as e}from"../chunk-ZP77TNW7.js";import"../chunk-ATBINUDP.js";export{e as checkForUpdates,d as fetchLatestVersion,c as getUpdateCommand,b as isNewerVersion,a as readUpdateCache};
1
+ import{b as a,c as b,d as c,e as d,f as e}from"../chunk-GNWZ7PX2.js";import"../chunk-ATBINUDP.js";export{e as checkForUpdates,d as fetchLatestVersion,c as getUpdateCommand,b as isNewerVersion,a as readUpdateCache};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigrisdata/cli",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
@@ -103,7 +103,7 @@
103
103
  "@aws-sdk/credential-providers": "^3.1038.0",
104
104
  "@smithy/shared-ini-file-loader": "^4.4.9",
105
105
  "@tigrisdata/iam": "^2.1.1",
106
- "@tigrisdata/storage": "^3.4.0",
106
+ "@tigrisdata/storage": "^3.6.0",
107
107
  "commander": "^14.0.3",
108
108
  "enquirer": "^2.4.1",
109
109
  "jose": "^6.2.3",
@@ -1,8 +0,0 @@
1
- import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.0.0-beta.1";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
2
- ${s}
3
- ${o("")}
4
- ${o(r)}
5
- ${o(t)}
6
- ${o("")}
7
- ${l}
8
- `),v({...e,lastNotified:Date.now()})}let a=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||216e5;(!e||Date.now()-e.lastChecked>a)&&j()}export{u as a,y as b,T as c,M as d,k as e,O as f};