diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e7d1dd8f3..75ad25421c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,5 @@ - Fixed bug where `esbuild` execution was throwing an error saying "Command line too long" on Windows (#7250, #6193). (#7395) - Automatically detect app platform during `init dataconnect:sdk`. - Support `sharp` ^0.33.x for web frameworks. (#7517) -- Update Firebase Data Connect toolkit to v1.3.4, which supports `offset`, cascade delete support, always all foreign fields and multiple generated SDK options. (#7545) +- Updated Firebase Data Connect toolkit to v1.3.4, which supports `offset`, cascade delete support, always all foreign fields and multiple generated SDK options. (#7545) +- Updated Data Connect SDK options default to avoid duplicate output path. (#7545) diff --git a/src/init/features/dataconnect/sdk.ts b/src/init/features/dataconnect/sdk.ts index 36d02f46b09..282bffd051c 100644 --- a/src/init/features/dataconnect/sdk.ts +++ b/src/init/features/dataconnect/sdk.ts @@ -21,7 +21,7 @@ import { } from "../../../dataconnect/types"; import { DataConnectEmulator } from "../../../emulator/dataconnectEmulator"; import { FirebaseError } from "../../../error"; -import { camelCase, snakeCase } from "lodash"; +import { camelCase, snakeCase, upperFirst } from "lodash"; import { logSuccess, logBullet } from "../../../utils"; export type SDKInfo = { @@ -110,10 +110,11 @@ async function askQuestions(setup: Setup, config: Config): Promise { newConnectorYaml.generate.swiftSdk?.outputDir || path.relative( connectorInfo.directory, - path.join(appDir, `generated/${newConnectorYaml.connectorId}`), + path.join(appDir, `generated/${newConnectorYaml.connectorId}/swift`), ); const pkg = - newConnectorYaml.generate.swiftSdk?.package ?? camelCase(newConnectorYaml.connectorId); + newConnectorYaml.generate.swiftSdk?.package ?? + upperFirst(camelCase(newConnectorYaml.connectorId)); const swiftSdk = { outputDir, package: pkg }; newConnectorYaml.generate.swiftSdk = swiftSdk; displayIOSWarning = true; @@ -124,7 +125,7 @@ async function askQuestions(setup: Setup, config: Config): Promise { newConnectorYaml.generate.javascriptSdk?.outputDir || path.relative( connectorInfo.directory, - path.join(appDir, `generated/${newConnectorYaml.connectorId}`), + path.join(appDir, `generated/${newConnectorYaml.connectorId}/javascript`), ); const pkg = newConnectorYaml.generate.javascriptSdk?.package ?? @@ -150,17 +151,16 @@ async function askQuestions(setup: Setup, config: Config): Promise { // app/src/main/kotlin and app/src/main/java are conventional for Android, // but not required or enforced. If one of them is present (preferring the // "kotlin" directory), use it. Otherwise, fall back to the app directory. - let baseDir = path.join(appDir, "generated"); + let baseDir = path.join(appDir, `generated/${newConnectorYaml.connectorId}/kotlin`); for (const candidateSubdir of ["app/src/main/java", "app/src/main/kotlin"]) { const candidateDir = path.join(appDir, candidateSubdir); if (fs.existsSync(candidateDir)) { baseDir = candidateDir; } } - const outputDir = newConnectorYaml.generate.kotlinSdk?.outputDir || - path.relative(connectorInfo.directory, baseDir); + path.relative(connectorInfo.directory, path.join(appDir, baseDir)); const pkg = newConnectorYaml.generate.kotlinSdk?.package ?? `connectors.${snakeCase(connectorInfo.connectorYaml.connectorId)}`;