@tigrisdata/cli 3.0.0-beta.2 → 3.1.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.
Files changed (42) hide show
  1. package/README.md +630 -512
  2. package/dist/chunk-G4DHMSCQ.js +8 -0
  3. package/dist/chunk-GLKOUVFH.js +8 -0
  4. package/dist/chunk-LAB2KJTN.js +1 -0
  5. package/dist/chunk-N3Y6RFSK.js +1 -0
  6. package/dist/{chunk-EBWDZEHM.js → chunk-RZPBM4CD.js} +1 -1
  7. package/dist/{chunk-ABUCZZSA.js → chunk-WE7KHYIP.js} +1 -1
  8. package/dist/cli-core.js +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/lib/buckets/create.js +1 -1
  12. package/dist/lib/buckets/get.js +1 -1
  13. package/dist/lib/buckets/lifecycle/create.js +1 -1
  14. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  15. package/dist/lib/buckets/lifecycle/list.js +1 -1
  16. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  17. package/dist/lib/buckets/list.js +1 -1
  18. package/dist/lib/buckets/restore.js +1 -0
  19. package/dist/lib/buckets/set-locations.js +1 -1
  20. package/dist/lib/buckets/set.js +1 -1
  21. package/dist/lib/cp.js +1 -1
  22. package/dist/lib/iam/policies/edit.js +1 -1
  23. package/dist/lib/mk.js +1 -1
  24. package/dist/lib/mv.js +1 -1
  25. package/dist/lib/objects/delete.js +1 -1
  26. package/dist/lib/objects/get.js +1 -1
  27. package/dist/lib/objects/info.js +1 -1
  28. package/dist/lib/objects/list-versions.js +6 -0
  29. package/dist/lib/objects/put.js +1 -1
  30. package/dist/lib/objects/set-access.js +1 -0
  31. package/dist/lib/objects/set.js +1 -1
  32. package/dist/lib/stat.js +1 -1
  33. package/dist/lib/update.js +1 -1
  34. package/dist/specs.yaml +116 -3
  35. package/dist/utils/bucket-info.js +1 -1
  36. package/dist/utils/locations.js +1 -1
  37. package/dist/utils/update-check.js +1 -1
  38. package/package.json +2 -2
  39. package/dist/chunk-HWX63Y3P.js +0 -1
  40. package/dist/chunk-K4QARFBT.js +0 -8
  41. package/dist/chunk-QWZ6FK7E.js +0 -8
  42. package/dist/chunk-TD2HGNDY.js +0 -1
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
@@ -665,6 +667,7 @@ commands:
665
667
  - "tigris buckets list"
666
668
  - "tigris buckets list --format json"
667
669
  - "tigris buckets list --forks-of my-bucket"
670
+ - "tigris buckets list --deleted"
668
671
  messages:
669
672
  onStart: 'Listing buckets...'
670
673
  onSuccess: 'Found {{count}} bucket(s)'
@@ -677,6 +680,9 @@ commands:
677
680
  default: table
678
681
  - name: forks-of
679
682
  description: Only list buckets that are forks of the named source bucket
683
+ - name: deleted
684
+ description: Only list soft-deleted buckets
685
+ type: flag
680
686
  - name: limit
681
687
  description: Maximum number of items to return per page
682
688
  - name: page-token
@@ -791,6 +797,25 @@ commands:
791
797
  - name: force
792
798
  type: flag
793
799
  description: Skip confirmation prompts (alias for --yes)
800
+ # restore
801
+ - name: restore
802
+ description: Restore a soft-deleted bucket within its retention window. List recoverable buckets with "tigris buckets list --deleted"
803
+ examples:
804
+ - "tigris buckets restore my-bucket"
805
+ messages:
806
+ onStart: 'Restoring bucket...'
807
+ onSuccess: "Bucket '{{name}}' restored successfully"
808
+ onFailure: "Failed to restore bucket '{{name}}'"
809
+ nextActions:
810
+ - command: 'tigris buckets get {{name}}'
811
+ description: 'Inspect the restored bucket'
812
+ arguments:
813
+ - name: name
814
+ description: Name of the soft-deleted bucket to restore
815
+ type: positional
816
+ required: true
817
+ examples:
818
+ - my-bucket
794
819
  # set
