@archildata/just-bash 0.8.1 → 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 +86 -99
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,158 +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
|
|
47
|
+
// Create a filesystem adapter and a bash executor
|
|
32
48
|
const fs = await ArchilFs.create(client);
|
|
49
|
+
const bash = new Bash({
|
|
50
|
+
fs,
|
|
51
|
+
customCommands: [createArchilCommand(client, fs)],
|
|
52
|
+
});
|
|
33
53
|
|
|
34
|
-
//
|
|
35
|
-
const bash = new Bash({ fs });
|
|
36
|
-
|
|
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
|
-
const inodeId = await fs.resolveInodeId('/mydir');
|
|
55
|
-
|
|
56
|
-
// Checkout to get write access
|
|
57
|
-
await client.checkout(inodeId);
|
|
58
|
-
|
|
59
|
-
// Now you can write
|
|
60
|
-
await bash.exec('echo "hello" > /mydir/newfile.txt');
|
|
74
|
+
const fs = await ArchilFs.create(client);
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
await
|
|
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
|
-
user?: UnixUser;
|
|
113
|
-
subdirectory?: string;
|
|
114
|
-
})
|
|
112
|
+
```bash
|
|
113
|
+
ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
|
|
115
114
|
```
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
- `readFile(path, encoding?)` - Read file as string
|
|
119
|
-
- `readFileBuffer(path)` - Read file as Uint8Array
|
|
120
|
-
- `readdir(path)` - List directory entries
|
|
121
|
-
- `stat(path)` / `lstat(path)` - Get file stats
|
|
122
|
-
- `exists(path)` - Check if path exists
|
|
123
|
-
- `readlink(path)` - Read symlink target
|
|
116
|
+
## Interactive Shell Reference
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- `mkdir(path, options?)` - Create directory
|
|
129
|
-
- `rm(path, options?)` - Delete file/directory
|
|
130
|
-
- `cp(src, dest, options?)` - Copy
|
|
131
|
-
- `mv(src, dest)` - Move/rename
|
|
132
|
-
- `symlink(target, path)` - Create symlink
|
|
133
|
-
|
|
134
|
-
#### Utilities
|
|
135
|
-
- `resolveInodeId(path)` - Get inode ID for delegation operations
|
|
136
|
-
|
|
137
|
-
## Debugging
|
|
118
|
+
```bash
|
|
119
|
+
# Basic usage
|
|
120
|
+
npx @archildata/just-bash <region> <org>/<disk>
|
|
138
121
|
|
|
139
|
-
|
|
122
|
+
# With mount token
|
|
123
|
+
ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
|
|
140
124
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
DEBUG=archil:fs node myapp.js
|
|
125
|
+
# With subdirectory
|
|
126
|
+
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/path/to/subdir
|
|
144
127
|
|
|
145
|
-
#
|
|
146
|
-
|
|
128
|
+
# With debug logging
|
|
129
|
+
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk --log-level debug
|
|
147
130
|
```
|
|
148
131
|
|
|
149
|
-
|
|
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
|
|
150
138
|
|
|
151
|
-
|
|
152
|
-
- **Native protocol** - Direct Archil protocol access, no FUSE overhead
|
|
139
|
+
## Platform Support
|
|
153
140
|
|
|
154
|
-
|
|
141
|
+
Requires **Linux** (x64 or arm64, glibc) or **macOS** (Apple Silicon / arm64) for the native filesystem client.
|
|
155
142
|
|
|
156
|
-
##
|
|
143
|
+
## Support
|
|
157
144
|
|
|
158
|
-
|
|
145
|
+
Questions, feature requests, or issues? Reach us at **support@archil.com**.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archildata/just-bash",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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.
|
|
29
|
+
"@archildata/client": "^0.8.2",
|
|
30
30
|
"commander": "^14.0.3",
|
|
31
31
|
"debug": "^4.3.4",
|
|
32
32
|
"just-bash": "^2.7.0"
|