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

App Hosting Emulator: Change startCommandOverride to startCommand #7990

Merged
merged 3 commits into from
Dec 2, 2024
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
2 changes: 1 addition & 1 deletion schema/firebase-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
"rootDirectory": {
"type": "string"
},
"startCommandOverride": {
"startCommand": {
"type": "string"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/emulator/apphosting/developmentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Returns the package manager used by the project
* @param rootdir project's root directory
* @returns PackageManager

Check warning on line 17 in src/emulator/apphosting/developmentServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export async function detectPackageManager(rootdir: string): Promise<PackageManager> {
if (await pathExists(join(rootdir, "pnpm-lock.yaml"))) {
Expand All @@ -32,13 +32,13 @@
throw new FirebaseError("Unsupported package manager");
}

export async function detectStartCommand(rootDir: string) {

Check warning on line 35 in src/emulator/apphosting/developmentServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 35 in src/emulator/apphosting/developmentServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
try {
const packageManager = await detectPackageManager(rootDir);
return `${packageManager} run dev`;
} catch (e) {
throw new FirebaseError(
"Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.startCommandOverride`",
"Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.startCommand`",
);
}
}
4 changes: 2 additions & 2 deletions src/emulator/apphosting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { start as apphostingStart } from "./serve";
import { logger } from "./developmentServer";
interface AppHostingEmulatorArgs {
options?: any;

Check warning on line 5 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
port?: number;
host?: string;
startCommandOverride?: string;
startCommand?: string;
rootDirectory?: string;
}

Expand All @@ -19,11 +19,11 @@
async start(): Promise<void> {
const { hostname, port } = await apphostingStart({
port: this.args.port,
startCommand: this.args.startCommandOverride,
startCommand: this.args.startCommand,
rootDirectory: this.args.rootDirectory,
});
this.args.options.host = hostname;

Check warning on line 25 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .host on an `any` value
this.args.options.port = port;

Check warning on line 26 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .port on an `any` value
}

connect(): Promise<void> {
Expand All @@ -39,8 +39,8 @@
getInfo(): EmulatorInfo {
return {
name: Emulators.APPHOSTING,
host: this.args.options.host!,

Check warning on line 42 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 42 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion

Check warning on line 42 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .host on an `any` value
port: this.args.options.port!,

Check warning on line 43 in src/emulator/apphosting/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/emulator/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ export async function startAll(
const apphostingEmulator = new AppHostingEmulator({
host: apphostingAddr.host,
port: apphostingAddr.port,
startCommandOverride: apphostingConfig?.startCommandOverride,
startCommand: apphostingConfig?.startCommand,
rootDirectory: apphostingConfig?.rootDirectory,
options,
});
Expand Down
4 changes: 2 additions & 2 deletions src/emulator/initEmulators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export const AdditionalInitFns: AdditionalInitFnsType = {
const backendRoot = join(cwd, backendRelativeDir);
try {
const startCommand = await detectStartCommand(backendRoot);
additionalConfigs.set("startCommandOverride", startCommand);
additionalConfigs.set("startCommand", startCommand);
} catch (e) {
logger.log(
"WARN",
"Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.startCommandOverride`",
"Failed to auto-detect your project's start command. Consider manually setting the start command by setting `firebase.json#emulators.apphosting.startCommand`",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/firebaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export type EmulatorsConfig = {
apphosting?: {
host?: string;
port?: number;
startCommandOverride?: string;
startCommand?: string;
rootDirectory?: string;
};
pubsub?: {
Expand Down
Loading