Skip to content

Commit

Permalink
Merge branch 'main' into 40-metadata-to-json-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
darnjo authored Sep 12, 2023
2 parents 9004bc2 + a2f57ca commit ff86e19
Show file tree
Hide file tree
Showing 13 changed files with 1,570 additions and 1,311 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/codecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ jobs:
run: npm install -g eslint
- name: Install and run ESLint
run: eslint . --quiet
- name: Run Mocha Tests
run: npm install && npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ dist

config.json
output
errors
errors
.DS_Store
4 changes: 2 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"bracketSameLine": true,
"endOfLine": "lf",
"useTabs": false,
"printWidth": 110,
"printWidth": 140,
"proseWrap": "preserve"
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Restores a RESO Certification API Server using a set of existing results in a gi

[**MORE INFO**](./lib/restore-utils/README.md)

## Find Variations
Uses a number of techniques to find potential variations for local items contained in a Data Dictionary metadata report.

[**MORE INFO**](./utils/find-variations/README.md)


## Tests

To run the tests, clone the repository:
Expand Down
155 changes: 110 additions & 45 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,111 @@
#! /usr/bin/env node
const { program } = require('commander');
const { restore } = require('./lib/restore-utils');
const { runTests } = require('./lib/batch-test-runner');
const { schema } = require('./lib/schema');

program
.name('reso-certification-utils')
.description('Command line batch-testing and restore utils')
.version('0.0.2');

program
.command('restore')
.option('-p, --pathToResults <string>', 'Path to test results')
.option('-u, --url <string>', 'URL of Certification API')
.description('Restores local or S3 results to a RESO Certification API instance')
.action(restore);

program
.command('runDDTests')
.requiredOption('-p, --pathToConfigFile <string>', 'Path to config file')
.option(
'-a, --runAvailability',
'Flag to run data availability tests, otherwise only metadata tests are run'
)
.description('Runs Data Dictionary tests')
.action(runTests);

program
.command('schema')
.option('-g, --generate', 'Generate JSON schema from a metadata report')
.option('-v, --validate', 'Validate a payload against a generated schema')
.option('-m, --metadataPath <string>', 'Path to the metadata report JSON file')
.option('-o, --outputPath <string>', 'Path tho the directory to store the generated schema')
.option('-p, --payloadPath <string>', 'Path to the payload that needs to be validated')
.option('-s, --schemaPath <string>', 'Path to the generated JSON schema')
.option(
'-e, --errorPath <string>',
'Path to save error reports in case of failed validation. Defaults to "./errors"'
)
.option('-a, --additionalProperties', 'Pass this flag to allow additional properties in the schema')
.option('-z, --zipFilePath <string>', 'Path to a zip file containing JSON payloads')
.description('Generate a schema or validate a payload against a schema')
.action(schema);

program.parse();

const { program } = require("commander");
const { schema } = require("./lib/schema");
const { restore } = require("./lib/restore-utils");
const { runTests } = require("./lib/batch-test-runner");
const {
findVariations,
computeVariations,
} = require("./lib/find-variations/index.js");

if (require?.main === module) {
const { program } = require("commander");

program
.name("reso-certification-utils")
.description("Command line batch-testing and restore utils")
.version("0.0.3");

program
.command("runDDTests")
.requiredOption("-p, --pathToConfigFile <string>", "Path to config file")
.option(
"-a, --runAvailability",
"Flag to run data availability tests, otherwise only metadata tests are run"
)
.description("Runs Data Dictionary tests")
.action(runTests);

program
.command("schema")
.option("-g, --generate", "Generate JSON schema from a metadata report")
.option("-v, --validate", "Validate a payload against a generated schema")
.option(
"-m, --metadataPath <string>",
"Path to the metadata report JSON file"
)
.option(
"-o, --outputPath <string>",
"Path tho the directory to store the generated schema"
)
.option(
"-p, --payloadPath <string>",
"Path to the payload that needs to be validated"
)
.option("-s, --schemaPath <string>", "Path to the generated JSON schema")
.option(
"-e, --errorPath <string>",
'Path to save error reports in case of failed validation. Defaults to "./errors"'
)
.option(
"-a, --additionalProperties",
"Pass this flag to allow additional properties in the schema"
)
.option(
"-z, --zipFilePath <string>",
"Path to a zip file containing JSON payloads"
)
.description("Generate a schema or validate a payload against a schema")
.action(schema);

program
.command("restore")
.option("-p, --pathToResults <string>", "Path to test results")
.option("-u, --url <string>", "URL of Certification API")
.option("-c, --console <boolean>", "Show output to console", true)
.description(
"Restores local or S3 results to a RESO Certification API instance"
)
.action(restore);

program
.command("runDDTests")
.requiredOption("-p, --pathToConfigFile <string>", "Path to config file")
.option(
"-a, --runAvailability",
"Flag to run data availability tests, otherwise only metadata tests are run"
)
.option("-c, --console <boolean>", "Show output to console", true)
.description("Runs Data Dictionary tests")
.action(runTests);

program
.command("findVariations")
.requiredOption(
"-p, --pathToMetadataReportJson <string>",
"Path to metadata-report.json file"
)
.option(
"-f, --fuzziness <float>",
"Set fuzziness to something besides the default"
)
.option(
"-v, --version <string>",
"Data Dictionary version to compare to, i.e. 1.7 or 2.0"
)
.option("-c, --console <boolean>", "Show output to console", true)
.description(
"Finds possible variations in metadata using a number of methods."
)
.action(findVariations);

program.parse();
}

module.exports = {
restore,
runTests,
findVariations,
computeVariations,
};
11 changes: 11 additions & 0 deletions lib/find-variations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Find Variations
This tool uses a number of techniques to find variations between Data Dictionary metadata and the given file.

To use, a Metadata Report is required.

Usage:

```
reso-certification-utils findVariations -p /path/to/metadata-report.json
```

Loading

0 comments on commit ff86e19

Please sign in to comment.