node-sword-interface 0.254.0 → 1.0.0
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/API.md +29 -15
- package/index.js +25 -14
- package/package.json +1 -1
- package/src/napi_module/node_sword_interface.cpp +23 -1
- package/src/napi_module/node_sword_interface.hpp +1 -0
- package/src/node_sword_cli.cpp +17 -3
- package/src/sword_backend/module_store.cpp +6 -1
- package/src/sword_backend/module_store.hpp +2 -0
- package/src/sword_backend/repository_interface.cpp +44 -2
- package/src/sword_backend/repository_interface.hpp +7 -1
package/API.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<dl>
|
|
12
12
|
<dt><a href="#VerseObject">VerseObject</a> : <code>Object</code></dt>
|
|
13
|
-
<dd><p>An object representation of a
|
|
13
|
+
<dd><p>An object representation of a Bible verse.</p>
|
|
14
14
|
</dd>
|
|
15
15
|
<dt><a href="#ModuleObject">ModuleObject</a> : <code>Object</code></dt>
|
|
16
16
|
<dd><p>An object representation of a SWORD module.</p>
|
|
@@ -37,6 +37,7 @@ This is the main class of node-sword-interface and it provides a set of static f
|
|
|
37
37
|
* [.getRepoLanguages(repositoryName, moduleType)](#NodeSwordInterface+getRepoLanguages) ⇒ <code>Array.<String></code>
|
|
38
38
|
* [.getAllRepoModules(repositoryName, moduleType)](#NodeSwordInterface+getAllRepoModules) ⇒ <code>Array.<String></code>
|
|
39
39
|
* [.getRepoModulesByLang(repositoryName, language, moduleType, headersFilter, strongsFilter, hebrewStrongsKeys, greekStrongsKeys)](#NodeSwordInterface+getRepoModulesByLang) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
40
|
+
* [.getUpdatedRepoModules(repositoryName, includeBeta)](#NodeSwordInterface+getUpdatedRepoModules) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
40
41
|
* [.getRepoModule(moduleCode)](#NodeSwordInterface+getRepoModule) ⇒ [<code>ModuleObject</code>](#ModuleObject)
|
|
41
42
|
* [.getAllLocalModules(moduleType)](#NodeSwordInterface+getAllLocalModules) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
42
43
|
* [.getRepoModuleCount(repositoryName, moduleType)](#NodeSwordInterface+getRepoModuleCount) ⇒ <code>Number</code>
|
|
@@ -111,11 +112,11 @@ Returns the names of all available SWORD repositories.
|
|
|
111
112
|
<a name="NodeSwordInterface+getRepoLanguages"></a>
|
|
112
113
|
|
|
113
114
|
### nodeSwordInterface.getRepoLanguages(repositoryName, moduleType) ⇒ <code>Array.<String></code>
|
|
114
|
-
Returns the available languages for the modules from a given repository (default:
|
|
115
|
+
Returns the available languages for the modules from a given repository (default: Bible modules).
|
|
115
116
|
Note that the languages are returned as language codes.
|
|
116
117
|
|
|
117
118
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
118
|
-
**Returns**: <code>Array.<String></code> - An array of strings with the languages codes for the
|
|
119
|
+
**Returns**: <code>Array.<String></code> - An array of strings with the languages codes for the Bible modules from the given repository.
|
|
119
120
|
|
|
120
121
|
| Param | Type | Default | Description |
|
|
121
122
|
| --- | --- | --- | --- |
|
|
@@ -125,10 +126,10 @@ Note that the languages are returned as language codes.
|
|
|
125
126
|
<a name="NodeSwordInterface+getAllRepoModules"></a>
|
|
126
127
|
|
|
127
128
|
### nodeSwordInterface.getAllRepoModules(repositoryName, moduleType) ⇒ <code>Array.<String></code>
|
|
128
|
-
Returns all modules for the given repository (default:
|
|
129
|
+
Returns all modules for the given repository (default: Bible modules).
|
|
129
130
|
|
|
130
131
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
131
|
-
**Returns**: <code>Array.<String></code> - An array of strings with the module codes for the
|
|
132
|
+
**Returns**: <code>Array.<String></code> - An array of strings with the module codes for the Bible modules of the given repository.
|
|
132
133
|
|
|
133
134
|
| Param | Type | Default | Description |
|
|
134
135
|
| --- | --- | --- | --- |
|
|
@@ -138,7 +139,7 @@ Returns all modules for the given repository (default: bible modules).
|
|
|
138
139
|
<a name="NodeSwordInterface+getRepoModulesByLang"></a>
|
|
139
140
|
|
|
140
141
|
### nodeSwordInterface.getRepoModulesByLang(repositoryName, language, moduleType, headersFilter, strongsFilter, hebrewStrongsKeys, greekStrongsKeys) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
141
|
-
Returns all
|
|
142
|
+
Returns all Bible modules for the given repository and language
|
|
142
143
|
|
|
143
144
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
144
145
|
**Returns**: [<code>Array.<ModuleObject></code>](#ModuleObject) - An array of module objects.
|
|
@@ -153,6 +154,19 @@ Returns all bible modules for the given repository and language
|
|
|
153
154
|
| hebrewStrongsKeys | <code>Boolean</code> | <code>false</code> | Whether only modules with Hebrew Strong's keys shall be returned (only applies to dictionaries). |
|
|
154
155
|
| greekStrongsKeys | <code>Boolean</code> | <code>false</code> | Whether only modules with Greek Strong's keys shall be returned (only applies to dictionaries). |
|
|
155
156
|
|
|
157
|
+
<a name="NodeSwordInterface+getUpdatedRepoModules"></a>
|
|
158
|
+
|
|
159
|
+
### nodeSwordInterface.getUpdatedRepoModules(repositoryName, includeBeta) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
160
|
+
Returns all updated modules from all repositories or one specific repository.
|
|
161
|
+
|
|
162
|
+
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
163
|
+
**Returns**: [<code>Array.<ModuleObject></code>](#ModuleObject) - An array of module objects.
|
|
164
|
+
|
|
165
|
+
| Param | Type | Default | Description |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| repositoryName | <code>String</code> | <code>all</code> | The name of the repository from which updates shall retrieved. Default: 'all' |
|
|
168
|
+
| includeBeta | <code>Boolean</code> | <code>false</code> | Whether modules from the CrossWire Beta repository should also be included. |
|
|
169
|
+
|
|
156
170
|
<a name="NodeSwordInterface+getRepoModule"></a>
|
|
157
171
|
|
|
158
172
|
### nodeSwordInterface.getRepoModule(moduleCode) ⇒ [<code>ModuleObject</code>](#ModuleObject)
|
|
@@ -167,10 +181,10 @@ Returns an object representation of a SWORD module from a repository.
|
|
|
167
181
|
<a name="NodeSwordInterface+getAllLocalModules"></a>
|
|
168
182
|
|
|
169
183
|
### nodeSwordInterface.getAllLocalModules(moduleType) ⇒ [<code>Array.<ModuleObject></code>](#ModuleObject)
|
|
170
|
-
Returns all modules installed locally (default:
|
|
184
|
+
Returns all modules installed locally (default: Bible modules).
|
|
171
185
|
|
|
172
186
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
173
|
-
**Returns**: [<code>Array.<ModuleObject></code>](#ModuleObject) - An array of ModuleObjects which represents the locally installed
|
|
187
|
+
**Returns**: [<code>Array.<ModuleObject></code>](#ModuleObject) - An array of ModuleObjects which represents the locally installed Bible modules.
|
|
174
188
|
|
|
175
189
|
| Param | Type | Default | Description |
|
|
176
190
|
| --- | --- | --- | --- |
|
|
@@ -179,10 +193,10 @@ Returns all modules installed locally (default: bible modules).
|
|
|
179
193
|
<a name="NodeSwordInterface+getRepoModuleCount"></a>
|
|
180
194
|
|
|
181
195
|
### nodeSwordInterface.getRepoModuleCount(repositoryName, moduleType) ⇒ <code>Number</code>
|
|
182
|
-
Returns the number of modules for a given repository (default:
|
|
196
|
+
Returns the number of modules for a given repository (default: Bible modules).
|
|
183
197
|
|
|
184
198
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
185
|
-
**Returns**: <code>Number</code> - The number of
|
|
199
|
+
**Returns**: <code>Number</code> - The number of Bible modules for the given repository and module type.
|
|
186
200
|
|
|
187
201
|
| Param | Type | Default | Description |
|
|
188
202
|
| --- | --- | --- | --- |
|
|
@@ -192,10 +206,10 @@ Returns the number of modules for a given repository (default: bible modules).
|
|
|
192
206
|
<a name="NodeSwordInterface+getRepoLanguageModuleCount"></a>
|
|
193
207
|
|
|
194
208
|
### nodeSwordInterface.getRepoLanguageModuleCount(repositoryName, language, moduleType) ⇒ <code>Number</code>
|
|
195
|
-
Returns the number of modules for a given repository and language (default:
|
|
209
|
+
Returns the number of modules for a given repository and language (default: Bible modules).
|
|
196
210
|
|
|
197
211
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
198
|
-
**Returns**: <code>Number</code> - The number of
|
|
212
|
+
**Returns**: <code>Number</code> - The number of Bible modules for the given repository, language and module type.
|
|
199
213
|
|
|
200
214
|
| Param | Type | Default | Description |
|
|
201
215
|
| --- | --- | --- | --- |
|
|
@@ -413,7 +427,7 @@ Returns the number of verses in the given chapter.
|
|
|
413
427
|
<a name="NodeSwordInterface+getBibleText"></a>
|
|
414
428
|
|
|
415
429
|
### nodeSwordInterface.getBibleText(moduleCode) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
416
|
-
Returns the
|
|
430
|
+
Returns the Bible text of a module.
|
|
417
431
|
|
|
418
432
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
419
433
|
**Returns**: [<code>Array.<VerseObject></code>](#VerseObject) - An array of verse objects.
|
|
@@ -575,7 +589,7 @@ Returns the platform-specific path where SWORD accesses and stores its modules.
|
|
|
575
589
|
<a name="VerseObject"></a>
|
|
576
590
|
|
|
577
591
|
## VerseObject : <code>Object</code>
|
|
578
|
-
An object representation of a
|
|
592
|
+
An object representation of a Bible verse.
|
|
579
593
|
|
|
580
594
|
**Kind**: global typedef
|
|
581
595
|
**Properties**
|
|
@@ -583,7 +597,7 @@ An object representation of a bible verse.
|
|
|
583
597
|
| Name | Type | Description |
|
|
584
598
|
| --- | --- | --- |
|
|
585
599
|
| moduleCode | <code>String</code> | The name/code of the SWORD module |
|
|
586
|
-
| bibleBookShortTitle | <code>String</code> | The short title of the verses's
|
|
600
|
+
| bibleBookShortTitle | <code>String</code> | The short title of the verses's Bible book |
|
|
587
601
|
| chapter | <code>String</code> | The chapter number |
|
|
588
602
|
| verseNr | <code>String</code> | The verse number |
|
|
589
603
|
| absoluteVerseNr | <code>Number</code> | The absolute number of the verse within the book (independent of chapters, starting from 1) |
|
package/index.js
CHANGED
|
@@ -20,11 +20,11 @@ const path = require('path');
|
|
|
20
20
|
const nodeSwordInterfaceModule = require('./build/Release/node_sword_interface.node');
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* An object representation of a
|
|
23
|
+
* An object representation of a Bible verse.
|
|
24
24
|
* @typedef VerseObject
|
|
25
25
|
* @type {Object}
|
|
26
26
|
* @property {String} moduleCode - The name/code of the SWORD module
|
|
27
|
-
* @property {String} bibleBookShortTitle - The short title of the verses's
|
|
27
|
+
* @property {String} bibleBookShortTitle - The short title of the verses's Bible book
|
|
28
28
|
* @property {String} chapter - The chapter number
|
|
29
29
|
* @property {String} verseNr - The verse number
|
|
30
30
|
* @property {Number} absoluteVerseNr - The absolute number of the verse within the book (independent of chapters, starting from 1)
|
|
@@ -132,30 +132,30 @@ class NodeSwordInterface {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Returns the available languages for the modules from a given repository (default:
|
|
135
|
+
* Returns the available languages for the modules from a given repository (default: Bible modules).
|
|
136
136
|
* Note that the languages are returned as language codes.
|
|
137
137
|
*
|
|
138
138
|
* @param {String} repositoryName - The name of the given repository.
|
|
139
139
|
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
140
|
-
* @return {String[]} An array of strings with the languages codes for the
|
|
140
|
+
* @return {String[]} An array of strings with the languages codes for the Bible modules from the given repository.
|
|
141
141
|
*/
|
|
142
142
|
getRepoLanguages(repositoryName, moduleType="BIBLE") {
|
|
143
143
|
return this.nativeInterface.getRepoLanguages(repositoryName, moduleType);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* Returns all modules for the given repository (default:
|
|
147
|
+
* Returns all modules for the given repository (default: Bible modules).
|
|
148
148
|
*
|
|
149
149
|
* @param {String} repositoryName - The name of the given repository.
|
|
150
150
|
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
151
|
-
* @return {String[]} An array of strings with the module codes for the
|
|
151
|
+
* @return {String[]} An array of strings with the module codes for the Bible modules of the given repository.
|
|
152
152
|
*/
|
|
153
153
|
getAllRepoModules(repositoryName, moduleType="BIBLE") {
|
|
154
154
|
return this.nativeInterface.getAllRepoModules(repositoryName, moduleType);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
* Returns all
|
|
158
|
+
* Returns all Bible modules for the given repository and language
|
|
159
159
|
*
|
|
160
160
|
* @param {String} repositoryName - The name of the given repository.
|
|
161
161
|
* @param {String} language - The language code that shall be used as a filter.
|
|
@@ -170,6 +170,17 @@ class NodeSwordInterface {
|
|
|
170
170
|
return this.nativeInterface.getRepoModulesByLang(repositoryName, language, moduleType, headersFilter, strongsFilter, hebrewStrongsKeys, greekStrongsKeys);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Returns all updated modules from all repositories or one specific repository.
|
|
175
|
+
*
|
|
176
|
+
* @param {String} repositoryName - The name of the repository from which updates shall retrieved. Default: 'all'
|
|
177
|
+
* @param {Boolean} includeBeta - Whether modules from the CrossWire Beta repository should also be included.
|
|
178
|
+
* @returns {ModuleObject[]} An array of module objects.
|
|
179
|
+
*/
|
|
180
|
+
getUpdatedRepoModules(repositoryName="all", includeBeta=false) {
|
|
181
|
+
return this.nativeInterface.getUpdatedRepoModules(repositoryName, includeBeta);
|
|
182
|
+
}
|
|
183
|
+
|
|
173
184
|
/**
|
|
174
185
|
* Returns an object representation of a SWORD module from a repository.
|
|
175
186
|
*
|
|
@@ -181,32 +192,32 @@ class NodeSwordInterface {
|
|
|
181
192
|
}
|
|
182
193
|
|
|
183
194
|
/**
|
|
184
|
-
* Returns all modules installed locally (default:
|
|
195
|
+
* Returns all modules installed locally (default: Bible modules).
|
|
185
196
|
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
186
|
-
* @return {ModuleObject[]} An array of ModuleObjects which represents the locally installed
|
|
197
|
+
* @return {ModuleObject[]} An array of ModuleObjects which represents the locally installed Bible modules.
|
|
187
198
|
*/
|
|
188
199
|
getAllLocalModules(moduleType="BIBLE") {
|
|
189
200
|
return this.nativeInterface.getAllLocalModules(moduleType);
|
|
190
201
|
}
|
|
191
202
|
|
|
192
203
|
/**
|
|
193
|
-
* Returns the number of modules for a given repository (default:
|
|
204
|
+
* Returns the number of modules for a given repository (default: Bible modules).
|
|
194
205
|
*
|
|
195
206
|
* @param {String} repositoryName - The name of the given repository.
|
|
196
207
|
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
197
|
-
* @return {Number} The number of
|
|
208
|
+
* @return {Number} The number of Bible modules for the given repository and module type.
|
|
198
209
|
*/
|
|
199
210
|
getRepoModuleCount(repositoryName, moduleType="BIBLE") {
|
|
200
211
|
return this.nativeInterface.getRepoModuleCount(repositoryName, moduleType);
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
/**
|
|
204
|
-
* Returns the number of modules for a given repository and language (default:
|
|
215
|
+
* Returns the number of modules for a given repository and language (default: Bible modules).
|
|
205
216
|
*
|
|
206
217
|
* @param {String} repositoryName - The name of the given repository.
|
|
207
218
|
* @param {String} language - The language code that shall be used as a filter.
|
|
208
219
|
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
209
|
-
* @return {Number} The number of
|
|
220
|
+
* @return {Number} The number of Bible modules for the given repository, language and module type.
|
|
210
221
|
*/
|
|
211
222
|
getRepoLanguageModuleCount(repositoryName, language, moduleType="BIBLE") {
|
|
212
223
|
return this.nativeInterface.getRepoLanguageModuleCount(repositoryName, language, moduleType);
|
|
@@ -421,7 +432,7 @@ class NodeSwordInterface {
|
|
|
421
432
|
}
|
|
422
433
|
|
|
423
434
|
/**
|
|
424
|
-
* Returns the
|
|
435
|
+
* Returns the Bible text of a module.
|
|
425
436
|
*
|
|
426
437
|
* @param {String} moduleCode - The module code of the SWORD module.
|
|
427
438
|
* @return {VerseObject[]} An array of verse objects.
|
package/package.json
CHANGED
|
@@ -78,6 +78,7 @@ Napi::Object NodeSwordInterface::Init(Napi::Env env, Napi::Object exports)
|
|
|
78
78
|
InstanceMethod("getRepoNames", &NodeSwordInterface::getRepoNames),
|
|
79
79
|
InstanceMethod("getAllRepoModules", &NodeSwordInterface::getAllRepoModules),
|
|
80
80
|
InstanceMethod("getRepoModulesByLang", &NodeSwordInterface::getRepoModulesByLang),
|
|
81
|
+
InstanceMethod("getUpdatedRepoModules", &NodeSwordInterface::getUpdatedRepoModules),
|
|
81
82
|
InstanceMethod("getAllLocalModules", &NodeSwordInterface::getAllLocalModules),
|
|
82
83
|
InstanceMethod("isModuleInUserDir", &NodeSwordInterface::isModuleInUserDir),
|
|
83
84
|
InstanceMethod("isModuleAvailableInRepo", &NodeSwordInterface::isModuleAvailableInRepo),
|
|
@@ -173,7 +174,7 @@ NodeSwordInterface::NodeSwordInterface(const Napi::CallbackInfo& info) : Napi::O
|
|
|
173
174
|
if (!homeDirError && !localeDirError) { // We only proceed if there has not been any issue with the homeDir or localeDir
|
|
174
175
|
this->_moduleStore = new ModuleStore(this->customHomeDir);
|
|
175
176
|
this->_moduleHelper = new ModuleHelper(*(this->_moduleStore));
|
|
176
|
-
this->_repoInterface = new RepositoryInterface(this->_swordStatusReporter, *(this->_moduleHelper), this->customHomeDir);
|
|
177
|
+
this->_repoInterface = new RepositoryInterface(this->_swordStatusReporter, *(this->_moduleHelper), *(this->_moduleStore), this->customHomeDir);
|
|
177
178
|
this->_moduleInstaller = new ModuleInstaller(*(this->_repoInterface), *(this->_moduleStore), this->customHomeDir);
|
|
178
179
|
this->_napiSwordHelper = new NapiSwordHelper(*(this->_moduleHelper), *(this->_moduleStore));
|
|
179
180
|
this->_textProcessor = new TextProcessor(*(this->_moduleStore), *(this->_moduleHelper));
|
|
@@ -384,6 +385,27 @@ Napi::Value NodeSwordInterface::getRepoModulesByLang(const Napi::CallbackInfo& i
|
|
|
384
385
|
return moduleArray;
|
|
385
386
|
}
|
|
386
387
|
|
|
388
|
+
Napi::Value NodeSwordInterface::getUpdatedRepoModules(const Napi::CallbackInfo& info)
|
|
389
|
+
{
|
|
390
|
+
lockApi();
|
|
391
|
+
Napi::Env env = info.Env();
|
|
392
|
+
INIT_SCOPE_AND_VALIDATE(ParamType::string, ParamType::boolean);
|
|
393
|
+
Napi::String repoName = info[0].As<Napi::String>();
|
|
394
|
+
Napi::Boolean includeBeta = info[1].As<Napi::Boolean>();
|
|
395
|
+
|
|
396
|
+
vector<SWModule*> modules = this->_repoInterface->getUpdatedRepoModules(repoName, includeBeta);
|
|
397
|
+
Napi::Array moduleArray = Napi::Array::New(env, modules.size());
|
|
398
|
+
|
|
399
|
+
for (unsigned int i = 0; i < modules.size(); i++) {
|
|
400
|
+
Napi::Object napiObject = Napi::Object::New(env);
|
|
401
|
+
this->_napiSwordHelper->swordModuleToNapiObject(env, modules[i], napiObject);
|
|
402
|
+
moduleArray.Set(i, napiObject);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
unlockApi();
|
|
406
|
+
return moduleArray;
|
|
407
|
+
}
|
|
408
|
+
|
|
387
409
|
Napi::Value NodeSwordInterface::getRepoLanguages(const Napi::CallbackInfo& info)
|
|
388
410
|
{
|
|
389
411
|
lockApi();
|
|
@@ -55,6 +55,7 @@ private:
|
|
|
55
55
|
Napi::Value getRepoNames(const Napi::CallbackInfo& info);
|
|
56
56
|
Napi::Value getAllRepoModules(const Napi::CallbackInfo& info);
|
|
57
57
|
Napi::Value getRepoModulesByLang(const Napi::CallbackInfo& info);
|
|
58
|
+
Napi::Value getUpdatedRepoModules(const Napi::CallbackInfo& info);
|
|
58
59
|
Napi::Value getRepoLanguages(const Napi::CallbackInfo& info);
|
|
59
60
|
Napi::Value getRepoModuleCount(const Napi::CallbackInfo& info);
|
|
60
61
|
Napi::Value getRepoModule(const Napi::CallbackInfo& info);
|
package/src/node_sword_cli.cpp
CHANGED
|
@@ -86,6 +86,18 @@ void get_repo_module(RepositoryInterface& repoInterface)
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
void get_updated_repo_modules(RepositoryInterface& repoInterface)
|
|
90
|
+
{
|
|
91
|
+
ModuleStore moduleStore;
|
|
92
|
+
ModuleHelper moduleHelper(moduleStore);
|
|
93
|
+
|
|
94
|
+
vector<SWModule*> updatedModules = repoInterface.getUpdatedRepoModules();
|
|
95
|
+
|
|
96
|
+
for (int i = 0; i < updatedModules.size(); i++) {
|
|
97
|
+
cout << updatedModules[i]->getName() << " : " << updatedModules[i]->getConfigEntry("Version") << endl;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
89
101
|
void get_module_text(TextProcessor& text_processor)
|
|
90
102
|
{
|
|
91
103
|
cout << "Text:" << endl;
|
|
@@ -162,7 +174,7 @@ int main(int argc, char** argv)
|
|
|
162
174
|
ModuleStore moduleStore;
|
|
163
175
|
ModuleHelper moduleHelper(moduleStore);
|
|
164
176
|
SwordStatusReporter statusReporter;
|
|
165
|
-
RepositoryInterface repoInterface(statusReporter, moduleHelper);
|
|
177
|
+
RepositoryInterface repoInterface(statusReporter, moduleHelper, moduleStore);
|
|
166
178
|
ModuleInstaller moduleInstaller(repoInterface, moduleStore);
|
|
167
179
|
TextProcessor textProcessor(moduleStore, moduleHelper);
|
|
168
180
|
ModuleSearch moduleSearch(moduleStore, moduleHelper, textProcessor);
|
|
@@ -214,13 +226,15 @@ int main(int argc, char** argv)
|
|
|
214
226
|
//string translation = sword_facade.getSwordTranslation(string("/usr/share/sword/locales.d"), string("de"), string("locales"));
|
|
215
227
|
//cout << translation << endl;
|
|
216
228
|
|
|
217
|
-
/*vector<Verse> searchResults = moduleSearch.getModuleSearchResults("
|
|
229
|
+
/*vector<Verse> searchResults = moduleSearch.getModuleSearchResults("GerNeUe", "Glaube", SearchType::multiWord, SearchScope::NT, true);
|
|
218
230
|
cout << "Got " << searchResults.size() << " results!" << endl;
|
|
219
231
|
for (unsigned int i=0; i < searchResults.size(); i++) {
|
|
220
232
|
cout << searchResults[i].reference << endl;
|
|
221
233
|
}*/
|
|
222
234
|
|
|
223
|
-
|
|
235
|
+
get_updated_repo_modules(repoInterface);
|
|
236
|
+
|
|
237
|
+
/*get_book_headers(textProcessor);*/
|
|
224
238
|
|
|
225
239
|
return 0;
|
|
226
240
|
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// STD C++ includes
|
|
20
20
|
#include <iostream>
|
|
21
21
|
#include <sstream>
|
|
22
|
+
#include <map>
|
|
22
23
|
|
|
23
24
|
#ifdef __ANDROID__
|
|
24
25
|
#include <sys/cdefs.h>
|
|
@@ -49,8 +50,11 @@ using namespace sword;
|
|
|
49
50
|
|
|
50
51
|
static Mutex remoteSourceUpdateMutex;
|
|
51
52
|
|
|
52
|
-
RepositoryInterface::RepositoryInterface(SwordStatusReporter& statusReporter,
|
|
53
|
-
|
|
53
|
+
RepositoryInterface::RepositoryInterface(SwordStatusReporter& statusReporter,
|
|
54
|
+
ModuleHelper& moduleHelper,
|
|
55
|
+
ModuleStore& moduleStore,
|
|
56
|
+
string customHomeDir)
|
|
57
|
+
: _statusReporter(statusReporter), _moduleHelper(moduleHelper), _moduleStore(moduleStore)
|
|
54
58
|
{
|
|
55
59
|
this->_fileSystemHelper.setCustomHomeDir(customHomeDir);
|
|
56
60
|
this->resetMgr();
|
|
@@ -293,6 +297,44 @@ vector<SWModule*> RepositoryInterface::getRepoModulesByLang(string repoName,
|
|
|
293
297
|
return selectedLanguageModules;
|
|
294
298
|
}
|
|
295
299
|
|
|
300
|
+
vector<SWModule*> RepositoryInterface::getUpdatedRepoModules(string repoName, bool includeBeta)
|
|
301
|
+
{
|
|
302
|
+
vector<string> repoNames = this->getRepoNames();
|
|
303
|
+
vector<SWModule*> updatedModules;
|
|
304
|
+
SWMgr* localMgr = this->_moduleStore.getSwMgr();
|
|
305
|
+
|
|
306
|
+
for (size_t i = 0; i < repoNames.size(); i++) {
|
|
307
|
+
string currentRepo = repoNames[i];
|
|
308
|
+
InstallSource* currentRemoteSource = this->getRemoteSource(currentRepo);
|
|
309
|
+
|
|
310
|
+
if (currentRepo == "CrossWire Beta" && !includeBeta) {
|
|
311
|
+
// Exclude modules from the beta repository unless explicitly requested.
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (repoName != "all") {
|
|
316
|
+
if (currentRepo != repoName) {
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (currentRemoteSource != 0) {
|
|
322
|
+
SWMgr* remoteMgr = currentRemoteSource->getMgr();
|
|
323
|
+
map<SWModule*, int> moduleStatusMap = this->_installMgr->getModuleStatus(*localMgr, *remoteMgr, false);
|
|
324
|
+
|
|
325
|
+
for (auto const& moduleStatus : moduleStatusMap) {
|
|
326
|
+
const unsigned int updateStatus = moduleStatus.second;
|
|
327
|
+
|
|
328
|
+
if (updateStatus == InstallMgr::MODSTAT_UPDATED) {
|
|
329
|
+
updatedModules.push_back(moduleStatus.first);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return updatedModules;
|
|
336
|
+
}
|
|
337
|
+
|
|
296
338
|
unsigned int RepositoryInterface::getRepoModuleCount(string repoName, ModuleType moduleType)
|
|
297
339
|
{
|
|
298
340
|
vector<SWModule*> allModules = this->getAllRepoModules(repoName, moduleType);
|
|
@@ -40,7 +40,11 @@ class ModuleHelper;
|
|
|
40
40
|
|
|
41
41
|
class RepositoryInterface {
|
|
42
42
|
public:
|
|
43
|
-
RepositoryInterface(SwordStatusReporter& statusReporter,
|
|
43
|
+
RepositoryInterface(SwordStatusReporter& statusReporter,
|
|
44
|
+
ModuleHelper& moduleHelper,
|
|
45
|
+
ModuleStore& moduleStore,
|
|
46
|
+
std::string customHomeDir="");
|
|
47
|
+
|
|
44
48
|
virtual ~RepositoryInterface(){}
|
|
45
49
|
|
|
46
50
|
void resetMgr();
|
|
@@ -58,6 +62,7 @@ public:
|
|
|
58
62
|
bool strongsFilter=false,
|
|
59
63
|
bool hebrewStrongsKeys=false,
|
|
60
64
|
bool greekStrongsKeys=false);
|
|
65
|
+
std::vector<sword::SWModule*> getUpdatedRepoModules(std::string repoName="all", bool includeBeta=false);
|
|
61
66
|
unsigned int getRepoModuleCount(std::string repoName, ModuleType moduleType=ModuleType::bible);
|
|
62
67
|
std::vector<std::string> getRepoLanguages(std::string repoName, ModuleType moduleType=ModuleType::bible);
|
|
63
68
|
unsigned int getRepoLanguageModuleCount(std::string repoName, std::string languageCode, ModuleType moduleType=ModuleType::bible);
|
|
@@ -106,6 +111,7 @@ private:
|
|
|
106
111
|
SwordStatusReporter& _statusReporter;
|
|
107
112
|
FileSystemHelper _fileSystemHelper;
|
|
108
113
|
ModuleHelper& _moduleHelper;
|
|
114
|
+
ModuleStore& _moduleStore;
|
|
109
115
|
};
|
|
110
116
|
|
|
111
117
|
#endif // _REPOSITORY_INTERFACE
|