Skip to content

Commit 490c46c

Browse files
committed
Merge remote-tracking branch 'origin/dev', v0.4.4
2 parents fdfea84 + 1acd454 commit 490c46c

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

COMPARISON.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Here I'd like to give an overview of what the validators are capable of and what
1414

1515
| | Python Validator | PySTAC | STAC Node Validator |
1616
| :------------------------- | ------------------------------------------ | ------------------- | ------------------- |
17-
| Validator Version | 1.0.1 | 0.5.2 | 0.4.3 |
17+
| Validator Version | 1.0.1 | 0.5.2 | 0.4.4 |
1818
| Language | Python 3.6 | Python 3 | NodeJS |
1919
| CLI | Yes | No | Yes |
2020
| Programmatic | Yes | Yes | Planned |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ See the [STAC Validator Comparison](COMPARISON.md) for the features supported by
66

77
## Versions
88

9-
**Current version: 0.4.3*
9+
**Current version: 0.4.4*
1010

1111
| STAC Node Validator Version | Supported STAC Versions |
1212
| --------------------------- | ----------------------- |

index.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ let SHORTCUTS = [
1717
'item-assets',
1818
'label',
1919
'pointcloud',
20+
'processing',
2021
'projection',
2122
'sar',
2223
'sat',
@@ -92,12 +93,12 @@ async function run() {
9293
if (Array.isArray(json.collections)) {
9394
entries = json.collections;
9495
isApiList = true;
95-
console.log(file + " is a /collections endpoint. Validating all " + entries.length + " collections, but ignoring the other parts of the response.\n");
96+
console.log(`${file} is a /collections endpoint. Validating all ${entries.length} collections, but ignoring the other parts of the response.\n`);
9697
}
9798
else if (Array.isArray(json.features)) {
9899
entries = json.features;
99100
isApiList = true;
100-
console.log(file + " is a /collections/:id/items endpoint. Validating all " + entries.length + " items, but ignoring the other parts of the response.\n");
101+
console.log(`${file} is a /collections/:id/items endpoint. Validating all ${entries.length} items, but ignoring the other parts of the response.\n`);
101102
}
102103
else {
103104
entries = [json];
@@ -111,16 +112,16 @@ async function run() {
111112
id += " -> " + data.id;
112113
}
113114
if (typeof data.stac_version !== 'string') {
114-
console.error("-- " + id + ": Skipping; No STAC version found\n");
115+
console.error(`-- ${id}: Skipping; No STAC version found\n`);
115116
fileValid = false;
116117
continue;
117118
}
118119
else if (compareVersions(data.stac_version, '1.0.0-beta.2', '<')) {
119-
console.error("-- " + id + ": Skipping; Can only validate STAC version >= 1.0.0-beta.2\n");
120+
console.error(`-- ${id}: Skipping; Can only validate STAC version >= 1.0.0-beta.2\n`);
120121
continue;
121122
}
122123
else {
123-
console.log("-- " + id + " (" + data.stac_version + ")");
124+
console.log(`-- ${id} (${data.stac_version})`);
124125
}
125126

126127
let type;
@@ -130,17 +131,17 @@ async function run() {
130131
}
131132
else if (data.type === 'FeatureCollection') {
132133
// type = 'itemcollection';
133-
console.warn("-- " + id + ": Skipping; STAC ItemCollections not supported yet\n");
134+
console.warn(`-- ${id}: Skipping; STAC ItemCollections not supported yet\n`);
134135
continue;
135136
}
136137
else {
137-
console.error("-- " + id + ": `type` is invalid; must be `Feature`\n");
138+
console.error(`-- ${id}: 'type' is invalid; must be 'Feature'\n`);
138139
fileValid = false;
139140
continue;
140141
}
141142
}
142143
else {
143-
if (typeof data.extent !== 'undefined' || data.license !== 'undefined') {
144+
if (typeof data.extent !== 'undefined' || typeof data.license !== 'undefined') {
144145
type = 'collection';
145146

146147
}
@@ -161,7 +162,7 @@ async function run() {
161162
let validate = await loadSchema(...loadArgs);
162163
let valid = validate(data);
163164
if (!valid) {
164-
console.log('---- ' + schema + ": invalid");
165+
console.log(`---- ${schema}: invalid`);
165166
console.warn(validate.errors);
166167
console.log("\n");
167168
fileValid = false;
@@ -171,11 +172,11 @@ async function run() {
171172
}
172173
}
173174
else {
174-
console.info('---- ' + schema + ": valid");
175+
console.log(`---- ${schema}: valid`);
175176
}
176177
} catch (error) {
177178
fileValid = false;
178-
console.error('---- ' + schema + ": " + error.message);
179+
console.error(`---- ${schema}: ${error.message}`);
179180
if (DEBUG) {
180181
console.trace(error);
181182
}
@@ -202,7 +203,7 @@ function isUrl(uri) {
202203
let part = uri.match(/^(\w+):\/\//i);
203204
if(part) {
204205
if (!SUPPORTED_PROTOCOLS.includes(part[1].toLowerCase())) {
205-
throw new Error('Given protocol "' + part[1] + '" is not supported.');
206+
throw new Error(`Given protocol "${part[1]}" is not supported.`);
206207
}
207208
return true;
208209
}
@@ -213,7 +214,7 @@ async function readExamples(folder) {
213214
var files = [];
214215
for await (let file of klaw(folder)) {
215216
let relPath = path.relative(folder, file.path);
216-
if (relPath.includes(path.sep + 'examples' + path.sep) && path.extname(relPath) === '.json') {
217+
if (relPath.match(/(^|\/|\\)examples(\/|\\)[^\/\\]+\.json$/i)) {
217218
files.push(file.path);
218219
}
219220
}
@@ -224,7 +225,7 @@ async function loadSchema(baseUrl = null, version = null, shortcut = null) {
224225
version = (typeof version === 'string') ? "v" + version : "unversioned";
225226

226227
if (typeof baseUrl !== 'string') {
227-
baseUrl = "https://schemas.stacspec.org/" + version;
228+
baseUrl = `https://schemas.stacspec.org/${version}`;
228229
}
229230
else {
230231
baseUrl = baseUrl.replace(/\\/g, '/').replace(/\/$/, "");
@@ -233,14 +234,14 @@ async function loadSchema(baseUrl = null, version = null, shortcut = null) {
233234
let url;
234235
let isExtension = false;
235236
if (shortcut === 'item' || shortcut === 'catalog' || shortcut === 'collection') {
236-
url = baseUrl + "/" + shortcut + "-spec/json-schema/" + shortcut + ".json";
237+
url = `${baseUrl}/${shortcut}-spec/json-schema/${shortcut}.json`;
237238
}
238239
else if (typeof shortcut === 'string') {
239240
if (shortcut === 'proj') {
240241
// Capture a very common mistake and give a better explanation (see #4)
241242
throw new Error("'stac_extensions' must contain 'projection instead of 'proj'.");
242243
}
243-
url = baseUrl + "/extensions/" + shortcut + "/json-schema/schema.json";
244+
url = `${baseUrl}/extensions/${shortcut}/json-schema/schema.json`;
244245
isExtension = true;
245246
}
246247
else {
@@ -271,7 +272,7 @@ async function loadSchema(baseUrl = null, version = null, shortcut = null) {
271272
if (DEBUG) {
272273
console.trace(error);
273274
}
274-
throw new Error(`Schema at '${url}' not found. Please ensure all entries in 'stac_extensions' are valid. ${hint}`);
275+
throw new Error(`Schema at '${url}' not found. Please ensure all entries in 'stac_extensions' are valid.`);
275276
}
276277
else {
277278
throw error;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stac-node-validator",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "STAC Validator for NodeJS",
55
"author": "Matthias Mohr",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)