Skip to content

Conversation

annajowang
Copy link
Collaborator

  • Support adapter builds and add tests.
  • Clean up
  • get test working with esm
  • clean
  • clean
  • more config fixes
  • clean
  • move OutputBundleConfig to fix lint
  • disable eslint
  • lint
  • dumb fix found
  • fix disable comment maybe
  • please disable this lint check
  • fix a mistake AI did not catch
  • Update version for common package

Copy link

@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.

Summary of Changes

Hello @annajowang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the @apphosting/build package by introducing robust end-to-end testing for framework adapter builds and generalizing the local build process. It also includes a version bump for the @apphosting/common package and refines development dependencies to streamline the build environment.

Highlights

  • Enhanced Local Build Process: The apphosting-local-build command has been enhanced to accept a --framework option, allowing for more flexible and generic local builds across different frameworks.
  • Comprehensive E2E Testing: New end-to-end tests have been introduced to rigorously validate the bundle.yaml generation for both Next.js and Angular applications, ensuring the correctness of framework adapter outputs.
  • Dynamic Adapter Version Resolution: The build process now dynamically fetches the latest framework adapter version directly from npm, ensuring that builds consistently utilize the most up-to-date adapters.
  • Dependency Streamlining: Several development dependencies were removed from @apphosting/build, and typescript was explicitly added, contributing to a more streamlined and focused dependency tree.
  • Package Version Updates: The @apphosting/common package has been updated to version 0.0.8, and the @apphosting/build package to 0.1.1, reflecting ongoing development and improvements.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@annajowang annajowang closed this Aug 18, 2025
Copy link

@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 introduces a significant feature: adapter-based builds for different frameworks, along with end-to-end tests to validate them. It also includes version bumps and dependency cleanups. My review focuses on improving type safety and robustness in the new test files and build scripts. I've identified a few areas where using more specific types and safer patterns can prevent potential runtime errors and improve code clarity.

Comment on lines +3 to +10
import pkg from "@apphosting/common";
import { scenarios } from "./scenarios.ts";
import fsExtra from "fs-extra";
import { parse as parseYaml } from "yaml";

const { readFileSync } = fsExtra;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { OutputBundleConfig } = pkg;

Choose a reason for hiding this comment

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

high

This way of importing a type is confusing and can lead to runtime errors. Since OutputBundleConfig is only used as a type, you can use a type-only import, which is safer and clearer. This also allows you to remove the eslint-disable and the runtime destructuring.

Suggested change
import pkg from "@apphosting/common";
import { scenarios } from "./scenarios.ts";
import fsExtra from "fs-extra";
import { parse as parseYaml } from "yaml";
const { readFileSync } = fsExtra;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { OutputBundleConfig } = pkg;
import type { OutputBundleConfig } from "@apphosting/common";
import { scenarios } from "./scenarios.ts";
import fsExtra from "fs-extra";
import { parse as parseYaml } from "yaml";
const { readFileSync } = fsExtra;


const __dirname = dirname(fileURLToPath(import.meta.url));

const errors: any[] = [];

Choose a reason for hiding this comment

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

medium

Using any is discouraged as it bypasses type checking. It's better to use a more specific type like Error or unknown to improve type safety.

const errors: Error[] = [];

}
}
if (errors.length) {
console.error(errors);

Choose a reason for hiding this comment

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

medium

Printing the errors array directly might not provide readable output for Error objects. Iterating over the array and logging each error individually would be more informative for debugging.

  errors.forEach((error) => console.error(error));

Comment on lines +1 to +5
interface Scenario {
inputs: string[];
expectedBundleYaml: {};
tests?: string[]; // List of test files to run
}

Choose a reason for hiding this comment

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

medium

Using {} as a type is not very descriptive and is similar to any. It's better to use a more specific type. You could import OutputBundleConfig from @apphosting/common and use Partial<OutputBundleConfig> for expectedBundleYaml to improve type safety and code clarity.

import type { OutputBundleConfig } from "@apphosting/common";

interface Scenario {
  inputs: string[];
  expectedBundleYaml: Partial<OutputBundleConfig>;
  tests?: string[]; // List of test files to run
}

import promiseSpawn from "@npmcli/promise-spawn";
import { yellow, bgRed, bold } from "colorette";

export async function adapterBuild(projectRoot: string, framework: string) {

Choose a reason for hiding this comment

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

medium

For better type safety, consider using the Framework type from @apphosting/common for the framework parameter, instead of a generic string. This requires exporting the Framework type from @apphosting/common first, and adding import type { Framework } from '@apphosting/common'; to this file.

Suggested change
export async function adapterBuild(projectRoot: string, framework: string) {
export async function adapterBuild(projectRoot: string, framework: Framework) {

@@ -1,46 +1,23 @@
#! /usr/bin/env node
import { spawn } from "child_process";
import { SupportedFrameworks } from "@apphosting/common";

Choose a reason for hiding this comment

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

medium

To improve type safety, import the Framework type as well. This will be used to cast the framework option before passing it to other functions.

Suggested change
import { SupportedFrameworks } from "@apphosting/common";
import { SupportedFrameworks, Framework } from "@apphosting/common";

// TODO(#382): parse apphosting.yaml for environment variables / secrets needed during build time.
if (opts.framework && SupportedFrameworks.includes(opts.framework)) {
// TODO(#382): Skip this if there's a custom build command in apphosting.yaml.
await adapterBuild(projectRoot, opts.framework);

Choose a reason for hiding this comment

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

medium

To ensure type safety when calling adapterBuild, cast opts.framework to the more specific Framework type. The includes check on line 13 makes this cast safe.

Suggested change
await adapterBuild(projectRoot, opts.framework);
await adapterBuild(projectRoot, opts.framework as Framework);

import * as path from "node:path";

// List of apphosting supported frameworks.
export const SupportedFrameworks = ["nextjs", "angular"] as const;

Choose a reason for hiding this comment

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

medium

To improve type safety across packages, it's a good practice to also export a type alias for the supported frameworks. This can then be used as a specific type instead of a generic string in functions that accept a framework name.

Suggested change
export const SupportedFrameworks = ["nextjs", "angular"] as const;
export const SupportedFrameworks = ["nextjs", "angular"] as const;
export type Framework = typeof SupportedFrameworks[number];

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