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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Fixed an issue where functions deployments would silently fail (#6989)
- Renamed Data Connect displayed text to SQL Connect
81 changes: 39 additions & 42 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import { reconcileStudioFirebaseProject } from "./management/studio";
import { requireAuth } from "./requireAuth";
import { Options } from "./options";
import { logger, useConsoleLoggers } from "./logger";
import { useConsoleLoggers } from "./logger";
import { isFirebaseStudio } from "./env";

export interface CommandModule {
load: () => void;
}

export function isCommandModule(value: unknown): value is CommandModule {

Check warning on line 25 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
return typeof value === "function" && typeof (value as any).load === "function";

Check warning on line 26 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 26 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

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

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -38,7 +38,7 @@
export interface CLIClient {
cli: CommanderStatic;
errorOut: (e: Error) => void;
[key: string]: any;

Check warning on line 41 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

/**
Expand Down Expand Up @@ -78,7 +78,7 @@

/**
* Sets an alias for a command.
* @param aliases an alternativre name for the command. Users will be able to call the command via this name.

Check warning on line 81 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected @param names to be "alias". Got "aliases"
* @return the command, for chaining.
*/
alias(alias: string): Command {
Expand All @@ -87,10 +87,10 @@
}

/**
* Sets any options for the command.

Check warning on line 90 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @example
* command.option("-d, --debug", "turn on debugging", false)

Check warning on line 93 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected no lines between tags
*
* @param args the commander-style option definition.
* @return the command, for chaining.
Expand All @@ -102,10 +102,10 @@
}

/**
* Sets up --force flag for the command.

Check warning on line 105 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param message overrides the description for --force for this command
* @returns the command, for chaining

Check warning on line 108 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
withForce(message?: string): Command {
this.options.push(["-f, --force", message || "automatically accept all interactive prompts"]);
Expand All @@ -129,7 +129,7 @@
*
* This text is displayed when:
* - the `--help` flag is passed to the command, or
* - the `help <command>` command is used.

Check warning on line 132 in src/command.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param t the human-readable help text.
* @return the command, for chaining.
Expand Down Expand Up @@ -236,28 +236,28 @@
});
}
const duration = Math.floor((process.uptime() - start) * 1000);
try {
const trackSuccess = trackGA4(
"command_execution",
{
command_name: this.name,
result: "success",
interactive: getInheritedOption(options, "nonInteractive") ? "false" : "true",
},
duration,
);
const tracks = [trackSuccess];
if (isEmulator) {
tracks.push(
const trackSuccess = trackGA4(
"command_execution",
{
command_name: this.name,
result: "success",
interactive: getInheritedOption(options, "nonInteractive") ? "false" : "true",
},
duration,
);
if (!isEmulator) {
await withTimeout(5000, trackSuccess);
} else {
await withTimeout(
5000,
Promise.all([
trackSuccess,
trackEmulator("command_success", {
command_name: this.name,
duration,
}),
);
}
await withTimeout(1000, Promise.all(tracks));
} catch (gaErr) {
logger.debug("Analytics tracking failed during success path:", gaErr);
]),
);
}
process.exit();
})
Expand All @@ -278,30 +278,27 @@
});
}
const duration = Math.floor((process.uptime() - start) * 1000);
try {
const trackError = trackGA4(
"command_execution",
{
command_name: this.name,
result: "error",
interactive: getInheritedOption(options, "nonInteractive") ? "false" : "true",
},
duration,
);
const tracks = [trackError];
if (isEmulator) {
tracks.push(
trackEmulator("command_error", {
await withTimeout(
5000,
Promise.all([
trackGA4(
"command_execution",
{
command_name: this.name,
duration,
error_type: err?.exit === 1 ? "user" : "unexpected",
}),
);
}
await withTimeout(1000, Promise.all(tracks));
} catch (gaErr) {
logger.debug("Analytics tracking failed during error path:", gaErr);
}
result: "error",
interactive: getInheritedOption(options, "nonInteractive") ? "false" : "true",
},
duration,
),
isEmulator
? trackEmulator("command_error", {
command_name: this.name,
duration,
error_type: err.exit === 1 ? "user" : "unexpected",
})
: Promise.resolve(),
]),
);

client.errorOut(err);
});
Expand Down
12 changes: 6 additions & 6 deletions src/commands/dataconnect-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ import { FirebaseError } from "../error";
type CompileOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:compile")
.description("compile your Data Connect schema and connector config and GQL files.")
.description("compile your SQL Connect schema and connector config and GQL files.")
.option(
"--service <serviceId>",
"the serviceId of the Data Connect service. If not provided, compiles all services.",
"the serviceId of the SQL Connect service. If not provided, compiles all services.",
)
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.action(async (options: CompileOptions) => {
const projectId = getProjectId(options);

const config = options.config;
if (!config || !config.has("dataconnect")) {
throw new FirebaseError(
`No Data Connect project directory found. Please run ${clc.bold("firebase init dataconnect")} to set it up first.`,
`No SQL Connect project directory found. Please run ${clc.bold("firebase init dataconnect")} to set it up first.`,
);
}

Expand All @@ -41,7 +41,7 @@ export const command = new Command("dataconnect:compile")
);

if (!serviceInfos.length) {
throw new FirebaseError("No Data Connect services found to compile.");
throw new FirebaseError("No SQL Connect services found to compile.");
}

for (const serviceInfo of serviceInfos) {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const command = new Command("dataconnect:compile")

logLabeledSuccess(
"dataconnect",
`Successfully compiled Data Connect service: ${clc.bold(serviceInfo.dataConnectYaml.serviceId)}`,
`Successfully compiled SQL Connect service: ${clc.bold(serviceInfo.dataConnectYaml.serviceId)}`,
);
}
});
2 changes: 1 addition & 1 deletion src/commands/dataconnect-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let stdinUsedFor: string | undefined = undefined;

export const command = new Command("dataconnect:execute [file] [operationName]")
.description(
"execute a Data Connect query or mutation. If FIREBASE_DATACONNECT_EMULATOR_HOST is set (such as during 'firebase emulator:exec', executes against the emulator instead.",
"execute a SQL Connect query or mutation. If FIREBASE_DATACONNECT_EMULATOR_HOST is set (such as during 'firebase emulator:exec', executes against the emulator instead.",
)
.option(
"--service <serviceId>",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/dataconnect-sdk-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import { EmulatorHub } from "../emulator/hub";
type GenerateOptions = Options & { watch?: boolean; service?: string; location?: string };

export const command = new Command("dataconnect:sdk:generate")
.description("generate typed SDKs to use Data Connect in your apps")
.description("generate typed SDKs to use SQL Connect in your apps")
.option(
"--service <serviceId>",
"the serviceId of the Data Connect service. If not provided, generates SDKs for all services.",
"the serviceId of the SQL Connect service. If not provided, generates SDKs for all services.",
)
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.option(
"--watch",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/dataconnect-services-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Table from "cli-table3";

// TODO: Update this command to also list secondary schema information.
export const command = new Command("dataconnect:services:list")
.description("list all deployed Data Connect services")
.description("list all deployed SQL Connect services")
.before(requirePermissions, [
"dataconnect.services.list",
"dataconnect.schemas.list",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/dataconnect-sql-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ type DiffOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:sql:diff")
.description(
"display the differences between the local Data Connect schema and your CloudSQL database's schema",
"display the differences between the local SQL Connect schema and your CloudSQL database's schema",
)
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.option("--service <serviceId>", "the serviceId of the SQL Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, [
"firebasedataconnect.services.list",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/dataconnect-sql-grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export const command = new Command("dataconnect:sql:grant")
"-E, --email <email>",
"The email of the user or service account we would like to grant the role to.",
)
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.option("--service <serviceId>", "the serviceId of the SQL Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, ["firebasedataconnect.services.list"])
.before(requireAuth)
Expand Down
8 changes: 4 additions & 4 deletions src/commands/dataconnect-sql-migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { mainSchema, mainSchemaYaml } from "../dataconnect/types";
type MigrateOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:sql:migrate")
.description("migrate your CloudSQL database's schema to match your local Data Connect schema")
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.description("migrate your CloudSQL database's schema to match your local SQL Connect schema")
.option("--service <serviceId>", "the serviceId of the SQL Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, [
"firebasedataconnect.services.list",
Expand Down Expand Up @@ -53,7 +53,7 @@ export const command = new Command("dataconnect:sql:migrate")
if (diffs.length) {
logLabeledSuccess(
"dataconnect",
`Database schema sucessfully migrated! Run 'firebase deploy' to deploy your new schema to your Data Connect service.`,
`Database schema sucessfully migrated! Run 'firebase deploy' to deploy your new schema to your SQL Connect service.`,
);
} else {
logLabeledSuccess("dataconnect", "Database schema is already up to date!");
Expand Down
4 changes: 2 additions & 2 deletions src/commands/dataconnect-sql-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type SetupOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:sql:setup")
.description("set up your CloudSQL database")
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.option("--service <serviceId>", "the serviceId of the SQL Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, [
"firebasedataconnect.services.list",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/dataconnect-sql-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ type ShellOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:sql:shell")
.description(
"start a shell connected directly to your Data Connect service's linked CloudSQL instance",
"start a shell connected directly to your SQL Connect service's linked CloudSQL instance",
)
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.option("--service <serviceId>", "the serviceId of the SQL Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
"the location of the SQL Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, ["firebasedataconnect.services.list", "cloudsql.instances.connect"])
.before(requireAuth)
Expand Down Expand Up @@ -134,7 +134,7 @@ export const command = new Command("dataconnect:sql:shell")
await conn.query(`SET search_path TO "${schemaName}"`);

logger.info(`Logged in as ${username}`);
logger.info(clc.cyan("Welcome to Data Connect Cloud SQL Shell"));
logger.info(clc.cyan("Welcome to SQL Connect Cloud SQL Shell"));
logger.info(
clc.gray(
"Type your your SQL query or '.exit' to quit, queries should end with ';' or add empty line to execute.",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let choices: {
}[] = [
{
value: "dataconnect",
name: "Data Connect: Set up a Firebase Data Connect service",
name: "SQL Connect: Set up a Firebase SQL Connect service",
checked: false,
},
{
Expand Down Expand Up @@ -90,7 +90,7 @@ let choices: {
},
{
value: "dataconnect:sdk",
name: "Data Connect: Set up a generated SDK for your Firebase Data Connect service",
name: "SQL Connect: Set up a generated SDK for your Firebase SQL Connect service",
checked: false,
hidden: true,
},
Expand All @@ -104,7 +104,7 @@ let choices: {
if (isEnabled("fdcwebhooks")) {
choices.push({
value: "dataconnect:resolver",
name: "Data Connect: Set up a custom resolver for your Firebase Data Connect service",
name: "SQL Connect: Set up a custom resolver for your Firebase SQL Connect service",
checked: false,
hidden: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LINKS: Link[] = [
{ name: "Crash Reporting", arg: "crash", consolePath: "/crashlytics" },
{ name: "Database: Data", arg: "database", consolePath: "/database/data" },
{ name: "Database: Rules", arg: "database:rules", consolePath: "/database/rules" },
{ name: "Data Connect", arg: "dataconnect", consolePath: "/dataconnect" },
{ name: "SQL Connect", arg: "dataconnect", consolePath: "/dataconnect" },
{ name: "Docs", arg: "docs", url: "https://firebase.google.com/docs" },
{ name: "Dynamic Links", arg: "links", consolePath: "/durablelinks" },
{ name: "Extensions", arg: "extensions", consolePath: "/extensions" },
Expand Down
2 changes: 1 addition & 1 deletion src/commands/setup-emulators-dataconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const command = new Command(`setup:emulators:${NAME}`)
await downloadIfNecessary(NAME);
if (!options.config) {
logger.info(
"Not currently in a Firebase project directory. Run this command from a project directory to configure the Data Connect emulator.",
"Not currently in a Firebase project directory. Run this command from a project directory to configure the SQL Connect emulator.",
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dataconnect/ensureApis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("ensureApis", () => {
sinon.verifyAndRestore();
});

it("should ensure Data Connect and Cloud SQL Admin APIs are enabled", async () => {
it("should ensure SQL Connect and Cloud SQL Admin APIs are enabled", async () => {
ensureStub.resolves();
await apis.ensureApis("my-project");
expect(ensureStub).to.be.calledWith("my-project", api.dataconnectOrigin(), "dataconnect");
Expand Down
4 changes: 2 additions & 2 deletions src/dataconnect/freeTrial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export async function checkFreeTrialInstanceUsed(projectId: string): Promise<boo
}

export function upgradeInstructions(projectId: string, trialUsed: boolean): string {
return `To provision a ${trialUsed ? "paid CloudSQL Postgres instance" : "CloudSQL Postgres instance on the Firebase Data Connect no-cost trial"}:
return `To provision a ${trialUsed ? "paid CloudSQL Postgres instance" : "CloudSQL Postgres instance on the Firebase SQL Connect no-cost trial"}:
1. Please upgrade to the pay-as-you-go (Blaze) billing plan. Visit the following page:
https://console.firebase.google.com/project/${projectId}/usage/details
2. Run ${clc.bold("firebase deploy --only dataconnect")} to deploy your Data Connect service.`;
2. Run ${clc.bold("firebase deploy --only dataconnect")} to deploy your SQL Connect service.`;
}
10 changes: 5 additions & 5 deletions src/dataconnect/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { readFileFromDirectory, wrappedSafeLoad } from "../utils";
import { DataConnectMultiple } from "../firebaseConfig";
import * as experiments from "../experiments";

/** Picks exactly one Data Connect service based on flags. */
/** Picks exactly one SQL Connect service based on flags. */
export async function pickOneService(
projectId: string,
config: Config,
Expand All @@ -39,7 +39,7 @@ export async function pickOneService(
return services[0];
}

/** Picks Data Connect services based on flags. */
/** Picks SQL Connect services based on flags. */
export async function pickServices(
projectId: string,
config: Config,
Expand All @@ -49,8 +49,8 @@ export async function pickServices(
const serviceInfos = await loadAll(projectId, config);
if (serviceInfos.length === 0) {
throw new FirebaseError(
"No Data Connect services found in firebase.json. " +
`\nYou can run ${clc.bold("firebase init dataconnect")} to add a Data Connect service.`,
"No SQL Connect services found in firebase.json. " +
`\nYou can run ${clc.bold("firebase init dataconnect")} to add a SQL Connect service.`,
);
}

Expand All @@ -71,7 +71,7 @@ export async function pickServices(
}

/**
* Loads all Data Connect service configurations from the firebase.json file.
* Loads all SQL Connect service configurations from the firebase.json file.
*/
export async function loadAll(projectId: string, config: Config): Promise<ServiceInfo[]> {
const serviceCfgs = readFirebaseJson(config);
Expand Down
Loading
Loading