@lsbjordao/type-taxon-script 1.0.15 → 1.1.1
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/dist/export.js +201 -205
- package/dist/exportSources.js +59 -63
- package/dist/findProperty.js +58 -58
- package/dist/import.js +98 -98
- package/dist/init.js +115 -115
- package/dist/new.js +47 -47
- package/dist/tts.js +108 -130
- package/package.json +4 -4
- package/readme.md +453 -1
- package/dist/exportToCsv.js +0 -268
package/dist/new.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,130 +1,108 @@
|
|
|
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
|
|
13
|
-
|
|
14
|
-
yargs_1.default.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
yargs_1.default.command({
|
|
111
|
-
command: 'findProperty',
|
|
112
|
-
describe: 'Find a property',
|
|
113
|
-
builder: {
|
|
114
|
-
property: {
|
|
115
|
-
describe: 'Property path to find',
|
|
116
|
-
demandOption: true,
|
|
117
|
-
type: 'string',
|
|
118
|
-
},
|
|
119
|
-
genus: {
|
|
120
|
-
describe: 'Genus name',
|
|
121
|
-
demandOption: true,
|
|
122
|
-
type: 'string',
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
handler: (argv) => {
|
|
126
|
-
(0, findProperty_1.default)(argv.property, argv.genus);
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
yargs_1.default
|
|
130
|
-
.parse();
|
|
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();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsbjordao/type-taxon-script",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"fs": "^0.0.1-security",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
14
|
"mustache": "^4.2.0",
|
|
15
|
-
"yargs": "^17.7.2"
|
|
15
|
+
"yargs": "^17.7.2",
|
|
16
|
+
"typescript": "^5.1.5"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@types/cli-spinner": "^0.2.3",
|
|
19
20
|
"@types/lodash": "^4.14.202",
|
|
20
21
|
"@types/mustache": "^4.2.5",
|
|
21
22
|
"@types/node": "^20.4.10",
|
|
22
|
-
"@types/yargs": "^17.0.32"
|
|
23
|
-
"typescript": "^5.1.5"
|
|
23
|
+
"@types/yargs": "^17.0.32"
|
|
24
24
|
},
|
|
25
25
|
"main": "dist/tts.js",
|
|
26
26
|
"files": [
|