@ca-plant-list/ca-plant-list 0.4.11 → 0.4.12
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/data/exceptions.json +16 -1
- package/data/inattaxonphotos.csv +6 -0
- package/data/taxa.csv +1363 -1362
- package/lib/csv.js +37 -1
- package/lib/exceptions.js +2 -2
- package/lib/htmltaxon.js +17 -0
- package/lib/taxa.js +8 -2
- package/lib/taxon.js +24 -6
- package/lib/tools/calflora.js +220 -0
- package/lib/tools/calscape.js +214 -0
- package/lib/tools/taxacsv.js +31 -0
- package/lib/web/pagetaxon.js +5 -1
- package/package.json +4 -3
- package/schemas/exceptions.schema.json +6 -1
- package/scripts/cpl-photos.js +5 -1
- package/scripts/cpl-tools.js +177 -0
- package/types/classes.d.ts +6 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ca-plant-list/ca-plant-list",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.12",
|
4
4
|
"description": "Tools to create Jekyll files for a website listing plants in an area of California.",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -16,7 +16,8 @@
|
|
16
16
|
"bin": {
|
17
17
|
"ca-plant-list": "scripts/build-site.js",
|
18
18
|
"ca-plant-book": "scripts/build-ebook.js",
|
19
|
-
"cpl-photos": "scripts/cpl-photos.js"
|
19
|
+
"cpl-photos": "scripts/cpl-photos.js",
|
20
|
+
"cpl-tools": "scripts/cpl-tools.js"
|
20
21
|
},
|
21
22
|
"dependencies": {
|
22
23
|
"archiver": "^5.3.1",
|
@@ -36,8 +37,8 @@
|
|
36
37
|
"@types/markdown-it": "^14.1.2",
|
37
38
|
"@types/node": "^22.7.8",
|
38
39
|
"@types/unzipper": "^0.10.9",
|
39
|
-
"ajv-cli": "^5.0.0",
|
40
40
|
"eslint": "^9.13.0",
|
41
|
+
"exceljs": "^4.4.0",
|
41
42
|
"prettier": "^3.3.3",
|
42
43
|
"typescript": "^5.6.3"
|
43
44
|
}
|
@@ -9,12 +9,17 @@
|
|
9
9
|
"badjepsonid": {
|
10
10
|
"const": true
|
11
11
|
},
|
12
|
+
"native": { "type": "boolean" },
|
12
13
|
"notintaxondata": {
|
13
14
|
"const": true
|
14
15
|
}
|
15
16
|
},
|
16
17
|
"additionalProperties": false
|
17
18
|
},
|
19
|
+
"calscape": {
|
20
|
+
"type": "object",
|
21
|
+
"properties": { "notnative": { "const": true } }
|
22
|
+
},
|
18
23
|
"comment": {
|
19
24
|
"type": "string"
|
20
25
|
},
|
@@ -54,4 +59,4 @@
|
|
54
59
|
},
|
55
60
|
"additionalProperties": false
|
56
61
|
}
|
57
|
-
}
|
62
|
+
}
|
package/scripts/cpl-photos.js
CHANGED
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import * as path from "node:path";
|
4
|
+
import { Option } from "commander";
|
5
|
+
import { Taxa } from "../lib/taxa.js";
|
6
|
+
import { Program } from "../lib/program.js";
|
7
|
+
import { Calflora } from "../lib/tools/calflora.js";
|
8
|
+
import { Exceptions } from "../lib/exceptions.js";
|
9
|
+
import { ErrorLog } from "../lib/errorlog.js";
|
10
|
+
import { Calscape } from "../lib/tools/calscape.js";
|
11
|
+
|
12
|
+
const TOOLS = {
|
13
|
+
CALFLORA: "calflora",
|
14
|
+
CALSCAPE: "calscape",
|
15
|
+
INAT: "inat",
|
16
|
+
JEPSON_EFLORA: "jepson-eflora",
|
17
|
+
JEPSON_FAM: "jepson-families",
|
18
|
+
RPI: "rpi",
|
19
|
+
TEXT: "text",
|
20
|
+
};
|
21
|
+
|
22
|
+
const ALL_TOOLS = [
|
23
|
+
TOOLS.CALFLORA,
|
24
|
+
TOOLS.CALSCAPE,
|
25
|
+
TOOLS.INAT,
|
26
|
+
TOOLS.JEPSON_EFLORA,
|
27
|
+
TOOLS.RPI,
|
28
|
+
TOOLS.TEXT,
|
29
|
+
];
|
30
|
+
|
31
|
+
const OPT_LOADER = "loader";
|
32
|
+
const OPT_TOOL = "tool";
|
33
|
+
|
34
|
+
const TOOLS_DATA_DIR = "./external_data";
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @param {import("commander").Command} program
|
38
|
+
* @param {import("commander").OptionValues} options
|
39
|
+
*/
|
40
|
+
async function build(program, options) {
|
41
|
+
let tools = options[OPT_TOOL];
|
42
|
+
if (!tools) {
|
43
|
+
program.help();
|
44
|
+
}
|
45
|
+
if (tools[0] === "all") {
|
46
|
+
tools = ALL_TOOLS;
|
47
|
+
}
|
48
|
+
|
49
|
+
const exceptions = new Exceptions(options.datadir);
|
50
|
+
// const config = new Config(options.datadir);
|
51
|
+
const taxa = await getTaxa(options);
|
52
|
+
|
53
|
+
const errorLog = new ErrorLog(options.outputdir + "/log.tsv", true);
|
54
|
+
for (const tool of tools) {
|
55
|
+
switch (tool) {
|
56
|
+
case TOOLS.CALFLORA:
|
57
|
+
await Calflora.analyze(
|
58
|
+
TOOLS_DATA_DIR,
|
59
|
+
taxa,
|
60
|
+
exceptions,
|
61
|
+
errorLog,
|
62
|
+
);
|
63
|
+
break;
|
64
|
+
case TOOLS.CALSCAPE:
|
65
|
+
await Calscape.analyze(
|
66
|
+
TOOLS_DATA_DIR,
|
67
|
+
options.datadir,
|
68
|
+
taxa,
|
69
|
+
exceptions,
|
70
|
+
errorLog,
|
71
|
+
!!options.update,
|
72
|
+
);
|
73
|
+
break;
|
74
|
+
case TOOLS.INAT:
|
75
|
+
// await INat.analyze(
|
76
|
+
// TOOLS_DATA_DIR,
|
77
|
+
// taxa,
|
78
|
+
// exceptions,
|
79
|
+
// errorLog,
|
80
|
+
// options.inTaxafile,
|
81
|
+
// );
|
82
|
+
break;
|
83
|
+
case TOOLS.JEPSON_EFLORA: {
|
84
|
+
// const eflora = new JepsonEFlora(
|
85
|
+
// TOOLS_DATA_DIR,
|
86
|
+
// taxa,
|
87
|
+
// errorLog,
|
88
|
+
// options.efLognotes,
|
89
|
+
// );
|
90
|
+
// await eflora.analyze(exceptions);
|
91
|
+
break;
|
92
|
+
}
|
93
|
+
case TOOLS.JEPSON_FAM:
|
94
|
+
// await JepsonFamilies.build(TOOLS_DATA_DIR, options.outputdir);
|
95
|
+
break;
|
96
|
+
case TOOLS.RPI:
|
97
|
+
// await RPI.analyze(
|
98
|
+
// TOOLS_DATA_DIR,
|
99
|
+
// taxa,
|
100
|
+
// config,
|
101
|
+
// exceptions,
|
102
|
+
// errorLog,
|
103
|
+
// );
|
104
|
+
break;
|
105
|
+
case TOOLS.TEXT:
|
106
|
+
// SupplementalText.analyze(taxa, errorLog);
|
107
|
+
break;
|
108
|
+
default:
|
109
|
+
console.log("unrecognized tool: " + tool);
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
errorLog.write();
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* @param {import("commander").OptionValues} options
|
119
|
+
*/
|
120
|
+
async function getTaxa(options) {
|
121
|
+
const errorLog = new ErrorLog(options.outputdir + "/errors.tsv", true);
|
122
|
+
|
123
|
+
const loader = options[OPT_LOADER];
|
124
|
+
let taxa;
|
125
|
+
if (loader) {
|
126
|
+
const taxaLoaderClass = await import("file:" + path.resolve(loader));
|
127
|
+
taxa = await taxaLoaderClass.TaxaLoader.loadTaxa(options, errorLog);
|
128
|
+
} else {
|
129
|
+
taxa = new Taxa(
|
130
|
+
Program.getIncludeList(options.datadir),
|
131
|
+
errorLog,
|
132
|
+
options.showFlowerErrors,
|
133
|
+
);
|
134
|
+
}
|
135
|
+
|
136
|
+
errorLog.write();
|
137
|
+
return taxa;
|
138
|
+
}
|
139
|
+
|
140
|
+
const program = Program.getProgram();
|
141
|
+
program.addOption(
|
142
|
+
new Option(
|
143
|
+
"-t, --tool <tool...>",
|
144
|
+
"The tools to run. Value may be any subset of the tools below.",
|
145
|
+
).choices(["all"].concat(ALL_TOOLS).concat(TOOLS.JEPSON_FAM)),
|
146
|
+
);
|
147
|
+
program.option(
|
148
|
+
"--in-taxafile <file>",
|
149
|
+
"The name of the file containing the iNaturalist taxa. Can be used for testing on a smaller subset of the iNaturalist data.",
|
150
|
+
"inat_taxa.csv",
|
151
|
+
);
|
152
|
+
program.option(
|
153
|
+
"--ef-lognotes",
|
154
|
+
"When running the jepson-eflora tool, include eFlora notes, invalid names, etc. in the log file.",
|
155
|
+
);
|
156
|
+
program.option(
|
157
|
+
"--loader <path>",
|
158
|
+
"The path (relative to the current directory) of the JavaScript file containing the TaxaLoader class. If not provided, the default TaxaLoader will be used.",
|
159
|
+
);
|
160
|
+
program.option("--update", "Update taxa.csv to remove errors if possible.");
|
161
|
+
program.addHelpText(
|
162
|
+
"after",
|
163
|
+
`
|
164
|
+
Tools:
|
165
|
+
'all' runs the 'calflora', 'inat', 'jepson-eflora', 'rpi', and 'text' tools.
|
166
|
+
'${TOOLS.CALFLORA}' retrieves data from Calflora and compares with local data.
|
167
|
+
'${TOOLS.CALSCAPE}' retrieves data from Calscape and compares with local data.
|
168
|
+
'${TOOLS.INAT}' retrieves data from iNaturalist and compares with local data.
|
169
|
+
'${TOOLS.JEPSON_EFLORA}' retrieves data from Jepson eFlora indexes and compares with local data.
|
170
|
+
'${TOOLS.JEPSON_FAM}' retrieves section, family and genus data from Jepson eFlora and creates data files for use by ca-plant-list.
|
171
|
+
'${TOOLS.RPI}' retrieves data from the CNPS Rare Plant Inventory and compares with local data.
|
172
|
+
'${TOOLS.TEXT}' checks supplemental text files to make sure their names are referenced.
|
173
|
+
`,
|
174
|
+
);
|
175
|
+
program.action((options) => build(program, options));
|
176
|
+
|
177
|
+
await program.parseAsync();
|
package/types/classes.d.ts
CHANGED
@@ -83,6 +83,7 @@ declare class Taxa {
|
|
83
83
|
getFlowerColors(): FlowerColor[];
|
84
84
|
getTaxon(name: string): Taxon;
|
85
85
|
getTaxonList(): Taxon[];
|
86
|
+
isSubset(): boolean;
|
86
87
|
}
|
87
88
|
|
88
89
|
declare class TaxaCol {
|
@@ -96,8 +97,11 @@ declare class Taxon {
|
|
96
97
|
getBaseFileName(): string;
|
97
98
|
getBloomEnd(): number | undefined;
|
98
99
|
getBloomStart(): number | undefined;
|
100
|
+
getCalfloraID(): string;
|
99
101
|
getCalfloraName(): string;
|
100
102
|
getCalfloraTaxonLink(): string | undefined;
|
103
|
+
getCalscapeCommonName(): string | undefined;
|
104
|
+
getCalscapeName(): string;
|
101
105
|
getCESA(): string | undefined;
|
102
106
|
getCommonNames(): string[];
|
103
107
|
getFamily(): Family;
|
@@ -123,6 +127,7 @@ declare class Taxon {
|
|
123
127
|
getRPITaxonLink(): string;
|
124
128
|
getStatusDescription(config: Config): string;
|
125
129
|
getSynonyms(): string[];
|
130
|
+
isCANative(): boolean;
|
126
131
|
isNative(): boolean;
|
127
132
|
}
|
128
133
|
|
@@ -130,6 +135,7 @@ declare class TaxonData {
|
|
130
135
|
bloom_end: string;
|
131
136
|
bloom_start: string;
|
132
137
|
calrecnum: string;
|
138
|
+
calscape_cn?: string;
|
133
139
|
CESA: string;
|
134
140
|
"common name": string;
|
135
141
|
CRPR: string;
|