@tigrisdata/cli 2.18.1-beta.1 → 3.0.0-beta.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.
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-UJFCUY34.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-K4QARFBT.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 @@
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};
@@ -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-beta.2";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};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-MX5N556B.js";import"./chunk-UJFCUY34.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-ABUCZZSA.js";import"./chunk-K4QARFBT.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-MX5N556B.js";import"./chunk-UJFCUY34.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-ABUCZZSA.js";import"./chunk-K4QARFBT.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 D}from"../chunk-SAAGVLRE.js";import{a as _}from"../chunk-HPICBIXL.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as N,d as v,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 m}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 X,head as Y,list as et,put as E}from"@tigrisdata/storage";import{createReadStream as ot,createWriteStream as it,existsSync as Z,mkdirSync as nt,readdirSync as z,statSync as L}from"fs";import{homedir as rt}from"os";import{basename as M,dirname as K,join as T,relative as H,resolve as Q}from"path";import{Readable as P}from"stream";import{pipeline as at}from"stream/promises";var h=!1;function lt(n,t){let e=U(n),r=U(t);return!e&&!r&&m("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 tt(n){return n==="~"||n.startsWith("~/")?Q(rt(),n.slice(2)):Q(n)}function ct(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let r=e.parentPath??e.path;return T(r,e.name)})}function st(n,t){let e=K(n),r=M(n),s=O(r);return Z(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&s.test(a.name)).map(a=>{let o=a.parentPath??a.path;return T(o,a.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>T(e,o.name)):[]}async function I(n,t,e,r,s=!1){let f;try{f=L(n).size}catch{return{error:`File not found: ${n}`}}let a=ot(n),o=P.toWeb(a),i=_(n),{error:l}=await E(e,o,{...B(f),...i?{contentType:i}:{},onUploadProgress:s?({loaded:p})=>{if(f!==void 0&&f>0){let c=Math.round(p/f*100);process.stdout.write(`\rUploading: ${w(p)} / ${w(f)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(p)}`)}:void 0,config:{...r,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function V(n,t,e,r,s=!1){let f;if(s){let{data:c}=await Y(t,{config:{...r,bucket:n}});f=c?.size}let{data:a,error:o}=await X(t,"stream",{config:{...r,bucket:n}});if(o)return{error:o.message};let i=K(e);Z(i)||nt(i,{recursive:!0});let l=it(e),p=P.fromWeb(a);if(s&&f!==void 0&&f>0){let c=0;p.on("data",u=>{c+=u.length;let g=Math.round(c/f*100);process.stdout.write(`\rDownloading: ${w(c)} / ${w(f)} (${g}%)`)})}return await at(p,l),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,r,s,f=!1){if(e.endsWith("/")){let{error:u}=await E(s,"",{config:{...n,bucket:r}});return u?{error:u.message}:{}}let{data:a}=await Y(e,{config:{...n,bucket:t}}),o=a?.size,i=a?.contentType,{data:l,error:p}=await X(e,"stream",{config:{...n,bucket:t}});if(p)return{error:p.message};let{error:c}=await E(s,l,{...B(o),...i?{contentType:i}:{},onUploadProgress:f?({loaded:u})=>{if(o!==void 0&&o>0){let g=Math.round(u/o*100);process.stdout.write(`\rCopying: ${w(u)} / ${w(o)} (${g}%)`)}else process.stdout.write(`\rCopying: ${w(u)}`)}:void 0,config:{...n,bucket:r}});return f&&process.stdout.write("\r"+" ".repeat(60)+"\r"),c?{error:c.message}:{}}async function pt(n,t,e,r){let s=tt(n);if(n.includes("*")){let o=st(s,r);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),l=o.map(u=>async()=>{let g=H(i,u),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,y=await I(u,t.bucket,k,e);return y.error?(console.error(`Failed to upload ${u}: ${y.error}`),!1):(h||console.log(`Uploaded ${u} -> t3://${t.bucket}/${k}`),!0)}),c=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:c}):`Uploaded ${c} file(s)`);return}let a;try{a=L(s)}catch{m(`Source not found: ${n}`)}if(a.isDirectory()){r||m(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=ct(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),l=o.map(u=>async()=>{let g=H(s,u),y=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(u,t.bucket,y,e);return R.error?(console.error(`Failed to upload ${u}: ${R.error}`),!1):(h||console.log(`Uploaded ${u} -> t3://${t.bucket}/${y}`),!0)}),c=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:c}):`Uploaded ${c} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await v(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let l=await I(s,t.bucket,i,e,!h);l.error&&m(l.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 ut(n,t,e,r,s){let f=n.endsWith("/");!t.path&&!f&&m("Cannot copy a bucket. Provide a path within the bucket.");let a=tt(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&f;if(!o&&!i&&(i=await v(t.bucket,t.path,r)),i&&!o&&!s&&m("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let l=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",p=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:c,error:u}=await j(t.bucket,l||void 0,r);u&&m(u);let g=c.filter($=>!$.name.endsWith("/"));if(o){let $=t.path.split("/").pop(),b=O($);g=g.filter(S=>{let d=l?S.name.slice(l.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($=>async()=>{let b=l?$.name.slice(l.length):$.name,S=p?T(a,p,b):T(a,b),d=await V(t.bucket,$.name,S,r);return d.error?(console.error(`Failed to download ${$.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${$.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 l=t.path.split("/").pop(),p,c=!1;try{c=L(a).isDirectory()}catch{}c||e.endsWith("/")?p=T(a,l):p=a;let u=await V(t.bucket,t.path,p,r,!h);u.error&&m(u.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:p}):`Downloaded t3://${t.bucket}/${t.path} -> ${p}`)}}async function ft(n,t,e,r,s){let f=n.endsWith("/");!t.path&&!f&&m("Cannot copy a bucket. Provide a path within the bucket.");let a=n.includes("*"),o=t.path.endsWith("/")||!t.path&&f;if(!a&&!o&&t.path&&(o=await v(t.bucket,t.path,r)),o&&!a&&!s&&m("Source is a remote folder (not copied). Use -r to copy recursively."),a||o){let i=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()??"":"",c=[e.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),u=c?`${c}/`:"";t.bucket===e.bucket&&i===u&&m("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,r);k&&m(k);let y=g.filter(d=>d.name!==i);if(a){let d=t.path.split("/").pop(),W=O(d);y=y.filter(F=>{let C=i?F.name.slice(i.length):F.name;return!s&&C.includes("/")?!1:W.test(C.split("/").pop())})}let R=y.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=c?`${c}/${W}`:W,C=await A(r,t.bucket,d.name,e.bucket,F);return C.error?(console.error(`Failed to copy ${d.name}: ${C.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(c&&i){let{data:d}=await et({prefix:i,limit:1,config:{...r,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${c}/`,F=await A(r,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(),l;e.path?e.path.endsWith("/")?l=`${e.path}${i}`:await v(e.bucket,e.path,r)?l=`${e.path}/${i}`:l=e.path:l=i,t.bucket===e.bucket&&t.path===l&&m("Source and destination are the same");let p=await A(r,t.bucket,t.path,e.bucket,l,!h);p.error&&m(p.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 mt(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&m("Both src and dest arguments are required");let r=!!x(n,["recursive","r"]);h=q(n)==="json";let f=lt(t,e),a=await G({withCredentialProvider:!0});switch(f){case"local-to-remote":{let o=N(e);o.bucket||m("Invalid destination path"),await pt(t,o,a,r);break}case"remote-to-local":{let o=N(t);o.bucket||m("Invalid source path"),await ut(t,o,e,a,r);break}case"remote-to-remote":{let o=N(t),i=N(e);o.bucket||m("Invalid source path"),i.bucket||m("Invalid destination path"),await ft(t,o,i,a,r);break}}process.exit(0)}export{mt 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 J}from"../chunk-EKW6XTGL.js";import{a as M}from"../chunk-IRDNZN7R.js";import{a as x,b as E}from"../chunk-S77OAN6Y.js";import{a as T,b as j,d as C,f as U,g as D,i as z}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as P,b as N}from"../chunk-S6KFKBMY.js";import{a}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 A}from"@tigrisdata/storage";var m=!1;async function X(s){let c=P(s,["src"]),l=P(s,["dest"]),g=P(s,["yes","y","force","f"]),b=!!P(s,["recursive","r"]);m=N(s)==="json",(!c||!l)&&a("both src and dest arguments are required"),(!T(c)||!T(l))&&a("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(c),t=j(l);e.bucket||a("Invalid source path"),t.bucket||a("Invalid destination path");let k=c.endsWith("/");!e.path&&!k&&a("Cannot move a bucket. Provide a path within the bucket.");let n=await O({withCredentialProvider:!0}),f=e.path.includes("*"),p=e.path.endsWith("/")||!e.path&&k;if(!f&&!p&&e.path&&(p=await C(e.bucket,e.path,n)),p&&!f&&!b&&a("Source is a remote folder (not moved). Use -r to move recursively."),f||p){let o=f?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",r=!f&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",d=[t.path?.replace(/\/$/,"")||"",r].filter(Boolean).join("/"),B=d?`${d}/`:"";e.bucket===t.bucket&&o===B&&a("Source and destination are the same");let{items:_,error:I}=await z(e.bucket,o||void 0,n);I&&a(I);let v=_.filter(i=>i.name!==o);if(f){let i=e.path.split("/").pop(),h=U(i);v=v.filter(w=>{let y=o?w.name.slice(o.length):w.name;return!b&&y.includes("/")?!1:h.test(y.split("/").pop())})}let{data:G}=await V({prefix:o,limit:1,config:{...n,bucket:e.bucket}}),F=o?G?.items?.some(i=>i.name===o):!1;if(v.length===0&&!F){console.log(m?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let H=v.length+(F?1:0);if(!g&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move ${H} object(s)?`))){m||console.log("Aborted");return}let $=0;for(let i of v){let h=o?i.name.slice(o.length):i.name,w=d?`${d}/${h}`:h,y=await R(n,e.bucket,i.name,t.bucket,w);y.error?console.error(`Failed to move ${i.name}: ${y.error}`):(m||console.log(`Moved t3://${e.bucket}/${i.name} -> t3://${t.bucket}/${w}`),$++)}let W=!1;if(F)if(d){let i=`${d}/`,h=await R(n,e.bucket,o,t.bucket,i);h.error?console.error(`Failed to move folder marker: ${h.error}`):W=!0}else{let{error:i}=await A(o,{config:{...n,bucket:e.bucket}});i?console.error(`Failed to remove source folder marker: ${i.message}`):W=!0}$===0&&W&&($=1),console.log(m?JSON.stringify({action:"moved",count:$}):`Moved ${$} object(s)`)}else{let o=e.path.split("/").pop(),r;if(t.path?t.path.endsWith("/")?r=`${t.path}${o}`:await C(t.bucket,t.path,n)?r=`${t.path}/${o}`:r=t.path:r=o,e.bucket===t.bucket&&e.path===r&&a("Source and destination are the same"),!g&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){m||console.log("Aborted");return}let u=await R(n,e.bucket,e.path,t.bucket,r,!m);u.error&&a(u.error),console.log(m?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${r}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${r}`)}process.exit(0)}async function R(s,c,l,g,b,S=!1){if(l.endsWith("/")){let{error:r}=await q(b,"",{config:{...s,bucket:g}});if(r)return{error:r.message};let{error:u}=await A(l,{config:{...s,bucket:c}});return u?{error:`Copied but failed to delete source: ${u.message}`}:{}}let{data:e}=await Q(l,{config:{...s,bucket:c}}),t=e?.size,k=e?.contentType,{data:n,error:f}=await L(l,"stream",{config:{...s,bucket:c}});if(f)return{error:f.message};let{error:p}=await q(b,n,{...J(t),...k?{contentType:k}:{},onUploadProgress:S?({loaded:r})=>{if(t!==void 0&&t>0){let u=Math.round(r/t*100);process.stdout.write(`\rMoving: ${M(r)} / ${M(t)} (${u}%)`)}else process.stdout.write(`\rMoving: ${M(r)}`)}:void 0,config:{...s,bucket:g}});if(S&&process.stdout.write("\r"+" ".repeat(60)+"\r"),p)return{error:p.message};let{error:o}=await A(l,{config:{...s,bucket:c}});return o?{error:`Copied but failed to delete source: ${o.message}`}:{}}export{X 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 A}from"../../chunk-HPICBIXL.js";import{a as R}from"../../chunk-EKW6XTGL.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};
@@ -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-UJFCUY34.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-K4QARFBT.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};
@@ -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-UJFCUY34.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-K4QARFBT.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": "2.18.1-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
@@ -76,7 +76,12 @@
76
76
  [
77
77
  "@semantic-release/commit-analyzer",
78
78
  {
79
+ "preset": "conventionalcommits",
79
80
  "releaseRules": [
81
+ {
82
+ "breaking": true,
83
+ "release": "major"
84
+ },
80
85
  {
81
86
  "type": "refactor",
82
87
  "release": "patch"
@@ -84,7 +89,12 @@
84
89
  ]
85
90
  }
86
91
  ],
87
- "@semantic-release/release-notes-generator",
92
+ [
93
+ "@semantic-release/release-notes-generator",
94
+ {
95
+ "preset": "conventionalcommits"
96
+ }
97
+ ],
88
98
  "@semantic-release/github",
89
99
  "@semantic-release/npm"
90
100
  ]
@@ -105,6 +115,7 @@
105
115
  "@commitlint/config-conventional": "^20.5.0",
106
116
  "@eslint/js": "^10.0.1",
107
117
  "@types/node": "^22.19.11",
118
+ "conventional-changelog-conventionalcommits": "^9.3.1",
108
119
  "dotenv": "^17.4.2",
109
120
  "eslint": "^10.2.1",
110
121
  "eslint-plugin-simple-import-sort": "^13.0.0",
@@ -1,8 +0,0 @@
1
- import{d,e as m,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="2.18.1-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(d,{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};