@archildata/just-bash
v0.1.13
Published
Archil filesystem adapter for just-bash
Maintainers
Readme
@archildata/just-bash
Archil filesystem adapter for just-bash - run bash commands against Archil distributed filesystems.
Launch an interactive shell against your Archil disk:
ARCHIL_TOKEN=adt_xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydiskInstallation
npm install @archildata/just-bash @archildata/client just-bashQuick Start
import { ArchilClient } from '@archildata/client';
import { ArchilFs } from '@archildata/just-bash';
import { Bash } from 'just-bash';
// Connect to Archil
const client = await ArchilClient.connect({
region: 'aws-us-east-1',
diskName: 'myaccount/mydisk',
authToken: 'adt_xxx', // or omit for IAM auth
});
// Create filesystem adapter
const fs = new ArchilFs(client);
// Use with just-bash
const bash = new Bash({ fs });
// Run commands
const result = await bash.exec('ls -la /');
console.log(result.stdout);
// Read files
const content = await bash.exec('cat /myfile.txt');
// Close when done
await client.close();Writing Files (Delegations)
Archil uses a delegation system for write access. Before writing, you need to "checkout" the directory or file:
// Get the inode ID for a path
const inodeId = await fs.resolveInodeId('/mydir');
// Checkout to get write access
await client.checkout(inodeId);
// Now you can write
await bash.exec('echo "hello" > /mydir/newfile.txt');
// Release the delegation when done
await client.checkin(inodeId);For shared/multi-client access, use force to revoke existing delegations:
await client.checkout(inodeId, { force: true });With User Context
Specify a Unix user context for permission checks:
const fs = new ArchilFs(client, {
user: { uid: 1000, gid: 1000 }
});Interactive Shell
The package includes an interactive shell for testing:
# Positional arguments (recommended)
npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
# With flags
npx @archildata/just-bash --region aws-us-east-1 --disk myaccount/mydisk
# With token (use env var to keep out of shell history)
ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
# With debug logging
npx @archildata/just-bash aws-us-east-1 myaccount/mydisk --log-level debugShell commands:
- Standard bash commands (
ls,cat,echo, etc.) archil checkout [--force] <path>- Acquire write delegationarchil checkin <path>- Release write delegationarchil help- Show archil commands
API
ArchilFs
new ArchilFs(client: ArchilClient, options?: { user?: UnixUser })Read Operations
readFile(path, encoding?)- Read file as stringreadFileBuffer(path)- Read file as Uint8Arrayreaddir(path)- List directory entriesstat(path)/lstat(path)- Get file statsexists(path)- Check if path existsreadlink(path)- Read symlink target
Write Operations
writeFile(path, content)- Write fileappendFile(path, content)- Append to filemkdir(path, options?)- Create directoryrm(path, options?)- Delete file/directorycp(src, dest, options?)- Copymv(src, dest)- Move/renamesymlink(target, path)- Create symlink
Utilities
resolveInodeId(path)- Get inode ID for delegation operations
Debugging
Enable debug logging with the DEBUG environment variable:
# Enable archil:fs logging
DEBUG=archil:fs node myapp.js
# Enable all archil debug logging
DEBUG=archil:* node myapp.jsPerformance
- Chunked reads - Large files read in 4 MiB chunks
- Native protocol - Direct Archil protocol access, no FUSE overhead
Note: For best performance, run your application in the same region as your Archil disk (e.g., if your disk is in
aws-us-east-1, deploy your app to AWS us-east-1).
License
MIT
