@helloao/cli 0.0.7 → 0.0.8-alpha

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/README.md CHANGED
@@ -1,125 +1,132 @@
1
- ## Hello AO CLI
2
-
3
- A Command Line Interface (CLI) that makes it easy to generate and manage your own [Free Use Bible API](https://bible.helloao.org/).
4
-
5
- Additionally, it includes many functions and utilities that can make working with commonly formatted Bible data much easier.
6
-
7
- ### Features
8
-
9
- - Supports [USFM](https://ubsicap.github.io/usfm/), [USX](https://ubsicap.github.io/usx/), and Codex (A JSON format).
10
- - Download over 1000 Bible translations from [fetch.bible](https://fetch.bible/).
11
- - Import Bible translations into a SQLite database.
12
- - Upload to S3, a zip file, or a local directory.
13
-
14
- ### Usage
15
-
16
- ```
17
- Usage: helloao [options] [command]
18
-
19
- A CLI for managing a Free Use Bible API.
20
-
21
- Options:
22
- -V, --version output the version number
23
- -h, --help display help for command
24
-
25
- Commands:
26
- init [options] [path] Initialize a new Bible API DB.
27
- import-translation [options] <dir> [dirs...] Imports a translation from the given directory into the database.
28
- import-translations [options] <dir> Imports all translations from the given directory into the database.
29
- generate-translation-files [options] <input> <dir> Generates API files from the given input translation.
30
- generate-translations-files [options] <input> <dir> Generates API files from the given input translations.
31
- upload-api-files [options] <dest> Uploads API files to the specified destination. For S3, use the format s3://bucket-name/path/to/folder.
32
- fetch-translations [options] <dir> [translations...] Fetches the specified translations from fetch.bible and places them in the given directory.
33
- fetch-audio [options] <dir> [translations...] Fetches the specified audio translations and places them in the given directory.
34
- Translations should be in the format "translationId/audioId". e.g. "BSB/gilbert"
35
- fetch-bible-metadata <dir> Fetches the Theographic bible metadata and places it in the given directory.
36
- help [command] display help for command
37
- ```
38
-
39
- The `@helloao/cli` package can also be used as a library.
40
-
41
- The library exports a variety of actions, utilities, and supporting classes designed to assist with generating and managing a Free Use Bible API.
42
-
43
- There are 6 main exports:
44
-
45
- - `actions` - This export contains function versions of the CLI commands. They make it easy to call a CLI command from a script.
46
- - `db` - This export contains functions that make working with a database easier. It supports operations like importing translations into a database, inserting chapters, verses, etc. and getting an updated database instance from a path.
47
- - `downloads` - This export contains functions that make downloading files easier.
48
- - `files` - This export contains functions that make working with files easier. It has functions to load files from a translation, discover translation metadata from the filesystem, and classes that support uploading API files to the local file system or to a zip archive.
49
- - `uploads` - This export contains functions that make it easy to upload an API to a destination like S3, the local filesystem, or a zip archive.
50
- - `s3` - This export contains a class that can upload files to S3.
51
-
52
- Here are some common operations that you might want to perform:
53
-
54
- #### Get a SQL Database
55
-
56
- ```typescript
57
- import { db } from '@helloao/cli';
58
-
59
- const pathToDb = './bible-database.db';
60
- const database = await db.getDb(pathToDb);
61
-
62
- // do work on the database
63
-
64
- // Close it when you are done.
65
- database.close();
66
- ```
67
-
68
- #### Import a translation into a database from a directory
69
-
70
- ```typescript
71
- import { db } from '@helloao/cli';
72
-
73
- const pathToDb = './bible-database.db';
74
- const database = await db.getDb(pathToDb);
75
-
76
- // Get a DOMParser for parsing USX.
77
- // On Node.js, you may have to import jsdom or linkedom.
78
- const parser = new DOMParser();
79
-
80
- const pathToTranslation = './path/to/translation';
81
-
82
- // Whether to overwrite files that already exist in the database.
83
- // The system will automatically determine the hashes of the input files and overwrite changed files if needed, so this is only needed
84
- // when you know that they need to be overwritten.
85
- const overwrite = false;
86
- await db.importTranslations(database, pathToTranslation, parser, overwrite);
87
- ```
88
-
89
- #### Generate an API from a translation
90
-
91
- ```typescript
92
- import { files, uploads } from '@helloao/cli';
93
- import { generation } from '@helloao/tools';
94
- import { toAsyncIterable } from '@helloao/tools/parser/iterators';
95
-
96
- const translationPath = './path/to/translation';
97
- const translationFiles = await files.loadTranslationFiles(translationPath);
98
-
99
- // Used to parse XML
100
- const domParser = new DOMParser();
101
-
102
- // Generate a dataset from the files
103
- // Datasets organize all the files and their content
104
- // by translation, book, chapter, and verse
105
- const dataset = generation.dataset.generateDataset(files, parser);
106
-
107
- // You can optionally specifiy a prefix that should be added to all API
108
- // links
109
- const pathPrefix = '';
110
-
111
- // Generate an API representation from the files
112
- // This adds links between chapters and additional metadata.
113
- const api = generation.api.generateApiForDataset(dataset, {
114
- pathPrefix,
115
- });
116
-
117
- // Generate output files from the API representation.
118
- // This will give us a list of files and file paths that represent
119
- // the entire API.
120
- const outputFiles = generation.api.generateFilesForApi(api);
121
-
122
- // Optionally upload files by using:
123
- // const dest = 's3://my-bucket';
124
- // await uploads.serializeAndUploadDatasets(dest, toAsyncIterable(outputFiles));
125
- ```
1
+ ## Hello AO CLI
2
+
3
+ A Command Line Interface (CLI) that makes it easy to generate and manage your own [Free Use Bible API](https://bible.helloao.org/).
4
+
5
+ Additionally, it includes many functions and utilities that can make working with commonly formatted Bible data much easier.
6
+
7
+ ### Features
8
+
9
+ - Supports [USFM](https://ubsicap.github.io/usfm/), [USX](https://ubsicap.github.io/usx/), and Codex (A JSON format).
10
+ - Download over 1000 Bible translations from [fetch.bible](https://fetch.bible/).
11
+ - Import Bible translations into a SQLite database.
12
+ - Upload to S3, a zip file, or a local directory.
13
+
14
+ ### Usage
15
+
16
+ ```
17
+ Usage: helloao [options] [command]
18
+
19
+ A CLI for managing a Free Use Bible API.
20
+
21
+ Options:
22
+ -V, --version output the version number
23
+ -h, --help display help for command
24
+
25
+ Commands:
26
+ init [options] [path] Initialize a new Bible API DB.
27
+ generate-translation-metadata Generates a metadata file for a translation.
28
+ import-translation [options] <dir> [dirs...] Imports a translation from the given directory into the database.
29
+ import-translations [options] <dir> Imports all translations from the given directory into the database.
30
+ upload-test-translation [options] <input> Uploads a translation to the HelloAO Free Bible API test S3 bucket.
31
+ Requires access to the HelloAO Free Bible API test S3 bucket.
32
+ For inquiries, please contact hello@helloao.org.
33
+ upload-test-translations [options] <input> Uploads all the translations in the given input directory to the HelloAO Free Bible API test S3 bucket.
34
+ Requires access to the HelloAO Free Bible API test S3 bucket.
35
+ For inquiries, please contact hello@helloao.org.
36
+ generate-translation-files [options] <input> <dir> Generates API files from the given input translation.
37
+ generate-translations-files [options] <input> <dir> Generates API files from the given input translations.
38
+ upload-api-files [options] <dest> Uploads API files to the specified destination. For S3, use the format s3://bucket-name/path/to/folder.
39
+ fetch-translations [options] <dir> [translations...] Fetches the specified translations from fetch.bible and places them in the given directory.
40
+ fetch-audio [options] <dir> [translations...] Fetches the specified audio translations and places them in the given directory.
41
+ Translations should be in the format "translationId/audioId". e.g. "BSB/gilbert"
42
+ fetch-bible-metadata <dir> Fetches the Theographic bible metadata and places it in the given directory.
43
+ help [command] display help for command
44
+ ```
45
+
46
+ The `@helloao/cli` package can also be used as a library.
47
+
48
+ The library exports a variety of actions, utilities, and supporting classes designed to assist with generating and managing a Free Use Bible API.
49
+
50
+ There are 6 main exports:
51
+
52
+ - `actions` - This export contains function versions of the CLI commands. They make it easy to call a CLI command from a script.
53
+ - `db` - This export contains functions that make working with a database easier. It supports operations like importing translations into a database, inserting chapters, verses, etc. and getting an updated database instance from a path.
54
+ - `downloads` - This export contains functions that make downloading files easier.
55
+ - `files` - This export contains functions that make working with files easier. It has functions to load files from a translation, discover translation metadata from the filesystem, and classes that support uploading API files to the local file system or to a zip archive.
56
+ - `uploads` - This export contains functions that make it easy to upload an API to a destination like S3, the local filesystem, or a zip archive.
57
+ - `s3` - This export contains a class that can upload files to S3.
58
+
59
+ Here are some common operations that you might want to perform:
60
+
61
+ #### Get a SQL Database
62
+
63
+ ```typescript
64
+ import { db } from '@helloao/cli';
65
+
66
+ const pathToDb = './bible-database.db';
67
+ const database = await db.getDb(pathToDb);
68
+
69
+ // do work on the database
70
+
71
+ // Close it when you are done.
72
+ database.close();
73
+ ```
74
+
75
+ #### Import a translation into a database from a directory
76
+
77
+ ```typescript
78
+ import { db } from '@helloao/cli';
79
+
80
+ const pathToDb = './bible-database.db';
81
+ const database = await db.getDb(pathToDb);
82
+
83
+ // Get a DOMParser for parsing USX.
84
+ // On Node.js, you may have to import jsdom or linkedom.
85
+ const parser = new DOMParser();
86
+
87
+ const pathToTranslation = './path/to/translation';
88
+
89
+ // Whether to overwrite files that already exist in the database.
90
+ // The system will automatically determine the hashes of the input files and overwrite changed files if needed, so this is only needed
91
+ // when you know that they need to be overwritten.
92
+ const overwrite = false;
93
+ await db.importTranslations(database, pathToTranslation, parser, overwrite);
94
+ ```
95
+
96
+ #### Generate an API from a translation
97
+
98
+ ```typescript
99
+ import { files, uploads } from '@helloao/cli';
100
+ import { generation } from '@helloao/tools';
101
+ import { toAsyncIterable } from '@helloao/tools/parser/iterators';
102
+
103
+ const translationPath = './path/to/translation';
104
+ const translationFiles = await files.loadTranslationFiles(translationPath);
105
+
106
+ // Used to parse XML
107
+ const domParser = new DOMParser();
108
+
109
+ // Generate a dataset from the files
110
+ // Datasets organize all the files and their content
111
+ // by translation, book, chapter, and verse
112
+ const dataset = generation.dataset.generateDataset(files, parser);
113
+
114
+ // You can optionally specifiy a prefix that should be added to all API
115
+ // links
116
+ const pathPrefix = '';
117
+
118
+ // Generate an API representation from the files
119
+ // This adds links between chapters and additional metadata.
120
+ const api = generation.api.generateApiForDataset(dataset, {
121
+ pathPrefix,
122
+ });
123
+
124
+ // Generate output files from the API representation.
125
+ // This will give us a list of files and file paths that represent
126
+ // the entire API.
127
+ const outputFiles = generation.api.generateFilesForApi(api);
128
+
129
+ // Optionally upload files by using:
130
+ // const dest = 's3://my-bucket';
131
+ // await uploads.serializeAndUploadDatasets(dest, toAsyncIterable(outputFiles));
132
+ ```