Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
);
}
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
);
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);
}
}
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
);
}
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
);
}
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
);
}
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
);
}
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) {
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
);
}
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`,