@archildata/ just- bash (英语)
未建议新项目. 随着Archil的无服务器执行(
disk <id> exec <command>,或Disk.exec()从disk软件包),您可以在磁盘上运行命令,而无需站起客户端挂载或击打环境——命令运行在一个Archil管理的容器中,并带有磁盘预挂载并返回stdout/stderr/exit代码. 我们不再建议@archildata/just-bash; 达到disk exec换句话说.这个软件包仍然为已有的用户发布,他们围绕它构建了工具.
运行针对您云存储的点击命令 阿奇尔 不需要本地挂载。 工作包括脚本、CI管道和互动会议.
快速启动
如果您已经设置了 Archil 磁盘( 请参看 disk 对于设置,您可以在一个命令中启动 shell :
ARCHIL_DISK_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
这会让你变成一个交互式的外壳。 你看到的文件是您云桶的内容:
$ ls
data/ logs/ config.json
$ cat config.json
{"version": 2, "debug": false}
$ echo "hello from archil" > greeting.txt
你在这里所做的一切——读取,写出,重命名,删取——都通过阿奇尔到你的桶上去.
使用您的代码
交互外壳很适合绕来绕去,但您也可以从自己的代码运行bash命令. 这对脚本, CI 管道, AI 代理, 或任何您想要运行的外壳命令对你的云存储器有用.
npm install @archildata/just-bash @archildata/native just-bash
import { ArchilClient } from '@archildata/native';
import { ArchilFs, createArchilCommand } from '@archildata/just-bash';
import { Bash } from 'just-bash';
// Connect to your disk
const client = await ArchilClient.connect({
region: 'aws-us-east-1',
diskName: 'myaccount/my-disk',
authToken: 'my-secret-mount-token',
});
// Create a filesystem adapter and a bash executor
const fs = await ArchilFs.create(client);
const bash = new Bash({
fs,
customCommands: [createArchilCommand(client, fs)],
});
// Run commands just like you would in a terminal
const result = await bash.exec('ls -la /');
console.log(result.stdout);
// Write a file
await bash.exec('echo "hello world" > /greeting.txt');
// Read it back
const cat = await bash.exec('cat /greeting.txt');
console.log(cat.stdout); // "hello world"
// Clean up
await client.close();
直接使用文件系统适配器
如果你不需要击打而只需要标准文件操作,你可以使用 ArchilFs 独自一人。 它的工作像节点Js fs数字 :
const fs = await ArchilFs.create(client);
await fs.writeFile('/notes.txt', 'some content');
const content = await fs.readFile('/notes.txt');
const entries = await fs.readdir('/');
const stats = await fs.stat('/notes.txt');
await fs.mkdir('/mydir', { recursive: true });
await fs.cp('/notes.txt', '/mydir/notes-copy.txt');
await fs.rm('/notes.txt');
写入文件( 代表团)
Archil使用授权系统写作. 当多个客户端连接到同一个磁盘时,代表团会协调谁可以写到什么. 在写到文件或目录之前,你先"检查"一个代表团在上面. 完事后"入户"放出.
在交互式外壳中,使用内置 archil 命令 :
$ archil checkout /mydir
$ echo "hello" > /mydir/newfile.txt
$ archil checkin /mydir
在代码中,直接使用客户端:
const inodeId = await fs.resolveInodeId('/mydir');
await client.checkout(inodeId);
await bash.exec('echo "hello" > /mydir/newfile.txt');
await client.checkin(inodeId);
子目录挂起
您可以挂载磁盘的子目录而不是根 。 这在你的桶里嵌入一个项目时有用:
ARCHIL_DISK_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
交互式 shell 引用
# Basic usage
npx @archildata/just-bash <region> <org>/<disk>
# With mount token
ARCHIL_DISK_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
# With subdirectory
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/path/to/subdir
# With debug logging
npx @archildata/just-bash aws-us-east-1 myaccount/my-disk --log-level debug
贝壳命令 :
- 标准 bash 命令 (
ls, (中文(简体) ),cat, (中文(简体) ),echo, (中文(简体) ),cp, (中文(简体) ),mv, (中文(简体) ),rm页:1 archil checkout [--force] <path>获得书面授权archil checkin <path>——放行写代表团archil list-delegations——展出现有代表团archil help——显示拱门命令
平台支持
要求数 链接 (x64 或 arm64, glibc) 或 马科斯 (pple Silicon / arm64),用于本地文件系统客户端.
支助
问题、专题请求还是问题? 联系我们 支持@ archil.com。 。 。 .