-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding dataconnect:compile command #9727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+77
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ad7d10
Adding dataconnect:compile command
joehan 0ef377e
Remove unused import
joehan e8923e8
Merge branch 'main' into jh-fdc-compile
joehan 496e428
pr fixes
joehan 24216c3
Merge branch 'main' into jh-fdc-compile
joehan e556fcf
formats
joehan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 +1,3 @@ | ||
| - Added `firebase dataconnect:compile` command. | ||
| - Loads experiments earlier in CLI startup so they can be used earlier. (#9797) | ||
| - Fixed issue where Storage security rules is overwritten when running `firebase init storage`. (#8170) |
This file contains hidden or 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,75 @@ | ||
| import * as clc from "colorette"; | ||
|
|
||
| import { Command } from "../command"; | ||
| import { Options } from "../options"; | ||
| import { DataConnectEmulator } from "../emulator/dataconnectEmulator"; | ||
| import { getProjectId } from "../projectUtils"; | ||
| import { pickServices } from "../dataconnect/load"; | ||
| import { getProjectDefaultAccount } from "../auth"; | ||
| import { logLabeledSuccess } from "../utils"; | ||
| import { EmulatorHub } from "../emulator/hub"; | ||
| import { handleBuildErrors } from "../dataconnect/build"; | ||
| 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.") | ||
| .option( | ||
| "--service <serviceId>", | ||
| "the serviceId of the Data 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.", | ||
| ) | ||
| .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.`, | ||
| ); | ||
| } | ||
|
|
||
| const serviceInfos = await pickServices( | ||
| projectId || EmulatorHub.MISSING_PROJECT_PLACEHOLDER, | ||
| config, | ||
| options.service, | ||
| options.location, | ||
| ); | ||
|
|
||
| if (!serviceInfos.length) { | ||
| throw new FirebaseError("No Data Connect services found to compile."); | ||
| } | ||
|
|
||
| for (const serviceInfo of serviceInfos) { | ||
| const configDir = serviceInfo.sourceDirectory; | ||
| const account = getProjectDefaultAccount(options.projectRoot); | ||
|
|
||
| // 1. Build (Validate Schema/Connectors + Generate .dataconnect) | ||
| const buildArgs = { | ||
| configDir, | ||
| projectId, // Optional, passes to fdc build --project_id if present | ||
| account, | ||
| }; | ||
|
|
||
| const buildResult = await DataConnectEmulator.build(buildArgs); | ||
|
|
||
| if (buildResult?.errors?.length) { | ||
| await handleBuildErrors(buildResult.errors, options.nonInteractive, options.force, false); | ||
| } | ||
|
|
||
| // 2. Generate SDKs | ||
| await DataConnectEmulator.generate({ | ||
| configDir, | ||
| account, | ||
| }); | ||
|
|
||
| logLabeledSuccess( | ||
| "dataconnect", | ||
| `Successfully compiled Data Connect service: ${clc.bold(serviceInfo.dataConnectYaml.serviceId)}`, | ||
| ); | ||
| } | ||
| }); | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.