@lsbjordao/type-taxon-script 1.1.3 → 1.1.5
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/package.json +1 -1
- package/readme.md +4 -1
- package/dist/export.js +0 -234
- package/dist/exportSources.js +0 -59
- package/dist/findProperty.js +0 -58
- package/dist/import.js +0 -98
- package/dist/init.js +0 -131
- package/dist/new.js +0 -47
- package/dist/tts.js +0 -108
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsbjordao/type-taxon-script",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"author": "Lucas Jordão <tucarj@gmail.com> & André Eppinghaus <andreeppinghaus@gmail.com> & Vicente Calfo <vicentecalfo@gmail.com>",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "TypeTaxonScript",
|
package/readme.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# TypeTaxonScript (TTS)
|
|
2
2
|
|
|
3
|
+
[](https://doi.org/10.1093/biomethods/bpae017)
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
Not Word or Excel, but TypeTaxonScript. We stand at the threshold of a new era in biological taxonomy descriptions. In this methodology, software engineering methods using TypeScript (TS) are employed to build a robust data structure, fostering enduring, non-redundant collaborative efforts through the application of a kind of taxonomic engineering of biological bodies. This innovative program introduces a new approach for precise and resilient documentation of taxa and characters, transcending the limitations of traditional text and spreadsheet editors. TypeTaxonScript streamlines and optimizes this process, enabling meticulous and efficient descriptions of diverse organisms, propelling the science of taxonomy and systematics to elevate levels of collaboration, precision, and effectiveness.
|
|
4
7
|
|
|
5
8
|
## Install Node.js
|
|
@@ -44,7 +47,7 @@ Within VS Code, open your terminal and execute the command bellow, following the
|
|
|
44
47
|
3. In the terminal, type and execute the following command:
|
|
45
48
|
|
|
46
49
|
```bash
|
|
47
|
-
npm install -g
|
|
50
|
+
npm install -g typescript
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
## Installing TTS package globally
|
package/dist/export.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const child_process_1 = require("child_process");
|
|
18
|
-
const csv_parser_1 = __importDefault(require("csv-parser"));
|
|
19
|
-
const cli_spinner_1 = require("cli-spinner");
|
|
20
|
-
function deleteJSFiles(folderPath) {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
try {
|
|
23
|
-
const files = yield fs_1.default.promises.readdir(folderPath);
|
|
24
|
-
for (const file of files) {
|
|
25
|
-
if (file.endsWith('.js')) {
|
|
26
|
-
yield fs_1.default.promises.unlink(`${folderPath}/${file}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
console.error('Error deleting files:', err);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function ttsExport(genus, load) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if (genus === '') {
|
|
38
|
-
console.error('\x1b[31m✖ Argument `--genus` cannot be empty.\x1b[0m');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const spinner = new cli_spinner_1.Spinner('\x1b[36mProcessing... %s\x1b[0m');
|
|
42
|
-
spinner.setSpinnerString('|/-\\'); // spinner sequence
|
|
43
|
-
spinner.start();
|
|
44
|
-
const taxa = [];
|
|
45
|
-
fs_1.default.mkdirSync('./temp', { recursive: true });
|
|
46
|
-
if (load === 'all') {
|
|
47
|
-
const directoryPath = `./taxon/${genus}/`;
|
|
48
|
-
fs_1.default.readdir(directoryPath, (err, files) => {
|
|
49
|
-
if (err) {
|
|
50
|
-
spinner.stop();
|
|
51
|
-
console.error('Error reading directory:', err);
|
|
52
|
-
process.exit();
|
|
53
|
-
}
|
|
54
|
-
const taxa = files
|
|
55
|
-
.filter(file => file.endsWith('.ts') && file !== 'index.ts')
|
|
56
|
-
.map(file => path_1.default.parse(file).name);
|
|
57
|
-
const importStatements = taxa.map((species) => {
|
|
58
|
-
return `import { ${species.replace(/\s/g, '_').replace(/\-([a-z])/, (_, match) => match.toUpperCase())} } from '../taxon/${genus}/${species.replace(/\s/g, '_')}'`;
|
|
59
|
-
}).join('\n');
|
|
60
|
-
const speciesCall = taxa.map((species) => {
|
|
61
|
-
return ` ${species.replace(/\s/g, '_').replace(/\-([a-z])/, (_, match) => match.toUpperCase())},`;
|
|
62
|
-
}).join('\n');
|
|
63
|
-
const fileContent = `// Import genus ${genus}
|
|
64
|
-
import { ${genus} } from '../taxon/${genus}'
|
|
65
|
-
|
|
66
|
-
// Import species of ${genus}
|
|
67
|
-
${importStatements}
|
|
68
|
-
|
|
69
|
-
const ${genus}_species: ${genus}[] = [
|
|
70
|
-
${speciesCall}
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
// Export ${genus}DB.json
|
|
74
|
-
//import { writeFileSync } from 'fs'
|
|
75
|
-
const jsonData = JSON.stringify(${genus}_species);
|
|
76
|
-
console.log(jsonData)
|
|
77
|
-
//const inputFilePath = '../output/${genus}DB.json'
|
|
78
|
-
//writeFileSync(inputFilePath, jsonData, 'utf-8')
|
|
79
|
-
//console.log('\\x1b[1m\\x1b[32m✔ Process finished.\\x1b[0m')`;
|
|
80
|
-
const tempFilePath = './temp/exportTemp.ts';
|
|
81
|
-
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
82
|
-
const fileToTranspile = 'exportTemp';
|
|
83
|
-
(0, child_process_1.exec)(`tsc ./temp/${fileToTranspile}.ts`, (error, stdout, stderr) => {
|
|
84
|
-
if (stdout) {
|
|
85
|
-
spinner.stop();
|
|
86
|
-
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
87
|
-
process.exit();
|
|
88
|
-
}
|
|
89
|
-
if (stderr) {
|
|
90
|
-
spinner.stop();
|
|
91
|
-
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stderr}`);
|
|
92
|
-
process.exit();
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
spinner.stop();
|
|
99
|
-
console.error(`An error occurred while deleting the file: ${err}`);
|
|
100
|
-
process.exit();
|
|
101
|
-
}
|
|
102
|
-
(0, child_process_1.exec)(`node ./temp/${fileToTranspile}.js > ./output/${genus}DB.json`, (error, stdout, stderr) => {
|
|
103
|
-
// if (error) {
|
|
104
|
-
// spinner.stop()
|
|
105
|
-
// console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${error.message}`)
|
|
106
|
-
// process.exit()
|
|
107
|
-
// }
|
|
108
|
-
if (stdout) {
|
|
109
|
-
spinner.stop();
|
|
110
|
-
console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${stdout}`);
|
|
111
|
-
process.exit();
|
|
112
|
-
}
|
|
113
|
-
if (stderr) {
|
|
114
|
-
spinner.stop();
|
|
115
|
-
console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${stderr}`);
|
|
116
|
-
process.exit();
|
|
117
|
-
}
|
|
118
|
-
deleteJSFiles(`./taxon/${genus}`).then(() => {
|
|
119
|
-
const filePath = './output/';
|
|
120
|
-
console.log(`\x1b[1m\x1b[32m✔ Database exported: \x1b[33m${filePath}${genus}DB.json\x1b[0m\x1b[1m\x1b[32m\x1b[0m`);
|
|
121
|
-
spinner.stop();
|
|
122
|
-
try {
|
|
123
|
-
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.js`);
|
|
124
|
-
fs_1.default.rm('./temp', { recursive: true }, (err) => {
|
|
125
|
-
if (err) {
|
|
126
|
-
console.error('Error deleting directory:', err);
|
|
127
|
-
process.exit();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
console.error(`An error occurred while deleting the file: ${err}`);
|
|
133
|
-
process.exit();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (load === 'csv') {
|
|
141
|
-
const inputFilePath = './input/taxaToExport.csv';
|
|
142
|
-
const tempFilePath = './temp/exportTemp.ts';
|
|
143
|
-
fs_1.default.createReadStream(inputFilePath)
|
|
144
|
-
.pipe((0, csv_parser_1.default)({ headers: false }))
|
|
145
|
-
.on('data', (data) => {
|
|
146
|
-
taxa.push(data['0']);
|
|
147
|
-
})
|
|
148
|
-
.on('end', () => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const importStatements = taxa.map((species) => {
|
|
150
|
-
return `import { ${species.replace(/\s/g, '_').replace(/\-([a-z])/, (_, match) => match.toUpperCase())} } from '../taxon/${genus}/${species.replace(/\s/g, '_')}'`;
|
|
151
|
-
}).join('\n');
|
|
152
|
-
const speciesCall = taxa.map((species) => {
|
|
153
|
-
return ` ${species.replace(/\s/g, '_').replace(/\-([a-z])/, (_, match) => match.toUpperCase())},`;
|
|
154
|
-
}).join('\n');
|
|
155
|
-
const fileContent = `// Import genus ${genus}
|
|
156
|
-
import { ${genus} } from '../taxon/${genus}'
|
|
157
|
-
|
|
158
|
-
// Import species of ${genus}
|
|
159
|
-
${importStatements}
|
|
160
|
-
|
|
161
|
-
const ${genus}_species: ${genus}[] = [
|
|
162
|
-
${speciesCall}
|
|
163
|
-
]
|
|
164
|
-
|
|
165
|
-
// Export ${genus}DB.json
|
|
166
|
-
const jsonData = JSON.stringify(${genus}_species);
|
|
167
|
-
console.log(jsonData)
|
|
168
|
-
// import { writeFileSync } from 'fs'
|
|
169
|
-
// const jsonData = JSON.stringify(${genus}_species)
|
|
170
|
-
// const inputFilePath = '../output/${genus}DB.json'
|
|
171
|
-
// writeFileSync(inputFilePath, jsonData, 'utf-8')
|
|
172
|
-
// console.log('\\x1b[1m\\x1b[32m✔ Process finished.\\x1b[0m')`;
|
|
173
|
-
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
174
|
-
const fileToTranspile = 'exportTemp';
|
|
175
|
-
(0, child_process_1.exec)(`tsc ./temp/${fileToTranspile}.ts`, (error, stdout, stderr) => {
|
|
176
|
-
if (stdout) {
|
|
177
|
-
spinner.stop();
|
|
178
|
-
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
179
|
-
process.exit();
|
|
180
|
-
}
|
|
181
|
-
if (stderr) {
|
|
182
|
-
spinner.stop();
|
|
183
|
-
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
184
|
-
process.exit();
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
spinner.stop();
|
|
191
|
-
console.error(`An error occurred while deleting the file: ${err}`);
|
|
192
|
-
process.exit();
|
|
193
|
-
}
|
|
194
|
-
(0, child_process_1.exec)(`node ./temp/${fileToTranspile}.js > ./output/${genus}DB.json`, (error, stdout, stderr) => {
|
|
195
|
-
// if (error) {
|
|
196
|
-
// spinner.stop()
|
|
197
|
-
// console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${error.message}`)
|
|
198
|
-
// process.exit()
|
|
199
|
-
// }
|
|
200
|
-
if (stdout) {
|
|
201
|
-
spinner.stop();
|
|
202
|
-
console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${stdout}`);
|
|
203
|
-
process.exit();
|
|
204
|
-
}
|
|
205
|
-
if (stderr) {
|
|
206
|
-
spinner.stop();
|
|
207
|
-
console.error('\x1b[31m✖ JS execution time error:\x1b[0m\n\n' + `${stderr}`);
|
|
208
|
-
process.exit();
|
|
209
|
-
}
|
|
210
|
-
deleteJSFiles(`./taxon/${genus}`).then(() => {
|
|
211
|
-
const filePath = './output/';
|
|
212
|
-
console.log(`\x1b[1m\x1b[32m✔ Database exported: \x1b[33m${filePath}${genus}DB.json\x1b[0m\x1b[1m\x1b[32m\x1b[0m`);
|
|
213
|
-
spinner.stop();
|
|
214
|
-
try {
|
|
215
|
-
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.js`);
|
|
216
|
-
fs_1.default.rm('./temp', { recursive: true }, (err) => {
|
|
217
|
-
if (err) {
|
|
218
|
-
console.error('Error deleting directory:', err);
|
|
219
|
-
process.exit();
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
catch (err) {
|
|
224
|
-
console.error(`An error occurred while deleting the file: ${err}`);
|
|
225
|
-
process.exit();
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
exports.default = ttsExport;
|
package/dist/exportSources.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
function ttsExportSources(genus) {
|
|
9
|
-
if (genus === '') {
|
|
10
|
-
console.error('\x1b[31m✖ Argument `--genus` cannot be empty.\x1b[0m');
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const filePath = `./output/${genus}DB.json`;
|
|
14
|
-
fs_1.default.readFile(filePath, 'utf8', (err, data) => {
|
|
15
|
-
if (err) {
|
|
16
|
-
console.error('Error reading the file:', err);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const jsonData = JSON.parse(data);
|
|
21
|
-
const findObjectsWithSources = (obj, currentPath = []) => {
|
|
22
|
-
let objectsWithSources = [];
|
|
23
|
-
const findObjectsWithSourcesRecursively = (currentObj, path) => {
|
|
24
|
-
if (lodash_1.default.isObject(currentObj)) {
|
|
25
|
-
lodash_1.default.forOwn(currentObj, (value, key) => {
|
|
26
|
-
if (key === 'sources' && Array.isArray(value) && value.length > 0) {
|
|
27
|
-
value.forEach((source) => {
|
|
28
|
-
objectsWithSources.push({
|
|
29
|
-
index: path[0],
|
|
30
|
-
path: path.join('.'),
|
|
31
|
-
specificEpithet: lodash_1.default.get(jsonData[path[0]], 'specificEpithet'),
|
|
32
|
-
source: source
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
if (lodash_1.default.isObject(value)) {
|
|
37
|
-
findObjectsWithSourcesRecursively(value, [...path, key]);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
findObjectsWithSourcesRecursively(obj, currentPath);
|
|
43
|
-
objectsWithSources.forEach(item => {
|
|
44
|
-
item.path = item.path.replace(new RegExp(`^${item.index}\\.|${item.index}$`), '');
|
|
45
|
-
});
|
|
46
|
-
return objectsWithSources;
|
|
47
|
-
};
|
|
48
|
-
const objectsWithSources = findObjectsWithSources(jsonData.map((item, index) => (Object.assign(Object.assign({}, item), { index }))));
|
|
49
|
-
const filePathOutput = `./output/${genus}SourcesDB.json`;
|
|
50
|
-
const jsonContent = JSON.stringify(objectsWithSources, null, 2);
|
|
51
|
-
fs_1.default.writeFileSync(filePathOutput, jsonContent, 'utf-8');
|
|
52
|
-
console.log(`\x1b[1m\x1b[32m✔ Database exported: \x1b[33m${filePathOutput}\x1b[0m\x1b[1m\x1b[32m\x1b[0m`);
|
|
53
|
-
}
|
|
54
|
-
catch (jsonErr) {
|
|
55
|
-
console.error('Error parsing JSON:', jsonErr);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.default = ttsExportSources;
|
package/dist/findProperty.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
function ttsfindProperty(property, genus) {
|
|
9
|
-
if (property === '') {
|
|
10
|
-
console.error('\x1b[31m✖ Argument `--property` cannot be empty.\x1b[0m');
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (genus === '') {
|
|
14
|
-
console.error('\x1b[31m✖ Argument `--genus` cannot be empty.\x1b[0m');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const filePath = `./output/${genus}DB.json`;
|
|
18
|
-
const propertyPathToFind = property;
|
|
19
|
-
fs_1.default.readFile(filePath, 'utf8', (err, data) => {
|
|
20
|
-
if (err) {
|
|
21
|
-
console.error('Error reading the file:', err);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
const jsonData = JSON.parse(data);
|
|
26
|
-
const findPropertyPath = (obj, propertyPath, currentPath = []) => {
|
|
27
|
-
const paths = [];
|
|
28
|
-
const findPathsRecursively = (currentObj, path) => {
|
|
29
|
-
const lastKey = path[path.length - 1];
|
|
30
|
-
if (lodash_1.default.get(currentObj, propertyPath)) {
|
|
31
|
-
if (typeof lastKey !== 'number') {
|
|
32
|
-
paths.push(path.join('.'));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
lodash_1.default.forEach(currentObj, (value, key) => {
|
|
36
|
-
if (lodash_1.default.isObject(value)) {
|
|
37
|
-
findPathsRecursively(value, [...path, key]);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
findPathsRecursively(obj, currentPath);
|
|
42
|
-
return paths;
|
|
43
|
-
};
|
|
44
|
-
const resultIndicesAndPaths = jsonData.flatMap((item, index) => {
|
|
45
|
-
const paths = findPropertyPath(item, propertyPathToFind);
|
|
46
|
-
if (paths.length > 0) {
|
|
47
|
-
return { index, paths, specificEpithet: jsonData[index].specificEpithet };
|
|
48
|
-
}
|
|
49
|
-
return [];
|
|
50
|
-
});
|
|
51
|
-
console.log(`\x1b[36mℹ️ Indices and paths of objects with the property \x1b[33m${propertyPathToFind}\x1b[0m\x1b[36m:\n\n\x1b[0m`, resultIndicesAndPaths);
|
|
52
|
-
}
|
|
53
|
-
catch (jsonErr) {
|
|
54
|
-
console.error('Error parsing JSON:', jsonErr);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.default = ttsfindProperty;
|
package/dist/import.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const csv_parser_1 = __importDefault(require("csv-parser"));
|
|
8
|
-
const mustache_1 = __importDefault(require("mustache"));
|
|
9
|
-
const mapColumns = {
|
|
10
|
-
'specificEpithet': 'specificEpithet',
|
|
11
|
-
'descriptionAuthorship': 'descriptionAuthorship',
|
|
12
|
-
'leaf.bipinnate.pinnae.numberOfPairs.rarelyMin': 'leafBipinnatePinnaeNumberOfPairsRarelyMin',
|
|
13
|
-
'leaf.bipinnate.pinnae.numberOfPairs.min': 'leafBipinnatePinnaeNumberOfPairsMin',
|
|
14
|
-
'leaf.bipinnate.pinnae.numberOfPairs.max': 'leafBipinnatePinnaeNumberOfPairsMax',
|
|
15
|
-
'leaf.bipinnate.pinnae.numberOfPairs.rarelyMax': 'leafBipinnatePinnaeNumberOfPairsRarelyMax',
|
|
16
|
-
'leaf.bipinnate.pinnae.numberOfPairs.value': 'leafBipinnatePinnaeNumberOfPairsValue',
|
|
17
|
-
'leaf.bipinnate.pinnae.leaflet.numberOfPairs.rarelyMin': 'leafBipinnatePinnaeLeafletNumberOfPairsRarelyMin',
|
|
18
|
-
'leaf.bipinnate.pinnae.leaflet.numberOfPairs.min': 'leafBipinnatePinnaeLeafletNumberOfPairsMin',
|
|
19
|
-
'leaf.bipinnate.pinnae.leaflet.numberOfPairs.max': 'leafBipinnatePinnaeLeafletNumberOfPairsMax',
|
|
20
|
-
'leaf.bipinnate.pinnae.leaflet.numberOfPairs.rarelyMax': 'leafBipinnatePinnaeLeafletNumberOfPairsRarelyMax',
|
|
21
|
-
'leaf.bipinnate.pinnae.leaflet.numberOfPairs.value': 'leafBipinnatePinnaeLeafletNumberOfPairsValue',
|
|
22
|
-
'inflorescence.type': 'inflorescenceType',
|
|
23
|
-
'inflorescence.shape': 'inflorescenceShape',
|
|
24
|
-
'flower.merism': 'flowerMerism',
|
|
25
|
-
'flower.numberWhorlsOfStamens': 'numberWhorlsOfStamens',
|
|
26
|
-
'flower.calyx.shape': 'flowerCalyxShape',
|
|
27
|
-
'flower.corolla.shape': 'flowerCorollaShape',
|
|
28
|
-
'androecium.filaments.colour': 'androeciumFilamentsColour',
|
|
29
|
-
'timestamp': 'timestamp'
|
|
30
|
-
};
|
|
31
|
-
let genusErrorShown = {};
|
|
32
|
-
function generateDescription(taxon, genus) {
|
|
33
|
-
try {
|
|
34
|
-
const template = fs_1.default.readFileSync(`./taxon/${genus}/${genus}_template.txt`, 'utf-8');
|
|
35
|
-
const outputDir = 'output/';
|
|
36
|
-
const context = {};
|
|
37
|
-
for (const column in mapColumns) {
|
|
38
|
-
const templateColumn = mapColumns[column];
|
|
39
|
-
if (taxon[column]) {
|
|
40
|
-
context[templateColumn] = taxon[column];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (taxon['inflorescence.capitate'] === 'yes') {
|
|
44
|
-
context['capitateInflorescence'] = true;
|
|
45
|
-
}
|
|
46
|
-
if (taxon['inflorescence.spicate'] === 'yes') {
|
|
47
|
-
context['spicateInflorescence'] = true;
|
|
48
|
-
}
|
|
49
|
-
let sanitizeSpecificEpithet = taxon['specificEpithet'].replace(/\s/g, '_');
|
|
50
|
-
sanitizeSpecificEpithet = sanitizeSpecificEpithet.replace(/-(\w)/, function (match, p1) {
|
|
51
|
-
return p1.toUpperCase();
|
|
52
|
-
});
|
|
53
|
-
context['specificEpithet'] = sanitizeSpecificEpithet;
|
|
54
|
-
let output = mustache_1.default.render(template, context);
|
|
55
|
-
const specificEpithet = taxon['specificEpithet'];
|
|
56
|
-
const fileName = `${outputDir}${genus}_${specificEpithet.replace(/\s/g, '_')}.ts`;
|
|
57
|
-
// timestamp
|
|
58
|
-
output = output.replace('date:', `date: ` + Math.floor(Date.now() / 1000));
|
|
59
|
-
output = output
|
|
60
|
-
.replace(/'\[/g, '[')
|
|
61
|
-
.replace(/\]'/g, ']')
|
|
62
|
-
.replace(/'/g, '\'');
|
|
63
|
-
if (output.trim() !== '') {
|
|
64
|
-
fs_1.default.writeFileSync(fileName, output);
|
|
65
|
-
console.log(`\x1b[1m\x1b[32m✔ New script file: \x1b[0m\x1b[1m\x1b[33m./${fileName}\x1b[0m`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
if (error.code === 'ENOENT') {
|
|
70
|
-
if (genus !== '' && !genusErrorShown[genus]) {
|
|
71
|
-
console.error(`\x1b[31m✖ A TTS project for genus \x1b[33m\x1b[3m${genus}\x1b[0m\x1b[31m has not been implemented yet.\x1b[0m`);
|
|
72
|
-
console.log('\x1b[36m + ℹ️ To create a new TTS project, visit:\x1b[0m');
|
|
73
|
-
console.log('\x1b[33m https://www.npmjs.com/package/typetaxonscript?activeTab=readme#creating-and-editing-a-genus-template.\x1b[0m');
|
|
74
|
-
genusErrorShown[genus] = true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
console.error('An error occurred while reading the file:', error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function ttsImportFromCsv(genus) {
|
|
83
|
-
if (genus === '') {
|
|
84
|
-
console.error('\x1b[31m✖ Argument `--genus` cannot be empty.\x1b[0m');
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
fs_1.default.createReadStream('./input/importTaxa.csv')
|
|
88
|
-
.pipe((0, csv_parser_1.default)({ separator: ';' }))
|
|
89
|
-
.on('data', (taxon) => {
|
|
90
|
-
generateDescription(taxon, genus);
|
|
91
|
-
})
|
|
92
|
-
.on('end', () => {
|
|
93
|
-
if (!genusErrorShown[genus]) {
|
|
94
|
-
//console.log('\x1b[1m\x1b[32m✔ Process finished.\x1b[0m')
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
exports.default = ttsImportFromCsv;
|
package/dist/init.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const fs = __importStar(require("fs"));
|
|
27
|
-
const path = __importStar(require("path"));
|
|
28
|
-
function createInputCSVFiles() {
|
|
29
|
-
const inputDir = 'input';
|
|
30
|
-
if (!fs.existsSync(inputDir)) {
|
|
31
|
-
fs.mkdirSync(inputDir);
|
|
32
|
-
console.log('\x1b[36mℹ️ The', '\x1b[33m./input', '\x1b[36mdirectory has been created.\x1b[0m');
|
|
33
|
-
const taxaToExportContent = `Mimosa afranioi
|
|
34
|
-
Mimosa arenosa var arenosa
|
|
35
|
-
Mimosa aurivillus var calothamnos
|
|
36
|
-
Mimosa bimucronata
|
|
37
|
-
Mimosa blanchetii
|
|
38
|
-
Mimosa caesalpiniifolia
|
|
39
|
-
Mimosa campicola
|
|
40
|
-
Mimosa cordistipula
|
|
41
|
-
Mimosa cubatanensis
|
|
42
|
-
Mimosa debilis var debilis
|
|
43
|
-
Mimosa diplotricha var diplotricha
|
|
44
|
-
Mimosa dolens var dolens
|
|
45
|
-
Mimosa dryandroides var dryandroides
|
|
46
|
-
Mimosa elliptica`;
|
|
47
|
-
const importTaxaContent = `"specificEpithet";"leaf.bipinnate.pinnae.numberOfPairs.rarelyMin";"leaf.bipinnate.pinnae.numberOfPairs.min";"leaf.bipinnate.pinnae.numberOfPairs.max";"leaf.bipinnate.pinnae.numberOfPairs.rarelyMax";"leaf.bipinnate.pinnae.numberOfPairs.value";"leaf.bipinnate.pinnae.leaflet.numberOfPairs.rarelyMin";"leaf.bipinnate.pinnae.leaflet.numberOfPairs.min";"leaf.bipinnate.pinnae.leaflet.numberOfPairs.max";"leaf.bipinnate.pinnae.leaflet.numberOfPairs.rarelyMax";"leaf.bipinnate.pinnae.leaflet.numberOfPairs.value";"inflorescence.spicate";"inflorescence.capitate";"flower.merism";"flower.calyx.shape";"flower.corolla.shape";"flower.numberWhorlsOfStamens";"androecium.filaments.colour";"descriptionAuthorship"
|
|
48
|
-
"arenosa var arenosa";"";"4";"12";"";"";"";"12";"30";"";"";"yes";"";"['4-merous', '5-merous']";"campanulate";"turbinate";"diplostemonous";"withish";"June Doe"
|
|
49
|
-
"artemisiana";"";"7";"12";"";"";"";"15";"29";"";"";"yes";"";"4-merous";"campanulate";"campanulate";"diplostemonous";"withish";"June Doe"
|
|
50
|
-
"ceratonia var pseudo-obovata";"";"2";"4";"5";"";"";"2";"4";"5";"";"";"yes";"3-merous";"campanulate";"turbinate";"diplostemonous";"withish";"June Doe"`;
|
|
51
|
-
const taxaToExportPath = path.join(inputDir, 'taxaToExport.csv');
|
|
52
|
-
const importTaxaPath = path.join(inputDir, 'importTaxa.csv');
|
|
53
|
-
fs.writeFileSync(taxaToExportPath, taxaToExportContent);
|
|
54
|
-
fs.writeFileSync(importTaxaPath, importTaxaContent);
|
|
55
|
-
console.log('\x1b[36mℹ️ The', '\x1b[33m./input/importTaxa.csv', '\x1b[36mfile has been created.\x1b[0m');
|
|
56
|
-
console.log('\x1b[90m + This file is needed to execute the `import` command.\x1b[0m');
|
|
57
|
-
console.log('\x1b[90m + It is a simple headerless CSV with each taxon on a separate line/row.\x1b[0m');
|
|
58
|
-
console.log('\x1b[36mℹ️ The', '\x1b[33m./input/taxaToExport.csv', '\x1b[36mfile has been created.\x1b[0m');
|
|
59
|
-
console.log('\x1b[90m + This file is needed to execute argument `--load csv` of `export` command.\x1b[0m');
|
|
60
|
-
console.log('\x1b[90m + It is used to export a specific list of taxa instead of exporting all, which is the default setting.\x1b[0m');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function ttsInit() {
|
|
64
|
-
// Checking directories
|
|
65
|
-
fs.readdir('./', (err, dirs) => {
|
|
66
|
-
if (err) {
|
|
67
|
-
console.error('Error reading directories:', err);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (dirs.length === 0) {
|
|
71
|
-
console.error('\x1b[36mℹ️ The directory is empty. Please clone a TTS project first.\x1b[0m');
|
|
72
|
-
console.log('\x1b[36mℹ️ Please, visit:\x1b[0m');
|
|
73
|
-
console.log('\x1b[36m TypeTaxonScript package:', '\x1b[33mhttps://www.npmjs.com/package/typetaxonscript.\x1b[0m');
|
|
74
|
-
console.log('\x1b[36m TTS project (Mimosa):', '\x1b[33mhttps://github.com/lsbjordao/TTS-Mimosa.\x1b[0m');
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (!dirs.includes('taxon') && !dirs.includes('character')) {
|
|
78
|
-
console.error('\x1b[36mℹ️ The directory does not contain a TTS project.\x1b[0m');
|
|
79
|
-
console.log('\x1b[36mℹ️ Please, visit:\x1b[0m');
|
|
80
|
-
console.log('\x1b[36m TypeTaxonScript package:', '\x1b[33mhttps://www.npmjs.com/package/typetaxonscript.\x1b[0m');
|
|
81
|
-
console.log('\x1b[36m TTS project (Mimosa):', '\x1b[33mhttps://github.com/lsbjordao/TTS-Mimosa.\x1b[0m');
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const requiredDirs = ['input', 'output', 'characters', 'taxon'];
|
|
85
|
-
const allRequiredDirsPresent = requiredDirs.every(dir => dirs.includes(dir));
|
|
86
|
-
if (allRequiredDirsPresent) {
|
|
87
|
-
console.error('\x1b[36mℹ️ The root directory is not clean. Look:\x1b[0m');
|
|
88
|
-
const listDirectoryTree = (dir, prefix = '') => {
|
|
89
|
-
const files = fs.readdirSync(dir);
|
|
90
|
-
files.forEach((file, index) => {
|
|
91
|
-
const filePath = path.join(dir, file);
|
|
92
|
-
const isDirectory = fs.statSync(filePath).isDirectory();
|
|
93
|
-
const isLast = index === files.length - 1;
|
|
94
|
-
console.log(`${prefix}${isLast ? '└──' : '├──'} ${file}`);
|
|
95
|
-
if (isDirectory) {
|
|
96
|
-
const nestedPrefix = `${prefix}${isLast ? ' ' : '│ '}`;
|
|
97
|
-
listDirectoryTree(filePath, nestedPrefix);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
const excludedDirectories = ['node_modules', '.git', 'dist'];
|
|
102
|
-
const hasPreviousProject = (dir, prefix = '') => {
|
|
103
|
-
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
104
|
-
const directories = files
|
|
105
|
-
.filter(dirent => dirent.isDirectory() && !excludedDirectories.includes(dirent.name))
|
|
106
|
-
.map(dirent => dirent.name);
|
|
107
|
-
directories.forEach((directory, index) => {
|
|
108
|
-
const directoryPath = path.join(dir, directory);
|
|
109
|
-
const isLast = index === directories.length - 1;
|
|
110
|
-
console.log(`${prefix}${isLast ? '└──' : '├──'} ${directory}`);
|
|
111
|
-
const nestedPrefix = `${prefix}${isLast ? ' ' : '│ '}`;
|
|
112
|
-
hasPreviousProject(directoryPath, nestedPrefix);
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
hasPreviousProject('./');
|
|
116
|
-
console.error('\x1b[36mℹ️ A previous project is already found.\x1b[0m');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
createInputCSVFiles();
|
|
121
|
-
const outputDir = 'output';
|
|
122
|
-
if (!fs.existsSync(outputDir)) {
|
|
123
|
-
fs.mkdirSync(outputDir);
|
|
124
|
-
const gitKeepFile = `${outputDir}/.gitkeep`;
|
|
125
|
-
fs.writeFileSync(gitKeepFile, '');
|
|
126
|
-
console.log('\x1b[36mℹ️ The', '\x1b[33m./output', '\x1b[36mdirectory has been created.\x1b[0m');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
exports.default = ttsInit;
|
package/dist/new.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
-
function ttsNewDesc(genus, species) {
|
|
9
|
-
try {
|
|
10
|
-
if (species === '') {
|
|
11
|
-
console.error('\x1b[31m✖ Argument `--species` cannot be empty.\x1b[0m');
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (genus === '') {
|
|
15
|
-
console.error('\x1b[31m✖ Argument `--genus` cannot be empty.\x1b[0m');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const outputDir = 'output/';
|
|
19
|
-
const templatePath = `./taxon/${genus}/${genus}_template.txt`;
|
|
20
|
-
if (!fs_1.default.existsSync(templatePath)) {
|
|
21
|
-
console.error(`\x1b[31m✖ A TTS project for genus \x1b[33m\x1b[3m${genus}\x1b[0m\x1b[31m has not been implemented yet.\x1b[0m`);
|
|
22
|
-
console.log('\x1b[36m + ℹ️ To create a new TTS project, visit:\x1b[0m');
|
|
23
|
-
console.log('\x1b[33m https://www.npmjs.com/package/typetaxonscript?activeTab=readme#creating-and-editing-a-genus-template.\x1b[0m');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const template = fs_1.default.readFileSync(templatePath, 'utf-8');
|
|
27
|
-
let sanitizeSpecificEpithet = species.replace(/\s/g, '_');
|
|
28
|
-
sanitizeSpecificEpithet = sanitizeSpecificEpithet.replace(/-(\w)/, function (match, p1) {
|
|
29
|
-
return p1.toUpperCase();
|
|
30
|
-
});
|
|
31
|
-
const context = {
|
|
32
|
-
specificEpithet: sanitizeSpecificEpithet
|
|
33
|
-
};
|
|
34
|
-
let output = mustache_1.default.render(template, context);
|
|
35
|
-
const fileName = `${outputDir}${genus}_${species.replace(/\s/g, '_')}.ts`;
|
|
36
|
-
// timestamp
|
|
37
|
-
output = output.replace('date:', `date: ` + Math.floor(Date.now() / 1000));
|
|
38
|
-
if (output.trim() !== '') {
|
|
39
|
-
fs_1.default.writeFileSync(fileName, output);
|
|
40
|
-
console.log(`\x1b[1m\x1b[32m✔ New script file: \x1b[0m\x1b[1m\x1b[33m./${fileName}\x1b[0m`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
console.error('An error occurred:', error);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = ttsNewDesc;
|
package/dist/tts.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
7
|
-
const init_1 = __importDefault(require("./init"));
|
|
8
|
-
const new_1 = __importDefault(require("./new"));
|
|
9
|
-
const import_1 = __importDefault(require("./import"));
|
|
10
|
-
const export_1 = __importDefault(require("./export"));
|
|
11
|
-
const exportSources_1 = __importDefault(require("./exportSources"));
|
|
12
|
-
const findProperty_1 = __importDefault(require("./findProperty"));
|
|
13
|
-
yargs_1.default.version();
|
|
14
|
-
yargs_1.default.command({
|
|
15
|
-
command: 'init',
|
|
16
|
-
describe: 'Initiate a TTS project',
|
|
17
|
-
builder: {},
|
|
18
|
-
handler: () => (0, init_1.default)(),
|
|
19
|
-
});
|
|
20
|
-
yargs_1.default.command({
|
|
21
|
-
command: 'new',
|
|
22
|
-
describe: 'Create a new description entry',
|
|
23
|
-
builder: {
|
|
24
|
-
genus: {
|
|
25
|
-
describe: 'Genus name',
|
|
26
|
-
demandOption: true,
|
|
27
|
-
type: 'string',
|
|
28
|
-
},
|
|
29
|
-
species: {
|
|
30
|
-
describe: 'Specific epithet',
|
|
31
|
-
demandOption: true,
|
|
32
|
-
type: 'string',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
handler: (argv) => {
|
|
36
|
-
(0, new_1.default)(argv.genus, argv.species);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
yargs_1.default.command({
|
|
40
|
-
command: 'import',
|
|
41
|
-
describe: 'Import taxa and characters from CSV file',
|
|
42
|
-
builder: {
|
|
43
|
-
genus: {
|
|
44
|
-
describe: 'Genus name',
|
|
45
|
-
demandOption: true,
|
|
46
|
-
type: 'string',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
handler: (argv) => {
|
|
50
|
-
(0, import_1.default)(argv.genus);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
yargs_1.default.command({
|
|
54
|
-
command: 'export',
|
|
55
|
-
describe: 'Export database',
|
|
56
|
-
builder: {
|
|
57
|
-
genus: {
|
|
58
|
-
describe: 'Genus name',
|
|
59
|
-
demandOption: true,
|
|
60
|
-
type: 'string',
|
|
61
|
-
},
|
|
62
|
-
load: {
|
|
63
|
-
describe: 'Load a list of taxa to export from the csv file: "./input/taxaToExport.csv".',
|
|
64
|
-
demandOption: false,
|
|
65
|
-
type: 'string',
|
|
66
|
-
choices: ['all', 'csv'],
|
|
67
|
-
default: 'all'
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
handler: (argv) => {
|
|
71
|
-
(0, export_1.default)(argv.genus, argv.load);
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
yargs_1.default.command({
|
|
75
|
-
command: 'exportSources',
|
|
76
|
-
describe: 'Export sources database',
|
|
77
|
-
builder: {
|
|
78
|
-
genus: {
|
|
79
|
-
describe: 'Genus name',
|
|
80
|
-
demandOption: true,
|
|
81
|
-
type: 'string',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
handler: (argv) => {
|
|
85
|
-
(0, exportSources_1.default)(argv.genus);
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
yargs_1.default.command({
|
|
89
|
-
command: 'findProperty',
|
|
90
|
-
describe: 'Find a property',
|
|
91
|
-
builder: {
|
|
92
|
-
property: {
|
|
93
|
-
describe: 'Property path to find',
|
|
94
|
-
demandOption: true,
|
|
95
|
-
type: 'string',
|
|
96
|
-
},
|
|
97
|
-
genus: {
|
|
98
|
-
describe: 'Genus name',
|
|
99
|
-
demandOption: true,
|
|
100
|
-
type: 'string',
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
handler: (argv) => {
|
|
104
|
-
(0, findProperty_1.default)(argv.property, argv.genus);
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
yargs_1.default
|
|
108
|
-
.parse();
|