Skip to content

Conversation

inlined
Copy link
Member

@inlined inlined commented Apr 11, 2024

Improves FAH secrets set command with AST-based YAML editing.

Replaces js-yaml in our codebase with yaml for consistency (though nowhere else needs the AST API). Unfortunately, js-yaml is still a dependency for our tooling, so it's still in package-lock.json

Want review from Tony for FAH stuff and Joe for CLI dependency changes + double checking extensions changes

@inlined inlined requested review from tonyjhuang and joehan April 11, 2024 14:37
Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, change looks good, extensions code looks fine, and yaml seems like a clearly better library to use than js-yaml. I'd love if you could get rid of the usage of NodeType though.


import * as fs from "../fsutils";
import { NodeType } from "yaml/dist/nodes/Node";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an internal type for the library, and they explicitly don't use it in their public API. https://github.com/eemeli/yaml/blob/main/src/public-api.ts

Do you need this type? Could this be refactored not to use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an oversight for it not to be exported. AFAICT none of the types are exported (note in public-api, Node is imported, and is a mandatory base class of Document<T, Strict> but is not exported in that file either.

Frankly, the type annotations are a mess; I had it working and removed it all. I could hypothetically remove the API call, but it would instead involve yet more casting as any/unknown.

aalej and others added 4 commits April 11, 2024 13:11
* Fix --only firestore:rules,firestore:indexes edge case

* Added changelog entry
…tions (#6990)

* fix the falsy value from not being calculated

* add changelog entry
@@ -55,12 +56,45 @@ export function yamlPath(cwd: string): string | null {
}

/** Load apphosting.yaml */
export function load(yamlPath: string): Config {
export function load(yamlPath: string): yaml.Document {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit but these methods all feel like good candidates to wrap in a yaml.ts that can be shared across firebase products.

Especially the main logic in getEnv and setEnv could likely be genericized and get/setEnv can use those helpers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.