Skip to content

Commit

Permalink
@comet/create-app remove-showcase: Improve and fix regex for content-…
Browse files Browse the repository at this point in the history
…removal (#159)

The regex is slightly changed in order to:

- Fix an issue, where too much content in "Routes.tsx" is deleted
- Avoid empty lines after the deletion of content
- Don't delete "ConfigModule, ConsoleModule" in "fixture.modules.ts" as
it is needed for an import in another module
  • Loading branch information
max-debug022 authored Feb 13, 2024
1 parent 9d9870f commit 1c3c64e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions create-app/src/scripts/remove-showcase/removeShowcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import { deleteFilesAndFolders } from "../../util/deleteFilesAndFolders";
async function removeFileContent() {
const contentToRemove: Array<{
file: string;
replacements: RegExp[];
replacements: Array<string | RegExp>;
}> = [
{
file: `./admin/src/Routes.tsx`,
replacements: [/<.*?products.*?>/gs],
replacements: [/\s*<.*?products.*?>/g],
},
{
file: `./admin/src/common/MasterMenu.tsx`,
replacements: [/<MenuItemRouterLink[ \n]*primary={intl.formatMessage\({ id: "comet.menu.products".*products`}[ \n]*\/>/gs],
replacements: [/\s*<MenuCollapsibleItem.*products`}\s*\/>\s*<\/MenuCollapsibleItem>/gs],
},
{
file: `./api/src/app.module.ts`,
replacements: [/ProductsModule,\n/gs],
replacements: [/\s*ProductsModule,/gs],
},
{
file: `./api/src/db/fixtures/fixtures.console.ts`,
replacements: [/constructor.*Product.*{}/gs, /await Promise.all\(\[generateProducts.*]\);/gs],
replacements: [/, @InjectRepository.*Product.*<Product>/gs, /\s*await Promise.all\(\[generateProducts.*]\);/gs],
},
{
file: `./api/src/db/fixtures/fixtures.module.ts`,
replacements: [/imports: \[MikroOrmModule.forFeature\(\[Product]\), ConfigModule, ConsoleModule],/gs],
replacements: ["MikroOrmModule.forFeature([Product]), "],
},
];
const eslint = new ESLint({
Expand Down

0 comments on commit 1c3c64e

Please sign in to comment.