brsh 2.8.1 → 3.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/.github/workflows/release.yml +3 -1
- package/CHANGELOG.md +32 -0
- package/POSIX-CHECKLIST.md +3 -3
- package/Readme.md +138 -223
- package/bin/Readme.md +70 -24
- package/bin/brsh-shell.js +16 -131
- package/bin/exportFileSystem.js +4 -0
- package/bin/zsh-server.js +261 -0
- package/dist/brsh.css +1 -1
- package/dist/shell.es.js +1020 -648
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +34 -19
- package/dist/shell.min.js.map +1 -1
- package/dist/terminal.cjs.js +77 -100
- package/dist/terminal.cjs.js.map +1 -1
- package/dist/terminal.es.js +1382 -603
- package/dist/terminal.es.js.map +1 -1
- package/dist/terminal.min.js +77 -100
- package/dist/terminal.min.js.map +1 -1
- package/dist/wbt.es.js +410 -238
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +10 -8
- package/dist/wbt.min.js.map +1 -1
- package/index.js +472 -0
- package/lib/Command.js +30 -0
- package/lib/InteractiveCommand.js +28 -0
- package/lib/Readme.md +111 -12
- package/lib/ReplCommand.js +15 -0
- package/lib/Terminal.js +769 -510
- package/lib/TtyStream.js +181 -0
- package/lib/WasmCommand.js +26 -5
- package/lib/builtins/cat.js +2 -2
- package/lib/builtins/grep.js +2 -2
- package/lib/local/clear.js +3 -0
- package/lib/terminal/DomRenderer.js +325 -0
- package/lib/terminal/PtyBridge.js +169 -0
- package/lib/terminal/ScreenBuffer.js +594 -0
- package/lib/terminal/VtParser.js +728 -0
- package/lib/wbt/index.js +3 -2
- package/lib/wbt/registry.js +15 -1
- package/package.json +4 -2
- package/styles/terminal.css +33 -4
- package/test/terminal.test.js +762 -40
- package/test/wbt.test.js +92 -0
package/test/wbt.test.js
CHANGED
|
@@ -3,9 +3,21 @@ import { describe, it, expect, beforeEach } from 'vitest';
|
|
|
3
3
|
import { createShell, run } from './helpers.js';
|
|
4
4
|
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const fs = require('fs');
|
|
6
8
|
const Wbt = require('../lib/wbt/index.js');
|
|
7
9
|
const { wllamaInstances } = require('../lib/wbt/packages/wllama.js');
|
|
8
10
|
|
|
11
|
+
const NANO_WASM_PATH = path.resolve(import.meta.dirname, '../../nano-wasm/dist/nano.wasm');
|
|
12
|
+
const NANO_WASM_BYTES = (() => {
|
|
13
|
+
try {
|
|
14
|
+
if (fs.existsSync(NANO_WASM_PATH)) {
|
|
15
|
+
return new Uint8Array(fs.readFileSync(NANO_WASM_PATH));
|
|
16
|
+
}
|
|
17
|
+
} catch { /* ignore */ }
|
|
18
|
+
return null;
|
|
19
|
+
})();
|
|
20
|
+
|
|
9
21
|
// Minimal valid WASM binary that exits cleanly with 0 via _start:
|
|
10
22
|
// (module (func (export "_start")))
|
|
11
23
|
const MINIMAL_WASM_BYTES = new Uint8Array([
|
|
@@ -508,6 +520,13 @@ function createTestWbt() {
|
|
|
508
520
|
return null;
|
|
509
521
|
},
|
|
510
522
|
fetch: async (url) => {
|
|
523
|
+
if ((url.includes('nano-wasm') || url.includes('nano.wasm')) && NANO_WASM_BYTES) {
|
|
524
|
+
return {
|
|
525
|
+
ok: true,
|
|
526
|
+
status: 200,
|
|
527
|
+
arrayBuffer: async () => NANO_WASM_BYTES.buffer
|
|
528
|
+
};
|
|
529
|
+
}
|
|
511
530
|
if (url === 'https://example.com/hello.wasm' || /\.wasm(\?.*)?$/i.test(url)) {
|
|
512
531
|
return {
|
|
513
532
|
ok: true,
|
|
@@ -1192,3 +1211,76 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
|
|
|
1192
1211
|
expect(modelsRes.output.join('\n')).toContain('persisted (fs)');
|
|
1193
1212
|
});
|
|
1194
1213
|
});
|
|
1214
|
+
|
|
1215
|
+
describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
|
|
1216
|
+
let shell;
|
|
1217
|
+
|
|
1218
|
+
beforeEach(async () => {
|
|
1219
|
+
shell = await createShell();
|
|
1220
|
+
shell.context.setCommand(createTestWbt());
|
|
1221
|
+
});
|
|
1222
|
+
|
|
1223
|
+
it('registers nano and nano-wasm in registry, wbt search, and wbt show', async () => {
|
|
1224
|
+
const listRes = await run(shell, 'wbt list');
|
|
1225
|
+
expect(listRes.exitCode).toBe(0);
|
|
1226
|
+
expect(listRes.output.join('\n')).toContain('nano/wasm 8.0.0');
|
|
1227
|
+
|
|
1228
|
+
const searchRes = await run(shell, 'wbt search editor');
|
|
1229
|
+
expect(searchRes.exitCode).toBe(0);
|
|
1230
|
+
expect(searchRes.output.join('\n')).toContain('nano');
|
|
1231
|
+
|
|
1232
|
+
const showRes = await run(shell, 'wbt show nano');
|
|
1233
|
+
expect(showRes.exitCode).toBe(0);
|
|
1234
|
+
expect(showRes.output.join('\n')).toContain('Package: nano');
|
|
1235
|
+
expect(showRes.output.join('\n')).toContain('Version: 8.0.0');
|
|
1236
|
+
expect(showRes.output.join('\n')).toContain('Aliases: nano-wasm');
|
|
1237
|
+
|
|
1238
|
+
const showAliasRes = await run(shell, 'wbt show nano-wasm');
|
|
1239
|
+
expect(showAliasRes.exitCode).toBe(0);
|
|
1240
|
+
expect(showAliasRes.output.join('\n')).toContain('Package: nano');
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
it('installs nano and nano-wasm into /bin and runs --version and --help', async () => {
|
|
1244
|
+
const installRes = await run(shell, 'wbt install nano');
|
|
1245
|
+
expect(installRes.exitCode).toBe(0);
|
|
1246
|
+
expect(shell.context.fs.exists('/var/lib/wbt/wasm/nano.wasm')).toBe(true);
|
|
1247
|
+
expect(shell.context.fs.exists('/bin/nano')).toBe(true);
|
|
1248
|
+
expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(true);
|
|
1249
|
+
|
|
1250
|
+
const verRes = await run(shell, 'nano --version');
|
|
1251
|
+
expect(verRes.exitCode).toBe(0);
|
|
1252
|
+
expect(verRes.output.join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.0.*wasm/i);
|
|
1253
|
+
|
|
1254
|
+
const helpRes = await run(shell, 'nano --help');
|
|
1255
|
+
expect(helpRes.exitCode).toBe(0);
|
|
1256
|
+
expect(helpRes.output.join('\n')).toMatch(/Usage:\s+nano/i);
|
|
1257
|
+
|
|
1258
|
+
const aliasVerRes = await run(shell, 'nano-wasm --version');
|
|
1259
|
+
expect(aliasVerRes.exitCode).toBe(0);
|
|
1260
|
+
expect(aliasVerRes.output.join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.0.*wasm/i);
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
it('supports wbt run nano --version without permanently installing', async () => {
|
|
1264
|
+
const runRes = await run(shell, 'wbt run nano --version');
|
|
1265
|
+
expect(runRes.exitCode).toBe(0);
|
|
1266
|
+
expect(runRes.output.join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.0.*wasm/i);
|
|
1267
|
+
expect(shell.context.fs.exists('/bin/nano')).toBe(false);
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
it('removes nano and unregisters both nano and nano-wasm from /bin', async () => {
|
|
1271
|
+
await run(shell, 'wbt install nano-wasm');
|
|
1272
|
+
expect(shell.context.fs.exists('/bin/nano')).toBe(true);
|
|
1273
|
+
expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(true);
|
|
1274
|
+
expect(shell.context.fs.exists('/var/lib/wbt/wasm/nano.wasm')).toBe(true);
|
|
1275
|
+
|
|
1276
|
+
const rmRes = await run(shell, 'wbt remove nano');
|
|
1277
|
+
expect(rmRes.exitCode).toBe(0);
|
|
1278
|
+
expect(shell.context.fs.exists('/bin/nano')).toBe(false);
|
|
1279
|
+
expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(false);
|
|
1280
|
+
expect(shell.context.fs.exists('/var/lib/wbt/wasm/nano.wasm')).toBe(false);
|
|
1281
|
+
});
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|