Skip to content
Open
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
3 changes: 3 additions & 0 deletions schema/firebase-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,9 @@
"firestore": {
"additionalProperties": false,
"properties": {
"edition": {
"type": "string"
},
"host": {
"type": "string"
},
Expand Down
1 change: 1 addition & 0 deletions src/commands/emulators-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
.option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
.option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
.option(commandUtils.FLAG_VERBOSITY, commandUtils.DESC_VERBOSITY)
.option(commandUtils.FLAG_EDITION, commandUtils.DESC_EDITION)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.action((options: Options) => {
const killSignalPromise = commandUtils.shutdownWhenKilled(options);
Expand All @@ -35,7 +36,7 @@
try {
({ deprecationNotices } = await controller.startAll(options));
await sendVSCodeMessage({ message: VSCODE_MESSAGE.EMULATORS_STARTED });
} catch (e: any) {

Check warning on line 39 in src/commands/emulators-start.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
await sendVSCodeMessage({ message: VSCODE_MESSAGE.EMULATORS_START_ERRORED });
await controller.cleanShutdown();
throw e;
Expand All @@ -61,7 +62,7 @@
if (info) {
reservedPorts.push(info.port);
}
controller.filterEmulatorTargets(options).forEach((emulator: Emulators) => {

Check warning on line 65 in src/commands/emulators-start.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `{ only: string; config: any; }`
reservedPorts.push(...(EmulatorRegistry.getInfo(emulator)?.reservedPorts || []));
});
}
Expand Down Expand Up @@ -94,7 +95,7 @@

emulatorsTable.push(
...controller
.filterEmulatorTargets(options)

Check warning on line 98 in src/commands/emulators-start.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `{ only: string; config: any; }`
.map((emulator) => {
const emulatorName = Constants.description(emulator).replace(/ emulator/i, "");
const isSupportedByUi = EMULATORS_SUPPORTED_BY_UI.includes(emulator);
Expand Down Expand Up @@ -126,9 +127,9 @@
extensionsTable = extensionsEmulatorInstance.extensionsInfoTable();
}
const hubInfo = EmulatorRegistry.getInfo(Emulators.HUB);
logger.info(`\n${successMessageTable}

Check warning on line 130 in src/commands/emulators-start.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "Table" of template literal expression

${emulatorsTable}

Check warning on line 132 in src/commands/emulators-start.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "Table" of template literal expression
${
hubInfo
? clc.blackBright(` Emulator Hub host: ${hubInfo.host} port: ${hubInfo.port}`)
Expand Down
3 changes: 3 additions & 0 deletions src/emulator/commandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
`"${FLAG_EXPORT_ON_EXIT_NAME}" must be used with "${FLAG_IMPORT}"` +
` or provide a dir directly to "${FLAG_EXPORT_ON_EXIT}"`;

export const FLAG_EDITION = "--edition [edition]";
export const DESC_EDITION = "start emulator in either standard or enterprise edition.";

export const EXPORT_ON_EXIT_CWD_DANGER = `"${FLAG_EXPORT_ON_EXIT_NAME}" must not point to the current directory or parents. Please choose a new/dedicated directory for exports.`;

export const FLAG_VERBOSITY_NAME = "--log-verbosity";
Expand Down Expand Up @@ -82,7 +85,7 @@
* specify an emulator address.
*/
export function printNoticeIfEmulated(
options: any,

Check warning on line 88 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
emulator: Emulators.DATABASE | Emulators.FIRESTORE,
): void {
if (emulator !== Emulators.DATABASE && emulator !== Emulators.FIRESTORE) {
Expand Down Expand Up @@ -110,7 +113,7 @@
* an emulator port that the command actually talks to production.
*/
export async function warnEmulatorNotSupported(
options: any,

Check warning on line 116 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
emulator: Emulators.DATABASE | Emulators.FIRESTORE,
): Promise<void> {
if (emulator !== Emulators.DATABASE && emulator !== Emulators.FIRESTORE) {
Expand All @@ -137,8 +140,8 @@
}
}

export async function errorMissingProject(options: any): Promise<void> {

Check warning on line 143 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 143 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
if (!options.project) {

Check warning on line 144 in src/emulator/commandUtils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .project on an `any` value
throw new FirebaseError(
"Project is not defined. Either use `--project` or use `firebase use` to set your active project.",
);
Expand Down
21 changes: 21 additions & 0 deletions src/emulator/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,26 @@ export async function startAll(
const firestoreAddr = legacyGetFirstAddr(Emulators.FIRESTORE);
const websocketPort = legacyGetFirstAddr("firestore.websocket").port;

if (options.edition !== undefined) {
utils.assertIsString(options.edition, "edition");
}
const edition = (
(options.edition as string) ||
options.config.src.emulators?.firestore?.edition ||
"standard"
).toLowerCase();
if (edition !== "standard" && edition !== "enterprise") {
throw new FirebaseError(
"The Firestore emulator edition must be either 'standard' or 'enterprise'.",
{ exit: 1 },
);
}

const args: FirestoreEmulatorArgs = {
host: firestoreAddr.host,
port: firestoreAddr.port,
websocket_port: websocketPort,
"database-edition": edition,
project_id: projectId,
auto_download: true,
};
Expand Down Expand Up @@ -730,6 +746,11 @@ export async function startAll(

const firestoreEmulator = new FirestoreEmulator(args);
await startEmulator(firestoreEmulator);
firestoreLogger.logLabeled(
"SUCCESS",
Emulators.FIRESTORE,
`Firestore Emulator was started in ${edition} edition.`,
);
firestoreLogger.logLabeled(
"SUCCESS",
Emulators.FIRESTORE,
Expand Down
1 change: 1 addition & 0 deletions src/emulator/downloadableEmulators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ const Commands: { [s in DownloadableEmulators]: DownloadableEmulatorCommand } =
"host",
"rules",
"websocket_port",
"database-edition",
"functions_emulator",
"seed_from_export",
"project_id",
Expand Down
1 change: 1 addition & 0 deletions src/emulator/firestoreEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface FirestoreEmulatorArgs {
port?: number;
host?: string;
websocket_port?: number;
"database-edition"?: string;
project_id?: string;
rules?: string;
functions_emulator?: string;
Expand Down
1 change: 1 addition & 0 deletions src/firebaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export type EmulatorsConfig = {
host?: string;
port?: number;
websocketPort?: number;
edition?: string;
};
functions?: {
host?: string;
Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface BaseOptions {
// Emulator specific import/export options
exportOnExit?: boolean | string;
import?: string;
edition?: string;

isMCP?: boolean;

Expand Down
Loading