-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PoC initial api calls * moving list functionality into helper method and added unit tests * update changelog * fix lint * adding jsdoc comment * Remove HttpsTrigger.allowInsecure (#3733) * Remove HttpsTrigger.allowInsecure * Formatter * Create new endpoint type definition (#3731) * Create new endpoint type definition * Fix build breaks * Remove HttpsTrigger.allowInsecure * Formatter * Add type discrimiation functions and fix break * Fix bug where CLI would crash when customers upload an empty functions project (#3705) * Fix bug where CLI would crash when customers upload an empty functions project * Changelog * Add support for --non-interactive to ext:install, and support updating existing instances (#3710) * started adding noninteractive support to ext:install * Refactoring ext-install to support non-interactive runs and offer updates to existing instances * self review * pr fixes * update changelog * moving list function to backend and table creation to command, added unit tests for comparing functions * adding listFunctions.ts back and move compare functions to backend * Update CHANGELOG.md Co-authored-by: Bryan Kendall <bkend@google.com> * fixing pr comments Co-authored-by: Thomas Bouldin <inlined@users.noreply.github.com> Co-authored-by: joehan <joehanley@google.com> Co-authored-by: Bryan Kendall <bkend@google.com>
- Loading branch information
1 parent
17f8fe9
commit 88a3173
Showing
8 changed files
with
344 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- `ext:install` now supports `--force` and `--non-interactive` flags. | ||
- Fixes a crash when customers deploy an empty Cloud Functions project (#3705) | ||
- Fixes (and implements) `--no-authorized-domains`, skipping syncing with Firebase Auth, when deploying to a Firebase Hosting channel (#3740). | ||
- Adds a command (`functions:list`) for listing all functions in the Firebase project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Command } from "../command"; | ||
import { FirebaseError } from "../error"; | ||
import * as args from "../deploy/functions/args"; | ||
import { needProjectId } from "../projectUtils"; | ||
import { Options } from "../options"; | ||
import { requirePermissions } from "../requirePermissions"; | ||
import * as backend from "../deploy/functions/backend"; | ||
import { listFunctions } from "../functions/listFunctions"; | ||
import { previews } from "../previews"; | ||
import { logger } from "../logger"; | ||
import Table = require("cli-table"); | ||
|
||
export default new Command("functions:list") | ||
.description("list all deployed functions in your Firebase project") | ||
.before(requirePermissions, ["cloudfunctions.functions.list"]) | ||
.action(async (options: Options) => { | ||
try { | ||
const context = { | ||
projectId: needProjectId(options), | ||
} as args.Context; | ||
const functionList = await listFunctions(context); | ||
const table = previews.functionsv2 | ||
? new Table({ | ||
head: ["Function", "Version", "Trigger", "Location", "Memory", "Runtime"], | ||
style: { head: ["yellow"] }, | ||
}) | ||
: new Table({ | ||
head: ["Function", "Trigger", "Location", "Memory", "Runtime"], | ||
style: { head: ["yellow"] }, | ||
}); | ||
for (const fnSpec of functionList.functions) { | ||
const trigger = backend.isEventTrigger(fnSpec.trigger) ? fnSpec.trigger.eventType : "https"; | ||
const availableMemoryMb = fnSpec.availableMemoryMb || "---"; | ||
const entry = previews.functionsv2 | ||
? [ | ||
fnSpec.entryPoint, | ||
fnSpec.platform === "gcfv2" ? "v2" : "v1", | ||
trigger, | ||
fnSpec.region, | ||
availableMemoryMb, | ||
fnSpec.runtime, | ||
] | ||
: [fnSpec.entryPoint, trigger, fnSpec.region, availableMemoryMb, fnSpec.runtime]; | ||
table.push(entry); | ||
} | ||
logger.info(table.toString()); | ||
return functionList; | ||
} catch (err) { | ||
throw new FirebaseError(`Failed to list functions ${err.message}`, { | ||
exit: 1, | ||
original: err, | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as backend from "../deploy/functions/backend"; | ||
import { previews } from "../previews"; | ||
import { Context } from "../deploy/functions/args"; | ||
|
||
/** | ||
* Lists all functions of the Firebase project in order | ||
* @param context the Context of the project | ||
* @returns a mapping that contains an array of {@link FunctionSpec} in order under the 'functions' key | ||
*/ | ||
export async function listFunctions( | ||
context: Context | ||
): Promise<{ functions: backend.FunctionSpec[] }> { | ||
const functionSpecs = (await backend.existingBackend(context, true)).cloudFunctions; | ||
functionSpecs.sort(backend.compareFunctions); | ||
return { functions: functionSpecs }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.