Skip to content

Commit

Permalink
docs: TECH adjust readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kirpichenko committed Aug 10, 2023
1 parent b32914f commit 9b92372
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@ Generates `ts` files from `proto` file definitions.

## Setup

To install the "new" generator (bear in mind that it could be installed in `${HOME}/.local/bin` too):
To install the generator (bear in mind that it could be installed in `${HOME}/.local/bin` too):
```
curl -Lo protoc-gen-tsx \
https://github.com/join-com/protoc-gen-ts/releases/download/[VERSION]/protoc-gen-tsx.darwin.amd64 \
https://github.com/join-com/protoc-gen-ts/releases/download/[VERSION]/protoc-gen-tsx.darwin.arm64 \
&& chmod +x protoc-gen-tsx \
&& sudo mv protoc-gen-tsx /usr/local/bin
```

In case you need to use the old generator as well, you can install it too in parallel:
```
curl -Lo protoc-gen-ts \
https://github.com/join-com/protoc-gen-ts/releases/download/0.7.1/protoc-gen-ts.darwin.x86_64 \
&& chmod +x protoc-gen-ts \
&& sudo mv protoc-gen-ts /usr/local/bin
```

- If you need a binary for Linux, you can change the word "darwin" in the url by "linux".
- If you need support for the M1 processor, or any other ARM processor, change "amd64" by "arm64".
- If you need support for the Intel processor, or any other ARM processor, change "arm64" by "amd64".

## Usage

Expand All @@ -30,11 +22,6 @@ will generate TS implementations into `proto-ts` folder for all your proto files
protoc proto/*.proto -I proto --tsx_out=proto-ts
```

If you want to use the old generator (notice the `tsx_out` -> `ts_out` change):
```
protoc proto/*.proto -I proto --ts_out=proto-ts
```

## Advanced topics: Required fields & type flavors

In order to enable the "required fields" feature and the "type flavors" feature,
Expand Down Expand Up @@ -74,9 +61,19 @@ message UserProfile {
}
```

### Field masks

By default, the generated type for the field mask property will be `{ paths: string[] }`. To add clarity which fields can be send as a mask use:
```proto
message GetRequest {
int32 id = 1;
google.protobuf.FieldMask read_mask = 2 [(join.protobuf.typescript_mask) = "Company"];
}
```

## Develop

1. Follow [instructions](https://golang.org/doc/install) to install Go and add /usr/local/go/bin to the PATH environment variable
1. Follow [instructions](https://golang.org/doinc/install) to install Go and add /usr/local/go/bin to the PATH environment variable
2. Run `./build.sh` to compile the package
3. Or navigate to `tests` folder and run `yarn compile`
4. Run `yarn proto:build:package(1/2/3)` to generate one of the packages for tests
Expand Down

0 comments on commit 9b92372

Please sign in to comment.