@archildata/just-bash 0.1.0
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/LICENSE +21 -0
- package/README.md +139 -0
- package/bin/shell.ts +276 -0
- package/dist/index.cjs +532 -0
- package/dist/index.d.cts +171 -0
- package/dist/index.d.mts +185 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +514 -0
- package/dist/index.mjs +522 -0
- package/package.json +55 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as _archil_node from '@archil/node';
|
|
2
|
+
import { ArchilClient, UnixUser } from '@archil/node';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Archil filesystem adapter for just-bash
|
|
6
|
+
*
|
|
7
|
+
* Implements the IFileSystem interface from just-bash using the ArchilClient
|
|
8
|
+
* from @archil/node for direct protocol access to Archil distributed filesystems.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type BufferEncoding = "utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex" | "latin1";
|
|
12
|
+
type FileContent = string | Uint8Array;
|
|
13
|
+
interface FsStat {
|
|
14
|
+
isFile(): boolean;
|
|
15
|
+
isDirectory(): boolean;
|
|
16
|
+
isSymlink(): boolean;
|
|
17
|
+
mode: number;
|
|
18
|
+
size: number;
|
|
19
|
+
mtimeMs: number;
|
|
20
|
+
atimeMs: number;
|
|
21
|
+
ctimeMs: number;
|
|
22
|
+
birthtimeMs: number;
|
|
23
|
+
}
|
|
24
|
+
interface DirentEntry {
|
|
25
|
+
name: string;
|
|
26
|
+
isFile(): boolean;
|
|
27
|
+
isDirectory(): boolean;
|
|
28
|
+
isSymlink(): boolean;
|
|
29
|
+
}
|
|
30
|
+
interface IFileSystem {
|
|
31
|
+
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
32
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
33
|
+
readdir(path: string): Promise<string[]>;
|
|
34
|
+
readdirWithFileTypes?(path: string): Promise<DirentEntry[]>;
|
|
35
|
+
stat(path: string): Promise<FsStat>;
|
|
36
|
+
lstat(path: string): Promise<FsStat>;
|
|
37
|
+
exists(path: string): Promise<boolean>;
|
|
38
|
+
readlink(path: string): Promise<string>;
|
|
39
|
+
realpath(path: string): Promise<string>;
|
|
40
|
+
writeFile(path: string, content: FileContent): Promise<void>;
|
|
41
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
42
|
+
mkdir(path: string, options?: {
|
|
43
|
+
recursive?: boolean;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
rm(path: string, options?: {
|
|
46
|
+
recursive?: boolean;
|
|
47
|
+
force?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
cp(src: string, dest: string, options?: {
|
|
50
|
+
recursive?: boolean;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
mv(src: string, dest: string): Promise<void>;
|
|
53
|
+
symlink(target: string, path: string): Promise<void>;
|
|
54
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
55
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
56
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
57
|
+
resolvePath(base: string, ...paths: string[]): string;
|
|
58
|
+
getAllPaths?(): Promise<string[]>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ArchilFs implements the just-bash IFileSystem interface using Archil protocol.
|
|
62
|
+
*
|
|
63
|
+
* This adapter provides:
|
|
64
|
+
* - Path-to-inode resolution with caching
|
|
65
|
+
* - Full filesystem operations via Archil protocol
|
|
66
|
+
* - Optional user context for permission checks
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { ArchilClient } from '@archil/node';
|
|
71
|
+
* import { ArchilFs } from '@archil/just-bash';
|
|
72
|
+
*
|
|
73
|
+
* const client = await ArchilClient.connectAuthenticated({
|
|
74
|
+
* mountServer: 'mount.archil.com:443',
|
|
75
|
+
* mountName: 'myaccount/mydisk',
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const fs = new ArchilFs(client);
|
|
79
|
+
*
|
|
80
|
+
* // Use with just-bash
|
|
81
|
+
* import { Bash } from 'just-bash';
|
|
82
|
+
* const bash = new Bash({ fs });
|
|
83
|
+
* await bash.run('ls -la /');
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare class ArchilFs implements IFileSystem {
|
|
87
|
+
private client;
|
|
88
|
+
private inodeCache;
|
|
89
|
+
private user?;
|
|
90
|
+
private rootInodeId;
|
|
91
|
+
/**
|
|
92
|
+
* Create a new ArchilFs adapter
|
|
93
|
+
*
|
|
94
|
+
* @param client - Connected ArchilClient instance
|
|
95
|
+
* @param options - Optional configuration
|
|
96
|
+
* @param options.user - Unix user context for permission checks
|
|
97
|
+
*/
|
|
98
|
+
constructor(client: ArchilClient, options?: {
|
|
99
|
+
user?: UnixUser;
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Normalize a path (remove . and .., ensure leading /)
|
|
103
|
+
*/
|
|
104
|
+
private normalizePath;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve a path to its inode ID, walking the directory tree
|
|
107
|
+
*/
|
|
108
|
+
private resolve;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve parent directory and get child name
|
|
111
|
+
*/
|
|
112
|
+
private resolveParent;
|
|
113
|
+
/**
|
|
114
|
+
* Invalidate cache entries for a path and its descendants
|
|
115
|
+
*/
|
|
116
|
+
private invalidateCache;
|
|
117
|
+
/**
|
|
118
|
+
* Convert InodeAttributes to FsStat
|
|
119
|
+
*/
|
|
120
|
+
private toStat;
|
|
121
|
+
resolvePath(base: string, ...paths: string[]): string;
|
|
122
|
+
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
123
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
124
|
+
readdir(path: string): Promise<string[]>;
|
|
125
|
+
readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
|
|
126
|
+
stat(path: string): Promise<FsStat>;
|
|
127
|
+
lstat(path: string): Promise<FsStat>;
|
|
128
|
+
exists(path: string): Promise<boolean>;
|
|
129
|
+
readlink(path: string): Promise<string>;
|
|
130
|
+
realpath(path: string): Promise<string>;
|
|
131
|
+
writeFile(path: string, content: FileContent): Promise<void>;
|
|
132
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
133
|
+
mkdir(path: string, options?: {
|
|
134
|
+
recursive?: boolean;
|
|
135
|
+
}): Promise<void>;
|
|
136
|
+
private mkdirSingle;
|
|
137
|
+
rm(path: string, options?: {
|
|
138
|
+
recursive?: boolean;
|
|
139
|
+
force?: boolean;
|
|
140
|
+
}): Promise<void>;
|
|
141
|
+
cp(src: string, dest: string, options?: {
|
|
142
|
+
recursive?: boolean;
|
|
143
|
+
}): Promise<void>;
|
|
144
|
+
mv(src: string, dest: string): Promise<void>;
|
|
145
|
+
symlink(target: string, path: string): Promise<void>;
|
|
146
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
147
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
148
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
149
|
+
getAllPaths(): Promise<string[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Clear the inode cache
|
|
152
|
+
*/
|
|
153
|
+
clearCache(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get cache statistics
|
|
156
|
+
*/
|
|
157
|
+
getCacheStats(): {
|
|
158
|
+
size: number;
|
|
159
|
+
paths: string[];
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Create an ArchilFs instance from an existing client
|
|
165
|
+
*
|
|
166
|
+
* This is a convenience function for creating the filesystem adapter.
|
|
167
|
+
*
|
|
168
|
+
* @param client - Connected ArchilClient instance
|
|
169
|
+
* @param options - Optional configuration
|
|
170
|
+
* @returns Configured ArchilFs instance
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* import { ArchilClient } from '@archil/node';
|
|
175
|
+
* import { createArchilFs } from '@archil/just-bash';
|
|
176
|
+
*
|
|
177
|
+
* const client = await ArchilClient.connectAuthenticated({...});
|
|
178
|
+
* const fs = createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
declare function createArchilFs(client: _archil_node.ArchilClient, options?: {
|
|
182
|
+
user?: _archil_node.UnixUser;
|
|
183
|
+
}): ArchilFs;
|
|
184
|
+
|
|
185
|
+
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilFs };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as _archildata_client from '@archildata/client';
|
|
2
|
+
import { ArchilClient, UnixUser } from '@archildata/client';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Archil filesystem adapter for just-bash
|
|
6
|
+
*
|
|
7
|
+
* Implements the IFileSystem interface from just-bash using the ArchilClient
|
|
8
|
+
* from @archildata/client for direct protocol access to Archil distributed filesystems.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type BufferEncoding = "utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex" | "latin1";
|
|
12
|
+
type FileContent = string | Uint8Array;
|
|
13
|
+
interface FsStat {
|
|
14
|
+
isFile: boolean;
|
|
15
|
+
isDirectory: boolean;
|
|
16
|
+
isSymlink: boolean;
|
|
17
|
+
mode: number;
|
|
18
|
+
size: number;
|
|
19
|
+
mtime: Date;
|
|
20
|
+
}
|
|
21
|
+
interface DirentEntry {
|
|
22
|
+
name: string;
|
|
23
|
+
isFile: boolean;
|
|
24
|
+
isDirectory: boolean;
|
|
25
|
+
isSymlink: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface IFileSystem {
|
|
28
|
+
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
29
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
30
|
+
readdir(path: string): Promise<string[]>;
|
|
31
|
+
readdirWithFileTypes?(path: string): Promise<DirentEntry[]>;
|
|
32
|
+
stat(path: string): Promise<FsStat>;
|
|
33
|
+
lstat(path: string): Promise<FsStat>;
|
|
34
|
+
exists(path: string): Promise<boolean>;
|
|
35
|
+
readlink(path: string): Promise<string>;
|
|
36
|
+
realpath(path: string): Promise<string>;
|
|
37
|
+
writeFile(path: string, content: FileContent): Promise<void>;
|
|
38
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
39
|
+
mkdir(path: string, options?: {
|
|
40
|
+
recursive?: boolean;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
rm(path: string, options?: {
|
|
43
|
+
recursive?: boolean;
|
|
44
|
+
force?: boolean;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
cp(src: string, dest: string, options?: {
|
|
47
|
+
recursive?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
mv(src: string, dest: string): Promise<void>;
|
|
50
|
+
symlink(target: string, path: string): Promise<void>;
|
|
51
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
52
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
53
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
54
|
+
resolvePath(base: string, ...paths: string[]): string;
|
|
55
|
+
getAllPaths?(): Promise<string[]>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* ArchilFs implements the just-bash IFileSystem interface using Archil protocol.
|
|
59
|
+
*
|
|
60
|
+
* This adapter provides:
|
|
61
|
+
* - Path-to-inode resolution
|
|
62
|
+
* - Full filesystem operations via Archil protocol
|
|
63
|
+
* - Optional user context for permission checks
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { ArchilClient } from '@archildata/client';
|
|
68
|
+
* import { ArchilFs } from '@archildata/just-bash';
|
|
69
|
+
*
|
|
70
|
+
* const client = await ArchilClient.connect({
|
|
71
|
+
* region: 'aws-us-east-1',
|
|
72
|
+
* diskName: 'myaccount/mydisk',
|
|
73
|
+
* authToken: 'adt_xxx',
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* const fs = new ArchilFs(client);
|
|
77
|
+
*
|
|
78
|
+
* // Use with just-bash
|
|
79
|
+
* import { Bash } from 'just-bash';
|
|
80
|
+
* const bash = new Bash({ fs });
|
|
81
|
+
* await bash.run('ls -la /');
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare class ArchilFs implements IFileSystem {
|
|
85
|
+
private client;
|
|
86
|
+
private user?;
|
|
87
|
+
private rootInodeId;
|
|
88
|
+
/**
|
|
89
|
+
* Create a new ArchilFs adapter
|
|
90
|
+
*
|
|
91
|
+
* @param client - Connected ArchilClient instance
|
|
92
|
+
* @param options - Optional configuration
|
|
93
|
+
* @param options.user - Unix user context for permission checks
|
|
94
|
+
*/
|
|
95
|
+
constructor(client: ArchilClient, options?: {
|
|
96
|
+
user?: UnixUser;
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Normalize a path (remove . and .., ensure leading /)
|
|
100
|
+
*/
|
|
101
|
+
private normalizePath;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve a path to its inode ID, walking the directory tree
|
|
104
|
+
*/
|
|
105
|
+
private resolve;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve parent directory and get child name
|
|
108
|
+
*/
|
|
109
|
+
private resolveParent;
|
|
110
|
+
/**
|
|
111
|
+
* Convert InodeAttributes to FsStat
|
|
112
|
+
*/
|
|
113
|
+
private toStat;
|
|
114
|
+
resolvePath(base: string, ...paths: string[]): string;
|
|
115
|
+
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
116
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
117
|
+
readdir(path: string): Promise<string[]>;
|
|
118
|
+
readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
|
|
119
|
+
stat(path: string): Promise<FsStat>;
|
|
120
|
+
lstat(path: string): Promise<FsStat>;
|
|
121
|
+
exists(path: string): Promise<boolean>;
|
|
122
|
+
readlink(path: string): Promise<string>;
|
|
123
|
+
realpath(path: string): Promise<string>;
|
|
124
|
+
writeFile(path: string, content: FileContent): Promise<void>;
|
|
125
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
126
|
+
mkdir(path: string, options?: {
|
|
127
|
+
recursive?: boolean;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
private mkdirSingle;
|
|
130
|
+
rm(path: string, options?: {
|
|
131
|
+
recursive?: boolean;
|
|
132
|
+
force?: boolean;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
cp(src: string, dest: string, options?: {
|
|
135
|
+
recursive?: boolean;
|
|
136
|
+
}): Promise<void>;
|
|
137
|
+
mv(src: string, dest: string): Promise<void>;
|
|
138
|
+
symlink(target: string, path: string): Promise<void>;
|
|
139
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
140
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
141
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
142
|
+
getAllPaths(): Promise<string[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Resolve a path to its inode ID (public wrapper for delegation operations)
|
|
145
|
+
*/
|
|
146
|
+
resolveInodeId(path: string): Promise<number>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Create an ArchilFs instance from an existing client
|
|
151
|
+
*
|
|
152
|
+
* This is a convenience function for creating the filesystem adapter.
|
|
153
|
+
*
|
|
154
|
+
* @param client - Connected ArchilClient instance
|
|
155
|
+
* @param options - Optional configuration
|
|
156
|
+
* @returns Configured ArchilFs instance
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* import { ArchilClient } from '@archildata/client';
|
|
161
|
+
* import { createArchilFs } from '@archildata/just-bash';
|
|
162
|
+
*
|
|
163
|
+
* const client = await ArchilClient.connectAuthenticated({...});
|
|
164
|
+
* const fs = createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function createArchilFs(client: _archildata_client.ArchilClient, options?: {
|
|
168
|
+
user?: _archildata_client.UnixUser;
|
|
169
|
+
}): ArchilFs;
|
|
170
|
+
|
|
171
|
+
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilFs };
|