Skip to content

Commit

Permalink
feat(generate): add option to disable output validation (#53)
Browse files Browse the repository at this point in the history
* feat(generate): add option to disable output validation

Signed-off-by: Dan Selman <[email protected]>

* chore(lint) fix linting issues

Signed-off-by: Dan Selman <[email protected]>

---------

Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored Jul 23, 2024
1 parent 00fc809 commit 8796a1c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
mocha: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 8
ecmaVersion: 2020
sourceType: 'script'
rules:
indent:
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,17 @@ require('yargs')
type: 'boolean',
default: false,
});
yargs.option('disableValidation', {
describe: 'Do not validate generated output',
type: 'boolean',
default: false
});
}, argv => {
return Commands.generate(argv.model, argv.concept, argv.mode, {
optionalFields: argv.includeOptionalFields,
metamodel: argv.metamodel,
strict: argv.strict,
disableValidation: argv.disableValidation
})
.then(obj => {
console.log(JSON.stringify(obj, null, 2));

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (18.x, ubuntu-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (18.x, macOS-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (16.x, ubuntu-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (16.x, macOS-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (18.x, windows-latest)

Unexpected console statement

Check warning on line 411 in index.js

View workflow job for this annotation

GitHub Actions / Unit Tests (16.x, windows-latest)

Unexpected console statement
Expand Down
3 changes: 2 additions & 1 deletion lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class Commands {
* @param {string} [options.optionalFields] if true, optional fields will be included in the output
* @param {boolean} [options.strict] - require versioned namespaces and imports
* @param {boolean} [options.metamodel] - include the Concerto Metamodel
* @param {boolean} [options.disableValidation] - do not validate the generated output
*/
static async generate(ctoFiles, concept, mode, options) {
const modelManagerOptions = { offline: options && options.offline, strict: options && options.strict };
Expand Down Expand Up @@ -342,7 +343,7 @@ class Commands {
);
const serializer = new Serializer(factory, modelManager);

return Promise.resolve(serializer.toJSON(resource));
return Promise.resolve(serializer.toJSON(resource, {validate: !options?.disableValidation}));
}

/**
Expand Down

0 comments on commit 8796a1c

Please sign in to comment.