How to use yamlexchange
Overview
yamlexchange is a command-line tool in the YamlExchange package. It allows you to export and import models from the command line without launching Next Design.
It can be used for batch processing in scripts and for checking the consistency between Git-managed projects and YAML files (Git consistency check) (Use cases).
yamlexchange is included in the YamlExchange package, so there is no need to install it separately (location of yamlexchange).
If you are using the same version of yamlexchange as the extension, the conversion results will be the same whether you run it from the screen or from yamlexchange, except when using yamlexchange-only options (such as --out).
Prerequisites
Next Design license registration is required for the yamlexchange execution environment.
Location of yamlexchange
The executable file for yamlexchange is yamlexchange.exe.
If you have installed the YamlExchange package in Next Design, it will be located in the following folder ({version} is the package version):
%LOCALAPPDATA%\DENSO CREATE\Next Design\installed-packages\YamlExchange.{version}\extensions\5.1\Tools
If necessary, add the folder containing yamlexchange.exe to the PATH environment variable. If not added, run it using the full path.
Run the following command; if the version is displayed, the installation is complete.
yamlexchange --version
- The path of the executable file will change when the YamlExchange package is updated. Please update the path after updating the package.
- If you have set up a Git hook, please also update the path included in that setting.
Usage by Purpose
This shows the main uses of yamlexchange, categorized by purpose. For details on the options for each command, please refer to the Command List.
Updating the Yaml folder in the same location as the screen
Exporting without --out behaves the same as exporting from the screen. It exports to the Yaml folder in the same folder as the project file, with the same layout as the screen.
Use this when you want to update the Yaml folder in the same location as the screen from a script or Git hook.
> yamlexchange export --project ADAS.nproj --model "Software Requirements Development/Software Requirements/ADAS ECU"
If the specified model is not subject to file splitting, the specification will be added to the configuration file, just like on the screen (File Splitting (YAML Exchange Settings) > Specifications Added to Settings).
Processing in Batch
When exporting multiple models in a batch, specify --model repeatedly. If both parent and child models are specified, the descendant model will be included in the parent model's file and will not be exported individually.
> yamlexchange export --project ADAS.nproj --model "Software Requirements Development/Software Requirements/ADAS ECU" --model "Software Requirements Development/Software Requirements/Meter ECU"
When incorporating this into a script, please note the following:
-
Success or failure is determined by the exit code (Exit Codes). If you want to determine success or failure based on the warning content, use the execution report (Execution Report).
-
Do not perform simultaneous exports to the same destination. Do not overlap with screen exports or
git checkout/git pull. Overlapping may cause the file exported by one to be deleted as the previously exported file. If it fails midway, run the same command again.
Handing over the exported set to other people/tools
Specifying --out exports to the specified folder. It does not add any settings to the configuration file, nor does it overwrite the source files.
> yamlexchange export --project ADAS.nproj --all --out out/
-
The main file alone cannot be imported. Please provide the entire export destination folder, including the main file, the destination folder, and the
contentsfolder. -
yamlexchange does not support zip input/output. If you want to combine files into a single file, compress the export destination folder using Explorer's [Compress] function, etc.
-
For Git management or AI editing, please use uncompressed files.
Importing Received YAML
This is the procedure for importing YAML received from other people or tools.
> yamlexchange validate --in incoming.yaml --metamodel nd.metamodel.yaml
> yamlexchange import --project ADAS.nproj --in incoming.yaml --dry-run --report dry.json
> yamlexchange import --project ADAS.nproj --in incoming.yaml --write-back
-
Use
validateto check for errors in the YAML syntax (yamlexchange validate). -
Run with
--dry-runto check the number and details of changes. The project will not be saved. -
After reviewing the contents, remove
--dry-runand import. Adding--write-backwill write the newly created model'sidback to the YAML (yamlexchange import).
Synchronizing with Git
When managing Next Design projects and YAML files with Git, run yamlexchange using a Git hook before pushing to check if both are correct. If only one has changed, the hook will correct the other. See Integrity Check with Git for instructions and hook configuration.
Command Syntax
The yamlexchange syntax consists of a command and options.
yamlexchange <command> [<--option> [params]]
yamlexchange <--option>
Example (if project name is ADAS):
> yamlexchange export --project ADAS.nproj --all --out out/
> yamlexchange import --project ADAS.nproj --in out/ADAS.yaml --dry-run
> yamlexchange --version
-
Command
Specifies the process to execute. See Command List for a list of available commands. -
Options
Options can be specified for the command. Some options take arguments.
For example, when executing yamlexchange export --project ADAS.nproj --all, the --project option and its argument ADAS.nproj, and the --all option are passed to the export command.
When specifying a model with the --model or --parent options, write one of the following:
- The value exported to the
idfield in the YAML (short ID) - The full GUID
- The model path (the model name connected to the design model root with
/) Example:Software Requirements Development/Software Requirements
License
A Next Design license is required to run yamlexchange. The Windows user running yamlexchange must have registered a Next Design license.
yamlexchange does not have a function to register licenses; licenses are registered in Next Design.
If the license is not authenticated, the project cannot be opened and the program will exit with exit code (2). The validate command and --version command, which do not open a project, can be run without a license.
Exit Codes
Each command returns the following exit code depending on the execution result:
| Exit Code | export/import/validate/metamodel | diff |
|---|---|---|
| 0 | Success | No difference |
| 1 | Success with warnings | Differences found |
| 2 | Error | Error |
- The
metamodelcommand does not return (1). - The
diffcommand does not include warnings in its exit code, even if present. - Exit code (1) includes both cases where the execution ended with warnings that do not require action and cases where the references could not be resolved and data was missing. See Execution Report for distinction.
Execution Report
Specifying the --report <path> option for each command writes the execution results to a JSON file.
The number of items processed, a list of warnings and errors, and the id (short ID) of newly created models are recorded.
> yamlexchange import --project ADAS.nproj --in incoming.yaml --dry-run --report dry.json
Even if there are argument errors or the project cannot be opened, an execution report will be written if --report is specified. Determine success or failure first by the exit code.
If the execution report file cannot be written, even if the process itself (including saving and writing back the id) was successful, it will terminate with exit code (2), and the previous execution report will remain. When --report is specified, do not assume "nothing has changed" based solely on exit code (2); check the console messages.
Common Problems and Solutions
The following are problems and solutions specific to yamlexchange. For issues common to the screen, please refer to Common Issues and Solutions.
| Symptom | Cause | Solution |
|---|---|---|
| If you import the same file twice, the model will be duplicated | Models added without writing id will be newly created each time you import. | Importing with --write-back will write the id of the new model back to the YAML (yamlexchange import). |
| References remain in Next Design even though all references were deleted | When deleting the last item, the field name line (e.g., Functions:) was also deleted. Default import does not change fields that are not in the YAML. | Leave the field name line and set the value to [], or import with --complete. Do not use --complete for files where AI has only written part of it. All references that were not written will be removed. |
| Child elements that were removed from the YAML will not be deleted | Imports without --prune will not delete the model. | Import with --prune (Delete). |
If you revert only the project after importing with --write-back, it will be interrupted because there is no model corresponding to id | The model for the written-back id is not in the reverted project. | Revert the YAML file as well, delete the line for the written-back id, or change it back to a value starting with new-. |
| If you change the project name (if the name of the main file changes), the old YAML will remain | If the name of the main file itself changes, you cannot delete the previously exported file. | Export with --all and --clean. --clean will empty the Yaml folder, so any edits to YAML files that haven't been imported yet will be lost (yamlexchange export). |