Repository navigation
Begin typing config and options - #3420
Conversation
| @@ -0,0 +1,245 @@ | |||
| "use strict"; | |||
There was a problem hiding this comment.
The logic in this file is 100% unmodified besides the addition of a new get src() function which does a cast.
It seems GitHub couldn't recognize the TS-ification as a clean diff.
There was a problem hiding this comment.
Certainly not required, but it would be great to modernize this file a bit as well. Theres a lot of old conventions in here that could be switched easily - private methods that start with __, lots of lodash that can be switched for native methods, etc.
There was a problem hiding this comment.
I was planning on doing this in a follow-up so that the diff is clear. This is a super critical file and I don't want to mess with it any more than I need to all at once.
| * @param options The CLI options object. | ||
| */ | ||
| export default async function (context: any, options: any): Promise<void> { | ||
| export default async function (context: any, options: Options): Promise<void> { |
There was a problem hiding this comment.
This is the only file where I am actually using Options, Config, and FirebaseConfig types. It's a proof of concept.
| @@ -0,0 +1,245 @@ | |||
| "use strict"; | |||
There was a problem hiding this comment.
Certainly not required, but it would be great to modernize this file a bit as well. Theres a lot of old conventions in here that could be switched easily - private methods that start with __, lots of lodash that can be switched for native methods, etc.
| @@ -0,0 +1,8 @@ | |||
| import { Config } from "./config"; | |||
|
|
|||
| export interface Options { | |||
There was a problem hiding this comment.
@inlined has been working toward a similar goal for the functions deploy codepath: https://github.com/firebase/firebase-tools/blob/master/src/deploy/functions/args.ts#L17. I agree with the approach of trying to standardize these types across the whole codebase, but I think there are some conflicts between these types that should be resolved.
Added him as a reviewer too, since he spent a good bit of time thinking about this recently & may have some insights.
There was a problem hiding this comment.
Oh nice, I will definitely unify this.
bkendall
left a comment
There was a problem hiding this comment.
I like the idea of this. Joe/Thomas have been in this codebase more than I have recently, so it's good for them to take a look and help join efforts. Thanks for taking on the challenge!
inlined
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the initiative here. I'd especially love getting rid of set/get.
For Context, wdyt about the coding style I used in backend.ts where individual libraries will extend the object internally w/ a private interface? I took the inspiration from Golang's context.Context where each library uses some key in context to be a private implementation detail.
* Unbreak build (#3463) * Unbreak build * linter changed its mind * firestore:delete getConfirmationMessage should include current project (#3457) The firestore:delete command should notify the user of the current project. This should help users minimize chances of accidental deletions when switching between projects. * Add asia-southeast1 to RTDB CLI (#3460) * Fix init database without projectId (#3446) * Fix init database (#3445) * Added value check for "feature" parameter in init (#3449) When the optional feature parameter is provided in a `firebase init [feature]` command, this checks that its value is a valid choice before attempting any other initialization. * Bump trim-newlines from 3.0.0 to 3.0.1 (#3471) Bumps [trim-newlines](https://github.com/sindresorhus/trim-newlines) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/sindresorhus/trim-newlines/releases) - [Commits](https://github.com/sindresorhus/trim-newlines/commits) --- updated-dependencies: - dependency-name: trim-newlines dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump ws from 7.2.3 to 7.4.6 (#3428) * add node16 to tests (#3462) * Import/export download tokens (#3444) * Fixes Storage Emulator startup errors (#3478) * Bump normalize-url from 4.5.0 to 4.5.1 (#3476) Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/sindresorhus/normalize-url/releases) - [Commits](https://github.com/sindresorhus/normalize-url/commits) --- updated-dependencies: - dependency-name: normalize-url dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fixes download tokens missing when uploading files via Cloud SDK (#3479) * Follow up to #3420 (#3437) * Increase waitForPortClosed timeout to 60s (#3483) * Added validation logic to allow selectResource param type in extensions.yaml (#3489) * Fix background functions in functions:shell (#3491) * 9.13.0 * [firebase-release] Removed change log and reset repo after 9.13.0 release * Fix ext:update issue where local extension is incorrectly inferred as published extension (#3499) * Add missing changelog entry for #3499 (#3500) * Fix init hosting:github (#3503) * 9.13.1 * [firebase-release] Removed change log and reset repo after 9.13.1 release * Avoid emulator data loss when there an error during export (#3511) * Ask before overwriting storage.rules (#3510) * Update CONTRIBUTING.md (#3513) added note to run `npm install` before `npm link` the first time * Release Cloud Firestore Emulator v1.13.0. (#3515) * Basic create support This change adds support for `firebase --open-sesame golang`. After running this command, `firebase init` will support Go 1.13 as a langauge for Cloud Functions. Limitations: 1. .gitignore is empty 2. Customers cannot mix Node and Go code (WAI) 3. There is little validation being done of customer code 4. The actual deployed function params are hard coded; SDK incoming * Use vendoring to fetch SDK * Update sample code * Simplify unarchive pipe * TSLint * PR feedback * Delete Container Registry images left after Functions deployment (#3439) * Delete Container Registry images left after Functions deployment * Simplify caching * Improve error handling and report next steps to users * lint fixes * Fix typo * Increase max function ID length to 63 (#3521) * Fix crash when deploying zero functions. (#3520) Previously most code read the desired backend from `options.config.get("functions.backend")` which was set to the empty backend correctly. Code that depended on payload.functions.backend crashed because payload.functions was null when the backend was empty. Since optins.config should be firebase.json data, this change normalizes on payload.functions.backend and ensures that it is never null while options.config.get('functions') is present (i.e. when the customer has functions to deploy). * Use proper replace and get commands * Update changelog with my recent pushes (#3522) * 9.14.0 * [firebase-release] Removed change log and reset repo after 9.14.0 release * Bump glob-parent from 5.0.0 to 5.1.2 (#3472) * Added deferred provisioning check for Storage and Authentication during extension install (#3497) Implemented provisioning check helper which checks whether products use by the extension are fully provisioned. * Generate JSON Schema for firebase.json (#3505) * Fetch from newly public GH repo * PR feedback * Format Co-authored-by: davidbrenner <[email protected]> Co-authored-by: Fred Zhang <[email protected]> Co-authored-by: Sam Stern <[email protected]> Co-authored-by: Andrew Heard <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bryan Kendall <[email protected]> Co-authored-by: Abe Haskins <[email protected]> Co-authored-by: Enrico Graziani <[email protected]> Co-authored-by: Pavel Jbanov <[email protected]> Co-authored-by: Google Open Source Bot <[email protected]> Co-authored-by: huangjeff5 <[email protected]> Co-authored-by: davidbielik <[email protected]> Co-authored-by: Yuchen Shi <[email protected]>
Description
Begin to address #1409 and make the use of
optionsandoptions.configaround the codebase much more typesafe.If we're happy with this approach I will send another PR to slowly introduce the use of these types throughout the codebase. As a proof of concept I used them in exactly one place:
src/deploy/firestore/release.ts.Future work could include turning the TS into a JSON Schema and then using it to actually validate the JSON at load time.
Scenarios Tested
Unit tests should cover this.
Sample Commands
N/A