Synchronize Specification File Changes With Generated Source Code
You can use the ochain sync command to bring
new changes from the specification file to the current source files (model and controller).
The command works with both TypeScript and Go projects.
- Synchronization is unidirectional: you can bring changes from your specification file into your chaincode project, but not the other way around. Changes made in your chaincode project remain as-is after the synchronizing process.
- The
ochain synccommand works only if the chaincode project was scaffolded by using a specification file. Do not delete, rename or move the specification file if you plan to synchronize any changes from the specification file to the source code in the future. - If you used a single specification file to generate more than one chaincode
project, you can synchronize only one project at a time by using the
ochain synccommand.
Usage:
sync [options] [...args]my-mac:TsProject myname@ ochain sync -h
Usage: sync [options] [...args]
Synchronize Changes from spec file to the required chaincode.
Arguments:
[...args] (optional) Sync Arguments.
Options :
-h, --help output command usage information
-D, --debug enable debug logging
-p, --project <path> (optional) Path to Chaincode project to sync. If not specified, it defaults to current directory
-c, --confirm <bool> (optional) Parameter to ensure if you have resolved all the conflicts, and commit changes
Examples :
$> ochain sync
without chaincode initial argumentsochain sync command has two optional
arguments:
-p / --projectThis option takes the chaincode project directory where the synchronization needs to be performed. If not specified, it defaults to the current directory.
-c / --confirmThis option takes Boolean (true/false) values. If there are any conflicts during the merging process, you must resolve those conflicts manually and set this option to true in the next synchronization cycle. Don't use this option if you're not sure that the conflicts have been merged.
ochain sync command fails and you have installed and configured
all prerequisites including Git and the Git username and password, complete the
following steps to reinitialize the synchronization operation:
- Check the specification file for errors and fix any errors that you find.
- In the chaincode project folder, remove the following folders if they are
present:
.sync_temp,.sync_backup, and.sync_repo. - In the
srcfolder, remove the.gitfolder if it is present. - In the project root folder, edit the
ochain.jsonfile and set thesyncEnabledproperty to false. Save and close the file. - Retry the
ochain synccommand.