Skip to content

Commit d0f410d

Browse files
authored
fix: make gapic-tools depend on gax-nodejs (#1480)
* fix: make gapic-tools depend on gax-nodejs
1 parent 2bb9ae2 commit d0f410d

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"c8": "^8.0.0",
3838
"codecov": "^3.1.0",
3939
"execa": "^5.0.0",
40-
"gapic-tools": "^0.1.7",
4140
"google-proto-files": "^3.0.3",
4241
"gts": "^3.1.0",
4342
"linkinator": "^4.0.0",
@@ -74,7 +73,7 @@
7473
"compile-http-protos": "pbjs -t static-module -r http_proto --keep-case google/api/http.proto -p ./protos > protos/http.js && pbts protos/http.js -o protos/http.d.ts",
7574
"compile-showcase-proto": "pbjs -t json google/showcase/v1beta1/echo.proto google/showcase/v1beta1/identity.proto google/showcase/v1beta1/messaging.proto google/showcase/v1beta1/testing.proto -p ./protos > test/fixtures/google-gax-packaging-test-app/protos/protos.json && pbjs -t static-module -r showcase_protos google/showcase/v1beta1/echo.proto google/showcase/v1beta1/identity.proto google/showcase/v1beta1/messaging.proto google/showcase/v1beta1/testing.proto -p ./protos > test/fixtures/google-gax-packaging-test-app/protos/protos.js && pbts test/fixtures/google-gax-packaging-test-app/protos/protos.js -o test/fixtures/google-gax-packaging-test-app/protos/protos.d.ts",
7675
"fix": "gts fix",
77-
"prepare": "npm run compile && prepublishProtos . && mkdirp build/protos && cp -r protos/* build/protos/ && npm run minify-proto-json",
76+
"prepare": "npm run compile && node ./build/tools/src/prepublish.js . && mkdirp build/protos && cp -r protos/* build/protos/ && npm run minify-proto-json",
7877
"system-test": "c8 mocha build/test/system-test --timeout 600000 && npm run test-application",
7978
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
8079
"docs-test": "linkinator docs",
@@ -83,8 +82,8 @@
8382
"test-application": "cd test/test-application && npm run prefetch && npm install && npm start",
8483
"prelint": "cd samples; npm link ../; npm install",
8584
"precompile": "gts clean",
86-
"update-protos": "listProtos .",
87-
"minify-proto-json": "minifyProtoJson"
85+
"update-protos": "node ./build/tools/src/listProtos.js .",
86+
"minify-proto-json": "node ./build/tools/src/minify.js"
8887
},
8988
"repository": "googleapis/gax-nodejs",
9089
"keywords": [

tools/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "compiles, updates, and minifies protos",
55
"main": "build/src/compileProtos.js",
66
"files": [
7-
"build/tools/src",
7+
"build/src",
88
"!build/src/**/*.map"
99
],
1010
"scripts": {
@@ -28,6 +28,7 @@
2828
"author": "Google API Authors",
2929
"license": "Apache-2.0",
3030
"dependencies": {
31+
"google-gax": "^4.0.2",
3132
"google-proto-files": "^3.0.3",
3233
"protobufjs-cli": "1.1.1",
3334
"rimraf": "^5.0.1",

tools/src/compileProtos.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import * as util from 'util';
2222
import * as pbjs from 'protobufjs-cli/pbjs';
2323
import * as pbts from 'protobufjs-cli/pbts';
2424

25+
export const gaxProtos = path.join(
26+
require.resolve('google-gax'),
27+
'..',
28+
'..',
29+
'protos'
30+
);
2531
const readdir = util.promisify(fs.readdir);
2632
const readFile = util.promisify(fs.readFile);
2733
const writeFile = util.promisify(fs.writeFile);
@@ -246,7 +252,7 @@ async function compileProtos(
246252
'-p',
247253
'protos',
248254
'-p',
249-
path.join(__dirname, '..', '..', '..', 'google-gax', 'build', 'protos'),
255+
gaxProtos,
250256
'-o',
251257
jsonOutput,
252258
];
@@ -264,7 +270,7 @@ async function compileProtos(
264270
'-p',
265271
'protos',
266272
'-p',
267-
path.join(__dirname, '..', '..', '..', 'google-gax', 'build', 'protos'),
273+
gaxProtos,
268274
'-o',
269275
jsOutput,
270276
];

tools/test/compileProtos.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ describe('compileProtos tool', () => {
4949
process.chdir(cwd);
5050
});
5151

52+
it('fetches gax from the appropriate place', async () => {
53+
assert.deepStrictEqual(fs.readdirSync(compileProtos.gaxProtos), [
54+
'compute_operations.d.ts',
55+
'compute_operations.js',
56+
'compute_operations.json',
57+
'google',
58+
'http.d.ts',
59+
'http.js',
60+
'iam_service.d.ts',
61+
'iam_service.js',
62+
'iam_service.json',
63+
'locations.d.ts',
64+
'locations.js',
65+
'locations.json',
66+
'operations.d.ts',
67+
'operations.js',
68+
'operations.json',
69+
'status.json',
70+
]);
71+
});
5272
it('compiles protos to JSON, JS, TS', async function () {
5373
this.timeout(20000);
5474
await compileProtos.main([

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
},
1010
"include": [
1111
"src/*.ts",
12+
"tools/src/listProtos.ts",
13+
"tools/src/minify.ts",
14+
"tools/src/prepublish.ts",
1215
"src/*/*.ts",
1316
"test/system-test/*.ts",
1417
"test/unit/*.ts",

0 commit comments

Comments
 (0)