Skip to content

chore: fix gapic-generator-typescript build scripts for easier local development#8103

Open
pearigee wants to merge 8 commits intomainfrom
pearigee-fix-gapic-generator-build
Open

chore: fix gapic-generator-typescript build scripts for easier local development#8103
pearigee wants to merge 8 commits intomainfrom
pearigee-fix-gapic-generator-build

Conversation

@pearigee
Copy link
Copy Markdown
Contributor

@pearigee pearigee commented Apr 23, 2026

Today, building the GAPIC generator depends on Bazel, which doesn't work in the packages default state.

This PR, removes the dependency on Bazel from the package.json and enables the following commands to work again:

  1. npm run compile now successfully builds the artifacts required to run the generator and places them in a build/ directory.
  2. npm link now successfully creates executable scripts, puts them in your node_modules/.bin folder, and adds them to your path so they can be run immediately.

In addition to fixing the compile and link functionality, I also fixed the npm run test script so we can verify our changes locally. I also deleted test scripts which point to files no longer defined in the source code.

Example output from running locally:

gabepearhill@gabepearhill-mac gapic-generator-typescript % npm run compile

> @google-cloud/gapic-generator@4.11.13 compile
> tsc && chmod +x build/typescript/src/gapic-generator-typescript.js build/typescript/src/protoc-plugin.js && cp -rf templates protos build/

gabepearhill@gabepearhill-mac gapic-generator-typescript % 
gabepearhill@gabepearhill-mac gapic-generator-typescript % npm run test 

> @google-cloud/gapic-generator@4.11.13 test
> mocha build/typescript/test/unit



  src/schema/api.ts
    ✔ should construct an API object and return list of protos
    ✔ should correctly derive a valid logging name
    ✔ throw error if an api does not have default host
    ✔ should not return common protos in the list of protos
    ✔ should be able to generate google.iam.v1 alone
    ✔ should be able to generate google.cloud.location alone
    ✔ should not return common protos in the proto list
    ✔ should include the protos has no service and different package name
    ✔ should return lexicographically first service name as mainServiceName
    ✔ should return correct mainServiceName for API without namespace
    ✔ should return main service name specificed as an option
    ✔ should return list of protos in lexicographical order
    ✔ should throw error when the service name is not found
  
[... Truncated for brevity]


  152 passing (15s)

gabepearhill@gabepearhill-mac gapic-generator-typescript % 

@pearigee pearigee requested a review from a team as a code owner April 23, 2026 17:18
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the gapic-generator-typescript package from a Bazel-based build system to a standard TypeScript and npm workflow. Key changes include replacing Bazel commands with tsc and mocha, updating JSON import syntax to use the with keyword, and adjusting the protoc binary path validation. Review feedback identifies potential compilation errors caused by restricted type definitions in tsconfig.json, cross-platform compatibility issues with Unix-specific commands in the compile script, and potential file state inconsistencies during the prepack process.

Comment thread core/generator/gapic-generator-typescript/tsconfig.json Outdated
Comment thread core/generator/gapic-generator-typescript/package.json
Comment thread core/generator/gapic-generator-typescript/package.json Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant