ts-proto 1.90.1 → 1.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [1.91.0](https://github.com/stephenh/ts-proto/compare/v1.90.1...v1.91.0) (2021-11-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use Long.fromValue instead of Long.fromString for improved robustness regarding already parsed objects ([#405](https://github.com/stephenh/ts-proto/issues/405)) ([7bdc3ee](https://github.com/stephenh/ts-proto/commit/7bdc3eee05ed1318e18e27aa7d5bb2680060f8b6))
7
+
8
+
9
+ ### Features
10
+
11
+ * Include dockerized protoc ([#404](https://github.com/stephenh/ts-proto/issues/404)) ([7564a78](https://github.com/stephenh/ts-proto/commit/7564a7887ccd0bb80cac19d313ee9bd8daae778d))
12
+
1
13
  ## [1.90.1](https://github.com/stephenh/ts-proto/compare/v1.90.0...v1.90.1) (2021-11-27)
2
14
 
3
15
 
package/README.markdown CHANGED
@@ -18,7 +18,7 @@
18
18
  - [Supported options](#supported-options)
19
19
  - [Only Types](#only-types)
20
20
  - [NestJS Support](NESTJS.markdown)
21
- - [Building](#building)
21
+ - [Development](#development)
22
22
  - [Assumptions](#assumptions)
23
23
  - [Todo](#todo)
24
24
  - [OneOf Handling](#oneof-handling)
@@ -362,15 +362,69 @@ Kudos to our sponsors:
362
362
 
363
363
  If you need ts-proto customizations or priority support for your company, you can ping me at [via email](mailto:stephen.haberman@gmail.com).
364
364
 
365
- # Building
365
+ # Development
366
366
 
367
- After running `yarn install`, run `./integration/pbjs.sh` to create the integration test types. These pbjs-generated files are not currently checked in.
367
+ **Requirements**
368
368
 
369
- After this, the tests should pass.
369
+ - [Docker](https://www.docker.com) or [protoc](https://github.com/protocolbuffers/protobuf/releases) v3.19.1
370
+ - `yarn` — `npm install -g yarn`
370
371
 
371
- After making changes to `ts-proto`, you can run `cd integration` and `./codegen.sh` to re-generate the test case `*.ts` output files that are in each `integration/<test-case>/` directory.
372
+ **Setup**
372
373
 
373
- The test suite's proto files (i.e. `simple.proto`, `batching.proto`, etc.) currently have serialized/`.bin` copies checked into git (i.e. `simple.bin`, `batching.bin`, etc.), so that the test suite can run without having to invoke the `protoc` build chain. I.e. if you change the `simple.proto`/etc. files, you'll need to run `./integration/update-bins.sh`, which does require having the `protoc` executable available.
374
+ The commands below assume you have **Docker** installed. To use a **local** copy of `protoc` without docker, use commands suffixed with `:local`
375
+
376
+ - Check out the [repository]() for the latest code.
377
+ - Run `yarn install` to install the dependencies.
378
+ - Run `yarn build:test` or `yarn build:test:local` to generate the test files.
379
+ > _This runs the following commands:_
380
+ > - `proto2bin` — Converts integration test `.proto` files to `.bin`.
381
+ > - `bin2ts` — Runs `ts-proto` on the `.bin` files to generate `.ts` files.
382
+ > - `proto2pbjs` — Generates a reference implementation using `pbjs` for testing compatibility.
383
+ - Run `yarn test`
384
+
385
+ **Workflow**
386
+
387
+ - Modifying the plugin implementation:
388
+ - Run `yarn bin2ts` or `yarn bin2ts:local`.
389
+ _Since the proto files were not changed, you only need to regenerate the typescript files._
390
+ - Run `yarn test` to verify the typescript files are compatible with the reference implementation, and pass other tests.
391
+ - Updating or adding `.proto` files in the integration directory:
392
+ - Run `yarn build:test` to regenerate the integration test files.
393
+ - Run `yarn test` to retest.
394
+
395
+ **Contributing**
396
+
397
+ - Run `yarn build:test` and `yarn test` to make sure everything works.
398
+ - Run `yarn prettier` to format the typescript files.
399
+ - Commit the changes:
400
+ - Also include the generated `.bin` files for the tests where you added or modified `.proto` files.
401
+ > These are checked into git so that the test suite can run without having to invoke the `protoc` build chain.
402
+ - Also include the generated `.ts` files.
403
+ - Create a pull request
404
+
405
+ **Dockerized Protoc**
406
+
407
+ The repository includes a dockerized version of `protoc`, which is configured in [docker-compose.yml](docker-compose.yml).
408
+
409
+ It can be useful in case you want to manually invoke the plugin with a known version of `protoc`.
410
+
411
+ Usage:
412
+
413
+ ```bash
414
+ # Include the protoc alias in your shell.
415
+ . aliases.sh
416
+
417
+ # Run protoc as usual. The ts-proto directory is available in /ts-proto.
418
+ protoc --plugin=/ts-proto/protoc-gen-ts_proto --ts_proto_out=./output -I=./protos ./protoc/*.proto
419
+
420
+ # Or use the ts-protoc alias which specifies the plugin path for you.
421
+ ts-protoc --ts_proto_out=./output -I=./protos ./protoc/*.proto
422
+ ```
423
+
424
+ - All paths must be relative paths _within_ the current working directory of the host. `../` is not allowed
425
+ - Within the docker container, the absolute path to the project root is `/ts-proto`
426
+ - The container mounts the current working directory in `/host`, and sets it as its working directory.
427
+ - Once `aliases.sh` is sourced, you can use the `protoc` command in any folder.
374
428
 
375
429
  # Assumptions
376
430
 
package/build/main.js CHANGED
@@ -823,7 +823,7 @@ function generateFromJson(ctx, fullName, messageDesc) {
823
823
  }
824
824
  }
825
825
  else if (types_1.isLong(valueType) && options.forceLong === options_1.LongOption.LONG) {
826
- return ts_poet_1.code `Long.fromString(${from} as string)`;
826
+ return ts_poet_1.code `Long.fromValue(${from} as Long | string)`;
827
827
  }
828
828
  else if (types_1.isEnum(valueType)) {
829
829
  return ts_poet_1.code `${from} as number`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.90.1",
3
+ "version": "1.91.0",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",
@@ -9,10 +9,19 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "yarn tsc",
12
- "setup": "cd ./integration && ./pbjs.sh && ./update-bins.sh && ./codegen.sh",
12
+ "build:test": "yarn proto2bin && yarn proto2pbjs && yarn bin2ts",
13
+ "build:test:local": "yarn proto2bin:local && yarn proto2pbjs:local && yarn bin2ts:local",
14
+ "proto2bin": "docker-compose run --rm protoc update-bins.sh",
15
+ "proto2bin-node": "docker-compose run --rm node update-bins.sh",
16
+ "proto2pbjs": "docker-compose run --rm protoc pbjs.sh",
17
+ "bin2ts": "docker-compose run --rm protoc codegen.sh",
18
+ "proto2bin:local": "integration/update-bins.sh",
19
+ "proto2pbjs:local": "integration/pbjs.sh",
20
+ "bin2ts:local": "integration/codegen.sh",
13
21
  "test": "yarn jest -c jest.config.js --maxWorkers=2",
14
22
  "prettier": "prettier --write {src,tests}/**/*.ts",
15
- "prettier:check": "prettier --list-different {src,tests}/**/*.ts"
23
+ "prettier:check": "prettier --list-different {src,tests}/**/*.ts",
24
+ "setup:docker": "docker-compose build"
16
25
  },
17
26
  "files": [
18
27
  "build"