How to use the generator-jhipster/generators/utils.rewriteFile function in generator-jhipster

To help you get started, we’ve selected a few generator-jhipster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhipster / jhipster-vuejs / generators / utils.js View on Github external
function addEntityServiceToMain(generator, entityName, className) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/main.ts`,
            needle: 'jhipster-needle-add-entity-service-to-main',
            splicable: [generator.stripMargin(
                // prettier-ignore
                `|    ${entityName}Service: () => new ${className}Service(),`
            )]
        },
        generator
    );
}
github jhipster / jhipster-vuejs / generators / utils.js View on Github external
function addPageToRouter(generator, pageName, pageFolderName) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/router/index.ts`,
            needle: 'jhipster-needle-add-entity-to-router',
            splicable: [generator.stripMargin(
                // prettier-ignore
                `|,
                |    {
                |      path: '/pages/${pageFolderName}',
                |      name: '${pageName}',
                |      component: ${pageName},
                |      meta: { authorities: ['ROLE_USER'] }
                |    }`
            )]
        },
        generator
    );
github bhangun / generator-jhipster-fx / generators / entity-client / index.js View on Github external
addEntityToDrawer(entityInstance, entityClass, entityAngularName, entityFolderName, entityFileName, enableTranslation) {
        // workaround method being called on initialization
        if (!entityClass) {
            return;
        }
        const entityPagePath = 'lib/widgets/drawer.dart';
        try {
            const page2 = `list.add(_listTitle("${entityClass}", context,"/${entityInstance}"));`;
            utils.rewriteFile({
                file: entityPagePath,
                needle: 'kutilang-needle-add-drawer',
                splicable: [
                    this.stripMargin(page2)
                ]
            }, this);
        } catch (e) {
            this.log(`${chalk.yellow('\nUnable to find ') + entityPagePath + chalk.yellow(' or missing required jhipster-needle. Reference to ') + entityClass} ${chalk.yellow(`not added to ${entityPagePath}.\n`)}`);
            this.debug('Error:', e);
        }
    }
github jhipster / jhipster-vuejs / generators / entity-client / utils.js View on Github external
function addEntityServiceToMainImport(generator, className, fileName, folderName) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/main.ts`,
            needle: 'jhipster-needle-add-entity-service-to-main-import',
            splicable: [generator.stripMargin(
                // prettier-ignore
                `|import ${className}Service from '@/entities/${folderName}/${fileName}.service';`
            )]
        },
        generator
    );
}
github jhipster / jhipster-vuejs / generators / entity-client / utils.js View on Github external
function addEntityToRouter(generator, entityName, entityFileName, className) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/router/index.ts`,
            needle: 'jhipster-needle-add-entity-to-router',
            splicable: [generator.stripMargin(
                // prettier-ignore
                `|,
                |  { path: '/entity/${entityFileName}', name: '${className}', component: ${className}, meta: { authorities: ['ROLE_USER'] } },
                |  { path: '/entity/${entityFileName}/new', name: '${className}Create', component: ${className}Update, meta: { authorities: ['ROLE_USER'] } },
                |  { path: '/entity/${entityFileName}/:${entityName}Id/edit', name: '${className}Edit', component: ${className}Update, meta: { authorities: ['ROLE_USER'] } },
                |  { path: '/entity/${entityFileName}/:${entityName}Id/view', name: '${className}View', component: ${className}Details, meta: { authorities: ['ROLE_USER'] } }`
            )]
        },
        generator
    );
}
github jhipster / jhipster-vuejs / generators / entity-client / utils.js View on Github external
function addEntityToMenu(generator, entityName, translationKey, className) {
    const menuI18nTitle = generator.enableTranslation ? `v-text="$t('global.menu.entities.${translationKey}')"` : '';
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/core/jhi-navbar/jhi-navbar.vue`,
            needle: 'jhipster-needle-add-entity-to-menu',
            splicable: [
                // prettier-ignore
                `
                    
                    <span>${className}</span>
              `
            ]
        },
        generator
    );
}
github jhipster / jhipster-vuejs / generators / entity-client / utils.js View on Github external
function addEntityToRouterImport(generator, className, fileName, folderName) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_MAIN_SRC_DIR}/app/router/index.ts`,
            needle: 'jhipster-needle-add-entity-to-router-import',
            splicable: [generator.stripMargin(
                // prettier-ignore
                `|// prettier-ignore
                |const ${className} = () => import('../entities/${folderName}/${fileName}.vue');
                |// prettier-ignore
                |const ${className}Update = () => import('../entities/${folderName}/${fileName}-update.vue');
                |// prettier-ignore
                |const ${className}Details = () => import('../entities/${folderName}/${fileName}-details.vue');`
            )]
        },
        generator
    );
}
github bhangun / generator-jhipster-fx / generators / entity-client / index.js View on Github external
addEntityToRoute(entityInstance, entityClass, entityAngularName, entityFolderName, entityFileName, enableTranslation) {
        // workaround method being called on initialization
        if (!entityClass) {
            return;
        }
        const entityPagePath = 'lib/services/routes.dart';
        try {
            const page2 = `import '../pages/${entityInstance}/${entityInstance}.list.dart';`;
            utils.rewriteFile({
                file: entityPagePath,
                needle: 'kutilang-needle-add-import-route',
                splicable: [
                    this.stripMargin(page2)
                ]
            }, this);

            const page = `"/${entityInstance}": (BuildContext context) => ${entityClass}ListPage(),`;
            utils.rewriteFile({
                file: entityPagePath,
                needle: 'kutilang-needle-add-route',
                splicable: [
                    this.stripMargin(page)
                ]
            }, this);
        } catch (e) {
github jhipster / jhipster-vuejs / generators / utils.js View on Github external
function addPageProtractorConf(generator, pageFolderName) {
    jhipsterUtils.rewriteFile(
        {
            file: `${CLIENT_TEST_SRC_DIR}/protractor.conf.js`,
            needle: 'jhipster-needle-add-protractor-tests',
            splicable: [generator.stripMargin('\'./e2e/pages/**/*.spec.ts\',')]
        },
        generator
    );
}
github contribution-jhipster-uga / generator-jhipster-angular-material-integration / generators / app / index.js View on Github external
jhipsterUtils.rewriteFile({
                file: `${webappDir}app/app.module.ts`,
                needle: 'jhipster-needle-angular-add-module-import',
                splicable: [`import { BrowserAnimationsModule } from '@angular/platform-browser/animations';`]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}app/app.module.ts`,
                needle: 'jhipster-needle-angular-add-module-import',
                splicable: [`import {FlexLayoutModule} from '@angular/flex-layout';`]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}app/app.module.ts`,
                needle: 'jhipster-needle-angular-add-module-import',
                splicable: [`import 'hammerjs';`]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}content/scss/vendor.scss`,
                needle: 'jhipster-needle-scss-add-vendor',
                splicable: [`@import "~@angular/material/prebuilt-themes/indigo-pink.css";`]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}app/shared/shared.module.ts`,
                needle: '@NgModule({',
                splicable: [`import {JhMaterialModule} from 'app/shared/jh-material.module';`]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}index.html`,
                needle: 'jhipster-needle-add-resources-to-root',
                splicable: [``]
            }, this);
            jhipsterUtils.rewriteFile({
                file: `${webappDir}app/shared/shared-libs.module.ts`,

generator-jhipster

Spring Boot + Angular/React/Vue in one handy generator

Apache-2.0
Latest version published 26 days ago

Package Health Score

89 / 100
Full package analysis