@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/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 exportToCsv_1 = __importDefault(require("./exportToCsv"));
13
- const findProperty_1 = __importDefault(require("./findProperty"));
14
- yargs_1.default.version();
15
- yargs_1.default.command({
16
- command: 'init',
17
- describe: 'Initiate a TTS project',
18
- builder: {},
19
- handler: () => (0, init_1.default)(),
20
- });
21
- yargs_1.default.command({
22
- command: 'new',
23
- describe: 'Create a new description entry',
24
- builder: {
25
- genus: {
26
- describe: 'Genus name',
27
- demandOption: true,
28
- type: 'string',
29
- },
30
- species: {
31
- describe: 'Specific epithet',
32
- demandOption: true,
33
- type: 'string',
34
- },
35
- },
36
- handler: (argv) => {
37
- (0, new_1.default)(argv.genus, argv.species);
38
- },
39
- });
40
- yargs_1.default.command({
41
- command: 'import',
42
- describe: 'Import taxa and characters from CSV file',
43
- builder: {
44
- genus: {
45
- describe: 'Genus name',
46
- demandOption: true,
47
- type: 'string',
48
- },
49
- },
50
- handler: (argv) => {
51
- (0, import_1.default)(argv.genus);
52
- },
53
- });
54
- yargs_1.default.command({
55
- command: 'export',
56
- describe: 'Export a JSON database',
57
- builder: {
58
- genus: {
59
- describe: 'Genus name',
60
- demandOption: true,
61
- type: 'string',
62
- },
63
- load: {
64
- describe: 'Load a list of taxa to export from the csv file: "./input/taxaToExport.csv".',
65
- demandOption: false,
66
- type: 'string',
67
- choices: ['all', 'csv'],
68
- default: 'all'
69
- }
70
- },
71
- handler: (argv) => {
72
- (0, export_1.default)(argv.genus, argv.load);
73
- },
74
- });
75
- yargs_1.default.command({
76
- command: 'exportSources',
77
- describe: 'Export sources database',
78
- builder: {
79
- genus: {
80
- describe: 'Genus name',
81
- demandOption: true,
82
- type: 'string',
83
- },
84
- },
85
- handler: (argv) => {
86
- (0, exportSources_1.default)(argv.genus);
87
- },
88
- });
89
- yargs_1.default.command({
90
- command: 'exportToCsv',
91
- describe: 'Export a CSV database',
92
- builder: {
93
- genus: {
94
- describe: 'Genus name',
95
- demandOption: true,
96
- type: 'string',
97
- },
98
- load: {
99
- describe: 'Load a list of taxa to export from the csv file: "./input/taxaToExport.csv".',
100
- demandOption: false,
101
- type: 'string',
102
- choices: ['all', 'csv'],
103
- default: 'all'
104
- }
105
- },
106
- handler: (argv) => {
107
- (0, exportToCsv_1.default)(argv.genus, argv.load);
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.0.15",
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": [