stow-cli 1.0.0 → 1.0.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.
@@ -0,0 +1,173 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-ZDVARBCV.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-LYCXXF2T.js";
7
+ import "./chunk-OZ7QQTIZ.js";
8
+
9
+ // src/commands/upload.ts
10
+ import { existsSync, readFileSync } from "fs";
11
+ import { createHash } from "crypto";
12
+ import { basename, resolve } from "path";
13
+ var CONTENT_TYPES = {
14
+ png: "image/png",
15
+ jpg: "image/jpeg",
16
+ jpeg: "image/jpeg",
17
+ gif: "image/gif",
18
+ webp: "image/webp",
19
+ svg: "image/svg+xml",
20
+ ico: "image/x-icon",
21
+ avif: "image/avif",
22
+ pdf: "application/pdf",
23
+ mp4: "video/mp4",
24
+ webm: "video/webm",
25
+ mov: "video/quicktime",
26
+ mp3: "audio/mpeg",
27
+ wav: "audio/wav",
28
+ ogg: "audio/ogg",
29
+ zip: "application/zip",
30
+ tar: "application/x-tar",
31
+ gz: "application/gzip",
32
+ txt: "text/plain",
33
+ json: "application/json",
34
+ xml: "application/xml",
35
+ html: "text/html",
36
+ css: "text/css",
37
+ js: "application/javascript"
38
+ };
39
+ function getContentType(filename) {
40
+ const ext = filename.toLowerCase().split(".").pop();
41
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
42
+ }
43
+ function readFile(filePath) {
44
+ const resolvedPath = resolve(filePath);
45
+ if (!existsSync(resolvedPath)) {
46
+ console.error(`Error: File not found: ${filePath}`);
47
+ process.exit(1);
48
+ }
49
+ const buffer = readFileSync(resolvedPath);
50
+ const filename = basename(resolvedPath);
51
+ const contentType = getContentType(filename);
52
+ return { buffer, filename, contentType };
53
+ }
54
+ async function uploadToPresignedUrl(uploadUrl, contentType, buffer) {
55
+ const putRes = await fetch(uploadUrl, {
56
+ method: "PUT",
57
+ headers: { "Content-Type": contentType },
58
+ body: new Uint8Array(buffer)
59
+ });
60
+ if (!putRes.ok) {
61
+ throw new Error(`Upload to storage failed (${putRes.status})`);
62
+ }
63
+ }
64
+ async function runUploadPipeline(options) {
65
+ const presign = await apiRequest(options.presignPath, {
66
+ method: "POST",
67
+ body: JSON.stringify(options.presignBody)
68
+ });
69
+ const resolved = options.resolvePresign(presign);
70
+ if ("dedupedUrl" in resolved) {
71
+ return { url: resolved.dedupedUrl, deduped: true };
72
+ }
73
+ await uploadToPresignedUrl(
74
+ resolved.uploadUrl,
75
+ options.contentType,
76
+ options.buffer
77
+ );
78
+ const confirm = await apiRequest(resolved.confirmPath, {
79
+ method: "POST",
80
+ body: JSON.stringify(resolved.confirmBody)
81
+ });
82
+ return { url: options.getResultUrl(confirm), deduped: false };
83
+ }
84
+ function printUploadResult(url, options, opts) {
85
+ if (options.quiet) {
86
+ console.log(url);
87
+ return;
88
+ }
89
+ console.error(opts?.deduped ? "Done! (deduped)" : "Done!");
90
+ console.log("");
91
+ console.log(url);
92
+ }
93
+ function withBucket(path, bucket) {
94
+ if (!bucket) {
95
+ return path;
96
+ }
97
+ const joiner = path.includes("?") ? "&" : "?";
98
+ return `${path}${joiner}bucket=${encodeURIComponent(bucket)}`;
99
+ }
100
+ async function uploadDrop(filePath, options) {
101
+ const { buffer, filename, contentType } = readFile(filePath);
102
+ if (!options.quiet) {
103
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
104
+ }
105
+ const result = await runUploadPipeline({
106
+ presignPath: "/api/drops/presign",
107
+ presignBody: {
108
+ filename,
109
+ contentType,
110
+ size: buffer.length
111
+ },
112
+ contentType,
113
+ buffer,
114
+ resolvePresign: (presign) => ({
115
+ uploadUrl: presign.uploadUrl,
116
+ confirmPath: presign.confirmUrl || "/api/drops/presign/confirm",
117
+ confirmBody: {
118
+ shortId: presign.shortId,
119
+ r2Key: presign.r2Key,
120
+ size: buffer.length,
121
+ contentType,
122
+ filename,
123
+ ...presign.uploadToken ? { uploadToken: presign.uploadToken } : {}
124
+ }
125
+ }),
126
+ getResultUrl: (confirm) => confirm.url
127
+ });
128
+ printUploadResult(result.url, options, { deduped: result.deduped });
129
+ }
130
+ async function uploadFile(filePath, options) {
131
+ const { buffer, filename, contentType } = readFile(filePath);
132
+ if (!options.quiet) {
133
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
134
+ }
135
+ const contentHash = createHash("sha256").update(buffer).digest("hex");
136
+ const result = await runUploadPipeline({
137
+ presignPath: withBucket("/api/presign", options.bucket),
138
+ presignBody: {
139
+ filename,
140
+ contentType,
141
+ size: buffer.length,
142
+ contentHash
143
+ },
144
+ contentType,
145
+ buffer,
146
+ resolvePresign: (presign) => {
147
+ if ("dedupe" in presign && presign.dedupe) {
148
+ return { dedupedUrl: presign.url };
149
+ }
150
+ return {
151
+ uploadUrl: presign.uploadUrl,
152
+ confirmPath: withBucket(
153
+ presign.confirmUrl || "/api/presign/confirm",
154
+ options.bucket
155
+ ),
156
+ confirmBody: {
157
+ fileKey: presign.fileKey,
158
+ size: buffer.length,
159
+ contentType,
160
+ filename,
161
+ contentHash,
162
+ skipVerify: true
163
+ }
164
+ };
165
+ },
166
+ getResultUrl: (confirm) => confirm.url
167
+ });
168
+ printUploadResult(result.url, options, { deduped: result.deduped });
169
+ }
170
+ export {
171
+ uploadDrop,
172
+ uploadFile
173
+ };
@@ -0,0 +1,173 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-ZDVARBCV.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-R5CCBTXZ.js";
7
+ import "./chunk-2AORPTQB.js";
8
+
9
+ // src/commands/upload.ts
10
+ import { existsSync, readFileSync } from "fs";
11
+ import { createHash } from "crypto";
12
+ import { basename, resolve } from "path";
13
+ var CONTENT_TYPES = {
14
+ png: "image/png",
15
+ jpg: "image/jpeg",
16
+ jpeg: "image/jpeg",
17
+ gif: "image/gif",
18
+ webp: "image/webp",
19
+ svg: "image/svg+xml",
20
+ ico: "image/x-icon",
21
+ avif: "image/avif",
22
+ pdf: "application/pdf",
23
+ mp4: "video/mp4",
24
+ webm: "video/webm",
25
+ mov: "video/quicktime",
26
+ mp3: "audio/mpeg",
27
+ wav: "audio/wav",
28
+ ogg: "audio/ogg",
29
+ zip: "application/zip",
30
+ tar: "application/x-tar",
31
+ gz: "application/gzip",
32
+ txt: "text/plain",
33
+ json: "application/json",
34
+ xml: "application/xml",
35
+ html: "text/html",
36
+ css: "text/css",
37
+ js: "application/javascript"
38
+ };
39
+ function getContentType(filename) {
40
+ const ext = filename.toLowerCase().split(".").pop();
41
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
42
+ }
43
+ function readFile(filePath) {
44
+ const resolvedPath = resolve(filePath);
45
+ if (!existsSync(resolvedPath)) {
46
+ console.error(`Error: File not found: ${filePath}`);
47
+ process.exit(1);
48
+ }
49
+ const buffer = readFileSync(resolvedPath);
50
+ const filename = basename(resolvedPath);
51
+ const contentType = getContentType(filename);
52
+ return { buffer, filename, contentType };
53
+ }
54
+ async function uploadToPresignedUrl(uploadUrl, contentType, buffer) {
55
+ const putRes = await fetch(uploadUrl, {
56
+ method: "PUT",
57
+ headers: { "Content-Type": contentType },
58
+ body: new Uint8Array(buffer)
59
+ });
60
+ if (!putRes.ok) {
61
+ throw new Error(`Upload to storage failed (${putRes.status})`);
62
+ }
63
+ }
64
+ async function runUploadPipeline(options) {
65
+ const presign = await apiRequest(options.presignPath, {
66
+ method: "POST",
67
+ body: JSON.stringify(options.presignBody)
68
+ });
69
+ const resolved = options.resolvePresign(presign);
70
+ if ("dedupedUrl" in resolved) {
71
+ return { url: resolved.dedupedUrl, deduped: true };
72
+ }
73
+ await uploadToPresignedUrl(
74
+ resolved.uploadUrl,
75
+ options.contentType,
76
+ options.buffer
77
+ );
78
+ const confirm = await apiRequest(resolved.confirmPath, {
79
+ method: "POST",
80
+ body: JSON.stringify(resolved.confirmBody)
81
+ });
82
+ return { url: options.getResultUrl(confirm), deduped: false };
83
+ }
84
+ function printUploadResult(url, options, opts) {
85
+ if (options.quiet) {
86
+ console.log(url);
87
+ return;
88
+ }
89
+ console.error(opts?.deduped ? "Done! (deduped)" : "Done!");
90
+ console.log("");
91
+ console.log(url);
92
+ }
93
+ function withBucket(path, bucket) {
94
+ if (!bucket) {
95
+ return path;
96
+ }
97
+ const joiner = path.includes("?") ? "&" : "?";
98
+ return `${path}${joiner}bucket=${encodeURIComponent(bucket)}`;
99
+ }
100
+ async function uploadDrop(filePath, options) {
101
+ const { buffer, filename, contentType } = readFile(filePath);
102
+ if (!options.quiet) {
103
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
104
+ }
105
+ const result = await runUploadPipeline({
106
+ presignPath: "/api/drops/presign",
107
+ presignBody: {
108
+ filename,
109
+ contentType,
110
+ size: buffer.length
111
+ },
112
+ contentType,
113
+ buffer,
114
+ resolvePresign: (presign) => ({
115
+ uploadUrl: presign.uploadUrl,
116
+ confirmPath: presign.confirmUrl || "/api/drops/presign/confirm",
117
+ confirmBody: {
118
+ shortId: presign.shortId,
119
+ r2Key: presign.r2Key,
120
+ size: buffer.length,
121
+ contentType,
122
+ filename,
123
+ ...presign.uploadToken ? { uploadToken: presign.uploadToken } : {}
124
+ }
125
+ }),
126
+ getResultUrl: (confirm) => confirm.url
127
+ });
128
+ printUploadResult(result.url, options, { deduped: result.deduped });
129
+ }
130
+ async function uploadFile(filePath, options) {
131
+ const { buffer, filename, contentType } = readFile(filePath);
132
+ if (!options.quiet) {
133
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
134
+ }
135
+ const contentHash = createHash("sha256").update(buffer).digest("hex");
136
+ const result = await runUploadPipeline({
137
+ presignPath: withBucket("/api/presign", options.bucket),
138
+ presignBody: {
139
+ filename,
140
+ contentType,
141
+ size: buffer.length,
142
+ contentHash
143
+ },
144
+ contentType,
145
+ buffer,
146
+ resolvePresign: (presign) => {
147
+ if ("dedupe" in presign && presign.dedupe) {
148
+ return { dedupedUrl: presign.url };
149
+ }
150
+ return {
151
+ uploadUrl: presign.uploadUrl,
152
+ confirmPath: withBucket(
153
+ presign.confirmUrl || "/api/presign/confirm",
154
+ options.bucket
155
+ ),
156
+ confirmBody: {
157
+ fileKey: presign.fileKey,
158
+ size: buffer.length,
159
+ contentType,
160
+ filename,
161
+ contentHash,
162
+ skipVerify: true
163
+ }
164
+ };
165
+ },
166
+ getResultUrl: (confirm) => confirm.url
167
+ });
168
+ printUploadResult(result.url, options, { deduped: result.deduped });
169
+ }
170
+ export {
171
+ uploadDrop,
172
+ uploadFile
173
+ };
@@ -0,0 +1,98 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-MHRMBH4Y.js";
4
+ import {
5
+ apiUpload
6
+ } from "./chunk-YRHPOFJT.js";
7
+ import "./chunk-2AORPTQB.js";
8
+
9
+ // src/commands/upload.ts
10
+ import { readFileSync, existsSync } from "fs";
11
+ import { basename, resolve } from "path";
12
+ var CONTENT_TYPES = {
13
+ png: "image/png",
14
+ jpg: "image/jpeg",
15
+ jpeg: "image/jpeg",
16
+ gif: "image/gif",
17
+ webp: "image/webp",
18
+ svg: "image/svg+xml",
19
+ ico: "image/x-icon",
20
+ avif: "image/avif",
21
+ pdf: "application/pdf",
22
+ mp4: "video/mp4",
23
+ webm: "video/webm",
24
+ mov: "video/quicktime",
25
+ mp3: "audio/mpeg",
26
+ wav: "audio/wav",
27
+ ogg: "audio/ogg",
28
+ zip: "application/zip",
29
+ tar: "application/x-tar",
30
+ gz: "application/gzip",
31
+ txt: "text/plain",
32
+ json: "application/json",
33
+ xml: "application/xml",
34
+ html: "text/html",
35
+ css: "text/css",
36
+ js: "application/javascript"
37
+ };
38
+ function getContentType(filename) {
39
+ const ext = filename.toLowerCase().split(".").pop();
40
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
41
+ }
42
+ function readFile(filePath) {
43
+ const resolvedPath = resolve(filePath);
44
+ if (!existsSync(resolvedPath)) {
45
+ console.error(`Error: File not found: ${filePath}`);
46
+ process.exit(1);
47
+ }
48
+ const buffer = readFileSync(resolvedPath);
49
+ const filename = basename(resolvedPath);
50
+ const contentType = getContentType(filename);
51
+ return { buffer, filename, contentType };
52
+ }
53
+ async function uploadDrop(filePath, options) {
54
+ const { buffer, filename, contentType } = readFile(filePath);
55
+ if (!options.quiet) {
56
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
57
+ }
58
+ const result = await apiUpload(
59
+ "/api/drops/upload",
60
+ buffer,
61
+ filename,
62
+ contentType
63
+ );
64
+ if (options.quiet) {
65
+ console.log(result.url);
66
+ } else {
67
+ console.error("Done!");
68
+ console.log("");
69
+ console.log(result.url);
70
+ }
71
+ }
72
+ async function uploadFile(filePath, options) {
73
+ const { buffer, filename, contentType } = readFile(filePath);
74
+ if (!options.quiet) {
75
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
76
+ }
77
+ let path = "/api/upload";
78
+ if (options.bucket) {
79
+ path += `?bucket=${encodeURIComponent(options.bucket)}`;
80
+ }
81
+ const result = await apiUpload(
82
+ path,
83
+ buffer,
84
+ filename,
85
+ contentType
86
+ );
87
+ if (options.quiet) {
88
+ console.log(result.url);
89
+ } else {
90
+ console.error("Done!");
91
+ console.log("");
92
+ console.log(result.url);
93
+ }
94
+ }
95
+ export {
96
+ uploadDrop,
97
+ uploadFile
98
+ };
@@ -0,0 +1,92 @@
1
+ import {
2
+ createStow
3
+ } from "./chunk-JYOMHKFS.js";
4
+ import {
5
+ formatBytes
6
+ } from "./chunk-ZDVARBCV.js";
7
+ import "./chunk-OZ7QQTIZ.js";
8
+
9
+ // src/commands/upload.ts
10
+ import { existsSync, readFileSync } from "fs";
11
+ import { basename, resolve } from "path";
12
+ var CONTENT_TYPES = {
13
+ png: "image/png",
14
+ jpg: "image/jpeg",
15
+ jpeg: "image/jpeg",
16
+ gif: "image/gif",
17
+ webp: "image/webp",
18
+ svg: "image/svg+xml",
19
+ ico: "image/x-icon",
20
+ avif: "image/avif",
21
+ pdf: "application/pdf",
22
+ mp4: "video/mp4",
23
+ webm: "video/webm",
24
+ mov: "video/quicktime",
25
+ mp3: "audio/mpeg",
26
+ wav: "audio/wav",
27
+ ogg: "audio/ogg",
28
+ zip: "application/zip",
29
+ tar: "application/x-tar",
30
+ gz: "application/gzip",
31
+ txt: "text/plain",
32
+ json: "application/json",
33
+ xml: "application/xml",
34
+ html: "text/html",
35
+ css: "text/css",
36
+ js: "application/javascript"
37
+ };
38
+ function getContentType(filename) {
39
+ const ext = filename.toLowerCase().split(".").pop();
40
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
41
+ }
42
+ function readFile(filePath) {
43
+ const resolvedPath = resolve(filePath);
44
+ if (!existsSync(resolvedPath)) {
45
+ console.error(`Error: File not found: ${filePath}`);
46
+ process.exit(1);
47
+ }
48
+ const buffer = readFileSync(resolvedPath);
49
+ const filename = basename(resolvedPath);
50
+ const contentType = getContentType(filename);
51
+ return { buffer, filename, contentType };
52
+ }
53
+ function printUploadResult(url, options, opts) {
54
+ if (options.quiet) {
55
+ console.log(url);
56
+ return;
57
+ }
58
+ console.error(opts?.deduped ? "Done! (deduped)" : "Done!");
59
+ console.log("");
60
+ console.log(url);
61
+ }
62
+ async function uploadDrop(filePath, options) {
63
+ const { buffer, filename, contentType } = readFile(filePath);
64
+ if (!options.quiet) {
65
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
66
+ }
67
+ const stow = createStow();
68
+ const result = await stow.drop(buffer, {
69
+ filename,
70
+ contentType
71
+ });
72
+ printUploadResult(result.url, options);
73
+ }
74
+ async function uploadFile(filePath, options) {
75
+ const { buffer, filename, contentType } = readFile(filePath);
76
+ if (!options.quiet) {
77
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
78
+ }
79
+ const stow = createStow();
80
+ const result = await stow.uploadFile(buffer, {
81
+ ...options.bucket ? { bucket: options.bucket } : {},
82
+ filename,
83
+ contentType
84
+ });
85
+ printUploadResult(result.url ?? result.key, options, {
86
+ deduped: result.deduped
87
+ });
88
+ }
89
+ export {
90
+ uploadDrop,
91
+ uploadFile
92
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-ZDVARBCV.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-LYCXXF2T.js";
7
+ import "./chunk-OZ7QQTIZ.js";
8
+
9
+ // src/commands/whoami.ts
10
+ async function whoami() {
11
+ const data = await apiRequest("/api/whoami");
12
+ console.log(`Account: ${data.user.email}`);
13
+ console.log("");
14
+ console.log(`Buckets: ${data.stats.bucketCount}`);
15
+ console.log(`Files: ${data.stats.totalFiles}`);
16
+ console.log(`Storage: ${formatBytes(data.stats.totalBytes)}`);
17
+ if (data.key) {
18
+ console.log("");
19
+ console.log(`API Key: ${data.key.name}`);
20
+ console.log(`Scope: ${data.key.scope}`);
21
+ const perms = Object.entries(data.key.permissions).filter(([, v]) => v).map(([k]) => k);
22
+ console.log(`Perms: ${perms.join(", ")}`);
23
+ }
24
+ }
25
+ export {
26
+ whoami
27
+ };
@@ -0,0 +1,28 @@
1
+ import {
2
+ createStow
3
+ } from "./chunk-JYOMHKFS.js";
4
+ import {
5
+ formatBytes
6
+ } from "./chunk-ZDVARBCV.js";
7
+ import "./chunk-OZ7QQTIZ.js";
8
+
9
+ // src/commands/whoami.ts
10
+ async function whoami() {
11
+ const stow = createStow();
12
+ const data = await stow.whoami();
13
+ console.log(`Account: ${data.user.email}`);
14
+ console.log("");
15
+ console.log(`Buckets: ${data.stats.bucketCount}`);
16
+ console.log(`Files: ${data.stats.totalFiles}`);
17
+ console.log(`Storage: ${formatBytes(data.stats.totalBytes)}`);
18
+ if (data.key) {
19
+ console.log("");
20
+ console.log(`API Key: ${data.key.name}`);
21
+ console.log(`Scope: ${data.key.scope}`);
22
+ const perms = Object.entries(data.key.permissions).filter(([, v]) => v).map(([k]) => k);
23
+ console.log(`Perms: ${perms.join(", ")}`);
24
+ }
25
+ }
26
+ export {
27
+ whoami
28
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-MHRMBH4Y.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-YRHPOFJT.js";
7
+ import "./chunk-2AORPTQB.js";
8
+
9
+ // src/commands/whoami.ts
10
+ async function whoami() {
11
+ const data = await apiRequest("/api/whoami");
12
+ console.log(`Account: ${data.user.email}`);
13
+ console.log("");
14
+ console.log(`Buckets: ${data.stats.bucketCount}`);
15
+ console.log(`Files: ${data.stats.totalFiles}`);
16
+ console.log(`Storage: ${formatBytes(data.stats.totalBytes)}`);
17
+ if (data.key) {
18
+ console.log("");
19
+ console.log(`API Key: ${data.key.name}`);
20
+ console.log(`Scope: ${data.key.scope}`);
21
+ const perms = Object.entries(data.key.permissions).filter(([, v]) => v).map(([k]) => k);
22
+ console.log(`Perms: ${perms.join(", ")}`);
23
+ }
24
+ }
25
+ export {
26
+ whoami
27
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-ZDVARBCV.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-R5CCBTXZ.js";
7
+ import "./chunk-2AORPTQB.js";
8
+
9
+ // src/commands/whoami.ts
10
+ async function whoami() {
11
+ const data = await apiRequest("/api/whoami");
12
+ console.log(`Account: ${data.user.email}`);
13
+ console.log("");
14
+ console.log(`Buckets: ${data.stats.bucketCount}`);
15
+ console.log(`Files: ${data.stats.totalFiles}`);
16
+ console.log(`Storage: ${formatBytes(data.stats.totalBytes)}`);
17
+ if (data.key) {
18
+ console.log("");
19
+ console.log(`API Key: ${data.key.name}`);
20
+ console.log(`Scope: ${data.key.scope}`);
21
+ const perms = Object.entries(data.key.permissions).filter(([, v]) => v).map(([k]) => k);
22
+ console.log(`Perms: ${perms.join(", ")}`);
23
+ }
24
+ }
25
+ export {
26
+ whoami
27
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-ZDVARBCV.js";
4
+ import {
5
+ apiRequest
6
+ } from "./chunk-FEMMZ4YZ.js";
7
+ import "./chunk-2AORPTQB.js";
8
+
9
+ // src/commands/whoami.ts
10
+ async function whoami() {
11
+ const data = await apiRequest("/api/whoami");
12
+ console.log(`Account: ${data.user.email}`);
13
+ console.log("");
14
+ console.log(`Buckets: ${data.stats.bucketCount}`);
15
+ console.log(`Files: ${data.stats.totalFiles}`);
16
+ console.log(`Storage: ${formatBytes(data.stats.totalBytes)}`);
17
+ if (data.key) {
18
+ console.log("");
19
+ console.log(`API Key: ${data.key.name}`);
20
+ console.log(`Scope: ${data.key.scope}`);
21
+ const perms = Object.entries(data.key.permissions).filter(([, v]) => v).map(([k]) => k);
22
+ console.log(`Perms: ${perms.join(", ")}`);
23
+ }
24
+ }
25
+ export {
26
+ whoami
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stow-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "CLI for Stow file storage",
6
6
  "license": "MIT",