@tigrisdata/cli 3.12.2 → 3.14.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 (129) hide show
  1. package/README.md +37 -4
  2. package/dist/auth/iam.js +1 -1
  3. package/dist/auth/provider.js +1 -1
  4. package/dist/browser/index.d.ts +18 -0
  5. package/dist/browser/index.js +463 -190
  6. package/dist/{chunk-WJWXPQBD.js → chunk-7BWCRJKU.js} +1 -1
  7. package/dist/{chunk-2NEE6EHO.js → chunk-A54TR6PZ.js} +1 -1
  8. package/dist/chunk-ABDWDZNK.js +4 -0
  9. package/dist/chunk-AG6GAJQM.js +5 -0
  10. package/dist/chunk-BTGWYSBL.js +2 -0
  11. package/dist/chunk-CIRQB45N.js +7 -0
  12. package/dist/{chunk-5HE5V2XI.js → chunk-CV77M3XG.js} +1 -1
  13. package/dist/{chunk-4Q7K4H7G.js → chunk-ELGUUOPX.js} +1 -1
  14. package/dist/{chunk-IUIKP2LU.js → chunk-EOCLTUJ4.js} +1 -1
  15. package/dist/chunk-GJLY3P2R.js +1 -0
  16. package/dist/chunk-K6JNY5VH.js +1 -0
  17. package/dist/{chunk-4IGHNCH2.js → chunk-P5DIPVOU.js} +1 -1
  18. package/dist/{chunk-RKQ4APOU.js → chunk-PAANXFCH.js} +1 -1
  19. package/dist/{chunk-ARZNOO2O.js → chunk-PGHGQCUB.js} +1 -1
  20. package/dist/{chunk-OLHVLEN3.js → chunk-QBBCW6FL.js} +1 -1
  21. package/dist/chunk-RAA7DIID.js +3 -0
  22. package/dist/{chunk-M63SODRY.js → chunk-X554SYWE.js} +1 -1
  23. package/dist/chunk-Y36SHW6I.js +14 -0
  24. package/dist/{chunk-RDGK5VBP.js → chunk-YJ2RZYU4.js} +1 -1
  25. package/dist/cli-core.js +1 -1
  26. package/dist/cli.js +1 -1
  27. package/dist/help.js +1 -0
  28. package/dist/index.js +1 -1
  29. package/dist/lib/access-keys/assign.js +1 -1
  30. package/dist/lib/access-keys/attach-policy.js +1 -1
  31. package/dist/lib/access-keys/create.js +2 -1
  32. package/dist/lib/access-keys/delete.js +1 -1
  33. package/dist/lib/access-keys/detach-policy.js +1 -1
  34. package/dist/lib/access-keys/get.js +1 -1
  35. package/dist/lib/access-keys/list-policies.js +1 -1
  36. package/dist/lib/access-keys/list.js +1 -1
  37. package/dist/lib/access-keys/roles.js +1 -0
  38. package/dist/lib/access-keys/rotate.js +1 -1
  39. package/dist/lib/buckets/create.js +1 -1
  40. package/dist/lib/buckets/delete.js +1 -1
  41. package/dist/lib/buckets/disable-snapshots.js +1 -1
  42. package/dist/lib/buckets/enable-snapshots.js +1 -1
  43. package/dist/lib/buckets/get.js +1 -1
  44. package/dist/lib/buckets/lifecycle/create.js +1 -1
  45. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  46. package/dist/lib/buckets/lifecycle/list.js +1 -1
  47. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  48. package/dist/lib/buckets/list.js +1 -1
  49. package/dist/lib/buckets/merge.js +1 -1
  50. package/dist/lib/buckets/migrate.js +1 -1
  51. package/dist/lib/buckets/rebase.js +1 -1
  52. package/dist/lib/buckets/restore.js +1 -1
  53. package/dist/lib/buckets/set-cors.js +1 -1
  54. package/dist/lib/buckets/set-locations.js +1 -1
  55. package/dist/lib/buckets/set-migration.js +1 -1
  56. package/dist/lib/buckets/set-notifications.js +1 -1
  57. package/dist/lib/buckets/set.js +1 -1
  58. package/dist/lib/buckets/share.js +1 -1
  59. package/dist/lib/bundle.js +1 -1
  60. package/dist/lib/configure/index.js +1 -1
  61. package/dist/lib/cp.js +1 -1
  62. package/dist/lib/credentials/test.js +1 -1
  63. package/dist/lib/iam/policies/create.js +1 -1
  64. package/dist/lib/iam/policies/delete.js +1 -1
  65. package/dist/lib/iam/policies/edit.js +1 -1
  66. package/dist/lib/iam/policies/get.js +1 -1
  67. package/dist/lib/iam/policies/link-key.js +1 -1
  68. package/dist/lib/iam/policies/list-keys.js +1 -1
  69. package/dist/lib/iam/policies/list.js +1 -1
  70. package/dist/lib/iam/policies/select-policy.js +1 -1
  71. package/dist/lib/iam/policies/unlink-key.js +1 -1
  72. package/dist/lib/iam/teams/create.js +1 -1
  73. package/dist/lib/iam/teams/edit.js +1 -1
  74. package/dist/lib/iam/teams/list.js +1 -1
  75. package/dist/lib/iam/teams/shared.js +1 -1
  76. package/dist/lib/iam/users/invite.js +1 -1
  77. package/dist/lib/iam/users/list.js +1 -1
  78. package/dist/lib/iam/users/remove.js +1 -1
  79. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  80. package/dist/lib/iam/users/update-role.js +1 -1
  81. package/dist/lib/init/index.js +1 -1
  82. package/dist/lib/init/plan.js +1 -1
  83. package/dist/lib/login/credentials.js +1 -1
  84. package/dist/lib/login/oauth.js +1 -1
  85. package/dist/lib/login/select.js +1 -1
  86. package/dist/lib/logout.js +1 -1
  87. package/dist/lib/ls.js +1 -1
  88. package/dist/lib/mk.js +1 -1
  89. package/dist/lib/mv.js +1 -1
  90. package/dist/lib/objects/delete.js +1 -1
  91. package/dist/lib/objects/get.js +1 -1
  92. package/dist/lib/objects/info.js +1 -1
  93. package/dist/lib/objects/list-versions.js +1 -1
  94. package/dist/lib/objects/list.js +1 -1
  95. package/dist/lib/objects/purge.js +1 -1
  96. package/dist/lib/objects/put.js +1 -1
  97. package/dist/lib/objects/restore-deleted.js +1 -1
  98. package/dist/lib/objects/restore-info.js +1 -1
  99. package/dist/lib/objects/restore.js +1 -1
  100. package/dist/lib/objects/set-access.js +1 -1
  101. package/dist/lib/objects/set.js +1 -1
  102. package/dist/lib/organizations/create.js +1 -1
  103. package/dist/lib/organizations/list.js +1 -1
  104. package/dist/lib/organizations/select.js +1 -1
  105. package/dist/lib/presign.js +1 -1
  106. package/dist/lib/rm.js +1 -1
  107. package/dist/lib/snapshots/delete.js +1 -1
  108. package/dist/lib/snapshots/list.js +1 -1
  109. package/dist/lib/snapshots/take.js +1 -1
  110. package/dist/lib/stat.js +1 -1
  111. package/dist/lib/telemetry/disable.js +1 -1
  112. package/dist/lib/telemetry/enable.js +1 -1
  113. package/dist/lib/telemetry/status.js +1 -1
  114. package/dist/lib/touch.js +1 -1
  115. package/dist/lib/update.js +1 -1
  116. package/dist/lib/whoami.js +1 -1
  117. package/dist/specs.yaml +280 -19
  118. package/dist/utils/analytics.js +1 -1
  119. package/dist/utils/bucket-info.js +1 -1
  120. package/dist/utils/credentials-export.js +1 -0
  121. package/dist/utils/exit.js +1 -1
  122. package/dist/utils/telemetry.js +1 -1
  123. package/dist/utils/update-check.js +1 -1
  124. package/package.json +3 -3
  125. package/dist/chunk-DCSVQMPM.js +0 -2
  126. package/dist/chunk-F67MYOOP.js +0 -1
  127. package/dist/chunk-JELDAKLB.js +0 -30
  128. package/dist/chunk-JRLZXECQ.js +0 -5
  129. package/dist/chunk-NNZ3E7E5.js +0 -10
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-5HE5V2XI.js";import"../chunk-G4OJTPSI.js";import"../chunk-F67MYOOP.js";import"../chunk-BMWWPXMU.js";import"../chunk-APJUJ6TW.js";import"../chunk-QPUL2AAI.js";export{d as captureCommand,c as decodeTokenEmail,f as identifyOnLogin,a as isCI,e as trackCommand,b as usedFlags};
1
+ import{a,b,c,d,e,f}from"../chunk-CV77M3XG.js";import"../chunk-G4OJTPSI.js";import"../chunk-APJUJ6TW.js";import"../chunk-K6JNY5VH.js";import"../chunk-BMWWPXMU.js";import"../chunk-QPUL2AAI.js";export{d as captureCommand,c as decodeTokenEmail,f as identifyOnLogin,a as isCI,e as trackCommand,b as usedFlags};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-IUIKP2LU.js";import"../chunk-AFM3TY2D.js";import"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";export{c as buildBucketInfo,b as describeExpiration,a as describeTransition};
1
+ import{a,b,c}from"../chunk-EOCLTUJ4.js";import"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import"../chunk-AFM3TY2D.js";export{c as buildBucketInfo,b as describeExpiration,a as describeTransition};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g}from"../chunk-CIRQB45N.js";import"../chunk-QPUL2AAI.js";export{a as CREDENTIALS_SDKS,b as credentialVariables,c as formatDotenvValue,g as gitignoreStatus,d as mergeDotenv,f as shellExportLines,e as writeDotenv};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-4IGHNCH2.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-RDGK5VBP.js";import"../chunk-DV3LCXRH.js";import"../chunk-F67MYOOP.js";import"../chunk-BMWWPXMU.js";import"../chunk-APJUJ6TW.js";import"../chunk-QPUL2AAI.js";export{a as exitWithError,b as failWithError,c as getSuccessNextActions,d as printNextActions};
1
+ import{a,b,c,d}from"../chunk-P5DIPVOU.js";import"../chunk-YJ2RZYU4.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-APJUJ6TW.js";import"../chunk-K6JNY5VH.js";import"../chunk-BMWWPXMU.js";import"../chunk-DV3LCXRH.js";import"../chunk-QPUL2AAI.js";export{a as exitWithError,b as failWithError,c as getSuccessNextActions,d as printNextActions};
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f,e as g}from"../chunk-RDGK5VBP.js";import"../chunk-F67MYOOP.js";import{a,b}from"../chunk-BMWWPXMU.js";import"../chunk-APJUJ6TW.js";import"../chunk-QPUL2AAI.js";export{d as beforeSend,f as captureError,g as flushTelemetry,e as initTelemetry,c as invocationCommand,a as redactSecrets,b as scrubArgv};
1
+ import{a as c,b as d,c as e,d as f,e as g}from"../chunk-YJ2RZYU4.js";import"../chunk-APJUJ6TW.js";import"../chunk-K6JNY5VH.js";import{a,b}from"../chunk-BMWWPXMU.js";import"../chunk-QPUL2AAI.js";export{d as beforeSend,f as captureError,g as flushTelemetry,e as initTelemetry,c as invocationCommand,a as redactSecrets,b as scrubArgv};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../chunk-RKQ4APOU.js";import"../chunk-G4OJTPSI.js";import"../chunk-F67MYOOP.js";import"../chunk-QPUL2AAI.js";export{e as checkForUpdates,d as fetchLatestVersion,c as getUpdateCommand,b as isNewerVersion,a as readUpdateCache};
1
+ import{a,b,c,d,e}from"../chunk-PAANXFCH.js";import"../chunk-G4OJTPSI.js";import"../chunk-K6JNY5VH.js";import"../chunk-QPUL2AAI.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.12.2",
3
+ "version": "3.14.0",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
@@ -53,8 +53,8 @@
53
53
  "jsonc-parser": "^3.3.1",
