创建蓝图时如何覆盖needle API?

时间:2019-07-15 12:56:12

标签: jhipster

我实际上正在为JHipster设计.Net Core蓝图。文件树与Java版本不同,并且指针不再起作用。我需要覆盖针,以修改其中的路径。 如何使用蓝图的针而不是原始的针制作发生器?

我试图伸出针并修改其中的路径,但未将它们考虑在内。始终使用JHipster的针头。我还尝试查看了ViewJS和Kotlin等其他人如何解决该问题,但是没有人能解决问题。我还试图找到有关needle API的文档,但没有。

例如,不再在同一路径上生成客户的实体。因此,我尝试覆盖needle-client-angular.js。

const chalk = require('chalk');
const _ = require('lodash');
const needleClientAngular = require('generator-jhipster/generators/client/needle-api/needle-client-angular');
const constants = require('generator-jhipster/generators/generator-constants');
const dotnetConstants = require('../../generator-dotnetcore-constants');
const jhipsterUtils = require('generator-jhipster/generators/utils');
const toPascalCase = require('to-pascal-case');

const CLIENT_MAIN_SRC_DIR = `${dotnetConstants.SERVER_SRC_DIR}${toPascalCase(this.baseName)}/ClientApp`;

module.exports = class extends needleClientAngular {
    ...

    addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu) {
        const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
        const entityMenuPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`;
        const entityEntry =
            // prettier-ignore
            this.generator.stripMargin(`|<li>
                             |                        <a class="dropdown-item" routerLink="${routerName}" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }" (click)="collapseNavbar()">
                             |                            <fa-icon icon="asterisk" fixedWidth="true"></fa-icon>
                             |                            <span${enableTranslation ? ` jhiTranslate="global.menu.entities.${entityTranslationKeyMenu}"` : ''}>${_.startCase(routerName)}</span>
                             |                        </a>
                             |                    </li>`);
        const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-entity-to-menu', entityEntry);

        this.addBlockContentToFile(rewriteFileModel, errorMessage);
    }

    ...
}

当前,我收到此错误,证明未使用机针倍率:

  

找不到   src / main / webapp / app / layouts / navbar / navbar.component.html或缺少   所需的针刺针。未添加对银行帐户的引用   菜单

1 个答案:

答案 0 :(得分:0)

当前,我发现的唯一方法是将蓝图客户端子生成器的指针路径直接替换为generator-jhipster节点模块。我知道这不干净,但这不是优先事项,我们将来肯定会做得更好。

相关问题: https://github.com/jhipster/jhipster-dotnetcore/issues/11