Skip to content

Commit b2a998d

Browse files
authored
Refactor dataconnect to use the common appUtils models (#9286)
* Refactor dataconnect to use the common appUtils models * Print all platforms in the init prompt * Respond to more code review comments
1 parent 1a5e085 commit b2a998d

File tree

12 files changed

+635
-361
lines changed

12 files changed

+635
-361
lines changed

src/appUtils.spec.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,27 @@ describe("appUtils", () => {
615615
{
616616
platform: Platform.WEB,
617617
directory: ".",
618-
frameworks: ["REACT"],
618+
frameworks: ["react"],
619+
},
620+
]);
621+
});
622+
623+
it("should detect angular web framework", async () => {
624+
mockfs({
625+
[testDir]: {
626+
"package.json": JSON.stringify({
627+
dependencies: {
628+
"@angular/core": "1.0.0",
629+
},
630+
}),
631+
},
632+
});
633+
const apps = cleanUndefinedFields(await detectApps(testDir));
634+
expect(apps).to.have.deep.members([
635+
{
636+
platform: Platform.WEB,
637+
directory: ".",
638+
frameworks: ["angular"],
619639
},
620640
]);
621641
});
@@ -635,7 +655,7 @@ describe("appUtils", () => {
635655
{
636656
platform: Platform.WEB,
637657
directory: ".",
638-
frameworks: ["REACT"],
658+
frameworks: ["react"],
639659
},
640660
]);
641661
});
@@ -655,7 +675,7 @@ describe("appUtils", () => {
655675
{
656676
platform: Platform.WEB,
657677
directory: ".",
658-
frameworks: ["ANGULAR"],
678+
frameworks: ["angular"],
659679
},
660680
]);
661681
});

src/appUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export enum Platform {
1717
* Supported web frameworks.
1818
*/
1919
export enum Framework {
20-
REACT = "REACT",
21-
ANGULAR = "ANGULAR",
20+
REACT = "react",
21+
ANGULAR = "angular",
2222
}
2323

2424
interface AppIdentifier {
@@ -176,8 +176,8 @@ async function packageJsonToWebApp(dirPath: string, packageJsonFile: string): Pr
176176

177177
const WEB_FRAMEWORKS: Framework[] = Object.values(Framework);
178178
const WEB_FRAMEWORKS_SIGNALS: { [key in Framework]: string[] } = {
179-
REACT: ["react", "next"],
180-
ANGULAR: ["@angular/core"],
179+
react: ["react", "next"],
180+
angular: ["@angular/core"],
181181
};
182182

183183
async function detectAppIdsForPlatform(

src/commands/apps-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { requireAuth } from "../requireAuth";
1717
import { logger } from "../logger";
1818
import { Options } from "../options";
1919
import { needProjectId } from "../projectUtils";
20-
import { Platform } from "../dataconnect/types";
20+
import { Platform } from "../appUtils";
2121
import { assertEnabled } from "../experiments";
2222

2323
export interface AppsInitOptions extends Options {

src/dataconnect/appFinder.spec.ts

Lines changed: 0 additions & 179 deletions
This file was deleted.

src/dataconnect/appFinder.ts

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/dataconnect/types.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ export interface SupportedFrameworks {
153153
angular?: boolean;
154154
}
155155

156-
export type Framework = keyof SupportedFrameworks;
157-
158156
export interface JavascriptSDK extends SupportedFrameworks {
159157
outputDir: string;
160158
package: string;
@@ -174,15 +172,6 @@ export interface DartSDK {
174172
package: string;
175173
}
176174

177-
export enum Platform {
178-
NONE = "NONE",
179-
ANDROID = "ANDROID",
180-
WEB = "WEB",
181-
IOS = "IOS",
182-
FLUTTER = "FLUTTER",
183-
MULTIPLE = "MULTIPLE",
184-
}
185-
186175
// Helper types && converters
187176
export interface ServiceInfo {
188177
serviceName: string;

0 commit comments

Comments
 (0)