Skip to content

Commit

Permalink
Included dart sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
maneesht committed Sep 23, 2024
1 parent 299c3df commit 184c38d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
13 changes: 2 additions & 11 deletions src/dataconnect/fileUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { getPlatformFromFolder, generateSdkYaml } from "./fileUtils";
import { ConnectorYaml, Platform } from "./types";
import * as mockfs from "mock-fs";
import FileSystem from "mock-fs/lib/filesystem";
import { isEnabled, setEnabled } from "../experiments";

describe("getPlatformFromFolder", () => {
const cases: {
desc: string;
folderName: string;
folderItems: FileSystem.DirectoryItems;
output: Platform;
enableDart?: boolean;
}[] = [
{
desc: "Empty folder",
Expand Down Expand Up @@ -94,7 +92,6 @@ describe("getPlatformFromFolder", () => {
file1: "contents",
"pubspec.yaml": "my deps",
},
enableDart: true,
output: Platform.DART,
},
{
Expand All @@ -103,16 +100,14 @@ describe("getPlatformFromFolder", () => {
folderItems: {
"pubspec.lock": "my deps",
},
enableDart: true,
output: Platform.DART,
},
{
desc: "Dart identifier with experiment disabled",
folderName: "is/this/a/dart/test",
folderItems: {
"pubspec.lock": "my deps",
"pubspec.mispelled": "my deps",
},
enableDart: false,
output: Platform.UNDETERMINED,
},
{
Expand All @@ -128,13 +123,9 @@ describe("getPlatformFromFolder", () => {
];
for (const c of cases) {
it(c.desc, async () => {
const wasEnabledBefore = isEnabled("fdcdart");
setEnabled("fdcdart", !!c.enableDart);
mockfs({ [c.folderName]: c.folderItems });
const platform = await getPlatformFromFolder(c.folderName);
expect(platform).to.equal(c.output);
// Reset experiment
setEnabled("fdcdart", wasEnabledBefore);
});
afterEach(() => {
mockfs.restore();
Expand Down Expand Up @@ -191,7 +182,7 @@ describe("generateSdkYaml", () => {
});
});

it("should add Dart SDK generation for DART platform when Dart is enabled", () => {
it("should add Dart SDK generation for DART platform", () => {
const modifiedYaml = generateSdkYaml(
Platform.DART,
sampleConnectorYaml,
Expand Down
2 changes: 0 additions & 2 deletions src/dataconnect/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { readFileFromDirectory, wrappedSafeLoad } from "../utils";
import { Config } from "../config";
import { DataConnectMultiple } from "../firebaseConfig";
import { load } from "./load";
import * as experiments from "../experiments";

export function readFirebaseJson(config?: Config): DataConnectMultiple {
if (!config?.has("dataconnect")) {
Expand Down Expand Up @@ -134,7 +133,6 @@ export async function getPlatformFromFolder(dirPath: string) {
IOS_INDICATORS.some((indicator) => indicator === cleanedFileName) ||
IOS_POSTFIX_INDICATORS.some((indicator) => cleanedFileName.endsWith(indicator));
hasDart ||=
experiments.isEnabled("fdcdart") &&
DART_INDICATORS.some((indicator) => indicator === cleanedFileName);
}
if (hasWeb && !hasAndroid && !hasIOS && !hasDart) {
Expand Down
5 changes: 2 additions & 3 deletions src/emulator/downloadableEmulators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ export const DownloadDetails: { [s in DownloadableEmulators]: EmulatorDownloadDe
cacheDir: CACHE_DIR,
remoteUrl:
process.platform === "darwin"
? `https://firebasestorage.googleapis.com/v0/b/getting-started-dart-storage.appspot.com/o/dart_emulator-2?alt=media&token=48694c1f-5458-4044-8361-44d0f37193ce`
? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
: process.platform === "win32"
? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
: `https://firebasestorage.googleapis.com/v0/b/getting-started-dart-storage.appspot.com/o/dart_emulator-3-linux.sh?alt=media&token=36d788ec-e366-4bcd-9aeb-fb2929ccfeab`,
: `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
expectedSize: EMULATOR_UPDATE_DETAILS.dataconnect.expectedSize,
expectedChecksum: EMULATOR_UPDATE_DETAILS.dataconnect.expectedChecksum,
skipChecksumAndSize: false,
Expand Down Expand Up @@ -295,7 +295,6 @@ const Commands: { [s in DownloadableEmulators]: DownloadableEmulatorCommand } =
"config_dir",
"enable_output_schema_extensions",
"enable_output_generated_sdk",
"enable_dart",
// Additional flags that CLI shouldn't pass:
// rpc_retry_count,
// resolvers_emulator,
Expand Down
6 changes: 0 additions & 6 deletions src/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ export const ALL_EXPERIMENTS = experiments({
fullDescription: "Enable Data Connect schema migrations in Compatible Mode",
public: false,
},
// TODO(mtewani): Remove when Dart SDK Generation is supported.
fdcdart: {
shortDescription: "Enable Data Connect Dart SDK Generation",
fullDescription: "Enable Data Connect Dart SDK Generation",
public: false,
},
});

export type ExperimentName = keyof typeof ALL_EXPERIMENTS;
Expand Down
4 changes: 1 addition & 3 deletions src/init/features/dataconnect/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ async function askQuestions(setup: Setup, config: Config): Promise<SDKInfo> {
{ name: "iOS (Swift)", value: Platform.IOS },
{ name: "Web (JavaScript)", value: Platform.WEB },
{ name: "Android (Kotlin)", value: Platform.ANDROID },
{ name: "Flutter (Dart)", value: Platform.DART },
];
if (experiments.isEnabled("fdcdart")) {
platforms.push({ name: "Flutter (Dart)", value: Platform.DART });
}
targetPlatform = await promptOnce({
message: "Which platform do you want to set up a generated SDK for?",
type: "list",
Expand Down

0 comments on commit 184c38d

Please sign in to comment.