@archildata/just-bash 0.1.13 → 0.8.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.
- package/README.md +88 -98
- package/dist/index.cjs +571 -458
- package/dist/index.d.cts +60 -17
- package/dist/index.d.ts +60 -17
- package/dist/index.js +561 -469
- package/dist/shell.js +170 -108
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,155 +1,145 @@
|
|
|
1
1
|
# @archildata/just-bash
|
|
2
2
|
|
|
3
|
-
Archil
|
|
3
|
+
Run bash commands against your cloud storage through [Archil](https://archil.com) — no local mount required. Works in scripts, CI pipelines, and interactive sessions.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
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:
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
ARCHIL_TOKEN=
|
|
10
|
+
ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
This drops you into an interactive shell. The files you see are the contents of your cloud bucket:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ ls
|
|
17
|
+
data/ logs/ config.json
|
|
18
|
+
|
|
19
|
+
$ cat config.json
|
|
20
|
+
{"version": 2, "debug": false}
|
|
21
|
+
|
|
22
|
+
$ echo "hello from archil" > greeting.txt
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Everything you do here — reads, writes, renames, deletes — goes through Archil to your bucket.
|
|
26
|
+
|
|
27
|
+
## Using in Your Code
|
|
28
|
+
|
|
29
|
+
The interactive shell is great for poking around, but you can also run bash commands from your own code. This is useful for scripts, CI pipelines, AI agents, or anywhere you want to run shell commands against your cloud storage.
|
|
12
30
|
|
|
13
31
|
```bash
|
|
14
32
|
npm install @archildata/just-bash @archildata/client just-bash
|
|
15
33
|
```
|
|
16
34
|
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
35
|
```typescript
|
|
20
36
|
import { ArchilClient } from '@archildata/client';
|
|
21
|
-
import { ArchilFs } from '@archildata/just-bash';
|
|
37
|
+
import { ArchilFs, createArchilCommand } from '@archildata/just-bash';
|
|
22
38
|
import { Bash } from 'just-bash';
|
|
23
39
|
|
|
24
|
-
// Connect to
|
|
40
|
+
// Connect to your disk
|
|
25
41
|
const client = await ArchilClient.connect({
|
|
26
42
|
region: 'aws-us-east-1',
|
|
27
|
-
diskName: 'myaccount/
|
|
28
|
-
authToken: '
|
|
43
|
+
diskName: 'myaccount/my-disk',
|
|
44
|
+
authToken: 'my-secret-mount-token',
|
|
29
45
|
});
|
|
30
46
|
|
|
31
|
-
// Create filesystem adapter
|
|
32
|
-
const fs =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
// Create a filesystem adapter and a bash executor
|
|
48
|
+
const fs = await ArchilFs.create(client);
|
|
49
|
+
const bash = new Bash({
|
|
50
|
+
fs,
|
|
51
|
+
customCommands: [createArchilCommand(client, fs)],
|
|
52
|
+
});
|
|
36
53
|
|
|
37
|
-
// Run commands
|
|
54
|
+
// Run commands just like you would in a terminal
|
|
38
55
|
const result = await bash.exec('ls -la /');
|
|
39
56
|
console.log(result.stdout);
|
|
40
57
|
|
|
41
|
-
//
|
|
42
|
-
|
|
58
|
+
// Write a file
|
|
59
|
+
await bash.exec('echo "hello world" > /greeting.txt');
|
|
60
|
+
|
|
61
|
+
// Read it back
|
|
62
|
+
const cat = await bash.exec('cat /greeting.txt');
|
|
63
|
+
console.log(cat.stdout); // "hello world"
|
|
43
64
|
|
|
44
|
-
//
|
|
65
|
+
// Clean up
|
|
45
66
|
await client.close();
|
|
46
67
|
```
|
|
47
68
|
|
|
48
|
-
##
|
|
69
|
+
## Using the Filesystem Adapter Directly
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
If you don't need bash and just want standard file operations, you can use `ArchilFs` on its own. It works like Node.js `fs`:
|
|
51
72
|
|
|
52
73
|
```typescript
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
await
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await
|
|
61
|
-
|
|
62
|
-
// Release the delegation when done
|
|
63
|
-
await client.checkin(inodeId);
|
|
74
|
+
const fs = await ArchilFs.create(client);
|
|
75
|
+
|
|
76
|
+
await fs.writeFile('/notes.txt', 'some content');
|
|
77
|
+
const content = await fs.readFile('/notes.txt');
|
|
78
|
+
const entries = await fs.readdir('/');
|
|
79
|
+
const stats = await fs.stat('/notes.txt');
|
|
80
|
+
await fs.mkdir('/mydir', { recursive: true });
|
|
81
|
+
await fs.cp('/notes.txt', '/mydir/notes-copy.txt');
|
|
82
|
+
await fs.rm('/notes.txt');
|
|
64
83
|
```
|
|
65
84
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
await client.checkout(inodeId, { force: true });
|
|
70
|
-
```
|
|
85
|
+
## Writing Files (Delegations)
|
|
71
86
|
|
|
72
|
-
|
|
87
|
+
Archil uses a delegation system for writes. When multiple clients connect to the same disk, delegations coordinate who can write to what. Before writing to a file or directory, you "check out" a delegation on it. When you're done, you "check in" to release it.
|
|
73
88
|
|
|
74
|
-
|
|
89
|
+
In the interactive shell, use the built-in `archil` command:
|
|
75
90
|
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
```
|
|
92
|
+
$ archil checkout /mydir
|
|
93
|
+
$ echo "hello" > /mydir/newfile.txt
|
|
94
|
+
$ archil checkin /mydir
|
|
80
95
|
```
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
The package includes an interactive shell for testing:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Positional arguments (recommended)
|
|
88
|
-
npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
|
|
97
|
+
In code, use the client directly:
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
```typescript
|
|
100
|
+
const inodeId = await fs.resolveInodeId('/mydir');
|
|
101
|
+
await client.checkout(inodeId);
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
|
|
103
|
+
await bash.exec('echo "hello" > /mydir/newfile.txt');
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
npx @archildata/just-bash aws-us-east-1 myaccount/mydisk --log-level debug
|
|
105
|
+
await client.checkin(inodeId);
|
|
98
106
|
```
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
- Standard bash commands (`ls`, `cat`, `echo`, etc.)
|
|
102
|
-
- `archil checkout [--force] <path>` - Acquire write delegation
|
|
103
|
-
- `archil checkin <path>` - Release write delegation
|
|
104
|
-
- `archil help` - Show archil commands
|
|
105
|
-
|
|
106
|
-
## API
|
|
108
|
+
## Subdirectory Mounting
|
|
107
109
|
|
|
108
|
-
|
|
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:
|
|
109
111
|
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
+
```bash
|
|
113
|
+
ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
|
|
112
114
|
```
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
- `readFile(path, encoding?)` - Read file as string
|
|
116
|
-
- `readFileBuffer(path)` - Read file as Uint8Array
|
|
117
|
-
- `readdir(path)` - List directory entries
|
|
118
|
-
- `stat(path)` / `lstat(path)` - Get file stats
|
|
119
|
-
- `exists(path)` - Check if path exists
|
|
120
|
-
- `readlink(path)` - Read symlink target
|
|
116
|
+
## Interactive Shell Reference
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- `mkdir(path, options?)` - Create directory
|
|
126
|
-
- `rm(path, options?)` - Delete file/directory
|
|
127
|
-
- `cp(src, dest, options?)` - Copy
|
|
128
|
-
- `mv(src, dest)` - Move/rename
|
|
129
|
-
- `symlink(target, path)` - Create symlink
|
|
130
|
-
|
|
131
|
-
#### Utilities
|
|
132
|
-
- `resolveInodeId(path)` - Get inode ID for delegation operations
|
|
133
|
-
|
|
134
|
-
## Debugging
|
|
118
|
+
```bash
|
|
119
|
+
# Basic usage
|
|
120
|
+
npx @archildata/just-bash <region> <org>/<disk>
|
|
135
121
|
|
|
136
|
-
|
|
122
|
+
# With mount token
|
|
123
|
+
ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
|
|
137
124
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
DEBUG=archil:fs node myapp.js
|
|
125
|
+
# With subdirectory
|
|
126
|
+
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/path/to/subdir
|
|
141
127
|
|
|
142
|
-
#
|
|
143
|
-
|
|
128
|
+
# With debug logging
|
|
129
|
+
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk --log-level debug
|
|
144
130
|
```
|
|
145
131
|
|
|
146
|
-
|
|
132
|
+
Shell commands:
|
|
133
|
+
- Standard bash commands (`ls`, `cat`, `echo`, `cp`, `mv`, `rm`, etc.)
|
|
134
|
+
- `archil checkout [--force] <path>` — acquire write delegation
|
|
135
|
+
- `archil checkin <path>` — release write delegation
|
|
136
|
+
- `archil list-delegations` — show currently held delegations
|
|
137
|
+
- `archil help` — show archil commands
|
|
147
138
|
|
|
148
|
-
|
|
149
|
-
- **Native protocol** - Direct Archil protocol access, no FUSE overhead
|
|
139
|
+
## Platform Support
|
|
150
140
|
|
|
151
|
-
|
|
141
|
+
Requires **Linux** (x64 or arm64, glibc) or **macOS** (Apple Silicon / arm64) for the native filesystem client.
|
|
152
142
|
|
|
153
|
-
##
|
|
143
|
+
## Support
|
|
154
144
|
|
|
155
|
-
|
|
145
|
+
Questions, feature requests, or issues? Reach us at **support@archil.com**.
|