Skip to content

Commit

Permalink
Merge pull request #1 from ESA-EarthCODE/root-level-package
Browse files Browse the repository at this point in the history
Root level package
  • Loading branch information
silvester-pari authored Oct 1, 2024
2 parents b45553b + 3d8023c commit c62e0c3
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 76 deletions.
File renamed without changes.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
# open-science-catalog-validation
Validation for [open-science-catalog-metadata](https://github.com/ESA-EarthCODE/open-science-catalog-metadata)
Validation for [open-science-catalog-metadata](https://github.com/ESA-EarthCODE/open-science-catalog-metadata).

# Instructions

## How-to
To run validation do the following:

In order to run the valdation, run the folling steps:
```bash
npm install ESA-EarthCODE/open-science-catalog-validation
```

Then, inside a folder containing a STAC structure compatible with Open Science Catalog, run:

```bash
npm install
open-science-catalog-validation ./{eo-missions,products,projects,themes,variables}
```

Example for single file validation:

```bash
npx stac-node-validator --config config.json ../../metadata/{eo-missions,products,projects,themes,variables}
```
open-science-catalog-validation ./projects/3d-earth/collection.json
```

# How it works
This validation package is based on [stac-node-validator](https://github.com/stac-utils/stac-node-validator). Additional to generic validation following the [STAC spec](https://github.com/radiantearth/stac-spec) it does some custom validation (see [./validate.js](./validate.js)).

# Open Science Catalog STAC schema
Open Science Catalog requires a certain STAC structure for its entities (products, projects, variables etc.). The schema for these can be found in [./schemas](./schemas).

These schemas can also be used for e.g. automatically rendering an input form.

# Development
For development, copy some compatible folder structure into the root folder, then run `npm install` follwed by a `npm test`.

18 changes: 18 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node
const { resolve } = require("path");
const { exec } = require("child_process");

exec(
`npm explore open-science-catalog-validation -- npm run test -- ${process.argv
.slice(2)
.map((p) => resolve(p))
.join(" ")}`,
(error, stdout) => {
if (error) {
console.error("Validation failed!");
} else {
console.info("Validation successful!");
}
console.log(stdout);
},
);
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lint": false,
"custom": "./validate.js"
}
File renamed without changes.
11 changes: 7 additions & 4 deletions validation/package-lock.json → package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions validation/package.json → package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "validation",
"version": "1.0.0",
"name": "open-science-catalog-validation",
"version": "1.0.0-rc.1",
"description": "Validates the metadata",
"main": "validate.js",
"author": "EOX",
"license": "ISC",
"bin": "./bin/cli.js",
"dependencies": {
"fs-extra": "^11.1.1",
"image-size": "^1.0.2",
Expand All @@ -13,4 +14,4 @@
"scripts": {
"test": "stac-node-validator --config config.json"
}
}
}
10 changes: 0 additions & 10 deletions validation/validate.js → validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ const {
} = require('./definitions.js');

const BEFORE_BUILD = process.env.BUILD_STAGE !== 'after-build';
const GITHUB_SCHEMA_URI = process.env.GITHUB_SCHEMA_URI || "https://raw.githubusercontent.com/ESA-EarthCODE/open-science-catalog-metadata-validation/main";

if (!GITHUB_SCHEMA_URI) {
// GITHUB_SCHEMA_URI = "https://raw.githubusercontent.com/ESA-EarthCODE/open-science-catalog-metadata-validation/main/";
// throw new Error("GITHUB_SCHEMA_URI environment variable is not set");
}
else {
console.log(`Using schema URI: ${GITHUB_SCHEMA_URI}`);
}

class CustomValidator extends BaseValidator {

constructor() {
Expand Down
33 changes: 0 additions & 33 deletions validation/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions validation/config.json

This file was deleted.

0 comments on commit c62e0c3

Please sign in to comment.