如何在创建蓝图时覆盖针API?

How to override the needle API when creating a blueprint?

我实际上正在为 JHipster 开发 .Net Core 蓝图。文件树与 Java 版本不同,针不再工作。我需要覆盖针以修改其中的路径。 如何使用蓝图的针而不是原来的针来制作发电机?

我试图延长针并修改其中的路径,但没有考虑到它们。 JHipster 的针总是被使用。我还尝试查看 ViewJS 和 Kotlin 等其他蓝图是如何解决这个问题的,但没有人可以超越针头。我也试图找到有关针 API 的文档,但有 none.

例如,客户端的实体不再在同一路径生成。所以我试图覆盖 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);
    }

    ...
}

目前,我得到这个错误,证明没有使用指针覆盖:

Unable to find src/main/webapp/app/layouts/navbar/navbar.component.html or missing required jhipster-needle. Reference to bank-account not added to the menu

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

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