A simple tool to sync the proto files from a remote repository to a local directory.
go install github.com/catalystgo/protosync@latestdocker pull catalystgo/protosync:latest| Command | Description | 
|---|---|
init | 
Initialize the configuration file | 
vendor | 
Sync the proto files from the remote repositories to the local directory | 
version | 
Print the version of the tool | 
validate | 
Validate the existing configuration file | 
help | 
Print the help message | 
| Option | Short | Description | 
|---|---|---|
--file | 
-f | 
Path to the configuration file | 
--verbose | 
-v | 
Enable verbose mode for debugging | 
Here is a sample configuration file
# The directory where the proto files will be saved
directory: "vendor.proto"
# The list of proto files that need to be synced
dependencies:
  # `source` URL of the proto file with the commit hash
  # Must be in the following format: `domain/user/repo/path/to/file@commit`
  - source: github.com/catalystgo/protosync/example/proto/echo.proto@54fc94f
  # `Path` path to download the proto file to (this path is appended to the directory variable)
  # Example:
  # - path: "proto/"
  # - directory: "vendor.proto"
  # The file will be saved in the `vendor.proto/proto/` directory
  # If not provided then the file will be saved in the `vendor.proto/{{SOURCE}}` directory
  # Example:
  # - path: "" (or not provided)
  # - directory: "vendor.proto"
  # - source: github.com/catalystgo/protosync/example/proto/echo.proto@54fc94f
  # The file will be saved in the `vendor.proto/github.com/catalystgo/protosync/example/proto/` directory
  - path: "proto/"
    source: github.com/catalystgo/protosync/example/proto/echo.proto@54fc94f
  - path: "proto/"
    # You can also provide multiple sources to be downloaded in the same path.
    # NOTICE: You can't use `source` & `sources` together.
    sources:
      - github.com/catalystgo/protosync/example/proto/echo.proto@54fc94f
      - github.com/catalystgo/protosync/example/proto/echo.proto@54fc94f
  # Example for GitLab company repository
  - source: gitlab.company.com/user/repo/path/to/file/echo.proto@abc123
# The list of domains that need to be replaced with the API URL
domains:
  - name: gitlab.company.com # The domain name of your company
    api: gitlab.com # The API URL (available values are `github.com`, `gitlab.com` and `bitbucket.org`)Print the version of the tool
protosync versionInitialize the configuration file
protosync initValidate the existing configuration file
protosync validateprotosync validate -f ./protosync.yml protosync validate --file ./protosync.yml protosync validate --file ./protosync.jsonSync the proto files from the remote repositories to the local directory
protosync vendorprotosync vendor -f ./protosync.ymlprotosync vendor --file ./protosync.ymlprotosync vendor --file ./protosync.yml --output /tmpSync the proto files from the remote repositories to the local directory and save the files in the output directory
So if the protosync.yml file has the following ourDir: vendor.proto and the output directory is /tmp then the files will be saved in /tmp/vendor.proto/...
If output directory is not provided then the files will be saved in the current directory under the vendor.proto directory (ourDir from config).
protosync vendor --file ./protosync.yml --output /tmpUsing Docker
docker run -v $(pwd):/app catalystgo/protosync:latest vendor --file /app/protosync.yml --output /app- Add method/way to use auth tokens for private repositories
 - If the URL redirects to another NON-proto file then the tool shouldn't download the file