just-bash 2.9.8 → 2.10.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/README.md +25 -0
- package/dist/Bash.d.ts +4 -0
- package/dist/bin/just-bash.js +264 -243
- package/dist/bin/shell/shell.js +217 -196
- package/dist/bundle/browser.js +739 -718
- package/dist/bundle/index.js +222 -201
- package/dist/index.d.ts +9 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Supports optional network access via `curl` with secure-by-default URL filtering
|
|
|
26
26
|
- [Default Layout](#default-layout)
|
|
27
27
|
- [Network Access](#network-access)
|
|
28
28
|
- [Execution Protection](#execution-protection)
|
|
29
|
+
- [AST Transform Plugins](#ast-transform-plugins)
|
|
29
30
|
- [Development](#development)
|
|
30
31
|
|
|
31
32
|
## Security model
|
|
@@ -435,6 +436,30 @@ const env = new Bash({
|
|
|
435
436
|
|
|
436
437
|
All limits have sensible defaults. Error messages include hints on which limit to increase. Feel free to increase if your scripts intentionally go beyond them.
|
|
437
438
|
|
|
439
|
+
## AST Transform Plugins
|
|
440
|
+
|
|
441
|
+
Parse bash scripts into an AST, run transform plugins, and serialize back to executable bash. Useful for instrumenting scripts (e.g., capturing per-command stdout/stderr) or analyzing them (e.g., extracting command names) before execution.
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
import { Bash, BashTransformPipeline, TeePlugin, CommandCollectorPlugin } from "just-bash";
|
|
445
|
+
|
|
446
|
+
// Standalone pipeline — output can be run by any shell
|
|
447
|
+
const pipeline = new BashTransformPipeline()
|
|
448
|
+
.use(new TeePlugin({ outputDir: "/tmp/logs" }))
|
|
449
|
+
.use(new CommandCollectorPlugin());
|
|
450
|
+
const result = pipeline.transform("echo hello | grep hello");
|
|
451
|
+
result.script; // transformed bash string
|
|
452
|
+
result.metadata.commands; // ["echo", "grep", "tee"]
|
|
453
|
+
|
|
454
|
+
// Integrated API — exec() auto-applies transforms and returns metadata
|
|
455
|
+
const bash = new Bash();
|
|
456
|
+
bash.registerTransformPlugin(new CommandCollectorPlugin());
|
|
457
|
+
const execResult = await bash.exec("echo hello | grep hello");
|
|
458
|
+
execResult.metadata?.commands; // ["echo", "grep"]
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
See [src/transform/README.md](src/transform/README.md) for the full API, built-in plugins, and how to write custom plugins.
|
|
462
|
+
|
|
438
463
|
## Development
|
|
439
464
|
|
|
440
465
|
```bash
|
package/dist/Bash.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { IFileSystem, InitialFiles } from "./fs/interface.js";
|
|
|
13
13
|
import { type ExecutionLimits } from "./limits.js";
|
|
14
14
|
import { type NetworkConfig } from "./network/index.js";
|
|
15
15
|
import type { DefenseInDepthConfig } from "./security/types.js";
|
|
16
|
+
import type { BashTransformResult, TransformPlugin } from "./transform/types.js";
|
|
16
17
|
import type { BashExecResult, Command, FeatureCoverageWriter, TraceCallback } from "./types.js";
|
|
17
18
|
export type { ExecutionLimits } from "./limits.js";
|
|
18
19
|
/**
|
|
@@ -167,6 +168,7 @@ export declare class Bash {
|
|
|
167
168
|
private logger?;
|
|
168
169
|
private defenseInDepthConfig?;
|
|
169
170
|
private coverageWriter?;
|
|
171
|
+
private transformPlugins;
|
|
170
172
|
private state;
|
|
171
173
|
constructor(options?: BashOptions);
|
|
172
174
|
registerCommand(command: Command): void;
|
|
@@ -176,4 +178,6 @@ export declare class Bash {
|
|
|
176
178
|
writeFile(path: string, content: string): Promise<void>;
|
|
177
179
|
getCwd(): string;
|
|
178
180
|
getEnv(): Record<string, string>;
|
|
181
|
+
registerTransformPlugin(plugin: TransformPlugin<any>): void;
|
|
182
|
+
transform(commandLine: string): BashTransformResult;
|
|
179
183
|
}
|