ruleset-development-cli
The ruleset-development-cli provides tooling to write, test and debug AMF Governance Rulesets that can then be applied over
RAML, OAS, GraphQL, gRPC or abitrary JSON-LD documents using the AMF Custom Validator[https://github.com/aml-org/amf-custom-validator/]
or any Open Policy Agent (OPA) compatible runtime.
You can find a complete explanation and tutorial about how to write rules here.
You can also open the tutorial just using the following CLI command:
$ ruleset-development-cli tutorial
Development flow
- Create a new ruleset project using the
ruleset-development-cli [ruleset-name]
from the directory for the ruleset - Create a new rule to the project with description and the right severity level using the
ruleset-development-cli new rule [rule-name]
command - Add positive and negative examples in the target specification languages using the
ruleset-development-cli new example [rule-name] [example-id]
command - Inspect the JSON-LD model of the examples if required to understand how to write the rule using the
ruleset-development-cli model dump
command - Check all the positive and negative examples for the ruleset using the
ruleset-development-cli test
command - If you need to debug the OPA Rego code generated for the rule use the
ruleset-development-cli test
command with the --debug
flag to find the rego code for the rulest and the input JSON for the validator for every example - When ready to publish use the
ruleset-development-cli clean
command to remove debug files and then use the ruleset-development-cli build
command to generate the consolidated ruleset YAML file with all the rules
Usage
$ npm install -g @aml-org/ruleset-development-cli
$ ruleset-development-cli COMMAND
running command...
$ ruleset-development-cli (--version)
@aml-org/ruleset-development-cli/1.0.0-beta linux-x64 node-v18.18.2
$ ruleset-development-cli --help [COMMAND]
USAGE
$ ruleset-development-cli COMMAND
...
Commands
ruleset-development-cli build
generates a consolidated ruleset file with all the rules
USAGE
$ ruleset-development-cli build [-l <value>]
FLAGS
-l, --location=<value> path where the project will be created
DESCRIPTION
generates a consolidated ruleset file with all the rules
EXAMPLES
$ ruleset-development-cli build
$ ruleset-development-cli build -l /development/my-ruleset-project
See code: src/commands/build.ts
ruleset-development-cli clean
cleans debug and model data
USAGE
$ ruleset-development-cli clean [-l <value>]
FLAGS
-l, --location=<value> path where the project will be created
DESCRIPTION
cleans debug and model data
EXAMPLES
$ ruleset-development-cli clean
$ ruleset-development-cli clean -l /development/my-ruleset-project
See code: src/commands/clean.ts
ruleset-development-cli help [COMMANDS]
Display help for ruleset-development-cli.
USAGE
$ ruleset-development-cli help [COMMANDS] [-n]
ARGUMENTS
COMMANDS Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for ruleset-development-cli.
See code: @oclif/plugin-help
ruleset-development-cli import
USAGE
$ ruleset-development-cli import [-l <value>] [-p <value>] [--omitExamples]
FLAGS
-l, --location=<value> path where the project will be created
-p, --targetLocation=<value> path where the ruleset should be imported as a project
--omitExamples omit scaffolding positive and negative examples for each rule
See code: src/commands/import.ts
ruleset-development-cli lint
Validates the rules syntax without testing any examples
USAGE
$ ruleset-development-cli lint [-l <value>]
FLAGS
-l, --location=<value> path where the project will be created
DESCRIPTION
Validates the rules syntax without testing any examples
EXAMPLES
$ ruleset-development-cli lint
$ ruleset-development-cli lint -l /development/my-ruleset-project
See code: src/commands/lint.ts
ruleset-development-cli model dump [RULENAME] [ID]
serializes the JSON-LD model for an example
USAGE
$ ruleset-development-cli model dump [RULENAME] [ID] [-l <value>] [-f <value>]
ARGUMENTS
RULENAME name of the rule where the example will be added
ID id of the example
FLAGS
-f, --filter=<value> regex used to filter the examples that are going to be validated
-l, --location=<value> path where the project will be created
DESCRIPTION
serializes the JSON-LD model for an example
EXAMPLES
$ ruleset-development-cli model dump my-rule-1 example1negative
See code: src/commands/model/dump.ts
ruleset-development-cli model inspect RULENAME ID
describe the command here
USAGE
$ ruleset-development-cli model inspect RULENAME ID [-l <value>]
ARGUMENTS
RULENAME name of the rule where the example will be added
ID id of the example
FLAGS
-l, --location=<value> path where the project will be created
DESCRIPTION
describe the command here
EXAMPLES
$ ruleset-development-cli model inspect my-rule1 example1negative
$ ruleset-development-cli model inspect -f positive.*
See code: src/commands/model/inspect.ts
ruleset-development-cli new NAME
Generates a new ruleset project
USAGE
$ ruleset-development-cli new NAME [-l <value>] [-s
oas|swagger|raml|asyncapi|graphql|grpc|jsonld|gcl|project] [-n <value>]
ARGUMENTS
NAME name of the ruleset
FLAGS
-l, --location=<value> path where the project will be created
-n, --ruleFileName=<value> name of the profile file in each rule
-s, --defaultSpec=<option> default spec for examples at new rules creation
<options: oas|swagger|raml|asyncapi|graphql|grpc|jsonld|gcl|project>
DESCRIPTION
Generates a new ruleset project
EXAMPLES
$ ruleset-development-cli new
$ ruleset-development-cli new -l /development/my-ruleset-project
$ ruleset-development-cli new -l /development/my-ruleset-project -s oas
See code: src/commands/new/index.ts
ruleset-development-cli new example RULENAME ID
generates a new example for a rule
USAGE
$ ruleset-development-cli new example RULENAME ID [-f <value>] [-l <value>] [-o <value>]
ARGUMENTS
RULENAME name of the rule where the example will be added
ID id of the example
FLAGS
-f, --format=<value> [default: oas] spec format for the example (oas, swagger, raml, asyncapi, graphql, grpc, gcl,
project)
-l, --location=<value> [default: .] path where the project has been created
-o, --only=<value> generate only positive|negative example
DESCRIPTION
generates a new example for a rule
EXAMPLES
$ ruleset-development-cli new example mandatory-tags ex1
$ ruleset-development-cli new example mandatory-tags ex1 -f grpc
$ ruleset-development-cli new example mandatory-tags ex1 -f graphql --only positive
See code: src/commands/new/example.ts
ruleset-development-cli new rule NAME
creates a new rule for the ruleset
USAGE
$ ruleset-development-cli new rule NAME [-s warning|violation|info] [-m <value>] [-l <value>]
ARGUMENTS
NAME name of the rule
FLAGS
-l, --location=<value> path where the project will be created
-m, --message=<value> error message for the rule
-s, --severity=<option> severity level for the rule
<options: warning|violation|info>
DESCRIPTION
creates a new rule for the ruleset
EXAMPLES
$ ruleset-development-cli new rule mandatory-tags
$ ruleset-development-cli new rule mandatory-tags -s warning -m "tags are mandatory"
$ ruleset-development-cli new rule mandatory-tags -l /development/my-ruleset-project
See code: src/commands/new/rule.ts
ruleset-development-cli plugins
List installed plugins.
USAGE
$ ruleset-development-cli plugins [--core]
FLAGS
--core Show core plugins.
DESCRIPTION
List installed plugins.
EXAMPLES
$ ruleset-development-cli plugins
See code: @oclif/plugin-plugins
ruleset-development-cli plugins:install PLUGIN...
Installs a plugin into the CLI.
USAGE
$ ruleset-development-cli plugins:install PLUGIN...
ARGUMENTS
PLUGIN Plugin to install.
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Installs a plugin into the CLI.
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ ruleset-development-cli plugins add
EXAMPLES
$ ruleset-development-cli plugins:install myplugin
$ ruleset-development-cli plugins:install https://github.com/someuser/someplugin
$ ruleset-development-cli plugins:install someuser/someplugin
ruleset-development-cli plugins:inspect PLUGIN...
Displays installation properties of a plugin.
USAGE
$ ruleset-development-cli plugins:inspect PLUGIN...
ARGUMENTS
PLUGIN [default: .] Plugin to inspect.
FLAGS
-h, --help Show CLI help.
-v, --verbose
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Displays installation properties of a plugin.
EXAMPLES
$ ruleset-development-cli plugins:inspect myplugin
See code: @oclif/plugin-plugins
ruleset-development-cli plugins:install PLUGIN...
Installs a plugin into the CLI.
USAGE
$ ruleset-development-cli plugins:install PLUGIN...
ARGUMENTS
PLUGIN Plugin to install.
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Installs a plugin into the CLI.
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ ruleset-development-cli plugins add
EXAMPLES
$ ruleset-development-cli plugins:install myplugin
$ ruleset-development-cli plugins:install https://github.com/someuser/someplugin
$ ruleset-development-cli plugins:install someuser/someplugin
See code: @oclif/plugin-plugins
ruleset-development-cli plugins:link PLUGIN
Links a plugin into the CLI for development.
USAGE
$ ruleset-development-cli plugins:link PLUGIN
ARGUMENTS
PATH [default: .] path to plugin
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Links a plugin into the CLI for development.
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLES
$ ruleset-development-cli plugins:link myplugin
See code: @oclif/plugin-plugins
ruleset-development-cli plugins:uninstall PLUGIN...
Removes a plugin from the CLI.
USAGE
$ ruleset-development-cli plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ ruleset-development-cli plugins unlink
$ ruleset-development-cli plugins remove
ruleset-development-cli plugins:uninstall PLUGIN...
Removes a plugin from the CLI.
USAGE
$ ruleset-development-cli plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ ruleset-development-cli plugins unlink
$ ruleset-development-cli plugins remove
See code: @oclif/plugin-plugins
ruleset-development-cli plugins:uninstall PLUGIN...
Removes a plugin from the CLI.
USAGE
$ ruleset-development-cli plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ ruleset-development-cli plugins unlink
$ ruleset-development-cli plugins remove
ruleset-development-cli plugins update
Update installed plugins.
USAGE
$ ruleset-development-cli plugins update [-h] [-v]
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Update installed plugins.
See code: @oclif/plugin-plugins
ruleset-development-cli test
Lints the rules syntax and test all the rule examples
USAGE
$ ruleset-development-cli test [-l <value>] [-f <value>] [-d] [-s]
FLAGS
-d, --debug generates debug output for the example being tested
-f, --filter=<value> regex used to filter the examples that are going to be validated
-l, --location=<value> path where the project will be created
-s, --skipLinting does not lint the rulesets before running the tests
DESCRIPTION
Lints the rules syntax and test all the rule examples
EXAMPLES
$ ruleset-development-cli test
$ ruleset-development-cli test -f positive.*
$ ruleset-development-cli test -f rule-34 --debug
$ ruleset-development-cli test --debug
$ ruleset-development-cli test --skipLinting
$ ruleset-development-cli test -l /development/my-ruleset-project
See code: src/commands/test.ts
ruleset-development-cli trace RULENAME ID
describe the command here
USAGE
$ ruleset-development-cli trace RULENAME ID [-l <value>] [-a] [-n]
ARGUMENTS
RULENAME name of the rule where the example will be added
ID id of the example
FLAGS
-a, --aggregate aggregate failures from multiple proofs for the same node
-l, --location=<value> path where the project will be created
-n, --negate checks the negation of the rule, useful to check rules that should not conform
DESCRIPTION
describe the command here
EXAMPLES
$ ruleset-development-cli trace mandatory-tags negative1
$ ruleset-development-cli trace mandatory-tags negative1 --agregate
$ ruleset-development-cli trace mandatory-tags negative1 --negate
See code: src/commands/trace.ts
ruleset-development-cli tutorial
Opens the AMF Ruleset Tutorial in the default system browser
USAGE
$ ruleset-development-cli tutorial
DESCRIPTION
Opens the AMF Ruleset Tutorial in the default system browser
EXAMPLES
$ ruleset-development-cli tutorial
See code: src/commands/tutorial.ts