@archildata/just-bash 0.8.4 → 0.8.7

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Run bash commands against your cloud storage through [Archil](https://archil.com
7
7
  If you already have an Archil disk set up (see [@archildata/client](https://www.npmjs.com/package/@archildata/client) for setup), you can start a shell in one command:
8
8
 
9
9
  ```bash
10
- ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
10
+ ARCHIL_DISK_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
11
11
  ```
12
12
 
13
13
  This drops you into an interactive shell. The files you see are the contents of your cloud bucket:
@@ -110,7 +110,7 @@ await client.checkin(inodeId);
110
110
  You can mount a subdirectory of a disk instead of the root. This is useful when your bucket has a project nested inside it:
111
111
 
112
112
  ```bash
113
- ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
113
+ ARCHIL_DISK_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
114
114
  ```
115
115
 
116
116
  ## Interactive Shell Reference
@@ -120,7 +120,7 @@ ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myacc
120
120
  npx @archildata/just-bash <region> <org>/<disk>
121
121
 
122
122
  # With mount token
123
- ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
123
+ ARCHIL_DISK_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
124
124
 
125
125
  # With subdirectory
126
126
  npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/path/to/subdir
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(index_exports);
38
38
 
39
39
  // src/ArchilFs.ts
40
40
  var import_debug = __toESM(require("debug"), 1);
41
+ var import_client = require("@archildata/client");
41
42
  var debug = (0, import_debug.default)("archil:fs");
42
43
  var ArchilFs = class _ArchilFs {
43
44
  client;
@@ -242,15 +243,14 @@ var ArchilFs = class _ArchilFs {
242
243
  debug("readFileBuffer file is empty, returning empty buffer");
243
244
  return new Uint8Array(0);
244
245
  }
245
- const MAX_CHUNK = 4 * 1024 * 1024;
246
- if (size <= MAX_CHUNK) {
246
+ if (size <= import_client.MAXIMUM_READ_SIZE) {
247
247
  const buffer = await this.client.readInode(inodeId, 0, size, { user: this.user });
248
248
  return new Uint8Array(buffer);
249
249
  }
250
250
  const result = new Uint8Array(size);
251
251
  let offset = 0;
252
252
  while (offset < size) {
253
- const chunkSize = Math.min(MAX_CHUNK, size - offset);
253
+ const chunkSize = Math.min(import_client.MAXIMUM_READ_SIZE, size - offset);
254
254
  const chunk = await this.client.readInode(inodeId, offset, chunkSize, { user: this.user });
255
255
  result.set(new Uint8Array(chunk), offset);
256
256
  offset += chunkSize;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/ArchilFs.ts
2
2
  import createDebug from "debug";
3
+ import { MAXIMUM_READ_SIZE } from "@archildata/client";
3
4
  var debug = createDebug("archil:fs");
4
5
  var ArchilFs = class _ArchilFs {
5
6
  client;
@@ -204,15 +205,14 @@ var ArchilFs = class _ArchilFs {
204
205
  debug("readFileBuffer file is empty, returning empty buffer");
205
206
  return new Uint8Array(0);
206
207
  }
207
- const MAX_CHUNK = 4 * 1024 * 1024;
208
- if (size <= MAX_CHUNK) {
208
+ if (size <= MAXIMUM_READ_SIZE) {
209
209
  const buffer = await this.client.readInode(inodeId, 0, size, { user: this.user });
210
210
  return new Uint8Array(buffer);
211
211
  }
212
212
  const result = new Uint8Array(size);
213
213
  let offset = 0;
214
214
  while (offset < size) {
215
- const chunkSize = Math.min(MAX_CHUNK, size - offset);
215
+ const chunkSize = Math.min(MAXIMUM_READ_SIZE, size - offset);
216
216
  const chunk = await this.client.readInode(inodeId, offset, chunkSize, { user: this.user });
217
217
  result.set(new Uint8Array(chunk), offset);
218
218
  offset += chunkSize;
package/dist/shell.js CHANGED
@@ -19,7 +19,7 @@ Quick Start (S3 bucket mode):
19
19
  Traditional usage (direct connection):
20
20
  $ npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
21
21
  $ npx @archildata/just-bash --region aws-us-east-1 --disk myaccount/mydisk
22
- $ ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
22
+ $ ARCHIL_DISK_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
23
23
 
24
24
  Subdirectory mounting (mount a subdirectory as the root):
25
25
  $ npx @archildata/just-bash aws-us-east-1 myaccount/mydisk:/data/project
@@ -28,7 +28,7 @@ Environment variables:
28
28
  ARCHIL_API_KEY API key for disk management
29
29
  ARCHIL_REGION Fallback for --region
30
30
  ARCHIL_DISK Fallback for --disk
31
- ARCHIL_TOKEN Fallback for --token (recommended for secrets)
31
+ ARCHIL_DISK_TOKEN Fallback for --token (recommended for secrets)
32
32
  ARCHIL_LOG_LEVEL Fallback for --log-level
33
33
  AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY S3 credentials for bucket mode
34
34
  `);
@@ -59,20 +59,9 @@ function findDiskForBucket(disks, bucketName) {
59
59
  }
60
60
  async function runS3BucketMode() {
61
61
  const s3Url = args[0];
62
- const apiKey = opts.apiKey || process.env.ARCHIL_API_KEY;
63
62
  const logLevel = opts.logLevel || process.env.ARCHIL_LOG_LEVEL;
64
63
  const region = opts.region || process.env.ARCHIL_REGION || "aws-us-east-1";
65
64
  const bucketRegion = opts.bucketRegion || "us-east-1";
66
- if (!apiKey) {
67
- console.error("Error: --api-key is required for S3 bucket mode");
68
- console.error("");
69
- console.error("Usage:");
70
- console.error(" npx @archildata/just-bash s3://my-bucket --api-key adt_xxx");
71
- console.error("");
72
- console.error("Or set ARCHIL_API_KEY environment variable:");
73
- console.error(" ARCHIL_API_KEY=adt_xxx npx @archildata/just-bash s3://my-bucket");
74
- process.exit(1);
75
- }
76
65
  const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
77
66
  const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
78
67
  if (!awsAccessKeyId || !awsSecretAccessKey) {
@@ -93,12 +82,25 @@ async function runS3BucketMode() {
93
82
  console.log(` Region: ${region}`);
94
83
  console.log(` Bucket Region: ${bucketRegion}`);
95
84
  console.log("");
96
- const archil = new Archil({
97
- apiKey,
98
- region
99
- });
85
+ let archil;
86
+ try {
87
+ archil = new Archil({
88
+ apiKey: opts.apiKey,
89
+ region
90
+ });
91
+ } catch (err) {
92
+ console.error(err instanceof Error ? err.message : err);
93
+ console.error("");
94
+ console.error("Usage:");
95
+ console.error(" npx @archildata/just-bash s3://my-bucket --api-key adt_xxx");
96
+ console.error("");
97
+ console.error("Or set ARCHIL_API_KEY environment variable:");
98
+ console.error(" ARCHIL_API_KEY=adt_xxx npx @archildata/just-bash s3://my-bucket");
99
+ process.exit(1);
100
+ }
100
101
  console.log("Checking for existing disk...");
101
102
  let disk;
103
+ let mountToken;
102
104
  try {
103
105
  const disks = await archil.disks.list();
104
106
  disk = findDiskForBucket(disks, bucket);
@@ -113,7 +115,7 @@ async function runS3BucketMode() {
113
115
  const diskName = diskNameFromBucket(bucket);
114
116
  console.log(`Creating new disk: ${diskName}`);
115
117
  try {
116
- disk = await archil.disks.create({
118
+ const result = await archil.disks.create({
117
119
  name: diskName,
118
120
  mounts: [
119
121
  {
@@ -125,16 +127,27 @@ async function runS3BucketMode() {
125
127
  }
126
128
  ]
127
129
  });
130
+ disk = result.disk;
131
+ mountToken = result.token ?? void 0;
128
132
  console.log(`Created disk: ${disk.name} (${disk.id})`);
129
133
  } catch (err) {
130
134
  console.error("Failed to create disk:", err instanceof Error ? err.message : err);
131
135
  process.exit(1);
132
136
  }
133
137
  }
138
+ if (!mountToken) {
139
+ try {
140
+ const { token } = await disk.createToken("just-bash");
141
+ mountToken = token;
142
+ } catch (err) {
143
+ console.error("Failed to create mount token:", err instanceof Error ? err.message : err);
144
+ process.exit(1);
145
+ }
146
+ }
134
147
  console.log("Connecting...");
135
148
  let client;
136
149
  try {
137
- client = await disk.mount({ authToken: apiKey, logLevel });
150
+ client = await disk.mount({ authToken: mountToken, logLevel });
138
151
  console.log("Connected!");
139
152
  } catch (err) {
140
153
  console.error("Failed to connect:", err instanceof Error ? err.message : err);
@@ -145,7 +158,7 @@ async function runS3BucketMode() {
145
158
  async function runDirectMode() {
146
159
  const region = args[0] || opts.region || process.env.ARCHIL_REGION;
147
160
  const rawDisk = args[1] || opts.disk || process.env.ARCHIL_DISK;
148
- const authToken = opts.token || process.env.ARCHIL_TOKEN;
161
+ const authToken = opts.token || process.env.ARCHIL_DISK_TOKEN;
149
162
  const logLevel = opts.logLevel || process.env.ARCHIL_LOG_LEVEL;
150
163
  let diskName;
151
164
  let subdirectory;
@@ -170,7 +183,7 @@ async function runDirectMode() {
170
183
  console.error(" npx @archildata/just-bash s3://my-bucket --api-key adt_xxx");
171
184
  console.error("\nExamples:");
172
185
  console.error(" npx @archildata/just-bash aws-us-east-1 myaccount/mydisk");
173
- console.error(" ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk");
186
+ console.error(" ARCHIL_DISK_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk");
174
187
  console.error("\nRun with --help for more options.");
175
188
  process.exit(1);
176
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archildata/just-bash",
3
- "version": "0.8.4",
3
+ "version": "0.8.7",
4
4
  "description": "Archil filesystem adapter for just-bash",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -26,7 +26,7 @@
26
26
  "shell": "tsx bin/shell.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@archildata/client": "^0.8.4",
29
+ "@archildata/client": "^0.8.7",
30
30
  "commander": "^14.0.3",
31
31
  "debug": "^4.3.4",
32
32
  "just-bash": "^2.7.0"