795
820
  - name: set
796
821
  description: Update settings on an existing bucket such as access level, location, caching, or custom domain
@@ -799,6 +824,8 @@ commands:
799
824
  - "tigris buckets set my-bucket --access public"
800
825
  - "tigris buckets set my-bucket --locations iad,fra --cache-control 'max-age=3600'"
801
826
  - "tigris buckets set my-bucket --custom-domain assets.example.com"
827
+ - "tigris buckets set my-bucket --soft-delete enable --retention-days 30"
828
+ - "tigris buckets set my-bucket --soft-delete disable"
802
829
  messages:
803
830
  onStart: 'Updating bucket...'
804
831
  onSuccess: 'Bucket {{name}} updated successfully'
@@ -833,6 +860,13 @@ commands:
833
860
  - name: enable-delete-protection
834
861
  description: Enable delete protection
835
862
  type: boolean
863
+ deprecated: true
864
+ replaced_by: --soft-delete
865
+ - name: soft-delete
866
+ description: Enable or disable soft delete (recoverable deletes). Requires --retention-days when enabling
867
+ options: [enable, disable]
868
+ - name: retention-days
869
+ description: Number of days to retain soft-deleted objects (required when enabling --soft-delete)
836
870
  - name: enable-additional-headers
837
871
  description: Enable additional HTTP headers (X-Content-Type-Options nosniff)
838
872
  type: boolean
@@ -1248,6 +1282,44 @@ commands:
1248
1282
  - name: source
1249
1283
  description: List objects from a specific storage source on buckets with shadow migration enabled
1250
1284
  options: [tigris, shadow]
1285
+ # list-versions
1286
+ - name: list-versions
1287
+ description: List object versions and delete markers in a bucket (requires bucket versioning). Returns both arrays separately to match the S3 ListObjectVersions response
1288
+ alias: lv
1289
+ examples:
1290
+ - "tigris objects list-versions my-bucket"
1291
+ - "tigris objects list-versions t3://my-bucket/logs/"
1292
+ - "tigris objects list-versions my-bucket --prefix images/"
1293
+ - "tigris objects list-versions my-bucket --format json"
1294
+ messages:
1295
+ onStart: 'Listing object versions...'
1296
+ onSuccess: 'Found {{versions}} version(s) and {{deleteMarkers}} delete marker(s)'
1297
+ onFailure: 'Failed to list object versions'
1298
+ onEmpty: 'No versions or delete markers found'
1299
+ arguments:
1300
+ - name: bucket
1301
+ description: Name of the bucket, or a path with optional prefix (t3://bucket/prefix/)
1302
+ type: positional
1303
+ required: true
1304
+ examples:
1305
+ - my-bucket
1306
+ - t3://my-bucket/images/
1307
+ - name: prefix
1308
+ description: Filter by key prefix
1309
+ alias: p
1310
+ - name: delimiter
1311
+ description: Group keys sharing a common prefix up to the delimiter (e.g. "/" for folder-style grouping)
1312
+ alias: d
1313
+ - name: format
1314
+ description: Output format
1315
+ options: [json, table, xml]
1316
+ default: table
1317
+ - name: limit
1318
+ description: Maximum number of items to return per page
1319
+ - name: key-marker
1320
+ description: Pagination marker — the key to start listing from (from a prior nextKeyMarker)
1321
+ - name: version-id-marker
1322
+ description: Pagination marker — the version id to start listing from (from a prior nextVersionIdMarker)
1251
1323
  # get
1252
1324
  - name: get
1253
1325
  description: Download an object by key. Prints to stdout by default, or saves to a file with --output
@@ -1283,6 +1355,8 @@ commands:
1283
1355
  - name: snapshot-version
1284
1356
  description: Read from a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464)
1285
1357
  alias: snapshot
1358
+ - name: version-id
1359
+ description: Object version id to download (requires bucket versioning). Omit to download the latest version
1286
1360
  # put
1287
1361
  - name: put
