stow-cli 2.2.1 → 2.2.3

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 (43) hide show
  1. package/README.md +10 -10
  2. package/dist/app-ZIHTOHXL.js +255 -0
  3. package/dist/backfill-BG65X4TP.js +65 -0
  4. package/dist/backfill-KW46AEAL.js +67 -0
  5. package/dist/buckets-FPMMPRR2.js +130 -0
  6. package/dist/buckets-JJBWUVKF.js +137 -0
  7. package/dist/chunk-533UGNLM.js +42 -0
  8. package/dist/chunk-AHBVZRDR.js +29 -0
  9. package/dist/chunk-KPIQZBTO.js +151 -0
  10. package/dist/chunk-MYFLRBWC.js +312 -0
  11. package/dist/chunk-NBHBVKP5.js +54 -0
  12. package/dist/chunk-PE6V3MVP.js +46 -0
  13. package/dist/chunk-RH4BOSYB.js +153 -0
  14. package/dist/chunk-XVKIRHTX.js +29 -0
  15. package/dist/cli.js +181 -199
  16. package/dist/delete-3UDS4RMH.js +34 -0
  17. package/dist/delete-CQJEGLP3.js +34 -0
  18. package/dist/describe-NH3K3LLW.js +79 -0
  19. package/dist/describe-W3ED4VW3.js +79 -0
  20. package/dist/drops-XO4CZ4BH.js +39 -0
  21. package/dist/files-BIMA5L2G.js +206 -0
  22. package/dist/files-SQURZ7VO.js +194 -0
  23. package/dist/health-3U3RHXFS.js +56 -0
  24. package/dist/health-TIJU6U2D.js +61 -0
  25. package/dist/jobs-HUW6Z6A7.js +87 -0
  26. package/dist/jobs-KK5IZYO5.js +99 -0
  27. package/dist/jobs-SX7DIN6T.js +90 -0
  28. package/dist/jobs-XUAXWUAK.js +102 -0
  29. package/dist/maintenance-7UBKZOR3.js +79 -0
  30. package/dist/maintenance-US3PUKFF.js +79 -0
  31. package/dist/mcp-TUZZB2C7.js +189 -0
  32. package/dist/profiles-FOLKZZRU.js +53 -0
  33. package/dist/profiles-XXVM3UKI.js +53 -0
  34. package/dist/queues-MTA2RWUP.js +56 -0
  35. package/dist/queues-X6IU3KBZ.js +61 -0
  36. package/dist/search-ULMFDWHE.js +135 -0
  37. package/dist/search-UWLK4OL2.js +119 -0
  38. package/dist/tags-OFZQ2XCX.js +90 -0
  39. package/dist/tags-V43DCLPQ.js +90 -0
  40. package/dist/upload-F5I2SJRB.js +126 -0
  41. package/dist/upload-N7NAVN3Q.js +126 -0
  42. package/dist/whoami-WUQDFC5P.js +28 -0
  43. package/package.json +12 -12
