Skip to content

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

Merged
pearigee merged 8 commits intomainfrom
pearigee-fix-gapic-generator-build
Apr 24, 2026
Merged

chore: fix gapic-generator-typescript build scripts for easier local development#8103
pearigee merged 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
Copy link
Copy Markdown
Contributor

@GautamSharda GautamSharda left a comment

Choose a reason for hiding this comment

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

Do you expect this change in the generator to eventually change the libraries in google-cloud-node? If not, why not? If so, do you know whether the resulting changes would increase or decrease diffs produced by librarian generate?

@pearigee
Copy link
Copy Markdown
Contributor Author

pearigee commented Apr 24, 2026

There is one change which may have a meaningful (but actually desired) impact on generation output:

Other than that, none of the core generation logic has been modified.

The changes are focused on:

  • Ensuring compatibility with versions of node >20 (by fixing import syntax)
  • Making the BUILD scripts in package.json useful to developers running locally (they are all currently broken and unused by automation)
  • Enable npm link to add the generated binaries to the path for use.

@pearigee pearigee merged commit df9f27e into main Apr 24, 2026
33 checks passed
@pearigee pearigee deleted the pearigee-fix-gapic-generator-build branch April 24, 2026 18:23
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.

2 participants