1288
1362
  description: Upload a local file as an object. Content-type is auto-detected from extension unless overridden
@@ -1330,12 +1404,14 @@ commands:
1330
1404
  default: table
1331
1405
  # delete
1332
1406
  - name: delete
1333
- description: Delete one or more objects by key from the given bucket
1407
+ 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
1408
  alias: d
1335
1409
  examples:
1336
1410
  - "tigris objects delete my-bucket old-file.txt --yes"
1337
1411
  - "tigris objects delete t3://my-bucket/old-file.txt --yes"
1338
1412
  - "tigris objects delete my-bucket file-a.txt,file-b.txt --yes"
1413
+ - "tigris objects delete my-bucket old-file.txt --version-id abc123 --yes"
1414
+ - "tigris objects delete my-bucket old-file.txt --all-versions --yes"
1339
1415
  messages:
1340
1416
  onStart: 'Deleting object...'
1341
1417
  onSuccess: "Object '{{key}}' deleted successfully"
@@ -1357,13 +1433,19 @@ commands:
1357
1433
  multiple: true
1358
1434
  examples:
1359
1435
  - my-file.txt
1436
+ - name: version-id
1437
+ description: Hard-delete a specific object version (requires bucket versioning). Targets a single key
1438
+ - name: all-versions
1439
+ description: Hard-delete every version and delete marker for the given key(s). Mutually exclusive with --version-id
1440
+ type: flag
1360
1441
  - name: force
1361
1442
  type: flag
1362
1443
  description: Skip confirmation prompts (alias for --yes)
1363
- # set
1444
+ # set (deprecated)
1364
1445
  - name: set
1365
- description: Update settings on an existing object such as access level
1446
+ 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
1447
  alias: s
1448
+ deprecated: true
1367
1449
  examples:
1368
1450
  - "tigris objects set my-bucket my-file.txt --access public"
1369
1451
  - "tigris objects set t3://my-bucket/my-file.txt --access public"
@@ -1372,6 +1454,7 @@ commands:
1372
1454
  onStart: 'Updating object...'
1373
1455
  onSuccess: "Object '{{key}}' updated successfully"
1374
1456
  onFailure: 'Failed to update object'
1457
+ 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
1458
  arguments:
1376
1459
  - name: bucket
