Skip to content

Commit

Permalink
chore: auto-format .proto files with buf (#227)
Browse files Browse the repository at this point in the history
This change should have no user impact.

`buf format` can auto-format .proto files, similar to Prettier. This
change:

- Auto-formats our .proto files with `buf format`.
- Adds `npm run format:buf` to auto-format .proto files.
- Adds `npm run lint:buf-format` to check formatting of .proto files.
- Updates `npm run format` to call both `npm run format:buf` and
  Prettier.
- Updates `npm run lint` to call both `npm run lint:buf-format` and
  Prettier.
  • Loading branch information
EvanHahn authored Aug 29, 2024
1 parent 788229e commit 486c627
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
"build:tsc": "tsc",
"build:copy": "cpy 'intermediate/generated/**' 'intermediate/src/**' dist/",
"build:doc": "typedoc src/index.ts --tsconfig tsconfig.typedoc.json --plugin typedoc-plugin-markdown",
"format": "prettier --write .",
"lint": "prettier --check .",
"format:buf": "buf format --write ./proto",
"format:prettier": "prettier --write .",
"format": "npm-run-all --parallel format:*",
"lint:buf-format": "buf format --diff --exit-code ./proto",
"lint:prettier": "prettier --check .",
"lint": "npm-run-all --parallel lint:*",
"prepack": "npm run build",
"pretest": "npm run lint",
"test": "node --test test"
Expand Down
2 changes: 1 addition & 1 deletion proto/coreOwnership/v1.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "common/v1.proto";
import "options.proto";

message CoreOwnership_1 {
Expand Down
2 changes: 1 addition & 1 deletion proto/deviceInfo/v1.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "common/v1.proto";
import "options.proto";

message DeviceInfo_1 {
Expand Down
4 changes: 2 additions & 2 deletions proto/field/v1.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "tags/v1.proto";
import "common/v1.proto";
import "options.proto";
import "tags/v1.proto";

message Field_1 {
// **DO NOT CHANGE dataTypeId** generated with `openssl rand -hex 6`
Expand Down
2 changes: 0 additions & 2 deletions proto/icon/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ message Icon_1 {
PixelDensity pixelDensity = 1 [(required) = true];
}


message IconVariant {
oneof variant {
IconVariantSvg svgIcon = 1;
Expand All @@ -48,5 +47,4 @@ message Icon_1 {
BlobVersionId blobVersionId = 4 [(required) = true];
}
repeated IconVariant variants = 3;

}
7 changes: 3 additions & 4 deletions proto/observation/v1.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package mapeo;

import "google/protobuf/timestamp.proto";
import "google/protobuf/struct.proto";
import "tags/v1.proto";
import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "options.proto";
import "tags/v1.proto";
import "versionId/v1.proto";

message Observation_1 {
Expand Down Expand Up @@ -74,5 +74,4 @@ message Observation_1 {
bytes docId = 1;
VersionId_1 versionId = 2;
}

}
3 changes: 2 additions & 1 deletion proto/options.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
syntax = "proto3";
import "google/protobuf/descriptor.proto";
package mapeo;

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
// This should be a hex-encoded 48-bit random number, and should never change
// for a given message type. Generated with `openssl rand -hex 6`
Expand Down
5 changes: 2 additions & 3 deletions proto/preset/v1.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "options.proto";
import "tags/v1.proto";
import "common/v1.proto";
import "versionId/v1.proto";
import "options.proto";

message Preset_1 {
// **DO NOT CHANGE dataTypeId** generated with `openssl rand -hex 6`
Expand Down Expand Up @@ -34,7 +34,6 @@ message Preset_1 {
relation = 5;
}


message FieldRef {
bytes docId = 1;
VersionId_1 versionId = 2;
Expand Down
4 changes: 2 additions & 2 deletions proto/projectSettings/v1.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";
package mapeo;

import "google/protobuf/timestamp.proto";
import "common/v1.proto";
import "google/protobuf/timestamp.proto";
import "options.proto";

message ProjectSettings_1 {
Expand All @@ -18,7 +18,7 @@ message ProjectSettings_1 {
repeated bytes vertex = 3;
repeated bytes line = 4;
repeated bytes relation = 5;
};
}

message ConfigMetadata {
string name = 1;
Expand Down
2 changes: 1 addition & 1 deletion proto/role/v1.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "common/v1.proto";
import "options.proto";

message Role_1 {
Expand Down
6 changes: 3 additions & 3 deletions proto/track/v1.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package mapeo;

import "google/protobuf/timestamp.proto";
import "google/protobuf/struct.proto";
import "tags/v1.proto";
import "common/v1.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "options.proto";
import "tags/v1.proto";
import "versionId/v1.proto";

message Track_1 {
Expand Down
3 changes: 1 addition & 2 deletions proto/translation/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ syntax = "proto3";
package mapeo;

import "common/v1.proto";
import "versionId/v1.proto";
import "options.proto";
import "versionId/v1.proto";

message Translation_1 {
// **DO NOT CHANGE dataTypeId** generated with `openssl rand -hex 6`
Expand Down Expand Up @@ -33,5 +33,4 @@ message Translation_1 {
track = 7;
}
DocRefType docRefType = 7;

}

0 comments on commit 486c627

Please sign in to comment.