Skip to content

Commit b57e572

Browse files
authored
chore: Upgrade to protobufjs 7 (#789)
1 parent 4de5326 commit b57e572

File tree

9 files changed

+3702
-3201
lines changed

9 files changed

+3702
-3201
lines changed

package-lock.json

Lines changed: 3680 additions & 3183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"npm-run-all": "^4.1.5",
9090
"pidusage": "^3.0.0",
9191
"prettier": "^2.7.1",
92+
"protobufjs-cli": "^1.0.0",
9293
"tail": "^2.2.4",
9394
"ts-prune": "^0.10.3",
9495
"typescript": "^4.7.4",

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@temporalio/internal-workflow-common": "file:../internal-workflow-common",
2020
"@temporalio/proto": "file:../proto",
2121
"ms": "^2.1.3",
22-
"protobufjs": "6.11.2",
22+
"protobufjs": "^7.0.0",
2323
"uuid": "^8.3.2"
2424
},
2525
"bugs": {

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@temporalio/internal-workflow-common": "file:../internal-workflow-common",
1717
"@temporalio/proto": "file:../proto",
1818
"proto3-json-serializer": "^1.0.2",
19-
"protobufjs": "6.11.2"
19+
"protobufjs": "^7.0.0"
2020
},
2121
"bugs": {
2222
"url": "https://github.com/temporalio/sdk-typescript/issues"

packages/proto/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@types/long": "^4.0.2",
2424
"long": "^5.2.0",
25-
"protobufjs": "6.11.2"
25+
"protobufjs": "^7.0.0"
2626
},
2727
"bugs": {
2828
"url": "https://github.com/temporalio/sdk-typescript/issues"

packages/proto/scripts/compile-proto.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const { promisify } = require('util');
44
const dedent = require('dedent');
55
const glob = require('glob');
66
const { statSync, mkdirSync, readFileSync, writeFileSync } = require('fs');
7-
const pbjs = require('protobufjs/cli/pbjs');
8-
const pbts = require('protobufjs/cli/pbts');
7+
const pbjs = require('protobufjs-cli/pbjs');
8+
const pbts = require('protobufjs-cli/pbts');
99

1010
const outputDir = resolve(__dirname, '../protos');
1111
const jsOutputFile = resolve(outputDir, 'json-module.js');
@@ -38,6 +38,7 @@ async function compileProtos(dtsOutputFile, ...args) {
3838
'--no-verify',
3939
'--root',
4040
'__temporal',
41+
resolve(require.resolve('protobufjs'), '../google/protobuf/descriptor.proto'),
4142
coreProtoPath,
4243
workflowServiceProtoPath,
4344
operatorServiceProtoPath,

packages/test/scripts/compile-proto.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const { promisify } = require('util');
66
const glob = require('glob');
77
const { statSync, mkdirsSync } = require('fs-extra');
88
const { rm } = require('fs/promises');
9-
const pbjs = require('protobufjs/cli/pbjs');
10-
const pbts = require('protobufjs/cli/pbts');
9+
const pbjs = require('protobufjs-cli/pbjs');
10+
const pbts = require('protobufjs-cli/pbts');
1111

1212
const outputDir = resolve(__dirname, '../protos');
1313
const moduleOutputFile = resolve(outputDir, 'json-module.js');
1414
const typesOutputFile = resolve(outputDir, 'root.d.ts');
1515
const tempFile = resolve(outputDir, 'temp.js');
1616
const protoBaseDir = resolve(__dirname, '../protos');
17-
const protosPath = protoBaseDir + '/*.proto';
17+
const protoFiles = glob.sync(protoBaseDir + '/*.proto');
1818

1919
function mtime(path) {
2020
try {
@@ -27,15 +27,14 @@ function mtime(path) {
2727
}
2828
}
2929

30-
async function compileProtos(protoPath, outputFile, ...args) {
31-
const pbjsArgs = [...args, '--wrap', 'commonjs', '--force-long', '--no-verify', '--out', outputFile, protoPath];
30+
async function compileProtos(outputFile, ...args) {
31+
const pbjsArgs = [...args, '--wrap', 'commonjs', '--force-long', '--no-verify', '--out', outputFile, ...protoFiles];
3232
return await promisify(pbjs.main)(pbjsArgs);
3333
}
3434

3535
async function main() {
3636
mkdirsSync(outputDir);
3737

38-
const protoFiles = glob.sync(resolve(protoBaseDir, '**/*.proto'));
3938
const protosMTime = Math.max(...protoFiles.map(mtime));
4039
const genMTime = Math.min(mtime(moduleOutputFile), mtime(typesOutputFile));
4140

@@ -44,12 +43,12 @@ async function main() {
4443
return;
4544
}
4645

47-
console.log(`Creating protobuf JS definitions from ${protosPath}`);
48-
await compileProtos(protosPath, moduleOutputFile, '--target', 'json-module', '--root', 'test');
46+
console.log(`Creating protobuf JS definitions from ${protoFiles}`);
47+
await compileProtos(moduleOutputFile, '--target', 'json-module', '--root', 'test');
4948

50-
console.log(`Creating protobuf TS definitions from ${protosPath}`);
49+
console.log(`Creating protobuf TS definitions from ${protoFiles}`);
5150
try {
52-
await compileProtos(protosPath, tempFile, '--target', 'static-module');
51+
await compileProtos(tempFile, '--target', 'static-module');
5352
await promisify(pbts.main)(['--out', typesOutputFile, tempFile]);
5453
} finally {
5554
await rm(tempFile);

packages/testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"get-port": "^6.1.2",
2828
"got": "^12.1.0",
2929
"long": "^5.2.0",
30-
"protobufjs": "6.11.2",
30+
"protobufjs": "^7.0.0",
3131
"tar-stream": "^2.2.0",
3232
"unzipper": "^0.10.11"
3333
},

packages/testing/scripts/compile-proto.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import { createRequire } from 'module';
12
import { resolve, dirname } from 'path';
23
import { fileURLToPath } from 'url';
34
import { promisify } from 'util';
45
import dedent from 'dedent';
56
import glob from 'glob';
67
import { statSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
7-
import pbjs from 'protobufjs/cli/pbjs.js';
8-
import pbts from 'protobufjs/cli/pbts.js';
8+
import pbjs from 'protobufjs-cli/pbjs.js';
9+
import pbts from 'protobufjs-cli/pbts.js';
910

11+
const require = createRequire(import.meta.url);
1012
const __dirname = dirname(fileURLToPath(import.meta.url));
1113
const outputDir = resolve(__dirname, '../generated-protos');
1214
const outputFile = resolve(outputDir, 'index.js');
@@ -40,6 +42,7 @@ async function compileProtos(protoPath, jsOutputFile, dtsOutputFile, ...args) {
4042
'__temporal_testing',
4143
'--out',
4244
jsOutputFile,
45+
resolve(require.resolve('protobufjs'), '../google/protobuf/descriptor.proto'),
4346
protoPath,
4447
];
4548
await promisify(pbjs.main)(pbjsArgs);

0 commit comments

Comments
 (0)