Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make gapic-tools depend on gax-nodejs #1480

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"c8": "^8.0.0",
"codecov": "^3.1.0",
"execa": "^5.0.0",
"gapic-tools": "^0.1.7",
"google-proto-files": "^3.0.3",
"gts": "^3.1.0",
"linkinator": "^4.0.0",
Expand Down Expand Up @@ -74,7 +73,7 @@
"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",
"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",
"fix": "gts fix",
"prepare": "npm run compile && prepublishProtos . && mkdirp build/protos && cp -r protos/* build/protos/ && npm run minify-proto-json",
"prepare": "npm run compile && node ./build/tools/src/prepublish.js . && mkdirp build/protos && cp -r protos/* build/protos/ && npm run minify-proto-json",
"system-test": "c8 mocha build/test/system-test --timeout 600000 && npm run test-application",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"docs-test": "linkinator docs",
Expand All @@ -83,8 +82,8 @@
"test-application": "cd test/test-application && npm run prefetch && npm install && npm start",
"prelint": "cd samples; npm link ../; npm install",
"precompile": "gts clean",
"update-protos": "listProtos .",
"minify-proto-json": "minifyProtoJson"
"update-protos": "node ./build/tools/src/listProtos.js .",
"minify-proto-json": "node ./build/tools/src/minify.js"
},
"repository": "googleapis/gax-nodejs",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "compiles, updates, and minifies protos",
"main": "build/src/compileProtos.js",
"files": [
"build/tools/src",
"build/src",
"!build/src/**/*.map"
],
"scripts": {
Expand All @@ -28,6 +28,7 @@
"author": "Google API Authors",
"license": "Apache-2.0",
"dependencies": {
"google-gax": "^4.0.2",
"google-proto-files": "^3.0.3",
"protobufjs-cli": "1.1.1",
"rimraf": "^5.0.1",
Expand Down
10 changes: 8 additions & 2 deletions tools/src/compileProtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import * as util from 'util';
import * as pbjs from 'protobufjs-cli/pbjs';
import * as pbts from 'protobufjs-cli/pbts';

export const gaxProtos = path.join(
require.resolve('google-gax'),
'..',
'..',
'protos'
);
const readdir = util.promisify(fs.readdir);
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
Expand Down Expand Up @@ -246,7 +252,7 @@ async function compileProtos(
'-p',
'protos',
'-p',
path.join(__dirname, '..', '..', '..', 'google-gax', 'build', 'protos'),
gaxProtos,
'-o',
jsonOutput,
];
Expand All @@ -264,7 +270,7 @@ async function compileProtos(
'-p',
'protos',
'-p',
path.join(__dirname, '..', '..', '..', 'google-gax', 'build', 'protos'),
gaxProtos,
'-o',
jsOutput,
];
Expand Down
20 changes: 20 additions & 0 deletions tools/test/compileProtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ describe('compileProtos tool', () => {
process.chdir(cwd);
});

it('fetches gax from the appropriate place', async () => {
assert.deepStrictEqual(fs.readdirSync(compileProtos.gaxProtos), [
'compute_operations.d.ts',
'compute_operations.js',
'compute_operations.json',
'google',
'http.d.ts',
'http.js',
'iam_service.d.ts',
'iam_service.js',
'iam_service.json',
'locations.d.ts',
'locations.js',
'locations.json',
'operations.d.ts',
'operations.js',
'operations.json',
'status.json',
]);
});
it('compiles protos to JSON, JS, TS', async function () {
this.timeout(20000);
await compileProtos.main([
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
"include": [
"src/*.ts",
"tools/src/listProtos.ts",
"tools/src/minify.ts",
"tools/src/prepublish.ts",
"src/*/*.ts",
"test/system-test/*.ts",
"test/unit/*.ts",
Expand Down
Loading