perf: Add CrmServiceMap (#19718)

* Generate crm apps map

* Remove .tsx file

* Use `CrmServiceMap` in `getCrm`

* Remove unused types

* Type fixes

* Type fixes
This commit is contained in:
Joe Au-Yeung authored and GitHub committed 2025-03-05 14:58:02 -03:00
1 parent 44a6ceff3f
commit 07969f5287
9 files changed
+62 -13

No files matched your search

+20
View File
@@ -37,6 +37,7 @@ function generateFiles() {
const schemasOutput = [];
const appKeysSchemasOutput = [];
const serverOutput = [];
const crmOutput = [];
const appDirs: { name: string; path: string }[] = [];
fs.readdirSync(`${APP_STORE_PATH}`).forEach(function (dir) {
@@ -330,6 +331,20 @@ function generateFiles() {
})
);
crmOutput.push(
...getExportedObject(
"CrmServiceMap",
{
importConfig: {
fileToBeImported: "lib/CrmService.ts",
importName: "default",
},
lazyImport: true,
},
isCrmApp
)
);
const banner = `/**
This file is autogenerated using the command \`yarn app-store:build --watch\`.
Don't modify this file manually.
@@ -342,6 +357,7 @@ function generateFiles() {
["apps.schemas.generated.ts", schemasOutput],
["apps.keys-schemas.generated.ts", appKeysSchemasOutput],
["bookerApps.metadata.generated.ts", bookerMetadataOutput],
["crm.apps.generated.ts", crmOutput],
];
filesToGenerate.forEach(([fileName, output]) => {
fs.writeFileSync(`${APP_STORE_PATH}/${fileName}`, formatOutput(`${banner}${output.join("\n")}`));
@@ -385,3 +401,7 @@ function isBookerApp(app: App) {
// 2. It is a tag manager app(e.g. Google Analytics, GTM, Fathom)
return !!(app.appData?.location || app.appData?.tag);
}
function isCrmApp(app: App) {
return !!app.categories?.includes("crm");
}