open-index/open-npm huggingface dataset:
npm package: @ootc/shu
Description: Utilities for working with shu project folders and `.shu` archives.
Latest version: 0.0.3

# @ootc/shu

Utilities for working with shu project folders and `.shu` archives.

## Install

```bash
pnpm add @ootc/shu
```

## Usage

### Create a project folder

```ts
import { ShuFolder } from '@ootc/shu'
import { Readable } from 'node:stream'

const folder = new ShuFolder('path/to/project')
await folder.setManifest({ preferredWindowSize: '800x600' })
await folder.writeFile('index.html', Readable.from('<h1>Hello</h1>'))
await folder.writeUserData('settings.json', Readable.from('{"ok":true}'))
```

### Pack a `.shu` file from a folder

```ts
import { ShuFolder } from '@ootc/shu'

const folder = new ShuFolder('path/to/project')
await folder.pack('output.shu')
```

The archive will include:

- `manifest.json`
- `content/<all files from source-folder>`

### Unpack a `.shu` file

```ts
import { unpack } from '@ootc/shu'

const folder = await unpack('path/to/archive.shu', 'path/to/output-folder')
const stream = await folder.getFile('folder/file.txt')
stream.pipe(process.stdout)
```

### Check file existence

```ts
const exists = await folder.fileExists('folder/file.txt')
```

## Folder methods

- `getManifest()` and `setManifest()`
- `getFileLists()` for real file lists under `content/`
- `pack(target)` to create a `.shu` archive
- `getFile` / `writeFile` / `fileExists` for `content/`
- `getUserData` / `writeUserData` / `userDataExists` / `clearUserData` for `user-data/`

## Notes

- Paths are relative to `content/` or `user-data/`; `../` is rejected.