@@ -0,0 +1,90 @@
1
+ import {
2
+ parseJsonInput
3
+ } from "./chunk-AHBVZRDR.js";
4
+ import {
5
+ validateInput
6
+ } from "./chunk-533UGNLM.js";
7
+ import {
8
+ isJsonOutput,
9
+ output
10
+ } from "./chunk-RH4BOSYB.js";
11
+ import {
12
+ formatTable
13
+ } from "./chunk-FZGOTXTE.js";
14
+ import {
15
+ createStow
16
+ } from "./chunk-5LU25QZK.js";
17
+ import "./chunk-TOADDO2F.js";
18
+
19
+ // src/commands/tags.ts
20
+ async function listTags(options) {
21
+ const stow = createStow();
22
+ const data = await stow.tags.list();
23
+ if (data.tags.length === 0) {
24
+ if (isJsonOutput() || options.json) {
25
+ output(data);
26
+ } else {
27
+ console.log("No tags yet. Create one with: stow tags create <name>");
28
+ }
29
+ return;
30
+ }
31
+ output(data, () => {
32
+ const rows = data.tags.map((t) => [t.name, t.slug, t.color ?? "\u2014", t.id]);
33
+ return formatTable(["Name", "Slug", "Color", "ID"], rows);
34
+ });
35
+ }
36
+ async function createTag(name, options) {
37
+ const input = parseJsonInput(
38
+ options.inputJson,
39
+ { name, color: options.color }
40
+ );
41
+ validateInput(input.name, "tag name");
42
+ if (options.dryRun) {
43
+ console.log(
44
+ JSON.stringify(
45
+ {
46
+ dryRun: true,
47
+ action: "createTag",
48
+ details: {
49
+ name: input.name,
50
+ color: input.color ?? null
51
+ }
52
+ },
53
+ null,
54
+ 2
55
+ )
56
+ );
57
+ return;
58
+ }
59
+ const stow = createStow();
60
+ const tag = await stow.tags.create({
61
+ name: input.name,
62
+ ...input.color ? { color: input.color } : {}
63
+ });
64
+ output(tag, () => `Created tag: ${tag.name}`);
65
+ }
66
+ async function deleteTag(id, options = {}) {
67
+ validateInput(id, "tag id");
68
+ if (options.dryRun) {
69
+ console.log(
70
+ JSON.stringify(
71
+ {
72
+ dryRun: true,
73
+ action: "deleteTag",
74
+ details: { id }
75
+ },
76
+ null,
77
+ 2
78
+ )
79
+ );
80
+ return;
81
+ }
82
+ const stow = createStow();
83
+ await stow.tags.delete(id);
84
+ console.log(`Deleted tag: ${id}`);
85
+ }
86
+ export {
87
+ createTag,
88
+ deleteTag,
89
+ listTags
90
+ };
@@ -0,0 +1,90 @@
1
+ import {
2
+ parseJsonInput
3
+ } from "./chunk-XVKIRHTX.js";
4
+ import {
5
+ validateInput
6
+ } from "./chunk-NBHBVKP5.js";
7
+ import {
8
+ isJsonOutput,
9
+ output
10
+ } from "./chunk-KPIQZBTO.js";
11
+ import {
12
+ formatTable
13
+ } from "./chunk-PE6V3MVP.js";
14
+ import {
15
+ createStow
16
+ } from "./chunk-5LU25QZK.js";
17
+ import "./chunk-TOADDO2F.js";
18
+
19
+ // src/commands/tags.ts
20
+ async function listTags(options) {
21
+ const stow = createStow();
22
+ const data = await stow.tags.list();
23
+ if (data.tags.length === 0) {
24
+ if (isJsonOutput() || options.json) {
25
+ output(data);
26
+ } else {
27
+ console.log("No tags yet. Create one with: stow tags create <name>");
28
+ }
29
+ return;
30
+ }
31
+ output(data, () => {
32
+ const rows = data.tags.map((t) => [t.name, t.slug, t.color ?? "\u2014", t.id]);
33
+ return formatTable(["Name", "Slug", "Color", "ID"], rows);
34
+ });
35
+ }
36
+ async function createTag(name, options) {
37
+ const input = parseJsonInput(options.inputJson, {
38
+ name,
39
+ color: options.color
40
+ });
41
+ validateInput(input.name, "tag name");
42
+ if (options.dryRun) {
43
+ console.log(
44
+ JSON.stringify(
45
+ {
46
+ dryRun: true,
47
+ action: "createTag",
48
+ details: {
49
+ name: input.name,
50
+ color: input.color ?? null
51
+ }
52
+ },
53
+ null,
54
+ 2
55
+ )
56
+ );
57
+ return;
58
+ }
59
+ const stow = createStow();
60
+ const tag = await stow.tags.create({
61
+ name: input.name,
62
+ ...input.color ? { color: input.color } : {}
63
+ });
64
+ output(tag, () => `Created tag: ${tag.name}`);
65
+ }
66
+ async function deleteTag(id, options = {}) {
67
+ validateInput(id, "tag id");
68
+ if (options.dryRun) {
69
+ console.log(
70
+ JSON.stringify(
71
+ {
72
+ dryRun: true,
73
+ action: "deleteTag",
74
+ details: { id }
75
+ },
76
+ null,
77
+ 2
78
+ )
79
+ );
80
+ return;
81
+ }
82
+ const stow = createStow();
83
+ await stow.tags.delete(id);
84
+ console.log(`Deleted tag: ${id}`);
85
+ }
86
+ export {
87
+ createTag,
88
+ deleteTag,
89
+ listTags
90
+ };
@@ -0,0 +1,126 @@
1
+ import {
2
+ validateBucketName
3
+ } from "./chunk-533UGNLM.js";
4
+ import {
5
+ formatBytes
6
+ } from "./chunk-FZGOTXTE.js";
7
+ import {
8
+ createStow
9
+ } from "./chunk-5LU25QZK.js";
10
+ import "./chunk-TOADDO2F.js";
11
+
12
+ // src/commands/upload.ts
13
+ import { existsSync, readFileSync, statSync } from "fs";
14
+ import { basename, resolve } from "path";
15
+ var CONTENT_TYPES = {
16
+ png: "image/png",
17
+ jpg: "image/jpeg",
18
+ jpeg: "image/jpeg",
19
+ gif: "image/gif",
20
+ webp: "image/webp",
21
+ svg: "image/svg+xml",
22
+ ico: "image/x-icon",
23
+ avif: "image/avif",
24
+ pdf: "application/pdf",
25
+ mp4: "video/mp4",
26
+ webm: "video/webm",
27
+ mov: "video/quicktime",
28
+ mp3: "audio/mpeg",
29
+ wav: "audio/wav",
30
+ ogg: "audio/ogg",
31
+ zip: "application/zip",
32
+ tar: "application/x-tar",
33
+ gz: "application/gzip",
34
+ txt: "text/plain",
35
+ json: "application/json",
36
+ xml: "application/xml",
37
+ html: "text/html",
38
+ css: "text/css",
39
+ js: "application/javascript"
40
+ };
41
+ function getContentType(filename) {
42
+ const ext = filename.toLowerCase().split(".").pop();
43
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
44
+ }
45
+ function readFile(filePath) {
46
+ const resolvedPath = resolve(filePath);
47
+ if (!existsSync(resolvedPath)) {
48
+ console.error(`Error: File not found: ${filePath}`);
49
+ process.exit(1);
50
+ }
51
+ const buffer = readFileSync(resolvedPath);
52
+ const filename = basename(resolvedPath);
53
+ const contentType = getContentType(filename);
54
+ return { buffer, filename, contentType };
55
+ }
56
+ function printUploadResult(url, options, opts) {
57
+ if (options.quiet) {
58
+ console.log(url);
59
+ return;
60
+ }
61
+ console.error(opts?.deduped ? "Done! (deduped)" : "Done!");
62
+ console.log("");
63
+ console.log(url);
64
+ }
65
+ async function uploadDrop(filePath, options) {
66
+ const { buffer, filename, contentType } = readFile(filePath);
67
+ if (!options.quiet) {
68
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
69
+ }
70
+ const stow = createStow();
71
+ const result = await stow.drop(buffer, {
72
+ filename,
73
+ contentType
74
+ });
75
+ printUploadResult(result.url, options);
76
+ }
77
+ async function uploadFile(filePath, options) {
78
+ if (options.bucket) {
79
+ validateBucketName(options.bucket);
80
+ }
81
+ const resolvedPath = resolve(filePath);
82
+ if (!existsSync(resolvedPath)) {
83
+ console.error(`Error: File not found: ${filePath}`);
84
+ process.exit(1);
85
+ }
86
+ const filename = basename(resolvedPath);
87
+ const contentType = getContentType(filename);
88
+ const size = statSync(resolvedPath).size;
89
+ if (options.dryRun) {
90
+ console.log(
91
+ JSON.stringify(
92
+ {
93
+ dryRun: true,
94
+ action: "upload",
95
+ details: {
96
+ file: resolvedPath,
97
+ filename,
98
+ contentType,
99
+ size,
100
+ bucket: options.bucket ?? null
101
+ }
102
+ },
103
+ null,
104
+ 2
105
+ )
106
+ );
107
+ return;
108
+ }
109
+ const buffer = readFileSync(resolvedPath);
110
+ if (!options.quiet) {
111
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
112
+ }
113
+ const stow = createStow();
114
+ const result = await stow.uploadFile(buffer, {
115
+ ...options.bucket ? { bucket: options.bucket } : {},
116
+ filename,
117
+ contentType
118
+ });
119
+ printUploadResult(result.url ?? result.key, options, {
120
+ deduped: result.deduped
121
+ });
122
+ }
123
+ export {
124
+ uploadDrop,
125
+ uploadFile
126
+ };
@@ -0,0 +1,126 @@
1
+ import {
2
+ validateBucketName
3
+ } from "./chunk-NBHBVKP5.js";
4
+ import {
5
+ formatBytes
6
+ } from "./chunk-PE6V3MVP.js";
7
+ import {
8
+ createStow
9
+ } from "./chunk-5LU25QZK.js";
10
+ import "./chunk-TOADDO2F.js";
11
+
12
+ // src/commands/upload.ts
13
+ import { existsSync, readFileSync, statSync } from "fs";
14
+ import { basename, resolve } from "path";
15
+ var CONTENT_TYPES = {
16
+ png: "image/png",
17
+ jpg: "image/jpeg",
18
+ jpeg: "image/jpeg",
19
+ gif: "image/gif",
20
+ webp: "image/webp",
21
+ svg: "image/svg+xml",
22
+ ico: "image/x-icon",
23
+ avif: "image/avif",
24
+ pdf: "application/pdf",
25
+ mp4: "video/mp4",
26
+ webm: "video/webm",
27
+ mov: "video/quicktime",
28
+ mp3: "audio/mpeg",
29
+ wav: "audio/wav",
30
+ ogg: "audio/ogg",
31
+ zip: "application/zip",
32
+ tar: "application/x-tar",
33
+ gz: "application/gzip",
34
+ txt: "text/plain",
35
+ json: "application/json",
36
+ xml: "application/xml",
37
+ html: "text/html",
38
+ css: "text/css",
39
+ js: "application/javascript"
40
+ };
41
+ function getContentType(filename) {
42
+ const ext = filename.toLowerCase().split(".").pop();
43
+ return CONTENT_TYPES[ext || ""] || "application/octet-stream";
44
+ }
45
+ function readFile(filePath) {
46
+ const resolvedPath = resolve(filePath);
47
+ if (!existsSync(resolvedPath)) {
48
+ console.error(`Error: File not found: ${filePath}`);
49
+ process.exit(1);
50
+ }
51
+ const buffer = readFileSync(resolvedPath);
52
+ const filename = basename(resolvedPath);
53
+ const contentType = getContentType(filename);
54
+ return { buffer, filename, contentType };
55
+ }
56
+ function printUploadResult(url, options, opts) {
57
+ if (options.quiet) {
58
+ console.log(url);
59
+ return;
60
+ }
61
+ console.error(opts?.deduped ? "Done! (deduped)" : "Done!");
62
+ console.log("");
63
+ console.log(url);
64
+ }
65
+ async function uploadDrop(filePath, options) {
66
+ const { buffer, filename, contentType } = readFile(filePath);
67
+ if (!options.quiet) {
68
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
69
+ }
70
+ const stow = createStow();
71
+ const result = await stow.drop(buffer, {
72
+ filename,
73
+ contentType
74
+ });
75
+ printUploadResult(result.url, options);
76
+ }
77
+ async function uploadFile(filePath, options) {
78
+ if (options.bucket) {
79
+ validateBucketName(options.bucket);
80
+ }
81
+ const resolvedPath = resolve(filePath);
82
+ if (!existsSync(resolvedPath)) {
83
+ console.error(`Error: File not found: ${filePath}`);
84
+ process.exit(1);
85
+ }
86
+ const filename = basename(resolvedPath);
87
+ const contentType = getContentType(filename);
88
+ const { size } = statSync(resolvedPath);
89
+ if (options.dryRun) {
90
+ console.log(
91
+ JSON.stringify(
92
+ {
93
+ dryRun: true,
94
+ action: "upload",
95
+ details: {
96
+ file: resolvedPath,
97
+ filename,
98
+ contentType,
99
+ size,
100
+ bucket: options.bucket ?? null
101
+ }
102
+ },
103
+ null,
104
+ 2
105
+ )
106
+ );
107
+ return;
108
+ }
109
+ const buffer = readFileSync(resolvedPath);
110
+ if (!options.quiet) {
111
+ console.error(`Uploading ${filename} (${formatBytes(buffer.length)})...`);
112
+ }
113
+ const stow = createStow();
114
+ const result = await stow.uploadFile(buffer, {
115
+ ...options.bucket ? { bucket: options.bucket } : {},
116
+ filename,
117
+ contentType
118
+ });
119
+ printUploadResult(result.url ?? result.key, options, {
120
+ deduped: result.deduped
121
+ });
122
+ }
123
+ export {
124
+ uploadDrop,
125
+ uploadFile
126
+ };
@@ -0,0 +1,28 @@
1
+ import {
2
+ formatBytes
3
+ } from "./chunk-PE6V3MVP.js";
4
+ import {
5
+ createStow
6
+ } from "./chunk-5LU25QZK.js";
7
+ import "./chunk-TOADDO2F.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
+ };
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "stow-cli",
3
- "version": "2.2.1",
4
- "type": "module",
3
+ "version": "2.2.3",
5
4
  "description": "CLI for Stow file storage",
