Skip to content

Commit

Permalink
Update README.md + remove unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ddvlanck committed Mar 13, 2024
1 parent e7824dc commit 04a8115
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 54 deletions.
28 changes: 23 additions & 5 deletions packages/oslo-generator-json-webuniversum/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# `oslo-generator-json-webuniversum`
# `oslo-generator-json-webuniversum` `OSLO JSON Webuniversum Generator

> TODO: description
> This package transforms an OSLO JSON-LD file into a JSON configuration file which will be used by the Nuxt.JS Service to render vocabularies and application profiles
## Usage
## Install

```bash
npm install @oslo-flanders/json-webuniversum-generator
```
const osloGeneratorJsonWebuniversum = require('oslo-generator-json-webuniversum');

// TODO: DEMONSTRATE API
## Global install

```bash
npm install -g @oslo-flanders/json-webuniversum-generator
```

## API

The service is executed from the CLI and expects the following parameters:
| Parameter | Description | Required | Possible values |
| ---------- | ----------------------------------------------------------- | --------------------------------- | --------------- |
| `--input` | The URL or local file path of an OSLO stakeholders csv file |:heavy_check_mark: | |
| `--output` | Name of the output file | No, default `webuniversum-config.json` | |
| `--language` | The language in which the config must be generated | :heavy_check_mark: | |

## Usage
```bash
oslo-webuniversum-json-generator --input report.jsonld --language nl
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export class JsonWebuniversumGenerationServiceRunner
.option('input', { describe: 'The input file to generate a JSON-LD context from.' })
.option('output', { describe: 'Name of the output file.', default: 'webuniversum-config.json' })
.option('language', { describe: 'The language in which the config must be generated.' })
.option('apTemplateMetadata', { describe: 'Markdown file with metadata for the AP template.' })
.option('vocTemplateMetadata', { describe: 'Markdown file with metadata for the VOC template.' })
.option('silent',
{
describe: 'All logs are suppressed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,10 @@ export class JsonWebuniversumGenerationServiceConfiguration implements IConfigur
*/
private _language: string | undefined;

/**
* Local path to a markdown file with metadata for the AP template
*/
private _apTemplateMetadata: string | undefined;

/**
* Local path to a markdown file with metadata for the VOC template
*/
private _vocTemplateMetadata: string | undefined;

public async createFromCli(params: YargsParams): Promise<void> {
this._input = <string>params.input;
this._output = <string>params.output;
this._language = <string>params.language;
this._apTemplateMetadata = <string>params.apTemplateMetadata;
this._vocTemplateMetadata = <string>params.vocTemplateMetadata;
}

public get input(): string {
Expand All @@ -56,18 +44,4 @@ export class JsonWebuniversumGenerationServiceConfiguration implements IConfigur
}
return this._language;
}

public get apTemplateMetadata(): string {
if (!this._apTemplateMetadata) {
throw new Error('Trying to access "apTemplateMetadata" before it was set.')
}
return this._apTemplateMetadata;
}

public get vocTemplateMetadata(): string {
if (!this._vocTemplateMetadata) {
throw new Error('Trying to access "vocTemplateMetadata" before it was set.')
}
return this._vocTemplateMetadata;
}
}
3 changes: 3 additions & 0 deletions packages/oslo-generator-json-webuniversum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"@oslo-generator-json-webuniversum": "./lib",
"@oslo-core": "node_modules/@oslo-flanders/core/lib"
},
"bin": {
"oslo-webuniversum-json-generator": "bin/runner.js"
},
"directories": {
"bin": "bin",
"lib": "lib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ describe('JsonWebuniversumGenerationServiceConfiguration', () => {
expect((<any>config)._input).toBeDefined();
expect((<any>config)._output).toBeDefined();
expect((<any>config)._language).toBeDefined();
expect((<any>config)._apTemplateMetadata).toBeDefined();
expect((<any>config)._vocTemplateMetadata).toBeDefined();
});

it('should throw an error when "input" is undefined or otherwise return its value', async () => {
Expand All @@ -52,23 +50,4 @@ describe('JsonWebuniversumGenerationServiceConfiguration', () => {
await config.createFromCli(params);
expect(config.language).toBe('en');
});

it('should throw an error when "apTemplateMetadata" is undefined or otherwise return its value', async () => {
const config = new JsonWebuniversumGenerationServiceConfiguration();

expect(() => config.apTemplateMetadata)
.toThrow(new Error('Trying to access "apTemplateMetadata" before it was set.'));
await config.createFromCli(params);
expect(config.apTemplateMetadata).toBe('ap-markdown.md');
});

it('should throw an error when "vocTemplateMetadata" is undefined or otherwise return its value', async () => {
const config = new JsonWebuniversumGenerationServiceConfiguration();

expect(() => config.vocTemplateMetadata)
.toThrow(new Error('Trying to access "vocTemplateMetadata" before it was set.'));
await config.createFromCli(params);
expect(config.vocTemplateMetadata).toBe('voc-markdown.md');
});

})

0 comments on commit 04a8115

Please sign in to comment.