1377
1460
  description: Name of the bucket, or a full path (t3://bucket/key)
@@ -1388,6 +1471,33 @@ commands:
1388
1471
  - name: new-key
1389
1472
  description: Rename the object to a new key
1390
1473
  alias: n
1474
+ # set-access
1475
+ - name: set-access
1476
+ description: Set the access level (public or private) on an existing object
1477
+ alias: sa
1478
+ examples:
1479
+ - "tigris objects set-access my-bucket my-file.txt public"
1480
+ - "tigris objects set-access t3://my-bucket/my-file.txt private"
1481
+ messages:
1482
+ onStart: 'Updating object access...'
1483
+ onSuccess: "Access for '{{key}}' updated to {{access}}"
1484
+ onFailure: 'Failed to update object access'
1485
+ arguments:
1486
+ - name: bucket
1487
+ description: Name of the bucket, or a full path (t3://bucket/key)
1488
+ type: positional
1489
+ required: true
1490
+ - name: key
1491
+ description: Key of the object (omit if bucket contains the full path)
1492
+ type: positional
1493
+ - name: access
1494
+ description: Access level (public or private)
1495
+ type: positional
1496
+ options: *access_options
1497
+ - name: format
1498
+ description: Output format
1499
+ options: [json, table, xml]
1500
+ default: table
1391
1501
  # info
1392
1502
  - name: info
1393
1503
  description: Show metadata for an object (content type, size, modified date)
@@ -1396,6 +1506,7 @@ commands:
1396
1506
  - "tigris objects info my-bucket report.pdf"
1397
1507
  - "tigris objects info t3://my-bucket/report.pdf"
1398
1508
  - "tigris objects info my-bucket report.pdf --format json"
1509
+ - "tigris objects info my-bucket report.pdf --version-id abc123"
1399
1510
  messages:
1400
1511
  onStart: ''
1401
1512
  onSuccess: ''
@@ -1415,6 +1526,8 @@ commands:
1415
1526
  - name: snapshot-version
1416
1527
  description: Read from a specific bucket snapshot
1417
1528
  alias: snapshot
1529
+ - name: version-id
1530
+ description: Object version id (requires bucket versioning). Omit to read the latest version
1418
1531
 
1419
1532
  #########################
1420
1533
  # Manage access keys
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-HWX63Y3P.js";import"../chunk-IRDNZN7R.js";export{c as buildBucketInfo,b as describeExpiration,a as describeTransition};
1
+ import{a,b,c}from"../chunk-LAB2KJTN.js";import"../chunk-IRDNZN7R.js";import"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";export{c as buildBucketInfo,b as describeExpiration,a as describeTransition};
@@ -1 +1 @@
1
- import{a,b}from"../chunk-TD2HGNDY.js";import"../chunk-S77OAN6Y.js";export{b as parseLocations,a as promptLocations};
1
+ import{a,b,c}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";export{b as formatLocations,c as parseLocations,a as promptLocations};
@@ -1 +1 @@
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};
1
+ import{b as a,c as b,d as c,e as d,f as e}from"../chunk-GLKOUVFH.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.2",
3
+ "version": "3.1.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.12.0",
107
107
  "commander": "^14.0.3",
108
108
  "enquirer": "^2.4.1",
109
109
  "jose": "^6.2.3",
@@ -1 +0,0 @@
1
- import{a as l}from"./chunk-IRDNZN7R.js";function r(e){if(e.storageClass)return e.days!==void 0?`${e.storageClass} after ${e.days}d`:e.date!==void 0?`${e.storageClass} on ${e.date}`:e.storageClass}function f(e){if(e.expiration){if(e.expiration.days!==void 0)return`${e.expiration.days}d`;if(e.expiration.date!==void 0)return e.expiration.date}}function a(e){let n=[],i=r(e);i&&n.push(i);let s=f(e);s&&n.push(e.expiration?.days!==void 0?`expire after ${s}`:`expire on ${s}`);let t=[];e.filter?.prefix&&t.push(`prefix=${e.filter.prefix}`),e.enabled===!1&&t.push("disabled");let o=n.join(", ");return t.length>0?`${o} (${t.join(", ")})`:o}function c(e){let n=[{label:"Number of Objects",value:e.sizeInfo.numberOfObjects?.toString()??"N/A"},{label:"Total Size",value:e.sizeInfo.size!==void 0?l(e.sizeInfo.size):"N/A"},{label:"All Versions Count",value:e.sizeInfo.numberOfObjectsAllVersions?.toString()??"N/A"},{label:"Default Tier",value:e.settings.defaultTier},{label:"Snapshots Enabled",value:e.isSnapshotEnabled?"Yes":"No"},{label:"Delete Protection",value:e.settings.deleteProtection?"Yes":"No"},{label:"Allow Object ACL",value:e.settings.allowObjectAcl?"Yes":"No"},{label:"Custom Domain",value:e.settings.customDomain??"None"},{label:"Has Forks",value:e.forkInfo?.hasChildren?"Yes":"No"}];return e.forkInfo?.parents?.length&&(n.push({label:"Forked From",value:e.forkInfo.parents[0].bucketName}),n.push({label:"Fork Snapshot",value:e.forkInfo.parents[0].snapshot})),e.settings.lifecycleRules?.length&&n.push({label:"Lifecycle Rules",value:e.settings.lifecycleRules.map(i=>a(i)).join(", ")}),e.settings.corsRules.length&&n.push({label:"CORS Rules",value:`${e.settings.corsRules.length} rule(s)`}),e.settings.notifications&&n.push({label:"Notifications",value:e.settings.notifications.enabled!==!1?"Enabled":"Disabled"}),e.settings.dataMigration&&n.push({label:"Data Migration",value:e.settings.dataMigration.endpoint?`${e.settings.dataMigration.name??"N/A"} (${e.settings.dataMigration.endpoint})`:e.settings.dataMigration.name??"Configured"}),n}export{r as a,f as b,c};
@@ -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.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};
@@ -1,8 +0,0 @@
1
- import{a as w}from"./chunk-UBANDLB4.js";import{h as C}from"./chunk-7ZUCJBD5.js";import{Command as L,Option as _}from"commander";function A(n,t,e,a,o){let r=n[n.length-1],i=typeof r=="object"&&r!==null&&"args"in r?r.args:n.filter(l=>typeof l=="string");if(i.length===0)return i;let m=i[0],d=(t.commands??[]).filter(l=>g(l,[...e,l.name],o));if(!new Set(d.flatMap(l=>[l.name,...Array.isArray(l.alias)?l.alias:l.alias?[l.alias]:[]])).has(m)){let l=d.map(u=>u.name),p=e.length>0?`'${m}' for '${e.join(" ")}'`:`'${m}'`;console.error(`Unknown command ${p}.`),l.length>0&&console.error(`Available commands: ${l.join(", ")}`);let f=e.length>0?`${a.name} ${e.join(" ")} help`:`${a.name} help`;console.error(`
2
- Run "${f}" for usage.`),process.exit(1)}return i}function G(){process.on("unhandledRejection",n=>{(n===""||n===void 0)&&(console.error(`
3
- Operation cancelled`),process.exit(1)),w(n)}),process.on("uncaughtException",n=>{w(n)})}function U(n){return/^[a-zA-Z0-9_-]+$/.test(n)}function D(n){let t;n.type==="positional"?t=` ${n.name}`:(t=` --${n.name}`,n.alias&&typeof n.alias=="string"&&(t+=n.alias.length===1?`, -${n.alias}`:`, --${n.alias}`));let e=26,a=t.length>=e?t+" ":t.padEnd(e),o=n.description;return n.options&&(Array.isArray(n.options)&&typeof n.options[0]=="string"?o+=` (options: ${n.options.join(", ")})`:o+=` (options: ${n.options.map(r=>r.value).join(", ")})`),n.default&&(o+=` [default: ${n.default}]`),n.required&&(o+=" [required]"),n["required-when"]&&(o+=` [required when: ${n["required-when"]}]`),n.multiple&&(o+=" [multiple values: comma-separated]"),n.type==="positional"&&(o+=" [positional argument]"),n.examples&&n.examples.length>0&&(o+=` (examples: ${n.examples.join(", ")})`),`${a}${o}`}function g(n,t,e){return n.removed||e(t)?!0:n.commands?n.commands.some(a=>g(a,[...t,a.name],e)):!1}function R(n,t){let e=t?` Use ${t} instead.`:" See the changelog for migration guidance.";console.error(`${n} was removed in this version.${e}`),process.exit(1)}function v(n,t){if(n)for(let e of n){if(!e.removed)continue;h(t,e.name,n)!==void 0&&R(`--${e.name}`,e.replaced_by)}}function b(n,t,e,a){let o=e.join(" ");if(console.log(`
4
- ${n.name} ${o} - ${t.description??""}
5
- `),t.commands&&t.commands.length>0){let m=t.commands.filter(s=>!s.removed&&g(s,[...e,s.name],a));m.length>0&&(console.log("Commands:"),m.forEach(s=>{let d=` ${s.name}`;if(s.alias){let l=Array.isArray(s.alias)?s.alias:[s.alias];d+=` (${l.join(", ")})`}let c=d.padEnd(24);console.log(`${c}${s.description??""}`)}),console.log())}let r=n.definitions?.global_arguments??[],i=y(r,t.arguments).filter(m=>!m.removed);i.length>0&&(console.log("Arguments:"),i.forEach(m=>{console.log(D(m))}),console.log()),t.examples&&t.examples.length>0&&(console.log("Examples:"),t.examples.forEach(m=>{console.log(` ${m}`)}),console.log()),t.commands&&t.commands.length>0&&console.log(`Use "${n.name} ${o} <command> help" for more information about a command.`)}function k(n,t,e){console.log(`Tigris CLI Version: ${t}
6
- `),console.log(`Usage: tigris [command] [options]
7
- `),console.log("Commands:"),n.commands.filter(o=>!o.removed&&g(o,[o.name],e)).forEach(o=>{let r=` ${o.name}`;if(o.alias){let m=Array.isArray(o.alias)?o.alias:[o.alias];r+=` (${m.join(", ")})`}let i=r.padEnd(24);console.log(`${i}${o.description??""}`)}),console.log(`
8
- Use "${n.name} <command> help" for more information about a command.`)}function y(n,t){let e=t??[],a=new Set(e.map(i=>i.name)),o=new Set(e.filter(i=>i.alias).map(i=>i.alias)),r=n.filter(i=>!a.has(i.name)&&!(i.alias&&o.has(i.alias)));return[...e,...r]}function E(n,t=[]){t.forEach(e=>{if(e.type==="positional"){let a=e.required?`<${e.name}>`:`[${e.name}]`;n.argument(a,e.description)}else{let a=e.alias&&typeof e.alias=="string"&&e.alias.length===1,o=e.alias&&typeof e.alias=="string"&&e.alias.length>1,r=a?`-${e.alias}, --${e.name}`:o?`--${e.alias}, --${e.name}`:`--${e.name}`;e.type==="flag"||(e.type==="boolean"?r+=" [value]":e.options?r+=" <value>":r+=e.required||e["required-when"]?" <value>":" [value]"),e.removed?n.addOption(new _(r,e.description??"").hideHelp()):n.option(r,e.description??"",e.default)}})}function M(n){return n.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function h(n,t,e){if(e){let o=e.find(r=>r.name===t);if(o&&o.alias&&typeof o.alias=="string"){let r=o.alias.charAt(0).toUpperCase()+o.alias.slice(1);if(n[r]!==void 0)return n[r]}}let a=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),M(t)];for(let o of a)if(n[o]!==void 0)return n[o]}function S(n,t){for(let e of n){if(e["required-when"]){let[a,o]=e["required-when"].split("="),r=h(t,a,n),i=h(t,e.name,n);if(r===o&&!i)return console.error(`--${e.name} is required when --${a} is ${o}`),!1}if(e.required&&!h(t,e.name,n))return console.error(`--${e.name} is required`),!1}return!0}function j(n,t,e){let a;"optsWithGlobals"in e&&typeof e.optsWithGlobals=="function"?a=e.optsWithGlobals():"opts"in e&&typeof e.opts=="function"?a=e.opts():a=e;let o={...a};return n.filter(i=>i.type==="positional").forEach((i,m)=>{t[m]!==void 0&&(i.multiple?o[i.name]=t[m].split(",").map(s=>s.trim()):o[i.name]=t[m])}),n.forEach(i=>{i.multiple&&i.type!=="positional"&&o[i.name]&&typeof o[i.name]=="string"&&(o[i.name]=o[i.name].split(",").map(m=>m.trim()))}),o}async function I(n,t,e=[],a={}){(a.json||a.format==="json")&&(globalThis.__TIGRIS_JSON_MODE=!0);let{module:o,error:r}=await n(t);(r||!o)&&(console.error(r),process.exit(1));let i=t[t.length-1],m=o.default||o[i];typeof m!="function"&&(console.error(`Command not implemented: ${t.join(" ")}`),process.exit(1)),await m({...a,_positional:e})}function q(n,t,e,a=[]){let{specs:o,loadModule:r,hasImplementation:i}=n,m=o.definitions?.global_arguments??[];for(let s of e){U(s.name)||(console.error(`Invalid command name "${s.name}": only alphanumeric, hyphens, and underscores allowed`),process.exit(1));let d=[...a,s.name];if(!g(s,d,i))continue;let c=t.command(s.name,s.removed?{hidden:!0}:void 0).description(s.description??"");if(s.alias&&(Array.isArray(s.alias)?s.alias:[s.alias]).forEach(p=>c.alias(p)),s.removed){c.allowUnknownOption(!0),c.allowExcessArguments(!0),c.action(()=>{R(`${o.name} ${d.join(" ")}`,s.replaced_by)});continue}if(s.commands&&s.commands.length>0)if(q(n,c,s.commands,d),s.default){let l=s.commands.find(p=>p.name===s.default);if(l){let p=y(m,[...s.arguments||[],...l.arguments||[]]);E(c,p),c.allowExcessArguments(!0),c.action(async(...f)=>{let u=f.pop(),x=A([u],s,d,o,i),$=j(p,x,u);p.length>0&&!S(p,$)||(v(p,$),l.deprecated&&l.messages?.onDeprecated&&C(l.messages.onDeprecated),await I(r,[...d,l.name],x,$))})}}else c.allowExcessArguments(!0),c.action((...l)=>{A(l,s,d,o,i),b(o,s,d,i)});else E(c,y(m,s.arguments)),c.action(async(...l)=>{let p=l.pop(),f=l,u=j(s.arguments||[],f,p);s.arguments&&!S(s.arguments,u)||(v(s.arguments,u),s.deprecated&&s.messages?.onDeprecated&&C(s.messages.onDeprecated),await I(r,d,f,u))});c.command("help").description("Show help for this command").action(()=>{b(o,s,d,i)})}}function P(n){let{specs:t,version:e,hasImplementation:a}=n,o=new L;return o.name(t.name).description(t.description).version(e),q(n,o,t.commands),o.command("help").description("Show general help").action(()=>{k(t,e,a)}),o.command("version").description("Show the CLI version").action(()=>{console.log(e)}),o.allowExcessArguments(!0),o.action((...r)=>{A(r,{commands:t.commands},[],t,a),k(t,e,a)}),o}export{G as a,U as b,D as c,g as d,b as e,k as f,E as g,S as h,j as i,q as j,P as k};
@@ -1 +0,0 @@
1
- import{a as i}from"./chunk-S77OAN6Y.js";import l from"enquirer";var{prompt:r}=l,u=["usa","eur"],m=[{name:"USA",value:"usa"},{name:"Europe",value:"eur"}],s=[{name:"Amsterdam, Netherlands (AMS)",value:"ams"},{name:"Frankfurt, Germany (FRA)",value:"fra"},{name:"Sao Paulo, Brazil (GRU)",value:"gru"},{name:"Ashburn, Virginia (IAD)",value:"iad"},{name:"Johannesburg, South Africa (JNB)",value:"jnb"},{name:"London, United Kingdom (LHR)",value:"lhr"},{name:"Tokyo, Japan (NRT)",value:"nrt"},{name:"Chicago, Illinois (ORD)",value:"ord"},{name:"Singapore, Singapore (SIN)",value:"sin"},{name:"San Jose, California (SJC)",value:"sjc"},{name:"Sydney, Australia (SYD)",value:"syd"}];async function g(t){try{if(t==="multi"){let{region:e}=await r({type:"select",name:"region",message:"Multi-region:",choices:m.map(n=>({name:n.value,message:n.name}))});return o(e)}if(t==="single"){let{region:e}=await r({type:"select",name:"region",message:"Region:",choices:s.map(n=>({name:n.value,message:n.name}))});return o(e)}let{regions:a}=await r({type:"multiselect",name:"regions",message:"Press space key to select regions (multiple supported) and enter to confirm:",choices:s.map(e=>({name:e.value,message:e.name}))});if(a.length<2)throw new Error("Dual region requires at least two regions");return o(a)}catch(a){if(a==="")return null;throw a}}async function c(){i("Provide --locations flag");let t;try{({locationType:t}=await r({type:"select",name:"locationType",message:"Location type:",choices:[{name:"global",message:"Global"},{name:"multi",message:"Multi-region (USA or Europe)"},{name:"dual",message:"Dual region"},{name:"single",message:"Single region"}]}))}catch{throw new Error("Location selection cancelled")}return t==="global"?{type:"global"}:await g(t)??c()}function o(t){let a=(Array.isArray(t)?t:[t]).flatMap(e=>e.split(",")).map(e=>e.trim()).filter(e=>e.length>0);if(a.length===0||a.length===1&&a[0]==="global")return{type:"global"};if(a.length===1){let e=a[0];return u.includes(e)?{type:"multi",values:e}:{type:"single",values:e}}return{type:"dual",values:a}}export{c as a,o as b};