@archildata/just-bash 0.1.13 → 0.8.1
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 +6 -3
- 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/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _archildata_client from '@archildata/client';
|
|
2
2
|
import { ArchilClient, UnixUser } from '@archildata/client';
|
|
3
|
+
import * as just_bash from 'just-bash';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Archil filesystem adapter for just-bash
|
|
@@ -13,7 +14,7 @@ type FileContent = string | Uint8Array;
|
|
|
13
14
|
interface FsStat {
|
|
14
15
|
isFile: boolean;
|
|
15
16
|
isDirectory: boolean;
|
|
16
|
-
|
|
17
|
+
isSymbolicLink: boolean;
|
|
17
18
|
mode: number;
|
|
18
19
|
size: number;
|
|
19
20
|
mtime: Date;
|
|
@@ -22,7 +23,7 @@ interface DirentEntry {
|
|
|
22
23
|
name: string;
|
|
23
24
|
isFile: boolean;
|
|
24
25
|
isDirectory: boolean;
|
|
25
|
-
|
|
26
|
+
isSymbolicLink: boolean;
|
|
26
27
|
}
|
|
27
28
|
interface IFileSystem {
|
|
28
29
|
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
@@ -50,9 +51,9 @@ interface IFileSystem {
|
|
|
50
51
|
symlink(target: string, path: string): Promise<void>;
|
|
51
52
|
link(existingPath: string, newPath: string): Promise<void>;
|
|
52
53
|
chmod(path: string, mode: number): Promise<void>;
|
|
53
|
-
utimes(path: string, atime:
|
|
54
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
54
55
|
resolvePath(base: string, ...paths: string[]): string;
|
|
55
|
-
getAllPaths?():
|
|
56
|
+
getAllPaths?(): string[];
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* ArchilFs implements the just-bash IFileSystem interface using Archil protocol.
|
|
@@ -73,7 +74,7 @@ interface IFileSystem {
|
|
|
73
74
|
* authToken: 'adt_xxx',
|
|
74
75
|
* });
|
|
75
76
|
*
|
|
76
|
-
* const fs =
|
|
77
|
+
* const fs = await ArchilFs.create(client);
|
|
77
78
|
*
|
|
78
79
|
* // Use with just-bash
|
|
79
80
|
* import { Bash } from 'just-bash';
|
|
@@ -85,24 +86,38 @@ declare class ArchilFs implements IFileSystem {
|
|
|
85
86
|
private client;
|
|
86
87
|
private user?;
|
|
87
88
|
private rootInodeId;
|
|
89
|
+
private constructor();
|
|
88
90
|
/**
|
|
89
|
-
* Create
|
|
91
|
+
* Create an ArchilFs adapter, optionally rooted at a subdirectory.
|
|
92
|
+
*
|
|
93
|
+
* The subdirectory path is resolved eagerly: if any component does not
|
|
94
|
+
* exist or is not a directory, this method throws immediately.
|
|
90
95
|
*
|
|
91
96
|
* @param client - Connected ArchilClient instance
|
|
92
97
|
* @param options - Optional configuration
|
|
93
98
|
* @param options.user - Unix user context for permission checks
|
|
99
|
+
* @param options.subdirectory - Subdirectory to treat as the root of the filesystem
|
|
94
100
|
*/
|
|
95
|
-
|
|
101
|
+
static create(client: ArchilClient, options?: {
|
|
96
102
|
user?: UnixUser;
|
|
97
|
-
|
|
103
|
+
subdirectory?: string;
|
|
104
|
+
}): Promise<ArchilFs>;
|
|
98
105
|
/**
|
|
99
106
|
* Normalize a path (remove . and .., ensure leading /)
|
|
100
107
|
*/
|
|
101
108
|
private normalizePath;
|
|
109
|
+
private static readonly MAX_SYMLINKS;
|
|
102
110
|
/**
|
|
103
|
-
* Resolve a path to its inode ID, walking the directory tree
|
|
111
|
+
* Resolve a path to its inode ID, walking the directory tree.
|
|
112
|
+
* Follows symlinks on intermediate components but NOT on the final
|
|
113
|
+
* component (matching lstat/readlink semantics).
|
|
104
114
|
*/
|
|
105
115
|
private resolve;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve a path, following symlinks on ALL components including the
|
|
118
|
+
* final one (like stat(2)). Use resolve() when you need lstat semantics.
|
|
119
|
+
*/
|
|
120
|
+
private resolveFollow;
|
|
106
121
|
/**
|
|
107
122
|
* Resolve parent directory and get child name
|
|
108
123
|
*/
|
|
@@ -111,6 +126,11 @@ declare class ArchilFs implements IFileSystem {
|
|
|
111
126
|
* Convert InodeAttributes to FsStat
|
|
112
127
|
*/
|
|
113
128
|
private toStat;
|
|
129
|
+
private static readonly DIR_PAGE_SIZE;
|
|
130
|
+
/**
|
|
131
|
+
* Read all directory entries using the paginated API.
|
|
132
|
+
*/
|
|
133
|
+
private readAllDirectoryEntries;
|
|
114
134
|
resolvePath(base: string, ...paths: string[]): string;
|
|
115
135
|
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
116
136
|
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
@@ -120,7 +140,7 @@ declare class ArchilFs implements IFileSystem {
|
|
|
120
140
|
lstat(path: string): Promise<FsStat>;
|
|
121
141
|
exists(path: string): Promise<boolean>;
|
|
122
142
|
readlink(path: string): Promise<string>;
|
|
123
|
-
realpath(path: string): Promise<string>;
|
|
143
|
+
realpath(path: string, symlinkDepth?: number): Promise<string>;
|
|
124
144
|
writeFile(path: string, content: FileContent): Promise<void>;
|
|
125
145
|
appendFile(path: string, content: FileContent): Promise<void>;
|
|
126
146
|
mkdir(path: string, options?: {
|
|
@@ -138,8 +158,8 @@ declare class ArchilFs implements IFileSystem {
|
|
|
138
158
|
symlink(target: string, path: string): Promise<void>;
|
|
139
159
|
link(existingPath: string, newPath: string): Promise<void>;
|
|
140
160
|
chmod(path: string, mode: number): Promise<void>;
|
|
141
|
-
utimes(path: string, atime:
|
|
142
|
-
getAllPaths():
|
|
161
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
162
|
+
getAllPaths(): string[];
|
|
143
163
|
/**
|
|
144
164
|
* Resolve a path to its inode ID (public wrapper for delegation operations)
|
|
145
165
|
*/
|
|
@@ -147,9 +167,31 @@ declare class ArchilFs implements IFileSystem {
|
|
|
147
167
|
}
|
|
148
168
|
|
|
149
169
|
/**
|
|
150
|
-
* Create
|
|
170
|
+
* Create the `archil` custom command for use with just-bash.
|
|
171
|
+
*
|
|
172
|
+
* Provides checkout/checkin delegation management and delegation listing
|
|
173
|
+
* as a shell command that works in scripts, pipes, and interactive use.
|
|
151
174
|
*
|
|
152
|
-
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* import { Bash } from 'just-bash';
|
|
178
|
+
* import { ArchilFs, createArchilCommand } from '@archildata/just-bash';
|
|
179
|
+
*
|
|
180
|
+
* const fs = await ArchilFs.create(client);
|
|
181
|
+
* const bash = new Bash({
|
|
182
|
+
* fs,
|
|
183
|
+
* customCommands: [createArchilCommand(client, fs)],
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* await bash.exec('archil checkout /mydir');
|
|
187
|
+
* await bash.exec('echo "hello" > /mydir/file.txt');
|
|
188
|
+
* await bash.exec('archil checkin /mydir');
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function createArchilCommand(client: ArchilClient, fs: ArchilFs): just_bash.Command;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create an ArchilFs instance, optionally rooted at a subdirectory.
|
|
153
195
|
*
|
|
154
196
|
* @param client - Connected ArchilClient instance
|
|
155
197
|
* @param options - Optional configuration
|
|
@@ -161,11 +203,12 @@ declare class ArchilFs implements IFileSystem {
|
|
|
161
203
|
* import { createArchilFs } from '@archildata/just-bash';
|
|
162
204
|
*
|
|
163
205
|
* const client = await ArchilClient.connectAuthenticated({...});
|
|
164
|
-
* const fs = createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
206
|
+
* const fs = await createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
165
207
|
* ```
|
|
166
208
|
*/
|
|
167
209
|
declare function createArchilFs(client: _archildata_client.ArchilClient, options?: {
|
|
168
210
|
user?: _archildata_client.UnixUser;
|
|
169
|
-
|
|
211
|
+
subdirectory?: string;
|
|
212
|
+
}): Promise<ArchilFs>;
|
|
170
213
|
|
|
171
|
-
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilFs };
|
|
214
|
+
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilCommand, createArchilFs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _archildata_client from '@archildata/client';
|
|
2
2
|
import { ArchilClient, UnixUser } from '@archildata/client';
|
|
3
|
+
import * as just_bash from 'just-bash';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Archil filesystem adapter for just-bash
|
|
@@ -13,7 +14,7 @@ type FileContent = string | Uint8Array;
|
|
|
13
14
|
interface FsStat {
|
|
14
15
|
isFile: boolean;
|
|
15
16
|
isDirectory: boolean;
|
|
16
|
-
|
|
17
|
+
isSymbolicLink: boolean;
|
|
17
18
|
mode: number;
|
|
18
19
|
size: number;
|
|
19
20
|
mtime: Date;
|
|
@@ -22,7 +23,7 @@ interface DirentEntry {
|
|
|
22
23
|
name: string;
|
|
23
24
|
isFile: boolean;
|
|
24
25
|
isDirectory: boolean;
|
|
25
|
-
|
|
26
|
+
isSymbolicLink: boolean;
|
|
26
27
|
}
|
|
27
28
|
interface IFileSystem {
|
|
28
29
|
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
@@ -50,9 +51,9 @@ interface IFileSystem {
|
|
|
50
51
|
symlink(target: string, path: string): Promise<void>;
|
|
51
52
|
link(existingPath: string, newPath: string): Promise<void>;
|
|
52
53
|
chmod(path: string, mode: number): Promise<void>;
|
|
53
|
-
utimes(path: string, atime:
|
|
54
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
54
55
|
resolvePath(base: string, ...paths: string[]): string;
|
|
55
|
-
getAllPaths?():
|
|
56
|
+
getAllPaths?(): string[];
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* ArchilFs implements the just-bash IFileSystem interface using Archil protocol.
|
|
@@ -73,7 +74,7 @@ interface IFileSystem {
|
|
|
73
74
|
* authToken: 'adt_xxx',
|
|
74
75
|
* });
|
|
75
76
|
*
|
|
76
|
-
* const fs =
|
|
77
|
+
* const fs = await ArchilFs.create(client);
|
|
77
78
|
*
|
|
78
79
|
* // Use with just-bash
|
|
79
80
|
* import { Bash } from 'just-bash';
|
|
@@ -85,24 +86,38 @@ declare class ArchilFs implements IFileSystem {
|
|
|
85
86
|
private client;
|
|
86
87
|
private user?;
|
|
87
88
|
private rootInodeId;
|
|
89
|
+
private constructor();
|
|
88
90
|
/**
|
|
89
|
-
* Create
|
|
91
|
+
* Create an ArchilFs adapter, optionally rooted at a subdirectory.
|
|
92
|
+
*
|
|
93
|
+
* The subdirectory path is resolved eagerly: if any component does not
|
|
94
|
+
* exist or is not a directory, this method throws immediately.
|
|
90
95
|
*
|
|
91
96
|
* @param client - Connected ArchilClient instance
|
|
92
97
|
* @param options - Optional configuration
|
|
93
98
|
* @param options.user - Unix user context for permission checks
|
|
99
|
+
* @param options.subdirectory - Subdirectory to treat as the root of the filesystem
|
|
94
100
|
*/
|
|
95
|
-
|
|
101
|
+
static create(client: ArchilClient, options?: {
|
|
96
102
|
user?: UnixUser;
|
|
97
|
-
|
|
103
|
+
subdirectory?: string;
|
|
104
|
+
}): Promise<ArchilFs>;
|
|
98
105
|
/**
|
|
99
106
|
* Normalize a path (remove . and .., ensure leading /)
|
|
100
107
|
*/
|
|
101
108
|
private normalizePath;
|
|
109
|
+
private static readonly MAX_SYMLINKS;
|
|
102
110
|
/**
|
|
103
|
-
* Resolve a path to its inode ID, walking the directory tree
|
|
111
|
+
* Resolve a path to its inode ID, walking the directory tree.
|
|
112
|
+
* Follows symlinks on intermediate components but NOT on the final
|
|
113
|
+
* component (matching lstat/readlink semantics).
|
|
104
114
|
*/
|
|
105
115
|
private resolve;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve a path, following symlinks on ALL components including the
|
|
118
|
+
* final one (like stat(2)). Use resolve() when you need lstat semantics.
|
|
119
|
+
*/
|
|
120
|
+
private resolveFollow;
|
|
106
121
|
/**
|
|
107
122
|
* Resolve parent directory and get child name
|
|
108
123
|
*/
|
|
@@ -111,6 +126,11 @@ declare class ArchilFs implements IFileSystem {
|
|
|
111
126
|
* Convert InodeAttributes to FsStat
|
|
112
127
|
*/
|
|
113
128
|
private toStat;
|
|
129
|
+
private static readonly DIR_PAGE_SIZE;
|
|
130
|
+
/**
|
|
131
|
+
* Read all directory entries using the paginated API.
|
|
132
|
+
*/
|
|
133
|
+
private readAllDirectoryEntries;
|
|
114
134
|
resolvePath(base: string, ...paths: string[]): string;
|
|
115
135
|
readFile(path: string, encoding?: BufferEncoding): Promise<string>;
|
|
116
136
|
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
@@ -120,7 +140,7 @@ declare class ArchilFs implements IFileSystem {
|
|
|
120
140
|
lstat(path: string): Promise<FsStat>;
|
|
121
141
|
exists(path: string): Promise<boolean>;
|
|
122
142
|
readlink(path: string): Promise<string>;
|
|
123
|
-
realpath(path: string): Promise<string>;
|
|
143
|
+
realpath(path: string, symlinkDepth?: number): Promise<string>;
|
|
124
144
|
writeFile(path: string, content: FileContent): Promise<void>;
|
|
125
145
|
appendFile(path: string, content: FileContent): Promise<void>;
|
|
126
146
|
mkdir(path: string, options?: {
|
|
@@ -138,8 +158,8 @@ declare class ArchilFs implements IFileSystem {
|
|
|
138
158
|
symlink(target: string, path: string): Promise<void>;
|
|
139
159
|
link(existingPath: string, newPath: string): Promise<void>;
|
|
140
160
|
chmod(path: string, mode: number): Promise<void>;
|
|
141
|
-
utimes(path: string, atime:
|
|
142
|
-
getAllPaths():
|
|
161
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
162
|
+
getAllPaths(): string[];
|
|
143
163
|
/**
|
|
144
164
|
* Resolve a path to its inode ID (public wrapper for delegation operations)
|
|
145
165
|
*/
|
|
@@ -147,9 +167,31 @@ declare class ArchilFs implements IFileSystem {
|
|
|
147
167
|
}
|
|
148
168
|
|
|
149
169
|
/**
|
|
150
|
-
* Create
|
|
170
|
+
* Create the `archil` custom command for use with just-bash.
|
|
171
|
+
*
|
|
172
|
+
* Provides checkout/checkin delegation management and delegation listing
|
|
173
|
+
* as a shell command that works in scripts, pipes, and interactive use.
|
|
151
174
|
*
|
|
152
|
-
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* import { Bash } from 'just-bash';
|
|
178
|
+
* import { ArchilFs, createArchilCommand } from '@archildata/just-bash';
|
|
179
|
+
*
|
|
180
|
+
* const fs = await ArchilFs.create(client);
|
|
181
|
+
* const bash = new Bash({
|
|
182
|
+
* fs,
|
|
183
|
+
* customCommands: [createArchilCommand(client, fs)],
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* await bash.exec('archil checkout /mydir');
|
|
187
|
+
* await bash.exec('echo "hello" > /mydir/file.txt');
|
|
188
|
+
* await bash.exec('archil checkin /mydir');
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function createArchilCommand(client: ArchilClient, fs: ArchilFs): just_bash.Command;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create an ArchilFs instance, optionally rooted at a subdirectory.
|
|
153
195
|
*
|
|
154
196
|
* @param client - Connected ArchilClient instance
|
|
155
197
|
* @param options - Optional configuration
|
|
@@ -161,11 +203,12 @@ declare class ArchilFs implements IFileSystem {
|
|
|
161
203
|
* import { createArchilFs } from '@archildata/just-bash';
|
|
162
204
|
*
|
|
163
205
|
* const client = await ArchilClient.connectAuthenticated({...});
|
|
164
|
-
* const fs = createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
206
|
+
* const fs = await createArchilFs(client, { user: { uid: 1000, gid: 1000 } });
|
|
165
207
|
* ```
|
|
166
208
|
*/
|
|
167
209
|
declare function createArchilFs(client: _archildata_client.ArchilClient, options?: {
|
|
168
210
|
user?: _archildata_client.UnixUser;
|
|
169
|
-
|
|
211
|
+
subdirectory?: string;
|
|
212
|
+
}): Promise<ArchilFs>;
|
|
170
213
|
|
|
171
|
-
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilFs };
|
|
214
|
+
export { ArchilFs, type BufferEncoding, type DirentEntry, type FileContent, type FsStat, type IFileSystem, createArchilCommand, createArchilFs };
|