diff --git a/packages/cli-plugin-extensions/src/extensions/AdminExtension.ts b/packages/cli-plugin-extensions/src/extensions/AdminExtension.ts index 75136f5e471..87575cfb6f7 100644 --- a/packages/cli-plugin-extensions/src/extensions/AdminExtension.ts +++ b/packages/cli-plugin-extensions/src/extensions/AdminExtension.ts @@ -5,6 +5,7 @@ import chalk from "chalk"; import { JsxFragment, Node, Project } from "ts-morph"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; import { updateDependencies, updateWorkspaces } from "~/utils"; +import Case from "case"; export class AdminExtension extends AbstractExtension { async link() { @@ -38,12 +39,10 @@ export class AdminExtension extends AbstractExtension { } private async addPluginToAdminApp() { - const { name, packageName } = this.params; - const extensionsFilePath = path.join("apps", "admin", "src", "Extensions.tsx"); - const ucFirstName = name.charAt(0).toUpperCase() + name.slice(1); - const componentName = ucFirstName + "Extension"; + const { packageName } = this.params; + const componentName = Case.pascal(packageName) + "Extension"; const importName = "{ Extension as " + componentName + " }"; const importPath = packageName; diff --git a/packages/cli-plugin-extensions/src/extensions/ApiExtension.ts b/packages/cli-plugin-extensions/src/extensions/ApiExtension.ts index 776374c84a8..35e6c269235 100644 --- a/packages/cli-plugin-extensions/src/extensions/ApiExtension.ts +++ b/packages/cli-plugin-extensions/src/extensions/ApiExtension.ts @@ -5,6 +5,7 @@ import chalk from "chalk"; import { ArrayLiteralExpression, Node, Project } from "ts-morph"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; import { updateDependencies, updateWorkspaces } from "~/utils"; +import Case from "case"; export class ApiExtension extends AbstractExtension { async link() { @@ -38,11 +39,11 @@ export class ApiExtension extends AbstractExtension { } private async addPluginToApiApp() { - const { name, packageName } = this.params; - const extensionsFilePath = path.join("apps", "api", "graphql", "src", "extensions.ts"); - const extensionFactory = name + "ExtensionFactory"; + const { packageName } = this.params; + const extensionFactory = Case.pascal(packageName) + "ExtensionFactory"; + const importName = "{ createExtension as " + extensionFactory + " }"; const importPath = packageName; diff --git a/packages/cli-plugin-extensions/src/extensions/PbElementExtension.ts b/packages/cli-plugin-extensions/src/extensions/PbElementExtension.ts index 9ca965948c5..0f7be7d90ce 100644 --- a/packages/cli-plugin-extensions/src/extensions/PbElementExtension.ts +++ b/packages/cli-plugin-extensions/src/extensions/PbElementExtension.ts @@ -5,6 +5,7 @@ import chalk from "chalk"; import { JsxFragment, Node, Project } from "ts-morph"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; import { updateDependencies, updateWorkspaces } from "~/utils"; +import Case from "case"; export class PbElementExtension extends AbstractExtension { async link() { @@ -46,12 +47,10 @@ export class PbElementExtension extends AbstractExtension { } private async addPluginToApp(app: "admin" | "website") { - const { name: extensionName, packageName } = this.params; - const extensionsFilePath = path.join("apps", app, "src", "Extensions.tsx"); - const ucFirstExtName = extensionName.charAt(0).toUpperCase() + extensionName.slice(1); - const componentName = ucFirstExtName + "Extension"; + const { packageName } = this.params; + const componentName = Case.pascal(packageName) + "Extension"; const importName = "{ Extension as " + componentName + " }"; const importPath = packageName + "/src/" + app; diff --git a/packages/cli-plugin-extensions/src/extensions/WebsiteExtension.ts b/packages/cli-plugin-extensions/src/extensions/WebsiteExtension.ts index 42326e3bb91..875d29f010f 100644 --- a/packages/cli-plugin-extensions/src/extensions/WebsiteExtension.ts +++ b/packages/cli-plugin-extensions/src/extensions/WebsiteExtension.ts @@ -5,6 +5,7 @@ import chalk from "chalk"; import { JsxFragment, Node, Project } from "ts-morph"; import { formatCode } from "@webiny/cli-plugin-scaffold/utils"; import { updateDependencies, updateWorkspaces } from "~/utils"; +import Case from "case"; export class WebsiteExtension extends AbstractExtension { async link() { @@ -38,12 +39,10 @@ export class WebsiteExtension extends AbstractExtension { } private async addPluginToWebsiteApp() { - const { name, packageName } = this.params; - const extensionsFilePath = path.join("apps", "website", "src", "Extensions.tsx"); - const ucFirstName = name.charAt(0).toUpperCase() + name.slice(1); - const componentName = ucFirstName + "Extension"; + const { packageName } = this.params; + const componentName = Case.pascal(packageName) + "Extension"; const importName = "{ Extension as " + componentName + " }"; const importPath = packageName;