@ootc/shu
v0.0.3
Published
Utilities for working with shu project folders and `.shu` archives.
Readme
@ootc/shu
Utilities for working with shu project folders and .shu archives.
Install
pnpm add @ootc/shuUsage
Create a project folder
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
import { ShuFolder } from '@ootc/shu'
const folder = new ShuFolder('path/to/project')
await folder.pack('output.shu')The archive will include:
manifest.jsoncontent/<all files from source-folder>
Unpack a .shu file
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
const exists = await folder.fileExists('folder/file.txt')Folder methods
getManifest()andsetManifest()getFileLists()for real file lists undercontent/pack(target)to create a.shuarchivegetFile/writeFile/fileExistsforcontent/getUserData/writeUserData/userDataExists/clearUserDataforuser-data/
Notes
- Paths are relative to
content/oruser-data/;../is rejected.
