Skip to content

Commit 01804ba

Browse files
committed
Release version 1.0.0-rc.3
- Added cyrillic characters to safe filenames. - Factored out extractPack and compilePack functionality into an external API.
1 parent 4dfb5d3 commit 01804ba

File tree

6 files changed

+564
-376
lines changed

6 files changed

+564
-376
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.0.0-rc.3
2+
3+
### Improvements
4+
- (phenomen) Added cyrillic characters to the set of filesystem-safe characters that a Document name can be written as.
5+
- Factored out `extractPack` and `compilePack` functionality into an external API.
6+
17
## 1.0.0-rc.2
28

39
### Fixes

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,52 @@ npm run build
116116
npm link
117117
```
118118

119+
## API
120+
121+
Certain internal functionality of the CLI is exposed as an API that can be imported into other projects.
122+
123+
### Example Usage
124+
125+
```js
126+
import { compilePack, extractPack } from "@foundryvtt/foundryvtt-cli";
127+
128+
// Extract a NeDB compendium pack.
129+
await extractpack("mymodule/packs/actors.db", "mymodule/packs/src/actors", { nedb: true });
130+
131+
// Compile a LevelDB compendium pack.
132+
await compilePack("mymodule/packs/src/actors", "mymodule/packs/actors");
133+
```
134+
135+
### `compilePack(src: string, dest: string, options?: object): Promise<void>`
136+
137+
Compile source files into a compendium pack.
138+
139+
#### Parameters
140+
141+
* **src:** *string* The directory containing the source files.
142+
* **dest:** *string* The target compendium pack.
143+
* **options:** *object*
144+
* **nedb:** *boolean = false* Whether to operate on a NeDB database, otherwise a LevelDB database is assumed.
145+
* **yaml:** *boolean = false* Whether the source files in YAML format, otherwise JSON is assumed.
146+
* **log:** *boolean = false* Whether to log operation progress to the console.
147+
* **recursive:** *boolean = false* Whether to recurse into child directories under **src**, otherwise only source files located directly under **src** will be used.
148+
* **transformEntry:** *(entry: object): Promise<false|void>* A function that is called on every entry. Returning *false* indicates that the entry should be discarded.
149+
150+
### `extractPack(src: string, dest: string, options?: object): Promise<void>`
151+
152+
Extract the contents of a compendium pack into individual source files for each primary Document.
153+
154+
#### Parameters
155+
156+
* **src:** *string* The source compendium pack.
157+
* **dest:** *string* The directory to write the extracted files into.
158+
* **options:** *object*
159+
* **nedb:** *boolean = false* Whether to operate on a NeDB database, otherwise a LevelDB database is assumed.
160+
* **yaml:** *boolean = false* Whether the source files in YAML format, otherwise JSON is assumed.
161+
* **log:** *boolean = false* Whether to log operation progress to the console.
162+
* **documentType:** *string* For NeDB operations, a **documentType** must be provided. This should be the same as the pack's *type* field in the *module.json* or *system.json*.
163+
* **transformEntry:** *(entry: object): Promise<false|void>* A function that is called on every entry. Returning *false* indicates that the entry should be discarded.
164+
* **transformName:** *(entry: object): Promise<string|void>* A function that is called on every entry. The value returned from this will be used as the entry's filename. If nothing is returned, an auto-generated name will be used instead.
165+
119166
## Contributing
120167
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

0 commit comments

Comments
 (0)