@@ -11,32 +11,98 @@ A browser-based Unix/Linux command emulator with vi editor support.
1111- Tab completion
1212- Command history
1313- Pipe and redirection support
14+ - Wildcard expansion (` * ` and ` ? ` )
1415- Customizable filesystem
1516- Custom command support
1617
1718## Installation
1819
20+ ### From npm
21+
22+ ``` bash
23+ npm install unix-shell-js
24+ ```
25+
1926### Local Development
2027
2128If you're working locally and want to use this library in another project:
2229
2330``` bash
2431cd ../unix-shell-js
32+ npm install
33+ npm run build
2534npm link
2635
2736cd ../your-project
2837npm link unix-shell-js
2938```
3039
31- ### From npm (when published)
40+ ## Development
3241
33- ``` bash
34- npm install unix-shell-js
35- ```
42+ This library is written in TypeScript and compiled to JavaScript.
43+
44+ ### Build Commands
45+
46+ - ` npm run build ` - Compile TypeScript to JavaScript (outputs to ` dist/ ` ) and copy to demo
47+ - ` npm run copy-to-demo ` - Copy built files to ` docs/ ` directory for GitHub Pages demo
48+ - ` npm run watch ` - Watch mode for development (auto-recompiles on changes)
49+ - ` npm run prepublishOnly ` - Automatically runs before publishing to npm
50+
51+ ### Testing
52+
53+ - ` npm test ` - Run all tests
54+ - ` npm run test:watch ` - Run tests in watch mode
55+ - ` npm run test:coverage ` - Run tests with coverage report
56+
57+ The project includes comprehensive test suites covering:
58+ - Core shell functionality (commands, navigation, environment)
59+ - File system operations (create, read, delete files/directories)
60+ - File redirection and piping
61+ - Custom command support
62+ - Tab completion
63+ - User switching (su, sudo, exit)
64+ - localStorage persistence
65+
66+ ### Project Structure
67+
68+ - ` src/ ` - TypeScript source files
69+ - ` index.ts ` - Main Unix Shell implementation
70+ - ` vi-editor.ts ` - Vi/Vim editor
71+ - ` example-files.ts ` - Example filesystem generator
72+ - ` dist/ ` - Compiled JavaScript files (generated by TypeScript compiler)
73+ - Includes ` .js ` , ` .d.ts ` (type definitions), and ` .map ` (source maps) files
3674
3775## Usage
3876
39- ### Basic Setup
77+ ### TypeScript
78+
79+ The library is written in TypeScript and includes full type definitions:
80+
81+ ``` typescript
82+ import { UnixShell } from ' unix-shell-js' ;
83+ import { createExampleFiles } from ' unix-shell-js/dist/example-files' ;
84+
85+ const shell = new UnixShell ({
86+ username: ' user' ,
87+ fileSystem: createExampleFiles (' user' ),
88+ persistence: {
89+ enabled: true ,
90+ prefix: ' myapp'
91+ }
92+ });
93+
94+ const output: string = shell .execute (' ls -la' );
95+ console .log (output );
96+ ```
97+
98+ ** Type definitions included:**
99+ - ` UnixShellOptions ` - Constructor options
100+ - ` FileSystem ` - Filesystem structure types
101+ - ` PersistenceOptions ` - Persistence configuration
102+ - ` CommandHandler ` - Custom command function signature
103+ - ` CompletionResult ` - Tab completion result type
104+
105+ ### JavaScript (Browser)
40106
41107Include the library files in your HTML:
42108
@@ -47,9 +113,9 @@ Include the library files in your HTML:
47113 <title >Terminal</title >
48114</head >
49115<body >
50- <script src =" node_modules/unix-shell-js/index.js" ></script >
51- <script src =" node_modules/unix-shell-js/vi-editor.js" ></script >
52- <script src =" node_modules/unix-shell-js/example-files.js" ></script >
116+ <script src =" node_modules/unix-shell-js/dist/ index.js" ></script >
117+ <script src =" node_modules/unix-shell-js/dist/ vi-editor.js" ></script >
118+ <script src =" node_modules/unix-shell-js/dist/ example-files.js" ></script >
53119 <script >
54120 // Create the shell with example files
55121 const shell = new UnixShell ({
0 commit comments