Skip to content

Commit

Permalink
fix: improve import identifier uniqueness (#4437)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j authored Dec 13, 2024
1 parent bb1a258 commit 2e18a18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions packages/cli-plugin-extensions/src/extensions/ApiExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2e18a18

Please sign in to comment.