5
+ "keywords": [
6
+ "cli",
7
+ "file-storage",
8
+ "stow",
9
+ "upload"
10
+ ],
11
+ "homepage": "https://stow.sh",
6
12
  "license": "MIT",
7
13
  "repository": {
8
14
  "type": "git",
9
15
  "url": "git+https://github.com/howells/stow.git",
10
16
  "directory": "packages/stow-cli"
11
17
  },
12
- "homepage": "https://stow.sh",
13
- "keywords": [
14
- "stow",
15
- "file-storage",
16
- "cli",
17
- "upload"
18
- ],
19
18
  "bin": {
20
19
  "stow": "./dist/cli.js"
21
20
  },
22
21
  "files": [
23
22
  "dist"
24
23
  ],
24
+ "type": "module",
25
25
  "scripts": {
26
26
  "build": "tsup src/cli.ts --format esm --shims",
27
27
  "dev": "tsup src/cli.ts --format esm --shims --watch",
28
- "test": "vitest run",
29
- "test:watch": "vitest"
28
+ "test": "vp test run",
29
+ "test:watch": "vp test"
30
30
  },
31
31
  "dependencies": {
32
32
  "@howells/stow-server": "workspace:*",
@@ -47,6 +47,6 @@
47
47
  "@types/react": "19.2.14",
48
48
  "tsup": "^8.5.1",
49
49
  "typescript": "^5.9.3",
50
- "vitest": "^4.1.0"
50
+ "vite-plus": "catalog:"
51
51
  }
52
52
  }