54
54
  "open": "^11.0.0",
55
55
  "yaml": "^2.8.3",
56
- "@tigrisdata/iam": "^2.6.0",
57
- "@tigrisdata/storage": "^3.21.0"
56
+ "@tigrisdata/storage": "^3.22.0",
57
+ "@tigrisdata/iam": "^2.6.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "buffer": "^6.0.3",
@@ -1,2 +0,0 @@
1
- import{a as o,e as a}from"./chunk-JRLZXECQ.js";import{b as i}from"./chunk-4IGHNCH2.js";import{d as r}from"./chunk-HBEO4D3T.js";import{i as n,p as s}from"./chunk-F4AGJWCK.js";async function d(e){s()!=="oauth"&&i(e,`This operation requires OAuth login.
2
- Run "tigris login oauth" first.`);let t=r();await t.isAuthenticated()||i(e,'Not authenticated. Run "tigris login oauth" first.');let c=n(),{iamEndpoint:g,mgmtEndpoint:u}=o();return{sessionToken:await t.getAccessToken(),organizationId:c??void 0,iamEndpoint:g,mgmtEndpoint:u}}async function A(e){let t=await a();switch(t.type){case"oauth":return d(e);case"aws-profile":case"credentials":case"environment":case"configured":return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,organizationId:n()??void 0,iamEndpoint:o().iamEndpoint};case"none":i(e,'Not authenticated. Run "tigris login" or "tigris configure" first.')}}export{d as a,A as b};
@@ -1 +0,0 @@
1
- var s="3.12.2";export{s as a};
@@ -1,30 +0,0 @@
1
- var r="Ask the user for permission. Then install the CLI: `npm install -g @tigrisdata/cli --ignore-scripts`.",i="Update the CLI to the latest version: `tigris update`.",o=["Run `tigris whoami` to get the authentication state. If the user is not authenticated, run `tigris login oauth`.","Run `tigris orgs list --format json`. If there is more than one org, ask the user which org to use. If there is more than one org, run `tigris orgs select <org>` to make that org active. The commands that come after target the active org.","Read the project name from a metadata file, for example package.json, go.mod, or pyproject.toml. Run `tigris buckets list --format json` first. If the bucket is absent, run `tigris buckets create <name> --format json`. If anything is ambiguous, ask the user.",'Create the access key in a private temporary file. Use `>` to overwrite the file. Do not use `>>` to append. Then print only the ID:\n `umask 077; tmpfile=$(mktemp); tigris access-keys create <username>-<project>-devel --format json > "$tmpfile" && jq -r \'.id\' < "$tmpfile"`',"Give the access key the Editor role on the bucket: `tigris access-keys assign <id> --bucket <bucket> --role Editor --format json`.",`Identify the SDK that the code uses: the Tigris SDK, or the AWS SDK. Then use a small script to append the correct variables to \`.env\`:
2
- - The script reads \`.id\` and \`.secret\` from the temporary file.
3
- - Do not read the secret into your own context. Only the script reads the secret.
4
- - When the script is complete, delete the temporary file: \`rm -f "$tmpfile"\`.
5
-
6
- Tigris SDK (@tigrisdata/storage, storage-go):
7
- TIGRIS_STORAGE_ACCESS_KEY_ID = .id
8
- TIGRIS_STORAGE_SECRET_ACCESS_KEY = .secret (secret)
9
- TIGRIS_STORAGE_BUCKET = <bucket>
10
-
11
- AWS SDK:
12
- AWS_ACCESS_KEY_ID = .id
13
- AWS_SECRET_ACCESS_KEY = .secret (secret)
14
- AWS_ENDPOINT_URL_S3 = https://t3.storage.dev (required)
15
- AWS_ENDPOINT_URL_IAM = https://iam.storageapi.dev (required)
16
- AWS_REGION = auto (required)
17
- `,`Congratulate the user. Then give these links:
18
- - JS: https://www.tigrisdata.com/docs/sdks/tigris/
19
- - Go: https://pkg.go.dev/github.com/tigrisdata/storage-go
20
- - Docs: https://www.tigrisdata.com/docs/
21
- - Discord: https://community.tigrisdata.com/
22
- - Skills: https://www.tigrisdata.com/docs/skills/
23
-
24
- Suggest that the user adds these lines to the agent configuration file:
25
- > ## Tigris object storage
26
- > This project uses Tigris. Read https://www.tigrisdata.com/llms.txt before you answer a question about Tigris. Do not answer from memory.`];function c(t){return`Help the user configure Tigris for this project:
27
-
28
- ${[t?i:r,...o].map((e,s)=>`${s+1}. ${e}`).join(`
29
- `)}
30
- `}export{c as a};
@@ -1,5 +0,0 @@
1
- import{a as o,b as a,c as g}from"./chunk-QPUL2AAI.js";import{a as I,d as f}from"./chunk-HBEO4D3T.js";import{i as c,j as y,k as A,l as i,p as d}from"./chunk-F4AGJWCK.js";import{fromIni as S}from"@aws-sdk/credential-providers";function r(){return process.env.AWS_ENDPOINT_URL_S3||process.env.AWS_ENDPOINT_URL_IAM?{endpoint:process.env.AWS_ENDPOINT_URL_S3||o,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||a,mgmtEndpoint:process.env.AWS_ENDPOINT_URL_MGMT||g}:{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||o,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||a,mgmtEndpoint:process.env.TIGRIS_MGMT_ENDPOINT||g}}function _(){let e=process.env.TIGRIS_FORCE_PATH_STYLE?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"||e==="on"}function u(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY){let e=process.env.AWS_ENDPOINT_URL_S3||o;return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,endpoint:e,source:"aws"}}if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID&&process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let e=process.env.TIGRIS_STORAGE_ENDPOINT||o;return{accessKeyId:process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,secretAccessKey:process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY,endpoint:e,source:"tigris"}}return null}var p=!1;function P(){p=!1}async function K(){if(p||!process.stdin.isTTY)return!1;p=!0,console.log(`Not authenticated. Starting login...
2
- `);let{default:e}=await import("./lib/login/select.js");return await e({}),console.log(),!0}async function T(){if(y()){let s=process.env.AWS_PROFILE||"default",l=await S({profile:s})();return{type:"aws-profile",profile:s,accessKeyId:l.accessKeyId,secretAccessKey:l.secretAccessKey}}let e=u();if(e)return{type:"environment",accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,source:e.source};let t=d();if(t==="oauth")return{type:"oauth"};if(t==="credentials"){let s=i();if(s)return{type:"credentials",accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey}}let n=i();return n?{type:"configured",accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey}:{type:"none"}}async function C(e){let t=await E(e);return _()?{...t,forcePathStyle:!0}:t}async function E(e){let t=await T();switch(t.type){case"aws-profile":{let n=await A(t.profile);return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:n.endpoint||r().endpoint||o,iamEndpoint:n.iamEndpoint||r().iamEndpoint}}case"oauth":{let n=f(),s=c();if(!s)throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:await n.getAccessToken(),accessKeyId:"",secretAccessKey:"",...e?.withCredentialProvider&&{credentialProvider:async()=>({accessKeyId:"",secretAccessKey:"",sessionToken:await n.getAccessToken(),expiration:new Date(Date.now()+600*1e3)})},endpoint:r().endpoint,organizationId:s,iamEndpoint:r().iamEndpoint,authDomain:I().domain}}case"credentials":{let n=c();return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:i()?.endpoint||o,organizationId:n??void 0,iamEndpoint:r().iamEndpoint}}case"environment":return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:u()?.endpoint||o};case"configured":{let n=c();return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:i()?.endpoint||o,organizationId:n??void 0,iamEndpoint:r().iamEndpoint}}case"none":{if(await K())return E(e);throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}}}async function N(){let e=await C(),t=c();return{...e,...t&&!e.organizationId?{organizationId:t}:{}}}function O(e){return d()==="oauth"?!1:(u()||i()?console.log(`You are using access key credentials, which belong to a single organization.
3
- ${e} is only available with OAuth login.
4
-
5
- Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.'),!0)}export{r as a,_ as b,u as c,P as d,T as e,C as f,N as g,O as h};
@@ -1,10 +0,0 @@
1
- import{e as x}from"./chunk-5HE5V2XI.js";import{a as k}from"./chunk-4IGHNCH2.js";import{h as C}from"./chunk-D7WXNA2O.js";import{c as I,d as b,e as E}from"./chunk-RDGK5VBP.js";import{b as v}from"./chunk-DV3LCXRH.js";import{Command as M,Help as U,Option as P}from"commander";function y(n,o,e,a,t){let r=n[n.length-1],i=typeof r=="object"&&r!==null&&"args"in r?r.args:n.filter(m=>typeof m=="string");if(i.length===0)return i;let l=i[0],c=(o.commands??[]).filter(m=>g(m,[...e,m.name],t));if(!new Set(c.flatMap(m=>[m.name,...Array.isArray(m.alias)?m.alias:m.alias?[m.alias]:[]])).has(l)){let m=c.map(u=>u.name),p=e.length>0?`'${l}' for '${e.join(" ")}'`:`'${l}'`;console.error(`Unknown command ${p}.`),m.length>0&&console.error(`Available commands: ${m.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 B(){I();let n=!1,o=async e=>{n&&process.exit(1),n=!0,b(e,{crash:!0,exitCode:v(e).exitCode}),await E(),k(e,void 0,{skipCapture:!0})};process.on("unhandledRejection",e=>{(e===""||e===void 0)&&(console.error(`
3
- Operation cancelled`),process.exit(1)),o(e)}),process.on("uncaughtException",e=>{o(e)})}function V(n){return/^[a-zA-Z0-9_-]+$/.test(n)}function G(n){let o;n.type==="positional"?o=` ${n.name}`:(o=` --${n.name}`,n.alias&&typeof n.alias=="string"&&(o+=n.alias.length===1?`, -${n.alias}`:`, --${n.alias}`));let e=26,a=o.length>=e?`${o} `:o.padEnd(e),t=n.description;return n.options&&(Array.isArray(n.options)&&typeof n.options[0]=="string"?t+=` (options: ${n.options.join(", ")})`:t+=` (options: ${n.options.map(r=>r.value).join(", ")})`),n.default&&(t+=` [default: ${n.default}]`),n.required&&(t+=" [required]"),n.deprecated&&(t+=n.replaced_by?` [deprecated: use ${n.replaced_by}]`:" [deprecated]"),n["required-when"]&&(t+=` [required when: ${n["required-when"]}]`),n.multiple&&(t+=" [multiple values: comma-separated]"),n.type==="positional"&&(t+=" [positional argument]"),n.examples&&n.examples.length>0&&(t+=` (examples: ${n.examples.join(", ")})`),`${a}${t}`}function g(n,o,e){return n.removed||e(o)?!0:n.commands?n.commands.some(a=>g(a,[...o,a.name],e)):!1}function L(n,o){let e=o?` Use ${o} instead.`:" See the changelog for migration guidance.";console.error(`${n} was removed in this version.${e}`),process.exit(1)}function S(n,o){if(n)for(let e of n){if(!e.removed)continue;h(o,e.name,n)!==void 0&&L(`--${e.name}`,e.replaced_by)}}function _(n,o,e,a){let t=e.join(" ");if(console.log(`
4
- ${n.name} ${t} - ${o.description??""}
5
- `),o.commands&&o.commands.length>0){let l=o.commands.filter(s=>!s.removed&&g(s,[...e,s.name],a));l.length>0&&(console.log("Commands:"),l.forEach(s=>{let c=` ${s.name}`;if(s.alias){let m=Array.isArray(s.alias)?s.alias:[s.alias];c+=` (${m.join(", ")})`}let d=c.padEnd(24);console.log(`${d}${s.description??""}`)}),console.log())}let r=n.definitions?.global_arguments??[],i=w(r,o.arguments).filter(l=>!l.removed);i.length>0&&(console.log("Arguments:"),i.forEach(l=>{console.log(G(l))}),console.log()),o.examples&&o.examples.length>0&&(console.log("Examples:"),o.examples.forEach(l=>{console.log(` ${l}`)}),console.log()),o.commands&&o.commands.length>0&&console.log(`Use "${n.name} ${t} <command> help" for more information about a command.`)}function R(n,o,e){console.log(`Tigris CLI Version: ${o}
6
- `),console.log(`Usage: tigris [command] [options]
7
- `),console.log("Commands:"),n.commands.filter(t=>!t.removed&&g(t,[t.name],e)).forEach(t=>{let r=` ${t.name}`;if(t.alias){let l=Array.isArray(t.alias)?t.alias:[t.alias];r+=` (${l.join(", ")})`}let i=r.padEnd(24);console.log(`${i}${t.description??""}`)}),console.log(`
8
- Use "${n.name} <command> help" for more information about a command.`)}function w(n,o){let e=o??[],a=new Set(e.map(i=>i.name)),t=new Set(e.filter(i=>i.alias).map(i=>i.alias)),r=n.filter(i=>!a.has(i.name)&&!(i.alias&&t.has(i.alias)));return[...e,...r]}function j(n,o=[]){o.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,t=e.alias&&typeof e.alias=="string"&&e.alias.length>1,r=a?`-${e.alias}, --${e.name}`:t?`--${e.alias}, --${e.name}`:`--${e.name}`;if(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 P(r,e.description??"").hideHelp());else{let i=e.description??"";if(e.deprecated){let l=e.replaced_by?` Use ${e.replaced_by} instead.`:"";i=`(deprecated) ${i}${l}`}n.option(r,i,e.default)}}})}function K(n){return n.replace(/-([a-z])/g,(o,e)=>e.toUpperCase())}function h(n,o,e){if(e){let t=e.find(r=>r.name===o);if(t?.alias&&typeof t.alias=="string"){let r=t.alias.charAt(0).toUpperCase()+t.alias.slice(1);if(n[r]!==void 0)return n[r]}}let a=[o,o.replace(/-/g,""),o.replace(/-/g,"").toLowerCase(),o.charAt(0).toUpperCase(),K(o)];for(let t of a)if(n[t]!==void 0)return n[t]}function D(n,o){for(let e of n){if(e["required-when"]){let[a,t]=e["required-when"].split("="),r=h(o,a,n),i=h(o,e.name,n);if(r===t&&!i)return console.error(`--${e.name} is required when --${a} is ${t}`),!1}if(e.required&&!h(o,e.name,n))return console.error(`--${e.name} is required`),e.description&&console.error(` ${e.description}`),!1}return!0}function W(n,o,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 t={...a};return n.filter(i=>i.type==="positional").forEach((i,l)=>{o[l]!==void 0&&(i.multiple?t[i.name]=o[l].split(",").map(s=>s.trim()):t[i.name]=o[l])}),n.forEach(i=>{i.multiple&&i.type!=="positional"&&t[i.name]&&typeof t[i.name]=="string"&&(t[i.name]=t[i.name].split(",").map(l=>l.trim()))}),t}async function q(n,o,e=[],a={}){(a.json||a.format==="json")&&(globalThis.__TIGRIS_JSON_MODE=!0);let{module:t,error:r}=await n(o);(r||!t)&&(console.error(r),process.exit(1));let i=o[o.length-1],l=t.default||t[i];typeof l!="function"&&(console.error(`Command not implemented: ${o.join(" ")}`),process.exit(1)),x(o),await l({...a,_positional:e})}function N(n,o,e,a=[]){let{specs:t,loadModule:r,hasImplementation:i}=n,l=t.definitions?.global_arguments??[];for(let s of e){V(s.name)||(console.error(`Invalid command name "${s.name}": only alphanumeric, hyphens, and underscores allowed`),process.exit(1));let c=[...a,s.name];if(!g(s,c,i))continue;let d=o.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=>{d.alias(p)}),s.removed){d.allowUnknownOption(!0),d.allowExcessArguments(!0),d.action(()=>{L(`${t.name} ${c.join(" ")}`,s.replaced_by)});continue}if(s.commands&&s.commands.length>0)if(N(n,d,s.commands,c),s.default){let m=s.commands.find(p=>p.name===s.default);if(m){let p=w(l,[...s.arguments||[],...m.arguments||[]]);j(d,p),d.allowExcessArguments(!0),d.action(async(...f)=>{let u=f.pop(),A=y([u],s,c,t,i),$=W(p,A,u);p.length>0&&!D(p,$)&&process.exit(1),S(p,$),m.deprecated&&m.messages?.onDeprecated&&C(m.messages.onDeprecated),await q(r,[...c,m.name],A,$)})}}else d.allowExcessArguments(!0),d.action((...m)=>{y(m,s,c,t,i),_(t,s,c,i)});else j(d,w(l,s.arguments)),d.action(async(...m)=>{let p=m.pop(),f=m,u=W(s.arguments||[],f,p);s.arguments&&!D(s.arguments,u)&&process.exit(1),S(s.arguments,u),s.deprecated&&s.messages?.onDeprecated&&C(s.messages.onDeprecated),await q(r,c,f,u)});d.command("help").description("Show help for this command").action(()=>{_(t,s,c,i)})}}var H=6,z=34,T=20,F={minWidthToWrap:T,formatItem(n,o,e,a){let i=a.helpWidth??80,l=i-o-2-2;if(!e||l>=z)return U.prototype.formatItem.call(this,n,o,e,a);let s=" ".repeat(H),c=a.boxWrap(e,Math.max(i-H,T));return`${" ".repeat(2)}${n}
9
- ${s}${c.replace(/\n/g,`
10
- ${s}`)}`}};function ee(n){let{specs:o,version:e,hasImplementation:a}=n,t=new M;return t.name(o.name).description(o.description).version(e),t.configureHelp(F),N(n,t,o.commands),t.command("help").description("Show general help").action(()=>{R(o,e,a)}),t.command("version").description("Show the CLI version").action(()=>{console.log(e)}),t.allowExcessArguments(!0),t.action((...r)=>{y(r,{commands:o.commands},[],o,a),R(o,e,a)}),t}export{B as a,V as b,G as c,g as d,_ as e,R as f,j as g,D as h,W as i,N as j,F as k,ee as l};